[asterisk-commits] trunk r29708 - in /trunk: channels/chan_jingle.c res/res_jabber.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue May 23 09:43:59 MST 2006


Author: mogorman
Date: Tue May 23 11:43:58 2006
New Revision: 29708

URL: http://svn.digium.com/view/asterisk?rev=29708&view=rev
Log:
finish cleaning up some more stuff before russell
gets a chance to.

Modified:
    trunk/channels/chan_jingle.c
    trunk/res/res_jabber.c

Modified: trunk/channels/chan_jingle.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_jingle.c?rev=29708&r1=29707&r2=29708&view=diff
==============================================================================
--- trunk/channels/chan_jingle.c (original)
+++ trunk/channels/chan_jingle.c Tue May 23 11:43:58 2006
@@ -184,8 +184,6 @@
 	.capabilities = ((AST_FORMAT_MAX_AUDIO << 1) - 1),
 	.requester = jingle_request,
 	.send_digit = jingle_digit,
-//  .devicestate = jingle_devicestate,
-//  .transfer = jingle_transfer,
 	.bridge = ast_rtp_bridge,
 	.call = jingle_call,
 	.hangup = jingle_hangup,
@@ -255,7 +253,6 @@
 
 static void add_codec_to_answer(const struct jingle_pvt *p, int codec, iks *dcodecs)
 {
-	ast_verbose("Adding codec 0x%x (%s) to SDP\n", codec, ast_getformatname(codec));
 	if (!strcasecmp("ulaw", ast_getformatname(codec))) {
 		iks *payload_eg711u, *payload_pcmu;
 		payload_pcmu = iks_new("payload-type");
@@ -267,7 +264,7 @@
 		iks_insert_attrib(payload_eg711u, "name", "EG711U");
 		iks_insert_attrib(payload_eg711u, "xmlns", "http://www.google.com/session/phone");
 		iks_insert_node(dcodecs, payload_pcmu);
-	//	iks_insert_node(dcodecs, payload_eg711u);
+		iks_insert_node(dcodecs, payload_eg711u);
 	}
 	if (!strcasecmp("alaw", ast_getformatname(codec))) {
 		iks *payload_eg711a, *payload_pcma;
@@ -347,14 +344,12 @@
 
 
 		iks_insert_attrib(iq, "type", "set");
-		//      iks_insert_attrib(iq,"from",client->connection->jid->full);
 		iks_insert_attrib(iq, "to", (p->from) ? p->from : client->user);
 		iks_insert_attrib(iq, "id", client->connection->mid);
 		ast_aji_increment_mid(client->connection->mid);
 
 		iks_insert_attrib(jingle, "xmlns", "http://www.google.com/session");
 		iks_insert_attrib(jingle, "type", JINGLE_ACCEPT);
-		ast_verbose("WOOH %d\n", p->initiator);
 		iks_insert_attrib(jingle, "initiator",
 						  p->initiator ? client->connection->jid->full : p->from);
 		iks_insert_attrib(jingle, GOOGLE_SID, tmp->sid);
@@ -489,7 +484,6 @@
 	tmp = client->p;
 	/* Make sure our new call doesn't exist yet */
 	while (tmp) {
-		ast_verbose("FFFFF %s\n", tmp->sid);
 		if (iks_find_with_attrib(pak->x, GOOGLE_NODE, GOOGLE_SID, tmp->sid)) {
 			break;
 		}
@@ -525,7 +519,6 @@
 	} else
 		ast_log(LOG_NOTICE, "Whoa, didn't find call!\n");
 	jingle_response(client, pak, NULL);
-	ast_verbose("END CALL\n");
 	return 1;
 }
 
@@ -537,7 +530,6 @@
 	struct sockaddr_in sin;
 	struct sockaddr_in dest;
 	struct in_addr us;
-	char iabuf[INET_ADDRSTRLEN];
 
 	iks *iq, *jingle, *candidate;
 	char user[17], pass[17], preference[5], port[7];
@@ -602,10 +594,9 @@
 		ours2 = NULL;
 	}
 	ours1 = NULL;
