[asterisk-commits] dvossel: branch dvossel/gtalk_fixup r291191 - /team/dvossel/gtalk_fixup/chann...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Oct 11 16:06:00 CDT 2010


Author: dvossel
Date: Mon Oct 11 16:05:58 2010
New Revision: 291191

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=291191
Log:
code tweaking and guideline cleanup

Modified:
    team/dvossel/gtalk_fixup/channels/chan_gtalk.c

Modified: team/dvossel/gtalk_fixup/channels/chan_gtalk.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/gtalk_fixup/channels/chan_gtalk.c?view=diff&rev=291191&r1=291190&r2=291191
==============================================================================
--- team/dvossel/gtalk_fixup/channels/chan_gtalk.c (original)
+++ team/dvossel/gtalk_fixup/channels/chan_gtalk.c Mon Oct 11 16:05:58 2010
@@ -198,6 +198,7 @@
 static int gtalk_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
 static int gtalk_sendhtml(struct ast_channel *ast, int subclass, const char *data, int datalen);
 static struct gtalk_pvt *gtalk_alloc(struct gtalk *client, const char *us, const char *them, const char *sid);
+static int gtalk_update_stun(struct gtalk *client, struct gtalk_pvt *p);
 /* static char *gtalk_do_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); */
 static char *gtalk_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
 static int gtalk_update_externip(void);
@@ -638,7 +639,7 @@
 		}
 	}
 
-	if (tmp == 0) {
+	if (!tmp) {
 		ast_log(LOG_WARNING, "Could not find session in iq\n");
 		return -1;
 	}
@@ -669,14 +670,14 @@
 	}
 
 	from = iks_find_attrib(pak->x, "to");
-	if(!from)
+	if (!from) {
 		from = client->connection->jid->full;
-
-	if (tmp) {
-		if (tmp->owner)
-			ast_queue_control(tmp->owner, AST_CONTROL_ANSWER);
-	} else
-		ast_log(LOG_NOTICE, "Whoa, didn't find call!\n");
+	}
+
+	if (tmp->owner) {
+		ast_queue_control(tmp->owner, AST_CONTROL_ANSWER);
+	}
+	gtalk_update_stun(tmp->parent, tmp);
 	gtalk_response(client, from, pak, NULL, NULL);
 	return 1;
 }
@@ -689,16 +690,21 @@
 	ast_log(LOG_DEBUG, "The client is %s\n", client->name);
 	/* find corresponding call */
 	for (tmp = client->p; tmp; tmp = tmp->next) {
-		if (iks_find_with_attrib(pak->x, "session", "id", tmp->sid))
+		if (iks_find_with_attrib(pak->x, "session", "id", tmp->sid)) {
 			break;
+		}
 	}
 
 	from = iks_find_attrib(pak->x, "to");
-	if(!from)
+	if (!from) {
 		from = client->connection->jid->full;
-
-	if (!tmp)
-		ast_log(LOG_NOTICE, "Whoa, didn't find call!\n");
+	}
+
+	if (tmp) {
+		gtalk_update_stun(tmp->parent, tmp);
+	} else {
+		ast_log(LOG_NOTICE, "Whoa, didn't find call during accept?!\n");
+	}
 
 	/* answer 'iq' packet to let the remote peer know that we're alive */
 	gtalk_response(client, from, pak, NULL, NULL);
@@ -717,9 +723,9 @@
 			break;
 	}
 	from = iks_find_attrib(pak->x, "to");
-	if(!from)
+	if (!from) {
 		from = client->connection->jid->full;
-
+	}
 
 	if (tmp) {
 		if(iks_find_with_attrib(pak->x, "dtmf-method", "method", "rtp")) {
@@ -766,8 +772,9 @@
 		}
 		gtalk_response(client, from, pak, NULL, NULL);
 		return 1;
-	} else
+	} else {
 		ast_log(LOG_NOTICE, "Whoa, didn't find call!\n");
+	}
 
 	gtalk_response(client, from, pak, NULL, NULL);
 	return 1;
@@ -785,15 +792,18 @@
 			break;
 	}
 	from = iks_find_attrib(pak->x, "to");
