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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Oct 14 14:54:56 CDT 2010


Author: dvossel
Date: Thu Oct 14 14:54:53 2010
New Revision: 291825

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=291825
Log:
Remove client specific code, we can treat all clients the same at this point

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=291825&r1=291824&r2=291825
==============================================================================
--- team/dvossel/gtalk_fixup/channels/chan_gtalk.c (original)
+++ team/dvossel/gtalk_fixup/channels/chan_gtalk.c Thu Oct 14 14:54:53 2010
@@ -100,14 +100,6 @@
 	AJI_CONNECT_RELAY = 3,
 };
 
-enum gtalk_client_type {
-	AJI_CLIENT_UNKNOWN,
-	AJI_CLIENT_GTALK,		/*!< Remote client type is GoogleTalk */
-	AJI_CLIENT_GMAIL,		/*!< Remote client type is Gmail */
-	AJI_CLIENT_GOOGLE_VOICE,/*!< Remote client type is Google Voice*/
-
-};
-
 struct gtalk_pvt {
 	ast_mutex_t lock;                /*!< Channel private lock */
 	time_t laststun;
@@ -118,7 +110,6 @@
 	char ring[10];                   /*!< Message ID of ring */
 	iksrule *ringrule;               /*!< Rule for matching RING request */
 	int initiator;                   /*!< If we're the initiator */
-	enum gtalk_client_type ctype;
 	int alreadygone;
 	int capability;
 	struct ast_codec_pref prefs;
@@ -452,9 +443,6 @@
 	iks_insert_attrib(gtalk, "id", sid);
 	iks_insert_node(iq, gtalk);
 	iks_insert_node(gtalk, dcodecs);
-	if (p->ctype != AJI_CLIENT_GOOGLE_VOICE) {
-		iks_insert_node(gtalk, transport);
-	}
 	iks_insert_node(dcodecs, payload_telephone);
 
 	ast_aji_send(client->connection, iq);
@@ -465,49 +453,6 @@
 	iks_delete(gtalk);
 	iks_delete(iq);
 	return 1;
-}
-
-static int gtalk_invite_response(struct gtalk_pvt *p, char *to , char *from, char *sid, int initiator)
-{
-	iks *iq, *session, *transport;
-	char *lowerto = NULL;
-
-	iq = iks_new("iq");
-	session = iks_new("session");
-	transport = iks_new("transport");
-	if(!(iq && session && transport)) {
-		iks_delete(iq);
-		iks_delete(session);
-		iks_delete(transport);
-		ast_log(LOG_ERROR, " Unable to allocate IKS node\n");
-		return -1;
-	}
-	iks_insert_attrib(iq, "from", from);
-	iks_insert_attrib(iq, "to", to);
-	iks_insert_attrib(iq, "type", "set");
-	iks_insert_attrib(iq, "id",p->parent->connection->mid);
-	ast_aji_increment_mid(p->parent->connection->mid);
-	iks_insert_attrib(session, "type", "transport-accept");
-	iks_insert_attrib(session, "id", sid);
-	/* put the initiator attribute to lower case if we receive the call
-	 * otherwise GoogleTalk won't establish the session */
-	if (!initiator) {
-	        char c;
-		char *t = lowerto = ast_strdupa(to);
-		while (((c = *t) != '/') && (*t++ = tolower(c)));
-	}
-	iks_insert_attrib(session, "initiator", initiator ? from : lowerto);
-	iks_insert_attrib(session, "xmlns", GOOGLE_NS);
-	iks_insert_attrib(transport, "xmlns", GOOGLE_TRANSPORT_NS);
-	iks_insert_node(iq,session);
-	iks_insert_node(session,transport);
-	ast_aji_send(p->parent->connection, iq);
-
-	iks_delete(transport);
-	iks_delete(session);
-	iks_delete(iq);
-	return 1;
-
 }
 
 static int gtalk_ringing_ack(void *data, ikspak *pak)
@@ -865,13 +810,8 @@
 
 	iks_insert_attrib(transport, "xmlns",GOOGLE_TRANSPORT_NS);
 	iks_insert_node(iq, gtalk);
