[Freeswitch-svn] [commit] r3886 - in freeswitch/branches/knhor/trunk/src: . include mod/endpoints/mod_dingaling

Freeswitch SVN knhor at freeswitch.org
Mon Jan 1 19:40:28 EST 2007


Author: knhor
Date: Mon Jan  1 19:40:28 2007
New Revision: 3886

Modified:
   freeswitch/branches/knhor/trunk/src/include/switch_types.h
   freeswitch/branches/knhor/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
   freeswitch/branches/knhor/trunk/src/switch_event.c

Log:
add "subscribe" and "unsubscribe" event generation for conference targets


Modified: freeswitch/branches/knhor/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/branches/knhor/trunk/src/include/switch_types.h	(original)
+++ freeswitch/branches/knhor/trunk/src/include/switch_types.h	Mon Jan  1 19:40:28 2007
@@ -724,6 +724,8 @@
 	SWITCH_EVENT_PRESENCE_IN		- Presence in
 	SWITCH_EVENT_PRESENCE_OUT		- Presence out
 	SWITCH_EVENT_PRESENCE_PROBE		- Presence probe
+	SWITCH_EVENT_PRESENCE_SUBSCRIBE		- Presence subscribe
+	SWITCH_EVENT_PRESENCE_UNSUBSCRIBE	- Presnece unsubscribe
 	SWITCH_EVENT_CODEC				- Codec Change
 	SWITCH_EVENT_BACKGROUND_JOB		- Background Job
 	SWITCH_EVENT_DETECTED_SPEECH	- Detected Speech
@@ -762,6 +764,8 @@
 	SWITCH_EVENT_PRESENCE_IN,
 	SWITCH_EVENT_PRESENCE_OUT,
 	SWITCH_EVENT_PRESENCE_PROBE,
+	SWITCH_EVENT_PRESENCE_SUBSCRIBE,
+	SWITCH_EVENT_PRESENCE_UNSUBSCRIBE,
 	SWITCH_EVENT_ROSTER,
 	SWITCH_EVENT_CODEC,
 	SWITCH_EVENT_BACKGROUND_JOB,

Modified: freeswitch/branches/knhor/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/branches/knhor/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c	(original)
+++ freeswitch/branches/knhor/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c	Mon Jan  1 19:40:28 2007
@@ -193,6 +193,7 @@
 static int sin_callback(void *pArg, int argc, char **argv, char **columnNames);
 
 #define is_special(s) (s && (strstr(s, "ext+") || strstr(s, "user+")))
+#define is_conference(s) (s && (strstr(s, "conf+")))
 
 static char *translate_rpid(char *in, char *ext)
 {
@@ -2145,19 +2146,29 @@
 			case LDL_SIGNAL_VCARD:
 				do_vcard(handle, to, from, subject);
 				break;
+
 			case LDL_SIGNAL_UNSUBSCRIBE:
 
 				if ((sql = switch_mprintf("delete from subscriptions where sub_from='%q' and sub_to='%q';", from, to))) {
 					execute_sql(profile->dbname, sql, profile->mutex);
 					switch_core_db_free(sql);
 				}
-
+				if (is_conference(to)) {
+					if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_UNSUBSCRIBE) == 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);
+						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s",  from);
+						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "to", "%s",  to);
+						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "unsubscribe");
+						switch_event_fire(&event);
+					}
+				}
 				break;
 
 			case LDL_SIGNAL_SUBSCRIBE:
 				
 				if ((sql = switch_mprintf("delete from subscriptions where sub_from='%q' and sub_to='%q';\n"
-										  "insert into subscriptions values('%q','%q','%q','%q');\n", from, to, from, to, msg, subject))) {
+							  "insert into subscriptions values('%q','%q','%q','%q');\n", from, to, from, to, msg, subject))) {
 					execute_sql(profile->dbname, sql, profile->mutex);
 					switch_core_db_free(sql);
 				}
@@ -2166,19 +2177,18 @@
 					ldl_handle_send_presence(profile->handle, to, from, NULL, NULL, "Click To Call");
 				}
 
-#if 0
-				if (is_special(to)) {
-					if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
+				if (is_conference(to)) {
+					if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_SUBSCRIBE) == 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);
-						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s",  to);
-						//switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "unknown");
-						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Click To Call");
+						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s",  from);
+						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "to", "%s",  to);
+						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "subscribe");
 						switch_event_fire(&event);
 					}
 				}
-#endif
 				break;
+
 			case LDL_SIGNAL_ROSTER:
 				if (switch_event_create(&event, SWITCH_EVENT_ROSTER) == SWITCH_STATUS_SUCCESS) {
 					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
@@ -2186,19 +2196,22 @@
 					switch_event_fire(&event);
 				}
 				break;
+
 			case LDL_SIGNAL_PRESENCE_PROBE:
 				if (is_special(to)) {
-                    ldl_handle_send_presence(profile->handle, to, from, NULL, NULL, "Click To Call");
-                } else {
+				    ldl_handle_send_presence(profile->handle, to, from, NULL, NULL, "Click To Call");
+				} else {
 					if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_PROBE) == 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);
 						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s",  from);
 						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "to", "%s",  to);
+						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "probe");
 						switch_event_fire(&event);
 					}
-                }
-                break;
+				}
+				break;
+
 			case LDL_SIGNAL_PRESENCE_IN:
 				
 				if ((sql = switch_mprintf("update subscriptions set show='%q', status='%q' where sub_from='%q'", msg, subject, from))) {
@@ -2212,6 +2225,7 @@
 					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s",  from);
 					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "%s", msg);
 					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "%s", subject);
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "in");
 					switch_event_fire(&event);
 				}
 
@@ -2243,9 +2257,11 @@
 					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
 					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", profile->login);
 					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s", from);
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "out");
 					switch_event_fire(&event);
 				}
 				break;
+
 			default:
 				break;
 			}

Modified: freeswitch/branches/knhor/trunk/src/switch_event.c
==============================================================================
--- freeswitch/branches/knhor/trunk/src/switch_event.c	(original)
+++ freeswitch/branches/knhor/trunk/src/switch_event.c	Mon Jan  1 19:40:28 2007
@@ -126,6 +126,8 @@
 	"PRESENCE_IN",
 	"PRESENCE_OUT",
 	"PRESENCE_PROBE",
+	"PRESENCE_SUBSCRIBE",
+	"PRESENCE_UNSUBSCRIBE",
 	"ROSTER",
 	"CODEC",
 	"BACKGROUND_JOB",



More information about the Freeswitch-svn mailing list