[Freeswitch-svn] [commit] r1660 - in freeswitch/trunk: libs/libdingaling/src src/mod/endpoints/mod_dingaling

anthm at freeswitch.org anthm at freeswitch.org
Thu Jun 22 17:57:40 EDT 2006


Author: anthm
Date: Thu Jun 22 17:57:40 2006
New Revision: 1660

Modified:
   freeswitch/trunk/libs/libdingaling/src/libdingaling.c
   freeswitch/trunk/libs/libdingaling/src/libdingaling.h
   freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c

Log:
dingaling tweak

Modified: freeswitch/trunk/libs/libdingaling/src/libdingaling.c
==============================================================================
--- freeswitch/trunk/libs/libdingaling/src/libdingaling.c	(original)
+++ freeswitch/trunk/libs/libdingaling/src/libdingaling.c	Thu Jun 22 17:57:40 2006
@@ -549,7 +549,7 @@
 			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 @@
 			}
 		} else if (strcmp("success", iks_name(node)) == 0) {
 			globals.logger(DL_LOG_DEBUG, "XMPP server connected\n");
+			iks_send_header(handle->parser, handle->acc->server);
+			ldl_set_flag(handle, LDL_FLAG_CONNECTED);
 			if (handle->session_callback) {
-				handle->session_callback(handle, NULL, LDL_SIGNAL_LOGIN_SUCCESS, "core", "Login Success", handle->login);
+				handle->session_callback(handle, NULL, LDL_SIGNAL_CONNECTED, "core", "Server Connected", handle->login);
 			}
-			iks_send_header(handle->parser, handle->acc->server);
-			ldl_set_flag(handle, LDL_FLAG_AUTHORIZED);
 		} 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 @@
 				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 @@
 
 		iks_disconnect(handle->parser);
 		iks_parser_delete(handle->parser);
+		ldl_clear_flag(handle, LDL_FLAG_CONNECTED);
 		ldl_clear_flag(handle, LDL_FLAG_AUTHORIZED);
 	}
 

Modified: freeswitch/trunk/libs/libdingaling/src/libdingaling.h
==============================================================================
--- freeswitch/trunk/libs/libdingaling/src/libdingaling.h	(original)
+++ freeswitch/trunk/libs/libdingaling/src/libdingaling.h	Thu Jun 22 17:57:40 2006
@@ -99,7 +99,8 @@
 	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 @@
 	LDL_SIGNAL_ERROR,
 	LDL_SIGNAL_LOGIN_SUCCESS,
 	LDL_SIGNAL_LOGIN_FAILURE,
+	LDL_SIGNAL_CONNECTED
 } ldl_signal_t;
 
 typedef enum {

Modified: freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c	Thu Jun 22 17:57:40 2006
@@ -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 @@
 		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;
 
@@ -1418,6 +1424,12 @@
 			break;
 		case LDL_SIGNAL_LOGIN_FAILURE:
 			if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, DL_EVENT_LOGIN_FAILURE) == SWITCH_STATUS_SUCCESS) {
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", profile->login);
+				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);
 			}



More information about the Freeswitch-svn mailing list