[asterisk-commits] phsultan: branch 1.4 r82309 - /branches/1.4/channels/chan_gtalk.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Sep 13 06:47:15 CDT 2007
Author: phsultan
Date: Thu Sep 13 06:47:14 2007
New Revision: 82309
URL: http://svn.digium.com/view/asterisk?view=rev&rev=82309
Log:
Closes issue #9401, reported and patched by irrot, with slight
modifications by me.
Handle DTMF sent by Asterisk properly.
Modified:
branches/1.4/channels/chan_gtalk.c
Modified: branches/1.4/channels/chan_gtalk.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_gtalk.c?view=diff&rev=82309&r1=82308&r2=82309
==============================================================================
--- branches/1.4/channels/chan_gtalk.c (original)
+++ branches/1.4/channels/chan_gtalk.c Thu Sep 13 06:47:14 2007
@@ -650,12 +650,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");
@@ -689,6 +689,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;
@@ -698,7 +714,6 @@
gtalk_response(client, from, pak, NULL, NULL);
return 1;
}
-
static int gtalk_hangup_farend(struct gtalk *client, ikspak *pak)
{
@@ -1433,7 +1448,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");
@@ -1442,9 +1457,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);
@@ -1637,7 +1652,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);
@@ -1734,10 +1749,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");
@@ -1850,8 +1866,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(>alk_list, member);
ASTOBJ_UNLOCK(iterator);
More information about the asterisk-commits
mailing list