[asterisk-commits] branch group/asterisk-xmpp r29505 - in /team/group/asterisk-xmpp: include/ast...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon May 22 12:34:53 MST 2006


Author: mogorman
Date: Mon May 22 14:34:52 2006
New Revision: 29505

URL: http://svn.digium.com/view/asterisk?rev=29505&view=rev
Log:
i think the jabber side is ready for trunk.

Modified:
    team/group/asterisk-xmpp/include/asterisk/jabber.h
    team/group/asterisk-xmpp/res/res_jabber.c

Modified: team/group/asterisk-xmpp/include/asterisk/jabber.h
URL: http://svn.digium.com/view/asterisk/team/group/asterisk-xmpp/include/asterisk/jabber.h?rev=29505&r1=29504&r2=29505&view=diff
==============================================================================
--- team/group/asterisk-xmpp/include/asterisk/jabber.h (original)
+++ team/group/asterisk-xmpp/include/asterisk/jabber.h Mon May 22 14:34:52 2006
@@ -41,8 +41,8 @@
 };
 
 enum aji_type {
-	AJI_COMPONENT=0,
-	AJI_CLIENT=1,
+	AJI_COMPONENT,
+	AJI_CLIENT,
 };
 
 struct aji_version {

Modified: team/group/asterisk-xmpp/res/res_jabber.c
URL: http://svn.digium.com/view/asterisk/team/group/asterisk-xmpp/res/res_jabber.c?rev=29505&r1=29504&r2=29505&view=diff
==============================================================================
--- team/group/asterisk-xmpp/res/res_jabber.c (original)
+++ team/group/asterisk-xmpp/res/res_jabber.c Mon May 22 14:34:52 2006
@@ -72,7 +72,7 @@
 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, char *utype);
+static int aji_create_client(char *label, struct ast_variable *var, int debug);
 static int aji_create_buddy(char *label, struct aji_client *client);
 static int aji_create_transport(char *label, struct aji_client *client);
 static void aji_reload(void);
