]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
skypopen: indented
authorGiovanni Maruzzelli <gmaruzz@gmail.com>
Mon, 7 May 2012 17:01:54 +0000 (19:01 +0200)
committerGiovanni Maruzzelli <gmaruzz@gmail.com>
Mon, 7 May 2012 17:02:16 +0000 (19:02 +0200)
src/mod/endpoints/mod_skypopen/mod_skypopen.c
src/mod/endpoints/mod_skypopen/skypopen.h
src/mod/endpoints/mod_skypopen/skypopen_protocol.c

index 7ef273c6d093e917dbae531829850991f80cd884..f489cc613a77b083c6f909980412d6d1aa4d250f 100644 (file)
@@ -112,6 +112,7 @@ char *interface_status[] = {        /* should match SKYPOPEN_STATE_xxx in skypopen.h */
        "PREANSW",
        "DEAD"
 };
+
 char *skype_callflow[] = {             /* should match CALLFLOW_XXX in skypopen.h */
        "IDLE",
        "DOWN",
@@ -381,7 +382,7 @@ static switch_status_t interface_exists(char *the_interface)
                if (tech_pvt->running && tech_pvt->SkypopenHandles.disp) {
                        XEvent e;
                        Atom atom1 = XInternAtom(tech_pvt->SkypopenHandles.disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False);
-                       switch_sleep(20000); 
+                       switch_sleep(20000);
                        XFlush(tech_pvt->SkypopenHandles.disp);
                        memset(&e, 0, sizeof(e));
                        e.xclient.type = ClientMessage;
@@ -739,6 +740,7 @@ static switch_status_t channel_kill_channel(switch_core_session_t *session, int
 
        return SWITCH_STATUS_SUCCESS;
 }
+
 static switch_status_t channel_on_consume_media(switch_core_session_t *session)
 {
        private_t *tech_pvt = NULL;
@@ -765,6 +767,7 @@ static switch_status_t channel_on_soft_execute(switch_core_session_t *session)
        DEBUGA_SKYPE("%s CHANNEL SOFT_EXECUTE\n", SKYPOPEN_P_LOG, tech_pvt->name);
        return SWITCH_STATUS_SUCCESS;
 }
+
 static switch_status_t channel_on_reset(switch_core_session_t *session)
 {
        private_t *tech_pvt = NULL;
@@ -873,9 +876,9 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
                switch_mutex_unlock(tech_pvt->mutex_audio_srv);
 
                if (!bytes_read) {
-                       switch_sleep(1000); //XXX don't like this
+                       switch_sleep(1000);     //XXX don't like this
                        try++;
-                       if (try < 5){
+                       if (try < 5) {
                                DEBUGA_SKYPE("skypopen_audio_read going back to read\n", SKYPOPEN_P_LOG);
                                goto read;
                        }
@@ -940,19 +943,19 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
                                                char *p = digit_str;
                                                switch_channel_t *channel = switch_core_session_get_channel(session);
 
-                                               if(channel){
+                                               if (channel) {
 
                                                        while (p && *p) {
-                                                               switch_dtmf_t dtmf = {0};
+                                                               switch_dtmf_t dtmf = { 0 };
                                                                dtmf.digit = *p;
                                                                dtmf.duration = SWITCH_DEFAULT_DTMF_DURATION;
                                                                switch_channel_queue_dtmf(channel, &dtmf);
                                                                p++;
                                                        }
-                                                       NOTICA("DTMF DETECTED: [%s] new_dtmf_timestamp: %u, delta_t: %u\n", SKYPOPEN_P_LOG, digit_str, (unsigned int) new_dtmf_timestamp,
-                                                                       (unsigned int) (new_dtmf_timestamp - tech_pvt->old_dtmf_timestamp));
+                                                       NOTICA("DTMF DETECTED: [%s] new_dtmf_timestamp: %u, delta_t: %u\n", SKYPOPEN_P_LOG, digit_str,
+                                                                  (unsigned int) new_dtmf_timestamp, (unsigned int) (new_dtmf_timestamp - tech_pvt->old_dtmf_timestamp));
                                                        tech_pvt->old_dtmf_timestamp = new_dtmf_timestamp;
-                                               }else{
+                                               } else {
                                                        WARNINGA("NO CHANNEL ?\n", SKYPOPEN_P_LOG);
                                                }
                                        }
@@ -1077,7 +1080,7 @@ static switch_status_t channel_answer_channel(switch_core_session_t *session)
        return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t * msg)
+static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
 {
        switch_channel_t *channel;
        private_t *tech_pvt;
@@ -1648,7 +1651,7 @@ static switch_status_t load_config(int reload_type)
                        } else {
                                DEBUGA_SKYPE("Initialized XInitThreads!\n", SKYPOPEN_P_LOG);
                        }
-                       switch_sleep(20000); 
+                       switch_sleep(20000);
 #endif /* WIN32 */
 
                        if (interface_id && interface_id < SKYPOPEN_MAX_INTERFACES) {
@@ -1751,8 +1754,7 @@ static switch_status_t load_config(int reload_type)
                                switch_threadattr_detach_set(skypopen_signaling_thread_attr, 0);
                                switch_threadattr_stacksize_set(skypopen_signaling_thread_attr, SWITCH_THREAD_STACKSIZE);
                                //switch_threadattr_priority_increase(skypopen_signaling_thread_attr);
-                               switch_thread_create(&globals.SKYPOPEN_INTERFACES[interface_id].
-                                                                        skypopen_signaling_thread, skypopen_signaling_thread_attr,
+                               switch_thread_create(&globals.SKYPOPEN_INTERFACES[interface_id].skypopen_signaling_thread, skypopen_signaling_thread_attr,
                                                                         skypopen_signaling_thread_func, &globals.SKYPOPEN_INTERFACES[interface_id], skypopen_module_pool);
 
                                switch_sleep(100000);
@@ -1858,8 +1860,8 @@ static switch_status_t load_config(int reload_type)
 
        return SWITCH_STATUS_SUCCESS;
 }
+
 static switch_status_t chat_send(switch_event_t *message_event)
-                                                                
 {
        char *user = NULL, *host, *f_user = NULL, *f_host = NULL, *f_resource = NULL;
        private_t *tech_pvt = NULL;
@@ -1867,7 +1869,7 @@ static switch_status_t chat_send(switch_event_t *message_event)
        char skype_msg[1024];
 
        const char *proto;
-       const char *from; 
+       const char *from;
        const char *to;
        const char *subject;
        const char *body;
@@ -1885,7 +1887,7 @@ static switch_status_t chat_send(switch_event_t *message_event)
        switch_assert(proto != NULL);
 
        //DEBUGA_SKYPE("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=%s, hint=%s)\n", SKYPOPEN_P_LOG, proto, from, to, subject, body, type,
-       //                       hint ? hint : "NULL");
+       //           hint ? hint : "NULL");
        DEBUGA_SKYPE("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, hint=%s)\n", SKYPOPEN_P_LOG, proto, from, to, subject, body,
                                 hint ? hint : "NULL");
 
@@ -1912,9 +1914,8 @@ static switch_status_t chat_send(switch_event_t *message_event)
                if ((host = strchr(user, '@'))) {
                        *host++ = '\0';
                }
-
                //DEBUGA_SKYPE("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=%s, hint=%s)\n", SKYPOPEN_P_LOG, proto, from, to, subject, body, type,
-               //                       hint ? hint : "NULL");
+               //           hint ? hint : "NULL");
                DEBUGA_SKYPE("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, hint=%s)\n", SKYPOPEN_P_LOG, proto, from, to, subject, body,
                                         hint ? hint : "NULL");
                if (hint && strlen(hint)) {
@@ -1950,7 +1951,7 @@ static switch_status_t chat_send(switch_event_t *message_event)
 
                        snprintf(skype_msg, sizeof(skype_msg), "CHAT CREATE %s", to);
                        skypopen_signaling_write(tech_pvt, skype_msg);
-                       switch_sleep(20000); 
+                       switch_sleep(20000);
                }
 
                found = 0;
@@ -1970,7 +1971,9 @@ static switch_status_t chat_send(switch_event_t *message_event)
                        }
                        tried++;
                        if (tried > 20) {
-                               ERRORA("No chat with dialog_partner='%s' was found. (If you're using mod_sms this is a bug of mod_skypopen when using mod_sms, from next incoming message it will probably work...)\n", SKYPOPEN_P_LOG, to);
+                               ERRORA
+                                       ("No chat with dialog_partner='%s' was found. (If you're using mod_sms this is a bug of mod_skypopen when using mod_sms, from next incoming message it will probably work...)\n",
+                                        SKYPOPEN_P_LOG, to);
                                break;
                        }
                        switch_sleep(50000);
@@ -2076,7 +2079,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypopen_shutdown)
                                        XEvent e;
                                        Atom atom1 = XInternAtom(tech_pvt->SkypopenHandles.disp, "SKYPECONTROLAPI_MESSAGE_BEGIN",
                                                                                         False);
-                                       switch_sleep(20000); 
+                                       switch_sleep(20000);
                                        XFlush(tech_pvt->SkypopenHandles.disp);
                                        memset(&e, 0, sizeof(e));
                                        e.xclient.type = ClientMessage;
@@ -2172,7 +2175,7 @@ int dtmf_received(private_t *tech_pvt, char *value)
                if (channel) {
 
                        if (switch_channel_test_flag(channel, CF_BRIDGED)
-                                       && !switch_true(switch_channel_get_variable(channel, "skype_add_outband_dtmf_also_when_bridged"))) {
+                               && !switch_true(switch_channel_get_variable(channel, "skype_add_outband_dtmf_also_when_bridged"))) {
 
 
                                NOTICA
@@ -2194,7 +2197,7 @@ int dtmf_received(private_t *tech_pvt, char *value)
                        WARNINGA("received %c DTMF, but no channel?\n", SKYPOPEN_P_LOG, value[0]);
                }
                switch_core_session_rwunlock(session);
-       }else{
+       } else {
                WARNINGA("received %c DTMF, but no session?\n", SKYPOPEN_P_LOG, value[0]);
        }
 
@@ -2203,14 +2206,14 @@ int dtmf_received(private_t *tech_pvt, char *value)
 
 void *SWITCH_THREAD_FUNC skypopen_do_mod_sms_thread(switch_thread_t *thread, void *obj)
 {
-        switch_event_t *event;
+       switch_event_t *event;
 
 
        event = obj;
-        switch_core_chat_send("GLOBAL", event); /* mod_sms */
-       
+       switch_core_chat_send("GLOBAL", event); /* mod_sms */
+
        return event;
-       
+
 }
 
 
@@ -2218,7 +2221,7 @@ void *SWITCH_THREAD_FUNC skypopen_do_mod_sms_thread(switch_thread_t *thread, voi
 int start_mod_sms_thread(private_t *tech_pvt, switch_event_t *event)
 {
        switch_threadattr_t *mod_sms_thread_thd_attr = NULL;
-        switch_thread_t *mod_sms_thread;
+       switch_thread_t *mod_sms_thread;
 
 
        switch_threadattr_create(&mod_sms_thread_thd_attr, skypopen_module_pool);
@@ -2274,7 +2277,8 @@ int start_audio_threads(private_t *tech_pvt)
        switch_threadattr_priority_increase(tcp_srv_thread_thd_attr);
        switch_mutex_lock(tech_pvt->mutex_thread_audio_srv);
        //DEBUGA_SKYPE("debugging_hangup srv lock\n", SKYPOPEN_P_LOG);
-       if (switch_thread_create(&tech_pvt->tcp_srv_thread, tcp_srv_thread_thd_attr, skypopen_do_tcp_srv_thread, tech_pvt, skypopen_module_pool) == SWITCH_STATUS_SUCCESS) {
+       if (switch_thread_create(&tech_pvt->tcp_srv_thread, tcp_srv_thread_thd_attr, skypopen_do_tcp_srv_thread, tech_pvt, skypopen_module_pool) ==
+               SWITCH_STATUS_SUCCESS) {
                DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPOPEN_P_LOG);
        } else {
                ERRORA("failed to start tcp_srv_thread thread.\n", SKYPOPEN_P_LOG);
@@ -2291,7 +2295,8 @@ int start_audio_threads(private_t *tech_pvt)
        switch_threadattr_priority_increase(tcp_cli_thread_thd_attr);
        switch_mutex_lock(tech_pvt->mutex_thread_audio_cli);
        //DEBUGA_SKYPE("debugging_hangup cli lock\n", SKYPOPEN_P_LOG);
-       if (switch_thread_create(&tech_pvt->tcp_cli_thread, tcp_cli_thread_thd_attr, skypopen_do_tcp_cli_thread, tech_pvt, skypopen_module_pool) == SWITCH_STATUS_SUCCESS) {
+       if (switch_thread_create(&tech_pvt->tcp_cli_thread, tcp_cli_thread_thd_attr, skypopen_do_tcp_cli_thread, tech_pvt, skypopen_module_pool) ==
+               SWITCH_STATUS_SUCCESS) {
                DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPOPEN_P_LOG);
        } else {
                ERRORA("failed to start tcp_cli_thread thread.\n", SKYPOPEN_P_LOG);
@@ -2509,24 +2514,25 @@ SWITCH_STANDARD_API(sk_function)
                goto end;
        }
 
-       
+
        if (!strcasecmp(argv[0], "balances")) {
-           stream->write_function(stream, "  Name  \tBalance\tCurrency\n");
-           stream->write_function(stream, "  ====  \t=======\t========\n");
-           
-           for (tmp_i = 0; tmp_i < SKYPOPEN_MAX_INTERFACES; tmp_i++) {
-               if (strlen(globals.SKYPOPEN_INTERFACES[tmp_i].name)) {
-                       skypopen_signaling_write(&globals.SKYPOPEN_INTERFACES[tmp_i], "GET PROFILE PSTN_BALANCE");
-                       switch_sleep(20000);
-                       
-                       strncpy(tmp_message, globals.SKYPOPEN_INTERFACES[tmp_i].message, sizeof(globals.SKYPOPEN_INTERFACES[tmp_i].message));
-                       
-                       skypopen_signaling_write(&globals.SKYPOPEN_INTERFACES[tmp_i], "GET PROFILE PSTN_BALANCE_CURRENCY");
-                       switch_sleep(20000);
-                       if(strlen(tmp_message)>21 && strlen(globals.SKYPOPEN_INTERFACES[tmp_i].message) > 30)
-                           stream->write_function(stream, "  %s \t%s\t%s\n", globals.SKYPOPEN_INTERFACES[tmp_i].name, tmp_message+21,  globals.SKYPOPEN_INTERFACES[tmp_i].message+30);
-               }
-           }
+               stream->write_function(stream, "  Name  \tBalance\tCurrency\n");
+               stream->write_function(stream, "  ====  \t=======\t========\n");
+
+               for (tmp_i = 0; tmp_i < SKYPOPEN_MAX_INTERFACES; tmp_i++) {
+                       if (strlen(globals.SKYPOPEN_INTERFACES[tmp_i].name)) {
+                               skypopen_signaling_write(&globals.SKYPOPEN_INTERFACES[tmp_i], "GET PROFILE PSTN_BALANCE");
+                               switch_sleep(20000);
+
+                               strncpy(tmp_message, globals.SKYPOPEN_INTERFACES[tmp_i].message, sizeof(globals.SKYPOPEN_INTERFACES[tmp_i].message));
+
+                               skypopen_signaling_write(&globals.SKYPOPEN_INTERFACES[tmp_i], "GET PROFILE PSTN_BALANCE_CURRENCY");
+                               switch_sleep(20000);
+                               if (strlen(tmp_message) > 21 && strlen(globals.SKYPOPEN_INTERFACES[tmp_i].message) > 30)
+                                       stream->write_function(stream, "  %s \t%s\t%s\n", globals.SKYPOPEN_INTERFACES[tmp_i].name, tmp_message + 21,
+                                                                                  globals.SKYPOPEN_INTERFACES[tmp_i].message + 30);
+                       }
+               }
        }
 
        if (!strcasecmp(argv[0], "list")) {
@@ -2542,11 +2548,11 @@ SWITCH_STANDARD_API(sk_function)
 
                for (i = 0; i < SKYPOPEN_MAX_INTERFACES; i++) {
                        if (strlen(globals.SKYPOPEN_INTERFACES[i].name)) {
-                       next_flag_char = i == globals.next_interface ? '*' : ' ';
-                       ib += globals.SKYPOPEN_INTERFACES[i].ib_calls;
-                       ib_failed += globals.SKYPOPEN_INTERFACES[i].ib_failed_calls;
-                       ob += globals.SKYPOPEN_INTERFACES[i].ob_calls;
-                       ob_failed += globals.SKYPOPEN_INTERFACES[i].ob_failed_calls;
+                               next_flag_char = i == globals.next_interface ? '*' : ' ';
+                               ib += globals.SKYPOPEN_INTERFACES[i].ib_calls;
+                               ib_failed += globals.SKYPOPEN_INTERFACES[i].ib_failed_calls;
+                               ob += globals.SKYPOPEN_INTERFACES[i].ob_calls;
+                               ob_failed += globals.SKYPOPEN_INTERFACES[i].ob_failed_calls;
 
                                stream->write_function(stream,
                                                                           "%c %d\t[%s]\t%3u/%u\t%6u/%u\t%s\t%s\t%s\n",
@@ -3011,14 +3017,14 @@ int incoming_chatmessage(private_t *tech_pvt, int which)
                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "chatname", tech_pvt->chatmessages[which].chatname);
                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "id", tech_pvt->chatmessages[which].id);
 /* mod_sms begin */
-                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to", tech_pvt->skype_user);
-                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hint", tech_pvt->name);
-                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_proto", SKYPE_CHAT_PROTO);
-                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_user", tech_pvt->chatmessages[which].from_handle);
-                //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_host", "from_host");
-                //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_full", "from_full");
-                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_user", tech_pvt->name);
-                //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_host", "to_host");
+               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to", tech_pvt->skype_user);
+               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hint", tech_pvt->name);
+               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_proto", SKYPE_CHAT_PROTO);
+               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_user", tech_pvt->chatmessages[which].from_handle);
+               //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_host", "from_host");
+               //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_full", "from_full");
+               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_user", tech_pvt->name);
+               //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_host", "to_host");
 /* mod_sms end */
 
                switch_event_add_body(event, "%s", tech_pvt->chatmessages[which].body);
@@ -3075,18 +3081,18 @@ int incoming_chatmessage(private_t *tech_pvt, int which)
                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "chatname", tech_pvt->chatmessages[which].chatname);
                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "id", tech_pvt->chatmessages[which].id);
 /* mod_sms begin */
-                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to", tech_pvt->skype_user);
-                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hint", tech_pvt->name);
-                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_proto", SKYPE_CHAT_PROTO);
-                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_user", tech_pvt->chatmessages[which].from_handle);
-                //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_host", "from_host");
-                //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_full", "from_full");
-                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_user", tech_pvt->name);
-                //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_host", "to_host");
+               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to", tech_pvt->skype_user);
+               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hint", tech_pvt->name);
+               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_proto", SKYPE_CHAT_PROTO);
+               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_user", tech_pvt->chatmessages[which].from_handle);
+               //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_host", "from_host");
+               //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_full", "from_full");
+               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_user", tech_pvt->name);
+               //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_host", "to_host");
 /* mod_sms end */
 
                switch_event_add_body(event, "%s", tech_pvt->chatmessages[which].body);
-                //switch_core_chat_send("GLOBAL", event); /* mod_sms */
+               //switch_core_chat_send("GLOBAL", event); /* mod_sms */
                start_mod_sms_thread(tech_pvt, event);
                //usleep(20000);
 
@@ -3110,19 +3116,19 @@ static switch_status_t compat_chat_send(const char *proto, const char *from, con
                switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "subject", subject);
                switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "type", type);
                switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "hint", hint);
-               
+
                if (body) {
                        switch_event_add_body(message_event, "%s", body);
                }
        } else {
                abort();
-       }       
+       }
 
        status = chat_send(message_event);
        switch_event_destroy(&message_event);
 
        return status;
-       
+
 }
 
 SWITCH_STANDARD_API(skypopen_chat_function)
@@ -3164,8 +3170,9 @@ SWITCH_STANDARD_API(skypopen_chat_function)
                        goto end;
                } else {
 
-                       NOTICA("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=NULL, hint=%s)\n", SKYPOPEN_P_LOG, SKYPE_CHAT_PROTO, tech_pvt->skype_user,
-                                  argv[1], "SIMPLE MESSAGE", switch_str_nil((char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]), tech_pvt->name);
+                       NOTICA("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=NULL, hint=%s)\n", SKYPOPEN_P_LOG, SKYPE_CHAT_PROTO,
+                                  tech_pvt->skype_user, argv[1], "SIMPLE MESSAGE", switch_str_nil((char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]),
+                                  tech_pvt->name);
 
                        compat_chat_send(SKYPE_CHAT_PROTO, tech_pvt->skype_user, argv[1], "SIMPLE MESSAGE",
                                                         switch_str_nil((char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]), NULL, tech_pvt->name);
index 960d960f82d2a562ac34a5cb1fb5c48aab948115..d2dd51bd37d7650b81ba860117abf999bfc51df5 100644 (file)
@@ -112,7 +112,7 @@ typedef enum {
 #define WARNINGA(...)  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,               "%-*s["SKYPOPEN_SVN_VERSION "] [WARNINGA     %-5d][%-15s][%s,%s] " __VA_ARGS__ );
 #define NOTICA(...)  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,          "%-*s ["SKYPOPEN_SVN_VERSION "] [NOTICA       %-5d][%-15s][%s,%s] " __VA_ARGS__ );
 
-#define SKYPOPEN_P_LOG (int)((20 - (strlen(__FILE__))) + ((__LINE__ - 1000) < 0) + ((__LINE__ - 100) < 0)), " ", __LINE__, tech_pvt ? tech_pvt->name ? tech_pvt->name : "none" : "none", tech_pvt ? interface_status[tech_pvt->interface_state] : "N/A", tech_pvt ? skype_callflow[tech_pvt->skype_callflow] : "N/A" 
+#define SKYPOPEN_P_LOG (int)((20 - (strlen(__FILE__))) + ((__LINE__ - 1000) < 0) + ((__LINE__ - 100) < 0)), " ", __LINE__, tech_pvt ? tech_pvt->name ? tech_pvt->name : "none" : "none", tech_pvt ? interface_status[tech_pvt->interface_state] : "N/A", tech_pvt ? skype_callflow[tech_pvt->skype_callflow] : "N/A"
 
 /*********************************/
 #define SKYPOPEN_CAUSE_NORMAL          1
index 4bb84505e0d888b3f0db8a40103b31e71d32d401..5aa113c3bf2f2c49199f894054f632d9085cc61b 100644 (file)
@@ -378,121 +378,121 @@ int skypopen_signaling_read(private_t *tech_pvt)
                                skypopen_strncpy(prop, where, sizeof(prop) - 1);
                                skypopen_strncpy(value, *stringp, sizeof(value) - 1);
 
- if (!tech_pvt->report_incoming_chatmessages) {
-                               if (!strcasecmp(prop, "STATUS") && !strcasecmp(value, "RECEIVED")) {
-                                       sprintf(msg_to_skype, "SET CHATMESSAGE %s SEEN", id);
-                                       skypopen_signaling_write(tech_pvt, msg_to_skype);
-                               }
-} else {
-                               if (!strcasecmp(prop, "STATUS") && !strcasecmp(value, "RECEIVED")) {
-                                       DEBUGA_SKYPE("RECEIVED CHATMESSAGE %s, let's see which type it is\n", SKYPOPEN_P_LOG, id);
-                                       sprintf(msg_to_skype, "GET CHATMESSAGE %s TYPE", id);
-                                       skypopen_signaling_write(tech_pvt, msg_to_skype);
-                               }
-
-                               if (!strcasecmp(prop, "TYPE") && !strcasecmp(value, "SAID")) {
-                                       DEBUGA_SKYPE("CHATMESSAGE %s is of type SAID, let's get the other infos\n", SKYPOPEN_P_LOG, id);
-                                       found = 0;
-                                       for (i = 0; i < MAX_CHATMESSAGES; i++) {
-                                               if (strlen(tech_pvt->chatmessages[i].id) == 0) {
-                                                       strncpy(tech_pvt->chatmessages[i].id, id, sizeof(tech_pvt->chatmessages[i].id));
-                                                       strncpy(tech_pvt->chatmessages[i].type, value, sizeof(tech_pvt->chatmessages[i].type));
-                                                       found = 1;
-                                                       break;
-                                               }
-                                       }
-                                       if (!found) {
-                                               ERRORA("why we do not have a chatmessages slot free? we have more than %d chatmessages in parallel?\n", SKYPOPEN_P_LOG,
-                                                                        MAX_CHATMESSAGES);
-                                       } else {
-                                               DEBUGA_SKYPE("CHATMESSAGE %s is in position %d in the chatmessages array, type=%s, id=%s\n", SKYPOPEN_P_LOG, id, i,
-                                                                        tech_pvt->chatmessages[i].type, tech_pvt->chatmessages[i].id);
-                                               sprintf(msg_to_skype, "GET CHATMESSAGE %s CHATNAME", id);
+                               if (!tech_pvt->report_incoming_chatmessages) {
+                                       if (!strcasecmp(prop, "STATUS") && !strcasecmp(value, "RECEIVED")) {
+                                               sprintf(msg_to_skype, "SET CHATMESSAGE %s SEEN", id);
                                                skypopen_signaling_write(tech_pvt, msg_to_skype);
-                                               //skypopen_sleep(1000);
-                                               sprintf(msg_to_skype, "GET CHATMESSAGE %s FROM_HANDLE", id);
-                                               skypopen_signaling_write(tech_pvt, msg_to_skype);
-                                               //skypopen_sleep(1000);
-                                               sprintf(msg_to_skype, "GET CHATMESSAGE %s FROM_DISPNAME", id);
-                                               skypopen_signaling_write(tech_pvt, msg_to_skype);
-                                               //skypopen_sleep(1000);
-                                               sprintf(msg_to_skype, "GET CHATMESSAGE %s BODY", id);
+                                       }
+                               } else {
+                                       if (!strcasecmp(prop, "STATUS") && !strcasecmp(value, "RECEIVED")) {
+                                               DEBUGA_SKYPE("RECEIVED CHATMESSAGE %s, let's see which type it is\n", SKYPOPEN_P_LOG, id);
+                                               sprintf(msg_to_skype, "GET CHATMESSAGE %s TYPE", id);
                                                skypopen_signaling_write(tech_pvt, msg_to_skype);
                                        }
-                               }
 
-                               if (!strcasecmp(prop, "CHATNAME")) {
-                                       DEBUGA_SKYPE("CHATMESSAGE %s belongs to the CHAT %s\n", SKYPOPEN_P_LOG, id, value);
-                                       found = 0;
-                                       for (i = 0; i < MAX_CHATMESSAGES; i++) {
-                                               if (!strcmp(tech_pvt->chatmessages[i].id, id)) {
-                                                       strncpy(tech_pvt->chatmessages[i].chatname, value, sizeof(tech_pvt->chatmessages[i].chatname));
-                                                       found = 1;
-                                                       break;
+                                       if (!strcasecmp(prop, "TYPE") && !strcasecmp(value, "SAID")) {
+                                               DEBUGA_SKYPE("CHATMESSAGE %s is of type SAID, let's get the other infos\n", SKYPOPEN_P_LOG, id);
+                                               found = 0;
+                                               for (i = 0; i < MAX_CHATMESSAGES; i++) {
+                                                       if (strlen(tech_pvt->chatmessages[i].id) == 0) {
+                                                               strncpy(tech_pvt->chatmessages[i].id, id, sizeof(tech_pvt->chatmessages[i].id));
+                                                               strncpy(tech_pvt->chatmessages[i].type, value, sizeof(tech_pvt->chatmessages[i].type));
+                                                               found = 1;
+                                                               break;
+                                                       }
                                                }
-                                       }
-                                       if (!found) {
-                                               DEBUGA_SKYPE("why chatmessage %s was not found in the chatmessages array??\n", SKYPOPEN_P_LOG, id);
-                                       }
-                               }
-                               if (!strcasecmp(prop, "FROM_HANDLE")) {
-                                       DEBUGA_SKYPE("CHATMESSAGE %s was sent by FROM_HANDLE %s\n", SKYPOPEN_P_LOG, id, value);
-                                       found = 0;
-                                       for (i = 0; i < MAX_CHATMESSAGES; i++) {
-                                               if (!strcmp(tech_pvt->chatmessages[i].id, id)) {
-                                                       strncpy(tech_pvt->chatmessages[i].from_handle, value, sizeof(tech_pvt->chatmessages[i].from_handle));
-                                                       found = 1;
-                                                       break;
+                                               if (!found) {
+                                                       ERRORA("why we do not have a chatmessages slot free? we have more than %d chatmessages in parallel?\n", SKYPOPEN_P_LOG,
+                                                                  MAX_CHATMESSAGES);
+                                               } else {
+                                                       DEBUGA_SKYPE("CHATMESSAGE %s is in position %d in the chatmessages array, type=%s, id=%s\n", SKYPOPEN_P_LOG, id, i,
+                                                                                tech_pvt->chatmessages[i].type, tech_pvt->chatmessages[i].id);
+                                                       sprintf(msg_to_skype, "GET CHATMESSAGE %s CHATNAME", id);
+                                                       skypopen_signaling_write(tech_pvt, msg_to_skype);
+                                                       //skypopen_sleep(1000);
+                                                       sprintf(msg_to_skype, "GET CHATMESSAGE %s FROM_HANDLE", id);
+                                                       skypopen_signaling_write(tech_pvt, msg_to_skype);
+                                                       //skypopen_sleep(1000);
+                                                       sprintf(msg_to_skype, "GET CHATMESSAGE %s FROM_DISPNAME", id);
+                                                       skypopen_signaling_write(tech_pvt, msg_to_skype);
+                                                       //skypopen_sleep(1000);
+                                                       sprintf(msg_to_skype, "GET CHATMESSAGE %s BODY", id);
+                                                       skypopen_signaling_write(tech_pvt, msg_to_skype);
                                                }
                                        }
-                                       if (!found) {
-                                               DEBUGA_SKYPE("why chatmessage %s was not found in the chatmessages array??\n", SKYPOPEN_P_LOG, id);
-                                       }
 
-                               }
-                               if (!strcasecmp(prop, "FROM_DISPNAME")) {
-                                       DEBUGA_SKYPE("CHATMESSAGE %s was sent by FROM_DISPNAME %s\n", SKYPOPEN_P_LOG, id, value);
-                                       found = 0;
-                                       for (i = 0; i < MAX_CHATMESSAGES; i++) {
-                                               if (!strcmp(tech_pvt->chatmessages[i].id, id)) {
-                                                       strncpy(tech_pvt->chatmessages[i].from_dispname, value, sizeof(tech_pvt->chatmessages[i].from_dispname));
-                                                       found = 1;
-                                                       break;
+                                       if (!strcasecmp(prop, "CHATNAME")) {
+                                               DEBUGA_SKYPE("CHATMESSAGE %s belongs to the CHAT %s\n", SKYPOPEN_P_LOG, id, value);
+                                               found = 0;
+                                               for (i = 0; i < MAX_CHATMESSAGES; i++) {
+                                                       if (!strcmp(tech_pvt->chatmessages[i].id, id)) {
+                                                               strncpy(tech_pvt->chatmessages[i].chatname, value, sizeof(tech_pvt->chatmessages[i].chatname));
+                                                               found = 1;
+                                                               break;
+                                                       }
+                                               }
+                                               if (!found) {
+                                                       DEBUGA_SKYPE("why chatmessage %s was not found in the chatmessages array??\n", SKYPOPEN_P_LOG, id);
                                                }
                                        }
-                                       if (!found) {
-                                               DEBUGA_SKYPE("why chatmessage %s was not found in the chatmessages array??\n", SKYPOPEN_P_LOG, id);
-                                       }
-
-                               }
-                               if (!strcasecmp(prop, "BODY")) {
-                                       DEBUGA_SKYPE("CHATMESSAGE %s has BODY %s\n", SKYPOPEN_P_LOG, id, value);
-                                       found = 0;
-                                       for (i = 0; i < MAX_CHATMESSAGES; i++) {
-                                               if (!strcmp(tech_pvt->chatmessages[i].id, id)) {
-                                                       strncpy(tech_pvt->chatmessages[i].body, value, sizeof(tech_pvt->chatmessages[i].body));
-                                                       found = 1;
-                                                       break;
+                                       if (!strcasecmp(prop, "FROM_HANDLE")) {
+                                               DEBUGA_SKYPE("CHATMESSAGE %s was sent by FROM_HANDLE %s\n", SKYPOPEN_P_LOG, id, value);
+                                               found = 0;
+                                               for (i = 0; i < MAX_CHATMESSAGES; i++) {
+                                                       if (!strcmp(tech_pvt->chatmessages[i].id, id)) {
+                                                               strncpy(tech_pvt->chatmessages[i].from_handle, value, sizeof(tech_pvt->chatmessages[i].from_handle));
+                                                               found = 1;
+                                                               break;
+                                                       }
                                                }
+                                               if (!found) {
+                                                       DEBUGA_SKYPE("why chatmessage %s was not found in the chatmessages array??\n", SKYPOPEN_P_LOG, id);
+                                               }
+
                                        }
-                                       if (!found) {
-                                               DEBUGA_SKYPE("why chatmessage %s was not found in the chatmessages array??\n", SKYPOPEN_P_LOG, id);
-                                       } else {
-                                               DEBUGA_SKYPE
-                                                       ("CHATMESSAGE %s is in position %d in the chatmessages array, type=%s, id=%s, chatname=%s, from_handle=%s, from_dispname=%s, body=%s\n",
-                                                        SKYPOPEN_P_LOG, id, i, tech_pvt->chatmessages[i].type, tech_pvt->chatmessages[i].id, tech_pvt->chatmessages[i].chatname,
-                                                        tech_pvt->chatmessages[i].from_handle, tech_pvt->chatmessages[i].from_dispname, tech_pvt->chatmessages[i].body);
-                                               if (strcmp(tech_pvt->chatmessages[i].from_handle, tech_pvt->skype_user)) {      //if the message was not sent by myself
-                                                       incoming_chatmessage(tech_pvt, i);
-                                                       memset(&tech_pvt->chatmessages[i], '\0', sizeof(&tech_pvt->chatmessages[i]));
-
-                                       sprintf(msg_to_skype, "SET CHATMESSAGE %s SEEN", id);
-                                       skypopen_signaling_write(tech_pvt, msg_to_skype);
+                                       if (!strcasecmp(prop, "FROM_DISPNAME")) {
+                                               DEBUGA_SKYPE("CHATMESSAGE %s was sent by FROM_DISPNAME %s\n", SKYPOPEN_P_LOG, id, value);
+                                               found = 0;
+                                               for (i = 0; i < MAX_CHATMESSAGES; i++) {
+                                                       if (!strcmp(tech_pvt->chatmessages[i].id, id)) {
+                                                               strncpy(tech_pvt->chatmessages[i].from_dispname, value, sizeof(tech_pvt->chatmessages[i].from_dispname));
+                                                               found = 1;
+                                                               break;
+                                                       }
+                                               }
+                                               if (!found) {
+                                                       DEBUGA_SKYPE("why chatmessage %s was not found in the chatmessages array??\n", SKYPOPEN_P_LOG, id);
                                                }
+
                                        }
+                                       if (!strcasecmp(prop, "BODY")) {
+                                               DEBUGA_SKYPE("CHATMESSAGE %s has BODY %s\n", SKYPOPEN_P_LOG, id, value);
+                                               found = 0;
+                                               for (i = 0; i < MAX_CHATMESSAGES; i++) {
+                                                       if (!strcmp(tech_pvt->chatmessages[i].id, id)) {
+                                                               strncpy(tech_pvt->chatmessages[i].body, value, sizeof(tech_pvt->chatmessages[i].body));
+                                                               found = 1;
+                                                               break;
+                                                       }
+                                               }
+                                               if (!found) {
+                                                       DEBUGA_SKYPE("why chatmessage %s was not found in the chatmessages array??\n", SKYPOPEN_P_LOG, id);
+                                               } else {
+                                                       DEBUGA_SKYPE
+                                                               ("CHATMESSAGE %s is in position %d in the chatmessages array, type=%s, id=%s, chatname=%s, from_handle=%s, from_dispname=%s, body=%s\n",
+                                                                SKYPOPEN_P_LOG, id, i, tech_pvt->chatmessages[i].type, tech_pvt->chatmessages[i].id, tech_pvt->chatmessages[i].chatname,
+                                                                tech_pvt->chatmessages[i].from_handle, tech_pvt->chatmessages[i].from_dispname, tech_pvt->chatmessages[i].body);
+                                                       if (strcmp(tech_pvt->chatmessages[i].from_handle, tech_pvt->skype_user)) {      //if the message was not sent by myself
+                                                               incoming_chatmessage(tech_pvt, i);
+                                                               memset(&tech_pvt->chatmessages[i], '\0', sizeof(&tech_pvt->chatmessages[i]));
+
+                                                               sprintf(msg_to_skype, "SET CHATMESSAGE %s SEEN", id);
+                                                               skypopen_signaling_write(tech_pvt, msg_to_skype);
+                                                       }
+                                               }
 
+                                       }
                                }
-}
 
                        }
 
@@ -896,7 +896,7 @@ void *skypopen_do_tcp_srv_thread_func(void *obj)
                                                   || tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD || tech_pvt->skype_callflow == SKYPOPEN_STATE_UP)) {
 
                                        //unsigned int fdselect;
-                                       int rt=1;
+                                       int rt = 1;
                                        //fd_set fs;
                                        //struct timeval to;
                                        int nospace;
@@ -1033,7 +1033,7 @@ void *skypopen_do_tcp_cli_thread_func(void *obj)
                if (!(running && tech_pvt->running))
                        break;
                FD_ZERO(&fsgio);
-               togio.tv_usec = MS_SKYPOPEN * 1000 * 3; 
+               togio.tv_usec = MS_SKYPOPEN * 1000 * 3;
                togio.tv_sec = 0;
                fdselectgio = s;
                FD_SET(fdselectgio, &fsgio);
@@ -1148,7 +1148,7 @@ int skypopen_senddigit(private_t *tech_pvt, char digit)
        char msg_to_skype[1024];
 
        DEBUGA_SKYPE("DIGIT received: %c\n", SKYPOPEN_P_LOG, digit);
-       if(digit != 'a' && digit != 'A'  && digit != 'b' && digit != 'B' && digit != 'c' && digit != 'C' && digit != 'd' && digit != 'D'){
+       if (digit != 'a' && digit != 'A' && digit != 'b' && digit != 'B' && digit != 'c' && digit != 'C' && digit != 'd' && digit != 'D') {
                sprintf(msg_to_skype, "SET CALL %s DTMF %c", tech_pvt->skype_call_id, digit);
                skypopen_signaling_write(tech_pvt, msg_to_skype);
        } else {
@@ -1701,7 +1701,7 @@ void skypopen_clean_disp(void *data)
                DEBUGA_SKYPE("NOT destroyed disp\n", SKYPOPEN_P_LOG);
        }
        DEBUGA_SKYPE("OUT destroyed disp\n", SKYPOPEN_P_LOG);
-       skypopen_sleep(20000); 
+       skypopen_sleep(20000);
 }
 
 void *skypopen_do_skypeapi_thread_func(void *obj)
@@ -1761,7 +1761,7 @@ void *skypopen_do_skypeapi_thread_func(void *obj)
                        if (session) {
                                switch_channel_t *channel = switch_core_session_get_channel(session);
 
-                               if(channel){
+                               if (channel) {
 
                                        switch_mutex_lock(tech_pvt->flag_mutex);
                                        switch_clear_flag(tech_pvt, TFLAG_IO);
@@ -1798,7 +1798,7 @@ void *skypopen_do_skypeapi_thread_func(void *obj)
                                switch_channel_t *channel = switch_core_session_get_channel(session);
 
 
-                               if(channel){
+                               if (channel) {
                                        switch_mutex_lock(tech_pvt->flag_mutex);
                                        switch_clear_flag(tech_pvt, TFLAG_IO);
                                        switch_clear_flag(tech_pvt, TFLAG_VOICE);
@@ -1910,7 +1910,7 @@ void *skypopen_do_skypeapi_thread_func(void *obj)
                                                case ClientMessage:
 
                                                        if (an_event.xclient.format != 8) {
-                                                               //skypopen_sleep(1000); //0.1 msec
+                                                               //skypopen_sleep(1000); //0.1 msec
                                                                break;
                                                        }
 
@@ -1970,11 +1970,10 @@ void *skypopen_do_skypeapi_thread_func(void *obj)
                                                                //XFlush(disp);
                                                                there_were_continues = 0;
                                                        }
-
-                                                       //skypopen_sleep(1000); //0.1 msec
+                                                       //skypopen_sleep(1000); //0.1 msec
                                                        break;
                                                default:
-                                                       //skypopen_sleep(1000); //0.1 msec
+                                                       //skypopen_sleep(1000); //0.1 msec
                                                        break;
                                                }               //switch event.type
                                        }                       //while XPending