dingaling tweak

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1660 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2006-06-22 21:57:40 +00:00
parent 4fb9e6e76b
commit 988841611a
3 changed files with 30 additions and 7 deletions

View File

@ -549,7 +549,7 @@ static int on_stream(ldl_handle_t *handle, int type, iks * node)
handle->features = iks_stream_features(node);
if (opt_use_tls && !iks_is_secure(handle->parser))
break;
if (ldl_test_flag(handle, LDL_FLAG_AUTHORIZED)) {
if (ldl_test_flag(handle, LDL_FLAG_CONNECTED)) {
iks *t;
if (handle->features & IKS_STREAM_BIND) {
t = iks_make_resource_bind(handle->acc);
@ -576,14 +576,22 @@ static int on_stream(ldl_handle_t *handle, int type, iks * node)
}
} else if (strcmp("success", iks_name(node)) == 0) {
globals.logger(DL_LOG_DEBUG, "XMPP server connected\n");
if (handle->session_callback) {
handle->session_callback(handle, NULL, LDL_SIGNAL_LOGIN_SUCCESS, "core", "Login Success", handle->login);
}
iks_send_header(handle->parser, handle->acc->server);
ldl_set_flag(handle, LDL_FLAG_AUTHORIZED);
ldl_set_flag(handle, LDL_FLAG_CONNECTED);
if (handle->session_callback) {
handle->session_callback(handle, NULL, LDL_SIGNAL_CONNECTED, "core", "Server Connected", handle->login);
}
} else {
ikspak *pak;
if (!ldl_test_flag(handle, LDL_FLAG_AUTHORIZED)) {
if (handle->session_callback) {
handle->session_callback(handle, NULL, LDL_SIGNAL_LOGIN_SUCCESS, "core", "Login Success", handle->login);
}
globals.logger(DL_LOG_DEBUG, "XMPP authenticated\n");
ldl_set_flag(handle, LDL_FLAG_AUTHORIZED);
}
pak = iks_packet(node);
iks_filter_packet(handle->filter, pak);
if (handle->job_done == 1)
@ -803,7 +811,7 @@ static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass)
ldl_flush_queue(handle);
}
if (!ldl_test_flag(handle, LDL_FLAG_AUTHORIZED)) {
if (!ldl_test_flag(handle, LDL_FLAG_CONNECTED)) {
if (IKS_NET_TLSFAIL == e) {
globals.logger(DL_LOG_DEBUG, "tls handshake failed\n");
microsleep(500);
@ -820,6 +828,7 @@ static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass)
iks_disconnect(handle->parser);
iks_parser_delete(handle->parser);
ldl_clear_flag(handle, LDL_FLAG_CONNECTED);
ldl_clear_flag(handle, LDL_FLAG_AUTHORIZED);
}

View File

@ -99,7 +99,8 @@ typedef enum {
LDL_FLAG_INIT = (1 << 0),
LDL_FLAG_RUNNING = (1 << 1),
LDL_FLAG_AUTHORIZED = (1 << 2),
LDL_FLAG_READY = (1 << 3)
LDL_FLAG_READY = (1 << 3),
LDL_FLAG_CONNECTED = (1 << 4)
} ldl_flag_t;
typedef enum {
@ -111,6 +112,7 @@ typedef enum {
LDL_SIGNAL_ERROR,
LDL_SIGNAL_LOGIN_SUCCESS,
LDL_SIGNAL_LOGIN_FAILURE,
LDL_SIGNAL_CONNECTED
} ldl_signal_t;
typedef enum {

View File

@ -39,6 +39,7 @@
#define DL_EVENT_LOGIN_SUCCESS "dingaling::login_success"
#define DL_EVENT_LOGIN_FAILURE "dingaling::login_failure"
#define DL_EVENT_MESSAGE "dingaling::message"
#define DL_EVENT_CONNECTED "dingaling::connected"
static const char modname[] = "mod_dingaling";
@ -1099,6 +1100,11 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
return SWITCH_STATUS_GENERR;
}
if (switch_event_reserve_subclass(DL_EVENT_CONNECTED) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!", DL_EVENT_CONNECTED);
return SWITCH_STATUS_GENERR;
}
/* connect my internal structure to the blank pointer passed to me */
*module_interface = &channel_module_interface;
@ -1422,6 +1428,12 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
switch_event_fire(&event);
}
break;
case LDL_SIGNAL_CONNECTED:
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, DL_EVENT_CONNECTED) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", profile->login);
switch_event_fire(&event);
}
break;
default:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR\n");
break;