diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/command/cmd_defs.c | 12 | ||||
-rw-r--r-- | src/command/cmd_funcs.c | 6 | ||||
-rw-r--r-- | src/xmpp/iq.c | 43 |
3 files changed, 47 insertions, 14 deletions
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 6d4a6ab9..1bad76cf 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -795,21 +795,21 @@ static struct cmd_t command_defs[] = CMD_TAG_GROUPCHAT) CMD_SYN( "/rooms", - "/rooms filter <glob>", + "/rooms filter <text>", "/rooms service <service>", - "/rooms service <service> filter <glob>") + "/rooms service <service> filter <text>") 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 filter argument accepts a glob (including * and ?) and filters the results.") + "The filter argument only shows rooms that contain the provided text, case insensitive.") CMD_ARGS( { "service <service>", "The conference service to query." }, - { "filter <glob>", "The glob to filter results by."}) + { "filter <text>", "The text to filter results by."}) CMD_EXAMPLES( "/rooms", - "/rooms filter *development*", + "/rooms filter development", "/rooms service conference.jabber.org", - "/rooms service conference.jabber.org filter *xsf*") + "/rooms service conference.jabber.org filter \"News Room\"") }, { "/bookmark", diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 65ac7344..bde86835 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -4458,6 +4458,12 @@ cmd_rooms(ProfWin *window, const char *const command, gchar **args) } } + cons_show(""); + if (filter) { + cons_show("Room list request sent: %s, filter: '%s'", service, filter); + } else { + cons_show("Room list request sent: %s", service); + } iq_room_list_request(service, filter); g_free(service); diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index a4be75b3..25fd98b8 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -901,6 +901,7 @@ _caps_response_legacy_id_handler(xmpp_stanza_t *const stanza, void *const userda static int _room_list_id_handler(xmpp_stanza_t *const stanza, void *const userdata) { + gchar *filter = (gchar*)userdata; const char *id = xmpp_stanza_get_id(stanza); const char *from = xmpp_stanza_get_from(stanza); @@ -908,31 +909,55 @@ _room_list_id_handler(xmpp_stanza_t *const stanza, void *const userdata) xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); if (query == NULL) { + g_free(filter); return 0; } + cons_show(""); + if (filter) { + cons_show("Rooms list response received: %s, filter: %s", from, filter); + } else { + cons_show("Rooms list response received: %s", from); + } xmpp_stanza_t *child = xmpp_stanza_get_children(query); if (child == NULL) { - cons_show("No rooms found for service: %s", from); + cons_show(" No rooms found."); + g_free(filter); return 0; } GPatternSpec *glob = NULL; - gchar *filter = (gchar*)userdata; if (filter != NULL) { - glob = g_pattern_spec_new(filter); + gchar *filter_lower = g_utf8_strdown(filter, -1); + GString *glob_str = g_string_new("*"); + g_string_append(glob_str, filter_lower); + g_free(filter_lower); + g_string_append(glob_str, "*"); + glob = g_pattern_spec_new(glob_str->str); + g_string_free(glob_str, TRUE); } gboolean matched = FALSE; - cons_show("Chat rooms at: %s", from); while (child) { const char *stanza_name = xmpp_stanza_get_name(child); if (stanza_name && (g_strcmp0(stanza_name, STANZA_NAME_ITEM) == 0)) { const char *item_jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID); + gchar *item_jid_lower = NULL; + if (item_jid) { + Jid *jidp = jid_create(item_jid); + if (jidp && jidp->localpart) { + item_jid_lower = g_utf8_strdown(jidp->localpart, -1); + } + jid_destroy(jidp); + } const char *item_name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME); - if ((item_jid) && ((glob == NULL) || - ((g_pattern_match(glob, strlen(item_jid), item_jid, NULL)) || - (item_name && g_pattern_match(glob, strlen(item_name), item_name, NULL))))) { + gchar *item_name_lower = NULL; + if (item_name) { + item_name_lower = g_utf8_strdown(item_name, -1); + } + if ((item_jid_lower) && ((glob == NULL) || + ((g_pattern_match(glob, strlen(item_jid_lower), item_jid_lower, NULL)) || + (item_name_lower && g_pattern_match(glob, strlen(item_name_lower), item_name_lower, NULL))))) { if (glob) { matched = TRUE; @@ -946,12 +971,14 @@ _room_list_id_handler(xmpp_stanza_t *const stanza, void *const userdata) cons_show(" %s", item->str); g_string_free(item, TRUE); } + g_free(item_jid_lower); + g_free(item_name_lower); } child = xmpp_stanza_get_next(child); } if (glob && matched == FALSE) { - cons_show(" No rooms found matching pattern: %s", filter); + cons_show(" No rooms found matching filter: %s", filter); } g_pattern_spec_free(glob); |