svn diff manager.c Index: manager.c =================================================================== --- manager.c (revision 33395) +++ manager.c (working copy) @@ -1034,6 +1034,37 @@ return 0; } +static char mandescr_sendtext[] = +"Description: Send a text message to a channel\n" +"Variables: \n" +" Channel: The channel name to send the text message to\n" +" Value: The text message to send\n"; + +static int action_sendtext(struct mansession *s, struct message *m) +{ + struct ast_channel *c = NULL; + char *name = astman_get_header(m, "Channel"); + char *msg = astman_get_header(m, "Value"); + int res; + if (ast_strlen_zero(name)) { + astman_send_error(s, m, "No channel specified"); + return 0; + } + if (ast_strlen_zero(msg)) { + astman_send_error(s, m, "No value specified"); + return 0; + } + c = ast_get_channel_by_name_locked(name); + if (!c) { + astman_send_error(s, m, "No such channel"); + return 0; + } + res = ast_sendtext(c, msg); + ast_mutex_unlock(&c->lock); + astman_send_ack(s, m, res>=0 ? "Message sent" : " Message send failed"); + return 0; +} + static char mandescr_setvar[] = "Description: Set a global or local channel variable.\n" "Variables: (Names marked with * are required)\n" @@ -2354,6 +2385,7 @@ ast_manager_register2("ListCommands", 0, action_listcommands, "List available manager commands", mandescr_listcommands); 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); + ast_manager_register2("Sendtext", EVENT_FLAG_CALL, action_sendtext, "send a text message to a channel", mandescr_sendtext); ast_cli_register(&show_mancmd_cli); ast_cli_register(&show_mancmds_cli);