[asterisk-commits] branch mogorman/asterisk-xmpp r19498 - in
/team/mogorman/asterisk-xmpp: chann...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Tue Apr 11 18:43:50 MST 2006
Author: mogorman
Date: Tue Apr 11 20:43:49 2006
New Revision: 19498
URL: http://svn.digium.com/view/asterisk?rev=19498&view=rev
Log:
updates
Modified:
team/mogorman/asterisk-xmpp/channels/chan_jingle.c
team/mogorman/asterisk-xmpp/include/asterisk/xmpp.h
team/mogorman/asterisk-xmpp/res/res_xmpp.c
Modified: team/mogorman/asterisk-xmpp/channels/chan_jingle.c
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-xmpp/channels/chan_jingle.c?rev=19498&r1=19497&r2=19498&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/channels/chan_jingle.c (original)
+++ team/mogorman/asterisk-xmpp/channels/chan_jingle.c Tue Apr 11 20:43:49 2006
@@ -89,7 +89,7 @@
static int jingle_call(struct ast_channel *ast, char *dest, int timeout);
static int jingle_hangup(struct ast_channel *ast);
static int jingle_answer(struct ast_channel *ast);
-static int jingle_answer2(struct axi_client *client, ikspak *pak);
+static int jingle_answer2(struct aji_client *client, ikspak *pak);
static struct ast_frame *jingle_read(struct ast_channel *ast);
static int jingle_write(struct ast_channel *ast, struct ast_frame *f);
static int jingle_indicate(struct ast_channel *ast, int condition);
@@ -143,7 +143,7 @@
static int flipflop = 0;
-struct jingle *find_jingle(struct axi_client *client, ikspak *pak)
+struct jingle *find_jingle(struct aji_client *client, ikspak *pak)
{
struct jingle *res=NULL;
ASTOBJ_CONTAINER_TRAVERSE(&jingles,1, {
@@ -270,7 +270,7 @@
return 0;
}
-static int jingle_bridge_call(struct axi_client *client,ikspak *pak)
+static int jingle_bridge_call(struct aji_client *client,ikspak *pak)
{
char *data, sid[100];
struct jingle_pvt *p=NULL;
@@ -365,13 +365,13 @@
return 1;
}
-static int jingle_hangup_farend(struct axi_client *client,ikspak *pak)
+static int jingle_hangup_farend(struct aji_client *client,ikspak *pak)
{
ast_verbose("END CALL\n");
return 1;
}
-static int jingle_create_candidates(struct axi_client *client,ikspak *pak)
+static int jingle_create_candidates(struct aji_client *client,ikspak *pak)
{
struct jingle_candidate *tmp;
struct jingle_pvt *p = NULL;
@@ -415,7 +415,7 @@
iks_insert_attrib(iq,"to", iks_find_attrib(pak->x,"from"));
iks_insert_attrib(iq,"type", "set");
iks_insert_attrib(iq,"id", client->mid);
- axi_increment_mid(client->mid);
+ aji_increment_mid(client->mid);
iks_insert_attrib(jingle,"type", "candidates");
iks_insert_attrib(jingle,"id", iks_find_attrib(pak->query,GOOGLE_SID));
iks_insert_attrib(jingle,"initiator",iks_find_attrib(pak->x,"from"));
@@ -449,7 +449,7 @@
iks_insert_attrib(iq,"to", iks_find_attrib(pak->x,"from"));
iks_insert_attrib(iq,"type", "set");
iks_insert_attrib(iq,"id", client->mid);
- axi_increment_mid(client->mid);
+ aji_increment_mid(client->mid);
iks_insert_attrib(jingle,"type", "candidates");
iks_insert_attrib(jingle,"id", iks_find_attrib(pak->query,GOOGLE_SID));
iks_insert_attrib(jingle,"initiator",iks_find_attrib(pak->x,"from"));
@@ -469,7 +469,7 @@
snprintf(user, sizeof(user),"%08x%08x",thread_safe_rand(),thread_safe_rand());
snprintf(pass, sizeof(pass),"%08x%08x",thread_safe_rand(),thread_safe_rand());
iks_insert_attrib(iq,"id", client->mid);
- axi_increment_mid(client->mid);
+ aji_increment_mid(client->mid);
iks_insert_attrib(candidate, "address", externip);
iks_insert_attrib(candidate, "port", port);
iks_insert_attrib(candidate, "username", user);
@@ -481,7 +481,7 @@
snprintf(user, sizeof(user),"%08x%08x",thread_safe_rand(),thread_safe_rand());
snprintf(pass, sizeof(pass),"%08x%08x",thread_safe_rand(),thread_safe_rand());
iks_insert_attrib(iq,"id", client->mid);
- axi_increment_mid(client->mid);
+ aji_increment_mid(client->mid);
iks_insert_attrib(candidate, "address", localip);
iks_insert_attrib(candidate, "port", port); /*FIX ME*/
iks_insert_attrib(candidate, "username", user);
@@ -545,7 +545,7 @@
ast_rtp_lookup_code(p->rtp, 1, codec);
}
-static int jingle_accept_call(struct axi_client *client, ikspak *pak)
+static int jingle_accept_call(struct aji_client *client, ikspak *pak)
{
struct jingle_pvt *tmp = NULL;
struct jingle *peer = NULL;
@@ -633,7 +633,7 @@
return 1;
}
-static struct jingle_pvt *jingle_alloc2(struct axi_client *client, ikspak *pak)
+static struct jingle_pvt *jingle_alloc2(struct aji_client *client, ikspak *pak)
{
struct jingle_pvt *tmp = NULL;
struct jingle *peer =NULL;
@@ -654,7 +654,7 @@
return tmp;
}
-static int jingle_answer2(struct axi_client *client,ikspak *pak)
+static int jingle_answer2(struct aji_client *client,ikspak *pak)
{
struct jingle_pvt *p ,*tmp = NULL;
struct jingle *peer = NULL;
@@ -702,7 +702,7 @@
return 1;
}
-static int jingle_add_candidate(struct axi_client *client,ikspak *pak)
+static int jingle_add_candidate(struct aji_client *client,ikspak *pak)
{
struct jingle_pvt *p =NULL,*tmp = NULL;
struct jingle *peer = NULL;
@@ -971,8 +971,8 @@
#if 0
struct jingle_pvt *p = ast->tech_pvt;
struct jingle *peer = NULL;
- struct axi_client *client = NULL;
- client = ast_axi_get_client("asterisk");
+ struct aji_client *client = NULL;
+ client = ast_aji_get_client("asterisk");
int isoutbound;
struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP };
struct jingle_pvt *cur, *prev=NULL;
@@ -1086,8 +1086,8 @@
struct jingle_pvt *p=NULL;
struct jingle *peer=NULL;
struct jingle_candidate *tmp;
- struct axi_client *client = NULL;
- client = ast_axi_get_client("asterisk");
+ struct aji_client *client = NULL;
+ client = ast_aji_get_client("asterisk");
if (argc != 3)
return RESULT_SHOWUSAGE;
ast_mutex_lock(&jinglelock);
@@ -1121,7 +1121,7 @@
static int jingle_parser(void *udata, ikspak *pak)
{
- struct axi_client *client= ASTOBJ_REF((struct axi_client *) udata);;
+ struct aji_client *client= ASTOBJ_REF((struct aji_client *) udata);;
ast_verbose("WOOHOO!!!\n");
if(iks_find_with_attrib(pak->x,GOOGLE_NODE,"type",JINGLE_INITIATE))
@@ -1149,18 +1149,18 @@
static int proof_of_concept(void *udata, ikspak *pak)
{
- struct axi_client *client;
- client = (struct axi_client *)malloc(sizeof(struct axi_client));
- memset(client,0,sizeof(struct axi_client));
-
- client =ASTOBJ_REF((struct axi_client *) udata);
+ struct aji_client *client;
+ client = (struct aji_client *)malloc(sizeof(struct aji_client));
+ memset(client,0,sizeof(struct aji_client));
+
+ client =ASTOBJ_REF((struct aji_client *) udata);
ast_verbose("\n\n\n\n\nXXXXXXXXXXX PASSED AROUND LIKE A HACKY SACK\n");
return IKS_FILTER_EAT;
}
static int jingle_create_member(char *label, struct ast_variable *var, int allowguest, struct ast_codec_pref prefs, char *context, struct jingle *member)
{
- struct axi_client *client=NULL;
+ struct aji_client *client=NULL;
if(!member)
ast_log(LOG_WARNING, "Out of memory.\n");
ast_copy_string(member->name, label, sizeof(member->name));
@@ -1178,7 +1178,7 @@
else if (!strcasecmp(var->name, "context"))
ast_copy_string(member->context,var->value,sizeof(member->context));
else if (!strcasecmp(var->name, "connection")) {
- if((client = ast_axi_get_client(var->value))) {
+ if((client = ast_aji_get_client(var->value))) {
// client->jingle=member;
member->connection=client;
// iks_filter_add_rule(client->f,jingle_parser, client, IKS_RULE_TYPE, IKS_RULE_FROM_PARTIAL, member->user, IKS_PAK_IQ, IKS_RULE_NS, "http://www.google.com/session", IKS_RULE_DONE);
@@ -1206,7 +1206,7 @@
struct ast_variable *var;
struct jingle *member;
struct ast_codec_pref prefs;
- struct axi_client_container *clients;
+ struct aji_client_container *clients;
cfg = ast_config_load(JINGLE_CONFIG);
if(!cfg) {
@@ -1249,7 +1249,7 @@
ast_copy_string(member->context,var->value,sizeof(member->context));
var = var->next;
}
- clients = ast_axi_get_clients();
+ clients = ast_aji_get_clients();
if(clients) {
ASTOBJ_CONTAINER_TRAVERSE(clients,1,{
ASTOBJ_WRLOCK(iterator);
@@ -1323,8 +1323,8 @@
int unload_module()
{
struct jingle_pvt *p = NULL;
- struct axi_client *client = NULL;
- client = ast_axi_get_client("asterisk");
+ struct aji_client *client = NULL;
+ client = ast_aji_get_client("asterisk");
/* First, take us out of the channel loop */
// ast_cli_unregister(&cli_show_xmpps);
ast_channel_unregister(&jingle_tech);
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=19498&r1=19497&r2=19498&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/include/asterisk/xmpp.h (original)
+++ team/mogorman/asterisk-xmpp/include/asterisk/xmpp.h Tue Apr 11 20:43:49 2006
@@ -16,71 +16,71 @@
* at the top of the source tree.
*/
-#ifndef _ASTERISK_XMPP_H
-#define _ASTERISK_XMPP_H
+#ifndef _ASTERISK_JABBER_H
+#define _ASTERISK_JABBER_H
#include <iksemel.h>
#include "asterisk/astobj.h"
-enum axi_state {
+enum aji_state {
AXI_DISCONNECTED=0,
AXI_CONNECTING,
AXI_ALMOST,
AXI_CONNECTED
};
-enum axi_prune_register {
+enum aji_prune_register {
AXI_DONOTHING=0,
AXI_PRUNE=1,
AXI_REGISTER=2
};
-enum axi_btype {
+enum aji_btype {
AXI_USER=0,
AXI_TRANS=1,
AXI_UTRANS=2
};
-enum axi_type {
+enum aji_type {
AXI_COMPONENT=0,
AXI_CLIENT=1,
};
-struct axi_buddy {
- ASTOBJ_COMPONENTS(struct axi_buddy);
+struct aji_buddy {
+ ASTOBJ_COMPONENTS(struct aji_buddy);
char user[160];
char host[160];
char pass[160]; /*For Transports*/
char server[160]; /*For Transports */
char channel[160];
- enum axi_btype btype;
- enum axi_prune_register on_roster;
+ enum aji_btype btype;
+ enum aji_prune_register on_roster;
int status;
};
-struct axi_buddy_container {
- ASTOBJ_CONTAINER_COMPONENTS(struct axi_buddy);
+struct aji_buddy_container {
+ ASTOBJ_CONTAINER_COMPONENTS(struct aji_buddy);
};
-struct axi_transport_container {
- ASTOBJ_CONTAINER_COMPONENTS(struct axi_transport);
+struct aji_transport_container {
+ ASTOBJ_CONTAINER_COMPONENTS(struct aji_transport);
};
-struct xmpp_pvt {
+struct jabber_pvt {
ast_mutex_t lock; /* Channel private lock */
char sid[100];
char from[100];
- struct axi_candidate *candidates;
+ struct aji_candidate *candidates;
struct ast_channel *owner; /* Master Channel */
struct ast_rtp *rtp; /*!< RTP Session */
int jointcapability; /*!< Supported capability at both ends (codecs ) */
int peercapability;
- struct xmpp_pvt *next; /* Next entity */
+ struct jabber_pvt *next; /* Next entity */
};
-struct axi_client {
- ASTOBJ_COMPONENTS(struct axi_client);
+struct aji_client {
+ ASTOBJ_COMPONENTS(struct aji_client);
char password[160];
char user[160];
char server[160];
@@ -92,7 +92,7 @@
iksparser *p;
iksfilter *f;
ikstack *stack;
- enum axi_state state;
+ enum aji_state state;
int port;
int debug;
int usetls;
@@ -103,24 +103,24 @@
int allowguest;
int timeout;
int authorized;
- enum axi_type component;
- struct axi_buddy_container buddies;
+ enum aji_type component;
+ struct aji_buddy_container buddies;
void *jingle;
pthread_t thread;
};
-struct axi_client_container{
- ASTOBJ_CONTAINER_COMPONENTS(struct axi_client);
+struct aji_client_container{
+ ASTOBJ_CONTAINER_COMPONENTS(struct aji_client);
};
-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_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);
-struct axi_client *ast_axi_get_client(char *name);
-struct axi_client_container *ast_axi_get_clients(void);
+int ast_aji_send(struct aji_client *client, char *address, char *message);
+int ast_aji_disconnect(struct aji_client *client);
+int ast_aji_check_roster(void);
+int ast_aji_create_chat(struct aji_client *client,char *room, char *server, char *topic);
+int ast_aji_invite_chat(struct aji_client *client, char *user, char *room, char *message);
+int ast_aji_join_chat(struct aji_client *client,char *room);
+struct aji_client *ast_aji_get_client(char *name);
+struct aji_client_container *ast_aji_get_clients(void);
/* Jingle Constants */
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=19498&r1=19497&r2=19498&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/res/res_xmpp.c (original)
+++ team/mogorman/asterisk-xmpp/res/res_xmpp.c Tue Apr 11 20:43:49 2006
@@ -18,7 +18,7 @@
/*! \file
* \brief A resource for interfacing asterisk directly as a client
- * or a component to a xmpp compliant server.
+ * or a component to a jabber compliant server.
*/
#include <stdlib.h>
@@ -30,7 +30,7 @@
ASTERISK_FILE_VERSION(__FILE__, "$Revision: 1.43 $")
#include "asterisk/channel.h"
-#include "asterisk/xmpp.h"
+#include "asterisk/jabber.h"
#include "asterisk/file.h"
#include "asterisk/config.h"
#include "asterisk/callerid.h"
@@ -46,94 +46,95 @@
#include "asterisk/module.h"
#include "asterisk/astobj.h"
-#define XMPP_CONFIG "xmpp.conf"
+#define JABBER_CONFIG "jabber.conf"
STANDARD_USECOUNT_DECL;
-static int axi_highest_bit(int number);
-static void axi_buddy_destroy(struct axi_buddy *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_act_hook(void *udata, int type, iks * node);
-static void axi_handle_iq(struct axi_client *client, iks *node);
-static void axi_handle_subscribe(struct axi_client *client, ikspak *pak);
-static void *axi_recv_loop(void *data);
-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_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_test(int fd, int argc, char *argv[]);
-static int axi_show_clients(int fd, int argc, char *argv[]);
-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_pruneregister(struct axi_client *client);
-static int axi_register_transport(void *udata,ikspak *pak);
-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 int axi_dinfo_handler(void *udata,ikspak *pak);
-static int axi_ditems_handler(void *udata,ikspak *pak);
+static int aji_highest_bit(int number);
+static void aji_buddy_destroy(struct aji_buddy *obj);
+static void aji_client_destroy(struct aji_client *obj);
+static int aji_send_exec(struct ast_channel *chan, void *data);
+static int aji_status_exec(struct ast_channel *chan, void *data);
+static void aji_log_hook(void *udata, const char *data, size_t size,int is_incoming);
+static int aji_act_hook(void *udata, int type, iks * node);
+static void aji_handle_iq(struct aji_client *client, iks *node);
+static void aji_handle_subscribe(struct aji_client *client, ikspak *pak);
+static void *aji_recv_loop(void *data);
+static int aji_component_initialize(struct aji_client *client);
+static int aji_client_initialize(struct aji_client *client);
+static int aji_client_connect(void *udata, ikspak *pak);
+static int aji_component_connect(void *udata,ikspak *pak);
+static void aji_set_presence(struct aji_client *client,char *user, int level, char *desc);
+static int aji_do_debug(int fd, int argc, char *argv[]);
+static int aji_no_debug(int fd, int argc, char *argv[]);
+static int aji_test(int fd, int argc, char *argv[]);
+static int aji_show_clients(int fd, int argc, char *argv[]);
+static int aji_create_client(char *label,struct ast_variable *var,int debug,int pruneregister,char *utype, struct aji_client *client);
+static int aji_create_buddy(char *label, struct aji_buddy *buddy);
+static int aji_create_transport(char *label, struct aji_buddy *buddy);
+static int aji_load_config(void);
+static void aji_pruneregister(struct aji_client *client);
+static int aji_register_transport(void *udata,ikspak *pak);
+static int aji_register_transport2(void *udata,ikspak *pak);
+void aji_increment_mid(char *mid);
+static int aji_filter_roster(void *udata,ikspak *pak);
+static int aji_dinfo_handler(void *udata,ikspak *pak);
+static int aji_ditems_handler(void *udata,ikspak *pak);
+static int aji_register_handler(void *udata,ikspak *pak);
static char debug_usage[] =
-"Usage: XMPP debug\n"
-" Enables dumping of XMPP packets for debugging purposes\n";
+"Usage: JABBER debug\n"
+" Enables dumping of JABBER packets for debugging purposes\n";
static char test_usage[] =
-"Usage: XMPP no debug\n"
-" Disables dumping of XMPP packets for debugging purposes\n";
+"Usage: JABBER no debug\n"
+" Disables dumping of JABBER packets for debugging purposes\n";
static char no_debug_usage[] =
-"Usage: XMPP test\n"
+"Usage: JABBER test\n"
" Sends test massage for debugging purposes\n";
-static struct ast_cli_entry axi_cli[] = {
- {{"xmpp", "debug", NULL}, axi_do_debug,"Enable XMPP debugging", debug_usage},
- {{"xmpp", "show","connected", NULL}, axi_show_clients,"Show state of clients and components",debug_usage},
- {{"xmpp", "no", "debug", NULL}, axi_no_debug,"Disable XMPP debug", no_debug_usage},
- {{"xmpp", "test", NULL}, axi_test, "Shows roster, but is genearlly used for mog's debugging.", test_usage},
+static struct ast_cli_entry aji_cli[] = {
+ {{"jabber", "debug", NULL}, aji_do_debug,"Enable JABBER debugging", debug_usage},
+ {{"jabber", "show","connected", NULL}, aji_show_clients,"Show state of clients and components",debug_usage},
+ {{"jabber", "no", "debug", NULL}, aji_no_debug,"Disable JABBER debug", no_debug_usage},
+ {{"jabber", "test", NULL}, aji_test, "Shows roster, but is genearlly used for mog's debugging.", test_usage},
};
-static const char *tdesc = "AXI - Asterisk XMPP Interface";
-
-static char *app_axisend = "XMPPSend";
-
-static char *axisend_synopsis = "XMPPSend(XMPP,ScreenName,Message)";
-
-static char *axisend_descrip =
-"XMPPSend(XMPP,ScreenName,Message)\n"
-" XMPP - Client or transport Asterisk uses to connect to XMPP\n"
+static const char *tdesc = "AXI - Asterisk JABBER Interface";
+
+static char *app_ajisend = "JABBERSend";
+
+static char *ajisend_synopsis = "JABBERSend(JABBER,ScreenName,Message)";
+
+static char *ajisend_descrip =
+"JABBERSend(JABBER,ScreenName,Message)\n"
+" JABBER - Client or transport Asterisk uses to connect to JABBER\n"
" ScreenName - User Name to message.\n"
" Message - Message to be sent to the buddy\n";
-static char *app_axistatus = "XMPPStatus";
-
-static char *axistatus_synopsis = "XMPPStatus(XMPP,ScreenName,Variable)";
-
-static char *axistatus_descrip =
-"XMPPStatus(XMPP,ScreenName,Variable)\n"
-" XMPP - Client or transport Asterisk uses to connect to XMPP\n"
+static char *app_ajistatus = "JABBERStatus";
+
+static char *ajistatus_synopsis = "JABBERStatus(JABBER,ScreenName,Variable)";
+
+static char *ajistatus_descrip =
+"JABBERStatus(JABBER,ScreenName,Variable)\n"
+" JABBER - Client or transport Asterisk uses to connect to JABBER\n"
" ScreenName - User Name to retrieve status from.\n"
" Variable - Variable to store presence in will be 1-6.\n"
" In order, Online, Chatty, Away, XAway, DND, Offline\n"
" If not in roster variable will = 7\n";
-struct axi_client_container clients;
-
-/*!
- * \brief Deletes the axi_client data structure.
+struct aji_client_container clients;
+
+/*!
+ * \brief Deletes the aji_client data structure.
* \param obj is the structure we will delete.
* \return void.
*/
-static void axi_client_destroy(struct axi_client *obj)
-{
- ASTOBJ_CONTAINER_DESTROYALL(&obj->buddies,axi_buddy_destroy);
+static void aji_client_destroy(struct aji_client *obj)
+{
+ ASTOBJ_CONTAINER_DESTROYALL(&obj->buddies,aji_buddy_destroy);
ASTOBJ_CONTAINER_DESTROY(&obj->buddies);
free(obj);
@@ -141,11 +142,11 @@
}
/*!
- * \brief Deletes the axi_buddy data structure.
+ * \brief Deletes the aji_buddy data structure.
* \param obj is the structure we will delete.
* \return void.
*/
-static void axi_buddy_destroy(struct axi_buddy *obj)
+static void aji_buddy_destroy(struct aji_buddy *obj)
{
free(obj);
obj =NULL;
@@ -156,7 +157,7 @@
* \param Number you want to have evaluated.
* \return the highest power of 2 that can go into the number.
*/
-static int axi_highest_bit(int number)
+static int aji_highest_bit(int number)
{
int x = sizeof(number) * 8 - 1;
if (!number)
@@ -174,10 +175,10 @@
* \param channel, and username,watched user, status var
* \return 0.
*/
-static int axi_status_exec(struct ast_channel *chan, void *data)
-{
- struct axi_client *client=NULL;
- struct axi_buddy *buddy=NULL;
+static int aji_status_exec(struct ast_channel *chan, void *data)
+{
+ struct aji_client *client=NULL;
+ struct aji_buddy *buddy=NULL;
char *s=NULL,*sender=NULL,*screenname=NULL,*variable=NULL;
int stat=7;
char status[2];
@@ -200,7 +201,7 @@
ast_log(LOG_ERROR, "Out of memory\n");
return -1;
}
- if(strchr(screenname,'@')) { /*real xmpp id */
+ if(strchr(screenname,'@')) { /*real jabber id */
ASTOBJ_CONTAINER_TRAVERSE2(&client->buddies,1,1,{
ASTOBJ_RDLOCK(iterator1);
{
@@ -224,9 +225,9 @@
* \param channel, and data, data is sender, reciever, message.
* \return 0.
*/
-static int axi_send_exec(struct ast_channel *chan, void *data)
-{
- struct axi_client *client=NULL;
+static int aji_send_exec(struct ast_channel *chan, void *data)
+{
+ struct aji_client *client=NULL;
char *s=NULL,*sender=NULL,*recipiant=NULL,*message=NULL;
if (data) {
@@ -249,45 +250,45 @@
return -1;
}
if(client)
- ast_axi_send(client,recipiant,message);
+ ast_aji_send(client,recipiant,message);
return 0;
}
/*!
* \brief the debug loop.
- * \param axi_client structure, xml data as string, size of string, direction of packet, 1 for inbound 0 for outbound.
- */
-static void axi_log_hook(void *udata, const char *data, size_t size,int is_incoming)
-{
- struct axi_client *client = ASTOBJ_REF((struct axi_client *) udata);
+ * \param aji_client structure, xml data as string, size of string, direction of packet, 1 for inbound 0 for outbound.
+ */
+static void aji_log_hook(void *udata, const char *data, size_t size,int is_incoming)
+{
+ struct aji_client *client = ASTOBJ_REF((struct aji_client *) udata);
char *buf = (char *) malloc(size + 1);
memcpy(buf, data, size);
buf[size] = 0;
if (client->debug == 1) {
if (is_incoming)
- ast_verbose("\nXMPP: %s INCOMING: %s\n",client->name, buf);
+ ast_verbose("\nJABBER: %s INCOMING: %s\n",client->name, buf);
else
- ast_verbose("\nXMPP: %s OUTGOING: %s\n",client->name, buf);
+ ast_verbose("\nJABBER: %s OUTGOING: %s\n",client->name, buf);
}
if(client)
- ASTOBJ_UNREF(client, axi_client_destroy);
+ ASTOBJ_UNREF(client, aji_client_destroy);
}
/*!
* \brief The action hook parses the inbound packets, constantly running.
- * \param axi client structure, type of packet, the actual packet.
+ * \param aji client structure, type of packet, the actual packet.
* \return IKS_OK or IKS_HOOK .
*/
-static int axi_act_hook(void *udata, int type, iks * node)
-{
- struct axi_client *client;
+static int aji_act_hook(void *udata, int type, iks * node)
+{
+ struct aji_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);
+ client = (struct aji_client *)malloc(sizeof(struct aji_client));
+ memset(client,0,sizeof(struct aji_client));
+ client = ASTOBJ_REF((struct aji_client *) udata);
iks_filter_packet (client->f,pak);
if(client->component == AXI_CLIENT) {
@@ -299,11 +300,11 @@
}
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);
+ iks_filter_add_rule (client->f, aji_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);
+ aji_increment_mid(client->mid);
iks_send(client->p,auth);
if(auth)
iks_delete(auth);
@@ -321,24 +322,24 @@
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);
+ iks_filter_add_rule (client->f, aji_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);
+ aji_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);
+ iks_filter_add_rule (client->f, aji_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);
+ aji_increment_mid(client->mid);
iks_send(client->p,auth);
if(auth)
iks_delete(auth);
}
} else {
- features=axi_highest_bit(features);
+ features=aji_highest_bit(features);
if(features == IKS_STREAM_SASL_MD5)
iks_start_sasl (client->p, IKS_SASL_DIGEST_MD5, client->jid->user, client->password);
else {
@@ -368,19 +369,19 @@
}
}
} else if (!strcmp("failure",iks_name(node))) {
- ast_verbose("XMPP: encryption failure.\n");
+ ast_verbose("JABBER: encryption failure.\n");
} else if (!strcmp("success",iks_name(node))) {
client->authorized=1;
iks_send_header(client->p,client->jid->server);
}
}
case IKS_NODE_ERROR: {
- ast_verbose("XMPP: Node Error\n");
+ ast_verbose("JABBER: Node Error\n");
return IKS_HOOK;
break;
}
case IKS_NODE_STOP: {
- ast_verbose("XMPP: Disconnected\n");
+ ast_verbose("JABBER: Disconnected\n");
return IKS_HOOK;
break;
}
@@ -400,8 +401,10 @@
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);
+ iks_filter_add_rule (client->f, aji_dinfo_handler, client, IKS_RULE_NS, "http://jabber.org/protocol/disco#info", IKS_RULE_DONE);
+ iks_filter_add_rule (client->f, aji_ditems_handler, client, IKS_RULE_NS, "http://jabber.org/protocol/disco#items", IKS_RULE_DONE);
+ iks_filter_add_rule (client->f, aji_register_handler, client, IKS_RULE_NS, "jabber:iq:register", IKS_RULE_DONE);
+
break;
case AXI_ALMOST:
@@ -421,12 +424,12 @@
}
case IKS_NODE_ERROR: {
- ast_verbose("XMPP: Node Error\n");
+ ast_verbose("JABBER: Node Error\n");
return IKS_HOOK;
break;
}
case IKS_NODE_STOP: {
- ast_verbose("XMPP: Disconnected\n");
+ ast_verbose("JABBER: Disconnected\n");
return IKS_HOOK;
break;
}
@@ -435,43 +438,53 @@
switch(pak->type) {
case IKS_PAK_NONE:
- ast_verbose(VERBOSE_PREFIX_3 "XMPP: I Don't know what to do with you NONE\n");
+ ast_verbose(VERBOSE_PREFIX_3 "JABBER: 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");
+ ast_verbose(VERBOSE_PREFIX_3 "JABBER: 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");
+ ast_verbose(VERBOSE_PREFIX_3 "JABBER: 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");
+ aji_handle_subscribe(client,pak);
+ ast_verbose(VERBOSE_PREFIX_3 "JABBER: 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);
+ ast_verbose(VERBOSE_PREFIX_3 "JABBER: I Dont have an IQ!!!\n");
+ aji_handle_iq(client,node);
break;
default:
- ast_verbose(VERBOSE_PREFIX_3 "XMPP: I Dont know %i\n",pak->type );
+ ast_verbose(VERBOSE_PREFIX_3 "JABBER: I Dont know %i\n",pak->type );
break;
}
if (node)
iks_delete(node);
if(client)
- ASTOBJ_UNREF(client, axi_client_destroy);
+ ASTOBJ_UNREF(client, aji_client_destroy);
return IKS_OK;
}
-
-static int axi_ditems_handler(void *udata,ikspak *pak)
+static int aji_register_handler(void *udata,ikspak *pak)
{
int res=0;
- struct axi_client *client;
+ struct aji_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);
+ client = (struct aji_client *)malloc(sizeof(struct aji_client));
+ memset(client,0,sizeof(struct aji_client));
+ client =ASTOBJ_REF((struct aji_client *) udata);
+
+}
+
+static int aji_ditems_handler(void *udata,ikspak *pak)
+{
+ int res=0;
+ struct aji_client *client;
+ char *node = NULL;
+ client = (struct aji_client *)malloc(sizeof(struct aji_client));
+ memset(client,0,sizeof(struct aji_client));
+ client =ASTOBJ_REF((struct aji_client *) udata);
if(!(node = iks_find_attrib(pak->query,"node"))) {
iks *iq, *query, *item;
iq = iks_new("iq");
@@ -544,14 +557,14 @@
}
-static int axi_dinfo_handler(void *udata,ikspak *pak)
+static int aji_dinfo_handler(void *udata,ikspak *pak)
{
int res=0;
- struct axi_client *client;
+ struct aji_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);
+ client = (struct aji_client *)malloc(sizeof(struct aji_client));
+ memset(client,0,sizeof(struct aji_client));
+ client =ASTOBJ_REF((struct aji_client *) udata);
if(!(node = iks_find_attrib(pak->query,"node"))) {
iks *iq, *query, *identity, *disco, *reg, *commands, *gateway, *version, *vcard, *search;
@@ -658,7 +671,7 @@
* \param client structure and the iq node.
* \return void.
*/
-static void axi_handle_iq(struct axi_client *client, iks *node)
+static void aji_handle_iq(struct aji_client *client, iks *node)
{
}
@@ -667,39 +680,39 @@
/*!
* \brief handles subscription requests.
- * \param axi_client struct and xml packet.
+ * \param aji_client struct and xml packet.
* \return void.
*/
-static void axi_handle_subscribe(struct axi_client *client, ikspak *pak)
+static void aji_handle_subscribe(struct aji_client *client, ikspak *pak)
{
int res=0;
switch(pak->subtype)
{
case IKS_TYPE_SUBSCRIBE:
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 );
+ ast_verbose(VERBOSE_PREFIX_3 "JABBER: This is a subcription of type %i\n",pak->subtype );
break;
case IKS_TYPE_SUBSCRIBED:
- ast_verbose(VERBOSE_PREFIX_3 "XMPP: This is a subcription of type %i\n",pak->subtype );
+ ast_verbose(VERBOSE_PREFIX_3 "JABBER: This is a subcription of type %i\n",pak->subtype );
break;
case IKS_TYPE_UNSUBSCRIBE:
- ast_verbose(VERBOSE_PREFIX_3 "XMPP: This is a subcription of type %i\n",pak->subtype );
+ ast_verbose(VERBOSE_PREFIX_3 "JABBER: This is a subcription of type %i\n",pak->subtype );
break;
case IKS_TYPE_UNSUBSCRIBED:
- ast_verbose(VERBOSE_PREFIX_3 "XMPP: This is a subcription of type %i\n",pak->subtype );
+ ast_verbose(VERBOSE_PREFIX_3 "JABBER: This is a subcription of type %i\n",pak->subtype );
break;
default: /*IKS_TYPE_ERROR:*/
- ast_verbose(VERBOSE_PREFIX_3 "XMPP: This is a subcription of type %i\n",pak->subtype );
+ ast_verbose(VERBOSE_PREFIX_3 "JABBER: This is a subcription of type %i\n",pak->subtype );
break;
}
}
/*!
* \brief sends messages.
- * \param axi_client struct , reciever, message.
+ * \param aji_client struct , reciever, message.
* \return 1.
*/
-int ast_axi_send(struct axi_client *client, char *address, char *message)
+int ast_aji_send(struct aji_client *client, char *address, char *message)
{
int res=0;
iks *message_packet;
@@ -710,16 +723,16 @@
if(message_packet)
iks_delete(message_packet);
} else
- ast_verbose("XMPP: Not connected can't send\n");
+ ast_verbose("JABBER: Not connected can't send\n");
return 1;
}
/*!
* \brief create a chatroom.
- * \param axi_client struct , room, server, topic for the room.
+ * \param aji_client struct , room, server, topic for the room.
* \return 0.
*/
-int ast_axi_create_chat(struct axi_client *client,char *room, char *server, char *topic)
+int ast_aji_create_chat(struct aji_client *client,char *room, char *server, char *topic)
{
int res=0;
iks *iq;
@@ -727,17 +740,17 @@
iks_insert_attrib(iq,"type","get");
iks_insert_attrib(iq,"to",server);
iks_insert_attrib(iq,"id",client->mid);
- axi_increment_mid(client->mid);
+ aji_increment_mid(client->mid);
return res;
}
/*!
* \brief join a chatroom.
- * \param axi_client struct , room.
+ * \param aji_client struct , room.
* \return res.
*/
-int ast_axi_join_chat(struct axi_client *client,char *room)
+int ast_aji_join_chat(struct aji_client *client,char *room)
{
int res=0;
iks *p1,*priority, *priority2, *p2;
@@ -767,10 +780,10 @@
/*!
* \brief invite to a chatroom.
- * \param axi_client struct ,user, room, message.
+ * \param aji_client struct ,user, room, message.
* \return res.
*/
-int ast_axi_invite_chat(struct axi_client *client, char *user, char *room, char *message)
+int ast_aji_invite_chat(struct aji_client *client, char *user, char *room, char *message)
{
int res=0;
iks *invite,*body,*namespace;
@@ -779,7 +792,7 @@
namespace = iks_new("x");
iks_insert_attrib(invite,"to",user);
iks_insert_attrib(invite,"id",client->mid);
- axi_increment_mid(client->mid);
+ aji_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);
@@ -798,36 +811,36 @@
/*!
* \brief receive message loop.
- * \param axi_client struct.
+ * \param aji_client struct.
* \return void.
*/
-static void *axi_recv_loop(void *data)
+static void *aji_recv_loop(void *data)
{
int res=0;
- struct axi_client *client = ASTOBJ_REF((struct axi_client *) data);
+ struct aji_client *client = ASTOBJ_REF((struct aji_client *) data);
while (res == IKS_OK) {
res =iks_recv(client->p,1);
if(res==IKS_HOOK) {
- ast_verbose("XMPP: Got hook event.\n");
+ ast_verbose("JABBER: Got hook event.\n");
break;
}
if(res==IKS_NET_TLSFAIL) {
- ast_verbose("XMPP: Failure in tls.\n");
+ ast_verbose("JABBER: Failure in tls.\n");
break;
}
client->timeout--;
if(client->timeout == 0 && client->state !=AXI_CONNECTED) {
res = -1;
- ast_verbose("XMPP: Network Timeout\n");
+ ast_verbose("JABBER: Network Timeout\n");
}
if(res==IKS_NET_RWERR) {
- ast_verbose("XMPP: socket read error\n");
+ ast_verbose("JABBER: socket read error\n");
res=IKS_OK;
}
}
if(client)
- ASTOBJ_UNREF(client, axi_client_destroy);
+ ASTOBJ_UNREF(client, aji_client_destroy);
return 0;
}
@@ -836,7 +849,7 @@
* \param message id.
* \return void.
*/
-void axi_increment_mid(char *mid)
+void aji_increment_mid(char *mid)
{
int i=0;
for(i=strlen(mid)-1;i >= 0;i--)
@@ -853,18 +866,18 @@
/*!
* \brief attempts to register to a transport.
- * \param axi_client struct, and xml packet.
+ * \param aji_client struct, and xml packet.
* \return IKS_FILTER_EAT.
*/
-static int axi_register_transport(void *udata,ikspak *pak)
+static int aji_register_transport(void *udata,ikspak *pak)
{
int res=0;
- struct axi_client *client;
- struct axi_buddy *buddy=NULL;
+ struct aji_client *client;
+ struct aji_buddy *buddy=NULL;
iks *send;
- client = (struct axi_client *)malloc(sizeof(struct axi_client));
- memset(client,0,sizeof(struct axi_client));
- client =ASTOBJ_REF((struct axi_client *) udata);
+ client = (struct aji_client *)malloc(sizeof(struct aji_client));
+ memset(client,0,sizeof(struct aji_client));
+ client =ASTOBJ_REF((struct aji_client *) udata);
ASTOBJ_CONTAINER_TRAVERSE(&client->buddies,1, {
ASTOBJ_RDLOCK(iterator);
if(iterator->btype==AXI_TRANS ) {
@@ -872,20 +885,20 @@
}
ASTOBJ_UNLOCK(iterator);
});
- iks_filter_remove_hook(client->f,axi_register_transport);
- iks_filter_add_rule(client->f,axi_register_transport2,client,
+ iks_filter_remove_hook(client->f,aji_register_transport);
+ iks_filter_add_rule(client->f,aji_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",client->mid);
- axi_increment_mid(client->mid);
+ aji_increment_mid(client->mid);
iks_insert_attrib(send,"from",client->user);
res =iks_send(client->p,send);
if(send)
iks_delete(send);
if(client){
- ASTOBJ_UNREF(client,axi_client_destroy);
+ ASTOBJ_UNREF(client,aji_client_destroy);
}
return IKS_FILTER_EAT;
@@ -893,25 +906,25 @@
/*!
* \brief attempts to register to a transport step 2.
- * \param axi_client struct, and xml packet.
+ * \param aji_client struct, and xml packet.
* \return IKS_FILTER_EAT.
*/
-static int axi_register_transport2(void *udata,ikspak *pak)
+static int aji_register_transport2(void *udata,ikspak *pak)
{
int res=0;
- struct axi_client *client;
- struct axi_buddy *buddy=NULL;
+ struct aji_client *client;
+ struct aji_buddy *buddy=NULL;
iks *regquery, *reguser, *regpass, *regiq;
- client = (struct axi_client *)malloc(sizeof(struct axi_client));
- memset(client,0,sizeof(struct axi_client));
- client =ASTOBJ_REF((struct axi_client *) udata);
+ client = (struct aji_client *)malloc(sizeof(struct aji_client));
+ memset(client,0,sizeof(struct aji_client));
[... 604 lines stripped ...]
More information about the asterisk-commits
mailing list