]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
sip is fun
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 14 Dec 2007 00:00:57 +0000 (00:00 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 14 Dec 2007 00:00:57 +0000 (00:00 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6774 d0543943-73ff-0310-b7d9-9358b9ac24b2

conf/autoload_configs/console.conf.xml
libs/curl/lib/config.h.in
src/mod/applications/mod_voicemail/mod_voicemail.c
src/mod/endpoints/mod_sofia/sofia_glue.c
src/mod/endpoints/mod_sofia/sofia_presence.c

index 12407ee2485b002a3a2cf1d1cd8407db42baf21e..76508cb17e16227ca060bc22052f3afae6fc6d6d 100644 (file)
@@ -6,7 +6,7 @@
         name can be a file name, function name or 'all' 
         value is one or more of debug,info,notice,warning,err,crit,alert,all
     -->
-    <map name="all" value="info,notice,warning,err,crit,alert"/>
+    <map name="all" value="debug,info,notice,warning,err,crit,alert"/>
   </mappings>
   <settings>
     <!-- comment or set to false for no color logging -->
index 4bc60b0df18042938b2435bfe78e445fc9ee644c..8602189707771fc5967cc202d5692b079195dda1 100644 (file)
 /* Define to the function return type for send. */
 #undef SEND_TYPE_RETV
 
-/* The size of `curl_off_t', as computed by sizeof. */
+/* The size of `curl_off_t', as computed by sizeof. */
 #undef SIZEOF_CURL_OFF_T
 
-/* The size of `long', as computed by sizeof. */
+/* The size of `long', as computed by sizeof. */
 #undef SIZEOF_LONG
 
-/* The size of `size_t', as computed by sizeof. */
+/* The size of `size_t', as computed by sizeof. */
 #undef SIZEOF_SIZE_T
 
-/* The size of `time_t', as computed by sizeof. */
+/* The size of `time_t', as computed by sizeof. */
 #undef SIZEOF_TIME_T
 
 /* Define to 1 if you have the ANSI C header files. */
 /* type to use in place of in_addr_t if not defined */
 #undef in_addr_t
 
-/* Define to `unsigned int' if <sys/types.h> does not define. */
+/* Define to `unsigned' if <sys/types.h> does not define. */
 #undef size_t
 
 /* type to use in place of socklen_t if not defined */
index ebed811d2976e7a9bd36a999ddc3495ce90af76f..3cc0985ee207c5ad262c7511806d2ad1bd688f4d 100644 (file)
@@ -1361,6 +1361,8 @@ static void voicemail_check_main(switch_core_session_t *session, const char *pro
                 listen_callback_t cbt;
                 char sql[256];
                 int cur_message, total_messages;
+                switch_event_t *event;
+                
                 message_count(profile, myid, domain_name, myfolder, &total_new_messages, &total_saved_messages, 
                               &total_new_urgent_messages, &total_saved_urgent_messages);
                 memset(&cbt, 0, sizeof(cbt));
@@ -1402,6 +1404,26 @@ static void voicemail_check_main(switch_core_session_t *session, const char *pro
                 switch_snprintf(sql, sizeof(sql), "delete from voicemail_data where user='%s' and domain='%s' and flags='delete'", myid, domain_name);
                 vm_execute_sql(profile, sql, profile->mutex);
                 vm_check_state = VM_CHECK_FOLDER_SUMMARY;
+
+                
+                message_count(profile, id, domain_name, myfolder, &total_new_messages, &total_saved_messages,
+                              &total_new_urgent_messages, &total_saved_urgent_messages);
+
+                if (switch_event_create(&event, SWITCH_EVENT_MESSAGE_WAITING) == SWITCH_STATUS_SUCCESS) {
+                    char *mwi_id;
+                    const char *yn = "no";
+                    if (total_new_messages || total_saved_messages || total_new_urgent_messages || total_saved_urgent_messages) {
+                        yn = "yes";
+                    }
+                    mwi_id = switch_mprintf("%s@%s", myid, domain_name);
+                    switch_assert(mwi_id);
+                    switch_event_add_header(event, SWITCH_STACK_BOTTOM, "MWI-Messages-Waiting", "%s", yn);
+                    switch_event_add_header(event, SWITCH_STACK_BOTTOM, "MWI-Message-Account", mwi_id);
+                    switch_event_add_header(event, SWITCH_STACK_BOTTOM, "MWI-Voice-Message", "%d/%d (%d/%d)", 
+                                            total_new_messages, total_saved_messages, total_new_urgent_messages, total_saved_urgent_messages);
+                    switch_event_fire(&event);
+                    switch_safe_free(mwi_id);
+                } 
             }
             break;
         case VM_CHECK_CONFIG:
@@ -1907,8 +1929,12 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, cons
                       &total_new_urgent_messages, &total_saved_urgent_messages);
 
         if (switch_event_create(&event, SWITCH_EVENT_MESSAGE_WAITING) == SWITCH_STATUS_SUCCESS) {
+            const char *yn = "no";
+            if (total_new_messages || total_saved_messages || total_new_urgent_messages || total_saved_urgent_messages) {
+                yn = "yes";
+            }
             mwi_id = switch_mprintf("%s@%s", id, domain_name);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "MWI-Messages-Waiting", "yes");
+            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "MWI-Messages-Waiting", "%s", yn);
             switch_event_add_header(event, SWITCH_STACK_BOTTOM, "MWI-Message-Account", mwi_id);
             switch_event_add_header(event, SWITCH_STACK_BOTTOM, "MWI-Voice-Message", "%d/%d (%d/%d)", 
                                     total_new_messages, total_saved_messages, total_new_urgent_messages, total_saved_urgent_messages);
@@ -2163,7 +2189,11 @@ static void  message_query_handler(switch_event_t *event)
                               &total_new_urgent_messages, &total_saved_urgent_messages);
                 if (total_new_messages || total_saved_messages) {
                     if (switch_event_create(&new_event, SWITCH_EVENT_MESSAGE_WAITING) == SWITCH_STATUS_SUCCESS) {
-                        switch_event_add_header(new_event, SWITCH_STACK_BOTTOM, "MWI-Messages-Waiting", "yes");
+                        const char *yn = "no";
+                        if (total_new_messages || total_saved_messages || total_new_urgent_messages || total_saved_urgent_messages) {
+                            yn = "yes";
+                        }
+                        switch_event_add_header(new_event, SWITCH_STACK_BOTTOM, "MWI-Messages-Waiting", "%s", yn);
                         switch_event_add_header(new_event, SWITCH_STACK_BOTTOM, "MWI-Message-Account", account);
                         switch_event_add_header(new_event, SWITCH_STACK_BOTTOM, "MWI-Voice-Message", "%d/%d (%d/%d)", 
                                                 total_new_messages, total_saved_messages, total_new_urgent_messages, total_saved_urgent_messages);
index 0ab91f4ea58fdc7fc68909f0c05158528b523e42..8c34aca8180b824ff0e4a04fa2cdc191cf16c7f5 100644 (file)
@@ -1736,7 +1736,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
                        switch_odbc_handle_exec(profile->master_odbc, reg_sql, NULL);
                }
 
-               if (switch_odbc_handle_exec(profile->master_odbc, "select * from sip_subscriptions where sip_user == ''", NULL) != SWITCH_ODBC_SUCCESS) {
+               if (switch_odbc_handle_exec(profile->master_odbc, "delete from sip_subscriptions where sip_user != ''", NULL) != SWITCH_ODBC_SUCCESS) {
                        switch_odbc_handle_exec(profile->master_odbc, "DROP TABLE sip_subscriptions", NULL);
                        switch_odbc_handle_exec(profile->master_odbc, sub_sql, NULL);
                }
@@ -1754,7 +1754,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
                }
 
                switch_core_db_test_reactive(profile->master_db, "select sip_user from sip_registrations", "DROP TABLE sip_registrations", reg_sql);
-               switch_core_db_test_reactive(profile->master_db, "select * from sip_subscriptions where sip_user == ''", "DROP TABLE sip_subscriptions", sub_sql);
+               switch_core_db_test_reactive(profile->master_db, "delete * from sip_subscriptions where sip_user != ''", "DROP TABLE sip_subscriptions", sub_sql);
                switch_core_db_test_reactive(profile->master_db, "select * from sip_authentication", "DROP TABLE sip_authentication", auth_sql);
 
        }
