From 9e9695a3d352ebf99351fd7212f74a4072b40de3 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 14 Dec 2007 00:00:57 +0000 Subject: [PATCH] sip is fun git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6774 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- conf/autoload_configs/console.conf.xml | 2 +- libs/curl/lib/config.h.in | 10 +++--- .../mod_voicemail/mod_voicemail.c | 34 +++++++++++++++++-- src/mod/endpoints/mod_sofia/sofia_glue.c | 4 +-- src/mod/endpoints/mod_sofia/sofia_presence.c | 19 +++++++---- 5 files changed, 52 insertions(+), 17 deletions(-) diff --git a/conf/autoload_configs/console.conf.xml b/conf/autoload_configs/console.conf.xml index 12407ee248..76508cb17e 100644 --- a/conf/autoload_configs/console.conf.xml +++ b/conf/autoload_configs/console.conf.xml @@ -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 --> - + diff --git a/libs/curl/lib/config.h.in b/libs/curl/lib/config.h.in index 4bc60b0df1..8602189707 100644 --- a/libs/curl/lib/config.h.in +++ b/libs/curl/lib/config.h.in @@ -621,16 +621,16 @@ /* 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 a `curl_off_t', as computed by sizeof. */ #undef SIZEOF_CURL_OFF_T -/* The size of `long', as computed by sizeof. */ +/* The size of a `long', as computed by sizeof. */ #undef SIZEOF_LONG -/* The size of `size_t', as computed by sizeof. */ +/* The size of a `size_t', as computed by sizeof. */ #undef SIZEOF_SIZE_T -/* The size of `time_t', as computed by sizeof. */ +/* The size of a `time_t', as computed by sizeof. */ #undef SIZEOF_TIME_T /* Define to 1 if you have the ANSI C header files. */ @@ -685,7 +685,7 @@ /* type to use in place of in_addr_t if not defined */ #undef in_addr_t -/* Define to `unsigned int' if does not define. */ +/* Define to `unsigned' if does not define. */ #undef size_t /* type to use in place of socklen_t if not defined */ diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c index ebed811d29..3cc0985ee2 100644 --- a/src/mod/applications/mod_voicemail/mod_voicemail.c +++ b/src/mod/applications/mod_voicemail/mod_voicemail.c @@ -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); diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 0ab91f4ea5..8c34aca818 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -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); } diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index 26a61bbe05..157f1dc07b 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -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; }