about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-08-05 23:08:30 +0100
committerJames Booth <boothj5@gmail.com>2013-08-05 23:08:30 +0100
commitc6e9a7455d1aa34c0b8386c8e6bc8f855cb29a2a (patch)
tree577eb73432ac6430cd3acaaef592b24f61bba2b1 /src
parent1525be613303e0682a6fb78c5457d53207b05936 (diff)
downloadprofani-tty-c6e9a7455d1aa34c0b8386c8e6bc8f855cb29a2a.tar.gz
Undo change to stanza check for nick change return value
Diffstat (limited to 'src')
-rw-r--r--src/xmpp/presence.c4
-rw-r--r--src/xmpp/stanza.c34
-rw-r--r--src/xmpp/stanza.h2
3 files changed, 12 insertions, 28 deletions
diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c
index 63462a56..c05ba198 100644
--- a/src/xmpp/presence.c
+++ b/src/xmpp/presence.c
@@ -567,7 +567,7 @@ _room_presence_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
     // handle self presence
     if (stanza_is_muc_self_presence(stanza, jabber_get_fulljid())) {
         char *type = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_TYPE);
-        char *new_nick = stanza_is_room_nick_change(stanza);
+        char *new_nick = stanza_get_new_nick(stanza);
 
         if ((type != NULL) && (strcmp(type, STANZA_TYPE_UNAVAILABLE) == 0)) {
 
@@ -606,7 +606,7 @@ _room_presence_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
         if ((type != NULL) && (strcmp(type, STANZA_TYPE_UNAVAILABLE) == 0)) {
 
             // handle nickname change
-            if (stanza_is_room_nick_change(stanza) != NULL) {
+            if (stanza_is_room_nick_change(stanza)) {
                 char *new_nick = stanza_get_new_nick(stanza);
                 muc_set_roster_pending_nick_change(room, new_nick, nick);
             } else {
diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c
index f4259d6f..4d232b7b 100644
--- a/src/xmpp/stanza.c
+++ b/src/xmpp/stanza.c
@@ -543,62 +543,46 @@ stanza_is_muc_self_presence(xmpp_stanza_t * const stanza,
     return FALSE;
 }
 
-char *
+gboolean
 stanza_is_room_nick_change(xmpp_stanza_t * const stanza)
 {
     if (stanza == NULL) {
-        return NULL;
+        return FALSE;
     }
     if (strcmp(xmpp_stanza_get_name(stanza), STANZA_NAME_PRESENCE) != 0) {
-        return NULL;
+        return FALSE;
     }
 
     xmpp_stanza_t *x = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_X);
 
     if (x == NULL) {
-        return NULL;
+        return FALSE;
     }
 
     char *ns = xmpp_stanza_get_ns(x);
     if (ns == NULL) {
-        return NULL;
+        return FALSE;
     }
     if (strcmp(ns, STANZA_NS_MUC_USER) != 0) {
-        return NULL;
+        return FALSE;
     }
 
     xmpp_stanza_t *x_children = xmpp_stanza_get_children(x);
     if (x_children == NULL) {
-        return NULL;
+        return FALSE;
     }
 
-    gboolean is_nick_change = FALSE;
     while (x_children != NULL) {
         if (strcmp(xmpp_stanza_get_name(x_children), STANZA_NAME_STATUS) == 0) {
             char *code = xmpp_stanza_get_attribute(x_children, STANZA_ATTR_CODE);
             if (strcmp(code, "303") == 0) {
-                is_nick_change = TRUE;
-                break;
+                return TRUE;
             }
         }
         x_children = xmpp_stanza_get_next(x_children);
     }
 
-    if (is_nick_change) {
-        xmpp_stanza_t *x_children = xmpp_stanza_get_children(x);
-        while (x_children != NULL) {
-            if (strcmp(xmpp_stanza_get_name(x_children), STANZA_NAME_ITEM) == 0) {
-                char *new_nick = xmpp_stanza_get_attribute(x_children, STANZA_ATTR_NICK);
-                if (new_nick != NULL) {
-                    return new_nick;
-                }
-            }
-
-            x_children = xmpp_stanza_get_next(x_children);
-        }
-    }
-
-    return NULL;
+    return FALSE;
 }
 
 char *
diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h
index 50b14c75..ad777f24 100644
--- a/src/xmpp/stanza.h
+++ b/src/xmpp/stanza.h
@@ -146,7 +146,7 @@ gboolean stanza_get_delay(xmpp_stanza_t * const stanza, GTimeVal *tv_stamp);
 gboolean stanza_is_muc_presence(xmpp_stanza_t * const stanza);
 gboolean stanza_is_muc_self_presence(xmpp_stanza_t * const stanza,
     const char * const self_jid);
-char * stanza_is_room_nick_change(xmpp_stanza_t * const stanza);
+gboolean stanza_is_room_nick_change(xmpp_stanza_t * const stanza);
 
 char * stanza_get_new_nick(xmpp_stanza_t * const stanza);
 
ass='oid'>a2726b6a ^
a7a28506 ^
a2c62117 ^


0e2fbeb3 ^
8ebc1d4a ^
0e2fbeb3 ^
055a5f71 ^
a48df401 ^
a7a28506 ^

a2726b6a ^

a7a28506 ^
a7a28506 ^
a48df401 ^
055a5f71 ^
6d39f49f ^
a2726b6a ^
a2c62117 ^
a2726b6a ^
0e2fbeb3 ^
a2c62117 ^


0e2fbeb3 ^
8ebc1d4a ^
a7a28506 ^
055a5f71 ^
a48df401 ^
a7a28506 ^

a2726b6a ^

a7a28506 ^
a7a28506 ^
a48df401 ^
055a5f71 ^
6d39f49f ^
a2726b6a ^
a2c62117 ^
a2726b6a ^
a7a28506 ^
a2c62117 ^


0e2fbeb3 ^
8ebc1d4a ^
0e2fbeb3 ^
055a5f71 ^
a48df401 ^
a7a28506 ^
5afb296e ^
a2726b6a ^

95ad5643 ^
a48df401 ^
055a5f71 ^
6d39f49f ^
95ad5643 ^
a2726b6a ^

95ad5643 ^
a2726b6a ^
95ad5643 ^
51bd4ed3 ^
a2726b6a ^
055a5f71 ^

8aba52f4 ^
a2726b6a ^
95ad5643 ^
9bd2315d ^
95ad5643 ^
055a5f71 ^
95ad5643 ^
a48df401 ^
95ad5643 ^
f180925c ^
a2726b6a ^

f180925c ^
055a5f71 ^
6d39f49f ^
f180925c ^
51bd4ed3 ^

f180925c ^

8aba52f4 ^
f180925c ^
a2726b6a ^

f180925c ^


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

                   

                   

                   
                 
 
                                

                             
                              


                               
                     

                            
 

                                                           
 
                                                      
                   
                    
                                      
                                   
                                                    
                                                                             
 


                                                                           
 
                                                        
 
                     
                       

 

                                                        
 
                                                   
                   
                    
                                      
                                   
                                                    
                                                                             
 


                                                                           
 
                                                        
 
                     
                       

 

                                                     
 
                                                   
                   
                    
                                      
                                   
                                                    
                                                                             
 


                                                                           
 
                                                        
 
                     
                       
 
 

                                                 
 
                   
                    
                                      
                         

                                             
                                                    
                                                                            
                                                     
                                                            
                                                             

                                                      
                                                   
                                                     
 
                         
 
                     
                          
                       
 
 

                                                  
 
                    
                                      
                         

                                                                       

                                 
                            
 

                                                                 


                          
 tests' href='/danisanti/profani-tty/commit/tests/test_cmd_bookmark.c?id=af51fa3c680b8299b243821a97e4c38af036ae6b'>af51fa3c ^
3bb1f124 ^
3487100c ^





af51fa3c ^
d2662a6f ^
af51fa3c ^
81190251 ^
af51fa3c ^
af51fa3c ^
a8ecbccc ^


a8ecbccc ^
a8ecbccc ^
2215a379 ^

a8ecbccc ^
3bb1f124 ^
3487100c ^


a8ecbccc ^
a8ecbccc ^

81190251 ^
a8ecbccc ^
a8ecbccc ^

9d957e5f ^

9d957e5f ^
9d957e5f ^
2215a379 ^

9d957e5f ^
3bb1f124 ^
3487100c ^


9d957e5f ^
95c48a0f ^

81190251 ^
95c48a0f ^
a564b024 ^
7c5ece24 ^

















e3f2ca7d ^
7c5ece24 ^






















e3f2ca7d ^
7c5ece24 ^



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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397