From 7a9472f8a40af34653e7ea6501f05eda8ba28f38 Mon Sep 17 00:00:00 2001
From: BJ Weschke <bweschke@btwtech.com>
Date: Thu, 4 May 2006 21:33:45 +0000
Subject: [PATCH]  New manager action SendDTMF #6682 (squinky86)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@24776 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 apps/app_senddtmf.c | 30 ++++++++++++++++++++++++++++++
 doc/manager.txt     |  3 +++
 2 files changed, 33 insertions(+)

diff --git a/apps/app_senddtmf.c b/apps/app_senddtmf.c
index 9ba21d2f3d..5b524bc059 100644
--- a/apps/app_senddtmf.c
+++ b/apps/app_senddtmf.c
@@ -43,6 +43,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/options.h"
 #include "asterisk/utils.h"
 #include "asterisk/app.h"
+#include "asterisk/manager.h"
 
 static char *tdesc = "Send DTMF digits Application";
 
@@ -93,11 +94,39 @@ static int senddtmf_exec(struct ast_channel *chan, void *data)
 	return res;
 }
 
+static char mandescr_playdtmf[] =
+"Description: Plays a dtmf digit on the specified channel.\n"
+"Variables: (all are required)\n"
+"	Channel: Channel name to send digit to\n"
+"	Digit: The dtmf digit to play\n";
+
+static int manager_play_dtmf(struct mansession *s, struct message *m)
+{
+	char *channel, *digit;
+
+	channel = astman_get_header(m, "Channel");
+	digit = astman_get_header(m, "Digit");
+	struct ast_channel *chan = ast_get_channel_by_name_locked(channel);
+	if (chan == NULL) {
+		astman_send_error(s, m, "No such channel");
+		return 0;
+	}
+	if (digit == NULL) {
+		astman_send_error(s, m, "No digit specified");
+		return 0;
+	}
+	ast_senddigit(chan, *digit);
+	ast_mutex_unlock(&chan->lock);
+	astman_send_ack(s, m, "DTMF successfully queued");
+	return 0;
+}
+
 static int unload_module(void *mod)
 {
 	int res;
 
 	res = ast_unregister_application(app);
+	res |= ast_manager_unregister("PlayDTMF");
 
 	STANDARD_HANGUP_LOCALUSERS;
 
@@ -106,6 +135,7 @@ static int unload_module(void *mod)
 
 static int load_module(void *mod)
 {
+	ast_manager_register2( "PlayDTMF", EVENT_FLAG_CALL, manager_play_dtmf, "Play DTMF signal on a specific channel.", mandescr_playdtmf );
 	return ast_register_application(app, senddtmf_exec, synopsis, descrip);
 }
 
diff --git a/doc/manager.txt b/doc/manager.txt
index cee0c470a9..38d17b3d2b 100644
--- a/doc/manager.txt
+++ b/doc/manager.txt
@@ -101,6 +101,9 @@ Parameters: Channel, Exten, Context, Priority, Timeout,
 Command: Ping
 Parameters: None
 
+Command: PlayDTMF
+Parameters: Channel, Digit
+
 Command: Redirect
 Parameters: Channel, ExtraChannel, Exten, Context, Priority
 
-- 
GitLab