add dl_pres

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4871 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2007-04-06 16:20:07 +00:00
parent d874ea6b94
commit 75c3314ad7

View File

@ -186,32 +186,33 @@ struct rfc2833_digit {
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan)
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_string, globals.codec_string)
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_rates_string, globals.codec_rates_string)
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_string, globals.codec_string)
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_rates_string, globals.codec_rates_string)
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 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);
static switch_status_t channel_on_loopback(switch_core_session_t *session);
static switch_status_t channel_on_transmit(switch_core_session_t *session);
static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
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 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);
static switch_status_t channel_on_loopback(switch_core_session_t *session);
static switch_status_t channel_on_transmit(switch_core_session_t *session);
static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
switch_caller_profile_t *outbound_profile,
switch_core_session_t **new_session, switch_memory_pool_t **pool);
static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id);
static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flags, int stream_id);
static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id);
static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flags, int stream_id);
static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlsession, ldl_signal_t dl_signal,
static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlsession, ldl_signal_t dl_signal,
char *to, char *from, char *subject, char *msg);
static ldl_status handle_response(ldl_handle_t * handle, char *id);
static switch_status_t load_config(void);
static int sin_callback(void *pArg, int argc, char **argv, char **columnNames);
static ldl_status handle_response(ldl_handle_t * handle, char *id);
static switch_status_t load_config(void);
static int sin_callback(void *pArg, int argc, char **argv, char **columnNames);
#define is_special(s) (s && (strstr(s, "ext+") || strstr(s, "user+")))
static char *translate_rpid(char *in, char *ext)
static char *translate_rpid(char *in, char *ext)
{
char *r = NULL;
@ -1548,13 +1549,20 @@ static const switch_endpoint_interface_t channel_endpoint_interface = {
};
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
};
static switch_api_interface_t logout_api_interface = {
/*.interface_name */ "dl_logout",
/*.desc */ "DingaLing Logout",
/*.function */ dl_logout,
/*.syntax */ "dl_logout <profile_name>",
/*.next */ NULL
/*.next */ &pres_api_interface
};
static switch_api_interface_t login_api_interface = {
@ -1953,6 +1961,33 @@ static void set_profile_val(mdl_profile_t *profile, char *var, char *val)
}
}
static switch_status_t dl_pres(char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream)
{
mdl_profile_t *profile;
if (session) {
return SWITCH_STATUS_FALSE;
}
if (!profile_name) {
stream->write_function(stream, "USAGE: %s\n", pres_api_interface.syntax);
return SWITCH_STATUS_SUCCESS;
}
if ((profile = switch_core_hash_find(globals.profile_hash, profile_name))) {
if (profile->user_flags & LDL_FLAG_COMPONENT) {
sign_on(profile);
stream->write_function(stream, "OK\n");
} else {
stream->write_function(stream, "NO PROFILE %s NOT A COMPONENT\n", profile_name);
}
} else {
stream->write_function(stream, "NO SUCH PROFILE %s\n", profile_name);
}
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t dl_logout(char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream)
{
mdl_profile_t *profile;