index 26a61bbe05d7011929295c21b955aec9fcfb3990..157f1dc07b19d63d9dbf7ad8adc53e7a5967d477 100644 (file)
@@ -647,7 +647,7 @@ static int sofia_presence_mwi_callback(void *pArg, int argc, char **argv, char *
        nua_handle_t *nh;
        int expire_sec = atoi(expires);
        int *total = (int *) pArg;
-
+       
        if (!(profile = sofia_glue_find_profile(sub_to_host))) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find profile for host %s\n", sub_to_host);
                return 0;
@@ -673,7 +673,7 @@ static int sofia_presence_mwi_callback(void *pArg, int argc, char **argv, char *
        switch_safe_free(exp);
 
        sofia_glue_release_profile(profile);
-       *total++;
+       (*total)++;
        return 0;
 }
 
@@ -689,27 +689,32 @@ static int sofia_presence_mwi_callback2(void *pArg, int argc, char **argv, char
        sofia_profile_t *profile = NULL;
        char *id = NULL;
        nua_handle_t *nh;
-
+       char *contact;
+       
        if (!(profile = sofia_glue_find_profile(sub_to_host))) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find profile for host %s\n", sub_to_host);
                return 0;
        }
 
        id = switch_mprintf("sip:%s@%s", sub_to_user, sub_to_host);
+
+       contact = sofia_glue_get_url_from_contact(argv[3], 0);
        
        nh = nua_handle(profile->nua, NULL,
+                                       NUTAG_URL(contact),
                                        SIPTAG_FROM_STR(id),
-                                       SIPTAG_TO_STR(id), SIPTAG_CONTACT_STR(profile->url), TAG_END());
-       
+                                       SIPTAG_TO_STR(id),
+                                       SIPTAG_CONTACT_STR(profile->url),
+                                       TAG_END());
        
        nua_notify(nh,
                           NUTAG_NEWSUB(1),
                           SIPTAG_EVENT_STR(event), SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"), SIPTAG_PAYLOAD_STR(body), TAG_END());
 
        switch_safe_free(id);
-
+       
        sofia_glue_release_profile(profile);
-
+       
        return 0;
 }