mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-16 23:08:32 +00:00
Merge cmaj's ZapDND and specific channel status manager commands (bugs #1917, 1918)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3314 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -8188,6 +8188,42 @@ static struct zt_pvt *find_channel(int channel)
|
||||
return p;
|
||||
}
|
||||
|
||||
static int action_zapdndon(struct mansession *s, struct message *m)
|
||||
{
|
||||
struct zt_pvt *p = NULL;
|
||||
char *channel = astman_get_header(m, "ZapChannel");
|
||||
if (ast_strlen_zero(channel)) {
|
||||
astman_send_error(s, m, "No channel specified");
|
||||
return 0;
|
||||
}
|
||||
p = find_channel(atoi(channel));
|
||||
if (!p) {
|
||||
astman_send_error(s, m, "No such channel");
|
||||
return 0;
|
||||
}
|
||||
p->dnd = 1;
|
||||
astman_send_ack(s, m, "DND Enabled");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int action_zapdndoff(struct mansession *s, struct message *m)
|
||||
{
|
||||
struct zt_pvt *p = NULL;
|
||||
char *channel = astman_get_header(m, "ZapChannel");
|
||||
if (ast_strlen_zero(channel)) {
|
||||
astman_send_error(s, m, "No channel specified");
|
||||
return 0;
|
||||
}
|
||||
p = find_channel(atoi(channel));
|
||||
if (!p) {
|
||||
astman_send_error(s, m, "No such channel");
|
||||
return 0;
|
||||
}
|
||||
p->dnd = 0;
|
||||
astman_send_ack(s, m, "DND Disabled");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int action_transfer(struct mansession *s, struct message *m)
|
||||
{
|
||||
struct zt_pvt *p = NULL;
|
||||
@@ -9038,6 +9074,8 @@ int load_module(void)
|
||||
ast_manager_register( "ZapTransfer", 0, action_transfer, "Transfer Zap Channel" );
|
||||
ast_manager_register( "ZapHangup", 0, action_transferhangup, "Hangup Zap Channel" );
|
||||
ast_manager_register( "ZapDialOffhook", 0, action_zapdialoffhook, "Dial over Zap channel while offhook" );
|
||||
ast_manager_register( "ZapDNDon", 0, action_zapdndon, "Toggle Zap channel Do Not Disturb status ON" );
|
||||
ast_manager_register( "ZapDNDoff", 0, action_zapdndoff, "Toggle Zap channel Do Not Disturb status OFF" );
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
21
manager.c
21
manager.c
@@ -553,6 +553,7 @@ static int action_getvar(struct mansession *s, struct message *m)
|
||||
static int action_status(struct mansession *s, struct message *m)
|
||||
{
|
||||
char *id = astman_get_header(m,"ActionID");
|
||||
char *name = astman_get_header(m,"Channel");
|
||||
char idText[256] = "";
|
||||
struct ast_channel *c;
|
||||
char bridge[256];
|
||||
@@ -560,6 +561,19 @@ static int action_status(struct mansession *s, struct message *m)
|
||||
c = ast_channel_walk_locked(NULL);
|
||||
if (id && !ast_strlen_zero(id))
|
||||
snprintf(idText,256,"ActionID: %s\r\n",id);
|
||||
if (name && !ast_strlen_zero(name)) {
|
||||
while (c) {
|
||||
if (!strcasecmp(c->name, name)) {
|
||||
break;
|
||||
}
|
||||
ast_mutex_unlock(&c->lock);
|
||||
c = ast_channel_walk_locked(c);
|
||||
}
|
||||
if (!c) {
|
||||
astman_send_error(s, m, "No such channel");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
while(c) {
|
||||
if (c->bridge)
|
||||
snprintf(bridge, sizeof(bridge), "Link: %s\r\n", c->bridge->name);
|
||||
@@ -570,6 +584,7 @@ static int action_status(struct mansession *s, struct message *m)
|
||||
"Event: Status\r\n"
|
||||
"Channel: %s\r\n"
|
||||
"CallerID: %s\r\n"
|
||||
"Account: %s\r\n"
|
||||
"State: %s\r\n"
|
||||
"Context: %s\r\n"
|
||||
"Extension: %s\r\n"
|
||||
@@ -579,6 +594,7 @@ static int action_status(struct mansession *s, struct message *m)
|
||||
"%s"
|
||||
"\r\n",
|
||||
c->name, c->callerid ? c->callerid : "<unknown>",
|
||||
c->accountcode,
|
||||
ast_state2str(c->_state), c->context,
|
||||
c->exten, c->priority, bridge, c->uniqueid, idText);
|
||||
} else {
|
||||
@@ -586,15 +602,20 @@ static int action_status(struct mansession *s, struct message *m)
|
||||
"Event: Status\r\n"
|
||||
"Channel: %s\r\n"
|
||||
"CallerID: %s\r\n"
|
||||
"Account: %s\r\n"
|
||||
"State: %s\r\n"
|
||||
"%s"
|
||||
"Uniqueid: %s\r\n"
|
||||
"%s"
|
||||
"\r\n",
|
||||
c->name, c->callerid ? c->callerid : "<unknown>",
|
||||
c->accountcode,
|
||||
ast_state2str(c->_state), bridge, c->uniqueid, idText);
|
||||
}
|
||||
ast_mutex_unlock(&c->lock);
|
||||
if (name && !ast_strlen_zero(name)) {
|
||||
break;
|
||||
}
|
||||
c = ast_channel_walk_locked(c);
|
||||
}
|
||||
ast_cli(s->fd,
|
||||
|
||||
Reference in New Issue
Block a user