]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add uuid_simplify and sip_auto_simplify
authorAnthony Minessale <anthony.minessale@gmail.com>
Wed, 20 Jan 2010 18:55:38 +0000 (18:55 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Wed, 20 Jan 2010 18:55:38 +0000 (18:55 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16420 d0543943-73ff-0310-b7d9-9358b9ac24b2

13 files changed:
src/include/private/switch_core_pvt.h
src/include/switch_channel.h
src/include/switch_core.h
src/include/switch_types.h
src/mod/applications/mod_commands/mod_commands.c
src/mod/applications/mod_dptools/mod_dptools.c
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_glue.c
src/mod/endpoints/mod_sofia/sofia_presence.c
src/switch_channel.c
src/switch_core_session.c
src/switch_log.c

index 2df7e24a03432b840747abaf4c6aa22937638abb..8f2ef2a3095297d1cd1f7687ee6f6ee60dbd3d48 100644 (file)
@@ -156,7 +156,6 @@ struct switch_core_session {
        uint32_t read_frame_count;
        uint32_t track_duration;
        uint32_t track_id;
-       switch_log_level_t loglevel;
 };
 
 struct switch_media_bug {
index a906b3659aa1e67719938afb0dc6186f01c1776b..95ddd778cf900cebd34f5ce56a8b4f26ead172b2 100644 (file)
@@ -537,7 +537,6 @@ SWITCH_DECLARE(void) switch_channel_clear_app_flag(switch_channel_t *channel, ui
 SWITCH_DECLARE(int) switch_channel_test_app_flag(switch_channel_t *channel, uint32_t flags);
 SWITCH_DECLARE(void) switch_channel_set_hangup_time(switch_channel_t *channel);
 SWITCH_DECLARE(switch_call_direction_t) switch_channel_direction(switch_channel_t *channel);
-SWITCH_DECLARE(switch_core_session_t*) switch_channel_get_session(switch_channel_t *channel);
 
 /** @} */
 
index 2997f567050bbe4913644a4999fccfb9c6a28591..19aea4337795ce29fa82e36f770151ca09f8ca43 100644 (file)
@@ -676,22 +676,6 @@ SWITCH_DECLARE(void) switch_core_session_signal_state_change(_In_ switch_core_se
 */
 SWITCH_DECLARE(char *) switch_core_session_get_uuid(_In_ switch_core_session_t *session);
 
-
-/*! 
-  \brief Sets the log level for a session
-  \param session the session to set the log level on 
-  \return SWITCH_STATUS_SUCCESS
-*/
-SWITCH_DECLARE(switch_status_t) switch_core_session_set_loglevel(switch_core_session_t *session, switch_log_level_t loglevel);
-
-
-/*! 
-  \brief Get the log level for a session
-  \param session the session to get the log level from 
-  \return the log level
-*/
-SWITCH_DECLARE(switch_log_level_t) switch_core_session_get_loglevel(switch_core_session_t *session);
-
 /*! 
   \brief Retrieve the unique identifier from the core
   \return a string representing the uuid
index 7d2b2495472642f16242d6e8bf6433c383c69a04..db801d762c0014df003e124d3d06f89d084303c0 100644 (file)
@@ -676,7 +676,7 @@ typedef enum {
        SWITCH_MESSAGE_INDICATE_AUDIO_SYNC,
        SWITCH_MESSAGE_INDICATE_REQUEST_IMAGE_MEDIA,
        SWITCH_MESSAGE_INDICATE_UUID_CHANGE,
-       SWITCH_MESSAGE_INDICATE_WARNING,
+       SWITCH_MESSAGE_INDICATE_SIMPLIFY,
        SWITCH_MESSAGE_INDICATE_DEBUG_AUDIO,
        SWITCH_MESSAGE_INVALID
 } switch_core_session_message_types_t;
@@ -805,8 +805,7 @@ SWITCH_CHANNEL_ID_EVENT                     - Write to the event engine as a LOG event
 typedef enum {
        SWITCH_CHANNEL_ID_LOG,
        SWITCH_CHANNEL_ID_LOG_CLEAN,
-       SWITCH_CHANNEL_ID_EVENT,
-       SWITCH_CHANNEL_ID_SESSION
+       SWITCH_CHANNEL_ID_EVENT
 } switch_text_channel_t;
 
 typedef enum {
@@ -818,11 +817,11 @@ typedef uint32_t switch_core_session_message_flag_t;
 
 #define SWITCH_CHANNEL_LOG SWITCH_CHANNEL_ID_LOG, __FILE__, __SWITCH_FUNC__, __LINE__, NULL
 #define SWITCH_CHANNEL_LOG_CLEAN SWITCH_CHANNEL_ID_LOG_CLEAN, __FILE__, __SWITCH_FUNC__, __LINE__, NULL
-#define SWITCH_CHANNEL_SESSION_LOG_CLEAN(x) SWITCH_CHANNEL_ID_LOG_CLEAN, __FILE__, __SWITCH_FUNC__, __LINE__, switch_core_session_get_uuid((x))
+#define SWITCH_CHANNEL_SESSION_LOG_CLEAN(x) SWITCH_CHANNEL_ID_LOG_CLEAN, __FILE__, __SWITCH_FUNC__, __LINE__, ((x) ? switch_core_session_get_uuid(x) : NULL)
 #define SWITCH_CHANNEL_EVENT SWITCH_CHANNEL_ID_EVENT, __FILE__, __SWITCH_FUNC__, __LINE__, NULL
-#define SWITCH_CHANNEL_SESSION_LOG(x) SWITCH_CHANNEL_ID_SESSION, __FILE__, __SWITCH_FUNC__, __LINE__, (const char*)(x)
-#define SWITCH_CHANNEL_CHANNEL_LOG(x) SWITCH_CHANNEL_ID_SESSION, __FILE__, __SWITCH_FUNC__, __LINE__, (const char*)switch_channel_get_session(x)
-#define SWITCH_CHANNEL_UUID_LOG(x) SWITCH_CHANNEL_ID_LOG, __FILE__, __SWITCH_FUNC__, __LINE__, (x)
+#define SWITCH_CHANNEL_SESSION_LOG(x) SWITCH_CHANNEL_ID_LOG, __FILE__, __SWITCH_FUNC__, __LINE__, ((x) ? switch_core_session_get_uuid(x) : NULL)
+#define SWITCH_CHANNEL_CHANNEL_LOG(x) SWITCH_CHANNEL_ID_LOG, __FILE__, __SWITCH_FUNC__, __LINE__, ((x) ? switch_channel_get_uuid(x) : NULL)
+#define SWITCH_CHANNEL_UUID_LOG(x) SWITCH_CHANNEL_ID_LOG, __FILE__, __SWITCH_FUNC__, __LINE__, x
 
 /*!
   \enum switch_channel_state_t
index ca5c303c43aa0763b0cb2142010baac7e37fd8e9..e4da4a1a79aee2ff730e1c3b19e642f24851090d 100644 (file)
@@ -2295,28 +2295,22 @@ SWITCH_STANDARD_API(uuid_display_function)
        return SWITCH_STATUS_SUCCESS;
 }
 
-#define WARNING_SYNTAX "<uuid> <warning>"
-SWITCH_STANDARD_API(uuid_warning_function)
+#define SIMPLIFY_SYNTAX "<uuid>"
+SWITCH_STANDARD_API(uuid_simplify_function)
 {
-       char *mycmd = NULL, *argv[2] = { 0 };
-       int argc = 0;
-       switch_status_t status = SWITCH_STATUS_FALSE;
-
-       if (!zstr(cmd) && (mycmd = strdup(cmd))) {
-               argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
-       }
+       switch_status_t status = SWITCH_STATUS_SUCCESS;
 
-       if (zstr(cmd) || argc < 2 || zstr(argv[0]) || zstr(argv[1])) {
-               stream->write_function(stream, "-USAGE: %s\n", WARNING_SYNTAX);
+       if (zstr(cmd)) {
+               stream->write_function(stream, "-USAGE: %s\n", SIMPLIFY_SYNTAX);
        } else {
                switch_core_session_message_t msg = { 0 };
                switch_core_session_t *lsession = NULL;
 
-               msg.message_id = SWITCH_MESSAGE_INDICATE_WARNING;
-               msg.string_arg = argv[1];
+               msg.message_id = SWITCH_MESSAGE_INDICATE_SIMPLIFY;
+               msg.string_arg = cmd;
                msg.from = __FILE__;
 
-               if ((lsession = switch_core_session_locate(argv[0]))) {
+               if ((lsession = switch_core_session_locate(cmd))) {
                        status = switch_core_session_receive_message(lsession, &msg);
                        switch_core_session_rwunlock(lsession);
                }
@@ -2328,7 +2322,6 @@ SWITCH_STANDARD_API(uuid_warning_function)
                stream->write_function(stream, "-ERR Operation Failed\n");
        }
 
-       switch_safe_free(mycmd);
        return SWITCH_STATUS_SUCCESS;
 }
 
@@ -4006,41 +3999,6 @@ SWITCH_STANDARD_API(escape_function)
        return SWITCH_STATUS_SUCCESS;
 }
 
-#define UUID_LOGLEVEL_SYNTAX "<uuid> <level>"
-SWITCH_STANDARD_API(uuid_loglevel)
-{
-       switch_core_session_t *tsession = NULL;
-       char *uuid = NULL, *text = NULL;
-
-       if (!zstr(cmd) && (uuid = strdup(cmd))) {
-               if ((text = strchr(uuid, ' '))) {
-                       *text++ = '\0';
-               }
-       }
-
-       if (zstr(uuid) || zstr(text)) {
-               stream->write_function(stream, "-USAGE: %s\n", UUID_LOGLEVEL_SYNTAX);
-       } else {
-               switch_log_level_t level = switch_log_str2level(text);
-
-               if (level == SWITCH_LOG_INVALID) {
-                       stream->write_function(stream, "-ERR Invalid log level!\n");
-               }
-               else if ((tsession = switch_core_session_locate(uuid))) {
-
-                       switch_core_session_set_loglevel(tsession, level);
-                       stream->write_function(stream, "+OK\n");
-                       switch_core_session_rwunlock(tsession);
-               }
-               else {
-                       stream->write_function(stream, "-ERR No Such Channel %s!\n", uuid);
-               }
-       }
-
-       switch_safe_free(uuid);
-       return SWITCH_STATUS_SUCCESS;
-}
-
 SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_commands_shutdown)
 {
        int x;
@@ -4143,7 +4101,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
        SWITCH_ADD_API(commands_api_interface, "uuid_getvar", "uuid_getvar", uuid_getvar_function, GETVAR_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "uuid_hold", "hold", uuid_hold_function, HOLD_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "uuid_kill", "Kill Channel", kill_function, KILL_SYNTAX);
-       SWITCH_ADD_API(commands_api_interface, "uuid_loglevel", "set loglevel on session", uuid_loglevel, UUID_LOGLEVEL_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "uuid_media", "media", uuid_media_function, MEDIA_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "uuid_park", "Park Channel", park_function, PARK_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "uuid_preprocess", "Pre-process Channel", preprocess_function, PREPROCESS_SYNTAX);
@@ -4154,7 +4111,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
        SWITCH_ADD_API(commands_api_interface, "uuid_setvar_multi", "uuid_setvar_multi", uuid_setvar_multi_function, SETVAR_MULTI_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "uuid_setvar", "uuid_setvar", uuid_setvar_function, SETVAR_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "uuid_transfer", "Transfer a session", transfer_function, TRANSFER_SYNTAX);
-       SWITCH_ADD_API(commands_api_interface, "uuid_warning", "send popup", uuid_warning_function, WARNING_SYNTAX);
+       SWITCH_ADD_API(commands_api_interface, "uuid_simplify", "Try to cut out of a call path / attended xfer", uuid_simplify_function, SIMPLIFY_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "xml_locate", "find some xml", xml_locate_function, "[root | <section> <tag> <tag_attr_name> <tag_attr_val>]");
        SWITCH_ADD_API(commands_api_interface, "xml_wrap", "Wrap another api command in xml", xml_wrap_api_function, "<command> <args>");
        switch_console_set_complete("add alias add");
@@ -4166,14 +4123,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
        switch_console_set_complete("add fsctl default_dtmf_duration");
        switch_console_set_complete("add fsctl hupall");
        switch_console_set_complete("add fsctl loglevel");
-       switch_console_set_complete("add fsctl loglevel console");
-       switch_console_set_complete("add fsctl loglevel alert");
-       switch_console_set_complete("add fsctl loglevel crit");
-       switch_console_set_complete("add fsctl loglevel err");
-       switch_console_set_complete("add fsctl loglevel warning");
-       switch_console_set_complete("add fsctl loglevel notice");
-       switch_console_set_complete("add fsctl loglevel info");
-       switch_console_set_complete("add fsctl loglevel debug");
        switch_console_set_complete("add fsctl max_dtmf_duration");
        switch_console_set_complete("add fsctl max_sessions");
        switch_console_set_complete("add fsctl min_dtmf_duration");
@@ -4237,14 +4186,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
        switch_console_set_complete("add uuid_getvar ::console::list_uuid");
        switch_console_set_complete("add uuid_hold ::console::list_uuid");
        switch_console_set_complete("add uuid_kill ::console::list_uuid");
-       switch_console_set_complete("add uuid_loglevel ::console::list_uuid console");
-       switch_console_set_complete("add uuid_loglevel ::console::list_uuid alert");
-       switch_console_set_complete("add uuid_loglevel ::console::list_uuid crit");
-       switch_console_set_complete("add uuid_loglevel ::console::list_uuid err");
-       switch_console_set_complete("add uuid_loglevel ::console::list_uuid warning");
-       switch_console_set_complete("add uuid_loglevel ::console::list_uuid notice");
-       switch_console_set_complete("add uuid_loglevel ::console::list_uuid info");
-       switch_console_set_complete("add uuid_loglevel ::console::list_uuid debug");
        switch_console_set_complete("add uuid_media ::console::list_uuid");
        switch_console_set_complete("add uuid_park ::console::list_uuid");
        switch_console_set_complete("add uuid_preprocess ::console::list_uuid");
index fab0548940b40daf10860fd9369e6a4293b6c3a6..4f936c4a01cbcc0588eef04c742794a1a709942a 100644 (file)
@@ -758,17 +758,6 @@ SWITCH_STANDARD_APP(display_function)
        switch_core_session_receive_message(session, &msg);
 }
 
-SWITCH_STANDARD_APP(warning_function)
-{
-       switch_core_session_message_t msg = { 0 };
-
-       /* Tell the channel to redirect */
-       msg.from = __FILE__;
-       msg.string_arg = data;
-       msg.message_id = SWITCH_MESSAGE_INDICATE_WARNING;
-       switch_core_session_receive_message(session, &msg);
-}
-
 SWITCH_STANDARD_APP(respond_function)
 {
        switch_core_session_message_t msg = { 0 };
@@ -2948,24 +2937,6 @@ static switch_status_t api_chat_send(const char *proto, const char *from, const
        return SWITCH_STATUS_SUCCESS;
 }
 
-
-#define SESSION_LOGLEVEL_SYNTAX "<level>"
-SWITCH_STANDARD_APP(session_loglevel_function)
-{
-       if (!zstr(data)) {
-               switch_log_level_t level = switch_log_str2level(data);
-
-               if (level == SWITCH_LOG_INVALID) {
-                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid log level: %s\n", data);
-               } else {
-                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Setting log level \"%s\" on session\n", switch_log_level2str(level));
-                       switch_core_session_set_loglevel(session, level);
-               }
-       } else {
-               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No log level specified\n");
-       }
-}
-
 #define SPEAK_DESC "Speak text to a channel via the tts interface"
 #define DISPLACE_DESC "Displace audio from a file to the channels input"
 #define SESS_REC_DESC "Starts a background recording of the entire session"
@@ -3056,8 +3027,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load)
                                   SAF_SUPPORT_NOMEDIA);
        SWITCH_ADD_APP(app_interface, "send_display", "Send session a new display", "Send session a new display.", display_function, "<text>",
                                   SAF_SUPPORT_NOMEDIA);
-       SWITCH_ADD_APP(app_interface, "send_warning", "Send session a popup", "Send session a popup.", warning_function, "<text>",
-                                  SAF_SUPPORT_NOMEDIA);
        SWITCH_ADD_APP(app_interface, "respond", "Send session respond", "Send a respond message to a session.", respond_function, "<respond_data>",
                                   SAF_SUPPORT_NOMEDIA);
        SWITCH_ADD_APP(app_interface, "deflect", "Send call deflect", "Send a call deflect.", deflect_function, "<deflect_data>", SAF_SUPPORT_NOMEDIA);
@@ -3126,7 +3095,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load)
        SWITCH_ADD_APP(app_interface, "say", "say", "say", say_function, SAY_SYNTAX, SAF_NONE);
 
        SWITCH_ADD_APP(app_interface, "wait_for_silence", "wait_for_silence", "wait_for_silence", wait_for_silence_function, WAIT_FOR_SILENCE_SYNTAX, SAF_NONE);
-       SWITCH_ADD_APP(app_interface, "session_loglevel", "session_loglevel", "session_loglevel", session_loglevel_function, SESSION_LOGLEVEL_SYNTAX, SAF_SUPPORT_NOMEDIA);
 
        SWITCH_ADD_DIALPLAN(dp_interface, "inline", inline_dialplan_hunt);
 
index ed3be6842bea7f08ab948f79ae08378aee0f3ffd..a948852d60a49caf35b538289b2ab91e6094fb71 100644 (file)
@@ -1151,25 +1151,59 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
                goto end;
 
        case SWITCH_MESSAGE_INDICATE_BRIDGE:
-               if (switch_rtp_ready(tech_pvt->rtp_session)) {
-                       const char *val;
-                       int ok = 0;
+               {
+                       const char *network_addr_a, *network_addr_b, *simplify_a, *simplify_b;
+                       int s_ok = 0;
 
-                       if (sofia_test_flag(tech_pvt, TFLAG_PASS_RFC2833) && switch_channel_test_flag_partner(channel, CF_FS_RTP)) {
-                               switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_PASS_RFC2833);
-                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s activate passthru 2833 mode.\n", switch_channel_get_name(channel));
+                       simplify_a = switch_channel_get_variable(channel, "sip_auto_simplify");
+                       simplify_b = switch_channel_get_variable_partner(channel, "sip_auto_simplify");
+                       
+                       if (switch_true(simplify_a)) {
+                               if (switch_true(simplify_b) && !switch_channel_test_flag(channel, CF_BRIDGE_ORIGINATOR)) {
+                                       s_ok = 0;
+                               } else {
+                                       s_ok = 1;
+                               }
                        }
 
-                       if ((val = switch_channel_get_variable(channel, "rtp_autoflush_during_bridge"))) {
-                               ok = switch_true(val);
-                       } else {
-                               ok = sofia_test_pflag(tech_pvt->profile, PFLAG_RTP_AUTOFLUSH_DURING_BRIDGE);
+                       if (s_ok) {
+                               network_addr_a = switch_channel_get_variable(channel, "network_addr");
+                               network_addr_b = switch_channel_get_variable_partner(channel, "network_addr");
+                               
+                               if (!zstr(network_addr_a) && !zstr(network_addr_b) && !strcmp(network_addr_a, network_addr_b)) {
+                                       if (strcmp(network_addr_a, switch_str_nil(tech_pvt->profile->sipip)) && 
+                                               strcmp(network_addr_a, switch_str_nil(tech_pvt->profile->extsipip))) {
+                                               switch_core_session_message_t smsg = { 0 };
+                                       
+                                               smsg.message_id = SWITCH_MESSAGE_INDICATE_SIMPLIFY;
+                                               smsg.from = __FILE__;
+                                               
+                                               status = switch_core_session_receive_message(session, &smsg);
+                                       }
+                               }
                        }
                        
-                       if (ok) {
-                               rtp_flush_read_buffer(tech_pvt->rtp_session, SWITCH_RTP_FLUSH_STICK);
-                       } else {
-                               rtp_flush_read_buffer(tech_pvt->rtp_session, SWITCH_RTP_FLUSH_ONCE);
+                       if (switch_rtp_ready(tech_pvt->rtp_session)) {
+                               const char *val;
+                               int ok = 0;
+
+                               if (sofia_test_flag(tech_pvt, TFLAG_PASS_RFC2833) && switch_channel_test_flag_partner(channel, CF_FS_RTP)) {
+                                       switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_PASS_RFC2833);
+                                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, 
+                                                                         "%s activate passthru 2833 mode.\n", switch_channel_get_name(channel));
+                               }
+
+                               if ((val = switch_channel_get_variable(channel, "rtp_autoflush_during_bridge"))) {
+                                       ok = switch_true(val);
+                               } else {
+                                       ok = sofia_test_pflag(tech_pvt->profile, PFLAG_RTP_AUTOFLUSH_DURING_BRIDGE);
+                               }
+                       
+                               if (ok) {
+                                       rtp_flush_read_buffer(tech_pvt->rtp_session, SWITCH_RTP_FLUSH_STICK);
+                               } else {
+                                       rtp_flush_read_buffer(tech_pvt->rtp_session, SWITCH_RTP_FLUSH_ONCE);
+                               }
                        }
                }
                goto end;
@@ -1382,26 +1416,49 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
                }
                break;
 
-       case SWITCH_MESSAGE_INDICATE_WARNING:
+       case SWITCH_MESSAGE_INDICATE_SIMPLIFY:
                {
-                       char *message;
-                       if (!zstr(msg->string_arg)) {
-                               const char *ua = switch_channel_get_variable(tech_pvt->channel, "sip_user_agent");
-                               
-                               if (!sofia_test_flag(tech_pvt, TFLAG_UPDATING_DISPLAY)) {
-                                               
-                                       if ((ua && (switch_stristr("polycom", ua)))) {
-                                               message = switch_mprintf("Warning: 399 devnull \"%s\"", msg->string_arg);
-                                               sofia_set_flag_locked(tech_pvt, TFLAG_UPDATING_DISPLAY);
-                                               nua_update(tech_pvt->nh, 
-                                                                  TAG_IF(!zstr(message), SIPTAG_HEADER_STR(message)),
-                                                                  TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
-                                                                  TAG_END());
-                                               free(message);
+                       char *ref_to, *ref_by;
+                       const char *uuid;
+                       const char *call_id = NULL, *to_user = NULL, *to_host = NULL, *to_tag = NULL, *from_tag = NULL, *from_user, *from_host;
+                       
+                       if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
+                               switch_core_session_t *rsession;
+                               if ((rsession = switch_core_session_locate(uuid))) {
+                                       switch_channel_t *rchannel = switch_core_session_get_channel(rsession);
+                                       call_id = switch_channel_get_variable(rchannel, "sip_call_id");
+
+                                       to_user = switch_channel_get_variable(rchannel, "sip_to_user");
+
+                                       if (switch_channel_direction(rchannel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
+                                               to_host = switch_channel_get_variable(rchannel, "sip_to_host");
+                                               from_user = switch_channel_get_variable(channel, "sip_from_user");
+                                               from_host = switch_channel_get_variable(channel, "sip_from_host");
+                                       } else {
+                                               to_host = switch_channel_get_variable(channel, "sip_to_host");
+                                               from_user = switch_channel_get_variable(rchannel, "sip_from_user");
+                                               from_host = switch_channel_get_variable(rchannel, "sip_from_host");
                                        }
 
+                                       to_tag = switch_channel_get_variable(rchannel, "sip_to_tag");
+                                       from_tag = switch_channel_get_variable(rchannel, "sip_from_tag");
+                                       switch_core_session_rwunlock(rsession);
                                }
                        }
+                       
+                       if (to_user && to_host && from_user && from_host && call_id && to_tag && from_tag) {
+                               char in[512] = "", out[1536] = "";
+
+                               switch_snprintf(in, sizeof(in), "%s;to-tag=%s;from-tag=%s", call_id, to_tag, from_tag);
+                               switch_url_encode(in, out, sizeof(out));
+
+                               ref_to = switch_mprintf("<sip:%s@%s?Replaces=%s>", to_user, to_host, out); 
+                               ref_by = switch_mprintf("<sip:%s@%s>", from_user, from_host);
+
+                               nua_refer(tech_pvt->nh, SIPTAG_REFER_TO_STR(ref_to), SIPTAG_REFERRED_BY_STR(ref_by), TAG_END());
+                               switch_safe_free(ref_to);
+                               switch_safe_free(ref_by);
+                       }
                }
                break;
        case SWITCH_MESSAGE_INDICATE_DISPLAY:
index f6ad98f78aaf6dfb5b796fe8e3d35e3e5099daf6..cdfebc4a90b16fc0f0a03e6b0337b4599897dee2 100644 (file)
@@ -4774,6 +4774,40 @@ static switch_status_t xfer_hanguphook(switch_core_session_t *session)
        return SWITCH_STATUS_SUCCESS;
 }
 
+nua_handle_t *sofia_global_nua_handle_by_replaces(sip_replaces_t *replaces)
+{
+       nua_handle_t *nh = NULL;
+       switch_hash_index_t *hi;
+       const void *var;
+    void *val;
+    sofia_profile_t *profile;
+       switch_xml_t xml_root;
+       const char *err;
+
+       if ((xml_root = switch_xml_open_root(1, &err))) {
+               switch_xml_free(xml_root);
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Reload XML [%s]\n", err);
+       }
+
+       switch_mutex_lock(mod_sofia_globals.hash_mutex);
+       if (mod_sofia_globals.profile_hash) {
+        for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
+                       switch_hash_this(hi, &var, NULL, &val);
+            if ((profile = (sofia_profile_t *) val)) {
+                               if (!(nh = nua_handle_by_replaces(profile->nua, replaces))) {
+                                       nh = nua_handle_by_call_id(profile->nua, replaces->rp_call_id);
+                               }
+                               if (nh) break;
+                       }
+               }
+       }
+       switch_mutex_unlock(mod_sofia_globals.hash_mutex);
+       
+       return nh;
+
+}
+
+
 void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, switch_core_session_t *session, sip_t const *sip, tagi_t tags[])
 {
        /* Incoming refer */
@@ -4828,7 +4862,7 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
 
                if (refer_to->r_url->url_headers && (rep = (char *)switch_stristr("Replaces=", refer_to->r_url->url_headers))) {
                        sip_replaces_t *replaces;
-                       nua_handle_t *bnh;
+                       nua_handle_t *bnh = NULL;
                        
                        if (rep) {
                                const char *br_a = NULL, *br_b = NULL;
@@ -4848,9 +4882,16 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Memory Error!\n");
                                        goto done;
                                }
+                               
+                               if ((replaces = sip_replaces_make(home, rep))) {
+                                       if (!(bnh = nua_handle_by_replaces(nua, replaces))) {
+                                               if (!(bnh = nua_handle_by_call_id(nua, replaces->rp_call_id))) {
+                                                       bnh = sofia_global_nua_handle_by_replaces(replaces);
+                                               }
+                                       }
+                               }
 
-                               if ((replaces = sip_replaces_make(home, rep))
-                                       && (bnh = nua_handle_by_replaces(nua, replaces))) {
+                               if (bnh) {
                                        sofia_private_t *b_private = NULL;
                                        private_object_t *b_tech_pvt = NULL;
                                        switch_core_session_t *b_session = NULL;
@@ -6080,8 +6121,12 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
                }
        }
 
-       if (sip->sip_replaces) {
-               bnh = nua_handle_by_replaces(nua, sip->sip_replaces);
+       if (!bnh && sip->sip_replaces) {
+               if (!(bnh = nua_handle_by_replaces(nua, sip->sip_replaces))) {
+                       if (!(bnh = nua_handle_by_call_id(nua, sip->sip_replaces->rp_call_id))) {
+                               bnh = sofia_global_nua_handle_by_replaces(sip->sip_replaces);
+                       }
+               }
        }
 
        if (bnh) {
index c04ee4f1b29c2a6567a4ecee3e3632ff16673f69..75756d0db7f045915faae621ff30d2c66782d927 100644 (file)
@@ -1435,6 +1435,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
        char *route_uri = NULL;
        sofia_destination_t *dst = NULL;
        sofia_cid_type_t cid_type = tech_pvt->profile->cid_type;
+       char *d_url = NULL, *url = NULL, *dest_host = NULL, *url_str = NULL;
 
        rep = switch_channel_get_variable(channel, SOFIA_REPLACES_HEADER);
 
@@ -1451,15 +1452,33 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
        check_decode(cid_name, session);
        check_decode(cid_num, session);
 
+       if (zstr(tech_pvt->dest)) {
+               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "URL Error!\n");
+               return SWITCH_STATUS_FALSE;
+       }
+       
+       if ((d_url = sofia_glue_get_url_from_contact(tech_pvt->dest, 1))) {
+               url = d_url;
+       } else {
+               url = tech_pvt->dest;
+       }
+       
+       url_str = url;
+
+       if ((dest_host = strchr(url_str, '@'))) {
+               dest_host++;
+       }
+
+
        if (!tech_pvt->from_str) {
                const char* sipip;
                const char* format;
                const char *alt = NULL;
 
-               if (sofia_glue_check_nat(tech_pvt->profile, tech_pvt->remote_ip)) {
+               sipip = tech_pvt->profile->sipip;
+
+               if (sofia_glue_check_nat(tech_pvt->profile, dest_host)) {
                        sipip = tech_pvt->profile->extsipip;
-               } else {
-                       sipip = tech_pvt->profile->extsipip ? tech_pvt->profile->extsipip : tech_pvt->profile->sipip;
                }
 
                format = strchr(sipip, ':') ? "\"%s\" <sip:%s%s[%s]>" : "\"%s\" <sip:%s%s%s>";
@@ -1492,9 +1511,9 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
        sofia_set_flag_locked(tech_pvt, TFLAG_READY);
 
        if (!tech_pvt->nh) {
-               char *d_url = NULL, *url = NULL;
+
                sofia_private_t *sofia_private;
-               char *invite_contact = NULL, *to_str, *use_from_str, *from_str, *url_str;
+               char *invite_contact = NULL, *to_str, *use_from_str, *from_str;
                const char *t_var;
                char *rpid_domain = "cluecon.com", *p;
                const char *priv = "off";
@@ -1507,19 +1526,6 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
                const char *from_var = switch_channel_get_variable(tech_pvt->channel, "sip_from_uri");
                const char *from_display = switch_channel_get_variable(tech_pvt->channel, "sip_from_display");
                
-               if (zstr(tech_pvt->dest)) {
-                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "URL Error!\n");
-                       return SWITCH_STATUS_FALSE;
-               }
-
-               if ((d_url = sofia_glue_get_url_from_contact(tech_pvt->dest, 1))) {
-                       url = d_url;
-               } else {
-                       url = tech_pvt->dest;
-               }
-
-               url_str = url;
-
                if (from_var) {
                        if (strncasecmp(from_var, "sip:", 4) || strncasecmp(from_var, "sips:", 5)) {
                                use_from_str = switch_core_session_strdup(tech_pvt->session, from_var);
@@ -4001,7 +4007,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
                }
 
                free(test_sql);
-               test_sql = switch_mprintf("delete from sip_dialogs where hostname='%q' and expires > 0", mod_sofia_globals.hostname);
+               test_sql = switch_mprintf("delete from sip_dialogs where hostname='%q' and expires >= 0", mod_sofia_globals.hostname);
 
                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
                        switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_dialogs", NULL, NULL);
index aea791770c8ac67d841aeee8f9bfe6c3d6f1ce05..d79626f4dcdc09011d38525b25f9a110a45c8175 100644 (file)
@@ -1885,6 +1885,10 @@ void sofia_presence_handle_sip_i_subscribe(int status,
                full_from = sip_header_as_string(profile->home, (void *) sip->sip_from);
                full_via = sip_header_as_string(profile->home, (void *) sip->sip_via);
                
+               if (sip->sip_expires->ex_delta > 31536000) {
+                       sip->sip_expires->ex_delta = 31536000;
+               }
+
                exp_delta = profile->force_subscription_expires ? profile->force_subscription_expires : (sip->sip_expires ? sip->sip_expires->ex_delta : 3600);
                
                if (exp_delta) {
index 8329b9553d36828213980598149eede75b65dcbd..1e9c27dc13bbab86971b2749ae7fdcb947312469 100644 (file)
@@ -2649,12 +2649,6 @@ SWITCH_DECLARE(switch_status_t) switch_channel_get_variables(switch_channel_t *c
        return status;
 }
 
-SWITCH_DECLARE(switch_core_session_t*) switch_channel_get_session(switch_channel_t *channel)
-{
-       switch_assert(channel);
-       return channel->session;
-}
-
 SWITCH_DECLARE(switch_status_t) switch_channel_set_timestamps(switch_channel_t *channel)
 {
        switch_status_t status = SWITCH_STATUS_SUCCESS;
index 304ecc2a36e814bb5cd2a3c23a4f554076848ecd..d2ef5490a11eedfa9388b71019c3d9db964cbeac 100644 (file)
@@ -1712,19 +1712,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_execute_exten(switch_core_se
        return status;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_core_session_set_loglevel(switch_core_session_t *session, switch_log_level_t loglevel)
-{
-       switch_assert(session != NULL);
-       session->loglevel = loglevel;
-       return SWITCH_STATUS_SUCCESS;
-}
-
-SWITCH_DECLARE(switch_log_level_t) switch_core_session_get_loglevel(switch_core_session_t *session)
-{
-       switch_assert(session != NULL);
-       return session->loglevel;
-}
-
 /* For Emacs:
  * Local Variables:
  * mode:c
index b07978506065f732829beb18343caa59f76b4c8a..fcafd060db2008b31b58e260137bc326f60cc76f 100644 (file)
@@ -339,14 +339,6 @@ SWITCH_DECLARE(void) switch_log_vprintf(switch_text_channel_t channel, const cha
 #else
        const char *extra_fmt = "%s [%s] %s:%d%c%s";
 #endif
-       switch_log_level_t limit_level = runtime.hard_log_level;
-
-       if (channel == SWITCH_CHANNEL_ID_SESSION && userdata) {
-               switch_core_session_t *session = (switch_core_session_t*)userdata;
-               if (limit_level < session->loglevel) {
-                       limit_level = session->loglevel;
-               }
-       }
 
        if (level > 100) {
                if ((uint32_t)(level - 100) > runtime.debug_level) {
@@ -356,7 +348,7 @@ SWITCH_DECLARE(void) switch_log_vprintf(switch_text_channel_t channel, const cha
                level = 7;
        }
 
-       if (level > limit_level) {
+       if (level > runtime.hard_log_level) {
                return;
        }
 
@@ -474,11 +466,7 @@ SWITCH_DECLARE(void) switch_log_vprintf(switch_text_channel_t channel, const cha
                node->content = content;
                node->timestamp = now;
                node->channel = channel;
-               if (channel == SWITCH_CHANNEL_ID_SESSION) {
-                       node->userdata = userdata ? strdup(switch_core_session_get_uuid((switch_core_session_t*)userdata)) : NULL;
-               } else {
-                       node->userdata = !zstr(userdata) ? strdup(userdata) : NULL;
-               }
+               node->userdata = !zstr(userdata) ? strdup(userdata) : NULL;
 
                if (switch_queue_trypush(LOG_QUEUE, node) != SWITCH_STATUS_SUCCESS) {
                        switch_log_node_free(&node);