]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add dl_debug api command
authorAnthony Minessale <anthony.minessale@gmail.com>
Sat, 7 Apr 2007 15:55:07 +0000 (15:55 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Sat, 7 Apr 2007 15:55:07 +0000 (15:55 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4883 d0543943-73ff-0310-b7d9-9358b9ac24b2

libs/libdingaling/src/libdingaling.c
libs/libdingaling/src/libdingaling.h
src/mod/endpoints/mod_dingaling/mod_dingaling.c

index 50c3441c4d555bdd4e4ca2801e85b27f2d8ec0ff..68bd716ac1127e0a211f30bd85a4eaa65742173e 100644 (file)
@@ -1391,9 +1391,9 @@ static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass)
                                                                                handle,
                                                                                (iksStreamHook *) (ldl_test_flag(handle, LDL_FLAG_COMPONENT) ? on_stream_component : on_stream));
 
-               if (globals.debug) {
-                       iks_set_log_hook(handle->parser, (iksLogHook *) on_log);
-               }
+
+               iks_set_log_hook(handle->parser, (iksLogHook *) on_log);
+                       
                
                strncpy(tmp, jabber_id, sizeof(tmp)-1);
                sl = strchr(tmp, '/');
@@ -1763,6 +1763,15 @@ void ldl_handle_send_msg(ldl_handle_t *handle, char *from, char *to, char *subje
        
 }
 
+int ldl_global_debug(int on)
+{
+       if (on > -1) {
+               globals.debug = on ? 1 : 0;
+       }
+
+       return globals.debug ? 1 : 0;
+}
+
 void ldl_global_set_logger(ldl_logger_t logger)
 {
        globals.logger = logger;
index 6013c6a8df678c5ff62de5b2290b954187b2b0f2..0de2f9408070f6bc3f53971b74a9942b8c3a68cd 100644 (file)
@@ -375,6 +375,13 @@ void *ldl_session_get_private(ldl_session_t *session);
 */
 void ldl_session_accept_candidate(ldl_session_t *session, ldl_candidate_t *candidate);
 
+/*!
+  \brief turn logging on/off
+  \param on (TRUE or FALSE)
+  \return current state
+*/
+int ldl_global_debug(int on);
+
 /*!
   \brief Set a custom logger
   \param logger the logger function
index d06dd13028d811f8e1dd1746c66f5e677cd99ed3..26cdab0bdd4d42f362552be19080b161efac014d 100644 (file)
@@ -192,6 +192,7 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_rates_string, globals.codec_r
 static switch_status_t dl_login(char *arg, switch_core_session_t *session, switch_stream_handle_t *stream);
 static switch_status_t dl_logout(char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream);
 static switch_status_t dl_pres(char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream);
+static switch_status_t dl_debug(char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream);
 static switch_status_t channel_on_init(switch_core_session_t *session);
 static switch_status_t channel_on_hangup(switch_core_session_t *session);
 static switch_status_t channel_on_ring(switch_core_session_t *session);
@@ -1586,12 +1587,20 @@ static const switch_endpoint_interface_t channel_endpoint_interface = {
 };
 
 
+static switch_api_interface_t debug_api_interface = {
+       /*.interface_name */ "dl_debug",
+       /*.desc */ "DingaLing Presence",
+       /*.function */ dl_debug,
+       /*.syntax */ "dl_debug [true|false]",
+       /*.next */ NULL
+};
+
 static switch_api_interface_t pres_api_interface = {
        /*.interface_name */ "dl_pres",
        /*.desc */ "DingaLing Presence",
        /*.function */ dl_pres,
        /*.syntax */ "dl_pres <profile_name>",
-       /*.next */ NULL
+       /*.next */ &debug_api_interface
 };
 
 static switch_api_interface_t logout_api_interface = {
@@ -1998,6 +2007,27 @@ static void set_profile_val(mdl_profile_t *profile, char *var, char *val)
        }
 }
 
+static switch_status_t dl_debug(char *tf, switch_core_session_t *session, switch_stream_handle_t *stream)
+{
+       int on, cur;
+
+       if (session) {
+               return SWITCH_STATUS_FALSE;
+       }
+
+       if (tf) {
+               on = switch_true(tf);
+               cur = ldl_global_debug(on);
+       } else {
+               cur = ldl_global_debug(-1);
+       }
+
+
+       stream->write_function(stream, "DEBUG IS NOW %s\n", cur ? "ON" : "OFF");
+
+       return SWITCH_STATUS_SUCCESS;
+}
+
 static switch_status_t dl_pres(char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
        mdl_profile_t *profile;