[asterisk-commits] branch mogorman/asterisk-xmpp r17178 - /team/mogorman/asterisk-xmpp/res/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Apr 3 14:37:56 MST 2006


Author: mogorman
Date: Mon Apr  3 16:37:55 2006
New Revision: 17178

URL: http://svn.digium.com/view/asterisk?rev=17178&view=rev
Log:
the code is documented. sort of.

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=17178&r1=17177&r2=17178&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/res/res_xmpp.c (original)
+++ team/mogorman/asterisk-xmpp/res/res_xmpp.c Mon Apr  3 16:37:55 2006
@@ -64,7 +64,6 @@
 static void axi_handle_iq(struct axi_client *client, iks *node);
 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_client *client);
 static int axi_client_initialize(struct axi_client *client);
@@ -73,16 +72,13 @@
 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[]);
-static int axi_no_debug_component(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_register_struct(struct axi_action *act);
-static int *axi_create_client(char *label,struct ast_variable *var,int debug,int pruneregister,char *utype, char *context, struct ast_codec_pref prefs, 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_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_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);
@@ -104,44 +100,11 @@
 
 static struct ast_cli_entry axi_cli[] = {
 	{{"xmpp", "debug", NULL}, axi_do_debug,"Enable XMPP debugging", debug_usage},
-	{{"xmpp", "debug", "component", NULL}, axi_do_debug_component,"Enable XMPP debugging for a component",debug_usage},
-	{{"xmpp", "debug", "client", NULL}, axi_do_debug_component,"Enable XMPP debugging for a client",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", "no","debug", "component", NULL}, axi_no_debug_component,"Disable XMPP debugging for a component",no_debug_usage},
-	{{"xmpp", "no", "debug", "client", NULL}, axi_no_debug_component,"Disable XMPP debugging for a client",no_debug_usage},
-
 	{{"xmpp", "test", NULL}, axi_test, "Shows roster, but is genearlly used for mog's debugging.", test_usage},
 };
 static char *tdesc = "AXI - Asterisk XMPP Interface";
-
-static struct axi_action *first_action = NULL;
-
-static int global_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW | AST_FORMAT_GSM | AST_FORMAT_H263;
-
-struct axi_client_container clients;
-
-int (*jingle_callback)(struct axi_client *client, iks *node) = NULL;
-
-/*!
- * \brief Deletes the axi_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);
-	ASTOBJ_CONTAINER_DESTROY(&obj->buddies);
-
-	free(obj);
-	obj = NULL;
-}
-
-static void axi_buddy_destroy(struct axi_buddy *obj)
-{
-	free(obj);
-	obj =NULL;
-}
 
 static char *app_axisend = "XMPPSend";
 
@@ -165,6 +128,42 @@
 "	      In order, Online, Chatty, Away, XAway, DND, Offline\n"
 "	      If not in roster variable will = 7\n";
 
+static struct axi_action *first_action = NULL;
+
+struct axi_client_container clients;
+
+int (*jingle_callback)(struct axi_client *client, iks *node) = NULL;
+
+/*!
+ * \brief Deletes the axi_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);
+	ASTOBJ_CONTAINER_DESTROY(&obj->buddies);
+
+	free(obj);
+	obj = NULL;
+}
+
+/*!
+ * \brief Deletes the axi_buddy data structure.
+ * \param obj is the structure we will delete.
+ * \return void.
+ */
+static void axi_buddy_destroy(struct axi_buddy *obj)
+{
+	free(obj);
+	obj =NULL;
+}
+
+/*!
+ * \brief Detects the highest bit in a number.
+ * \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)
 {
 	int x = sizeof(number) * 8 - 1;
@@ -177,6 +176,12 @@
 	return (1 << x);
 }
 
+/*!
+ * \brief Dial plan function status(). puts the status of watched user 
+   into a channel variable.
+ * \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;
@@ -222,6 +227,11 @@
 	return 0;
 }
 
+/*!
+ * \brief Dial plan function to send a message.
+ * \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;
@@ -251,6 +261,10 @@
 	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);
@@ -268,6 +282,11 @@
 		ASTOBJ_UNREF(client, axi_client_destroy);
 }
 
+/*!
+ * \brief Executes a function pointer registered to an event.
+ * \param axi client structure, action type, user, message, type.
+ * \return 0.
+ */
 static int axi_execute(struct axi_client *client, char *action, char *user, char *message, int type)
 {	
 	struct axi_action *tmp = first_action;
@@ -284,13 +303,19 @@
 	return 0;
 }
 
+/*!
+ * \brief The action hook parses the inbound packets, constantly running.
+ * \param axi 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 = ASTOBJ_REF((struct axi_client *) udata);
 	ikspak *pak;
 	pak=iks_packet(node);
-
-//	iks_filter_packet (client->f,pak);
+	
+	iks_filter_packet (client->f,pak);
+
 	switch(type) {
 		case IKS_NODE_START:
 			if(client->usetls &&!iks_is_secure(client->p)) {
@@ -378,7 +403,6 @@
 					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(client,pak);
 					ast_verbose(VERBOSE_PREFIX_3 "XMPP: I Don't know what to do with you MESSAGE\n");
 					break;
 				case IKS_PAK_PRESENCE:
@@ -420,15 +444,11 @@
 	return IKS_OK;
 }
 
-static void axi_handle_message(struct axi_client *client, ikspak *pak)
-{
-/*	ast_verbose("%s\n",pak->id);
-	if(pak->subtype == IKS_TYPE_CHAT)
-	{
-	}
-	*/
-}
-
+/*!
+ * \brief Handles <iq> tags.
+ * \param client structure and the iq node.
+ * \return void.
+ */
 static void axi_handle_iq(struct axi_client *client, iks *node)
 {
 		if(iks_packet(node)->subtype==IKS_TYPE_GET) {
@@ -455,6 +475,11 @@
 		}
 }
 
+/*!
+ * \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;
@@ -473,6 +498,11 @@
 
 }
 
+/*!
+ * \brief walks the list to give update on all stored status in roster.
+ * \param void.
+ * \return 1.
+ */
 int ast_axi_check_roster(void)
 {
 	char action[100];
@@ -486,6 +516,12 @@
 	});
 	return 1;
 }
