[Freeswitch-svn] [commit] r3720 - in freeswitch/trunk/src/mod/endpoints: mod_dingaling mod_sofia

Freeswitch SVN anthm at freeswitch.org
Tue Dec 19 12:48:51 EST 2006


Author: anthm
Date: Tue Dec 19 12:48:50 2006
New Revision: 3720

Modified:
   freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c

Log:
xmas presence

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	Tue Dec 19 12:48:50 2006
@@ -190,6 +190,7 @@
 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);
 
 #define is_special(s) (s && (strstr(s, "ext+") || strstr(s, "user+")))
 
@@ -305,6 +306,25 @@
 	}
 
 	switch(event->event_id) {
+	case SWITCH_EVENT_PRESENCE_PROBE: {
+        	char *sql;
+            switch_core_db_t *db;
+            char *errmsg;
+            char *to = switch_event_get_header(event, "to");
+
+            if (to && (sql = switch_mprintf("select * from subscriptions where sub_to='%q'", to))) {
+                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);
+                    return;
+                }
+                switch_mutex_lock(profile->mutex);
+                switch_core_db_exec(db, sql, sin_callback, profile, &errmsg);
+                switch_mutex_unlock(profile->mutex);
+                switch_core_db_close(db);
+                switch_safe_free(sql);
+            }
+    }
+        return;
 	case SWITCH_EVENT_PRESENCE_IN:
 		if (!status) {
 			status = "Available";
@@ -1614,6 +1634,11 @@
 	}
 	
 	if (switch_event_bind((char *) modname, SWITCH_EVENT_PRESENCE_IN, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
+		return SWITCH_STATUS_GENERR;
+	}
+
+	if (switch_event_bind((char *) modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
 		return SWITCH_STATUS_GENERR;
 	}

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	Tue Dec 19 12:48:50 2006
@@ -5326,6 +5326,35 @@
 
 
 	switch(event->event_id) {
+    case SWITCH_EVENT_PRESENCE_PROBE: {
+        switch_core_db_t *db;
+        char *to = switch_event_get_header(event, "to");
+        char *user, *host;
+
+        if (!to || !(user = strdup(to))) {
+            return;
+        }
+
+        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);
+            switch_safe_free(user);
+            return;
+        }
+
+        if ((host = strchr(user, '@'))) {
+            *host++ = '\0';
+        }
+        if (user && host && 
+            (sql = switch_mprintf("select user,host,'Registered','unknown','' from sip_registrations where user='%q' and host='%q'", user, host))) {
+            switch_mutex_lock(profile->ireg_mutex);
+            switch_core_db_exec(db, sql, resub_callback, profile, &errmsg);
+            switch_mutex_unlock(profile->ireg_mutex);
+            switch_safe_free(sql);
+        }
+        switch_safe_free(user);
+        switch_core_db_close(db);
+    }
+        return;
 	case SWITCH_EVENT_PRESENCE_IN:
 		sql = switch_mprintf("select 1,'%q','%q',* from sip_subscriptions where proto='%q' and event='%q' and sub_to_user='%q' and sub_to_host='%q'", 
 							 status , rpid, proto, event_type, euser, host);
@@ -5402,6 +5431,11 @@
 	}
 
 	if (switch_event_bind((char *) modname, SWITCH_EVENT_PRESENCE_OUT, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
+		return SWITCH_STATUS_GENERR;
+	}
+
+	if (switch_event_bind((char *) modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
 		return SWITCH_STATUS_GENERR;
 	}



More information about the Freeswitch-svn mailing list