|
|
|
@ -4715,10 +4715,13 @@ static int action_status(struct mansession *s, const struct message *m)
|
|
|
|
|
|
|
|
|
|
static int action_sendtext(struct mansession *s, const struct message *m)
|
|
|
|
|
{
|
|
|
|
|
struct ast_channel *c = NULL;
|
|
|
|
|
struct ast_channel *c;
|
|
|
|
|
const char *name = astman_get_header(m, "Channel");
|
|
|
|
|
const char *textmsg = astman_get_header(m, "Message");
|
|
|
|
|
int res = 0;
|
|
|
|
|
struct ast_control_read_action_payload *frame_payload;
|
|
|
|
|
int payload_size;
|
|
|
|
|
int frame_size;
|
|
|
|
|
int res;
|
|
|
|
|
|
|
|
|
|
if (ast_strlen_zero(name)) {
|
|
|
|
|
astman_send_error(s, m, "No channel specified");
|
|
|
|
@ -4730,13 +4733,29 @@ static int action_sendtext(struct mansession *s, const struct message *m)
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!(c = ast_channel_get_by_name(name))) {
|
|
|
|
|
c = ast_channel_get_by_name(name);
|
|
|
|
|
if (!c) {
|
|
|
|
|
astman_send_error(s, m, "No such channel");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
res = ast_sendtext(c, textmsg);
|
|
|
|
|
c = ast_channel_unref(c);
|
|
|
|
|
payload_size = strlen(textmsg) + 1;
|
|
|
|
|
frame_size = payload_size + sizeof(*frame_payload);
|
|
|
|
|
|
|
|
|
|
frame_payload = ast_malloc(frame_size);
|
|
|
|
|
if (!frame_payload) {
|
|
|
|
|
ast_channel_unref(c);
|
|
|
|
|
astman_send_error(s, m, "Failure");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
frame_payload->action = AST_FRAME_READ_ACTION_SEND_TEXT;
|
|
|
|
|
frame_payload->payload_size = payload_size;
|
|
|
|
|
memcpy(frame_payload->payload, textmsg, payload_size);
|
|
|
|
|
res = ast_queue_control_data(c, AST_CONTROL_READ_ACTION, frame_payload, frame_size);
|
|
|
|
|
|
|
|
|
|
ast_free(frame_payload);
|
|
|
|
|
ast_channel_unref(c);
|
|
|
|
|
|
|
|
|
|
if (res >= 0) {
|
|
|
|
|
astman_send_ack(s, m, "Success");
|
|
|
|
|