about summary refs log tree commit diff stats
path: root/src/xmpp/iq.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2018-01-27 23:51:03 +0000
committerJames Booth <boothj5@gmail.com>2018-01-27 23:51:03 +0000
commite571ccd8ea5a60b25a4b8c52d0ae62bec95e027c (patch)
tree4200b690bd5c4142067feea17bf57401bf4c3447 /src/xmpp/iq.c
parent2e414797a472a4f55206453fb7d5e139f7a30f3b (diff)
downloadprofani-tty-e571ccd8ea5a60b25a4b8c52d0ae62bec95e027c.tar.gz
Fix tests, move glob creation
Diffstat (limited to 'src/xmpp/iq.c')
-rw-r--r--src/xmpp/iq.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index ce163858..0a48dbb7 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -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);
@@ -913,14 +913,17 @@ _room_list_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
 
     xmpp_stanza_t *child = xmpp_stanza_get_children(query);
     if (child == NULL) {
+        cons_show("No rooms found for service: %s", from);
         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;
 }