Revision
16839
Author
mochouinard
Date
2010-02-26 14:17:31 -0600 (Fri, 26 Feb 2010)

Log Message

mod_directory: add third argument for the transfer context.  If not set, use the user domain as current behavior

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/applications/mod_directory/mod_directory.c (16838 => 16839)


--- freeswitch/trunk/src/mod/applications/mod_directory/mod_directory.c	2010-02-26 19:20:24 UTC (rev 16838)
+++ freeswitch/trunk/src/mod/applications/mod_directory/mod_directory.c	2010-02-26 20:17:31 UTC (rev 16839)
@@ -311,7 +311,7 @@
 }
 
 #define DIR_DESC "directory"
-#define DIR_USAGE "<profile_name> <domain_name>"
+#define DIR_USAGE "<profile_name> <domain_name> [<context_name>]"
 
 static void free_profile(dir_profile_t *profile)
 {
@@ -833,6 +833,7 @@
 	char *mydata = NULL;
 	const char *profile_name = NULL;
 	const char *domain_name = NULL;
+	const char *context_name = NULL;
 	dir_profile_t *profile = NULL;
 	int x = 0;
 	char *sql = NULL;
@@ -846,7 +847,10 @@
 	}
 
 	mydata = switch_core_session_strdup(session, data);
-	argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+	if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) < 2) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Not enough args [%s]\n", data);
+		return;
+	}
 
 	if (argv[x]) {
 		profile_name = argv[x++];
@@ -856,11 +860,19 @@
 		domain_name = argv[x++];
 	}
 
+	if (argv[x]) {
+		context_name = argv[x++];
+	}
+
 	if (!(profile = get_profile(profile_name))) {
 		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error invalid profile %s\n", profile_name);
 		return;
 	}
 
+	if (!context_name) {
+		context_name = domain_name;
+	}
+
 	populate_database(session, profile, domain_name);
 
 	memset(&s_param, 0, sizeof(s_param));
@@ -895,7 +907,7 @@
 
 	if (!zstr(s_param.transfer_to)) {
 		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Directory transfering call to : %s\n", s_param.transfer_to);
-		switch_ivr_session_transfer(session, s_param.transfer_to, "XML", domain_name);
+		switch_ivr_session_transfer(session, s_param.transfer_to, "XML", context_name);
 	}
 
 	/* Delete all sql entry for this call */