From 85c986c8b4a5cad99e591c7b4e2ea590b5f19141 Mon Sep 17 00:00:00 2001
From: Nathan Neulinger <nneul@neulinger.org>
Date: Fri, 2 Aug 2013 10:54:46 -0500
Subject: [PATCH] mod_skinny: add minimal handling of MeetMe button to send to
 a conference creation extension

---
 .../mod_skinny/conf/skinny_profiles/internal.xml         | 1 +
 src/mod/endpoints/mod_skinny/mod_skinny.c                | 9 +++++++++
 src/mod/endpoints/mod_skinny/mod_skinny.h                | 1 +
 src/mod/endpoints/mod_skinny/skinny_api.c                | 1 +
 src/mod/endpoints/mod_skinny/skinny_server.c             | 6 +++++-
 src/mod/endpoints/mod_skinny/skinny_tables.c             | 2 +-
 src/mod/endpoints/mod_skinny/skinny_tables.h             | 2 +-
 7 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/src/mod/endpoints/mod_skinny/conf/skinny_profiles/internal.xml b/src/mod/endpoints/mod_skinny/conf/skinny_profiles/internal.xml
index 39ce60fe4a..74cb86701b 100644
--- a/src/mod/endpoints/mod_skinny/conf/skinny_profiles/internal.xml
+++ b/src/mod/endpoints/mod_skinny/conf/skinny_profiles/internal.xml
@@ -14,6 +14,7 @@
     <param name="auto-restart" value="true"/>
     <param name="ext-voicemail" value="vmain"/>
     <param name="ext-redial" value="redial"/>
+    <!-- <param name="ext-meetme" value="conference"/> -->
   </settings>
   <soft-key-set-sets>
     <soft-key-set-set name="default">
diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.c b/src/mod/endpoints/mod_skinny/mod_skinny.c
index dc83c47294..18b0f3c3f5 100644
--- a/src/mod/endpoints/mod_skinny/mod_skinny.c
+++ b/src/mod/endpoints/mod_skinny/mod_skinny.c
@@ -171,6 +171,7 @@ switch_status_t skinny_profile_dump(const skinny_profile_t *profile, switch_stre
 	stream->write_function(stream, "Listener-Threads  \t%d\n", profile->listener_threads);
 	stream->write_function(stream, "Ext-Voicemail     \t%s\n", profile->ext_voicemail);
 	stream->write_function(stream, "Ext-Redial        \t%s\n", profile->ext_redial);
+	stream->write_function(stream, "Ext-MeetMe        \t%s\n", profile->ext_meetme);
 	stream->write_function(stream, "%s\n", line);
 
 	return SWITCH_STATUS_SUCCESS;
@@ -1864,6 +1865,10 @@ switch_status_t skinny_profile_set(skinny_profile_t *profile, const char *var, c
 		if (!profile->ext_redial || strcmp(val, profile->ext_redial)) {
 			profile->ext_redial = switch_core_strdup(profile->pool, val);
 		}
+	} else if (!strcasecmp(var, "ext-meetme")) {
+		if (!profile->ext_meetme || strcmp(val, profile->ext_meetme)) {
+			profile->ext_meetme = switch_core_strdup(profile->pool, val);
+		}
 	} else {
 		return SWITCH_STATUS_FALSE;
 	}
@@ -1956,6 +1961,10 @@ static switch_status_t load_skinny_config(void)
 					skinny_profile_set(profile, "ext-redial", "redial");
 				}
 
+				if (!profile->ext_meetme) {
+					skinny_profile_set(profile, "ext-meetme", "conference");
+				}
+
 				if (profile->port == 0) {
 					profile->port = 2000;
 				}
diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.h b/src/mod/endpoints/mod_skinny/mod_skinny.h
index d8ed1b03bf..39faed4388 100644
--- a/src/mod/endpoints/mod_skinny/mod_skinny.h
+++ b/src/mod/endpoints/mod_skinny/mod_skinny.h
@@ -117,6 +117,7 @@ struct skinny_profile {
 	/* extensions */
 	char *ext_voicemail;
 	char *ext_redial;
+	char *ext_meetme;
 	/* db */
 	char *dbname;
 	char *odbc_dsn;
diff --git a/src/mod/endpoints/mod_skinny/skinny_api.c b/src/mod/endpoints/mod_skinny/skinny_api.c
index 604b8509f7..94318c8de0 100644
--- a/src/mod/endpoints/mod_skinny/skinny_api.c
+++ b/src/mod/endpoints/mod_skinny/skinny_api.c
@@ -233,6 +233,7 @@ static switch_status_t skinny_api_list_settings(const char *line, const char *cu
 	switch_console_push_match(&my_matches, "auto-restart");
 	switch_console_push_match(&my_matches, "ext-voicemail");
 	switch_console_push_match(&my_matches, "ext-redial");
+	switch_console_push_match(&my_matches, "ext-meetme");
 
 	if (my_matches) {
 		*matches = my_matches;
diff --git a/src/mod/endpoints/mod_skinny/skinny_server.c b/src/mod/endpoints/mod_skinny/skinny_server.c
index 88db5b5347..a38005cdf6 100644
--- a/src/mod/endpoints/mod_skinny/skinny_server.c
+++ b/src/mod/endpoints/mod_skinny/skinny_server.c
@@ -76,7 +76,7 @@ uint32_t soft_key_template_default_events[] = {
 	SOFTKEY_CONF,
 	SOFTKEY_PARK,
 	SOFTKEY_JOIN,
-	SOFTKEY_MEETMECONF,
+	SOFTKEY_MEETME,
 	SOFTKEY_CALLPICKUP,
 	SOFTKEY_GRPCALLPICKUP,
 	SOFTKEY_DND,
@@ -1928,6 +1928,10 @@ switch_status_t skinny_handle_soft_key_event_message(listener_t *listener, skinn
 				}
 			}
 			break;
+		case SOFTKEY_MEETME:
+			skinny_create_incoming_session(listener, &line_instance, &session);
+			skinny_session_process_dest(session, listener, line_instance, listener->profile->ext_meetme, '\0', 0);
+			break;
 		default:
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
 					"Unknown SoftKeyEvent type: %d.\n", request->data.soft_key_event.event);
diff --git a/src/mod/endpoints/mod_skinny/skinny_tables.c b/src/mod/endpoints/mod_skinny/skinny_tables.c
index 9f04f8cd63..ea29918cbb 100644
--- a/src/mod/endpoints/mod_skinny/skinny_tables.c
+++ b/src/mod/endpoints/mod_skinny/skinny_tables.c
@@ -239,7 +239,7 @@ SKINNY_DECLARE_STR2ID(skinny_str2button, SKINNY_BUTTONS, -1)
 		{SOFTKEY_CONF, "SoftkeyConf"},
 		{SOFTKEY_PARK, "SoftkeyPark"},
 		{SOFTKEY_JOIN, "SoftkeyJoin"},
-		{SOFTKEY_MEETMECONF, "SoftkeyMeetmeconfrm"},
+		{SOFTKEY_MEETME, "SoftkeyMeetme"},
 		{SOFTKEY_CALLPICKUP, "SoftkeyCallpickup"},
 		{SOFTKEY_GRPCALLPICKUP, "SoftkeyGrpcallpickup"},
 		{SOFTKEY_DND, "SoftkeyDnd"},
diff --git a/src/mod/endpoints/mod_skinny/skinny_tables.h b/src/mod/endpoints/mod_skinny/skinny_tables.h
index 1e35a7d208..647837f212 100644
--- a/src/mod/endpoints/mod_skinny/skinny_tables.h
+++ b/src/mod/endpoints/mod_skinny/skinny_tables.h
@@ -192,7 +192,7 @@ enum skinny_soft_key_event {
 	SOFTKEY_CONF = 0x0D,
 	SOFTKEY_PARK = 0x0E,
 	SOFTKEY_JOIN = 0x0F,
-	SOFTKEY_MEETMECONF = 0x10,
+	SOFTKEY_MEETME = 0x10,
 	SOFTKEY_CALLPICKUP = 0x11,
 	SOFTKEY_GRPCALLPICKUP = 0x12,
 	SOFTKEY_DND = 0x13,