+
+/*!
+ * \brief checks presence info to see if we care then relays out for events.
+ * \param axi_client struct and xml packet.
+ * \return void.
+ */
 static void axi_handle_presence(struct axi_client *client, ikspak *pak)
 {
 	char action[100];
@@ -511,6 +547,11 @@
 	}
 }
 
+/*!
+ * \brief handles subscription requests.
+ * \param axi_client struct and xml packet.
+ * \return void.
+ */
 static void axi_handle_subscribe(struct axi_client *client, ikspak *pak)
 {
 	int res=0;
@@ -535,6 +576,11 @@
 	}
 }
 
+/*!
+ * \brief sends messages.
+ * \param axi_client struct , reciever, message.
+ * \return 1.
+ */
 int ast_axi_send(struct axi_client *client, char *address, char *message)
 {
 	int res=0;
@@ -550,6 +596,11 @@
 	return 1;
 }
 
+/*!
+ * \brief create a chatroom.
+ * \param axi_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 res=0;
@@ -563,6 +614,11 @@
 	return res; 
 }
 
+/*!
+ * \brief join a chatroom.
+ * \param axi_client struct , room.
+ * \return res.
+ */
 int ast_axi_join_chat(struct axi_client *client,char *room)
 {
 	int res=0;
@@ -588,8 +644,14 @@
 		iks_delete(p2);
 	if(priority2)
 		iks_delete(priority2);
-	return 1;
-}
+	return res;
+}
+
+/*!
+ * \brief invite to a chatroom.
+ * \param axi_client struct ,user, room, message.
+ * \return res.
+ */
 int ast_axi_invite_chat(struct axi_client *client, char *user, char *room, char *message)
 {
 	int res=0;
@@ -612,16 +674,15 @@
 		iks_delete(namespace);
 	if(invite)
 		iks_delete(invite);
-	return 1;
-}
-
-static int axi_recv(struct axi_client *client,int timeout)
-{
-	int res=0;
-	res =iks_recv(client->p, timeout);
 	return res;
 }
 
