include "logger.h" and errno.h from asterisk.h - usage shows that they
[asterisk/asterisk.git] / channels / chan_gtalk.c
index f179023..e28684e 100644 (file)
 /*** MODULEINFO
        <depend>iksemel</depend>
        <depend>res_jabber</depend>
-       <use>gnutls</use>
+       <use>openssl</use>
  ***/
 
 #include "asterisk.h"
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
 #include <sys/socket.h>
-#include <errno.h>
-#include <stdlib.h>
 #include <fcntl.h>
 #include <netdb.h>
 #include <netinet/in.h>
@@ -50,19 +44,12 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include <iksemel.h>
 #include <pthread.h>
 
-#ifdef HAVE_GNUTLS
-#include <gcrypt.h>
-GCRY_THREAD_OPTION_PTHREAD_IMPL;
-#endif /* HAVE_GNUTLS */
-
 #include "asterisk/lock.h"
 #include "asterisk/channel.h"
 #include "asterisk/config.h"
-#include "asterisk/logger.h"
 #include "asterisk/module.h"
 #include "asterisk/pbx.h"
 #include "asterisk/options.h"
-#include "asterisk/lock.h"
 #include "asterisk/sched.h"
 #include "asterisk/io.h"
 #include "asterisk/rtp.h"
@@ -203,7 +190,7 @@ static int gtalk_get_codec(struct ast_channel *chan);
 static const struct ast_channel_tech gtalk_tech = {
        .type = "Gtalk",
        .description = "Gtalk Channel Driver",
-       .capabilities = ((AST_FORMAT_MAX_AUDIO << 1) - 1),
+       .capabilities = AST_FORMAT_AUDIO_MASK,
        .requester = gtalk_request,
        .send_digit_begin = gtalk_digit_begin,
        .send_digit_end = gtalk_digit_end,
@@ -441,7 +428,7 @@ static int gtalk_invite(struct gtalk_pvt *p, char *to, char *from, char *sid, in
        iks_insert_node(gtalk, transport);
        iks_insert_node(dcodecs, payload_telephone);
 
-       iks_send(client->connection->p, iq);
+       ast_aji_send(client->connection, iq);
        iks_delete(payload_telephone);
        iks_delete(transport);
        iks_delete(dcodecs);
@@ -478,7 +465,7 @@ static int gtalk_invite_response(struct gtalk_pvt *p, char *to , char *from, cha
        iks_insert_attrib(transport, "xmlns", "http://www.google.com/transport/p2p");
        iks_insert_node(iq,session);
        iks_insert_node(session,transport);
-       iks_send(p->parent->connection->p, iq);
+       ast_aji_send(p->parent->connection, iq);
        iks_delete(transport);
        iks_delete(session);
        iks_delete(iq);
@@ -575,7 +562,7 @@ static int gtalk_response(struct gtalk *client, char *from, ikspak *pak, const c
                                iks_insert_node(response, error);
                        }
                }
-               iks_send(client->connection->p, response);
+               ast_aji_send(client->connection, response);
                if (reason)
                        iks_delete(reason);
                if (error)
@@ -835,7 +822,7 @@ static int gtalk_create_candidates(struct gtalk *client, struct gtalk_pvt *p, ch
                        iks_insert_attrib(candidate, "type", "relay");
                iks_insert_attrib(candidate, "network", "0");
                iks_insert_attrib(candidate, "generation", "0");
-               iks_send(c->p, iq);
+               ast_aji_send(c, iq);
        }
        p->laststun = 0;
 
@@ -1041,7 +1028,7 @@ static int gtalk_action(struct gtalk *client, struct gtalk_pvt *p, const char *a
                        iks_insert_attrib(session, "initiator", p->initiator ? p->us : p->them);
                        iks_insert_attrib(session, "xmlns", "http://www.google.com/session");
                        iks_insert_node(request, session);
-                       iks_send(client->connection->p, request);
+                       ast_aji_send(client->connection, request);
                        iks_delete(session);
                        res = 0;
                }
@@ -1215,9 +1202,6 @@ static int gtalk_add_candidate(struct gtalk *client, ikspak *pak)
        if(!from)
                from = c->jid->full;
 
-       newcandidate = ast_calloc(1, sizeof(*newcandidate));
-       if (!newcandidate)
-               return 0;
        for (tmp = client->p; tmp; tmp = tmp->next) {
                if (iks_find_with_attrib(pak->x, "session", "id", tmp->sid)) {
                        p = tmp;
@@ -1282,7 +1266,7 @@ static int gtalk_add_candidate(struct gtalk *client, ikspak *pak)
        iks_insert_attrib(receipt, "from", from);
        iks_insert_attrib(receipt, "to", iks_find_attrib(pak->x, "from"));
        iks_insert_attrib(receipt, "id", iks_find_attrib(pak->x, "id"));
-       iks_send(c->p, receipt);
+       ast_aji_send(c, receipt);
        iks_delete(receipt);
 
        return 1;
@@ -1455,7 +1439,7 @@ static int gtalk_digit(struct ast_channel *ast, char digit, unsigned int duratio
        } else if (ast->dtmff.frametype == AST_FRAME_DTMF_END || duration != 0) {
                iks_insert_attrib(dtmf, "action", "button-up");
        }
-       iks_send(client->connection->p, iq);
+       ast_aji_send(client->connection, iq);
        iks_delete(iq);
        iks_delete(gtalk);
        iks_delete(dtmf);
@@ -1904,10 +1888,6 @@ static int gtalk_load_config(void)
 /*! \brief Load module into PBX, register channel */
 static int load_module(void)
 {
-#ifdef HAVE_GNUTLS     
-        gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
-#endif /* HAVE_GNUTLS */
-
        ASTOBJ_CONTAINER_INIT(&gtalk_list);
        if (!gtalk_load_config()) {
                ast_log(LOG_ERROR, "Unable to read config file %s. Not loading module.\n", GOOGLE_CONFIG);