-	dest.sin_addr = __ourip;	/// THIS IS BAD NEED TO FIX
+	dest.sin_addr = __ourip;
 	dest.sin_port = sin.sin_port;
 
-	ast_verbose("We're at %s port %d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), us), ntohs(sin.sin_port));	/// THIS IS BAD NEED TO FIX
 
 	tmp = p->ourcandidates;
 	while (tmp) {				/*send standard candidates */
@@ -666,19 +657,15 @@
 
 	ast_log(LOG_DEBUG, "The client is %s for alloc\n", client->name);
 	if (!sid && !strchr(from, '/')) {	/*I started call! */
-		ast_verbose("shouldnt be called on inbound!\n");
 		if (!strcasecmp(client->name, "guest")) {
 			buddy = ASTOBJ_CONTAINER_FIND(&client->connection->buddies, from);
 			if (buddy)
 				resources = buddy->resources;
-			ast_verbose("shouldnt be called on inbound! %s ----- %s ---- %s\n",
-						client->name, from, buddy->name);
 		} else {
 			resources = client->buddy->resources;
 		}
 		while (resources) {
 			if (resources->cap->jingle) {
-				ast_verbose("WOW FOUND\n");
 				break;
 			}
 			resources = resources->next;
@@ -841,25 +828,6 @@
 	}
 }
 
-static struct jingle_candidate *jingle_dup_candidates(struct jingle_candidate *candidate)
-{
-	struct jingle_candidate *newcan = NULL, *prev = NULL, *tmp;
-	while (candidate) {
-		tmp = malloc(sizeof(struct jingle_candidate));
-		if (tmp) {
-			memcpy(tmp, candidate, sizeof(struct jingle_candidate));
-			tmp->next = NULL;
-			if (prev)
-				prev->next = tmp;
-			else
-				newcan = tmp;
-			prev = tmp;
-		}
-		candidate = candidate->next;
-	}
-	return newcan;
-}
-
 static void jingle_free_pvt(struct jingle *client, struct jingle_pvt *p)
 {
 	struct jingle_pvt *cur, *prev = NULL;
@@ -924,7 +892,6 @@
 			ast_rtp_set_m_type(p->rtp, atoi(iks_find_attrib(codec, "id")));
 			ast_rtp_set_rtpmap_type(p->rtp, atoi(iks_find_attrib(codec, "id")), "audio",
 									iks_find_attrib(codec, "name"));
-			ast_verbose("yatta!!\n");
 			codec = iks_next(codec);
 		}
 		
@@ -1003,20 +970,16 @@
 	}
 
 	if (!p) {
-		ast_verbose("NO MATCH\n");
 		return -1;
 	}
 
 	traversenodes = pak->query;
 	while(traversenodes) {
-		ast_verbose("OOH %s\n", iks_name(traversenodes));
 		if(!strcasecmp(iks_name(traversenodes), "session")) {
-			ast_verbose("XXXX OOH A SESSION\n");
 			traversenodes = iks_child(traversenodes);
 			continue;
 		}
 		if(!strcasecmp(iks_name(traversenodes), "candidate")) {
-			ast_verbose("XXXX OOH A CANDIDATE\n");
 			newcandidate =
 				(struct jingle_candidate *) ast_calloc(1, sizeof(struct jingle_candidate));
 			if (!newcandidate)
@@ -1227,14 +1190,13 @@
 	iks_delete(payload_pcmu);
 	return 0;
 }
-
+/* Not in use right now.
 static int jingle_auto_congest(void *nothing)
 {
 	struct jingle_pvt *p = nothing;
 
 	ast_mutex_lock(&p->lock);
 	if (p->owner) {
-		/* XXX fails on possible deadlock */
 		if (!ast_channel_trylock(p->owner)) {
 			ast_log(LOG_NOTICE, "Auto-congesting %s\n", p->owner->name);
 			ast_queue_control(p->owner, AST_CONTROL_CONGESTION);
@@ -1244,6 +1206,7 @@
 	ast_mutex_unlock(&p->lock);
 	return 0;
 }
+*/
 
 /*! \brief Initiate new call, part of PBX interface 
  * 	dest is the dial string */
@@ -1315,7 +1278,6 @@
 			}
 		}
 	}
