Index: channel.c =================================================================== --- channel.c (revision 8070) +++ channel.c (working copy) @@ -111,6 +111,8 @@ /*! the list of channels we have */ static struct ast_channel *channels = NULL; +static char *complete_dr_3(char *line, char *word, int pos, int state); + /*! Protect the channel list, both backends and channels. */ AST_MUTEX_DEFINE_STATIC(chlock); @@ -193,13 +195,72 @@ } +static int show_channeltype(int fd, int argc, char *argv[]) +{ + struct chanlist *cl = NULL; + + if (argc != 3) + return RESULT_SHOWUSAGE; + + if (ast_mutex_lock(&chlock)) { + ast_log(LOG_WARNING, "Unable to lock channel list\n"); + return RESULT_FAILURE; + } + + AST_LIST_TRAVERSE(&backends, cl, list) { + if (!strncasecmp(cl->tech->type, argv[2], strlen(cl->tech->type))) { + break; + } + } + + + if (!cl) { + ast_cli(fd, "\n%s is not a registered channel driver.\n", argv[2]); + ast_mutex_unlock(&chlock); + return RESULT_FAILURE; + } + + ast_cli(fd, + "-- Info about channel driver: %s --\n" + " Device State: %s\n" + " Indication: %s\n" + " Transfer : %s\n" + " Capabilities: %d\n" + " Send Digit: %s\n" + " Send HTML : %s\n" + " Image Support: %s\n" + " Text Support: %s\n", + cl->tech->type, + (cl->tech->devicestate) ? "yes" : "no", + (cl->tech->indicate) ? "yes" : "no", + (cl->tech->transfer) ? "yes" : "no", + (cl->tech->capabilities) ? cl->tech->capabilities : -1, + (cl->tech->send_digit) ? "yes" : "no", + (cl->tech->send_html) ? "yes" : "no", + (cl->tech->send_image) ? "yes" : "no", + (cl->tech->send_text) ? "yes" : "no" + + ); + + ast_mutex_unlock(&chlock); + return RESULT_SUCCESS; +} + + static char show_channeltypes_usage[] = "Usage: show channeltypes\n" " Shows available channel types registered in your Asterisk server.\n"; +static char show_channeltype_usage[] = +"Usage: show channeltype \n" +" Show all the details on that specified channel type .\n"; + static struct ast_cli_entry cli_show_channeltypes = { { "show", "channeltypes", NULL }, show_channeltypes, "Show available channel types", show_channeltypes_usage }; +static struct ast_cli_entry cli_show_channeltype = + { { "show", "channeltype", NULL }, show_channeltype, "Give more details on that channel type", show_channeltype_usage,complete_dr_3 }; + /*! \brief Checks to see if a channel is needing hang up */ int ast_check_hangup(struct ast_channel *chan) { @@ -3782,6 +3843,7 @@ void ast_channels_init(void) { ast_cli_register(&cli_show_channeltypes); + ast_cli_register(&cli_show_channeltype); } /*! \brief Print call group and pickup group ---*/ @@ -4047,3 +4109,32 @@ free(state); } + + +static char *complete_dr_helper(char *line, char *word, int pos, int state, int rpos) +{ + struct chanlist *cl; + int which = 0; + int wordlen; + char *ret = NULL; + + if (pos != rpos) + return NULL; + + wordlen = strlen(word); + + AST_LIST_TRAVERSE(&backends, cl, list) { + if (!strncasecmp(word, cl->tech->type, wordlen) && ++which > state) { + ret = strdup(cl->tech->type); + break; + } + } + + return ret; +} + +static char *complete_dr_3(char *line, char *word, int pos, int state) +{ + return complete_dr_helper(line, word, pos, state, 2); +} +