+
+/*!
+ * \brief receive message loop.
+ * \param axi_client struct.
+ * \return void.
+ */
 static void *axi_recv_loop(void *data)
 {
 	int res=0;
@@ -629,35 +690,38 @@
 	while (res == IKS_OK) {
 		res =iks_recv(client->p,1);
 		if(res==IKS_HOOK) {
-			ast_verbose("HOOK!!!!");
+			ast_verbose("XMPP: Got hook event.\n");
 			break;
 		}
 		if(res==IKS_NET_TLSFAIL) {
-			ast_verbose("FAILURE TLS");
+			ast_verbose("XMPP:  Failure in tls.\n");
 			break;
 		}
 		client->timeout--;
 		if(client->timeout == 0 && client->state !=AXI_CONNECTED) {
 			res = -1;
-			ast_verbose("Network Timeout");
+			ast_verbose("XMPP:  Network Timeout\n");
 		}
 		if(res==IKS_NET_RWERR) {
-			ast_verbose("socket error\n");
+			ast_verbose("XMPP: socket read error\n");
 			res=IKS_OK;
 		}
 
 	}
-	ast_verbose("\n\nIM NOT LISTENING!!!!!!!!!!!\n\n res = %d\n", res);
 	if(client)
 		ASTOBJ_UNREF(client, axi_client_destroy);
-
 	return 0;
 }
 
+/*!
+ * \brief increments the mid field for messages and other events.
+ * \param message id.
+ * \return void.
+ */
 void axi_increment_mid(char *mid)
 {
 	int i=0;
-	for(i=4;i >= 0;i--)
+	for(i=strlen(mid);i >= 0;i--)
 	{
 		if(mid[i]!='z'){
 			mid[i]=mid[i]+ 1;
@@ -668,6 +732,12 @@
 	}
 }
 
+
+/*!
+ * \brief attempts to register to a transport.
+ * \param axi_client struct, and xml packet.
+ * \return IKS_FILTER_EAT.
+ */
 static int axi_register_transport(void *udata,ikspak *pak)
 {
 	int res=0;
@@ -702,6 +772,12 @@
 	return IKS_FILTER_EAT;
 
 }
+
+/*!
+ * \brief attempts to register to a transport step 2.
+ * \param axi_client struct, and xml packet.
+ * \return IKS_FILTER_EAT.
+ */
 static int axi_register_transport2(void *udata,ikspak *pak)
 {
 	int res=0;
@@ -748,7 +824,11 @@
 	return IKS_FILTER_EAT;
 }
 
-
+/*!
+ * \brief goes through roster and prunes users not needed in list, or adds them accordingly.
+ * \param axi_client struct.
+ * \return void.
+ */
 static void axi_pruneregister(struct axi_client *client)
 {
 	int res=0;
@@ -805,6 +885,11 @@
 	ASTOBJ_CONTAINER_PRUNE_MARKED(&client->buddies,axi_buddy_destroy);
 }
 
+/*!
+ * \brief filters the roster packet we get back from server.
+ * \param axi_client struct, and xml packet.
+ * \return IKS_FILTER_EAT.
+ */
 static int axi_filter_roster(void *udata,ikspak *pak)
 {
 	int flag=0;
@@ -840,7 +925,7 @@
 		if(!flag)
 			if(client->pruneregister>=2)
 				iterator->on_roster=AXI_REGISTER;
-//		iks_delete(x);
+		iks_delete(x);
 		
 		ASTOBJ_UNLOCK(iterator);
 	});
@@ -884,15 +969,19 @@
 		x = iks_next(x);
 	}
 	
-//	iks_delete(x);
+	iks_delete(x);
 	axi_pruneregister(client);
-//	iks_filter_remove_hook(client->f,axi_filter_roster);
+	iks_filter_remove_hook(client->f,axi_filter_roster);
 	if(client)
 		ASTOBJ_UNREF(client, axi_client_destroy);
-	ast_verbose("beep\n");
 	return IKS_FILTER_EAT;
 }
 
+/*!
+ * \brief connects as a client to xmpp server.
+ * \param axi_client struct, and xml packet.
+ * \return res.
+ */
 static int axi_client_connect(void *udata,ikspak *pak)
 {
 	int res=0;
@@ -923,6 +1012,12 @@
 
 	return res;
 }
+
+/*!
+ * \brief connects as a component to xmpp server.
+ * \param axi_client struct, and xml packet.
+ * \return IKS_FILTER_EAT.
+ */
 static int axi_component_connect(void *udata,ikspak *pak)
 {
 	int res=0;
@@ -966,6 +1061,11 @@
 	return IKS_FILTER_EAT;
 }
 
+/*!
+ * \brief prepares client for connect.
+ * \param axi_client struct.
+ * \return 1.
+ */
 static int axi_client_initialize(struct axi_client *client)
 {
 	char *resource;
@@ -997,6 +1097,11 @@
 	return 1;
 }
 
