[asterisk-commits] mmichelson: trunk r106236 - in /trunk: ./ doc/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Mar 5 16:33:06 CST 2008


Author: mmichelson
Date: Wed Mar  5 16:33:05 2008
New Revision: 106236

URL: http://svn.digium.com/view/asterisk?view=rev&rev=106236
Log:
Adding the Atxfer manager command. With this, you may initiate
an attended transfer over AMI

(closes issue #10585)
Reported by: ornati
Patches:
      atxfer-trunk-r90428.diff uploaded by ornati (license 210)
	  (with modifications from me)
Tested by: putnopvut


Modified:
    trunk/CHANGES
    trunk/doc/manager_1_1.txt
    trunk/main/manager.c

Modified: trunk/CHANGES
URL: http://svn.digium.com/view/asterisk/trunk/CHANGES?view=diff&rev=106236&r1=106235&r2=106236
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Wed Mar  5 16:33:05 2008
@@ -57,6 +57,8 @@
   * Originate now requires the Originate privilege and, if you want to call out
     to a subshell, it requires the System privilege, as well.  This was done to
     enhance manager security.
+  * New command: Atxfer. See doc/manager_1_1.txt for more details or 
+    manager show command Atxfer from the CLI
 
 Dialplan functions
 ------------------

Modified: trunk/doc/manager_1_1.txt
URL: http://svn.digium.com/view/asterisk/trunk/doc/manager_1_1.txt?view=diff&rev=106236&r1=106235&r2=106236
==============================================================================
--- trunk/doc/manager_1_1.txt (original)
+++ trunk/doc/manager_1_1.txt Wed Mar  5 16:33:05 2008
@@ -177,6 +177,16 @@
 	  Rule: <name>			The name of the rule whose contents you wish to list. If this variable
 	  							is not present, all rules in queuerules.conf will be listed.
 		
+- Action: Atxfer
+	Modules: none
+	Purpose:
+		Initiate an attended transfer
+	Variables:
+		Channel: The transferer channel's name
+		Exten: The extension to transfer to
+		Priority: The priority to transfer to
+		Context: The context to transfer to
+
 
 * NEW EVENTS
 ------------

Modified: trunk/main/manager.c
URL: http://svn.digium.com/view/asterisk/trunk/main/manager.c?view=diff&rev=106236&r1=106235&r2=106236
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Wed Mar  5 16:33:05 2008
@@ -73,6 +73,7 @@
 #include "asterisk/version.h"
 #include "asterisk/term.h"
 #include "asterisk/astobj2.h"
+#include "asterisk/features.h"
 
 enum error_type {
 	UNKNOWN_ACTION = 1,
@@ -1941,6 +1942,74 @@
 	return 0;
 }
 
+static char mandescr_atxfer[] =
+"Description: Attended transfer.\n"
+"Variables: (Names marked with * are required)\n"
+"	*Channel: Transferer's channel\n"
+"	*Exten: Extension to transfer to\n"
+"	*Context: Context to transfer to\n"
+"	*Priority: Priority to transfer to\n"
+"	ActionID: Optional Action id for message matching.\n";
+
+static int action_atxfer(struct mansession *s, const struct message *m)
+{
+	const char *name = astman_get_header(m, "Channel");
+	const char *exten = astman_get_header(m, "Exten");
+	const char *context = astman_get_header(m, "Context");
+	const char *priority = astman_get_header(m, "Priority");
+	struct ast_channel *chan = NULL;
+	struct ast_call_feature *atxfer_feature = NULL;
+	char *feature_code = NULL;
+	int priority_int = 0;
+
+	if (ast_strlen_zero(name)) { 
+		astman_send_error(s, m, "No channel specified\n");
+		return 0;
+	}
+	if (ast_strlen_zero(exten)) {
+		astman_send_error(s, m, "No extension specified\n");
+		return 0;
+	}
+	if (ast_strlen_zero(context)) {
+		astman_send_error(s, m, "No context specified\n");
+		return 0;
+	}
+	if (ast_strlen_zero(priority)) {
+		astman_send_error(s, m, "No priority specified\n");
+		return 0;
+	}
+
+	if (sscanf(priority, "%d", &priority_int) != 1 && (priority_int = ast_findlabel_extension(NULL, context, exten, priority, NULL)) < 1) {
+		astman_send_error(s, m, "Invalid Priority\n");
+		return 0;
+	}
+
+	if (!(atxfer_feature = ast_find_call_feature("atxfer"))) {
+		astman_send_error(s, m, "No attended transfer feature found\n");
+		return 0;
+	}
+
+	if (!(chan = ast_get_channel_by_name_locked(name))) {
+		astman_send_error(s, m, "Channel specified does not exist\n");
+		return 0;
+	}
+
+	for (feature_code = atxfer_feature->exten; feature_code && *feature_code; ++feature_code) {
+		struct ast_frame f = {AST_FRAME_DTMF, *feature_code};
+		ast_queue_frame(chan, &f);
+	}
+
+	for (feature_code = (char *)exten; feature_code && *feature_code; ++feature_code) {
+		struct ast_frame f = {AST_FRAME_DTMF, *feature_code};
+		ast_queue_frame(chan, &f);
+	}
+
+	astman_send_ack(s, m, "Atxfer successfully queued\n");
+	ast_channel_unlock(chan);
+
+	return 0;
+}
+
 static char mandescr_command[] =
 "Description: Run a CLI command.\n"
 "Variables: (Names marked with * are required)\n"
@@ -3662,6 +3731,7 @@
 		ast_manager_register2("CreateConfig", EVENT_FLAG_CONFIG, action_createconfig, "Creates an empty file in the configuration directory", mandescr_createconfig);
 		ast_manager_register2("ListCategories", EVENT_FLAG_CONFIG, action_listcategories, "List categories in configuration file", mandescr_listcategories);
 		ast_manager_register2("Redirect", EVENT_FLAG_CALL, action_redirect, "Redirect (transfer) a call", mandescr_redirect );
+		ast_manager_register2("Atxfer", EVENT_FLAG_CALL, action_atxfer, "Attended transfer", mandescr_atxfer);
 		ast_manager_register2("Originate", EVENT_FLAG_ORIGINATE, action_originate, "Originate Call", mandescr_originate);
 		ast_manager_register2("Command", EVENT_FLAG_COMMAND, action_command, "Execute Asterisk CLI Command", mandescr_command );
 		ast_manager_register2("ExtensionState", EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, action_extensionstate, "Check Extension Status", mandescr_extensionstate );




More information about the asterisk-commits mailing list