about summary refs log tree commit diff stats
path: root/src/xmpp/roster.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xmpp/roster.c')
-rw-r--r--src/xmpp/roster.c62
1 files changed, 30 insertions, 32 deletions
diff --git a/src/xmpp/roster.c b/src/xmpp/roster.c
index 71396c4d..2f2bc77f 100644
--- a/src/xmpp/roster.c
+++ b/src/xmpp/roster.c
@@ -290,51 +290,49 @@ _roster_set_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
 }
 
 static int
-_roster_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
-    void * const userdata)
+_roster_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata)
 {
     const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID);
 
+    if (g_strcmp0(id, "roster") != 0) {
+        return 1;
+    }
+
     // handle initial roster response
-    if (g_strcmp0(id, "roster") == 0) {
-        xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
-        xmpp_stanza_t *item = xmpp_stanza_get_children(query);
-
-        while (item) {
-            const char *barejid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID);
-            gchar *barejid_lower = g_utf8_strdown(barejid, -1);
-            const char *name = xmpp_stanza_get_attribute(item, STANZA_ATTR_NAME);
-            const char *sub = xmpp_stanza_get_attribute(item, STANZA_ATTR_SUBSCRIPTION);
-
-            // do not set nickname to empty string, set to NULL instead
-            if (name && (strlen(name) == 0)) {
-                name = NULL;
-            }
+    xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
+    xmpp_stanza_t *item = xmpp_stanza_get_children(query);
 
-            gboolean pending_out = FALSE;
-            const char *ask = xmpp_stanza_get_attribute(item, STANZA_ATTR_ASK);
-            if (g_strcmp0(ask, "subscribe") == 0) {
-                pending_out = TRUE;
-            }
+    while (item) {
+        const char *barejid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID);
+        gchar *barejid_lower = g_utf8_strdown(barejid, -1);
+        const char *name = xmpp_stanza_get_attribute(item, STANZA_ATTR_NAME);
+        const char *sub = xmpp_stanza_get_attribute(item, STANZA_ATTR_SUBSCRIPTION);
 
-            GSList *groups = _get_groups_from_item(item);
+        // do not set nickname to empty string, set to NULL instead
+        if (name && (strlen(name) == 0)) name = NULL;
 
-            gboolean added = roster_add(barejid_lower, name, groups, sub, pending_out);
+        gboolean pending_out = FALSE;
+        const char *ask = xmpp_stanza_get_attribute(item, STANZA_ATTR_ASK);
+        if (g_strcmp0(ask, "subscribe") == 0) {
+            pending_out = TRUE;
+        }
 
-            if (!added) {
-                log_warning("Attempt to add contact twice: %s", barejid_lower);
-            }
+        GSList *groups = _get_groups_from_item(item);
 
-            g_free(barejid_lower);
-            item = xmpp_stanza_get_next(item);
+        gboolean added = roster_add(barejid_lower, name, groups, sub, pending_out);
+        if (!added) {
+            log_warning("Attempt to add contact twice: %s", barejid_lower);
         }
 
-        sv_ev_roster_received();
-
-        resource_presence_t conn_presence = accounts_get_login_presence(jabber_get_account_name());
-        presence_update(conn_presence, NULL, 0);
+        g_free(barejid_lower);
+        item = xmpp_stanza_get_next(item);
     }
 
+    sv_ev_roster_received();
+
+    resource_presence_t conn_presence = accounts_get_login_presence(jabber_get_account_name());
+    presence_update(conn_presence, NULL, 0);
+
     return 1;
 }
 
4e77712e5381d9db8781f5ae6'>9a81d746 ^
a6d9bd9b ^
af7349d5 ^
a6d9bd9b ^
e3894819 ^
b38d7fff ^
9a81d746 ^
a6d9bd9b ^


9a81d746 ^
3e1349d2 ^
3e1349d2 ^
f918675c ^
650a201d ^
af7349d5 ^
3e1349d2 ^
af7349d5 ^
3e1349d2 ^


dd660682 ^
01ce563d ^
fbf0536d ^
b38d7fff ^
e82dc626 ^
f918675c ^


b085378e ^
e82dc626 ^
38f0b91a ^
f0c55e6b ^
e82dc626 ^
f0c55e6b ^


e82dc626 ^



f0c55e6b ^





e82dc626 ^



f0c55e6b ^

816ffe20 ^
f0c55e6b ^

b085378e ^

f0c55e6b ^


b38d7fff ^

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