[asterisk-commits] oej: trunk r46630 - /trunk/main/manager.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Oct 31 03:42:23 MST 2006


Author: oej
Date: Tue Oct 31 04:42:22 2006
New Revision: 46630

URL: http://svn.digium.com/view/asterisk?rev=46630&view=rev
Log:
Add manager sendtext action. (Issue 6131, ZX81 - thanks!)

Modified:
    trunk/main/manager.c

Modified: trunk/main/manager.c
URL: http://svn.digium.com/view/asterisk/trunk/main/manager.c?rev=46630&r1=46629&r2=46630&view=diff
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Tue Oct 31 04:42:22 2006
@@ -1429,6 +1429,45 @@
 	return 0;
 }
 
+static char mandescr_sendtext[] =
+"Description: Sends A Text Message while in a call.\n"
+"Variables: (Names marked with * are required)\n"
+"       *Channel: Channel to send message to\n"
+"       *Message: Message to send\n"
+"       ActionID: Optional Action id for message matching.\n";
+
+static int action_sendtext(struct mansession *s, struct message *m)
+{
+	struct ast_channel *c = NULL;
+	char *name = astman_get_header(m, "Channel");
+	char *textmsg = astman_get_header(m, "Message");
+	int res = 0;
+
+	if (!ast_strlen_zero(name)) {
+		astman_send_error(s, m, "No channel specified");
+		return 0;
+	}
+	if (!ast_strlen_zero(textmsg)) {
+		astman_send_error(s, m, "No Message specified");
+		return 0;
+	}
+
+	c = ast_get_channel_by_name_locked(name);
+	if (!c) {
+		astman_send_error(s, m, "No such channel");
+		return 0;
+	}
+
+	ast_mutex_unlock(&c->lock);
+	res = ast_sendtext(c, textmsg);
+	if (res > 0) {
+		astman_send_ack(s, m, "Success");
+	} else {
+		astman_send_error(s, m, "Failure");
+	}
+	return res;
+}
+
 static char mandescr_redirect[] =
 "Description: Redirect (transfer) a call.\n"
 "Variables: (Names marked with * are required)\n"
@@ -2761,6 +2800,7 @@
 		ast_manager_register2("MailboxStatus", EVENT_FLAG_CALL, action_mailboxstatus, "Check Mailbox", mandescr_mailboxstatus );
 		ast_manager_register2("MailboxCount", EVENT_FLAG_CALL, action_mailboxcount, "Check Mailbox Message Count", mandescr_mailboxcount );
 		ast_manager_register2("ListCommands", 0, action_listcommands, "List available manager commands", mandescr_listcommands);
+		ast_manager_register2("SendText", EVENT_FLAG_CALL, action_sendtext, "Send text message to channel", mandescr_sendtext);
 		ast_manager_register2("UserEvent", EVENT_FLAG_USER, action_userevent, "Send an arbitrary event", mandescr_userevent);
 		ast_manager_register2("WaitEvent", 0, action_waitevent, "Wait for an event to occur", mandescr_waitevent);
 



More information about the asterisk-commits mailing list