[asterisk-commits] branch mogorman/asterisk-xmpp r24951 - in
/team/mogorman/asterisk-xmpp: chann...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Mon May 8 04:10:56 MST 2006
Author: mogorman
Date: Fri May 5 13:44:31 2006
New Revision: 24951
URL: http://svn.digium.com/view/asterisk?rev=24951&view=rev
Log:
ooh astobj used correctly who would have thunk
Modified:
team/mogorman/asterisk-xmpp/channels/chan_jingle.c
team/mogorman/asterisk-xmpp/res/res_jabber.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=24951&r1=24950&r2=24951&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/channels/chan_jingle.c (original)
+++ team/mogorman/asterisk-xmpp/channels/chan_jingle.c Fri May 5 13:44:31 2006
@@ -69,6 +69,7 @@
#include "asterisk/stringfields.h"
#include "asterisk/utils.h"
#include "asterisk/causes.h"
+#include "asterisk/astobj.h"
#include "asterisk/jabber.h"
#include "asterisk/jingle.h"
@@ -219,6 +220,11 @@
struct jingle_container jingles;
+static void jingle_member_destroy(struct jingle *obj)
+{
+ free(obj);
+ obj = NULL;
+}
static struct jingle *find_jingle(char *name, char *connection)
{
@@ -1344,9 +1350,9 @@
// "Show status of jingle channels", show_jingle_usage, NULL };
-static int jingle_parser(void *udata, ikspak *pak)
-{
- struct jingle *client= ASTOBJ_REF((struct jingle *) udata);
+static int jingle_parser(void *data, ikspak *pak)
+{
+ struct jingle *client= ASTOBJ_REF((struct jingle *) data);
ast_verbose("WOOHOO!!!\n");
if (iks_find_with_attrib(pak->x,GOOGLE_NODE,"type",JINGLE_INITIATE)) {
@@ -1362,6 +1368,7 @@
ast_verbose("not this\n");
jingle_hangup_farend(client, pak);
}
+ ASTOBJ_UNREF(client, jingle_member_destroy);
return IKS_FILTER_EAT;
}
@@ -1460,12 +1467,6 @@
}
ast_verbose("LABEL: %s\n member->name %s\n member->user %s\n",label,member->name,member->user);
return 1;
-}
-
-static void jingle_member_destroy(struct jingle *obj)
-{
- free(obj);
- obj = NULL;
}
static int jingle_load_config(void)
Modified: team/mogorman/asterisk-xmpp/res/res_jabber.c
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-xmpp/res/res_jabber.c?rev=24951&r1=24950&r2=24951&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/res/res_jabber.c (original)
+++ team/mogorman/asterisk-xmpp/res/res_jabber.c Fri May 5 13:44:31 2006
@@ -52,22 +52,20 @@
#define JABBER_CONFIG "jabber.conf"
-static struct module_symbols *me;
-
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_log_hook(void *data, const char *xmpp, size_t size,int is_incoming);
+static int aji_act_hook(void *data, int type, iks * node);
static void aji_handle_iq(struct aji_client *client, iks *node);
static void aji_handle_presence(struct aji_client *client, ikspak *pak);
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_client_connect(void *data, 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[]);
@@ -78,15 +76,15 @@
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);
-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_query_handler(void *udata,ikspak *pak);
-static int aji_register_approve_handler(void *udata,ikspak *pak);
+static int aji_register_transport(void *data,ikspak *pak);
+static int aji_register_transport2(void *data,ikspak *pak);
+static int aji_filter_roster(void *data,ikspak *pak);
+static int aji_dinfo_handler(void *data,ikspak *pak);
+static int aji_ditems_handler(void *data,ikspak *pak);
+static int aji_register_query_handler(void *data,ikspak *pak);
+static int aji_register_approve_handler(void *data,ikspak *pak);
static int aji_reconnect(struct aji_client *client);
-
+static iks * jabber_make_auth (iksid *id, const char *pass, const char *sid);
static char debug_usage[] =
"Usage: JABBER debug\n"
" Enables dumping of JABBER packets for debugging purposes\n";
@@ -165,8 +163,6 @@
static int gtalk_yuck(iks *node)
{
- iks *tmp= node;
- iks *next = tmp;
if(iks_find_with_attrib(node,"c","node","http://www.google.com/xmpp/client/caps"))
return 1;
if(iks_find_with_attrib(node,"c","node","http://psi-im.org/caps"))
@@ -190,10 +186,9 @@
return (1 << x);
}
-iks * jabber_make_auth (iksid *id, const char *pass, const char *sid)
+static iks * jabber_make_auth (iksid *id, const char *pass, const char *sid)
{
iks *x, *y;
- int i;
x = iks_new ("iq");
iks_insert_attrib (x, "type", "set");
y = iks_insert (x, "query");
@@ -332,22 +327,17 @@
* \brief the debug loop.
* \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 = (struct aji_client *) udata;
- char *buf = (char *) malloc(size + 1);
- memcpy(buf, data, size);
- buf[size] = 0;
+static void aji_log_hook(void *data, const char *xmpp, size_t size,int is_incoming)
+{
+ struct aji_client *client = ASTOBJ_REF((struct aji_client *) data);
if (client->debug == 1) {
if (is_incoming)
- ast_verbose("\nJABBER: %s INCOMING: %s\n",client->name, buf);
+ ast_verbose("\nJABBER: %s INCOMING: %s\n",client->name, xmpp);
else
- ast_verbose("\nJABBER: %s OUTGOING: %s\n",client->name, buf);
-
- }
- if(buf)
- free(buf);
-// ASTOBJ_UNREF(client);
+ ast_verbose("\nJABBER: %s OUTGOING: %s\n",client->name, xmpp);
+
+ }
+ ASTOBJ_UNREF(client, aji_client_destroy);
}
/*!
@@ -355,15 +345,14 @@
* \param aji client structure, type of packet, the actual packet.
* \return IKS_OK or IKS_HOOK .
*/
-static int aji_act_hook(void *udata, int type, iks *node)
-{
- struct aji_client *client;
+static int aji_act_hook(void *data, int type, iks *node)
+{
+ struct aji_client *client = ASTOBJ_REF((struct aji_client *) data);
ikspak *pak = NULL;
iks *auth = NULL;
pak = iks_packet(node);
- client = (struct aji_client *) udata;
if(client->component == AJI_CLIENT) {
switch(type) {
@@ -464,11 +453,13 @@
}
case IKS_NODE_ERROR: {
ast_log(LOG_ERROR,"JABBER: Node Error\n");
+ ASTOBJ_UNREF(client, aji_client_destroy);
return IKS_HOOK;
break;
}
case IKS_NODE_STOP: {
ast_log(LOG_WARNING,"JABBER: Disconnected\n");
+ ASTOBJ_UNREF(client, aji_client_destroy);
return IKS_HOOK;
break;
}
@@ -512,11 +503,13 @@
case IKS_NODE_ERROR: {
ast_log(LOG_ERROR,"JABBER: Node Error\n");
+ ASTOBJ_UNREF(client, aji_client_destroy);
return IKS_HOOK;
break;
}
case IKS_NODE_STOP: {
ast_log(LOG_WARNING,"JABBER: Disconnected\n");
+ ASTOBJ_UNREF(client, aji_client_destroy);
return IKS_HOOK;
break;
}
@@ -551,16 +544,16 @@
if (node)
iks_delete(node);
+
+ ASTOBJ_UNREF(client, aji_client_destroy);
return IKS_OK;
}
-static int aji_register_approve_handler(void *udata,ikspak *pak)
-{
- struct aji_client *client = NULL;
+static int aji_register_approve_handler(void *data,ikspak *pak)
+{
+ struct aji_client *client = ASTOBJ_REF((struct aji_client *) data);
iks *iq = NULL, *query = NULL, *item = NULL;
- client = (struct aji_client *) udata;
-
iq = iks_new("iq");
query = iks_new("query");
item = iks_new("item");
@@ -595,16 +588,16 @@
iks_delete(query);
if(item)
iks_delete(item);
-
+ ASTOBJ_UNREF(client, aji_client_destroy);
return IKS_FILTER_EAT;
}
-static int aji_register_query_handler(void *udata,ikspak *pak)
-{
- struct aji_client *client = NULL;
+static int aji_register_query_handler(void *data,ikspak *pak)
+{
+ struct aji_client *client = ASTOBJ_REF((struct aji_client *) data);
char *node = NULL;
- client = (struct aji_client *) udata;
+ client = (struct aji_client *) data;
if(!(node = iks_find_attrib(pak->query,"node"))) {
iks *iq = NULL, *query = NULL, *instructions = NULL;
@@ -632,15 +625,15 @@
if(instructions)
iks_delete(instructions);
}
+ ASTOBJ_UNREF(client, aji_client_destroy);
return IKS_FILTER_EAT;
}
-static int aji_ditems_handler(void *udata,ikspak *pak)
-{
- struct aji_client *client = NULL;
+static int aji_ditems_handler(void *data,ikspak *pak)
+{
+ struct aji_client *client = ASTOBJ_REF((struct aji_client *) data);
char *node = NULL;
- client = (struct aji_client *) udata;
if(!(node = iks_find_attrib(pak->query,"node"))) {
iks *iq = NULL, *query = NULL, *item = NULL;
iq = iks_new("iq");
@@ -726,17 +719,17 @@
if(feature)
iks_delete(feature);
}
-
+
+ ASTOBJ_UNREF(client, aji_client_destroy);
return IKS_FILTER_EAT;
}
-static int aji_dinfo_handler(void *udata,ikspak *pak)
-{
- struct aji_client *client = NULL;
+static int aji_dinfo_handler(void *data,ikspak *pak)
+{
+ struct aji_client *client = ASTOBJ_REF((struct aji_client *) data);
char *node = NULL;
- client = (struct aji_client *) udata;
if(!(node = iks_find_attrib(pak->query,"node"))) {
iks *iq = NULL, *query = NULL, *identity = NULL, *disco = NULL, *reg = NULL, *commands = NULL, *gateway = NULL, *version = NULL, *vcard = NULL, *search = NULL;
@@ -858,6 +851,8 @@
if(feature)
iks_delete(feature);
}
+
+ ASTOBJ_UNREF(client, aji_client_destroy);
return IKS_FILTER_EAT;
}
@@ -1163,8 +1158,8 @@
*/
static void *aji_recv_loop(void *data)
{
+ struct aji_client *client = ASTOBJ_REF((struct aji_client *) data);
int res=0;
- struct aji_client *client = (struct aji_client *) data;
while (res == IKS_OK) {
res = iks_recv(client->p,1);
client->timeout--;
@@ -1188,6 +1183,7 @@
}
}
+ ASTOBJ_UNREF(client, aji_client_destroy);
return 0;
}
@@ -1216,13 +1212,12 @@
* \param aji_client struct, and xml packet.
* \return IKS_FILTER_EAT.
*/
-static int aji_register_transport(void *udata,ikspak *pak)
-{
+static int aji_register_transport(void *data,ikspak *pak)
+{
+ struct aji_client *client = ASTOBJ_REF((struct aji_client *) data);
int res=0;
- struct aji_client *client = NULL;
struct aji_buddy *buddy=NULL;
iks *send = NULL;
- client = (struct aji_client *) udata;
send =iks_make_iq(IKS_TYPE_GET,"jabber:iq:register");
if(client && send) {
ASTOBJ_CONTAINER_TRAVERSE(&client->buddies,1, {
@@ -1246,6 +1241,7 @@
}
if(send)
iks_delete(send);
+ ASTOBJ_UNREF(client, aji_client_destroy);
return IKS_FILTER_EAT;
}
@@ -1255,13 +1251,12 @@
* \param aji_client struct, and xml packet.
* \return IKS_FILTER_EAT.
*/
-static int aji_register_transport2(void *udata,ikspak *pak)
-{
+static int aji_register_transport2(void *data,ikspak *pak)
+{
+ struct aji_client *client = ASTOBJ_REF((struct aji_client *) data);
int res=0;
- struct aji_client *client;
struct aji_buddy *buddy=NULL;
iks *regquery = NULL, *reguser = NULL, *regpass = NULL, *regiq = NULL;
- client = (struct aji_client *) udata;
regiq = iks_new("iq");
regquery = iks_new("query");
reguser = iks_new("username");
@@ -1298,6 +1293,7 @@
iks_delete(reguser);
if(regpass)
iks_delete(regpass);
+ ASTOBJ_UNREF(client, aji_client_destroy);
return IKS_FILTER_EAT;
}
@@ -1370,15 +1366,13 @@
* \param aji_client struct, and xml packet.
* \return IKS_FILTER_EAT.
*/
-static int aji_filter_roster(void *udata,ikspak *pak)
-{
+static int aji_filter_roster(void *data,ikspak *pak)
+{
+ struct aji_client *client = ASTOBJ_REF((struct aji_client *) data);
int flag=0;
iks *x = NULL;
- struct aji_client *client;
struct aji_buddy *buddy;
- client = (struct aji_client *) udata;
-
ASTOBJ_CONTAINER_TRAVERSE(&client->buddies,1, {
ASTOBJ_RDLOCK(iterator);
x = iks_child(pak->query);
@@ -1452,6 +1446,8 @@
iks_delete(x);
aji_pruneregister(client);
iks_filter_remove_hook(client->f,aji_filter_roster);
+
+ ASTOBJ_UNREF(client, aji_client_destroy);
return IKS_FILTER_EAT;
}
@@ -1478,12 +1474,11 @@
* \param aji_client struct, and xml packet.
* \return res.
*/
-static int aji_client_connect(void *udata,ikspak *pak)
-{
+static int aji_client_connect(void *data,ikspak *pak)
+{
+ struct aji_client *client = ASTOBJ_REF((struct aji_client *) data);
int res=0;
- struct aji_client *client = NULL;
iks *roster = NULL;
- client = (struct aji_client *) udata;
roster = iks_make_iq(IKS_TYPE_GET,IKS_NS_ROSTER);
if(roster && client) {
if(client->state==AJI_DISCONNECTED) {
@@ -1505,6 +1500,8 @@
}
if(roster)
iks_delete(roster);
+
+ ASTOBJ_UNREF(client, aji_client_destroy);
return res;
}
More information about the asterisk-commits
mailing list