Skip to content
Permalink
Browse files

Core(impl): impl /server list

  • Loading branch information...
SilverRainZ committed Oct 7, 2019
1 parent 72b13a0 commit 656f3e5f76142a5c8f5af0a796b37d28d47d10be
Showing with 27 additions and 1 deletion.
  1. +25 −0 src/core/chat_command.c
  2. +2 −1 src/core/chat_command.h
@@ -191,6 +191,31 @@ SrnRet on_command_server(SrnCommand *cmd, void *user_data){
return ret;
}

if (g_ascii_strcasecmp(subcmd, "list") == 0){
GList *lst;
GList *srv_cfg_lst;
GString *str;

// Get a list of server name
ret = srn_config_manager_read_server_config_list(
app->cfg_mgr, &srv_cfg_lst);
if (!RET_IS_OK(ret)){
return ret;
}

str = g_string_new(NULL);
for (lst = srv_cfg_lst; lst; lst = g_list_next(lst)) {
g_string_append_c(str, ' ');
g_string_append(str, lst->data);
}
ret = RET_OK(_("%1$d available server(s):%2$s"),
g_list_length(srv_cfg_lst), str->str);
g_string_free(str, TRUE);
g_list_free_full(srv_cfg_lst, g_free);

return ret;
}

return RET_ERR(_("Unknown sub command: %1$s"), subcmd);
}

@@ -56,8 +56,9 @@ static SrnCommandBinding cmd_bindings[] = {
},
{
.name = "/server",
.subcmd = {"connect", "disconnect", NULL},
.subcmd = {"connect", "disconnect", "list", NULL},
.argc = 1, // <name>
.flags = SRN_COMMAND_FLAG_OMIT_ARG,
.cb = on_command_server,
},
{

0 comments on commit 656f3e5

Please sign in to comment.
You can’t perform that action at this time.