-	ast_verbose("to : %s\n from :%s\n", to, sender);
 	client = find_jingle(to, sender);
 	if (!client) {
 		ast_log(LOG_WARNING, "Could not find Recipiant.\n");
@@ -1361,20 +1323,11 @@
 	return RESULT_SUCCESS;
 }
 #endif
-static char show_jingle_usage[] =
-	"Usage: jingle show channels\n"
-	"       Provides summary information on active jingle channels.\n";
-
-//static struct ast_cli_entry cli_show_jingle = {
-//  { "jingle", "show", "channels", NULL }, jingle_show, 
-//  "Show status of jingle channels", show_jingle_usage, NULL };
-
 
 static int jingle_parser(void *data, ikspak *pak)
 {
 	struct jingle *client = ASTOBJ_REF((struct jingle *) data);
 
-	ast_verbose("WOOHOO!!!\n");
 	if (iks_find_with_attrib(pak->x, GOOGLE_NODE, "type", JINGLE_INITIATE)) {
 		/* New call */
 		jingle_newcall(client, pak);
@@ -1385,16 +1338,14 @@
 	} else if (iks_find_with_attrib(pak->x, GOOGLE_NODE, "type", GOOGLE_ACCEPT)) {
 		jingle_is_answered(client, pak);
 	} else if (iks_find_with_attrib(pak->x, GOOGLE_NODE, "type", "terminate")) {
-		ast_verbose("not this\n");
 		jingle_hangup_farend(client, pak);
 	} else if (iks_find_with_attrib(pak->x, GOOGLE_NODE, "type", "reject")) {
-		ast_verbose("not this\n");
 		jingle_hangup_farend(client, pak);
 	}
 	ASTOBJ_UNREF(client, jingle_member_destroy);
 	return IKS_FILTER_EAT;
 }
-
+/* Not using this anymore probably take out soon 
 static struct jingle_candidate *jingle_create_candidate(char *args)
 {
 	char *name, *type, *preference, *protocol;
@@ -1440,7 +1391,7 @@
 
 	return res;
 }
-
+*/
 static int jingle_create_member(char *label, struct ast_variable *var, int allowguest,
 								struct ast_codec_pref prefs, char *context,
 								struct jingle *member)
@@ -1494,8 +1445,6 @@
 	else {
 		ast_log(LOG_ERROR, "No Connection or Username!\n");
 	}
-	ast_verbose("LABEL: %s\n member->name %s\n member->user %s\n", label, member->name,
-				member->user);
 	return 1;
 }
 
@@ -1552,9 +1501,6 @@
 				ast_copy_string(member->user, "guest", sizeof(member->user));
 				ast_copy_string(member->context, context, sizeof(member->context));
 				member->allowguest = allowguest;
