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

Freeswitch SVN anthm at freeswitch.org
Tue Dec 19 12:29:35 EST 2006


Author: anthm
Date: Tue Dec 19 12:29:33 2006
New Revision: 3719

Modified:
   freeswitch/trunk/libs/libdingaling/src/libdingaling.c
   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/libs/libdingaling/src/libdingaling.c
==============================================================================
--- freeswitch/trunk/libs/libdingaling/src/libdingaling.c	(original)
+++ freeswitch/trunk/libs/libdingaling/src/libdingaling.c	Tue Dec 19 12:29:33 2006
@@ -297,7 +297,7 @@
 static ldl_status parse_session_code(ldl_handle_t *handle, char *id, char *from, char *to, iks *xml, char *xtype)
 {
 	ldl_session_t *session = NULL;
-	ldl_signal_t signal = LDL_SIGNAL_NONE;
+	ldl_signal_t dl_signal = LDL_SIGNAL_NONE;
 	char *initiator = iks_find_attrib(xml, "initiator");
 	char *msg = NULL;
 
@@ -327,7 +327,7 @@
 			
 			if (!strcasecmp(type, "initiate") || !strcasecmp(type, "accept")) {
 
-				signal = LDL_SIGNAL_INITIATE;
+				dl_signal = LDL_SIGNAL_INITIATE;
 				if (!strcasecmp(type, "accept")) {
 					msg = "accept";
 				}
@@ -363,10 +363,10 @@
 					tag = iks_next_tag(tag);
 				}
 			} else if (!strcasecmp(type, "transport-accept")) {
-				signal = LDL_SIGNAL_TRANSPORT_ACCEPT;
+				dl_signal = LDL_SIGNAL_TRANSPORT_ACCEPT;
 			} else if (!strcasecmp(type, "transport-info")) {
 				char *tid = iks_find_attrib(xml, "id");
-				signal = LDL_SIGNAL_CANDIDATES;
+				dl_signal = LDL_SIGNAL_CANDIDATES;
 				tag = iks_child (xml);
 				
 				if (tag && !strcasecmp(iks_name(tag), "transport")) {
@@ -458,17 +458,17 @@
 					tag = iks_next_tag(tag);
 				}
 			} else if (!strcasecmp(type, "terminate")) {
-				signal = LDL_SIGNAL_TERMINATE;
+				dl_signal = LDL_SIGNAL_TERMINATE;
 			} else if (!strcasecmp(type, "error")) {
-				signal = LDL_SIGNAL_ERROR;
+				dl_signal = LDL_SIGNAL_ERROR;
 			}
 		}
 		
 		xml = iks_child(xml);
 	}
 
-	if (handle->session_callback && signal) {
-		handle->session_callback(handle, session, signal, to, from, id, msg); 
+	if (handle->session_callback && dl_signal) {
+		handle->session_callback(handle, session, dl_signal, to, from, id, msg); 
 	}
 
 	return LDL_STATUS_SUCCESS;
@@ -700,22 +700,24 @@
 	char id[1024];
 	char *resource;
 	struct ldl_buffer *buffer;
-	ldl_signal_t signal;
+	ldl_signal_t dl_signal = LDL_SIGNAL_PRESENCE_IN;
 
-	
-	if (type && !strcasecmp(type, "unavailable")) {
-		signal = LDL_SIGNAL_PRESENCE_OUT;
-    } else if (type && !strcasecmp(type, "probe")) {
-		signal = LDL_SIGNAL_PRESENCE_PROBE;
-	} else {
-		signal = LDL_SIGNAL_PRESENCE_IN;
-	}
+    if (type && *type) {
+        if (!strcasecmp(type, "unavailable")) {
+            dl_signal = LDL_SIGNAL_PRESENCE_OUT;
+        } else if (!strcasecmp(type, "probe")) {
+            dl_signal = LDL_SIGNAL_PRESENCE_PROBE;
+        }
+        if (!status) {
+            status = type;
+        }
+    } else {
+        if (!status) {
+            status = "Available";
+        }
+    }
 
-	if (!status) {
-		status = type;
-	}
 
-
 	apr_cpystrn(id, from, sizeof(id));
 	lowercase(id);
 
@@ -738,7 +740,7 @@
 	}
 	
     if (handle->session_callback) {
-        handle->session_callback(handle, NULL, signal, to, id, status ? status : "n/a", show ? show : "n/a");
+        handle->session_callback(handle, NULL, dl_signal, to, id, status ? status : "n/a", show ? show : "n/a");
     }
 
 	return IKS_FILTER_EAT;

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:29:33 2006
@@ -187,7 +187,7 @@
 										   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 signal, char *to, char *from, char *subject, char *msg);
