about summary refs log tree commit diff stats
path: root/src/xmpp/iq.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xmpp/iq.c')
-rw-r--r--src/xmpp/iq.c69
1 files changed, 34 insertions, 35 deletions
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index f17cdcb7..297d1bd2 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -2015,32 +2015,42 @@ _disco_items_result_handler(xmpp_stanza_t *const stanza)
     const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
     GSList *items = NULL;
 
-    if ((g_strcmp0(id, "confreq") == 0) || (g_strcmp0(id, "discoitemsreq") == 0) || (g_strcmp0(id, "discoitemsreq_onconnect") == 0)) {
-        log_debug("Response to query: %s", id);
-        xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
-
-        if (query) {
-            xmpp_stanza_t *child = xmpp_stanza_get_children(query);
-            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);
-                    if (item_jid) {
-                        DiscoItem *item = malloc(sizeof(struct disco_item_t));
-                        item->jid = strdup(item_jid);
-                        const char *item_name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME);
-                        if (item_name) {
-                            item->name = strdup(item_name);
-                        } else {
-                            item->name = NULL;
-                        }
-                        items = g_slist_append(items, item);
-                    }
-                }
+    if ((g_strcmp0(id, "confreq") != 0) &&
+            (g_strcmp0(id, "discoitemsreq") != 0) &&
+            (g_strcmp0(id, "discoitemsreq_onconnect") != 0)) {
+        return;
+    }
+
+    log_debug("Response to query: %s", id);
 
-                child = xmpp_stanza_get_next(child);
+    xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
+    if (query == NULL) {
+        return;
+    }
+
+    xmpp_stanza_t *child = xmpp_stanza_get_children(query);
+    if (child == NULL) {
+        return;
+    }
+
+    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);
+            if (item_jid) {
+                DiscoItem *item = malloc(sizeof(struct disco_item_t));
+                item->jid = strdup(item_jid);
+                const char *item_name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME);
+                if (item_name) {
+                    item->name = strdup(item_name);
+                } else {
+                    item->name = NULL;
+                }
+                items = g_slist_append(items, item);
             }
         }
+
+        child = xmpp_stanza_get_next(child);
     }
 
     if (g_strcmp0(id, "confreq") == 0) {
@@ -2048,18 +2058,7 @@ _disco_items_result_handler(xmpp_stanza_t *const stanza)
     } else if (g_strcmp0(id, "discoitemsreq") == 0) {
         cons_show_disco_items(items, from);
     } else if (g_strcmp0(id, "discoitemsreq_onconnect") == 0) {
-        GSList *res_items = items;
-        if (res_items && (g_slist_length(res_items) > 0)) {
-            while (res_items) {
-                DiscoItem *item = res_items->data;
-                DiscoInfo *info = malloc(sizeof(struct disco_info_t));
-                info->item = strdup(item->jid);
-                info->features = g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL);
-                connection_set_disco_items(g_slist_append(connection_get_disco_items(), info));
-                iq_disco_info_request_onconnect(info->item);
-                res_items = g_slist_next(res_items);
-            }
-        }
+        connection_set_disco_items(items);
     }
 
     g_slist_free_full(items, (GDestroyNotify)_item_destroy);
62e6b8b2dbd77328c8f99a2'>^
4c13e1f2 ^











f07bb12f ^
4c13e1f2 ^
f07bb12f ^













1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138










                                                                                                                                                                                                                                                                                                                          


                                                                                                                                          







                                                                                                  










                                                                                                                                                                                                  









                                                                                                                                                                                             
                                                                                                                   





















                                                                                                                                                        
                                                                                                                                                                




                                                                                                                                                                                                               

                                                                               


                                                                                                                                                                                                                        

                                                                                                                                                                                                    
 
                                                                                                                                                   












                                                                                                                                                                                                              















                                                                                                                              











                                                                                                                                                                                                                                         
                                                                                                                                          
                                                                                                          













                                                                                                                        
='#n580'>580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674