]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
mod_gsmopen: add tab completion for api commands
authorDušan Dragić <dragic.dusan@gmail.com>
Sun, 28 Sep 2014 13:02:31 +0000 (15:02 +0200)
committerDušan Dragić <dragic.dusan@gmail.com>
Mon, 29 Sep 2014 11:25:30 +0000 (13:25 +0200)
src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp

index 82b2eb39c6e96d8376393da58c41e124b7efdb7a..7ad50e65e92e3be46d47abdb9272af4f39832d44 100644 (file)
@@ -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