+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);
 
@@ -2065,7 +2065,7 @@
 	switch_safe_free(xmlstr);
 }
 
-static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsession, ldl_signal_t signal, char *to, char *from, char *subject, char *msg)
+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)
 {
 	struct mdl_profile *profile = NULL;
 	switch_core_session_t *session = NULL;
@@ -2085,7 +2085,7 @@
 
 	if (!dlsession) {
 		if (profile->user_flags & LDL_FLAG_COMPONENT) {
-			switch(signal) {
+			switch(dl_signal) {
 			case LDL_SIGNAL_VCARD:
 				do_vcard(handle, to, from, subject);
 				break;
@@ -2174,8 +2174,8 @@
 						switch_event_fire(&event);
 					}
 				}
-				break;
 #endif
+				break;
 
 			case LDL_SIGNAL_PRESENCE_OUT:
 				
@@ -2183,7 +2183,8 @@
 					execute_sql(profile->dbname, sql, profile->mutex);
 					switch_core_db_free(sql);
 				}
-
+                printf("XXXXXXXXXXXXXXXXXXXXXXXXXXNO FUCKING WAY!!! %d %d\n", dl_signal, LDL_SIGNAL_PRESENCE_OUT);
+                abort();
 				if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_OUT) == SWITCH_STATUS_SUCCESS) {
 					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
 					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", profile->login);
@@ -2196,7 +2197,7 @@
 			}
 		} 
 
-		switch(signal) {
+		switch(dl_signal) {
 		case LDL_SIGNAL_MSG: {
 			switch_chat_interface_t *ci;
 			char *proto = MDL_CHAT_PROTO;
@@ -2284,7 +2285,7 @@
 		}
 
 	} else {
-		if (signal != LDL_SIGNAL_INITIATE) {
+		if (dl_signal != LDL_SIGNAL_INITIATE) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Session is already dead\n");
 			status = LDL_STATUS_FALSE;
 			goto done;
@@ -2325,7 +2326,7 @@
 
 	}
 
-	switch(signal) {
+	switch(dl_signal) {
 	case LDL_SIGNAL_MSG:
 		if (msg) { 
 			if (*msg == '+') {
@@ -2370,7 +2371,7 @@
 		switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT_ACCEPT);
 		break;
 	case LDL_SIGNAL_INITIATE:
-		if (signal) {
+		if (dl_signal) {
 			ldl_payload_t *payloads;
 			unsigned int len = 0;
 			int match = 0;
@@ -2448,7 +2449,7 @@
 		
 		break;
 	case LDL_SIGNAL_CANDIDATES:
-		if (signal) {
+		if (dl_signal) {
 			ldl_candidate_t *candidates;
 			unsigned int len = 0;
 			unsigned int x;

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:29:33 2006
@@ -3234,7 +3234,10 @@
 		open = "closed";
 	}
 
-	if (strcasecmp(proto, SOFIA_CHAT_PROTO)) {
+    if (!strcasecmp(sub_to_host, host)) {
+        /* same host */
+		id = switch_mprintf("sip:%s+%s@%s", proto, sub_to_user, sub_to_host);
+	} else if (strcasecmp(proto, SOFIA_CHAT_PROTO)) {
 		/*encapsulate*/
 		id = switch_mprintf("sip:%s+%s+%s@%s", proto, sub_to_user, sub_to_host, host);
 	} else {
@@ -3268,7 +3271,7 @@
 	nua_notify(nh,
 			   NUTAG_URL(contact),
 			   SIPTAG_TO_STR(full_from),
-			   SIPTAG_FROM_STR(to),
+			   SIPTAG_FROM_STR(id),
 			   SIPTAG_CONTACT_STR(profile->url),
 			   SIPTAG_CALL_ID_STR(callid),
 			   SIPTAG_VIA_STR(full_via),
@@ -3406,6 +3409,13 @@
 			exp_raw = (sip->sip_expires ? sip->sip_expires->ex_delta : 3600);
 			exp = (long) time(NULL) + exp_raw;
 			
+            if (sip && sip->sip_from) {
+                from_user = (char *) sip->sip_from->a_url->url_user;
+                from_host = (char *) sip->sip_from->a_url->url_host;
+            } else {
+                from_user = "n/a";
+                from_host = "n/a";
+            }
 
 			if ((sql = switch_mprintf("delete from sip_subscriptions where "
 											  "proto='%q' and user='%q' and host='%q' and sub_to_user='%q' and sub_to_host='%q' and event='%q';\n"



More information about the Freeswitch-trunk mailing list