[asterisk-commits] branch mogorman/asterisk-xmpp r9210 - in /team/mogorman/asterisk-xmpp: channe...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Feb 7 23:00:48 MST 2006


Author: mogorman
Date: Wed Feb  8 00:00:47 2006
New Revision: 9210

URL: http://svn.digium.com/view/asterisk?rev=9210&view=rev
Log:
goodnight moon

Modified:
    team/mogorman/asterisk-xmpp/channels/chan_xmpp.c
    team/mogorman/asterisk-xmpp/include/asterisk/xmpp.h
    team/mogorman/asterisk-xmpp/res/res_xmpp.c

Modified: team/mogorman/asterisk-xmpp/channels/chan_xmpp.c
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-xmpp/channels/chan_xmpp.c?rev=9210&r1=9209&r2=9210&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/channels/chan_xmpp.c (original)
+++ team/mogorman/asterisk-xmpp/channels/chan_xmpp.c Wed Feb  8 00:00:47 2006
@@ -105,60 +105,7 @@
 	.send_html = xmpp_sendhtml,
 };
 
-static struct xmpp_pvt {
-	ast_mutex_t lock;			/* Channel private lock */
-//	int reqformat;				/* Requested format */
-//	int glaredetect;			/* Detect glare on hangup */
-//	int cancelqueue;			/* Cancel queue */
-//	int alreadymasqed;			/* Already masqueraded */
-//	int launchedpbx;			/* Did we launch the PBX */
-//	int nooptimization;			/* Don't leave masq state */
-	char sid[100];
-	char from[100];
-//	AST_DECLARE_STRING_FIELDS(
-//		AST_STRING_FIELD(callid);	/*!< Global CallID */
-//		AST_STRING_FIELD(randdata);	/*!< Random data */
-//		AST_STRING_FIELD(accountcode);	/*!< Account code */
-//		AST_STRING_FIELD(realm);	/*!< Authorization realm */
-//		AST_STRING_FIELD(nonce);	/*!< Authorization nonce */
-//		AST_STRING_FIELD(opaque);	/*!< Opaque nonsense */
-//		AST_STRING_FIELD(qop);		/*!< Quality of Protection, since SIP wasn't complicated enough yet. */
-//		AST_STRING_FIELD(domain);	/*!< Authorization domain */
-//		AST_STRING_FIELD(refer_to);	/*!< Place to store REFER-TO extension */
-//		AST_STRING_FIELD(referred_by);	/*!< Place to store REFERRED-BY extension */
-//		AST_STRING_FIELD(refer_contact);/*!< Place to store Contact info from a REFER extension */
-//		AST_STRING_FIELD(useragent);	/*!< User agent in SIP request */
-//		AST_STRING_FIELD(exten);	/*!< Extension where to start */
-//		AST_STRING_FIELD(context);	/*!< Context for this call */
-//		AST_STRING_FIELD(subscribecontext); /*!< Subscribecontext */
-//		AST_STRING_FIELD(fromdomain);	/*!< Domain to show in the from field */
-//		AST_STRING_FIELD(fromuser);	/*!< User to show in the user field */
-//		AST_STRING_FIELD(fromname);	/*!< Name to show in the user field */
-//		AST_STRING_FIELD(tohost);	/*!< Host we should put in the "to" field */
-//		AST_STRING_FIELD(language);	/*!< Default language for this call */
-//		AST_STRING_FIELD(musicclass);	/*!< Music on Hold class */
-//		AST_STRING_FIELD(rdnis);	/*!< Referring DNIS */
-//		AST_STRING_FIELD(theirtag);	/*!< Their tag */
-//		AST_STRING_FIELD(username);	/*!< [user] name */
-//		AST_STRING_FIELD(peername);	/*!< [peer] name, not set if [user] */
-//		AST_STRING_FIELD(authname);	/*!< Who we use for authentication */
-//		AST_STRING_FIELD(uri);		/*!< Original requested URI */
-//		AST_STRING_FIELD(okcontacturi);	/*!< URI from the 200 OK on INVITE */
-//		AST_STRING_FIELD(peersecret);	/*!< Password */
-//		AST_STRING_FIELD(peermd5secret);
-//		AST_STRING_FIELD(cid_num);	/*!< Caller*ID */
-//		AST_STRING_FIELD(cid_name);	/*!< Caller*ID */
-//		AST_STRING_FIELD(via);		/*!< Via: header */
-//		AST_STRING_FIELD(fullcontact);	/*!< The Contact: that the UA registers with us */
-//		AST_STRING_FIELD(our_contact);	/*!< Our contact header */
-//		AST_STRING_FIELD(rpid);		/*!< Our RPID header */
-//		AST_STRING_FIELD(rpid_from);	/*!< Our RPID From header */
-//	);
-	struct axi_candidate *candidates;
-	struct ast_channel *owner;		/* Master Channel */
-	struct xmpp_pvt *next;			/* Next entity */
-
-} *xmpps = NULL;
+
 int flipflop = 0;
 static struct xmpp_pvt *xmpp_alloc(char *data, int format);
 