@@ -1338,7 +1338,6 @@
 	int res = 0;
 	while (res == IKS_OK) {
 		res = iks_recv(client->p, 1);
-		ast_verbose("OOKA %s\n", client->jid->full);
 		client->timeout--;
 		if (res == IKS_HOOK) {
 			ast_log(LOG_WARNING, "JABBER: Got hook event.\n");
@@ -1614,7 +1613,6 @@
 	if (x)
 		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;
@@ -1900,7 +1898,7 @@
  * \param label, ast_variable, debug, pruneregister, component/client, aji_client to dump into. 
  * \return 0.
  */
-static int aji_create_client(char *label, struct ast_variable *var, int debug, char *utype)
+static int aji_create_client(char *label, struct ast_variable *var, int debug)
 {
 	char *resource;
 	struct aji_client *client = NULL;
@@ -1914,38 +1912,7 @@
 			memset(client, 0, sizeof(struct aji_client));
 			ASTOBJ_INIT(client);
 			ASTOBJ_WRLOCK(client);
-			client->p = iks_stream_new((client->component == AJI_CLIENT) ? IKS_NS_CLIENT : "jabber:component:accept", client, aji_act_hook);
-			if (!client->p) {
-				ast_log(LOG_WARNING, "Failed to create stream for client '%s'!\n", client->name);
-				return 0;
-			}
-			client->stack = iks_stack_new(8192, 8192);
-			if (!client->stack) {
-				ast_log(LOG_WARNING, "Failed to allocate stack for client '%s'\n", client->name);
-				return 0;
-			}
-			client->f = iks_filter_new();
-			if (!client->f) {
-				ast_log(LOG_WARNING, "Failed to create filter for client '%s'\n", client->name);
-				return 0;
-			}
 			ASTOBJ_CONTAINER_INIT(&client->buddies);
-			iks_set_log_hook(client->p, aji_log_hook);
-			if (!strchr(client->user, '/') && client->component == AJI_CLIENT) {
-				resource = NULL;
-				asprintf(&resource, "%s/asterisk", client->user);
-				if (resource) {
-					client->jid = iks_id_new(client->stack, resource);
-					free(resource);
-				}
-			} else
-				client->jid = iks_id_new(client->stack, client->user);
-			if (client->component == AJI_COMPONENT) {
-				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_query_handler, client, IKS_RULE_SUBTYPE, IKS_TYPE_GET, IKS_RULE_NS, "jabber:iq:register", IKS_RULE_DONE);
-				iks_filter_add_rule(client->f, aji_register_approve_handler, client, IKS_RULE_SUBTYPE, IKS_TYPE_SET, IKS_RULE_NS, "jabber:iq:register", IKS_RULE_DONE);
-			}
 		} else {
 			ast_log(LOG_ERROR, "Out of memory!\n");
 			return 0;
@@ -1965,13 +1932,10 @@
 	client->forcessl = 0;
 	client->keepalive = 1;
 	client->timeout = 20;
+	client->component = AJI_CLIENT;
 	if (flag) client->authorized = 0;
 	client->usesasl = 0;
 	if (flag) client->state = AJI_DISCONNECTED;
-	if (!strcasecmp(utype, "component"))
-		client->component = AJI_COMPONENT;
-	if (!strcasecmp(utype, "client"))
-		client->component = AJI_CLIENT;
 	while (var) {
 		ast_verbose("var->value: %s\n",var->value);
 		if (!strcasecmp(var->name, "username"))
@@ -1986,11 +1950,16 @@
 			client->port = atoi(var->value);
 		else if (!strcasecmp(var->name, "debug"))
 			client->debug = (ast_false(var->value)) ? 0 : 1;
-		else if (!strcasecmp(var->name, "usetls"))
+		else if (!strcasecmp(var->name, "type")){
+			if (!strcasecmp(var->value, "component"))
+				client->component = AJI_COMPONENT;
+		} else if (!strcasecmp(var->name, "usetls")) {
 			client->usetls = (ast_false(var->value)) ? 0 : 1;
-		else if (!strcasecmp(var->name, "usesasl"))
+			ast_verbose("USETLS = %d\n",client->usetls);
+		} else if (!strcasecmp(var->name, "usesasl")) {
 			client->usesasl = (ast_false(var->value)) ? 0 : 1;
-		else if (!strcasecmp(var->name, "forceoldssl"))
+			ast_verbose("USESASL = %d\n",client->usesasl);
+		} else if (!strcasecmp(var->name, "forceoldssl"))
 			client->forcessl = (ast_false(var->value)) ? 0 : 1;
 		else if (!strcasecmp(var->name, "keepalive"))
 			client->keepalive = (ast_false(var->value)) ? 0 : 1;
@@ -2005,6 +1974,21 @@
 		var = var->next;
 	}
 	if(flag) {
+		client->p = iks_stream_new(((client->component == AJI_CLIENT) ? "jabber:client" : "jabber:component:accept"), client, aji_act_hook);
+		if (!client->p) {
+			ast_log(LOG_WARNING, "Failed to create stream for client '%s'!\n", client->name);
+			return 0;
+		}
+		client->stack = iks_stack_new(8192, 8192);
+		if (!client->stack) {
+			ast_log(LOG_WARNING, "Failed to allocate stack for client '%s'\n", client->name);
+			return 0;
+		}
+		client->f = iks_filter_new();
+		if (!client->f) {
+			ast_log(LOG_WARNING, "Failed to create filter for client '%s'\n", client->name);
+			return 0;
+		}
 		if (!strchr(client->user, '/') && client->component == AJI_CLIENT) {
 			resource = NULL;
 			asprintf(&resource, "%s/asterisk", client->user);
@@ -2014,6 +1998,22 @@
 			}
 		} else
 			client->jid = iks_id_new(client->stack, client->user);
+		if (client->component == AJI_COMPONENT) {
+			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_query_handler, client, IKS_RULE_SUBTYPE, IKS_TYPE_GET, IKS_RULE_NS, "jabber:iq:register", IKS_RULE_DONE);
+			iks_filter_add_rule(client->f, aji_register_approve_handler, client, IKS_RULE_SUBTYPE, IKS_TYPE_SET, IKS_RULE_NS, "jabber:iq:register", IKS_RULE_DONE);
+		}
+		if (!strchr(client->user, '/') && client->component == AJI_CLIENT) {
+			resource = NULL;
+			asprintf(&resource, "%s/asterisk", client->user);
+			if (resource) {
+				client->jid = iks_id_new(client->stack, resource);
+				free(resource);
+			}
+		} else
+			client->jid = iks_id_new(client->stack, client->user);
+		iks_set_log_hook(client->p, aji_log_hook);
 		ASTOBJ_UNLOCK(client);
 		ASTOBJ_CONTAINER_LINK(&clients,client);
 	} else {
@@ -2113,7 +2113,6 @@
 static int aji_load_config(void)
 {
 	char *cat = NULL;
-	char *utype = NULL;
 	int debug = 1;
 	struct ast_config *cfg = NULL;
 	struct ast_variable *var = NULL;
@@ -2136,11 +2135,8 @@
 
 	while (cat) {
 		if (strcasecmp(cat, "general")) {
-			utype = ast_variable_retrieve(cfg, cat, "type");
-			if (utype) {
 				var = ast_variable_browse(cfg, cat);
-				aji_create_client(cat, var, debug, utype);
-			}
+				aji_create_client(cat, var, debug);
 		}
 		cat = ast_category_browse(cfg, cat);
 	}



More information about the asterisk-commits mailing list