summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAlfred E. Heggestad <aeh@db.org>2016-08-07 10:42:47 +0200
committerAlfred E. Heggestad <aeh@db.org>2016-08-07 10:42:47 +0200
commite3ecbddba06f91c3ef5b3cd8305a8f2fdb6c9cde (patch)
treec12474268e452b242c688689bd8eba3d92f4a151 /modules
parent7f35380ee3a39faad1f10fcbb6b115b8ddc5f2a7 (diff)
cmd: add support for long commands
- Long commands are commands that is 2 or more characters, and MUST be completed by pressing enter. - A given command can have a long-command, a short-command or both. - All long commands are using '/' (slash) prefix - a simple TAB-completion is supported, while punching in your long command you can press TAB to see a list of commands that matches the input string. Feedback is welcome, specially on the long-command strings itself. If you want to suggest changes, please make a small and non-intrusive patch and send it as a Pull Request (PR).
Diffstat (limited to 'modules')
-rw-r--r--modules/auloop/auloop.c4
-rw-r--r--modules/contact/contact.c10
-rw-r--r--modules/debug_cmd/debug_cmd.c18
-rw-r--r--modules/gtk/gtk_mod.c2
-rw-r--r--modules/menu/menu.c125
-rw-r--r--modules/natbd/natbd.c2
-rw-r--r--modules/presence/presence.c4
-rw-r--r--modules/vidloop/vidloop.c4
-rw-r--r--modules/zrtp/zrtp.c2
9 files changed, 92 insertions, 79 deletions
diff --git a/modules/auloop/auloop.c b/modules/auloop/auloop.c
index 05ee623..5d1d9e8 100644
--- a/modules/auloop/auloop.c
+++ b/modules/auloop/auloop.c
@@ -361,8 +361,8 @@ static int auloop_stop(struct re_printf *pf, void *arg)
static const struct cmd cmdv[] = {
- {'a', 0, "Start audio-loop", auloop_start },
- {'A', 0, "Stop audio-loop", auloop_stop },
+ {"auloop", 'a', 0, "Start audio-loop", auloop_start },
+ {"auloop_stop", 'A', 0, "Stop audio-loop", auloop_stop },
};
diff --git a/modules/contact/contact.c b/modules/contact/contact.c
index c71c370..bc2f09e 100644
--- a/modules/contact/contact.c
+++ b/modules/contact/contact.c
@@ -77,7 +77,7 @@ static int cmd_contact(struct re_printf *pf, void *arg)
switch (carg->key) {
- case '/':
+ case '|':
err = ua_connect(uag_current(), NULL, NULL,
contact_str(cnt), NULL, VIDMODE_ON);
if (err) {
@@ -127,10 +127,10 @@ static int cmd_message(struct re_printf *pf, void *arg)
static const struct cmd cmdv[] = {
- {'/', CMD_IPRM, "Dial from contacts", cmd_contact },
- {'=', CMD_IPRM, "Select chat peer", cmd_contact },
- {'C', 0, "List contacts", print_contacts },
- {'-', CMD_PRM, cmd_desc, cmd_message },
+{"dialcontact", '|', CMD_IPRM, "Dial from contacts", cmd_contact },
+{"chatpeer", '=', CMD_IPRM, "Select chat peer", cmd_contact },
+{"contacts", 'C', 0, "List contacts", print_contacts },
+{"message", '-', CMD_PRM, cmd_desc, cmd_message },
};
diff --git a/modules/debug_cmd/debug_cmd.c b/modules/debug_cmd/debug_cmd.c
index aee65cc..0d6c375 100644
--- a/modules/debug_cmd/debug_cmd.c
+++ b/modules/debug_cmd/debug_cmd.c
@@ -63,15 +63,15 @@ static int cmd_ua_debug(struct re_printf *pf, void *unused)
static const struct cmd debugcmdv[] = {
- {'M', 0, "Main loop debug", re_debug },
- {'g', 0, "Print configuration", cmd_config_print },
- {'i', 0, "SIP debug", ua_print_sip_status },
- {'m', 0, "Module debug", mod_debug },
- {'n', 0, "Network debug", cmd_net_debug },
- {'s', 0, "System info", print_system_info },
- {'t', 0, "Timer debug", tmr_status },
- {'u', 0, "UA debug", cmd_ua_debug },
- {'y', 0, "Memory status", mem_status },
+{"main", 0, 0, "Main loop debug", re_debug },
+{"config", 'g', 0, "Print configuration", cmd_config_print },
+{"sipstat", 'i', 0, "SIP debug", ua_print_sip_status },
+{"modules", 'm', 0, "Module debug", mod_debug },
+{"netstat", 'n', 0, "Network debug", cmd_net_debug },
+{"sysinfo", 's', 0, "System info", print_system_info },
+{"timers", 0, 0, "Timer debug", tmr_status },
+{"uastat", 'u', 0, "UA debug", cmd_ua_debug },
+{"memstat", 'y', 0, "Memory status", mem_status },
};
diff --git a/modules/gtk/gtk_mod.c b/modules/gtk/gtk_mod.c
index 55559d8..7397b9f 100644
--- a/modules/gtk/gtk_mod.c
+++ b/modules/gtk/gtk_mod.c
@@ -974,7 +974,7 @@ static int cmd_popup_menu(struct re_printf *pf, void *unused)
static const struct cmd cmdv[] = {
- {'G', 0, "Pop up GTK+ menu", cmd_popup_menu },
+ {"gtk", 'G', 0, "Pop up GTK+ menu", cmd_popup_menu },
};
diff --git a/modules/menu/menu.c b/modules/menu/menu.c
index 4349f48..619e88c 100644
--- a/modules/menu/menu.c
+++ b/modules/menu/menu.c
@@ -400,31 +400,34 @@ static int cmd_print_calls(struct re_printf *pf, void *unused)
static const struct cmd cmdv[] = {
- {'\n', 0, "Accept incoming call", cmd_answer },
- {'D', 0, "Accept incoming call", cmd_answer },
- {'b', 0, "Hangup call", cmd_hangup },
- {'c', 0, "Call status", ua_print_call_status },
- {'d', CMD_PRM, "Dial", dial_handler },
- {'h', 0, "Help menu", cmd_print },
- {'l', 0, "List active calls", cmd_print_calls },
- {'o', CMD_PRM, "Options", options_command },
- {'r', 0, "Registration info", ua_print_reg_status },
- {0x1b, 0, "Hangup call", cmd_hangup },
- {' ', 0, "Toggle UAs", cmd_ua_next },
- {'T', 0, "Toggle UAs", cmd_ua_next },
- {'R', CMD_PRM, "Create User-Agent", create_ua },
- {'#', CMD_PRM, NULL, dial_handler },
- {'*', CMD_PRM, NULL, dial_handler },
- {'0', CMD_PRM, NULL, dial_handler },
- {'1', CMD_PRM, NULL, dial_handler },
- {'2', CMD_PRM, NULL, dial_handler },
- {'3', CMD_PRM, NULL, dial_handler },
- {'4', CMD_PRM, NULL, dial_handler },
- {'5', CMD_PRM, NULL, dial_handler },
- {'6', CMD_PRM, NULL, dial_handler },
- {'7', CMD_PRM, NULL, dial_handler },
- {'8', CMD_PRM, NULL, dial_handler },
- {'9', CMD_PRM, NULL, dial_handler },
+
+{NULL, '\n', 0, "Accept incoming call", cmd_answer },
+{"accept", 'D', 0, "Accept incoming call", cmd_answer },
+{"hangup", 'b', 0, "Hangup call", cmd_hangup },
+{"callstat", 'c', 0, "Call status", ua_print_call_status },
+{"dial", 'd', CMD_PRM, "Dial", dial_handler },
+{"help", 'h', 0, "Help menu", cmd_print },
+{"listcalls", 'l', 0, "List active calls", cmd_print_calls },
+{"options", 'o', CMD_PRM, "Options", options_command },
+{"reginfo", 'r', 0, "Registration info", ua_print_reg_status },
+{NULL, KEYCODE_ESC,0, "Hangup call", cmd_hangup },
+{NULL, ' ', 0, "Toggle UAs", cmd_ua_next },
+{NULL, 'T', 0, "Toggle UAs", cmd_ua_next },
+{NULL, 'R', CMD_PRM, "Create User-Agent", create_ua },
+
+/* Numeric keypad inputs: */
+{NULL, '#', CMD_PRM, NULL, dial_handler },
+{NULL, '*', CMD_PRM, NULL, dial_handler },
+{NULL, '0', CMD_PRM, NULL, dial_handler },
+{NULL, '1', CMD_PRM, NULL, dial_handler },
+{NULL, '2', CMD_PRM, NULL, dial_handler },
+{NULL, '3', CMD_PRM, NULL, dial_handler },
+{NULL, '4', CMD_PRM, NULL, dial_handler },
+{NULL, '5', CMD_PRM, NULL, dial_handler },
+{NULL, '6', CMD_PRM, NULL, dial_handler },
+{NULL, '7', CMD_PRM, NULL, dial_handler },
+{NULL, '8', CMD_PRM, NULL, dial_handler },
+{NULL, '9', CMD_PRM, NULL, dial_handler },
};
@@ -487,12 +490,21 @@ static int call_xfer(struct re_printf *pf, void *arg)
}
-static int call_holdresume(struct re_printf *pf, void *arg)
+static int cmd_call_hold(struct re_printf *pf, void *arg)
+{
+ (void)pf;
+ (void)arg;
+
+ return call_hold(ua_call(uag_cur()), true);
+}
+
+
+static int cmd_call_resume(struct re_printf *pf, void *arg)
{
- const struct cmd_arg *carg = arg;
(void)pf;
+ (void)arg;
- return call_hold(ua_call(uag_cur()), 'x' == carg->key);
+ return call_hold(ua_call(uag_cur()), false);
}
@@ -663,38 +675,39 @@ static int set_current_call(struct re_printf *pf, void *arg)
static const struct cmd callcmdv[] = {
- {'I', 0, "Send re-INVITE", call_reinvite },
- {'X', 0, "Call resume", call_holdresume },
- {'a', 0, "Audio stream", call_audio_debug },
- {'e', 0, "Cycle audio encoder", call_audioenc_cycle },
- {'m', 0, "Call mute/un-mute", call_mute },
- {'r', CMD_IPRM,"Transfer call", call_xfer },
- {'x', 0, "Call hold", call_holdresume },
- {'H', 0, "Hold previous call", hold_prev_call },
- {'L', 0, "Resume previous call",hold_prev_call },
- {'A', CMD_IPRM,"Switch audio device", switch_audio_dev },
+{"", 'I', 0, "Send re-INVITE", call_reinvite },
+{"resume", 'X', 0, "Call resume", cmd_call_resume },
+{"", 'a', 0, "Audio stream", call_audio_debug },
+{"", 'e', 0, "Cycle audio encoder", call_audioenc_cycle },
+{"mute", 'm', 0, "Call mute/un-mute", call_mute },
+{"transfer", 'r', CMD_IPRM, "Transfer call", call_xfer },
+{"hold", 'x', 0, "Call hold", cmd_call_hold },
+{"", 'H', 0, "Hold previous call", hold_prev_call },
+{"", 'L', 0, "Resume previous call",hold_prev_call },
+{"", 'A', CMD_IPRM, "Switch audio device", switch_audio_dev },
#ifdef USE_VIDEO
- {'E', 0, "Cycle video encoder", call_videoenc_cycle },
- {'v', 0, "Video stream", call_video_debug },
+{"", 'E', 0, "Cycle video encoder", call_videoenc_cycle },
+{"", 'v', 0, "Video stream", call_video_debug },
#endif
- {'#', 0, NULL, digit_handler },
- {'*', 0, NULL, digit_handler },
- {'0', 0, NULL, digit_handler },
- {'1', 0, NULL, digit_handler },
- {'2', 0, NULL, digit_handler },
- {'3', 0, NULL, digit_handler },
- {'4', 0, NULL, digit_handler },
- {'5', 0, NULL, digit_handler },
- {'6', 0, NULL, digit_handler },
- {'7', 0, NULL, digit_handler },
- {'8', 0, NULL, digit_handler },
- {'9', 0, NULL, digit_handler },
- {KEYCODE_REL,0,NULL, digit_handler },
-
- {'S', 0, "Statusmode toggle", toggle_statmode },
- {'@', CMD_PRM, "Set current call <line>", set_current_call },
+/* Numeric keypad for DTMF events: */
+{NULL, '#', 0, NULL, digit_handler },
+{NULL, '*', 0, NULL, digit_handler },
+{NULL, '0', 0, NULL, digit_handler },
+{NULL, '1', 0, NULL, digit_handler },
+{NULL, '2', 0, NULL, digit_handler },
+{NULL, '3', 0, NULL, digit_handler },
+{NULL, '4', 0, NULL, digit_handler },
+{NULL, '5', 0, NULL, digit_handler },
+{NULL, '6', 0, NULL, digit_handler },
+{NULL, '7', 0, NULL, digit_handler },
+{NULL, '8', 0, NULL, digit_handler },
+{NULL, '9', 0, NULL, digit_handler },
+{NULL, KEYCODE_REL, 0, NULL, digit_handler },
+
+{NULL, 'S', 0, "Statusmode toggle", toggle_statmode },
+{NULL, '@', CMD_PRM, "Set current call <line>", set_current_call },
};
diff --git a/modules/natbd/natbd.c b/modules/natbd/natbd.c
index 428a51a..3c45ba4 100644
--- a/modules/natbd/natbd.c
+++ b/modules/natbd/natbd.c
@@ -451,7 +451,7 @@ static int status(struct re_printf *pf, void *unused)
static const struct cmd cmdv[] = {
- {'z', 0, "NAT status", status}
+ {"natbd", 'z', 0, "NAT status", status}
};
diff --git a/modules/presence/presence.c b/modules/presence/presence.c
index f343365..bfde2cd 100644
--- a/modules/presence/presence.c
+++ b/modules/presence/presence.c
@@ -47,8 +47,8 @@ static int cmd_offline(struct re_printf *pf, void *arg)
static const struct cmd cmdv[] = {
- {'[', 0, "Set presence online", cmd_online },
- {']', 0, "Set presence offline", cmd_offline },
+ {"presence_online", '[', 0, "Set presence online", cmd_online },
+ {"presence_offline", ']', 0, "Set presence offline", cmd_offline },
};
diff --git a/modules/vidloop/vidloop.c b/modules/vidloop/vidloop.c
index 59a5ed3..a9f44fa 100644
--- a/modules/vidloop/vidloop.c
+++ b/modules/vidloop/vidloop.c
@@ -469,8 +469,8 @@ static int vidloop_stop(struct re_printf *pf, void *arg)
static const struct cmd cmdv[] = {
- {'v', 0, "Start video-loop", vidloop_start },
- {'V', 0, "Stop video-loop", vidloop_stop },
+ {"vidloop", 'v', 0, "Start video-loop", vidloop_start },
+ {"vidloop_stop", 'V', 0, "Stop video-loop", vidloop_stop },
};
diff --git a/modules/zrtp/zrtp.c b/modules/zrtp/zrtp.c
index eddb364..9688545 100644
--- a/modules/zrtp/zrtp.c
+++ b/modules/zrtp/zrtp.c
@@ -311,7 +311,7 @@ static int verify_sas(struct re_printf *pf, void *arg)
static const struct cmd cmdv[] = {
- {'Z', CMD_PRM, "Verify ZRTP SAS", verify_sas },
+ {"zrtp", 'Z', CMD_PRM, "Verify ZRTP SAS", verify_sas },
};