mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 04:11:08 +00:00
implement a 'toggle' option for 'console mute' and 'console unmute'
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@126311 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -1125,25 +1125,32 @@ static char *console_mute(struct ast_cli_entry *e, int cmd, struct ast_cli_args
|
||||
{
|
||||
struct chan_oss_pvt *o = find_desc(oss_active);
|
||||
char *s;
|
||||
int toggle = 0;
|
||||
|
||||
if (cmd == CLI_INIT) {
|
||||
e->command = "console {mute|unmute}";
|
||||
e->command = "console {mute|unmute} [toggle]";
|
||||
e->usage =
|
||||
"Usage: console {mute|unmute}\n"
|
||||
"Usage: console {mute|unmute} [toggle]\n"
|
||||
" Mute/unmute the microphone.\n";
|
||||
return NULL;
|
||||
} else if (cmd == CLI_GENERATE)
|
||||
return NULL;
|
||||
|
||||
if (a->argc != e->args)
|
||||
if (a->argc > e->args)
|
||||
return CLI_SHOWUSAGE;
|
||||
s = a->argv[e->args-1];
|
||||
if (a->argc == e->args) {
|
||||
if (strcasecmp(a->argv[e->args-1], "toggle"))
|
||||
return CLI_SHOWUSAGE;
|
||||
toggle = 1;
|
||||
}
|
||||
s = a->argv[e->args-2];
|
||||
if (!strcasecmp(s, "mute"))
|
||||
o->mute = 1;
|
||||
o->mute = toggle ? ~o->mute : 1;
|
||||
else if (!strcasecmp(s, "unmute"))
|
||||
o->mute = 0;
|
||||
o->mute = toggle ? ~o->mute : 0;
|
||||
else
|
||||
return CLI_SHOWUSAGE;
|
||||
ast_cli(a->fd, "Console mic is %s\n", o->mute ? "off" : "on");
|
||||
return CLI_SUCCESS;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user