-#if 0
-				member->ourcandidates = jingle_dup_candidates(global_candidates);
-#endif
 				member->prefs = prefs;
 				while (var) {
 					if (!strcasecmp(var->name, "disallow"))
@@ -1596,7 +1542,6 @@
 				}
 			} else {
 				if (jingle_create_member(cat, var, allowguest, prefs, context, member)) {
-					ast_verbose("step member\n");
 					ASTOBJ_UNLOCK(member);
 					ASTOBJ_CONTAINER_LINK(&jingles, member);
 					ASTOBJ_UNREF(member, jingle_member_destroy);
@@ -1615,7 +1560,6 @@
 /*! \brief Load module into PBX, register channel */
 static int load_module(void *mod)
 {
-	ast_verbose("step 1\n");
 	ASTOBJ_CONTAINER_INIT(&jingles);
 	if (!jingle_load_config()) {
 		ast_log(LOG_ERROR, "Unable to read config file %s\n", JINGLE_CONFIG);
@@ -1645,7 +1589,6 @@
 		ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
 		return -1;
 	}
-//  ast_cli_register(&cli_show_xmpps);
 	return 0;
 }
 
@@ -1658,27 +1601,30 @@
 /*! \brief Unload the jingle channel from Asterisk */
 static int unload_module(void *mod)
 {
-//  struct jingle_pvt *p = NULL;
-	struct aji_client *client = NULL;
-	client = ast_aji_get_client("asterisk");
+	struct jingle_pvt *privates = NULL;
 	/* First, take us out of the channel loop */
-//  ast_cli_unregister(&cli_show_xmpps);
 	ast_channel_unregister(&jingle_tech);
 	ast_rtp_proto_unregister(&jingle_rtp);
 	if (!ast_mutex_lock(&jinglelock)) {
 		/* Hangup all interfaces if they have an owner */
-		//  p = jingles->p;
-		//  while(p) {
-		//      if (p->owner)
-		//          ast_softhangup(p->owner, AST_SOFTHANGUP_APPUNLOAD);
-		//      p = p->next;
-		//  }
-		//  jingles->p = NULL;
+		ASTOBJ_CONTAINER_TRAVERSE(&jingles, 1, {
+			ASTOBJ_WRLOCK(iterator);
+			privates = iterator->p;
+			while(privates) {
+			    if (privates->owner)
+			        ast_softhangup(privates->owner, AST_SOFTHANGUP_APPUNLOAD);
+			    privates = privates->next;
+			}
+			iterator->p = NULL;
+			ASTOBJ_UNLOCK(iterator);
+		});
 		ast_mutex_unlock(&jinglelock);
 	} else {
 		ast_log(LOG_WARNING, "Unable to lock the monitor\n");
 		return -1;
 	}
+	ASTOBJ_CONTAINER_DESTROYALL(&jingles, jingle_member_destroy);
+	ASTOBJ_CONTAINER_DESTROY(&jingles);
 	return 0;
 }
 

Modified: trunk/res/res_jabber.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_jabber.c?rev=29708&r1=29707&r2=29708&view=diff
==============================================================================
--- trunk/res/res_jabber.c (original)
+++ trunk/res/res_jabber.c Tue May 23 11:43:58 2006
@@ -286,7 +286,6 @@
 		char sidpass[100];
 		snprintf(sidpass, sizeof(sidpass), "%s%s", sid, pass);
 		ast_sha1_hash(buf, sidpass);
-		ast_verbose("\n");
 		iks_insert_cdata(iks_insert(y, "digest"), buf, 0);
 	} else {
 		iks_insert_cdata(iks_insert(y, "password"), pass, 0);
@@ -820,7 +819,6 @@
 
 	if (pak->subtype == IKS_TYPE_RESULT) {
 		if (iks_find_with_attrib(pak->query, "feature", "var", "http://www.google.com/xmpp/protocol/voice/v1")) {
-			ast_verbose("NO I AM JINGLECAPABLE!!!\n");
 			resource->cap->jingle = 1;
 		} else
 			resource->cap->jingle = 0;
@@ -1034,7 +1032,6 @@
 			tmp->status = status;
 			found = tmp;
 			if (status == 6) {	/* Sign off Destroy resource */
-				ast_verbose("KILL THE SIGN OFF!\n");
 				if (last && found->next) {
 					last->next = found->next;
 				} else if (!last) {
@@ -1149,38 +1146,39 @@
 				iks_delete(iq);
 		}
 	}
-	
-	switch (pak->subtype) {
-	case IKS_TYPE_AVAILABLE:
-		ast_verbose(VERBOSE_PREFIX_3 "JABBER: I am available ^_* %i\n", pak->subtype);
-		break;
-	case IKS_TYPE_UNAVAILABLE:
-		ast_verbose(VERBOSE_PREFIX_3 "JABBER: I am unavailable ^_* %i\n", pak->subtype);
-		break;
-	default:
-		ast_verbose(VERBOSE_PREFIX_3 "JABBER: Ohh sexy and the wrong type%i\n", pak->subtype);
-	}
-	switch (pak->show) {
-	case IKS_SHOW_UNAVAILABLE:
-		ast_verbose(VERBOSE_PREFIX_3 "JABBER: type: %i subtype %i\n", pak->subtype, pak->show);
-		break;
-	case IKS_SHOW_AVAILABLE:
-		ast_verbose(VERBOSE_PREFIX_3 "JABBER: type is available\n");
-		break;
-	case IKS_SHOW_CHAT:
-		ast_verbose(VERBOSE_PREFIX_3 "JABBER: type: %i subtype %i\n", pak->subtype, pak->show);
-		break;
-	case IKS_SHOW_AWAY:
-		ast_verbose(VERBOSE_PREFIX_3 "JABBER: type is away\n");
-		break;
-	case IKS_SHOW_XA:
-		ast_verbose(VERBOSE_PREFIX_3 "JABBER: type: %i subtype %i\n", pak->subtype, pak->show);
-		break;
-	case IKS_SHOW_DND:
-		ast_verbose(VERBOSE_PREFIX_3 "JABBER: type: %i subtype %i\n", pak->subtype, pak->show);
-		break;
-	default:
-		ast_verbose(VERBOSE_PREFIX_3 "JABBER: Kinky! how did that happen %i\n", pak->show);
+	if (option_verbose > 30) {
+		switch (pak->subtype) {
+		case IKS_TYPE_AVAILABLE:
+			ast_verbose(VERBOSE_PREFIX_3 "JABBER: I am available ^_* %i\n", pak->subtype);
+			break;
+		case IKS_TYPE_UNAVAILABLE:
+			ast_verbose(VERBOSE_PREFIX_3 "JABBER: I am unavailable ^_* %i\n", pak->subtype);
+			break;
+		default:
+			ast_verbose(VERBOSE_PREFIX_3 "JABBER: Ohh sexy and the wrong type%i\n", pak->subtype);
+		}
+		switch (pak->show) {
+		case IKS_SHOW_UNAVAILABLE:
+			ast_verbose(VERBOSE_PREFIX_3 "JABBER: type: %i subtype %i\n", pak->subtype, pak->show);
+			break;
+		case IKS_SHOW_AVAILABLE:
+			ast_verbose(VERBOSE_PREFIX_3 "JABBER: type is available\n");
+			break;
+		case IKS_SHOW_CHAT:
+			ast_verbose(VERBOSE_PREFIX_3 "JABBER: type: %i subtype %i\n", pak->subtype, pak->show);
+			break;
+		case IKS_SHOW_AWAY:
+			ast_verbose(VERBOSE_PREFIX_3 "JABBER: type is away\n");
+			break;
+		case IKS_SHOW_XA:
+			ast_verbose(VERBOSE_PREFIX_3 "JABBER: type: %i subtype %i\n", pak->subtype, pak->show);
+			break;
+		case IKS_SHOW_DND:
+			ast_verbose(VERBOSE_PREFIX_3 "JABBER: type: %i subtype %i\n", pak->subtype, pak->show);
+			break;
+		default:
+			ast_verbose(VERBOSE_PREFIX_3 "JABBER: Kinky! how did that happen %i\n", pak->show);
+		}
 	}
 }
 
@@ -1191,29 +1189,26 @@
  */
 static void aji_handle_subscribe(struct aji_client *client, ikspak *pak)
 {
-	int res = 0;
-	switch (pak->subtype) {
-	case IKS_TYPE_SUBSCRIBE:
-		res = iks_send(client->p, iks_make_s10n(IKS_TYPE_SUBSCRIBED, iks_find_attrib(pak->x, "from"), "Asterisk has approved subscription"));
-		if (option_verbose > 30)
+	if(pak->subtype == IKS_TYPE_SUBSCRIBE)
+		iks_send(client->p, iks_make_s10n(IKS_TYPE_SUBSCRIBED, iks_find_attrib(pak->x, "from"), "Asterisk has approved subscription"));
+	if (option_verbose > 30) {
+		switch (pak->subtype) {
+		case IKS_TYPE_SUBSCRIBE:
 			ast_verbose(VERBOSE_PREFIX_3 "JABBER: This is a subcription of type %i\n", pak->subtype);
-		break;
-	case IKS_TYPE_SUBSCRIBED:
-		if (option_verbose > 30)
+			break;
+		case IKS_TYPE_SUBSCRIBED:
 			ast_verbose(VERBOSE_PREFIX_3 "JABBER: This is a subcription of type %i\n", pak->subtype);
-		break;
-	case IKS_TYPE_UNSUBSCRIBE:
-		if (option_verbose > 30)
+			break;
+		case IKS_TYPE_UNSUBSCRIBE:
 			ast_verbose(VERBOSE_PREFIX_3 "JABBER: This is a subcription of type %i\n", pak->subtype);
-		break;
-	case IKS_TYPE_UNSUBSCRIBED:
-		if (option_verbose > 30)
+			break;
+		case IKS_TYPE_UNSUBSCRIBED:
 			ast_verbose(VERBOSE_PREFIX_3 "JABBER: This is a subcription of type %i\n", pak->subtype);
-		break;
-	default:					/*IKS_TYPE_ERROR: */
-		if (option_verbose > 30)
+			break;
+		default:				/*IKS_TYPE_ERROR: */
 			ast_verbose(VERBOSE_PREFIX_3 "JABBER: This is a subcription of type %i\n", pak->subtype);
-		break;
+			break;
+		}
 	}
 }
 
@@ -1353,7 +1348,7 @@
 		}
 
 		if (res != IKS_OK) {
-			ast_verbose("reconnecting %d\n", res);
+			if(option_verbose > 3) ast_verbose("JABBER: reconnecting %d\n", res);
 			aji_reconnect(client);
 			res = IKS_OK;
 		}
@@ -1904,7 +1899,6 @@
 	int flag = 0;
 	client = ASTOBJ_CONTAINER_FIND(&clients,label);
 	if(!client) {
-		ast_verbose("CLIENT NOT FOUND!\n");
 		flag = 1;
 		client = (struct aji_client *) malloc(sizeof(struct aji_client));
 		if(client) {
@@ -1936,7 +1930,6 @@
 	client->usesasl = 0;
 	if (flag) client->state = AJI_DISCONNECTED;
 	while (var) {
-		ast_verbose("var->value: %s\n",var->value);
 		if (!strcasecmp(var->name, "username"))
 			ast_copy_string(client->user, var->value, sizeof(client->user));
 		else if (!strcasecmp(var->name, "serverhost"))
@@ -1952,10 +1945,8 @@
 				client->component = AJI_COMPONENT;
 		} else if (!strcasecmp(var->name, "usetls")) {
 			client->usetls = (ast_false(var->value)) ? 0 : 1;
-			ast_verbose("USETLS = %d\n",client->usetls);
 		} else if (!strcasecmp(var->name, "usesasl")) {
 			client->usesasl = (ast_false(var->value)) ? 0 : 1;
-			ast_verbose("USESASL = %d\n",client->usesasl);
 		} else if (!strcasecmp(var->name, "forceoldssl"))
 			client->forcessl = (ast_false(var->value)) ? 0 : 1;
 		else if (!strcasecmp(var->name, "keepalive"))



More information about the asterisk-commits mailing list