From a94fbe807905be714c774f7479936387b31602b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Dragi=C4=87?= Date: Sun, 28 Sep 2014 15:02:31 +0200 Subject: [PATCH] mod_gsmopen: add tab completion for api commands --- src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp b/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp index 82b2eb39c6..7ad50e65e9 100644 --- a/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp +++ b/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp @@ -243,6 +243,26 @@ switch_status_t gsmopen_tech_init(private_t *tech_pvt, switch_core_session_t *se return SWITCH_STATUS_SUCCESS; } +static switch_status_t list_interfaces(const char *line, const char *cursor, switch_console_callback_match_t **matches) +{ + int interface_id; + switch_console_callback_match_t *my_matches = NULL; + switch_status_t status = SWITCH_STATUS_FALSE; + + for (interface_id = 0; interface_id < GSMOPEN_MAX_INTERFACES; interface_id++) { + if (globals.GSMOPEN_INTERFACES[interface_id].running) { + switch_console_push_match(&my_matches, (const char *) globals.GSMOPEN_INTERFACES[interface_id].name); + } + } + + if (my_matches) { + *matches = my_matches; + status = SWITCH_STATUS_SUCCESS; + } + + return status; +} + static switch_status_t interface_exists(char *the_interface) { int i; @@ -1883,6 +1903,20 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_gsmopen_load) SENDSMS_SYNTAX); SWITCH_ADD_CHAT(chat_interface, GSMOPEN_CHAT_PROTO, chat_send); + switch_console_set_complete("add gsm list"); + switch_console_set_complete("add gsm list full"); + switch_console_set_complete("add gsm console ::gsm::list_interfaces"); + switch_console_set_complete("add gsm remove ::gsm::list_interfaces"); + switch_console_set_complete("add gsm reload"); + switch_console_set_complete("add gsmopen ::gsm::list_interfaces"); + switch_console_set_complete("add gsmopen_dump list"); + switch_console_set_complete("add gsmopen_dump ::gsm::list_interfaces"); + switch_console_set_complete("add gsmopen_ussd ::gsm::list_interfaces"); + switch_console_set_complete("add gsmopen_sendsms ::gsm::list_interfaces"); + switch_console_set_complete("add gsmopen_boost_audio ::gsm::list_interfaces"); + + switch_console_add_complete_func("::gsm::list_interfaces", list_interfaces); + /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; } else