mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-20 00:26:21 +00:00
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);
|
||||
|
||||
|
||||
@@ -297,13 +297,13 @@ iq_set_autoping(const int seconds)
|
||||
}
|
||||
|
||||
void
|
||||
iq_room_list_request(gchar *conferencejid, GPatternSpec *glob)
|
||||
iq_room_list_request(gchar *conferencejid, gchar *filter)
|
||||
{
|
||||
xmpp_ctx_t * const ctx = connection_get_ctx();
|
||||
char *id = create_unique_id("confreq");
|
||||
xmpp_stanza_t *iq = stanza_create_disco_items_iq(ctx, id, conferencejid);
|
||||
|
||||
iq_id_handler_add(id, _room_list_id_handler, (ProfIdFreeCallback)g_pattern_spec_free, glob);
|
||||
iq_id_handler_add(id, _room_list_id_handler, NULL, filter);
|
||||
|
||||
iq_send_stanza(iq);
|
||||
xmpp_stanza_release(iq);
|
||||
@@ -912,15 +912,18 @@ _room_list_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
|
||||
}
|
||||
|
||||
xmpp_stanza_t *child = xmpp_stanza_get_children(query);
|
||||
if (child == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
GPatternSpec *glob = (GPatternSpec*)userdata;
|
||||
if (child == NULL) {
|
||||
cons_show("No rooms found for service: %s", from);
|
||||
return 0;
|
||||
}
|
||||
|
||||
GPatternSpec *glob = NULL;
|
||||
gchar *filter = (gchar*)userdata;
|
||||
if (filter != NULL) {
|
||||
glob = g_pattern_spec_new(filter);
|
||||
g_free(filter);
|
||||
}
|
||||
|
||||
gboolean matched = FALSE;
|
||||
cons_show("Chat rooms at: %s", from);
|
||||
while (child) {
|
||||
@@ -952,6 +955,8 @@ _room_list_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
|
||||
cons_show(" No rooms found matching pattern.");
|
||||
}
|
||||
|
||||
g_pattern_spec_free(glob);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ gboolean presence_sub_request_exists(const char *const bare_jid);
|
||||
void iq_enable_carbons(void);
|
||||
void iq_disable_carbons(void);
|
||||
void iq_send_software_version(const char *const fulljid);
|
||||
void iq_room_list_request(gchar *conferencejid, GPatternSpec *glob);
|
||||
void iq_room_list_request(gchar *conferencejid, gchar *filter);
|
||||
void iq_disco_info_request(gchar *jid);
|
||||
void iq_disco_items_request(gchar *jid);
|
||||
void iq_last_activity_request(gchar *jid);
|
||||
|
||||
Reference in New Issue
Block a user