-	if(!from)
+	if (!from) {
 		from = client->connection->jid->full;
+	}
 
 	if (tmp) {
 		tmp->alreadygone = 1;
-		if (tmp->owner)
+		if (tmp->owner) {
 			ast_queue_hangup(tmp->owner);
-	} else
-		ast_log(LOG_NOTICE, "Whoa, didn't find call!\n");
+		}
+	} else {
+		ast_log(LOG_NOTICE, "Whoa, didn't find call during hangup!\n");
+	}
 	gtalk_response(client, from, pak, NULL, NULL);
 	return 1;
 }
@@ -1232,7 +1242,7 @@
 
 	/* Make sure our new call doesn't exist yet */
 	from = iks_find_attrib(pak->x,"to");
-	if(!from) {
+	if (!from) {
 		from = client->connection->jid->full;
 	}
 
@@ -1407,8 +1417,8 @@
 		ast_sockaddr_to_sin(&aux_tmp, &aux);
 
 		/* If the STUN result is different from the IP of the hostname,
-			lock on the stun IP of the hostname advertised by the
-			remote client */
+		 * lock on the stun IP of the hostname advertised by the
+		 * remote client */
 		if (aux.sin_addr.s_addr && (aux.sin_addr.s_addr != sin.sin_addr.s_addr)) {
 			ast_rtp_instance_stun_request(p->rtp, &aux_tmp, username);
 		} else {
@@ -1434,8 +1444,9 @@
 	char *from;
 
 	from = iks_find_attrib(pak->x,"to");
-	if(!from)
+	if (!from) {
 		from = c->jid->full;
+	}
 
 	for (tmp = client->p; tmp; tmp = tmp->next) {
 		if (iks_find_with_attrib(pak->x, "session", "id", tmp->sid) || !strcmp(iks_find_attrib(pak->query, "id"), tmp->sid)) {
@@ -1531,11 +1542,11 @@
 				ast_set_read_format(p->owner, p->owner->readformat);
 				ast_set_write_format(p->owner, p->owner->writeformat);
 			}
-/*			if ((ast_test_flag(p, SIP_DTMF) == SIP_DTMF_INBAND) && p->vad) {
+			/* if ((ast_test_flag(p, SIP_DTMF) == SIP_DTMF_INBAND) && p->vad) {
 				f = ast_dsp_process(p->owner, p->vad, f);
 				if (option_debug && f && (f->frametype == AST_FRAME_DTMF))
 					ast_debug(1, "* Detected inband DTMF '%c'\n", f->subclass);
-		        } */
+	        } */
 		}
 	}
 	return f;
@@ -1803,8 +1814,9 @@
 	client = p->parent;
 	p->owner = NULL;
 	ast->tech_pvt = NULL;
-	if (!p->alreadygone)
+	if (!p->alreadygone) {
 		gtalk_action(client, p, "terminate");
+	}
 	ast_mutex_unlock(&p->lock);
 
 	gtalk_free_pvt(client, p);
@@ -1977,53 +1989,6 @@
 	return IKS_FILTER_EAT;
 }
 
-/* Not using this anymore probably take out soon 
-static struct gtalk_candidate *gtalk_create_candidate(char *args)
-{
-	char *name, *type, *preference, *protocol;
-	struct gtalk_candidate *res;
-	res = ast_calloc(1, sizeof(*res));
-	if (args)
-		name = args;
-	if ((args = strchr(args, ','))) {
-		*args = '\0';
-		args++;
-		preference = args;
-	}
-	if ((args = strchr(args, ','))) {
-		*args = '\0';
-		args++;
-		protocol = args;
-	}
-	if ((args = strchr(args, ','))) {
-		*args = '\0';
-		args++;
-		type = args;
-	}
-	if (name)
-		ast_copy_string(res->name, name, sizeof(res->name));
-	if (preference) {
-		res->preference = atof(preference);
-	}
-	if (protocol) {
-		if (!strcasecmp("udp", protocol))
-			res->protocol = AJI_PROTOCOL_UDP;
-		if (!strcasecmp("ssltcp", protocol))
-			res->protocol = AJI_PROTOCOL_SSLTCP;
-	}
-	if (type) {
-		if (!strcasecmp("stun", type))
-			res->type = AJI_CONNECT_STUN;
-		if (!strcasecmp("local", type))
-			res->type = AJI_CONNECT_LOCAL;
-		if (!strcasecmp("relay", type))
-			res->type = AJI_CONNECT_RELAY;
-	}
-
-	return res;
-}
-*/
-
 static int gtalk_create_member(char *label, struct ast_variable *var, int allowguest,
 								struct ast_codec_pref prefs, char *context,
 								struct gtalk *member)
