[asterisk-commits] branch mogorman/asterisk-xmpp r19392 -
/team/mogorman/asterisk-xmpp/res/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Tue Apr 11 15:07:28 MST 2006
Author: mogorman
Date: Tue Apr 11 17:07:27 2006
New Revision: 19392
URL: http://svn.digium.com/view/asterisk?rev=19392&view=rev
Log:
gateway suppport for jabber, ooh and now im a
millionaire on paper too...
Modified:
team/mogorman/asterisk-xmpp/res/res_xmpp.c
Modified: team/mogorman/asterisk-xmpp/res/res_xmpp.c
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-xmpp/res/res_xmpp.c?rev=19392&r1=19391&r2=19392&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/res/res_xmpp.c (original)
+++ team/mogorman/asterisk-xmpp/res/res_xmpp.c Tue Apr 11 17:07:27 2006
@@ -79,7 +79,8 @@
static int axi_register_transport2(void *udata,ikspak *pak);
void axi_increment_mid(char *mid);
static int axi_filter_roster(void *udata,ikspak *pak);
-static void axi_handle_discovery(struct axi_client *client, ikspak *pak);
+static int axi_dinfo_handler(void *udata,ikspak *pak);
+static int axi_ditems_handler(void *udata,ikspak *pak);
static char debug_usage[] =
"Usage: XMPP debug\n"
@@ -280,132 +281,181 @@
*/
static int axi_act_hook(void *udata, int type, iks * node)
{
- struct axi_client *client = ASTOBJ_REF((struct axi_client *) udata);
+ struct axi_client *client;
ikspak *pak;
pak=iks_packet(node);
+
+ client = (struct axi_client *)malloc(sizeof(struct axi_client));
+ memset(client,0,sizeof(struct axi_client));
+ client = ASTOBJ_REF((struct axi_client *) udata);
-
- switch(type) {
- case IKS_NODE_START:
- if(client->usetls &&!iks_is_secure(client->p)) {
- iks_start_tls(client->p);
+ iks_filter_packet (client->f,pak);
+ if(client->component == AXI_CLIENT) {
+ switch(type) {
+ case IKS_NODE_START:
+ if(client->usetls &&!iks_is_secure(client->p)) {
+ iks_start_tls(client->p);
+ break;
+ }
+ if(!client->usesasl) {
+ iks *auth;
+ iks_filter_add_rule (client->f, axi_client_connect, client, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT,IKS_RULE_ID,client->mid, IKS_RULE_DONE);
+
+ auth = iks_make_auth(client->jid,client->password,iks_find_attrib(node,"id"));
+ iks_insert_attrib(auth,"id",client->mid);
+ axi_increment_mid(client->mid);
+ iks_send(client->p,auth);
+ if(auth)
+ iks_delete(auth);
+ }
break;
- }
- if(!client->usesasl) {
+
+ case IKS_NODE_NORMAL:
+ {
+ int features=0;
iks *auth;
- iks_filter_add_rule (client->f, axi_client_connect, client, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT,IKS_RULE_ID,client->mid, IKS_RULE_DONE);
-
- auth = iks_make_auth(client->jid,client->password,iks_find_attrib(node,"id"));
- iks_insert_attrib(auth,"id",client->mid);
- axi_increment_mid(client->mid);
- iks_send(client->p,auth);
- if(auth)
- iks_delete(auth);
- }
- break;
-
- case IKS_NODE_NORMAL:
- {
- int features=0;
- iks *auth;
- if(!strcmp("stream:features",iks_name(node))) {
- features= iks_stream_features(node);
- if(client->usesasl) {
- if(client->usetls && !iks_is_secure(client->p))
- break;
- if(client->authorized) {
- if(features & IKS_STREAM_BIND) {
- iks_filter_add_rule (client->f, axi_client_connect, client, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_DONE);
- auth = iks_make_resource_bind(client->jid);
- axi_increment_mid(client->mid);
- iks_send(client->p,auth);
- if(auth)
- iks_delete(auth);
- }
- if(features & IKS_STREAM_SESSION) {
- iks_filter_add_rule (client->f, axi_client_connect, client, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_ID, "auth", IKS_RULE_DONE);
- auth =iks_make_session();
- iks_insert_attrib(auth,"id","auth");
- axi_increment_mid(client->mid);
- iks_send(client->p,auth);
- if(auth)
- iks_delete(auth);
- }
- } else {
- features=axi_highest_bit(features);
- if(features == IKS_STREAM_SASL_MD5)
- iks_start_sasl (client->p, IKS_SASL_DIGEST_MD5, client->jid->user, client->password);
- else {
- if(features == IKS_STREAM_SASL_PLAIN) {
- iks *x;
- x = iks_new ("auth");
- iks_insert_attrib (x, "xmlns", IKS_NS_XMPP_SASL);
- int len = strlen (client->jid->user) + strlen (client->password) + 3;
- /* XXX Check return values XXX */
- char *s = ast_malloc (80+len);
- char *base64 = ast_malloc(80 + len * 2);
- iks_insert_attrib (x, "mechanism", "PLAIN");
- sprintf (s, "%c%s%c%s", 0, client->jid->user, 0, client->password);
- ast_base64encode(base64, s,len, len * 2);
-
- iks_insert_cdata (x, base64, 0);
- iks_send (client->p, x);
- if(x)
- iks_delete (x);
- if(base64)
- free (base64);
- if(s)
- free (s);
-
+ if(!strcmp("stream:features",iks_name(node))) {
+ features= iks_stream_features(node);
+ if(client->usesasl) {
+ if(client->usetls && !iks_is_secure(client->p))
+ break;
+ if(client->authorized) {
+ if(features & IKS_STREAM_BIND) {
+ iks_filter_add_rule (client->f, axi_client_connect, client, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_DONE);
+ auth = iks_make_resource_bind(client->jid);
+ axi_increment_mid(client->mid);
+ iks_send(client->p,auth);
+ if(auth)
+ iks_delete(auth);
+ }
+ if(features & IKS_STREAM_SESSION) {
+ iks_filter_add_rule (client->f, axi_client_connect, client, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_ID, "auth", IKS_RULE_DONE);
+ auth =iks_make_session();
+ iks_insert_attrib(auth,"id","auth");
+ axi_increment_mid(client->mid);
+ iks_send(client->p,auth);
+ if(auth)
+ iks_delete(auth);
+ }
+ } else {
+ features=axi_highest_bit(features);
+ if(features == IKS_STREAM_SASL_MD5)
+ iks_start_sasl (client->p, IKS_SASL_DIGEST_MD5, client->jid->user, client->password);
+ else {
+ if(features == IKS_STREAM_SASL_PLAIN) {
+ iks *x;
+ x = iks_new ("auth");
+ iks_insert_attrib (x, "xmlns", IKS_NS_XMPP_SASL);
+ int len = strlen (client->jid->user) + strlen (client->password) + 3;
+ /* XXX Check return values XXX */
+ char *s = ast_malloc (80+len);
+ char *base64 = ast_malloc(80 + len * 2);
+ iks_insert_attrib (x, "mechanism", "PLAIN");
+ sprintf (s, "%c%s%c%s", 0, client->jid->user, 0, client->password);
+ ast_base64encode(base64, s,len, len * 2);
+
+ iks_insert_cdata (x, base64, 0);
+ iks_send (client->p, x);
+ if(x)
+ iks_delete (x);
+ if(base64)
+ free (base64);
+ if(s)
+ free (s);
+
+ }
}
}
}
+ } else if (!strcmp("failure",iks_name(node))) {
+ ast_verbose("XMPP: encryption failure.\n");
+ } else if (!strcmp("success",iks_name(node))) {
+ client->authorized=1;
+ iks_send_header(client->p,client->jid->server);
}
- } else if (!strcmp("failure",iks_name(node))) {
- ast_verbose("XMPP: encryption failure.\n");
- } else if (!strcmp("success",iks_name(node))) {
- client->authorized=1;
- iks_send_header(client->p,client->jid->server);
- }
-
- switch(pak->type) {
- case IKS_PAK_NONE:
- ast_verbose(VERBOSE_PREFIX_3 "XMPP: I Don't know what to do with you NONE\n");
- break;
- case IKS_PAK_MESSAGE:
- ast_verbose(VERBOSE_PREFIX_3 "XMPP: I Don't know what to do with you MESSAGE\n");
- break;
- case IKS_PAK_PRESENCE:
- ast_verbose(VERBOSE_PREFIX_3 "XMPP: I Do know how to handle presence!!\n");
- break;
- case IKS_PAK_S10N:
- axi_handle_subscribe(client,pak);
- ast_verbose(VERBOSE_PREFIX_3 "XMPP: I Dont know S10N subscribe!!\n");
- break;
- case IKS_PAK_IQ:
- ast_verbose(VERBOSE_PREFIX_3 "XMPP: I Dont have an IQ!!!\n");
- axi_handle_iq(client,node);
- break;
- default:
- ast_verbose(VERBOSE_PREFIX_3 "XMPP: I Dont know %i\n",pak->type );
- break;
- }
+ }
+ case IKS_NODE_ERROR: {
+ ast_verbose("XMPP: Node Error\n");
+ return IKS_HOOK;
+ break;
+ }
+ case IKS_NODE_STOP: {
+ ast_verbose("XMPP: Disconnected\n");
+ return IKS_HOOK;
+ break;
+ }
+ }
+ } else {
+ switch(type) {
+ case IKS_NODE_START:{
+ char buffer[160], buffer2[160], buffer3[320],*handshake;
+ switch(client->state) {
+ case AXI_DISCONNECTED:
+ sprintf(buffer2,"%s%s",pak->id,client->password);
+ ast_sha1_hash(buffer3,buffer2);
+ ast_verbose("Oh Really... %s\n",buffer2);
+ handshake = (char *)malloc((strlen("<handshake></handshake>")+strlen(buffer3)+1)*sizeof(char));
+ sprintf(handshake,"<handshake>%s</handshake>",buffer3);
+ iks_send_raw(client->p,handshake);
+ free(handshake);
+ handshake=NULL;
+ client->state=AXI_CONNECTED;
+ iks_filter_add_rule (client->f, axi_dinfo_handler, client, IKS_RULE_NS, "http://jabber.org/protocol/disco#info", IKS_RULE_DONE);
+ iks_filter_add_rule (client->f, axi_ditems_handler, client, IKS_RULE_NS, "http://jabber.org/protocol/disco#items", IKS_RULE_DONE);
+
+ break;
+ case AXI_ALMOST:
+ client->state=AXI_CONNECTED;
+ ast_verbose("shazam!\n");
+ break;
+ case AXI_CONNECTING:
+ case AXI_CONNECTED:
+ break;
+ };
+ break;
+ }
+
+ case IKS_NODE_NORMAL:{
+ ast_verbose("MOVE ZIG\n");
+ break;
+ }
+
+ case IKS_NODE_ERROR: {
+ ast_verbose("XMPP: Node Error\n");
+ return IKS_HOOK;
+ break;
+ }
+ case IKS_NODE_STOP: {
+ ast_verbose("XMPP: Disconnected\n");
+ return IKS_HOOK;
+ break;
+ }
+ }
+ }
+
+ switch(pak->type) {
+ case IKS_PAK_NONE:
+ ast_verbose(VERBOSE_PREFIX_3 "XMPP: I Don't know what to do with you NONE\n");
break;
- }
- case IKS_NODE_ERROR: {
- ast_verbose("XMPP: Node Error\n");
- return IKS_HOOK;
+ case IKS_PAK_MESSAGE:
+ ast_verbose(VERBOSE_PREFIX_3 "XMPP: I Don't know what to do with you MESSAGE\n");
break;
- }
- case IKS_NODE_STOP: {
- ast_verbose("XMPP: Disconnected\n");
- return IKS_HOOK;
+ case IKS_PAK_PRESENCE:
+ ast_verbose(VERBOSE_PREFIX_3 "XMPP: I Do know how to handle presence!!\n");
break;
- }
- }
-
- iks_filter_packet (client->f,pak);
-
+ case IKS_PAK_S10N:
+ axi_handle_subscribe(client,pak);
+ ast_verbose(VERBOSE_PREFIX_3 "XMPP: I Dont know S10N subscribe!!\n");
+ break;
+ case IKS_PAK_IQ:
+ ast_verbose(VERBOSE_PREFIX_3 "XMPP: I Dont have an IQ!!!\n");
+ axi_handle_iq(client,node);
+ break;
+ default:
+ ast_verbose(VERBOSE_PREFIX_3 "XMPP: I Dont know %i\n",pak->type );
+ break;
+ }
+
if (node)
iks_delete(node);
if(client)
@@ -413,6 +463,196 @@
return IKS_OK;
}
+
+static int axi_ditems_handler(void *udata,ikspak *pak)
+{
+ int res=0;
+ struct axi_client *client;
+ char *node = NULL;
+ client = (struct axi_client *)malloc(sizeof(struct axi_client));
+ memset(client,0,sizeof(struct axi_client));
+ client =ASTOBJ_REF((struct axi_client *) udata);
+ if(!(node = iks_find_attrib(pak->query,"node"))) {
+ iks *iq, *query, *item;
+ iq = iks_new("iq");
+ query = iks_new("query");
+ item = iks_new("item");
+
+ iks_insert_attrib(iq, "from", client->user);
+ iks_insert_attrib(iq, "to", pak->from->full);
+ iks_insert_attrib(iq, "id", pak->id);
+ iks_insert_attrib(iq, "type", "result");
+ iks_insert_attrib(query, "xmlns", "http://jabber.org/protocol/disco#items");
+ iks_insert_attrib(item, "node", "http://jabber.org/protocol/commands");
+ iks_insert_attrib(item, "name", "Million Dollar Asterisk Commands");
+ iks_insert_attrib(item, "jid", client->user);
+
+ iks_insert_node(iq,query);
+ iks_insert_node(query,item);
+ iks_send(client->p,iq);
+
+ iks_delete(iq);
+ iks_delete(query);
+ iks_delete(item);
+
+ } else if (!strcasecmp(node,"http://jabber.org/protocol/commands")) {
+ iks *iq, *query, *confirm, *emaillookup, *formatscreenname, *connectusers, *confirmaccount, *aimuritranslate, *changepassword, *stats, *updatemyvcard, *changeemail;
+ iq = iks_new("iq");
+ query = iks_new("query");
+ confirm = iks_new("item");
+
+ iks_insert_attrib(iq, "from", client->user);
+ iks_insert_attrib(iq, "to", pak->from->full);
+ iks_insert_attrib(iq, "id", pak->id);
+ iks_insert_attrib(iq, "type", "result");
+ iks_insert_attrib(query, "xmlns", "http://jabber.org/protocol/disco#items");
+ iks_insert_attrib(query, "node", "http://jabber.org/protocol/commands");
+ iks_insert_attrib(confirm, "node", "confirmaccount");
+ iks_insert_attrib(confirm, "name", "Confirm AIM account");
+ iks_insert_attrib(confirm, "jid","blog.astjab.org");
+
+ iks_insert_node(iq,query);
+ iks_insert_node(query,confirm);
+ iks_send(client->p,iq);
+
+ iks_delete(iq);
+ iks_delete(query);
+ iks_delete(confirm);
+ } else if (!strcasecmp(node,"confirmaccount")) {
+ iks *iq, *query, *feature;
+
+ iq = iks_new("iq");
+ query = iks_new("query");
+ feature = iks_new("feature");
+
+ iks_insert_attrib(iq, "from", client->user);
+ iks_insert_attrib(iq, "to", pak->from->full);
+ iks_insert_attrib(iq, "id", pak->id);
+ iks_insert_attrib(iq, "type", "result");
+ iks_insert_attrib(query, "xmlns", "http://jabber.org/protocol/disco#items");
+ iks_insert_attrib(feature, "var", "http://jabber.org/protocol/commands");
+
+ iks_insert_node(iq,query);
+ iks_insert_node(query,feature);
+ iks_send(client->p, iq);
+ iks_delete(iq);
+ iks_delete(query);
+ iks_delete(feature);
+ }
+
+ return IKS_FILTER_EAT;
+
+}
+
+static int axi_dinfo_handler(void *udata,ikspak *pak)
+{
+ int res=0;
+ struct axi_client *client;
+ char *node= NULL;
+ client = (struct axi_client *)malloc(sizeof(struct axi_client));
+ memset(client,0,sizeof(struct axi_client));
+ client =ASTOBJ_REF((struct axi_client *) udata);
+ if(!(node = iks_find_attrib(pak->query,"node"))) {
+ iks *iq, *query, *identity, *disco, *reg, *commands, *gateway, *version, *vcard, *search;
+
+ iq = iks_new("iq");
+ query = iks_new("query");
+ identity = iks_new("identity");
+ disco = iks_new("feature");
+ reg = iks_new("feature");
+ commands = iks_new("feature");
+ gateway = iks_new("feature");
+ version = iks_new("feature");
+ vcard = iks_new("feature");
+ search = iks_new("feature");
+
+
+ iks_insert_attrib(iq, "from", client->user);
+ iks_insert_attrib(iq, "to", pak->from->full);
+ iks_insert_attrib(iq, "id", pak->id);
+ iks_insert_attrib(iq, "type", "result");
+ iks_insert_attrib(query, "xmlns", "http://jabber.org/protocol/disco#info");
+ iks_insert_attrib(identity, "category", "gateway");
+ iks_insert_attrib(identity, "type", "pstn");
+ iks_insert_attrib(identity, "name", "Asterisk The Open Source PBX");
+ iks_insert_attrib(disco, "var", "http://jabber.org/protocol/disco");
+ iks_insert_attrib(reg, "var", "jabber:iq:register");
+ iks_insert_attrib(commands, "var", "http://jabber.org/protocol/commands");
+ iks_insert_attrib(gateway, "var", "jabber:iq:gateway");
+ iks_insert_attrib(version, "var", "jabber:iq:version");
+ iks_insert_attrib(vcard, "var", "vcard-temp");
+ iks_insert_attrib(search, "var", "jabber:iq:search");
+
+ iks_insert_node(iq,query);
+ iks_insert_node(query,identity);
+ iks_insert_node(query,disco);
+ iks_insert_node(query,reg);
+ iks_insert_node(query,commands);
+ iks_insert_node(query,gateway);
+ iks_insert_node(query,version);
+ iks_insert_node(query,vcard);
+ iks_insert_node(query,search);
+
+ iks_send(client->p,iq);
+ iks_delete(iq);
+ iks_delete(query);
+ iks_delete(identity);
+ iks_delete(disco);
+ iks_delete(reg);
+ iks_delete(commands);
+ iks_delete(gateway);
+ iks_delete(version);
+ iks_delete(vcard);
+ iks_delete(search);
+
+ } else if (!strcasecmp(node,"http://jabber.org/protocol/commands")) {
+ iks *iq, *query, *confirm, *emaillookup, *formatscreenname, *connectusers, *confirmaccount, *aimuritranslate, *changepassword, *stats, *updatemyvcard, *changeemail;
+ iq = iks_new("iq");
+ query = iks_new("query");
+ confirm = iks_new("item");
+
+ iks_insert_attrib(iq, "from", client->user);
+ iks_insert_attrib(iq, "to", pak->from->full);
+ iks_insert_attrib(iq, "id", pak->id);
+ iks_insert_attrib(iq, "type", "result");
+ iks_insert_attrib(query, "xmlns", "http://jabber.org/protocol/disco#items");
+ iks_insert_attrib(query, "node", "http://jabber.org/protocol/commands");
+ iks_insert_attrib(confirm, "node", "confirmaccount");
+ iks_insert_attrib(confirm, "name", "Confirm AIM account");
+ iks_insert_attrib(confirm, "jid","blog.astjab.org");
+
+ iks_insert_node(iq,query);
+ iks_insert_node(query,confirm);
+ iks_send(client->p,iq);
+
+ iks_delete(iq);
+ iks_delete(query);
+ iks_delete(confirm);
+
+ } else if (!strcasecmp(node,"confirmaccount")) {
+ iks *iq, *query, *feature;
+
+ iq = iks_new("iq");
+ query = iks_new("query");
+ feature = iks_new("feature");
+
+ iks_insert_attrib(iq, "from", client->user);
+ iks_insert_attrib(iq, "to", pak->from->full);
+ iks_insert_attrib(iq, "id", pak->id);
+ iks_insert_attrib(iq, "type", "result");
+ iks_insert_attrib(query, "xmlns", "http://jabber.org/protocol/disco#info");
+ iks_insert_attrib(feature, "var", "http://jabber.org/protocol/commands");
+
+ iks_insert_node(iq,query);
+ iks_insert_node(query,feature);
+ iks_send(client->p, iq);
+ iks_delete(iq);
+ iks_delete(query);
+ iks_delete(feature);
+ }
+ return IKS_FILTER_EAT;
+}
+
/*!
* \brief Handles <iq> tags.
* \param client structure and the iq node.
@@ -420,48 +660,10 @@
*/
static void axi_handle_iq(struct axi_client *client, iks *node)
{
- if(iks_packet(node)->subtype==IKS_TYPE_GET) {
- if(iks_find_with_attrib(iks_packet(node)->x,"query","xmlns","http://jabber.org/protocol/disco#info")) {
- axi_handle_discovery(client,iks_packet(node));
- }
- }
-#if 0
- if(iks_packet(node)->subtype==IKS_TYPE_SET) {
- if(iks_find_with_attrib(iks_packet(node)->x,GOOGLE_NODE,"xmlns",GOOGLE_NS))
- jingle_callback(client,iks_copy(node));
- }
- if(iks_packet(node)->subtype==IKS_TYPE_RESULT) {
- char *data;
- data = iks_find_attrib(iks_packet(node)->x, "id");
- if(data) {
- if(strstr(data,"j:")) {
- if(strstr(data,"active:"))
- jingle_callback(client,iks_copy(node));
- }
- }
- }
-#endif
-}
-
-/*!
- * \brief respond to a discovery packet.
- * \param axi client structure, and xml packet.
- * \return void.
- */
-static void axi_handle_discovery(struct axi_client *client, ikspak *pak)
-{
- iks *iq, *query,*identify;
- iq = iks_make_iq(IKS_TYPE_RESULT,"jabber:client");
- query = iks_new("query");
- identify = iks_new("identify");
- if(iks_find_attrib(pak->x, "id"))
- iks_insert_attrib(iq,"id",iks_find_attrib(pak->x, "id"));
- if(iks_find_attrib(pak->x,"from"))
- iks_insert_attrib(iq,"to",iks_find_attrib(pak->x,"from"));
- iks_insert_attrib(query,"xmlns","http://jabber.org/protocol/disco#info");
- iks_insert_attrib(identify,"category","client");
- iks_insert_attrib(identify,"type","pc");
-}
+
+}
+
+
/*!
* \brief handles subscription requests.
@@ -939,8 +1141,10 @@
client = (struct axi_client *)malloc(sizeof(struct axi_client));
memset(client,0,sizeof(struct axi_client));
-
- client =ASTOBJ_REF((struct axi_client *) udata);
+ client = ASTOBJ_REF((struct axi_client *) udata);
+
+ ast_verbose(" so long, state %d\n", client->state);
+
switch(client->state)
{
case AXI_DISCONNECTED:
@@ -952,7 +1156,7 @@
handshake = (char *)malloc((strlen("<handshake></handshake>")+strlen(buffer)+1)*sizeof(char));
sprintf(handshake,"<handshake>%s</handshake>",buffer);
iks_sha_delete (sha);
- res =iks_send_raw(client->p,handshake);
+ res = iks_send_raw(client->p,handshake);
free(handshake);
handshake=NULL;
client->state=AXI_ALMOST;
@@ -1016,15 +1220,29 @@
{
int connected=1;
if(!client->f)
- client->f= iks_filter_new();
-
- client->stack = iks_stack_new(8192, 8192);
- iks_filter_add_rule (client->f, axi_component_connect, client, IKS_RULE_FROM, client->server, IKS_RULE_DONE);
+ client->f = iks_filter_new();
+ client->stack = iks_stack_new(8192,8192);
+// iks_filter_add_rule (client->f, axi_component_connect, client, IKS_RULE_FROM,client->server, IKS_RULE_DONE);
client->jid = iks_id_new(client->stack, client->user);
client->p = iks_stream_new("jabber:component:accept", client, axi_act_hook);
-iks_set_log_hook(client->p, axi_log_hook);
-connected =iks_connect_via(client->p, client->server, client->port, client->user);
-return 1;
+ iks_set_log_hook(client->p, axi_log_hook);
+ connected =iks_connect_via(client->p, client->server, client->port, client->user);
+#if 0
+ client->p = iks_stream_new("jabber:component:accept", client, axi_act_hook);
+ if(!client->f)
+ client->f= iks_filter_new();
+ iks_set_log_hook(client->p, axi_log_hook);
+ client->jid = iks_id_new(iks_parser_stack(client->p), client->user);
+ connected =iks_connect_via(client->p, client->server, client->port, client->user);
+ iks_filter_add_rule (client->f, axi_component_connect, client, IKS_RULE_FROM, client->server, IKS_RULE_DONE);
+#endif
+ if(connected== IKS_NET_NOCONN)
+ ast_verbose("XMPP ERROR: No Connection");
+ if(connected == IKS_NET_NODNS)
+ ast_verbose("XMPP ERROR: No DNS");
+ if(!connected)
+ iks_recv(client->p,30);
+ return 1;
}
/*!
More information about the asterisk-commits
mailing list