Tue, 28 Feb 2023 03:23:06 -0600
Fix leaks in requests
Fixes a leak for images in requests:
```
3,627 bytes in 1 blocks are definitely lost in loss record 35,636 of 36,499
at 0x484386F: malloc (vg_replace_malloc.c:393)
by 0x4980168: g_malloc (gmem.c:130)
by 0x4995723: UnknownInlinedFun (gstrfuncs.c:426)
by 0x4995723: g_memdup2 (gstrfuncs.c:419)
by 0x4D3E534: purple_request_field_image_new (request.c:1677)
by 0x1CA970B1: purple_demo_protocol_request_fields_activate (purpledemoprotocolactions.c:553)
by 0x4DB5FBF: g_closure_invoke (gclosure.c:832)
by 0x4DE3D85: signal_emit_unlocked_R.isra.0 (gsignal.c:3796)
by 0x4DD3419: g_signal_emit_valist (gsignal.c:3549)
by 0x4DD3632: g_signal_emit (gsignal.c:3606)
by 0x581C784: g_simple_action_activate (gsimpleaction.c:227)
by 0x581B132: g_action_activate (gaction.c:399)
by 0x51221B6: UnknownInlinedFun (gtkmenutrackeritem.c:842)
by 0x51221B6: gtk_popover_item_activate.lto_priv.0 (gtkmenusectionbox.c:200)
```
and leak of the GObject wrapper for request fields:
```
4 bytes in 1 blocks are possibly lost in loss record 713 of 36,499
at 0x484386F: malloc (vg_replace_malloc.c:393)
by 0x4980168: g_malloc (gmem.c:130)
by 0x4995602: g_strdup (gstrfuncs.c:363)
by 0x488B324: create_list_field (gtkrequest.c:1504)
by 0x488D1D7: pidgin_request_fields (gtkrequest.c:2160)
by 0x4D3FFB8: purple_request_fields (request.c:2283)
by 0x1CA971D6: purple_demo_protocol_request_fields_activate (purpledemoprotocolactions.c:562)
by 0x4DB5FBF: g_closure_invoke (gclosure.c:832)
by 0x4DE3D85: signal_emit_unlocked_R.isra.0 (gsignal.c:3796)
by 0x4DD3419: g_signal_emit_valist (gsignal.c:3549)
by 0x4DD3632: g_signal_emit (gsignal.c:3606)
by 0x581C784: g_simple_action_activate (gsimpleaction.c:227)
56 bytes in 1 blocks are possibly lost in loss record 19,209 of 36,499
at 0x48486AF: realloc (vg_replace_malloc.c:1451)
by 0x498071F: g_realloc (gmem.c:201)
by 0x49592C4: g_data_set_internal (gdataset.c:474)
by 0x488B347: create_list_field (gtkrequest.c:1504)
by 0x488D1D7: pidgin_request_fields (gtkrequest.c:2160)
by 0x4D3FFB8: purple_request_fields (request.c:2283)
by 0x1CA971D6: purple_demo_protocol_request_fields_activate (purpledemoprotocolactions.c:562)
by 0x4DB5FBF: g_closure_invoke (gclosure.c:832)
by 0x4DE3D85: signal_emit_unlocked_R.isra.0 (gsignal.c:3796)
by 0x4DD3419: g_signal_emit_valist (gsignal.c:3549)
by 0x4DD3632: g_signal_emit (gsignal.c:3606)
by 0x581C784: g_simple_action_activate (gsimpleaction.c:227)
614 (192 direct, 422 indirect) bytes in 8 blocks are definitely lost in loss record 33,122 of 36,499
at 0x484386F: malloc (vg_replace_malloc.c:393)
by 0x4980168: g_malloc (gmem.c:130)
by 0x4997AB5: g_slice_alloc (gslice.c:1074)
by 0x49980EC: g_slice_alloc0 (gslice.c:1100)
by 0x4DDF04B: g_type_create_instance (gtype.c:1913)
by 0x4DC4C1F: g_object_new_internal (gobject.c:2228)
by 0x4DC6247: g_object_new_with_properties (gobject.c:2391)
by 0x4DC6FF0: g_object_new (gobject.c:2037)
by 0x488B2D5: create_list_field (gtkrequest.c:1499)
by 0x488D1D7: pidgin_request_fields (gtkrequest.c:2160)
by 0x4D3FFB8: purple_request_fields (request.c:2283)
by 0x1CA971D6: purple_demo_protocol_request_fields_activate (purpledemoprotocolactions.c:562)
```
and a request label:
```
128 bytes in 1 blocks are definitely lost in loss record 27,735 of 36,499
at 0x484378A: malloc (vg_replace_malloc.c:392)
by 0x484870B: realloc (vg_replace_malloc.c:1451)
by 0x498071F: g_realloc (gmem.c:201)
by 0x499A343: g_string_maybe_expand (gstring.c:92)
by 0x499A3BF: g_string_sized_new (gstring.c:116)
by 0x4981BCB: g_markup_escape_text (gmarkup.c:2323)
by 0x4887D8A: pidgin_request_escape (gtkrequest.c:360)
by 0x488CED9: pidgin_request_fields (gtkrequest.c:2105)
by 0x4D3FFB8: purple_request_fields (request.c:2283)
by 0x1CA971D6: purple_demo_protocol_request_fields_activate (purpledemoprotocolactions.c:562)
by 0x4DB5FBF: g_closure_invoke (gclosure.c:832)
by 0x4DE3D85: signal_emit_unlocked_R.isra.0 (gsignal.c:3796)
```
and one in the demo protocol:
```
40 bytes in 1 blocks are definitely lost in loss record 15,277 of 36,499
at 0x484386F: malloc (vg_replace_malloc.c:393)
by 0x4AE3017: __vasprintf_internal (vasprintf.c:71)
by 0x49C2E81: UnknownInlinedFun (stdio2.h:169)
by 0x49C2E81: g_vasprintf (gprintf.c:340)
by 0x4998EA0: g_strdup_vprintf (gstrfuncs.c:553)
by 0x4998F5C: g_strdup_printf (gstrfuncs.c:583)
by 0x1CA9584E: purple_demo_protocol_request_input_activate (purpledemoprotocolactions.c:203)
by 0x4DB5FBF: g_closure_invoke (gclosure.c:832)
by 0x4DE3D85: signal_emit_unlocked_R.isra.0 (gsignal.c:3796)
by 0x4DD3419: g_signal_emit_valist (gsignal.c:3549)
by 0x4DD3632: g_signal_emit (gsignal.c:3606)
by 0x581C784: g_simple_action_activate (gsimpleaction.c:227)
by 0x581B132: g_action_activate (gaction.c:399)
```
Testing Done:
Ran valgrind and confirmed above leaks were not there after opening Request Input and Request Fields.
Reviewed at https://reviews.imfreedom.org/r/2300/
|
17768
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
1 | /* |
|
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
2 | * purple - Jabber Protocol Plugin |
|
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
3 | * |
|
28322
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
28321
diff
changeset
|
4 | * Purple is the legal property of its developers, whose names are too numerous |
|
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
28321
diff
changeset
|
5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
28321
diff
changeset
|
6 | * source distribution. |
|
17768
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
7 | * |
|
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
8 | * This program is free software; you can redistribute it and/or modify |
|
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
9 | * it under the terms of the GNU General Public License as published by |
|
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
10 | * the Free Software Foundation; either version 2 of the License, or |
|
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
11 | * (at your option) any later version. |
|
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
12 | * |
|
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
13 | * This program is distributed in the hope that it will be useful, |
|
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17768
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
16 | * GNU General Public License for more details. |
|
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
17 | * |
|
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
18 | * You should have received a copy of the GNU General Public License |
|
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
19 | * along with this program; if not, write to the Free Software |
|
28321
c8d617c408ab
Update various header copyrights thanks to licensecheck.
Paul Aurich <darkrain42@pidgin.im>
parents:
27028
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
17768
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
21 | * |
|
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
22 | */ |
|
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
23 | |
|
40439
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
24 | #include <glib/gi18n-lib.h> |
|
19898
218e4bb04853
Fix mingw build of xmpp prpl
Daniel Atallah <datallah@pidgin.im>
parents:
17809
diff
changeset
|
25 | |
|
17768
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
26 | #include "pep.h" |
|
17772
918f65155a08
Implemented publishing events
Andreas Monitzer <am@adiumx.com>
parents:
17768
diff
changeset
|
27 | #include "iq.h" |
|
17773
6956b763b3d1
Implemented adding callbacks for PEP events. Moved the feature list to be application-global instead of per-connection (makes more sense).
Andreas Monitzer <am@adiumx.com>
parents:
17772
diff
changeset
|
28 | #include <string.h> |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
24818
diff
changeset
|
29 | #include "useravatar.h" |
| 17793 | 30 | #include "usermood.h" |
|
17803
882abe4d932e
Implemented XEP-0172: User Nickname, fixed some potential crashers in the other PEP callbacks.
Andreas Monitzer <am@adiumx.com>
parents:
17793
diff
changeset
|
31 | #include "usernick.h" |
|
24737
b8a96a07e7ac
Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents:
23586
diff
changeset
|
32 | #include "usertune.h" |
|
17768
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
33 | |
|
17773
6956b763b3d1
Implemented adding callbacks for PEP events. Moved the feature list to be application-global instead of per-connection (makes more sense).
Andreas Monitzer <am@adiumx.com>
parents:
17772
diff
changeset
|
34 | static GHashTable *pep_handlers = NULL; |
|
6956b763b3d1
Implemented adding callbacks for PEP events. Moved the feature list to be application-global instead of per-connection (makes more sense).
Andreas Monitzer <am@adiumx.com>
parents:
17772
diff
changeset
|
35 | |
|
6956b763b3d1
Implemented adding callbacks for PEP events. Moved the feature list to be application-global instead of per-connection (makes more sense).
Andreas Monitzer <am@adiumx.com>
parents:
17772
diff
changeset
|
36 | void jabber_pep_init(void) { |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
37 | if(!pep_handlers) { |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
38 | pep_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24818
diff
changeset
|
39 | |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
40 | /* register PEP handlers */ |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
24818
diff
changeset
|
41 | jabber_avatar_init(); |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
42 | jabber_mood_init(); |
|
24737
b8a96a07e7ac
Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents:
23586
diff
changeset
|
43 | jabber_tune_init(); |
|
17803
882abe4d932e
Implemented XEP-0172: User Nickname, fixed some potential crashers in the other PEP callbacks.
Andreas Monitzer <am@adiumx.com>
parents:
17793
diff
changeset
|
44 | jabber_nick_init(); |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
45 | } |
|
17773
6956b763b3d1
Implemented adding callbacks for PEP events. Moved the feature list to be application-global instead of per-connection (makes more sense).
Andreas Monitzer <am@adiumx.com>
parents:
17772
diff
changeset
|
46 | } |
|
6956b763b3d1
Implemented adding callbacks for PEP events. Moved the feature list to be application-global instead of per-connection (makes more sense).
Andreas Monitzer <am@adiumx.com>
parents:
17772
diff
changeset
|
47 | |
|
24737
b8a96a07e7ac
Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents:
23586
diff
changeset
|
48 | void jabber_pep_uninit(void) { |
|
27028
1a2ef7ddb463
Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents:
27016
diff
changeset
|
49 | /* any PEP handlers that need to clean things up go here. The standard |
|
1a2ef7ddb463
Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents:
27016
diff
changeset
|
50 | * cleanup of removing the handler and feature are handled here and by |
|
1a2ef7ddb463
Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents:
27016
diff
changeset
|
51 | * jabber_features_destroy() in jabber.c |
|
1a2ef7ddb463
Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents:
27016
diff
changeset
|
52 | */ |
|
24737
b8a96a07e7ac
Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents:
23586
diff
changeset
|
53 | g_hash_table_destroy(pep_handlers); |
|
b8a96a07e7ac
Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents:
23586
diff
changeset
|
54 | pep_handlers = NULL; |
|
b8a96a07e7ac
Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents:
23586
diff
changeset
|
55 | } |
|
b8a96a07e7ac
Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <darkrain42@pidgin.im>
parents:
23586
diff
changeset
|
56 | |
|
41789
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40439
diff
changeset
|
57 | void |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40439
diff
changeset
|
58 | jabber_pep_add_action_entries(GSimpleActionGroup *group) { |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40439
diff
changeset
|
59 | jabber_nick_add_action_entries(group); |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40439
diff
changeset
|
60 | } |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40439
diff
changeset
|
61 | |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40439
diff
changeset
|
62 | void |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40439
diff
changeset
|
63 | jabber_pep_append_menu(GMenu *menu) { |
|
17782
83af68644d0a
Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <am@adiumx.com>
parents:
17780
diff
changeset
|
64 | /* register the PEP-specific actions */ |
|
41789
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40439
diff
changeset
|
65 | jabber_nick_append_menu(menu); |
|
17782
83af68644d0a
Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <am@adiumx.com>
parents:
17780
diff
changeset
|
66 | } |
|
83af68644d0a
Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <am@adiumx.com>
parents:
17780
diff
changeset
|
67 | |
|
23586
e495a4623f76
Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents:
19899
diff
changeset
|
68 | void jabber_pep_register_handler(const char *xmlns, JabberPEPHandler handlerfunc) { |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
69 | gchar *notifyns = g_strdup_printf("%s+notify", xmlns); |
|
23586
e495a4623f76
Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents:
19899
diff
changeset
|
70 | jabber_add_feature(notifyns, NULL); /* receiving PEPs is always supported */ |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
71 | g_free(notifyns); |
|
17773
6956b763b3d1
Implemented adding callbacks for PEP events. Moved the feature list to be application-global instead of per-connection (makes more sense).
Andreas Monitzer <am@adiumx.com>
parents:
17772
diff
changeset
|
72 | g_hash_table_replace(pep_handlers, g_strdup(xmlns), handlerfunc); |
|
17768
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
73 | } |
|
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
74 | |
|
26687
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
75 | static void |
|
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
76 | do_pep_iq_request_item_callback(JabberStream *js, const char *from, |
|
41967
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41791
diff
changeset
|
77 | JabberIqType type, |
|
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41791
diff
changeset
|
78 | G_GNUC_UNUSED const char *id, |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29825
diff
changeset
|
79 | PurpleXmlNode *packet, gpointer data) |
|
26687
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26042
diff
changeset
|
80 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29825
diff
changeset
|
81 | PurpleXmlNode *pubsub; |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29825
diff
changeset
|
82 | PurpleXmlNode *items = NULL; |
|
17788
e6e381b0c7d6
Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents:
17787
diff
changeset
|
83 | JabberPEPHandler *cb = data; |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24818
diff
changeset
|
84 | |
|
27016
1e21b1e058c0
On errors, don't pretend we did fetch something, pass NULL.
Paul Aurich <darkrain42@pidgin.im>
parents:
26958
diff
changeset
|
85 | if (type == JABBER_IQ_RESULT) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29825
diff
changeset
|
86 | pubsub = purple_xmlnode_get_child_with_namespace(packet, "pubsub", "http://jabber.org/protocol/pubsub"); |
|
27016
1e21b1e058c0
On errors, don't pretend we did fetch something, pass NULL.
Paul Aurich <darkrain42@pidgin.im>
parents:
26958
diff
changeset
|
87 | if(pubsub) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29825
diff
changeset
|
88 | items = purple_xmlnode_get_child(pubsub, "items"); |
|
27016
1e21b1e058c0
On errors, don't pretend we did fetch something, pass NULL.
Paul Aurich <darkrain42@pidgin.im>
parents:
26958
diff
changeset
|
89 | } |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24818
diff
changeset
|
90 | |
|
17789
f75d542850e3
Turns out the example in XEP-0084 is wrong. Fixed my implementation to not try to work around an issue that isn't one.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
91 | cb(js, from, items); |
|
17788
e6e381b0c7d6
Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents:
17787
diff
changeset
|
92 | } |
|
e6e381b0c7d6
Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents:
17787
diff
changeset
|
93 | |
|
e6e381b0c7d6
Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents:
17787
diff
changeset
|
94 | void jabber_pep_request_item(JabberStream *js, const char *to, const char *node, const char *id, JabberPEPHandler cb) { |
|
e6e381b0c7d6
Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents:
17787
diff
changeset
|
95 | JabberIq *iq = jabber_iq_new(js, JABBER_IQ_GET); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29825
diff
changeset
|
96 | PurpleXmlNode *pubsub, *items; |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24818
diff
changeset
|
97 | |
|
29782
ca4fedd9e890
jabber: Allow jabber_pep_request_item() to take NULL for JID; server's routing takes care of the rest
Paul Aurich <darkrain42@pidgin.im>
parents:
28884
diff
changeset
|
98 | if (to) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29825
diff
changeset
|
99 | purple_xmlnode_set_attrib(iq->node, "to", to); |
|
29782
ca4fedd9e890
jabber: Allow jabber_pep_request_item() to take NULL for JID; server's routing takes care of the rest
Paul Aurich <darkrain42@pidgin.im>
parents:
28884
diff
changeset
|
100 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29825
diff
changeset
|
101 | pubsub = purple_xmlnode_new_child(iq->node,"pubsub"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29825
diff
changeset
|
102 | purple_xmlnode_set_namespace(pubsub, "http://jabber.org/protocol/pubsub"); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24818
diff
changeset
|
103 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29825
diff
changeset
|
104 | items = purple_xmlnode_new_child(pubsub, "items"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29825
diff
changeset
|
105 | purple_xmlnode_set_attrib(items,"node",node); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24818
diff
changeset
|
106 | |
|
28884
aa4c9e6ef61c
jabber: Properly request just the most recent item from a PEP node.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
107 | if (id) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29825
diff
changeset
|
108 | PurpleXmlNode *item = purple_xmlnode_new_child(items, "item"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29825
diff
changeset
|
109 | purple_xmlnode_set_attrib(item, "id", id); |
|
28884
aa4c9e6ef61c
jabber: Properly request just the most recent item from a PEP node.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
110 | } else |
|
aa4c9e6ef61c
jabber: Properly request just the most recent item from a PEP node.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
111 | /* Most recent item */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29825
diff
changeset
|
112 | purple_xmlnode_set_attrib(items, "max_items", "1"); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24818
diff
changeset
|
113 | |
|
17788
e6e381b0c7d6
Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents:
17787
diff
changeset
|
114 | jabber_iq_set_callback(iq,do_pep_iq_request_item_callback,(gpointer)cb); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24818
diff
changeset
|
115 | |
|
17788
e6e381b0c7d6
Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents:
17787
diff
changeset
|
116 | jabber_iq_send(iq); |
|
e6e381b0c7d6
Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents:
17787
diff
changeset
|
117 | } |
|
e6e381b0c7d6
Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents:
17787
diff
changeset
|
118 | |
|
41967
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41791
diff
changeset
|
119 | gboolean |
|
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41791
diff
changeset
|
120 | jabber_pep_namespace_only_when_pep_enabled_cb(JabberStream *js, |
|
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41791
diff
changeset
|
121 | G_GNUC_UNUSED const char *namespace) |
|
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41791
diff
changeset
|
122 | { |
|
17787
439329d20337
Added support for setting the avatar via XEP-0084. Receiving other people's avatar is up next.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
123 | return js->pep; |
|
439329d20337
Added support for setting the avatar via XEP-0084. Receiving other people's avatar is up next.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
124 | } |
|
439329d20337
Added support for setting the avatar via XEP-0084. Receiving other people's avatar is up next.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
125 | |
|
17768
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
126 | void jabber_handle_event(JabberMessage *jm) { |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
127 | /* this may be called even when the own server doesn't support pep! */ |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
128 | JabberPEPHandler *jph; |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
129 | GList *itemslist; |
|
26957
36f75a1d52a6
Don't try to process PEP events if it's not <message type='event'/>
Paul Aurich <darkrain42@pidgin.im>
parents:
26950
diff
changeset
|
130 | char *jid; |
|
36f75a1d52a6
Don't try to process PEP events if it's not <message type='event'/>
Paul Aurich <darkrain42@pidgin.im>
parents:
26950
diff
changeset
|
131 | |
|
36f75a1d52a6
Don't try to process PEP events if it's not <message type='event'/>
Paul Aurich <darkrain42@pidgin.im>
parents:
26950
diff
changeset
|
132 | if (jm->type != JABBER_MESSAGE_EVENT) |
|
36f75a1d52a6
Don't try to process PEP events if it's not <message type='event'/>
Paul Aurich <darkrain42@pidgin.im>
parents:
26950
diff
changeset
|
133 | return; |
|
36f75a1d52a6
Don't try to process PEP events if it's not <message type='event'/>
Paul Aurich <darkrain42@pidgin.im>
parents:
26950
diff
changeset
|
134 | |
|
36f75a1d52a6
Don't try to process PEP events if it's not <message type='event'/>
Paul Aurich <darkrain42@pidgin.im>
parents:
26950
diff
changeset
|
135 | jid = jabber_get_bare_jid(jm->from); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24818
diff
changeset
|
136 | |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
137 | for(itemslist = jm->eventitems; itemslist; itemslist = itemslist->next) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29825
diff
changeset
|
138 | PurpleXmlNode *items = (PurpleXmlNode*)itemslist->data; |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29825
diff
changeset
|
139 | const char *nodename = purple_xmlnode_get_attrib(items,"node"); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24818
diff
changeset
|
140 | |
|
17780
749862fd4a87
Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents:
17779
diff
changeset
|
141 | if(nodename && (jph = g_hash_table_lookup(pep_handlers, nodename))) |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
142 | jph(jm->js, jid, items); |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
143 | } |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24818
diff
changeset
|
144 | |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
145 | /* discard items we don't have a handler for */ |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
146 | g_free(jid); |
|
17768
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
147 | } |
|
17772
918f65155a08
Implemented publishing events
Andreas Monitzer <am@adiumx.com>
parents:
17768
diff
changeset
|
148 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29825
diff
changeset
|
149 | void jabber_pep_publish(JabberStream *js, PurpleXmlNode *publish) { |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
150 | JabberIq *iq; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29825
diff
changeset
|
151 | PurpleXmlNode *pubsub; |
|
19899
483c4f495a6c
Various warning fixes for the xmpp prpl.
Daniel Atallah <datallah@pidgin.im>
parents:
19898
diff
changeset
|
152 | |
|
17809
f10c83605116
Fixed a leak in the PEP code that leaked PEP nodes when the server doesn't support this XEP.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
153 | if(js->pep != TRUE) { |
|
f10c83605116
Fixed a leak in the PEP code that leaked PEP nodes when the server doesn't support this XEP.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
154 | /* ignore when there's no PEP support on the server */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29825
diff
changeset
|
155 | purple_xmlnode_free(publish); |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
156 | return; |
|
17809
f10c83605116
Fixed a leak in the PEP code that leaked PEP nodes when the server doesn't support this XEP.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
157 | } |
|
19899
483c4f495a6c
Various warning fixes for the xmpp prpl.
Daniel Atallah <datallah@pidgin.im>
parents:
19898
diff
changeset
|
158 | |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
159 | iq = jabber_iq_new(js, JABBER_IQ_SET); |
|
19899
483c4f495a6c
Various warning fixes for the xmpp prpl.
Daniel Atallah <datallah@pidgin.im>
parents:
19898
diff
changeset
|
160 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29825
diff
changeset
|
161 | pubsub = purple_xmlnode_new("pubsub"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29825
diff
changeset
|
162 | purple_xmlnode_set_namespace(pubsub, "http://jabber.org/protocol/pubsub"); |
|
19899
483c4f495a6c
Various warning fixes for the xmpp prpl.
Daniel Atallah <datallah@pidgin.im>
parents:
19898
diff
changeset
|
163 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29825
diff
changeset
|
164 | purple_xmlnode_insert_child(pubsub, publish); |
|
19899
483c4f495a6c
Various warning fixes for the xmpp prpl.
Daniel Atallah <datallah@pidgin.im>
parents:
19898
diff
changeset
|
165 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29825
diff
changeset
|
166 | purple_xmlnode_insert_child(iq->node, pubsub); |
|
19899
483c4f495a6c
Various warning fixes for the xmpp prpl.
Daniel Atallah <datallah@pidgin.im>
parents:
19898
diff
changeset
|
167 | |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
168 | jabber_iq_send(iq); |
|
17772
918f65155a08
Implemented publishing events
Andreas Monitzer <am@adiumx.com>
parents:
17768
diff
changeset
|
169 | } |