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

Freeswitch SVN anthm at freeswitch.org
Fri Oct 20 02:45:00 EDT 2006


Author: anthm
Date: Fri Oct 20 02:44:58 2006
New Revision: 3118

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

Log:
bs

Modified: freeswitch/trunk/libs/libdingaling/src/libdingaling.c
==============================================================================
--- freeswitch/trunk/libs/libdingaling/src/libdingaling.c	(original)
+++ freeswitch/trunk/libs/libdingaling/src/libdingaling.c	Fri Oct 20 02:44:58 2006
@@ -1247,7 +1247,7 @@
 	
 }
 
-static void ldl_flush_queue(ldl_handle_t *handle)
+static void ldl_flush_queue(ldl_handle_t *handle, int done)
 {
 	iks *msg;
 	void *pop;
@@ -1280,7 +1280,7 @@
 				packet_node->next = now + 5000000;
 			}
 		}
-		if (packet_node->retries == 0) {
+		if (packet_node->retries == 0 || done) {
 			if (globals.debug) {
 				globals.logger(DL_LOG_DEBUG, "Discarding packet %s\n", packet_node->id);
 			}
@@ -1302,7 +1302,7 @@
 	ldl_set_flag_locked(handle, LDL_FLAG_QUEUE_RUNNING);
 
 	while (ldl_test_flag(handle, LDL_FLAG_RUNNING)) {
-		ldl_flush_queue(handle);
+		ldl_flush_queue(handle, 0);
 
 		if (handle->loop_callback(handle) != LDL_STATUS_SUCCESS) {
 			int fd;
@@ -1414,7 +1414,7 @@
 
 			
 			if (!ldl_test_flag(handle, LDL_FLAG_TLS) && ldl_test_flag(handle, LDL_FLAG_READY)) {
-				ldl_flush_queue(handle);
+				ldl_flush_queue(handle, 0);
 			}
 
 			if (!ldl_test_flag(handle, LDL_FLAG_CONNECTED)) {
@@ -2022,7 +2022,7 @@
 {
 	apr_pool_t *pool = (*handle)->pool;
 
-	ldl_flush_queue(*handle);
+	ldl_flush_queue(*handle, 1);
 	
 
 	apr_pool_destroy(pool);

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	Fri Oct 20 02:44:58 2006
@@ -413,6 +413,59 @@
 
 }
 
+static int so_callback(void *pArg, int argc, char **argv, char **columnNames)
+{
+	struct mdl_profile *profile = (struct mdl_profile *) pArg;
+
+	char *sub_from = argv[0];
+	char *sub_to = argv[1];
+
+
+	ldl_handle_send_presence(profile->handle, sub_to, sub_from, "unavailable", "dnd", "Bub-Bye");
+	
+	return 0;
+}
+
+static void sign_off(void)
+{
+	struct mdl_profile *profile = NULL;
+	switch_hash_index_t *hi;
+    void *val;
+	char *sql;
+	switch_core_db_t *db;
+
+
+	sql = switch_mprintf("select * from subscriptions");
+	
+
+	for (hi = switch_hash_first(apr_hash_pool_get(globals.profile_hash), globals.profile_hash); hi; hi = switch_hash_next(hi)) {
+		char *errmsg;
+        switch_hash_this(hi, NULL, NULL, &val);
+        profile = (struct mdl_profile *) val;
+
+        if (!(profile->user_flags & LDL_FLAG_COMPONENT)) {
+			continue;
+        }
+
+
+		if (sql) {
+			if (!(db = switch_core_db_open_file(profile->dbname))) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname);
+				continue;
+			}
+			switch_mutex_lock(profile->mutex);
+			switch_core_db_exec(db, sql, so_callback, profile, &errmsg);
+			switch_mutex_unlock(profile->mutex);
+			switch_core_db_close(db);
+		}
+		
+	}
+	
+	switch_yield(1000000);
+	switch_safe_free(sql);
+
+}
+
 static void terminate_session(switch_core_session_t **session, int line, switch_call_cause_t cause)
 {
 	if (*session) {
@@ -1549,6 +1602,8 @@
 
 SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
 {
+	sign_off();
+
 	if (globals.running) {
 		int x = 0;
 		globals.running = 0;



More information about the Freeswitch-svn mailing list