[asterisk-commits] phsultan: trunk r82310 - in /trunk: ./ channels/chan_gtalk.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Sep 13 06:54:56 CDT 2007


Author: phsultan
Date: Thu Sep 13 06:54:56 2007
New Revision: 82310

URL: http://svn.digium.com/view/asterisk?view=rev&rev=82310
Log:
Merged revisions 82309 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r82309 | phsultan | 2007-09-13 13:47:14 +0200 (Thu, 13 Sep 2007) | 4 lines

Closes issue #9401, reported and patched by irrot, with slight
modifications by me.

Handle DTMF sent by Asterisk properly.
........

Modified:
    trunk/   (props changed)
    trunk/channels/chan_gtalk.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/channels/chan_gtalk.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_gtalk.c?view=diff&rev=82310&r1=82309&r2=82310
==============================================================================
--- trunk/channels/chan_gtalk.c (original)
+++ trunk/channels/chan_gtalk.c Thu Sep 13 06:54:56 2007
@@ -649,12 +649,12 @@
 static int gtalk_handle_dtmf(struct gtalk *client, ikspak *pak)
 {
 	struct gtalk_pvt *tmp;
-	iks *dtmfnode = NULL;
+	iks *dtmfnode = NULL, *dtmfchild = NULL;
 	char *dtmf;
 	char *from;
 	/* Make sure our new call doesn't exist yet */
 	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) || iks_find_with_attrib(pak->x, "gtalk", "sid", tmp->sid))
 			break;
 	}
 	from = iks_find_attrib(pak->x, "to");
@@ -688,6 +688,22 @@
 					ast_verbose("GOOGLE! DTMF-relay event received: %c\n", f.subclass);
 				}
 			}
+		} else if ((dtmfnode = iks_find_with_attrib(pak->x, "gtalk", "action", "session-info"))) {
+			if((dtmfchild = iks_find(dtmfnode, "dtmf"))) {
+				if((dtmf = iks_find_attrib(dtmfchild, "code"))) {
+					if(iks_find_with_attrib(dtmfnode, "dtmf", "action", "button-up")) {
+						struct ast_frame f = {AST_FRAME_DTMF_END, };
+						f.subclass = dtmf[0];
+						ast_queue_frame(tmp->owner, &f);
+						ast_verbose("GOOGLE! DTMF-relay event received: %c\n", f.subclass);
+					} else if(iks_find_with_attrib(dtmfnode, "dtmf", "action", "button-down")) {
+						struct ast_frame f = {AST_FRAME_DTMF_BEGIN, };
+						f.subclass = dtmf[0];
+						ast_queue_frame(tmp->owner, &f);
+						ast_verbose("GOOGLE! DTMF-relay event received: %c\n", f.subclass);
+					}
+				}
+			}
 		}
 		gtalk_response(client, from, pak, NULL, NULL);
 		return 1;
@@ -697,7 +713,6 @@
 	gtalk_response(client, from, pak, NULL, NULL);
 	return 1;
 }
-
 
 static int gtalk_hangup_farend(struct gtalk *client, ikspak *pak)
 {
@@ -1438,7 +1453,7 @@
 	iks_insert_attrib(iq, "id", client->connection->mid);
 	ast_aji_increment_mid(client->connection->mid);
 	iks_insert_attrib(gtalk, "xmlns", "http://jabber.org/protocol/gtalk");
-	iks_insert_attrib(gtalk, "action", "content-info");
+	iks_insert_attrib(gtalk, "action", "session-info");
 	iks_insert_attrib(gtalk, "initiator", p->initiator ? p->us: p->them);
 	iks_insert_attrib(gtalk, "sid", p->sid);
 	iks_insert_attrib(dtmf, "xmlns", "http://jabber.org/protocol/gtalk/info/dtmf");
@@ -1447,9 +1462,9 @@
 	iks_insert_node(gtalk, dtmf);
 
 	ast_mutex_lock(&p->lock);
-	if (ast->dtmff.frametype == AST_FRAME_DTMF_BEGIN) {
+	if (ast->dtmff.frametype == AST_FRAME_DTMF_BEGIN || duration == 0) {
 		iks_insert_attrib(dtmf, "action", "button-down");
-	} else if (ast->dtmff.frametype == AST_FRAME_DTMF_END) {
+	} else if (ast->dtmff.frametype == AST_FRAME_DTMF_END || duration != 0) {
 		iks_insert_attrib(dtmf, "action", "button-up");
 	}
 	iks_send(client->connection->p, iq);
@@ -1640,7 +1655,7 @@
 		gtalk_is_answered(client, pak);
 	} else if (iks_find_with_attrib(pak->x, "session", "type", "transport-accept")) {
 		gtalk_is_accepted(client, pak);
-	} else if (iks_find_with_attrib(pak->x, "session", "type", "content-info")) {
+	} else if (iks_find_with_attrib(pak->x, "session", "type", "content-info") || iks_find_with_attrib(pak->x, "gtalk", "action", "session-info")) {
 		gtalk_handle_dtmf(client, pak);
 	} else if (iks_find_with_attrib(pak->x, "session", "type", "terminate")) {
 		gtalk_hangup_farend(client, pak);
@@ -1736,10 +1751,11 @@
 		else if (!strcasecmp(var->name, "connection")) {
 			if ((client = ast_aji_get_client(var->value))) {
 				member->connection = client;
-				iks_filter_add_rule(client->f, gtalk_parser, member, IKS_RULE_TYPE,
-									IKS_PAK_IQ, IKS_RULE_FROM_PARTIAL, member->user,
-									IKS_RULE_NS, "http://www.google.com/session",
-									IKS_RULE_DONE);
+				iks_filter_add_rule(client->f, gtalk_parser, member, 
+						    IKS_RULE_TYPE, IKS_PAK_IQ, 
+						    IKS_RULE_FROM_PARTIAL, member->user,
+						    IKS_RULE_NS, "http://www.google.com/session",
+						    IKS_RULE_DONE);
 
 			} else {
 				ast_log(LOG_ERROR, "connection referenced not found!\n");
@@ -1852,8 +1868,8 @@
 						ASTOBJ_WRLOCK(iterator);
 						ASTOBJ_WRLOCK(member);
 						member->connection = iterator;
-						iks_filter_add_rule(iterator->f, gtalk_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS,
-										"http://www.google.com/session", IKS_RULE_DONE);
+						iks_filter_add_rule(iterator->f, gtalk_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS, "http://www.google.com/session", IKS_RULE_DONE);
+						iks_filter_add_rule(iterator->f, gtalk_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS, "http://jabber.org/protocol/gtalk", IKS_RULE_DONE);
 						ASTOBJ_UNLOCK(member);
 						ASTOBJ_CONTAINER_LINK(&gtalk_list, member);
 						ASTOBJ_UNLOCK(iterator);




More information about the asterisk-commits mailing list