[asterisk-commits] branch mogorman/asterisk-xmpp r9162 - in
/team/mogorman/asterisk-xmpp: ./ cha...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Sun Feb 5 23:16:27 MST 2006
Author: mogorman
Date: Mon Feb 6 00:16:27 2006
New Revision: 9162
URL: http://svn.digium.com/view/asterisk?rev=9162&view=rev
Log:
search and replace on some structures to make code
read better.
Modified:
team/mogorman/asterisk-xmpp/app.c
team/mogorman/asterisk-xmpp/channels/chan_agent.c
team/mogorman/asterisk-xmpp/channels/chan_xmpp.c
team/mogorman/asterisk-xmpp/include/asterisk/app.h
team/mogorman/asterisk-xmpp/include/asterisk/xmpp.h
team/mogorman/asterisk-xmpp/res/res_xmpp.c
Modified: team/mogorman/asterisk-xmpp/app.c
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-xmpp/app.c?rev=9162&r1=9161&r2=9162&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/app.c (original)
+++ team/mogorman/asterisk-xmpp/app.c Mon Feb 6 00:16:27 2006
@@ -235,11 +235,11 @@
static int (*ast_has_voicemail_func)(const char *mailbox, const char *folder) = NULL;
static int (*ast_messagecount_func)(const char *mailbox, int *newmsgs, int *oldmsgs) = NULL;
-static int (*astjab_register_func)(const char *action, int (*func)(struct axi_master *asterisk, char *user, char *m,int type), const char *synopsis, const char *description)=NULL;
-static int (*astjab_send)(struct axi_master *asterisk, char *address, char *message) =NULL;
+static int (*astjab_register_func)(const char *action, int (*func)(struct axi_client *client, char *user, char *m,int type), const char *synopsis, const char *description)=NULL;
+static int (*astjab_send)(struct axi_client *client, char *address, char *message) =NULL;
static int (*astjab_check_roster)(void)=NULL;
-void ast_install_xmpp_functions(int (*axi_check_roster)(void), int (*axi_send)(struct axi_master *asterisk, char *address, char *message), int (*axi_register)(const char *action, int (*func)(struct axi_master *asterisk,char *user, char *m, int type), const char *synopsis, const char *description))
+void ast_install_xmpp_functions(int (*axi_check_roster)(void), int (*axi_send)(struct axi_client *client, char *address, char *message), int (*axi_register)(const char *action, int (*func)(struct axi_client *client,char *user, char *m, int type), const char *synopsis, const char *description))
{
astjab_send = axi_send;
astjab_register_func=axi_register;
@@ -265,11 +265,11 @@
}
return 0;
}
-int ast_xmpp_send(struct axi_master *asterisk,char *address, char *message)
+int ast_xmpp_send(struct axi_client *client, char *address, char *message)
{
static int warned = 0;
if (astjab_send)
- return astjab_send(asterisk,address,message);
+ return astjab_send(client,address,message);
if (option_verbose > 2 ) {
warned++;
@@ -278,7 +278,7 @@
return 0;
}
-int ast_xmpp_register(const char *action, int (*func)(struct axi_master *asterisk, char *user, char *m, int type), const char *synopsis, const char *description)
+int ast_xmpp_register(const char *action, int (*func)(struct axi_client *client, char *user, char *m, int type), const char *synopsis, const char *description)
{
static int warned = 0;
if (astjab_register_func)
Modified: team/mogorman/asterisk-xmpp/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-xmpp/channels/chan_agent.c?rev=9162&r1=9161&r2=9162&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/channels/chan_agent.c (original)
+++ team/mogorman/asterisk-xmpp/channels/chan_agent.c Mon Feb 6 00:16:27 2006
@@ -262,7 +262,7 @@
static int agent_indicate(struct ast_channel *ast, int condition);
static int agent_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
static struct ast_channel *agent_bridgedchannel(struct ast_channel *chan, struct ast_channel *bridge);
-static int xmpp_agent_status(struct axi_master *asterisk,char *user,char *message, int type);
+static int xmpp_agent_status(struct axi_client *client,char *user,char *message, int type);
static int xmpp_login(char *agent,char *exten, char *context);
static void set_agentbycallerid(const char *callerid, const char *agent);
@@ -1698,7 +1698,7 @@
return 0;
}
-static int xmpp_agent_status(struct axi_master *asterisk,char *user,char *message, int type)
+static int xmpp_agent_status(struct axi_client *client,char *user,char *message, int type)
{
char *m=NULL;
m=(char*)malloc(strlen(message));
@@ -1722,11 +1722,11 @@
{
if(tmp->xmpplogon >= type){
xmpp_login(tmp->agent,extension,context);
- ast_xmpp_send(asterisk,user,"Agent is logged in.");
+ ast_xmpp_send(client,user,"Agent is logged in.");
}
if(tmp->xmpplogoff <= type){
agent_logoff(tmp->agent, 1);
- ast_xmpp_send(asterisk,user,"Agent is logged out.");
+ ast_xmpp_send(client,user,"Agent is logged out.");
}
}
Modified: team/mogorman/asterisk-xmpp/channels/chan_xmpp.c
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-xmpp/channels/chan_xmpp.c?rev=9162&r1=9161&r2=9162&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/channels/chan_xmpp.c (original)
+++ team/mogorman/asterisk-xmpp/channels/chan_xmpp.c Mon Feb 6 00:16:27 2006
@@ -101,10 +101,6 @@
.indicate = xmpp_indicate,
.fixup = xmpp_fixup,
.send_html = xmpp_sendhtml,
-};
-
-struct jingle_action {
- int (*func)(struct axi_master *asterisk, ikspak *pak);
};
static struct xmpp_pvt {
Modified: team/mogorman/asterisk-xmpp/include/asterisk/app.h
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-xmpp/include/asterisk/app.h?rev=9162&r1=9161&r2=9162&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/include/asterisk/app.h (original)
+++ team/mogorman/asterisk-xmpp/include/asterisk/app.h Mon Feb 6 00:16:27 2006
@@ -103,15 +103,15 @@
/*! Record voice (after playing prompt if specified), waiting for silence (in ms) up to a given timeout (in s) or '#' */
int ast_app_getvoice(struct ast_channel *c, char *dest, char *dstfmt, char *prompt, int silence, int maxsec);
-void ast_install_xmpp_functions(int (*axi_check_roster)(void), int (*axi_send)(struct axi_master *asterisk, char *address, char *message), int (*axi_register)(const char *action, int (*func)(struct axi_master *asterisk,char *user, char *m, int type), const char *synopsis, const char *description) );
+void ast_install_xmpp_functions(int (*axi_check_roster)(void), int (*axi_send)(struct axi_client *client, char *address, char *message), int (*axi_register)(const char *action, int (*func)(struct axi_client *client,char *user, char *m, int type), const char *synopsis, const char *description) );
void ast_uninstall_xmpp_functions(void);
-int ast_xmpp_send(struct axi_master *asterisk,char *address, char *message);
+int ast_xmpp_send(struct axi_client *client,char *address, char *message);
int ast_xmpp_check_roster(void);
-int ast_xmpp_register(const char *action, int (*func)(struct axi_master *asterisk,char *user, char *m, int type), const char *synopsis, const char *description);
+int ast_xmpp_register(const char *action, int (*func)(struct axi_client *client,char *user, char *m, int type), const char *synopsis, const char *description);
void ast_install_vm_functions(int (*has_voicemail_func)(const char *mailbox, const char *folder),
int (*messagecount_func)(const char *mailbox, int *newmsgs, int *oldmsgs));
Modified: team/mogorman/asterisk-xmpp/include/asterisk/xmpp.h
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-xmpp/include/asterisk/xmpp.h?rev=9162&r1=9161&r2=9162&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/include/asterisk/xmpp.h (original)
+++ team/mogorman/asterisk-xmpp/include/asterisk/xmpp.h Mon Feb 6 00:16:27 2006
@@ -87,8 +87,8 @@
ASTOBJ_CONTAINER_COMPONENTS(struct axi_transport);
};
-struct axi_master {
- ASTOBJ_COMPONENTS(struct axi_master);
+struct axi_client {
+ ASTOBJ_COMPONENTS(struct axi_client);
char password[160];
char user[160];
char server[160];
@@ -114,8 +114,8 @@
pthread_t thread;
};
-struct axi_master_container{
- ASTOBJ_CONTAINER_COMPONENTS(struct axi_master);
+struct axi_client_container{
+ ASTOBJ_CONTAINER_COMPONENTS(struct axi_client);
};
struct axi_action {
/*! Name of the action */
@@ -127,7 +127,7 @@
/*! Permission required for action. EVENT_FLAG_* */
/*! Function to be called */
- int (*func)(struct axi_master *asterisk,char *user, char *message, int type);
+ int (*func)(struct axi_client *client,char *user, char *message, int type);
/*! For easy linking */
struct axi_action *next;
};
@@ -142,11 +142,11 @@
\param synopsis Help text (one line, up to 30 chars) for CLI xmpp show commands
\param description Help text, several lines
*/
-int ast_axi_register2(const char *action, int (*func)(struct axi_master *asterisk,char *user, char *m,int type), const char *synopsis, const char *description);
-int ast_axi_send(struct axi_master *asterisk,char *address, char *message);
-int ast_axi_disconnect(struct axi_master *asterisk);
+int ast_axi_register2(const char *action, int (*func)(struct axi_client *client,char *user, char *m,int type), const char *synopsis, const char *description);
+int ast_axi_send(struct axi_client *client, char *address, char *message);
+int ast_axi_disconnect(struct axi_client *client);
int ast_axi_check_roster(void);
-int ast_axi_create_chat(struct axi_master *asterisk,char *room, char *server, char *topic);
-int ast_axi_invite_chat(struct axi_master *asterisk, char *user, char *room, char *message);
-int ast_axi_join_chat(struct axi_master *asterisk,char *room);
+int ast_axi_create_chat(struct axi_client *client,char *room, char *server, char *topic);
+int ast_axi_invite_chat(struct axi_client *client, char *user, char *room, char *message);
+int ast_axi_join_chat(struct axi_client *client,char *room);
#endif
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=9162&r1=9161&r2=9162&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/res/res_xmpp.c (original)
+++ team/mogorman/asterisk-xmpp/res/res_xmpp.c Mon Feb 6 00:16:27 2006
@@ -55,22 +55,22 @@
static int axi_highest_bit(int number);
static void axi_buddy_destroy(struct axi_buddy *obj);
-static void axi_master_destroy(struct axi_master *obj);
+static void axi_client_destroy(struct axi_client *obj);
static int axi_send_exec(struct ast_channel *chan, void *data);
static int axi_status_exec(struct ast_channel *chan, void *data);
static void axi_log_hook(void *udata, const char *data, size_t size,int is_incoming);
-static int axi_execute(struct axi_master *asterisk,char *action, char *user, char *message, int type);
+static int axi_execute(struct axi_client *client,char *action, char *user, char *message, int type);
static int axi_act_hook(void *udata, int type, iks * node);
-static void axi_handle_iq(struct axi_master *asterisk, ikspak *pak);
-static void axi_handle_presence(struct axi_master *asterisk, ikspak *pak);
-static void axi_handle_subscribe(struct axi_master *asterisk, ikspak *pak);
-static int axi_recv(struct axi_master *asterisk,int timeout);
+static void axi_handle_iq(struct axi_client *client, ikspak *pak);
+static void axi_handle_presence(struct axi_client *client, ikspak *pak);
+static void axi_handle_subscribe(struct axi_client *client, ikspak *pak);
+static int axi_recv(struct axi_client *client,int timeout);
static void *axi_recv_loop(void *data);
-static int axi_component_initialize(struct axi_master *asterisk);
-static int axi_client_initialize(struct axi_master *asterisk);
+static int axi_component_initialize(struct axi_client *client);
+static int axi_client_initialize(struct axi_client *client);
static int axi_client_connect(void *udata, ikspak *pak);
static int axi_component_connect(void *udata,ikspak *pak);
-static void axi_set_presence(struct axi_master *asterisk,char *user, int level, char *desc);
+static void axi_set_presence(struct axi_client *client,char *user, int level, char *desc);
static int axi_do_debug(int fd, int argc, char *argv[]);
static int axi_no_debug(int fd, int argc, char *argv[]);
static int axi_do_debug_component(int fd, int argc, char *argv[]);
@@ -78,17 +78,17 @@
static int axi_test(int fd, int argc, char *argv[]);
static int axi_show_clients(int fd, int argc, char *argv[]);
static int axi_register_struct(struct axi_action *act);
-static int *axi_create_master(char *label,struct ast_variable *var,int debug,int pruneregister,char *utype, struct axi_master *asterisk);
+static int *axi_create_client(char *label,struct ast_variable *var,int debug,int pruneregister,char *utype, struct axi_client *client);
static int *axi_create_buddy(char *label, struct axi_buddy *buddy);
static int *axi_create_transport(char *label, struct axi_buddy *buddy);
static int axi_load_config(void);
-static void axi_handle_message(struct axi_master *asterisk, ikspak *pak);
-static void axi_pruneregister(struct axi_master *asterisk);
+static void axi_handle_message(struct axi_client *client, ikspak *pak);
+static void axi_pruneregister(struct axi_client *client);
static int axi_register_transport(void *udata,ikspak *pak);
static int axi_register_transport2(void *udata,ikspak *pak);
static void axi_increment_mid(char *mid);
static int axi_filter_roster(void *udata,ikspak *pak);
-static void axi_handle_discovery(struct axi_master *asterisk, ikspak *pak);
+static void axi_handle_discovery(struct axi_client *client, ikspak *pak);
static char debug_usage[] =
"Usage: XMPP debug\n"
@@ -117,15 +117,15 @@
static struct axi_action *first_action = NULL;
-struct axi_master_container masters;
+struct axi_client_container clients;
/*!
- * \brief Deletes the axi_master data structure.
+ * \brief Deletes the axi_client data structure.
* \param obj is the structure we will delete.
* \return void.
*/
-static void axi_master_destroy(struct axi_master *obj)
+static void axi_client_destroy(struct axi_client *obj)
{
ASTOBJ_CONTAINER_DESTROYALL(&obj->buddies,axi_buddy_destroy);
ASTOBJ_CONTAINER_DESTROY(&obj->buddies);
@@ -176,7 +176,7 @@
static int axi_status_exec(struct ast_channel *chan, void *data)
{
- struct axi_master *asterisk=NULL;
+ struct axi_client *client=NULL;
struct axi_buddy *buddy=NULL;
char *s=NULL,*sender=NULL,*screenname=NULL,*variable=NULL;
int stat=7;
@@ -185,7 +185,7 @@
s = ast_strdupa((char *)data);
if (s) {
sender = strsep(&s,"|");
- asterisk = ASTOBJ_CONTAINER_FIND(&masters,sender);
+ client = ASTOBJ_CONTAINER_FIND(&clients,sender);
if(sender && (sender[0]!='\0')){
screenname = strsep(&s, "|");
if (screenname && (screenname[0] != '\0')) {
@@ -201,7 +201,7 @@
return -1;
}
if(strchr(screenname,'@')) { /*real xmpp id */
- ASTOBJ_CONTAINER_TRAVERSE2(&asterisk->buddies,1,1,{
+ ASTOBJ_CONTAINER_TRAVERSE2(&client->buddies,1,1,{
ASTOBJ_RDLOCK(iterator1);
{
if(!strcasecmp(iterator1->user,screenname)) {
@@ -211,7 +211,7 @@
ASTOBJ_UNLOCK(iterator1);
});
} else { /* just a label*/
- buddy=ASTOBJ_CONTAINER_FIND(&asterisk->buddies,screenname);
+ buddy=ASTOBJ_CONTAINER_FIND(&client->buddies,screenname);
stat=buddy->status;
}
sprintf(status,"%d",stat);
@@ -221,14 +221,14 @@
static int axi_send_exec(struct ast_channel *chan, void *data)
{
- struct axi_master *asterisk=NULL;
+ struct axi_client *client=NULL;
char *s=NULL,*sender=NULL,*recipiant=NULL,*message=NULL;
if (data) {
s = ast_strdupa((char *)data);
if (s) {
sender = strsep(&s,"|");
- asterisk = ASTOBJ_CONTAINER_FIND(&masters,sender);
+ client = ASTOBJ_CONTAINER_FIND(&clients,sender);
if(sender && (sender[0]!='\0')){
recipiant = strsep(&s, "|");
if (recipiant && (recipiant[0] != '\0')) {
@@ -243,35 +243,35 @@
ast_log(LOG_ERROR, "Out of memory\n");
return -1;
}
- if(asterisk)
- ast_axi_send(asterisk,recipiant,message);
+ if(client)
+ ast_axi_send(client,recipiant,message);
return 0;
}
static void axi_log_hook(void *udata, const char *data, size_t size,int is_incoming)
{
- struct axi_master *asterisk = ASTOBJ_REF((struct axi_master *) udata);
+ struct axi_client *client = ASTOBJ_REF((struct axi_client *) udata);
char *buf = (char *) malloc(size + 1);
memcpy(buf, data, size);
buf[size] = 0;
- if (asterisk->debug == 1) {
+ if (client->debug == 1) {
if (is_incoming)
- ast_verbose("\nXMPP: %s INCOMING: %s\n",asterisk->name, buf);
+ ast_verbose("\nXMPP: %s INCOMING: %s\n",client->name, buf);
else
- ast_verbose("\nXMPP: %s OUTGOING: %s\n",asterisk->name, buf);
-
- }
- if(asterisk)
- ASTOBJ_UNREF(asterisk, axi_master_destroy);
-}
-
-static int axi_execute(struct axi_master *asterisk, char *action, char *user, char *message, int type)
+ ast_verbose("\nXMPP: %s OUTGOING: %s\n",client->name, buf);
+
+ }
+ if(client)
+ ASTOBJ_UNREF(client, axi_client_destroy);
+}
+
+static int axi_execute(struct axi_client *client, char *action, char *user, char *message, int type)
{
struct axi_action *tmp = first_action;
while( tmp ) {
if (!strcasecmp(action, tmp->action)) {
- if (tmp->func(asterisk,user, message, type)) {
+ if (tmp->func(client,user, message, type)) {
return -1;
}
} else {
@@ -284,25 +284,25 @@
static int axi_act_hook(void *udata, int type, iks * node)
{
ast_verbose("Stuck on you\n");
- struct axi_master *asterisk = ASTOBJ_REF((struct axi_master *) udata);
+ struct axi_client *client = ASTOBJ_REF((struct axi_client *) udata);
ikspak *pak;
pak=iks_packet(node);
- iks_filter_packet (asterisk->f,pak);
+ iks_filter_packet (client->f,pak);
switch(type) {
case IKS_NODE_START:
- if(asterisk->usetls &&!iks_is_secure(asterisk->p)) {
- iks_start_tls(asterisk->p);
+ if(client->usetls &&!iks_is_secure(client->p)) {
+ iks_start_tls(client->p);
break;
}
- if(!asterisk->usesasl) {
+ if(!client->usesasl) {
iks *auth;
- iks_filter_add_rule (asterisk->f, axi_client_connect, asterisk, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT,IKS_RULE_ID,asterisk->mid, IKS_RULE_DONE);
-
- auth = iks_make_auth(asterisk->jid,asterisk->password,iks_find_attrib(node,"id"));
- iks_insert_attrib(auth,"id",asterisk->mid);
- axi_increment_mid(asterisk->mid);
- iks_send(asterisk->p,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);
iks_delete(auth);
}
break;
@@ -313,45 +313,45 @@
iks *auth;
if(!strcmp("stream:features",iks_name(node))) {
features= iks_stream_features(node);
- if(asterisk->usesasl) {
- if(asterisk->usetls && !iks_is_secure(asterisk->p))
+ if(client->usesasl) {
+ if(client->usetls && !iks_is_secure(client->p))
break;
- if(asterisk->authorized) {
+ if(client->authorized) {
if(features & IKS_STREAM_BIND) {
- iks_filter_add_rule (asterisk->f, axi_client_connect, asterisk, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_DONE);
- auth = iks_make_resource_bind(asterisk->jid);
- axi_increment_mid(asterisk->mid);
- iks_send(asterisk->p,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_DONE);
+ auth = iks_make_resource_bind(client->jid);
+ axi_increment_mid(client->mid);
+ iks_send(client->p,auth);
iks_delete(auth);
}
if(features & IKS_STREAM_SESSION) {
- iks_filter_add_rule (asterisk->f, axi_client_connect, asterisk, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_ID, "auth", IKS_RULE_DONE);
+ 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(asterisk->mid);
- iks_send(asterisk->p,auth);
+ axi_increment_mid(client->mid);
+ iks_send(client->p,auth);
iks_delete(auth);
}
} else {
features=axi_highest_bit(features);
if(features == IKS_STREAM_SASL_MD5)
- iks_start_sasl (asterisk->p, IKS_SASL_DIGEST_MD5, asterisk->jid->user, asterisk->password);
+ 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 = iks_strlen (asterisk->jid->user) + iks_strlen (asterisk->password) + 2;
+ int len = iks_strlen (client->jid->user) + iks_strlen (client->password) + 2;
char *s = iks_malloc (80+len);
char *base64;
iks_insert_attrib (x, "mechanism", "PLAIN");
- sprintf (s, "%c%s%c%s", 0, asterisk->jid->user, 0, asterisk->password);
+ sprintf (s, "%c%s%c%s", 0, client->jid->user, 0, client->password);
ast_base64encode(base64,s,len,((len/3+1)*4 +1));
iks_insert_cdata (x, base64, 0);
iks_free (base64);
iks_free (s);
- iks_send (asterisk->p, x);
+ iks_send (client->p, x);
iks_delete (x);
}
}
@@ -360,8 +360,8 @@
} else if (!strcmp("failure",iks_name(node))) {
ast_verbose("ENCRYPTION FAILURE");
} else if (!strcmp("success",iks_name(node))) {
- asterisk->authorized=1;
- iks_send_header(asterisk->p,asterisk->jid->server);
+ client->authorized=1;
+ iks_send_header(client->p,client->jid->server);
}
switch(pak->type) {
@@ -369,20 +369,20 @@
ast_verbose(VERBOSE_PREFIX_3 "XMPP: I Don't know what to do with you NONE\n");
break;
case IKS_PAK_MESSAGE:
- axi_handle_message(asterisk,pak);
+ axi_handle_message(client,pak);
ast_verbose(VERBOSE_PREFIX_3 "XMPP: I Don't know what to do with you MESSAGE\n");
break;
case IKS_PAK_PRESENCE:
- axi_handle_presence(asterisk,pak);
+ axi_handle_presence(client,pak);
ast_verbose(VERBOSE_PREFIX_3 "XMPP: I Do know how to handle presence!!\n");
break;
case IKS_PAK_S10N:
- axi_handle_subscribe(asterisk,pak);
+ 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(asterisk,pak);
+ axi_handle_iq(client,pak);
break;
default:
ast_verbose(VERBOSE_PREFIX_3 "XMPP: I Dont know %i\n",pak->type );
@@ -403,12 +403,12 @@
}
if (node)
iks_delete(node);
- if(asterisk)
- ASTOBJ_UNREF(asterisk, axi_master_destroy);
+ if(client)
+ ASTOBJ_UNREF(client, axi_client_destroy);
return IKS_OK;
}
-static void axi_handle_message(struct axi_master *asterisk, ikspak *pak)
+static void axi_handle_message(struct axi_client *client, ikspak *pak)
{
/* ast_verbose("%s\n",pak->id);
if(pak->subtype == IKS_TYPE_CHAT)
@@ -417,36 +417,36 @@
*/
}
-static void axi_handle_jingle(struct axi_master *asterisk, ikspak *pak)
+static void axi_handle_jingle(struct axi_client *client, ikspak *pak)
{
if(iks_find_with_attrib(pak->x,"session","type","initiate")) {
iks *accept;
accept = iks_new("iq");
iks_insert_attrib(accept,"type","result");
- iks_insert_attrib(accept,"from",asterisk->jid->full);
+ iks_insert_attrib(accept,"from",client->jid->full);
iks_insert_attrib(accept,"to",iks_find_attrib(pak->x,"from"));
- iks_insert_attrib(accept,"id",asterisk->mid);
- iks_send(asterisk->p,accept);
+ iks_insert_attrib(accept,"id",client->mid);
+ iks_send(client->p,accept);
iks_delete(accept);
}
}
-static void axi_handle_iq(struct axi_master *asterisk, ikspak *pak)
+static void axi_handle_iq(struct axi_client *client, ikspak *pak)
{
if(pak->subtype==IKS_TYPE_GET) {
- ast_verbose("this is it %s\n",iks_string(asterisk->stack,pak->query));
+ ast_verbose("this is it %s\n",iks_string(client->stack,pak->query));
if(iks_find_with_attrib(pak->x,"query","xmlns","http://jabber.org/protocol/disco#info")) {
- axi_handle_discovery(asterisk,pak);
+ axi_handle_discovery(client,pak);
}
}
if(pak->subtype==IKS_TYPE_SET) {
if(iks_find_with_attrib(pak->x,"session","xmlns","http://www.google.com/session"))
- axi_handle_jingle(asterisk,pak);
- }
-}
-
-static void axi_handle_discovery(struct axi_master *asterisk, ikspak *pak)
+ axi_handle_jingle(client,pak);
+ }
+}
+
+static void axi_handle_discovery(struct axi_client *client, ikspak *pak)
{
iks *iq, *query,*identify;
iq = iks_make_iq(IKS_TYPE_RESULT,"jabber:client");
@@ -467,7 +467,7 @@
int ast_axi_check_roster(void)
{
char action[100];
- ASTOBJ_CONTAINER_TRAVERSE2(&masters,1,1, {
+ ASTOBJ_CONTAINER_TRAVERSE2(&clients,1,1, {
ASTOBJ_RDLOCK(iterator1);
ASTOBJ_CONTAINER_TRAVERSE2(&iterator1->buddies,2,1, {
sprintf(action,"axi_agent %s",iterator2->user);
@@ -477,7 +477,7 @@
});
return 1;
}
-static void axi_handle_presence(struct axi_master *asterisk, ikspak *pak)
+static void axi_handle_presence(struct axi_client *client, ikspak *pak)
{
char action[100];
char *agent=NULL;
@@ -486,7 +486,7 @@
int status=6;
status=(pak->show)?pak->show:6;
- ASTOBJ_CONTAINER_TRAVERSE(&asterisk->buddies,1, {
+ ASTOBJ_CONTAINER_TRAVERSE(&client->buddies,1, {
ASTOBJ_RDLOCK(iterator);
if(!strncasecmp(iks_find_attrib(pak->x,"from"),iterator->name,strlen(iterator->name)))
buddy=iterator;
@@ -498,17 +498,17 @@
channel=buddy->channel;
buddy->status=(pak->show==0?6:pak->show);
sprintf(action,"axi_agent%s",agent);
- axi_execute(asterisk,action,iks_find_attrib(pak->x,"from"),channel,status);
- }
-}
-
-static void axi_handle_subscribe(struct axi_master *asterisk, ikspak *pak)
+ axi_execute(client,action,iks_find_attrib(pak->x,"from"),channel,status);
+ }
+}
+
+static void axi_handle_subscribe(struct axi_client *client, ikspak *pak)
{
int res=0;
switch(pak->subtype)
{
case IKS_TYPE_SUBSCRIBE:
- res =iks_send(asterisk->p,iks_make_s10n(IKS_TYPE_SUBSCRIBED,iks_find_attrib(pak->x, "from"),"Asterisk has approved subscription"));
+ res =iks_send(client->p,iks_make_s10n(IKS_TYPE_SUBSCRIBED,iks_find_attrib(pak->x, "from"),"Asterisk has approved subscription"));
ast_verbose(VERBOSE_PREFIX_3 "XMPP: This is a subcription of type %i\n",pak->subtype );
break;
case IKS_TYPE_SUBSCRIBED:
@@ -526,34 +526,34 @@
}
}
-int ast_axi_send(struct axi_master *asterisk, char *address, char *message)
+int ast_axi_send(struct axi_client *client, char *address, char *message)
{
int res=0;
iks *message_packet;
- if(asterisk->state==AXI_CONNECTED) {
+ if(client->state==AXI_CONNECTED) {
message_packet=iks_make_msg(IKS_TYPE_CHAT, address, message);
- iks_insert_attrib(message_packet,"from",asterisk->jid->full);
- res =iks_send(asterisk->p,message_packet);
+ iks_insert_attrib(message_packet,"from",client->jid->full);
+ res =iks_send(client->p,message_packet);
iks_delete(message_packet);
} else
ast_verbose("We arent connected dont send\n");
return 1;
}
-int ast_axi_create_chat(struct axi_master *asterisk,char *room, char *server, char *topic)
+int ast_axi_create_chat(struct axi_client *client,char *room, char *server, char *topic)
{
int res=0;
iks *iq;
iq = iks_new("iq");
iks_insert_attrib(iq,"type","get");
iks_insert_attrib(iq,"to",server);
- iks_insert_attrib(iq,"id",asterisk->mid);
- axi_increment_mid(asterisk->mid);
+ iks_insert_attrib(iq,"id",client->mid);
+ axi_increment_mid(client->mid);
return res;
}
-int ast_axi_join_chat(struct axi_master *asterisk,char *room)
+int ast_axi_join_chat(struct axi_client *client,char *room)
{
int res=0;
iks *p1,*priority, *priority2, *p2;
@@ -562,7 +562,7 @@
iks_insert_cdata(priority,"0",strlen("0"));
iks_insert_attrib(p1,"to",room);
iks_insert_node(p1,priority);
- res =iks_send(asterisk->p,p1);
+ res =iks_send(client->p,p1);
iks_delete(p1);
iks_delete(priority);
@@ -571,12 +571,12 @@
iks_insert_cdata(priority2,"5",strlen("5"));
iks_insert_attrib(p2,"to",room);
iks_insert_node(p2,priority2);
- res =iks_send(asterisk->p,p2);
+ res =iks_send(client->p,p2);
iks_delete(p2);
iks_delete(priority2);
return 1;
}
-int ast_axi_invite_chat(struct axi_master *asterisk, char *user, char *room, char *message)
+int ast_axi_invite_chat(struct axi_client *client, char *user, char *room, char *message)
{
int res=0;
iks *invite,*body,*namespace;
@@ -584,34 +584,34 @@
body = iks_new("body");
namespace = iks_new("x");
iks_insert_attrib(invite,"to",user);
- iks_insert_attrib(invite,"id",asterisk->mid);
- axi_increment_mid(asterisk->mid);
+ iks_insert_attrib(invite,"id",client->mid);
+ axi_increment_mid(client->mid);
iks_insert_cdata(body,message,strlen(message));
iks_insert_attrib(namespace,"xmlns","jabber:x:conference");
iks_insert_attrib(namespace,"jid",room);
iks_insert_node(invite,body);
iks_insert_node(invite,namespace);
- res =iks_send(asterisk->p,invite);
+ res =iks_send(client->p,invite);
iks_delete(body);
iks_delete(namespace);
iks_delete(invite);
return 1;
}
-static int axi_recv(struct axi_master *asterisk,int timeout)
+static int axi_recv(struct axi_client *client,int timeout)
{
int res=0;
- res =iks_recv(asterisk->p, timeout);
+ res =iks_recv(client->p, timeout);
return res;
}
static void *axi_recv_loop(void *data)
{
int res=0;
- struct axi_master *asterisk = ASTOBJ_REF((struct axi_master *) data);
+ struct axi_client *client = ASTOBJ_REF((struct axi_client *) data);
while (res == IKS_OK) {
- ast_verbose("waiting %d is the longest time\n",asterisk->timeout);
- res =iks_recv(asterisk->p,1);
+ ast_verbose("waiting %d is the longest time\n",client->timeout);
+ res =iks_recv(client->p,1);
printf("res = %d\n",res);
if(res==IKS_HOOK) {
ast_verbose("HOOK!!!!");
@@ -621,16 +621,16 @@
ast_verbose("FAILURE TLS");
break;
}
- asterisk->timeout--;
- if(asterisk->timeout == 0 && asterisk->state !=AXI_CONNECTED) {
+ client->timeout--;
+ if(client->timeout == 0 && client->state !=AXI_CONNECTED) {
res = -1;
ast_verbose("Network Timeout");
}
}
ast_verbose("\n\nIM NOT LISTENING!!!!!!!!!!!\n\n");
- if(asterisk)
- ASTOBJ_UNREF(asterisk, axi_master_destroy);
+ if(client)
+ ASTOBJ_UNREF(client, axi_client_destroy);
return 0;
}
@@ -653,32 +653,32 @@
static int axi_register_transport(void *udata,ikspak *pak)
{
int res=0;
- struct axi_master *asterisk;
+ struct axi_client *client;
struct axi_buddy *buddy=NULL;
iks *send;
- asterisk = (struct axi_master *)malloc(sizeof(struct axi_master));
- memset(asterisk,0,sizeof(struct axi_master));
- asterisk =ASTOBJ_REF((struct axi_master *) udata);
- ASTOBJ_CONTAINER_TRAVERSE(&asterisk->buddies,1, {
+ client = (struct axi_client *)malloc(sizeof(struct axi_client));
+ memset(client,0,sizeof(struct axi_client));
+ client =ASTOBJ_REF((struct axi_client *) udata);
+ ASTOBJ_CONTAINER_TRAVERSE(&client->buddies,1, {
ASTOBJ_RDLOCK(iterator);
if(iterator->btype==AXI_TRANS ) {
buddy=iterator;
}
ASTOBJ_UNLOCK(iterator);
});
- iks_filter_remove_hook(asterisk->f,axi_register_transport);
- iks_filter_add_rule(asterisk->f,axi_register_transport2,asterisk,
+ iks_filter_remove_hook(client->f,axi_register_transport);
+ iks_filter_add_rule(client->f,axi_register_transport2,client,
IKS_RULE_TYPE,IKS_PAK_IQ,IKS_RULE_SUBTYPE, IKS_TYPE_RESULT,IKS_RULE_NS,
IKS_NS_REGISTER,IKS_RULE_DONE);
send =iks_make_iq(IKS_TYPE_GET,"jabber:iq:register");
iks_insert_attrib(send,"to",buddy->host);
- iks_insert_attrib(send,"id",asterisk->mid);
- axi_increment_mid(asterisk->mid);
- iks_insert_attrib(send,"from",asterisk->user);
- res =iks_send(asterisk->p,send);
+ iks_insert_attrib(send,"id",client->mid);
+ axi_increment_mid(client->mid);
+ iks_insert_attrib(send,"from",client->user);
+ res =iks_send(client->p,send);
iks_delete(send);
- if(asterisk){
- ASTOBJ_UNREF(asterisk,axi_master_destroy);
+ if(client){
+ ASTOBJ_UNREF(client,axi_client_destroy);
}
return IKS_FILTER_EAT;
@@ -686,51 +686,51 @@
static int axi_register_transport2(void *udata,ikspak *pak)
{
int res=0;
- struct axi_master *asterisk;
+ struct axi_client *client;
struct axi_buddy *buddy=NULL;
iks *regquery, *reguser, *regpass, *regiq;
- asterisk = (struct axi_master *)malloc(sizeof(struct axi_master));
- memset(asterisk,0,sizeof(struct axi_master));
- asterisk =ASTOBJ_REF((struct axi_master *) udata);
- ASTOBJ_CONTAINER_TRAVERSE(&asterisk->buddies,1, {
+ client = (struct axi_client *)malloc(sizeof(struct axi_client));
+ memset(client,0,sizeof(struct axi_client));
+ client =ASTOBJ_REF((struct axi_client *) udata);
+ ASTOBJ_CONTAINER_TRAVERSE(&client->buddies,1, {
ASTOBJ_RDLOCK(iterator);
if(iterator->btype==AXI_TRANS)
buddy=iterator;
ASTOBJ_UNLOCK(iterator);
});
- iks_filter_remove_hook(asterisk->f,axi_register_transport2);
+ iks_filter_remove_hook(client->f,axi_register_transport2);
regiq = iks_new("iq");
regquery = iks_new("query");
reguser = iks_new("username");
regpass = iks_new("password");
iks_insert_attrib(regiq,"to",buddy->host);
iks_insert_attrib(regiq,"type","set");
- iks_insert_attrib(regiq,"id",asterisk->mid);
- axi_increment_mid(asterisk->mid);
- iks_insert_attrib(regiq,"from",asterisk->user);
+ iks_insert_attrib(regiq,"id",client->mid);
+ axi_increment_mid(client->mid);
+ iks_insert_attrib(regiq,"from",client->user);
iks_insert_attrib(regquery,"xmlns","jabber:iq:register");
iks_insert_cdata(reguser,buddy->user,strlen(buddy->user));
iks_insert_cdata(regpass,buddy->pass,strlen(buddy->pass));
iks_insert_node(regiq,regquery);
iks_insert_node(regquery,reguser);
iks_insert_node(regquery,regpass);
- res =iks_send(asterisk->p,regiq);
+ res =iks_send(client->p,regiq);
iks_delete(regiq);
iks_delete(regquery);
iks_delete(reguser);
iks_delete(regpass);
- if(asterisk) {
- ASTOBJ_UNREF(asterisk,axi_master_destroy);
+ if(client) {
+ ASTOBJ_UNREF(client,axi_client_destroy);
}
return IKS_FILTER_EAT;
}
-static void axi_pruneregister(struct axi_master *asterisk)
+static void axi_pruneregister(struct axi_client *client)
{
int res=0;
iks *removeiq, *removequery, *removeitem, *send;
- ASTOBJ_CONTAINER_TRAVERSE(&asterisk->buddies,1, {
+ ASTOBJ_CONTAINER_TRAVERSE(&client->buddies,1, {
ASTOBJ_RDLOCK(iterator);
switch(iterator->on_roster)
{
@@ -739,36 +739,35 @@
break;
case AXI_PRUNE:
ast_verbose("PRUNE THIS USER %s\n",iterator->name);
- res =iks_send(asterisk->p,iks_make_s10n(IKS_TYPE_UNSUBSCRIBE,iterator->name,"GoodBye your status is no longer needed by Asterisk the Open Source PBX so I am no longer subscribing to your presence.\n"));
- res =iks_send(asterisk->p,iks_make_s10n(IKS_TYPE_UNSUBSCRIBED,iterator->name,"GoodBye you are no longer in the asterisk config file so I am removing your access to my presence.\n"));
+ res =iks_send(client->p,iks_make_s10n(IKS_TYPE_UNSUBSCRIBE,iterator->name,"GoodBye your status is no longer needed by Asterisk the Open Source PBX so I am no longer subscribing to your presence.\n"));
+ res =iks_send(client->p,iks_make_s10n(IKS_TYPE_UNSUBSCRIBED,iterator->name,"GoodBye you are no longer in the asterisk config file so I am removing your access to my presence.\n"));
removeiq = iks_new("iq");
removequery = iks_new("query");
removeitem = iks_new("item");
- iks_insert_attrib(removeiq,"from",asterisk->user);
+ iks_insert_attrib(removeiq,"from",client->user);
iks_insert_attrib(removeiq,"type","set");
iks_insert_attrib(removequery,"xmlns","jabber:iq:roster");
iks_insert_attrib(removeitem,"jid",iterator->name);
iks_insert_attrib(removeitem,"subscription","remove");
iks_insert_node(removeiq,removequery);
iks_insert_node(removequery,removeitem);
- res =iks_send(asterisk->p, removeiq);
+ res =iks_send(client->p, removeiq);
iks_delete(removeiq);
iks_delete(removequery);
iks_delete(removeitem);
-// ASTOBJ_CONTAINER_UNLINK(&asterisk->buddies,iterator);
break;
case AXI_REGISTER:
ast_verbose("REGISTER THIS USER %s\n",iterator->name);
if(iterator->btype==AXI_USER) { /*if it is not a transport */
- res =iks_send(asterisk->p,iks_make_s10n(IKS_TYPE_SUBSCRIBE,iterator->name,"Greetings I am the Asterisk Open Source PBX and I want to subscribe to your presence\n"));
+ res =iks_send(client->p,iks_make_s10n(IKS_TYPE_SUBSCRIBE,iterator->name,"Greetings I am the Asterisk Open Source PBX and I want to subscribe to your presence\n"));
} else {
- iks_filter_add_rule(asterisk->f,axi_register_transport,asterisk,
+ iks_filter_add_rule(client->f,axi_register_transport,client,
IKS_RULE_TYPE,IKS_PAK_IQ,IKS_RULE_SUBTYPE, IKS_TYPE_RESULT,IKS_RULE_NS,
"http://jabber.org/protocol/disco#items",IKS_RULE_DONE);
send =iks_make_iq(IKS_TYPE_GET,"http://jabber.org/protocol/disco#items");
iks_insert_attrib(send,"to",iterator->host);
- iks_insert_attrib(send,"from",asterisk->user);
- res =iks_send(asterisk->p,send);
+ iks_insert_attrib(send,"from",client->user);
+ res =iks_send(client->p,send);
iks_delete(send);
}
iterator->on_roster=AXI_DONOTHING;
@@ -776,20 +775,20 @@
}
ASTOBJ_UNLOCK(iterator);
});
- ASTOBJ_CONTAINER_PRUNE_MARKED(&asterisk->buddies,axi_buddy_destroy);
+ ASTOBJ_CONTAINER_PRUNE_MARKED(&client->buddies,axi_buddy_destroy);
}
static int axi_filter_roster(void *udata,ikspak *pak)
{
int flag=0;
iks *x;
- struct axi_master *asterisk;
+ struct axi_client *client;
struct axi_buddy *buddy;
- asterisk = (struct axi_master *)malloc(sizeof(struct axi_master));
- memset(asterisk,0,sizeof(struct axi_master));
- asterisk =ASTOBJ_REF((struct axi_master *) udata);
+ client = (struct axi_client *)malloc(sizeof(struct axi_client));
+ memset(client,0,sizeof(struct axi_client));
+ client =ASTOBJ_REF((struct axi_client *) udata);
- ASTOBJ_CONTAINER_TRAVERSE(&asterisk->buddies,1, {
+ ASTOBJ_CONTAINER_TRAVERSE(&client->buddies,1, {
ASTOBJ_RDLOCK(iterator);
x = iks_child(pak->query);
flag=0;
@@ -812,7 +811,7 @@
}
if(!flag)
- if(asterisk->pruneregister>=2)
+ if(client->pruneregister>=2)
iterator->on_roster=AXI_REGISTER;
iks_delete(x);
@@ -823,7 +822,7 @@
while(x){
flag = 0;
if(iks_strcmp(iks_name(x), "item") == 0){
- ASTOBJ_CONTAINER_TRAVERSE(&asterisk->buddies,1, {
+ ASTOBJ_CONTAINER_TRAVERSE(&client->buddies,1, {
ASTOBJ_RDLOCK(iterator);
if(strlen(iterator->pass)!=0) {
if(!strcasecmp(iterator->host,iks_find_attrib(x,"jid")))
@@ -836,7 +835,7 @@
});
if(!flag) {
- if(asterisk->pruneregister==1||asterisk->pruneregister==3) {
+ if(client->pruneregister==1||client->pruneregister==3) {
buddy = (struct axi_buddy *)malloc(sizeof(struct axi_buddy));
if(!buddy)
ast_log(LOG_WARNING, "Out of memory\n");
@@ -849,7 +848,7 @@
buddy->objflags |= ASTOBJ_FLAG_MARKED;
ASTOBJ_UNLOCK(buddy);
if(buddy) {
- ASTOBJ_CONTAINER_LINK(&asterisk->buddies,buddy);
+ ASTOBJ_CONTAINER_LINK(&client->buddies,buddy);
ASTOBJ_UNREF(buddy, axi_buddy_destroy);
}
}
@@ -859,10 +858,10 @@
}
iks_delete(x);
- axi_pruneregister(asterisk);
- iks_filter_remove_hook(asterisk->f,axi_filter_roster);
[... 505 lines stripped ...]
More information about the asterisk-commits
mailing list