mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 12:36:58 +00:00
Simplification of res_jabber code (done at Inria, Paris with Philippe)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@67992 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -70,8 +70,7 @@ static void aji_handle_message(struct aji_client *client, ikspak *pak);
|
|||||||
static void aji_handle_presence(struct aji_client *client, ikspak *pak);
|
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_handle_subscribe(struct aji_client *client, ikspak *pak);
|
||||||
static void *aji_recv_loop(void *data);
|
static void *aji_recv_loop(void *data);
|
||||||
static int aji_component_initialize(struct aji_client *client);
|
static int aji_initialize(struct aji_client *client);
|
||||||
static int aji_client_initialize(struct aji_client *client);
|
|
||||||
static int aji_client_connect(void *data, ikspak *pak);
|
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 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[]);
|
static int aji_do_debug(int fd, int argc, char *argv[]);
|
||||||
@@ -1778,10 +1777,7 @@ static int aji_reconnect(struct aji_client *client)
|
|||||||
if (client->authorized)
|
if (client->authorized)
|
||||||
client->authorized = 0;
|
client->authorized = 0;
|
||||||
|
|
||||||
if(client->component)
|
res = aji_initialize(client);
|
||||||
res = aji_component_initialize(client);
|
|
||||||
else
|
|
||||||
res = aji_client_initialize(client);
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -1831,11 +1827,10 @@ static int aji_client_connect(void *data, ikspak *pak)
|
|||||||
* \param aji_client struct.
|
* \param aji_client struct.
|
||||||
* \return 1.
|
* \return 1.
|
||||||
*/
|
*/
|
||||||
static int aji_client_initialize(struct aji_client *client)
|
static int aji_initialize(struct aji_client *client)
|
||||||
{
|
{
|
||||||
int connected = 0;
|
/* 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);
|
||||||
connected = iks_connect_via(client->p, S_OR(client->serverhost, client->jid->server), client->port, client->jid->server);
|
|
||||||
|
|
||||||
if (connected == IKS_NET_NOCONN) {
|
if (connected == IKS_NET_NOCONN) {
|
||||||
ast_log(LOG_ERROR, "JABBER ERROR: No Connection\n");
|
ast_log(LOG_ERROR, "JABBER ERROR: No Connection\n");
|
||||||
@@ -1843,28 +1838,7 @@ static int aji_client_initialize(struct aji_client *client)
|
|||||||
} else if (connected == IKS_NET_NODNS) {
|
} 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));
|
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;
|
return IKS_HOOK;
|
||||||
} else
|
} else /* if (!connected) phsultan: check if this is needed! */
|
||||||
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)
|
|
||||||
iks_recv(client->p, 30);
|
iks_recv(client->p, 30);
|
||||||
return IKS_OK;
|
return IKS_OK;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user