-
-	if (p->ctype == AJI_CLIENT_GMAIL) {
-		iks_insert_node(gtalk,candidate);
-	} else {
-		iks_insert_node(gtalk,candidate);
-		iks_insert_node(gtalk,transport);
-	}
+	iks_insert_node(gtalk,candidate);
+	iks_insert_node(gtalk,transport);
 
 	for (; p; p = p->next) {
 		if (!strcasecmp(p->sid, sid))
@@ -934,18 +874,7 @@
 		iks_insert_attrib(iq, "type", "set");
 		iks_insert_attrib(iq, "id", c->mid);
 		ast_aji_increment_mid(c->mid);
-		switch (p->ctype) {
-		case AJI_CLIENT_GTALK:
-			iks_insert_attrib(gtalk, "type", "transport-info");
-			break;
-		case AJI_CLIENT_GMAIL:
-			iks_insert_attrib(gtalk, "type", "candidates");
-			break;
-		default:
-			ast_log(LOG_WARNING, "Client type is unknown\n");
-			iks_insert_attrib(gtalk, "type", "candidates");
-			break;
-		}
+		iks_insert_attrib(gtalk, "type", "candidates");
 		iks_insert_attrib(gtalk, "id", sid);
 		/* put the initiator attribute to lower case if we receive the call
 		 * otherwise GoogleTalk won't establish the session */
@@ -999,7 +928,6 @@
 	char idroster[200];
 	char *data, *exten = NULL;
 	struct ast_sockaddr bindaddr_tmp;
-	enum gtalk_client_type ctype = AJI_CLIENT_UNKNOWN;
 
 	ast_debug(1, "The client is %s for alloc\n", client->name);
 	if (!sid && !strchr(them, '/')) {	/* I started call! */
@@ -1020,12 +948,8 @@
 		}
 		if (resources) {
 			snprintf(idroster, sizeof(idroster), "%s/%s", them, resources->resource);
-			if (strstr(resources->resource, "gmail")) {
-				ctype = AJI_CLIENT_GMAIL;
-			}
 		} else if ((*them == '+') || (strstr(them, "@voice.google.com"))) {
 			snprintf(idroster, sizeof(idroster), "%s/srvres", them);
-			ctype = AJI_CLIENT_GOOGLE_VOICE;
 		} else {
 			ast_log(LOG_ERROR, "no gtalk capable clients to talk to.\n");
 			return NULL;
@@ -1034,8 +958,6 @@
 	if (!(tmp = ast_calloc(1, sizeof(*tmp)))) {
 		return NULL;
 	}
-	/* set client type to unknown until we have more info */
-	tmp->ctype = ctype;
 
 	memcpy(&tmp->prefs, &client->prefs, sizeof(struct ast_codec_pref));
 
@@ -1064,10 +986,11 @@
 	ast_rtp_codecs_payloads_clear(ast_rtp_instance_get_codecs(tmp->rtp), tmp->rtp);
 
 	/* add user configured codec capabilites */
-	if (client->capability)
+	if (client->capability) {
 		tmp->capability = client->capability;
-	else if (global_capability)
+	} else if (global_capability) {
 		tmp->capability = global_capability;
+	}
 
 	tmp->parent = client;
 	if (!tmp->rtp) {
@@ -1082,8 +1005,9 @@
 	if(strchr(tmp->us, '/')) {
 		data = ast_strdupa(tmp->us);
 		exten = strsep(&data, "/");
-	} else
+	} else {
 		exten = tmp->us;
+	}
 	ast_copy_string(tmp->exten,  exten, sizeof(tmp->exten));
 	ast_mutex_init(&tmp->lock);
 	ast_mutex_lock(&gtalklock);
@@ -1308,14 +1232,6 @@
 		return -1;
 	}
 
-	/* if the node name of the query contains a semicolon, the remote peer
-	 * is a gmail type client. If not, treat it as a regular GoogleTalk
-	 * client */
-	if (strchr(iks_name(pak->query), ':')) {
-		p->ctype = AJI_CLIENT_GMAIL;
-	} else {
-		p->ctype = AJI_CLIENT_GTALK;
-	}
 	chan = gtalk_new(client, p, AST_STATE_DOWN, pak->from->user, NULL);
 	if (!chan) {
 		gtalk_free_pvt(client, p);
@@ -1377,9 +1293,6 @@
 		break;
 	case AST_PBX_SUCCESS:
 		gtalk_response(client, from, pak, NULL, NULL);
-		if (p->ctype == AJI_CLIENT_GTALK) {
-			gtalk_invite_response(p, p->them, p->us,p->sid, 0);
-		}
 		gtalk_create_candidates(client, p, p->sid, p->them, p->us);
 		/* nothing to do */
 		break;




More information about the asterisk-commits mailing list