Index: asterisk/manager.c =================================================================== --- asterisk/manager.c (revision 8259) +++ asterisk/manager.c (working copy) @@ -914,6 +914,46 @@ 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_command[] = "Description: Run a CLI command.\n" "Variables: (Names marked with * are required)\n" @@ -1670,6 +1710,7 @@ ast_manager_register2("Logoff", 0, action_logoff, "Logoff Manager", mandescr_logoff); ast_manager_register2("Hangup", EVENT_FLAG_CALL, action_hangup, "Hangup Channel", mandescr_hangup); ast_manager_register("Status", EVENT_FLAG_CALL, action_status, "Lists channel status" ); + ast_manager_register2("SendText", EVENT_FLAG_CALL, action_sendText, "Send a Text Message", mandescr_sendText ); ast_manager_register2("Setvar", EVENT_FLAG_CALL, action_setvar, "Set Channel Variable", mandescr_setvar ); ast_manager_register2("Getvar", EVENT_FLAG_CALL, action_getvar, "Gets a Channel Variable", mandescr_getvar ); ast_manager_register2("Redirect", EVENT_FLAG_CALL, action_redirect, "Redirect (transfer) a call", mandescr_redirect );