[asterisk-commits] oej: trunk r67992 - /trunk/res/res_jabber.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Jun 7 01:45:20 MST 2007


Author: oej
Date: Thu Jun  7 03:45:19 2007
New Revision: 67992

URL: http://svn.digium.com/view/asterisk?view=rev&rev=67992
Log:
Simplification of res_jabber code (done at Inria, Paris with Philippe)

Modified:
    trunk/res/res_jabber.c

Modified: trunk/res/res_jabber.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_jabber.c?view=diff&rev=67992&r1=67991&r2=67992
==============================================================================
--- trunk/res/res_jabber.c (original)
+++ trunk/res/res_jabber.c Thu Jun  7 03:45:19 2007
@@ -70,8 +70,7 @@
 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_initialize(struct aji_client *client);
 static int aji_client_connect(void *data, ikspak *pak);
 static void aji_set_presence(struct aji_client *client, char *to, char *from, int level, char *desc);
 static int aji_do_debug(int fd, int argc, char *argv[]);
@@ -1778,10 +1777,7 @@
 	if (client->authorized)
 		client->authorized = 0;
 
-	if(client->component)
-		res = aji_component_initialize(client);
-	else
-		res = aji_client_initialize(client);
+	res = aji_initialize(client);
 
 	return res;
 }
@@ -1831,11 +1827,10 @@
  * \param aji_client struct.
  * \return 1.
  */
-static int aji_client_initialize(struct aji_client *client)
-{
-	int connected = 0;
-
-	connected = iks_connect_via(client->p, S_OR(client->serverhost, client->jid->server), client->port, client->jid->server);
+static int aji_initialize(struct aji_client *client)
+{
+	/* If it's a component, connect to user, otherwise, connect to server */
+	int connected = iks_connect_via(client->p, S_OR(client->serverhost, client->jid->server), client->port, client->component ? client->user : client->jid->server);
 
 	if (connected == IKS_NET_NOCONN) {
 		ast_log(LOG_ERROR, "JABBER ERROR: No Connection\n");
@@ -1843,28 +1838,7 @@
 	} else 	if (connected == IKS_NET_NODNS) {
 		ast_log(LOG_ERROR, "JABBER ERROR: No DNS %s for client to  %s\n", client->name, S_OR(client->serverhost, client->jid->server));
 		return IKS_HOOK;
-	} else
-		iks_recv(client->p, 30);
-	return IKS_OK;
-}
-
-/*!
- * \brief prepares component for connect.
- * \param aji_client struct.
- * \return 1.
- */
-static int aji_component_initialize(struct aji_client *client)
-{
-	int connected = 1;
-
-	connected = iks_connect_via(client->p, S_OR(client->serverhost, client->jid->server), client->port, client->user);
-	if (connected == IKS_NET_NOCONN) {
-		ast_log(LOG_ERROR, "JABBER ERROR: No Connection\n");
-		return IKS_HOOK;
-	} else if (connected == IKS_NET_NODNS) {
-		ast_log(LOG_ERROR, "JABBER ERROR: No DNS %s for client to  %s\n", client->name, S_OR(client->serverhost, client->jid->server));
-		return IKS_HOOK;
-	} else if (!connected) 
+	} else /* if (!connected) phsultan: check if this is needed! */
 		iks_recv(client->p, 30);
 	return IKS_OK;
 }



More information about the asterisk-commits mailing list