+/*!
+ * \brief prepares component for connect.
+ * \param axi_client struct.
+ * \return 1.
+ */
 static int axi_component_initialize(struct axi_client *client)
 {
 	int connected=1;
@@ -1012,6 +1117,11 @@
 return 1;
 }
 
+/*!
+ * \brief disconnect from xmpp server.
+ * \param axi_client struct.
+ * \return 1.
+ */
 int ast_axi_disconnect(struct axi_client *client)
 {
 	if(client) {
@@ -1023,6 +1133,12 @@
 
 	return 1;
 }
+
+/*!
+ * \brief set presence of client.
+ * \param axi_client struct, user to send it to, level, description.
+ * \return void.
+ */
 static void axi_set_presence(struct axi_client *client, char *user, int level, char *desc)
 {
 	int res=0;
@@ -1034,7 +1150,6 @@
 	iks_insert_attrib(cnode,"ext","voice-v1");
 	iks_insert_attrib(cnode,"xmlns","http://jabber.org/protocol/caps");
 	iks_insert_node(presence,cnode);
-//	iks_insert_attrib(presence,"from", user);
 	res =iks_send(client->p, presence);
 	if(cnode)
 		iks_delete(cnode);
@@ -1042,41 +1157,11 @@
 		iks_delete(presence);
 }
 
-static int axi_do_debug_component(int fd, int argc, char *argv[])
-{
-	struct axi_client *temp;
-
-	ast_verbose(VERBOSE_PREFIX_3 "XMPP: Debugging Enabled for %s %s %s %s %s.\n",argv[0],argv[1],argv[2],argv[3],argv[4]);
-	temp = ASTOBJ_CONTAINER_FIND(&clients, argv[4]);
-	if(temp) {
-		temp->debug=1;
-		ast_verbose(VERBOSE_PREFIX_3 "XMPP: Debugging Enabled for %s %s %s %s %s.\n",argv[0],argv[1],argv[2],argv[3],argv[4]);
-		ASTOBJ_UNREF(temp,axi_client_destroy);
-	} else
-		ast_verbose(VERBOSE_PREFIX_3 "XMPP: %s not found.\n",argv[4]);
-
-	return RESULT_SUCCESS;
-
-}
-
-static int axi_no_debug_component(int fd, int argc, char *argv[])
-{
-	struct axi_client *temp;
-
-	ast_verbose(VERBOSE_PREFIX_3 "XMPP: Debugging Disabled for %s %s %s %s %s.\n",argv[0],argv[1],argv[2],argv[3],argv[4]);
-
-	temp = ASTOBJ_CONTAINER_FIND(&clients, argv[5]);
-	if(temp) {
-		temp->debug=0;
-		ast_verbose(VERBOSE_PREFIX_3 "XMPP: Debugging Disabled for %s %s %s %s %s.\n",argv[0],argv[1],argv[2],argv[3],argv[4]);
-		ASTOBJ_UNREF(temp,axi_client_destroy);
-	} else
-		ast_verbose(VERBOSE_PREFIX_3 "XMPP: %s not found.\n",argv[5]);
-
-	return RESULT_SUCCESS;
-
-}
-
+/*!
+ * \brief turnon console debugging.
+ * \param fd, number of args, args.
+ * \return RESULT_SUCCESS.
+ */
 static int axi_do_debug(int fd, int argc, char *argv[])
 {
 	ASTOBJ_CONTAINER_TRAVERSE(&clients,1, {
@@ -1090,7 +1175,11 @@
 
 }
 
-
+/*!
+ * \brief turnoff console debugging.
+ * \param fd, number of args, args.
+ * \return RESULT_SUCCESS.
+ */
 static int axi_no_debug(int fd, int argc, char *argv[])
 {
 	ASTOBJ_CONTAINER_TRAVERSE(&clients,1, {
@@ -1104,6 +1193,11 @@
 
 }
 
+/*!
+ * \brief show client status.
+ * \param fd, number of args, args.
+ * \return RESULT_SUCCESS.
+ */
 static int axi_show_clients(int fd, int argc, char *argv[])
 {
 	char *status="";
@@ -1124,13 +1218,16 @@
 	return RESULT_SUCCESS;
 }
 
+/*!
+ * \brief send test message for debuging.
+ * \param fd, number of args, args.
+ * \return RESULT_SUCCESS.
+ */
 static int axi_test(int fd, int argc, char *argv[])
 {
 	struct axi_client *client;
 	client = ASTOBJ_CONTAINER_FIND(&clients,"asterisk");
 	ast_axi_send(client, "mogorman at astjab.org", "blahblah");
-//	ast_axi_send(client,"ogorman at gmail.com","blah blah blah");
-//	axi_send_call(client,"ogorman at gmail.com");
 	if(client) {
 		ASTOBJ_CONTAINER_TRAVERSE(&client->buddies,1, {
 			ASTOBJ_RDLOCK(iterator);
@@ -1150,6 +1247,11 @@
 	return RESULT_SUCCESS;
 }
 
+/*!
+ * \brief register action to list of actions to be performed on status event.
+ * \param axi_action 
+ * \return 0.
+ */
 static int axi_register_struct(struct axi_action *act)
 {
 	struct axi_action *cur = first_action, *prev = NULL;
@@ -1191,6 +1293,11 @@
 	return 0;
 }
 
+/*!
+ * \brief allows for external apps to register functions to be executed on status events.
+ * \param action,function pointer (ast_client structure, user, message, type) synopsis, description.
+ * \return 0.
+ */
 int ast_axi_register2(const char *action, int (*func)(struct axi_client *client, char *user,char *message, int type), const char *synopsis, const char *description)
 {
 	struct axi_action *cur;
@@ -1211,6 +1318,11 @@
 	return 0;
 }
 
+/*!
+ * \brief register jingle call back function.
+ * \param function pointer ( axi_client client, and xml packet).
+ * \return 0.
+ */
 int ast_axi_jingle_register(int (*func)(struct axi_client *client, iks *node))
 {	
 	if(func) {
@@ -1224,62 +1336,19 @@
 	return 1;
 }
 
-static struct axi_candidate *axi_create_candidate(char *args)
-{
-	char *name, *type, *preference, *protocol;
-	struct axi_candidate *res;
-	res= malloc(sizeof(struct axi_candidate));
-	memset(res,0,sizeof(struct axi_candidate));
-	if(args)
-		name = args;
-	if((args = strchr(args,','))) {
-		*args='\0';
-		args++;
-		preference = args;
-	}
-	if((args = strchr(args, ','))) {
-		*args='\0';
-		args++;
-		protocol=args;
-	}
-	if((args = strchr(args, ','))) {
-		*args='\0';
-		args++;
-		type=args;
-	}
-	if(name)
-		ast_copy_string(res->name,name,sizeof(res->name));
-	if(preference) {
-		res->preference = atof(preference);
-	}
-	if(protocol) {
-		if(!strcasecmp("udp",protocol))
-			res->protocol=AXI_PROTOCOL_UDP;
-		if(!strcasecmp("ssltcp",protocol))
-			res->protocol=AXI_PROTOCOL_SSLTCP;
-	}
-	if(type) {
-		if(!strcasecmp("stun",type))
-			res->type = AXI_CONNECT_STUN;
-		if(!strcasecmp("local",type))
-			res->type = AXI_CONNECT_LOCAL;
-		if(!strcasecmp("relay",type))
-			res->type = AXI_CONNECT_RELAY;
-	}
-
-	return res;
-}
-
-static int *axi_create_client(char *label,struct ast_variable *var, int debug, int pruneregister,char *utype, char *context, struct ast_codec_pref prefs, struct axi_client *client)
+/*!
+ * \brief creates axi_client structure.
+ * \param label, ast_variable, debug, pruneregister, component/client, axi_client to dump into. 
+ * \return 0.
+ */
+static int axi_create_client(char *label,struct ast_variable *var, int debug, int pruneregister,char *utype, struct axi_client *client)
 {
 	struct axi_buddy *buddy;
-	struct axi_candidate *sc;
 
 	if(!client)
 		ast_log(LOG_WARNING, "Out of memory\n");
 	ast_copy_string(client->name, label,sizeof(client->name));
 	ast_copy_string(client->mid, "aaaaa",sizeof(client->mid));
-	ast_copy_string(client->context, context, sizeof(client->context));
 
 	client->debug = debug;
 	client->pruneregister = pruneregister;
@@ -1290,8 +1359,6 @@
 	client->timeout=20;
 	client->authorized=0;
 	client->usesasl=0;
-	client->capability = global_capability;
-	client->prefs=prefs;
 	client->state=AXI_DISCONNECTED;
 	if(!strcasecmp(utype,"component"))
 		client->component=AXI_COMPONENT;
@@ -1312,8 +1379,6 @@
 			ast_copy_string(client->externip, var->value, sizeof(client->externip));
 		else if(!strcasecmp(var->name,"localip"))
 			ast_copy_string(client->localip,var->value,sizeof(client->localip));
-		else if(!strcasecmp(var->name,"context"))
-			ast_copy_string(client->context,var->value,sizeof(client->context));
 		else if(!strcasecmp(var->name,"port"))
 			client->port=atoi(var->value);
 		else if(!strcasecmp(var->name,"debug"))
@@ -1347,18 +1412,17 @@
 			ASTOBJ_CONTAINER_LINK(&client->buddies,buddy);
 			ASTOBJ_UNREF(buddy,axi_buddy_destroy);
 		}
-		else if(!strcasecmp(var->name,"candidate")) {
-			sc = axi_create_candidate(var->value);
-			sc->next = client->candidates;
-			client->candidates = sc;
-		}
-
 		var = var->next;
 	}
 	return 1;
 }
 
-static int *axi_create_transport(char *label, struct axi_buddy *buddy)
+/*!
+ * \brief creates transport.
+ * \param label, buddy to dump it into. 
+ * \return 0.
+ */
+static int axi_create_transport(char *label, struct axi_buddy *buddy)
 {
 	char *server=NULL,*buddyname=NULL,*user=NULL,*pass=NULL;
 	if(!buddy)
@@ -1388,7 +1452,12 @@
 	return 0;
 }
 
-static int *axi_create_buddy(char *label, struct axi_buddy *buddy)
+/*!
+ * \brief creates buddy.
+ * \param label, buddy to dump it into. 
+ * \return 0.
+ */
+static int axi_create_buddy(char *label, struct axi_buddy *buddy)
 {
 	char *channel=NULL;
 	if(!buddy)
@@ -1402,18 +1471,20 @@
 	return 1;
 }
 
+/*!
+ * \brief load config file.
+ * \param void. 
+ * \return 1.
+ */
 static int axi_load_config(void)
 {
 	char *cat=NULL;
 	char *utype=NULL;
-	char context[100];
 	int debug=1, pruneregister=3;
 	struct ast_config *cfg=NULL;
 	struct ast_variable *var;
 	struct axi_client *client;
-	struct ast_codec_pref prefs;
-
-	ast_copy_string(context,"default",sizeof(context));
+
 	cfg = ast_config_load(XMPP_CONFIG);
 	if(!cfg) {
 		ast_log(LOG_WARNING, "No such configuration file %s\n", XMPP_CONFIG);
@@ -1426,15 +1497,9 @@
 		if(!strcasecmp(var->name, "debug"))
 			debug = (ast_false(ast_variable_retrieve(cfg,"general","debug")))?0:1;
 		else if(!strcasecmp(var->name, "noautoprune"))
-			pruneregister = (ast_false(ast_variable_retrieve(cfg,"general","noautoprune")))?pruneregister:pruneregister--;
+			pruneregister = (ast_false(ast_variable_retrieve(cfg,"general","noautoprune")))?pruneregister:pruneregister-1;
 		else if(!strcasecmp(var->name, "noautoregister"))
 			pruneregister = (ast_false(ast_variable_retrieve(cfg,"general","noautoregister")))?pruneregister:pruneregister-2;
-		else if(!strcasecmp(var->name, "context"))
-			ast_copy_string(context,var->value,sizeof(context));
-		else if (!strcasecmp(var->name, "disallow")) 
-			ast_parse_allow_disallow(&prefs, &global_capability, var->value, 0);
-		else if (!strcasecmp(var->name, "allow")) 
-			ast_parse_allow_disallow(&prefs, &global_capability, var->value, 1);
 	}
 
 	while(cat) {
@@ -1446,7 +1511,7 @@
 				memset(client,0,sizeof(struct axi_client));
 				ASTOBJ_INIT(client);
 				ASTOBJ_WRLOCK(client);
-				axi_create_client(cat, var, debug, pruneregister, utype, context, prefs, client);
+				axi_create_client(cat, var, debug, pruneregister, utype, client);
 				ASTOBJ_UNLOCK(client);
 				ASTOBJ_CONTAINER_LINK(&clients,client);
 				ASTOBJ_UNREF(client,axi_client_destroy);
@@ -1457,6 +1522,11 @@
 	return 1;
 }
 
+/*!
+ * \brief grab a axi_client structure by label name.
+ * \param void. 
+ * \return 1.
+ */
 struct axi_client *ast_axi_get_client(char *name)
 {
 	struct axi_client *client = NULL;



More information about the asterisk-commits mailing list