about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/command/command.c61
-rw-r--r--src/contact.c6
-rw-r--r--src/contact.h1
-rw-r--r--src/profanity.c6
-rw-r--r--src/profanity.h3
-rw-r--r--src/ui/ui.h5
-rw-r--r--src/ui/windows.c97
-rw-r--r--src/xmpp/iq.c16
8 files changed, 130 insertions, 65 deletions
diff --git a/src/command/command.c b/src/command/command.c
index d88414e1..a2b280e3 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -277,7 +277,6 @@ static struct cmd_t main_commands[] =
           "----------------",
           "Find out a contact, or room members client capabilities.",
           "If in a chat window the parameter is not required, the current recipient will be used.",
-          "The command output is similar to the /info command, but shows the capabilities of each available resource.",
           NULL } } },
 
     { "/software",
@@ -995,7 +994,7 @@ _cmd_complete_parameters(char *input, int *size)
         _parameter_autocomplete(input, size, "/info",
             contact_list_find_contact);
         _parameter_autocomplete(input, size, "/caps",
-            contact_list_find_contact);
+            contact_list_find_resource);
         _parameter_autocomplete(input, size, "/status",
             contact_list_find_contact);
         _parameter_autocomplete(input, size, "/software",
@@ -1890,60 +1889,45 @@ _cmd_info(gchar **args, struct cmd_help_t help)
 static gboolean
 _cmd_caps(gchar **args, struct cmd_help_t help)
 {
-    char *usr = args[0];
-
     jabber_conn_status_t conn_status = jabber_get_connection_status();
 
     if (conn_status != JABBER_CONNECTED) {
         cons_show("You are not currently connected.");
     } else {
         if (win_current_is_groupchat()) {
-            if (usr != NULL) {
-                PContact pcontact = muc_get_participant(win_current_get_recipient(), usr);
+            if (args[0] != NULL) {
+                PContact pcontact = muc_get_participant(win_current_get_recipient(), args[0]);
                 if (pcontact != NULL) {
-                    cons_show_caps(pcontact);
+                    Resource *resource = p_contact_get_resource(pcontact, args[0]);
+                    cons_show_caps(args[0], resource);
                 } else {
-                    cons_show("No such participant \"%s\" in room.", usr);
+                    cons_show("No such participant \"%s\" in room.", args[0]);
                 }
             } else {
-                cons_show("No nickname supplied to /info in chat room.");
+                cons_show("No nickname supplied to /caps in chat room.");
             }
+        } else if (win_current_is_chat() || win_current_is_console()) {
+            if (args[0] != NULL) {
+                Jid *jid = jid_create(args[0]);
 
-        } else if (win_current_is_chat()) {
-            if (usr != NULL) {
-                cons_show("No parameter required for /info in chat.");
-            } else {
-                PContact pcontact = contact_list_get_contact(win_current_get_recipient());
-                if (pcontact != NULL) {
-                    cons_show_caps(pcontact);
+                if (jid->fulljid == NULL) {
+                    cons_show("You must provide a full jid to the /caps command.");
                 } else {
-                    cons_show("No such contact \"%s\" in roster.", win_current_get_recipient());
+                    PContact pcontact = contact_list_get_contact(jid->barejid);
+                    Resource *resource = p_contact_get_resource(pcontact, jid->resourcepart);
+                    cons_show_caps(jid->fulljid, resource);
                 }
+            } else {
+                cons_show("You must provide a jid to the /caps command.");
             }
-
-        } else if (win_current_is_private()) {
-            if (usr != NULL) {
-                win_current_show("No parameter required when in chat.");
+        } else { // private chat
+            if (args[0] != NULL) {
+                cons_show("No parameter needed to /caps when in private chat.");
             } else {
                 Jid *jid = jid_create(win_current_get_recipient());
                 PContact pcontact = muc_get_participant(jid->barejid, jid->resourcepart);
-                if (pcontact != NULL) {
-                    cons_show_caps(pcontact);
-                } else {
-                    cons_show("No such participant \"%s\" in room.", jid->resourcepart);
-                }
-                jid_destroy(jid);
-            }
-        } else {
-            if (usr != NULL) {
-                PContact pcontact = contact_list_get_contact(usr);
-                if (pcontact != NULL) {
-                    cons_show_caps(pcontact);
-                } else {
-                    cons_show("No such contact \"%s\" in roster.", usr);
-                }
-            } else {
-                cons_show("Usage: %s", help.usage);
+                Resource *resource = p_contact_get_resource(pcontact, jid->resourcepart);
+                cons_show_caps(jid->resourcepart, resource);
             }
         }
     }
@@ -1951,6 +1935,7 @@ _cmd_caps(gchar **args, struct cmd_help_t help)
     return TRUE;
 }
 
+
 static gboolean
 _cmd_software(gchar **args, struct cmd_help_t help)
 {
diff --git a/src/contact.c b/src/contact.c
index b63ff408..6a8dc7d3 100644
--- a/src/contact.c
+++ b/src/contact.c
@@ -223,6 +223,12 @@ p_contact_subscription(const PContact contact)
     return contact->subscription;
 }
 
+Resource *
+p_contact_get_resource(const PContact contact, const char * const resource)
+{
+    return g_hash_table_lookup(contact->available_resources, resource);
+}
+
 gboolean
 p_contact_pending_out(const PContact contact)
 {
diff --git a/src/contact.h b/src/contact.h
index beba5725..13b97043 100644
--- a/src/contact.h
+++ b/src/contact.h
@@ -50,5 +50,6 @@ void p_contact_set_pending_out(const PContact contact, gboolean pending_out);
 void p_contact_set_last_activity(const PContact contact, GDateTime *last_activity);
 gboolean p_contact_is_available(const PContact contact);
 gboolean p_contact_has_available_resource(const PContact contact);
+Resource * p_contact_get_resource(const PContact contact, const char * const resource);
 
 #endif
diff --git a/src/profanity.c b/src/profanity.c
index 39eb228b..8b6b560a 100644
--- a/src/profanity.c
+++ b/src/profanity.c
@@ -394,10 +394,10 @@ prof_handle_activity(void)
 }
 
 void
-prof_handle_version_result(const char * const jid, const char * const name,
-    const char * const version, const char * const os)
+prof_handle_version_result(const char * const jid, const char * const  presence,
+    const char * const name, const char * const version, const char * const os)
 {
-    cons_show_software_version(jid, name, version, os);
+    cons_show_software_version(jid, presence, name, version, os);
     win_current_page_off();
 }
 
diff --git a/src/profanity.h b/src/profanity.h
index 177b4e91..5363670c 100644
--- a/src/profanity.h
+++ b/src/profanity.h
@@ -68,7 +68,8 @@ void prof_handle_room_broadcast(const char *const room_jid,
     const char * const message);
 void prof_handle_idle(void);
 void prof_handle_activity(void);
-void prof_handle_version_result(const char * const jid, const char * const name,
+void prof_handle_version_result(const char * const jid,
+    const char * const presence, const char * const name,
     const char * const version, const char * const os);
 
 #endif
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 14d03ef0..4ff10679 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -165,10 +165,11 @@ void cons_check_version(gboolean not_available_msg);
 void cons_show_wins(void);
 void cons_show_status(const char * const contact);
 void cons_show_info(PContact pcontact);
-void cons_show_caps(PContact pcontact);
+void cons_show_caps(const char * const contact, Resource *resource);
 void cons_show_themes(GSList *themes);
 void cons_show_login_success(ProfAccount *account);
-void cons_show_software_version(const char * const jid, const char * const name,
+void cons_show_software_version(const char * const jid,
+    const char * const presence, const char * const name,
     const char * const version, const char * const os);
 
 // status bar actions
diff --git a/src/ui/windows.c b/src/ui/windows.c
index 7a34b17a..71aa1223 100644
--- a/src/ui/windows.c
+++ b/src/ui/windows.c
@@ -103,7 +103,7 @@ static void _win_resize_all(void);
 static gint _win_get_unread(void);
 static void _win_show_history(WINDOW *win, int win_index,
     const char * const contact);
-static void _win_show_info(WINDOW *win, PContact pcontact, gboolean show_caps);
+static void _win_show_info(WINDOW *win, PContact pcontact);
 static gboolean _new_release(char *found_version);
 static void _ui_draw_win_title(void);
 static void _presence_colour_on(WINDOW *win, const char * const presence);
@@ -1184,7 +1184,7 @@ cons_show_wins(void)
 void
 cons_show_info(PContact pcontact)
 {
-    _win_show_info(console->win, pcontact, FALSE);
+    _win_show_info(console->win, pcontact);
 
     if (current_index == 0) {
         dirty = TRUE;
@@ -1194,9 +1194,74 @@ cons_show_info(PContact pcontact)
 }
 
 void
-cons_show_caps(PContact pcontact)
+cons_show_caps(const char * const contact, Resource *resource)
 {
-    _win_show_info(console->win, pcontact, TRUE);
+    WINDOW *win = console->win;
+    cons_show("");
+    const char *resource_presence = string_from_resource_presence(resource->presence);
+    _win_show_time(win, '-');
+    _presence_colour_on(win, resource_presence);
+    wprintw(win, "%s", contact);
+    _presence_colour_off(win, resource_presence);
+    wprintw(win, ":\n");
+
+    if (resource->caps_str != NULL) {
+        Capabilities *caps = caps_get(resource->caps_str);
+        if (caps != NULL) {
+            // show identity
+            if ((caps->category != NULL) || (caps->type != NULL) || (caps->name != NULL)) {
+                _win_show_time(win, '-');
+                wprintw(win, "  Identity: ");
+                if (caps->name != NULL) {
+                    wprintw(win, "%s", caps->name);
+                    if ((caps->category != NULL) || (caps->type != NULL)) {
+                        wprintw(win, " ");
+                    }
+                }
+                if (caps->type != NULL) {
+                    wprintw(win, "%s", caps->type);
+                    if (caps->category != NULL) {
+                        wprintw(win, " ");
+                    }
+                }
+                if (caps->category != NULL) {
+                    wprintw(win, "%s", caps->category);
+                }
+                wprintw(win, "\n");
+            }
+            if (caps->software != NULL) {
+                _win_show_time(win, '-');
+                wprintw(win, "  Software: %s", caps->software);
+            }
+            if (caps->software_version != NULL) {
+                wprintw(win, ", %s", caps->software_version);
+            }
+            if ((caps->software != NULL) || (caps->software_version != NULL)) {
+                wprintw(win, "\n");
+            }
+            if (caps->os != NULL) {
+                _win_show_time(win, '-');
+                wprintw(win, "  OS: %s", caps->os);
+            }
+            if (caps->os_version != NULL) {
+                wprintw(win, ", %s", caps->os_version);
+            }
+            if ((caps->os != NULL) || (caps->os_version != NULL)) {
+                wprintw(win, "\n");
+            }
+
+            if (caps->features != NULL) {
+                _win_show_time(win, '-');
+                wprintw(win, "  Features:\n");
+                GSList *feature = caps->features;
+                while (feature != NULL) {
+                    _win_show_time(win, '-');
+                    wprintw(win, "    %s\n", feature->data);
+                    feature = g_slist_next(feature);
+                }
+            }
+        }
+    }
 
     if (current_index == 0) {
         dirty = TRUE;
@@ -1206,12 +1271,16 @@ cons_show_caps(PContact pcontact)
 }
 
 void
-cons_show_software_version(const char * const jid, const char * const name,
-    const char * const version, const char * const os)
+cons_show_software_version(const char * const jid, const char * const  presence,
+    const char * const name, const char * const version, const char * const os)
 {
     if ((name != NULL) || (version != NULL) || (os != NULL)) {
         cons_show("");
-        cons_show("%s:", jid);
+        _win_show_time(console->win, '-');
+        _presence_colour_on(console->win, presence);
+        wprintw(console->win, "%s", jid);
+        _presence_colour_off(console->win, presence);
+        wprintw(console->win, ":\n");
     }
     if (name != NULL) {
         cons_show("  Name    : %s", name);
@@ -2431,7 +2500,7 @@ _win_show_history(WINDOW *win, int win_index, const char * const contact)
 }
 
 static void
-_win_show_info(WINDOW *win, PContact pcontact, gboolean show_caps)
+_win_show_info(WINDOW *win, PContact pcontact)
 {
     const char *barejid = p_contact_barejid(pcontact);
     const char *name = p_contact_name(pcontact);
@@ -2551,18 +2620,6 @@ _win_show_info(WINDOW *win, PContact pcontact, gboolean show_caps)
                 if ((caps->os != NULL) || (caps->os_version != NULL)) {
                     wprintw(win, "\n");
                 }
-
-                if (show_caps && caps->features != NULL) {
-                    _win_show_time(win, '-');
-                    wprintw(win, "    Features:\n");
-                    GSList *feature = caps->features;
-                    while (feature != NULL) {
-                        _win_show_time(win, '-');
-                        wprintw(win, "      %s\n", feature->data);
-                        feature = g_slist_next(feature);
-                    }
-                }
-
             }
         }
 
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index b98d3bc6..4858482c 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -29,7 +29,9 @@
 
 #include "common.h"
 #include "contact_list.h"
+#include "jid.h"
 #include "log.h"
+#include "muc.h"
 #include "profanity.h"
 #include "xmpp/capabilities.h"
 #include "xmpp/connection.h"
@@ -207,7 +209,19 @@ _iq_handle_version_result(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza
         os_str = xmpp_stanza_get_text(os);
     }
 
-    prof_handle_version_result(jid, name_str, version_str, os_str);
+    PContact contact;
+    Jid *jidp = jid_create(jid);
+    if (muc_room_is_active(jidp)) {
+        contact = muc_get_participant(jidp->barejid, jidp->resourcepart);
+    } else {
+        contact = contact_list_get_contact(jidp->barejid);
+    }
+
+    Resource *resource = p_contact_get_resource(contact, jidp->resourcepart);
+    const char *presence = string_from_resource_presence(resource->presence);
+    prof_handle_version_result(jid, presence, name_str, version_str, os_str);
+
+    jid_destroy(jidp);
 
     return 1;
 }
eys.py?h=v1.9.0b3&id=895e04b312544515549fe953e0264d572837ae55'>^
09d8404c ^
933463fd ^
228f3f57 ^




3f388ce5 ^
228f3f57 ^

933463fd ^
228f3f57 ^
















933463fd ^
d8cd2b75 ^
cfe081ec ^
ee4687c3 ^
d6429e27 ^
ee4687c3 ^
d8cd2b75 ^

d6429e27 ^


d8cd2b75 ^

cfe081ec ^

d8cd2b75 ^
e5c44775 ^






ee4687c3 ^
95e3dfb1 ^
cfe081ec ^
95e3dfb1 ^

d8cd2b75 ^

cfe081ec ^

d8cd2b75 ^
ee4687c3 ^

e5c44775 ^




89466526 ^
ee4687c3 ^

d8cd2b75 ^
39db95d9 ^
d8cd2b75 ^
ca909b9a ^
95e3dfb1 ^
8d56a585 ^


95e3dfb1 ^

8d56a585 ^
95e3dfb1 ^
8d56a585 ^
d8cd2b75 ^
ee4687c3 ^

d8cd2b75 ^
8d56a585 ^

d8cd2b75 ^
8d56a585 ^
ca909b9a ^




d8cd2b75 ^
39db95d9 ^
cfe081ec ^

39db95d9 ^
ee4687c3 ^

39db95d9 ^
ee4687c3 ^
e5c44775 ^
39db95d9 ^

2feb26de ^
39db95d9 ^
ee4687c3 ^


39db95d9 ^







e5c44775 ^


ee4687c3 ^
39db95d9 ^



e5c44775 ^
39db95d9 ^


d8cd2b75 ^
4ba2112b ^
cfe081ec ^

4ba2112b ^
ee4687c3 ^

4ba2112b ^

89466526 ^
4ba2112b ^
ee4687c3 ^

4ba2112b ^








ca909b9a ^
cfe081ec ^

ca909b9a ^

ee4687c3 ^


ca909b9a ^



bfac461b ^
d6429e27 ^

ca909b9a ^




cfe081ec ^

ca909b9a ^

e5c44775 ^
cfe081ec ^

e5c44775 ^



89466526 ^
e5c44775 ^
ee4687c3 ^



e5c44775 ^

13ecffe7 ^










e5c44775 ^

ee4687c3 ^
e5c44775 ^



89466526 ^

e5c44775 ^
ee4687c3 ^
e5c44775 ^
89466526 ^

e5c44775 ^
c70c915b ^

e975b52f ^

c70c915b ^

e975b52f ^

c70c915b ^

4e9384fd ^
0b306138 ^






ef011c91 ^
0b306138 ^
ef011c91 ^
0b306138 ^

ef011c91 ^
0b306138 ^


feaf9e0a ^

0b306138 ^
ef011c91 ^
0b306138 ^



ef011c91 ^
0b306138 ^



ef011c91 ^






0b306138 ^
e5c44775 ^
ef011c91 ^



feaf9e0a ^

ef011c91 ^


93ecd88d ^
feaf9e0a ^

ef011c91 ^

feaf9e0a ^

ef011c91 ^
feaf9e0a ^

93ecd88d ^
feaf9e0a ^

ef011c91 ^
























4e9384fd ^
93ecd88d ^























feaf9e0a ^











93ecd88d ^
d8cd2b75 ^
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
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595