Fix tests, move glob creation
This commit is contained in:
@@ -595,7 +595,7 @@ cmd_ac_init(void)
|
||||
|
||||
rooms_ac = autocomplete_new();
|
||||
autocomplete_add(rooms_ac, "service");
|
||||
autocomplete_add(rooms_ac, "match");
|
||||
autocomplete_add(rooms_ac, "filter");
|
||||
|
||||
affiliation_ac = autocomplete_new();
|
||||
autocomplete_add(affiliation_ac, "owner");
|
||||
|
||||
@@ -795,20 +795,21 @@ static struct cmd_t command_defs[] =
|
||||
CMD_TAG_GROUPCHAT)
|
||||
CMD_SYN(
|
||||
"/rooms",
|
||||
"/rooms match <glob>",
|
||||
"/rooms filter <glob>",
|
||||
"/rooms service <service>",
|
||||
"/rooms service <service> match <glob>")
|
||||
"/rooms service <service> filter <glob>")
|
||||
CMD_DESC(
|
||||
"List the chat rooms available at the specified conference service. "
|
||||
"If no argument is supplied, the account preference 'muc.service' is used, 'conference.<domain-part>' by default. "
|
||||
"The match argument accepts a glob and returns only room names that match.")
|
||||
"The filter argument accepts a glob (including * and ?) and filters the results.")
|
||||
CMD_ARGS(
|
||||
{ "service <service>", "The conference service to query." },
|
||||
{ "match <glob>", "The string to match before displaying results."})
|
||||
{ "filter <glob>", "The glob to filter results by."})
|
||||
CMD_EXAMPLES(
|
||||
"/rooms",
|
||||
"/rooms match *development*",
|
||||
"/rooms service conference.jabber.org")
|
||||
"/rooms filter *development*",
|
||||
"/rooms service conference.jabber.org",
|
||||
"/rooms service conference.jabber.org filter *xsf*")
|
||||
},
|
||||
|
||||
{ "/bookmark",
|
||||
|
||||
@@ -4393,8 +4393,8 @@ cmd_rooms(ProfWin *window, const char *const command, gchar **args)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
char *service = NULL;
|
||||
char *match = NULL;
|
||||
gchar *service = NULL;
|
||||
gchar *filter = NULL;
|
||||
if (args[0] != NULL) {
|
||||
if (g_strcmp0(args[0], "service") == 0) {
|
||||
if (args[1] == NULL) {
|
||||
@@ -4403,13 +4403,13 @@ cmd_rooms(ProfWin *window, const char *const command, gchar **args)
|
||||
return TRUE;
|
||||
}
|
||||
service = g_strdup(args[1]);
|
||||
} else if (g_strcmp0(args[0], "match") == 0) {
|
||||
} else if (g_strcmp0(args[0], "filter") == 0) {
|
||||
if (args[1] == NULL) {
|
||||
cons_bad_cmd_usage(command);
|
||||
cons_show("");
|
||||
return TRUE;
|
||||
}
|
||||
match = g_strdup(args[1]);
|
||||
filter = g_strdup(args[1]);
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
cons_show("");
|
||||
@@ -4422,21 +4422,21 @@ cmd_rooms(ProfWin *window, const char *const command, gchar **args)
|
||||
cons_bad_cmd_usage(command);
|
||||
cons_show("");
|
||||
g_free(service);
|
||||
g_free(match);
|
||||
g_free(filter);
|
||||
return TRUE;
|
||||
}
|
||||
g_free(service);
|
||||
service = g_strdup(args[3]);
|
||||
} else if (g_strcmp0(args[2], "match") == 0) {
|
||||
} else if (g_strcmp0(args[2], "filter") == 0) {
|
||||
if (args[3] == NULL) {
|
||||
cons_bad_cmd_usage(command);
|
||||
cons_show("");
|
||||
g_free(service);
|
||||
g_free(match);
|
||||
g_free(filter);
|
||||
return TRUE;
|
||||
}
|
||||
g_free(match);
|
||||
match = g_strdup(args[3]);
|
||||
g_free(filter);
|
||||
filter = g_strdup(args[3]);
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
cons_show("");
|
||||
@@ -4444,12 +4444,6 @@ cmd_rooms(ProfWin *window, const char *const command, gchar **args)
|
||||
}
|
||||
}
|
||||
|
||||
GPatternSpec *glob = NULL;
|
||||
if (match != NULL) {
|
||||
glob = g_pattern_spec_new(match);
|
||||
g_free(match);
|
||||
}
|
||||
|
||||
if (service == NULL) {
|
||||
ProfAccount *account = accounts_get_account(session_get_account_name());
|
||||
if (account->muc_service) {
|
||||
@@ -4459,12 +4453,12 @@ cmd_rooms(ProfWin *window, const char *const command, gchar **args)
|
||||
cons_show("Account MUC service property not found.");
|
||||
account_free(account);
|
||||
g_free(service);
|
||||
g_free(match);
|
||||
g_free(filter);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
iq_room_list_request(service, glob);
|
||||
iq_room_list_request(service, filter);
|
||||
|
||||
g_free(service);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user