@@ -213,17 +160,13 @@
 static int xmpp_answer(struct ast_channel *ast)
 {
 	struct xmpp_pvt *p = ast->tech_pvt;
-	int isoutbound;
+	int isoutbound =1;
 	int res = -1;
 
 	ast_mutex_lock(&p->lock);
-//	isoutbound = IS_OUTBOUND(ast, p);
-	if (isoutbound) {
-		// Pass along answer since somebody answered us 
-		struct ast_frame answer = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER };
-		res = xmpp_queue_frame(p, isoutbound, &answer, ast);
-	} else
-		ast_log(LOG_WARNING, "Huh?  Local is being asked to answer?\n");
+	// Pass along answer since somebody answered us 
+	struct ast_frame answer = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER };
+	res = xmpp_queue_frame(p, isoutbound, &answer, ast);
 	ast_mutex_unlock(&p->lock);
 	return res;
 }
@@ -299,7 +242,7 @@
 
 static int xmpp_accept_call(struct axi_client *client, ikspak *pak)
 {
-	struct xmpp_pvt *tmp = xmpps;
+	struct xmpp_pvt *tmp = client->xmpps;
 	iks *iq, *jingle;
 	while(tmp) {
 		if(!strcasecmp(tmp->sid,iks_find_attrib(pak->query,GOOGLE_SID))) {
@@ -324,9 +267,26 @@
 	}
 	return 1;
 }
+
+static struct xmpp_pvt *xmpp_alloc2(struct axi_client *client)
+{
+	struct xmpp_pvt *tmp;
+
+	if (!(tmp = ast_calloc(1, sizeof(*tmp)))) {
+		return NULL;
+	}
+	
+	ast_mutex_init(&tmp->lock);
+	ast_mutex_lock(&xmpplock);
+	tmp->next = client->xmpps;
+	client->xmpps = tmp;
+	ast_mutex_unlock(&xmpplock);
+	return tmp;
+}
+
 static int xmpp_answer2(struct axi_client *client,ikspak *pak)
 {
-	struct xmpp_pvt *p ,*tmp = xmpps;
+	struct xmpp_pvt *p ,*tmp = client->xmpps;
 	iks *accept;
 	char *data = "1234 at local";
 	while(tmp) {
@@ -336,7 +296,7 @@
 		}
 		tmp=tmp->next;
 	}
-	p = xmpp_alloc(data, 1);
+	p = xmpp_alloc2(client);
 	ast_mutex_lock(&p->lock);
 	if(iks_find_attrib(pak->x,JINGLE_FROM))
 		ast_copy_string(p->from,iks_find_attrib(pak->x,JINGLE_FROM),sizeof(p->from));
@@ -357,7 +317,7 @@
 
 static int xmpp_add_candidate(struct axi_client *client,ikspak *pak)
 {
-	struct xmpp_pvt *p =NULL,*tmp = xmpps;
+	struct xmpp_pvt *p =NULL,*tmp = client->xmpps;
 	struct axi_candidate *newcandidate = NULL, *tmpcan = NULL;
 	iks *candidate_node = NULL;
 	iks *receipt = NULL;
@@ -552,13 +512,13 @@
 {
 	struct xmpp_pvt *cur, *prev = NULL;
 	ast_mutex_lock(&xmpplock);
-	cur = xmpps;
+	cur = client->xmpps;
 	while(cur) {
 		if (cur == p) {
 			if (prev)
 				prev->next = cur->next;
 			else
-				xmpps = cur->next;
+				client->xmpps = cur->next;
 			ast_mutex_destroy(cur);
 			free(cur);
 			break;
@@ -576,6 +536,8 @@
 static int xmpp_hangup(struct ast_channel *ast)
 {
 	struct xmpp_pvt *p = ast->tech_pvt;
+	struct axi_client *client = NULL;
+	client = ast_axi_get_client("asterisk");
 	int isoutbound;
 //	struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP };
 	struct xmpp_pvt *cur, *prev=NULL;
@@ -609,13 +571,13 @@
 		ast_mutex_unlock(&p->lock);
 		/* Remove from list */
 		ast_mutex_lock(&xmpplock);
-		cur = xmpps;
+		cur = client->xmpps;
 		while(cur) {
 			if (cur == p) {
 				if (prev)
 					prev->next = cur->next;
 				else
-					xmpps = cur->next;
+					client->xmpps = cur->next;
 				break;
 			}
 			prev = cur;
@@ -647,19 +609,10 @@
 static struct xmpp_pvt *xmpp_alloc(char *data, int format)
 {
 	struct xmpp_pvt *tmp;
-	char *c;
-	char *opts;
 
 	if (!(tmp = ast_calloc(1, sizeof(*tmp)))) {
 		return NULL;
 	}
-	
-	ast_mutex_init(&tmp->lock);
-//	strncpy(tmp->exten, data, sizeof(tmp->exten) - 1);
-	ast_mutex_lock(&xmpplock);
-	tmp->next = xmpps;
-	xmpps = tmp;
-	ast_mutex_unlock(&xmpplock);
 	return tmp;
 }
 
@@ -694,10 +647,13 @@
 {
 	struct xmpp_pvt *p;
 	struct axi_candidate *tmp;
+	struct axi_client *client = NULL;
+	client = ast_axi_get_client("asterisk");
 	if (argc != 3)
 		return RESULT_SHOWUSAGE;
 	ast_mutex_lock(&xmpplock);
-	p = xmpps;
+	if(client)
+		p = client->xmpps;
 	while(p) {
 		ast_mutex_lock(&p->lock);
 		ast_cli(fd, "SID = %s\n",p->sid );
@@ -709,7 +665,7 @@
 		ast_mutex_unlock(&p->lock);
 		p = p->next;
 	}
-	if (!xmpps)
+	if (!client->xmpps)
 		ast_cli(fd, "No xmpp channels in use\n");
 	ast_mutex_unlock(&xmpplock);
 	return RESULT_SUCCESS;
@@ -767,19 +723,20 @@
 int unload_module()
 {
 	struct xmpp_pvt *p;
-
+	struct axi_client *client = NULL;
+	client = ast_axi_get_client("asterisk");
 	/* First, take us out of the channel loop */
 	ast_cli_unregister(&cli_show_xmpps);
 	ast_channel_unregister(&xmpp_tech);
 	if (!ast_mutex_lock(&xmpplock)) {
 		/* Hangup all interfaces if they have an owner */
-		p = xmpps;
+		p = client->xmpps;
 		while(p) {
 			if (p->owner)
 				ast_softhangup(p->owner, AST_SOFTHANGUP_APPUNLOAD);
 			p = p->next;
 		}
-		xmpps = NULL;
+		client->xmpps = NULL;
 		ast_mutex_unlock(&xmpplock);
 	} else {
 		ast_log(LOG_WARNING, "Unable to lock the monitor\n");

Modified: team/mogorman/asterisk-xmpp/include/asterisk/xmpp.h
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-xmpp/include/asterisk/xmpp.h?rev=9210&r1=9209&r2=9210&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/include/asterisk/xmpp.h (original)
+++ team/mogorman/asterisk-xmpp/include/asterisk/xmpp.h Wed Feb  8 00:00:47 2006
@@ -88,6 +88,16 @@
 	ASTOBJ_CONTAINER_COMPONENTS(struct axi_transport);
 };
 
+struct xmpp_pvt {
+	ast_mutex_t lock;			/* Channel private lock */
+	char sid[100];
+	char from[100];
+	struct axi_candidate *candidates;
+	struct ast_channel *owner;		/* Master Channel */
+	struct xmpp_pvt *next;			/* Next entity */
+
+};
+
 struct axi_client {
 	ASTOBJ_COMPONENTS(struct axi_client);
 	char password[160];
@@ -115,6 +125,7 @@
 	enum axi_type component;
 	struct axi_buddy_container buddies;
 	struct axi_candidate *candidates;
+	struct xmpp_pvt *xmpps;
 	pthread_t thread;
 };
 
@@ -155,6 +166,7 @@
 int ast_axi_create_chat(struct axi_client *client,char *room, char *server, char *topic);
 int ast_axi_invite_chat(struct axi_client *client, char *user, char *room, char *message);
 int ast_axi_join_chat(struct axi_client *client,char *room);
+struct axi_client *ast_axi_get_client(char *name);
 
 /* Jingle Constants */
 

Modified: team/mogorman/asterisk-xmpp/res/res_xmpp.c
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-xmpp/res/res_xmpp.c?rev=9210&r1=9209&r2=9210&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/res/res_xmpp.c (original)
+++ team/mogorman/asterisk-xmpp/res/res_xmpp.c Wed Feb  8 00:00:47 2006
@@ -1363,6 +1363,13 @@
 	return 1;
 }
 
+struct axi_client *ast_axi_get_client(char *name)
+{
+	struct axi_client *client = NULL;
+	client = ASTOBJ_CONTAINER_FIND(&clients,name);
+	return client;
+}
+
 int unload_module(void)
 {
 	ast_uninstall_xmpp_functions();



More information about the asterisk-commits mailing list