@@ -2039,9 +2004,6 @@
 	member->allowguest = allowguest;
 	member->prefs = prefs;
 	while (var) {
-#if 0
-		struct gtalk_candidate *candidate = NULL;
-#endif
 		if (!strcasecmp(var->name, "username"))
 			ast_copy_string(member->user, var->value, sizeof(member->user));
 		else if (!strcasecmp(var->name, "disallow"))
@@ -2052,15 +2014,6 @@
 			ast_copy_string(member->context, var->value, sizeof(member->context));
 		else if (!strcasecmp(var->name, "parkinglot"))
 			ast_copy_string(member->parkinglot, var->value, sizeof(member->parkinglot));
-#if 0
-		else if (!strcasecmp(var->name, "candidate")) {
-			candidate = gtalk_create_candidate(var->value);
-			if (candidate) {
-				candidate->next = member->ourcandidates;
-				member->ourcandidates = candidate;
-			}
-		}
-#endif
 		else if (!strcasecmp(var->name, "connection")) {
 			if ((client = ast_aji_get_client(var->value))) {
 				member->connection = client;
@@ -2069,7 +2022,6 @@
 						    IKS_RULE_FROM_PARTIAL, member->user,
 						    IKS_RULE_NS, GOOGLE_NS,
 						    IKS_RULE_DONE);
-
 			} else {
 				ast_log(LOG_ERROR, "connection referenced not found!\n");
 				return 0;
@@ -2145,17 +2097,6 @@
 				ast_log(LOG_WARNING, "Invalid STUN server address: %s\n", var->value);
 			}
 		}
-
-/*  Idea to allow for custom candidates  */
-/*
-		else if (!strcasecmp(var->name, "candidate")) {
-			candidate = gtalk_create_candidate(var->value);
-			if (candidate) {
-				candidate->next = global_candidates;
-				global_candidates = candidate;
-			}
-		}
-*/
 	}
 	while (cat) {
 		if (strcasecmp(cat, "general")) {
@@ -2171,28 +2112,19 @@
 				member->allowguest = allowguest;
 				member->prefs = prefs;
 				while (var) {
-					if (!strcasecmp(var->name, "disallow"))
+					if (!strcasecmp(var->name, "disallow")) {
 						ast_parse_allow_disallow(&member->prefs, &member->capability,
 												 var->value, 0);
-					else if (!strcasecmp(var->name, "allow"))
+					} else if (!strcasecmp(var->name, "allow")) {
 						ast_parse_allow_disallow(&member->prefs, &member->capability,
 												 var->value, 1);
-					else if (!strcasecmp(var->name, "context"))
+					} else if (!strcasecmp(var->name, "context")) {
 						ast_copy_string(member->context, var->value,
 										sizeof(member->context));
-					else if (!strcasecmp(var->name, "parkinglot"))
+					} else if (!strcasecmp(var->name, "parkinglot")) {
 						ast_copy_string(member->parkinglot, var->value,
 										sizeof(member->parkinglot));
-/*  Idea to allow for custom candidates  */
-/*
-					else if (!strcasecmp(var->name, "candidate")) {
-						candidate = gtalk_create_candidate(var->value);
-						if (candidate) {
-							candidate->next = member->ourcandidates;
-							member->ourcandidates = candidate;
-						}
 					}
-*/
 					var = var->next;
 				}
 				ASTOBJ_UNLOCK(member);




More information about the asterisk-commits mailing list