mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-03 04:16:43 +00:00
Merged revisions 118020 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ........ r118020 | phsultan | 2008-05-23 12:33:21 +0200 (Fri, 23 May 2008) | 15 lines - remove whitespaces between tags in received XML packets before giving them to the parser ; - report Gtalk error messages from a buddy to the console. This patch makes Asterisk "Google Jingle" (chan_gtalk) implementation work with Empathy. Note that this is only true for audio streams, not video. Thank you to PH for his great help! (closes issue #12647) Reported by: PH Patches: trunk-12647-1.diff uploaded by phsultan (license 73) Tested by: phsultan, PH ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@118021 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -1699,7 +1699,10 @@ static int gtalk_parser(void *data, ikspak *pak)
|
|||||||
{
|
{
|
||||||
struct gtalk *client = ASTOBJ_REF((struct gtalk *) data);
|
struct gtalk *client = ASTOBJ_REF((struct gtalk *) data);
|
||||||
|
|
||||||
if (iks_find_with_attrib(pak->x, "session", "type", "initiate")) {
|
if (iks_find_attrib(pak->x, "type") && !strcmp(iks_find_attrib (pak->x, "type"),"error")) {
|
||||||
|
ast_log(LOG_NOTICE, "Remote peer reported an error, trying to establish the call anyway\n");
|
||||||
|
}
|
||||||
|
else if (iks_find_with_attrib(pak->x, "session", "type", "initiate")) {
|
||||||
/* New call */
|
/* New call */
|
||||||
gtalk_newcall(client, pak);
|
gtalk_newcall(client, pak);
|
||||||
} else if (iks_find_with_attrib(pak->x, "session", "type", "candidates") || iks_find_with_attrib(pak->x, "session", "type", "transport-info")) {
|
} else if (iks_find_with_attrib(pak->x, "session", "type", "candidates") || iks_find_with_attrib(pak->x, "session", "type", "transport-info")) {
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
#include <iksemel.h>
|
#include <iksemel.h>
|
||||||
|
|
||||||
#include "asterisk/channel.h"
|
#include "asterisk/channel.h"
|
||||||
@@ -638,23 +639,53 @@ static int aji_recv (struct aji_client *client, int timeout)
|
|||||||
{
|
{
|
||||||
int len, ret;
|
int len, ret;
|
||||||
char buf[NET_IO_BUF_SIZE -1];
|
char buf[NET_IO_BUF_SIZE -1];
|
||||||
|
char newbuf[NET_IO_BUF_SIZE -1];
|
||||||
|
int pos = 0;
|
||||||
|
int newbufpos = 0;
|
||||||
|
unsigned char c;
|
||||||
|
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
|
memset(newbuf, 0, sizeof(newbuf));
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
len = aji_io_recv(client, buf, NET_IO_BUF_SIZE - 1, timeout);
|
len = aji_io_recv(client, buf, NET_IO_BUF_SIZE - 1, timeout);
|
||||||
if (len < 0) return IKS_NET_RWERR;
|
if (len < 0) return IKS_NET_RWERR;
|
||||||
if (len == 0) return IKS_NET_EXPIRED;
|
if (len == 0) return IKS_NET_EXPIRED;
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
|
|
||||||
|
/* our iksemel parser won't work as expected if we feed
|
||||||
|
it with XML packets that contain multiple whitespace
|
||||||
|
characters between tags */
|
||||||
|
while (pos < len) {
|
||||||
|
c = buf[pos];
|
||||||
|
/* if we stumble on the ending tag character,
|
||||||
|
we skip any whitespace that follows it*/
|
||||||
|
if (c == '>') {
|
||||||
|
while (isspace(buf[pos+1])) {
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newbuf[newbufpos] = c;
|
||||||
|
newbufpos ++;
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
pos = 0;
|
||||||
|
newbufpos = 0;
|
||||||
|
|
||||||
/* Log the message here, because iksemel's logHook is
|
/* Log the message here, because iksemel's logHook is
|
||||||
unaccessible */
|
unaccessible */
|
||||||
aji_log_hook(client, buf, len, 1);
|
aji_log_hook(client, buf, len, 1);
|
||||||
|
|
||||||
ret = iks_parse(client->p, buf, len, 0);
|
/* let iksemel deal with the string length,
|
||||||
|
and reset our buffer */
|
||||||
|
ret = iks_parse(client->p, newbuf, 0, 0);
|
||||||
|
memset(newbuf, 0, sizeof(newbuf));
|
||||||
|
|
||||||
if (ret != IKS_OK) {
|
if (ret != IKS_OK) {
|
||||||
|
ast_log(LOG_WARNING, "XML parsing failed\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
ast_debug(3, "XML parsing successful\n");
|
||||||
}
|
}
|
||||||
return IKS_OK;
|
return IKS_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user