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/
| 7014 | 1 | /* |
| 15884 | 2 | * purple - Jabber Protocol Plugin |
| 7014 | 3 | * |
|
28322
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
27900
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:
27900
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:
27900
diff
changeset
|
6 | * source distribution. |
| 7014 | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19419
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 7014 | 21 | * |
| 22 | */ | |
|
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:
40358
diff
changeset
|
23 | #include <glib/gi18n-lib.h> |
|
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:
40358
diff
changeset
|
24 | |
|
40358
e6fe6fc1f516
move all protocols, purple plugins, and purple tests to use purple.h instead of including files individually
Gary Kramlich <grim@reaperworld.com>
parents:
40294
diff
changeset
|
25 | #include <purple.h> |
| 7014 | 26 | |
|
26871
d62964222795
Add a new signal which is emitted (after the account is connected) if the
Paul Aurich <darkrain42@pidgin.im>
parents:
26867
diff
changeset
|
27 | #include "adhoccommands.h" |
| 7014 | 28 | #include "buddy.h" |
| 29 | #include "chat.h" | |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
30 | #include "data.h" |
| 7014 | 31 | #include "message.h" |
|
17768
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
17351
diff
changeset
|
32 | #include "pep.h" |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
33 | #include "iq.h" |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
34 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
35 | #include <string.h> |
| 7014 | 36 | |
|
38248
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
37 | static GString *jm_body_with_oob(JabberMessage *jm) { |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
38 | GList *etc; |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
39 | GString *body = g_string_new(""); |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
40 | |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
41 | if(jm->xhtml) |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
42 | g_string_append(body, jm->xhtml); |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
43 | else if(jm->body) |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
44 | g_string_append(body, jm->body); |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
45 | |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
46 | for(etc = jm->etc; etc; etc = etc->next) { |
| 38358 | 47 | PurpleXmlNode *x = etc->data; |
| 48 | const char *xmlns = purple_xmlnode_get_namespace(x); | |
|
38264
99356e68aff5
Merge release-2.x.y changes, resolve conflicts
qarkai <qarkai@gmail.com>
diff
changeset
|
49 | if(purple_strequal(xmlns, NS_OOB_X_DATA)) { |
| 38358 | 50 | PurpleXmlNode *url, *desc; |
|
38248
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
51 | char *urltxt, *desctxt; |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
52 | |
| 38358 | 53 | url = purple_xmlnode_get_child(x, "url"); |
| 54 | desc = purple_xmlnode_get_child(x, "desc"); | |
|
38248
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
55 | |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
56 | if(!url) |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
57 | continue; |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
58 | |
| 38358 | 59 | urltxt = purple_xmlnode_get_data(url); |
| 60 | desctxt = desc ? purple_xmlnode_get_data(desc) : urltxt; | |
|
38248
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
61 | |
|
38264
99356e68aff5
Merge release-2.x.y changes, resolve conflicts
qarkai <qarkai@gmail.com>
diff
changeset
|
62 | if(body->len && !purple_strequal(body->str, urltxt)) |
|
38248
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
63 | g_string_append_printf(body, "<br/><a href='%s'>%s</a>", |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
64 | urltxt, desctxt); |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
65 | else |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
66 | g_string_printf(body, "<a href='%s'>%s</a>", |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
67 | urltxt, desctxt); |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
68 | |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
69 | g_free(urltxt); |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
70 | |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
71 | if(desctxt != urltxt) |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
72 | g_free(desctxt); |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
73 | } |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
74 | } |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
75 | |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
76 | return body; |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
77 | } |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
78 | |
| 7014 | 79 | void jabber_message_free(JabberMessage *jm) |
| 80 | { | |
| 15980 | 81 | g_free(jm->from); |
| 13484 | 82 | g_free(jm->to); |
| 83 | g_free(jm->id); | |
| 84 | g_free(jm->subject); | |
| 85 | g_free(jm->body); | |
| 86 | g_free(jm->xhtml); | |
| 87 | g_free(jm->password); | |
|
20057
728a7dce565e
grab revision 41389df89a4a6a007d41cec33e33043cd41ea159
Luke Schierer <lschiere@pidgin.im>
parents:
19917
diff
changeset
|
88 | g_free(jm->error); |
|
728a7dce565e
grab revision 41389df89a4a6a007d41cec33e33043cd41ea159
Luke Schierer <lschiere@pidgin.im>
parents:
19917
diff
changeset
|
89 | g_free(jm->thread_id); |
| 13484 | 90 | g_list_free(jm->etc); |
|
20057
728a7dce565e
grab revision 41389df89a4a6a007d41cec33e33043cd41ea159
Luke Schierer <lschiere@pidgin.im>
parents:
19917
diff
changeset
|
91 | g_list_free(jm->eventitems); |
| 7014 | 92 | |
|
41239
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
93 | g_clear_pointer(&jm->sent, g_date_time_unref); |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
94 | |
| 7014 | 95 | g_free(jm); |
| 96 | } | |
| 97 | ||
| 7145 | 98 | static void handle_chat(JabberMessage *jm) |
| 7014 | 99 | { |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
100 | const gchar *contact = jm->outgoing ? jm->to : jm->from; |
|
40290
0a722071a754
Refactor jm->from to contact in handle_chat()
Koosha Khajehmoogahi <koosha@posteo.de>
parents:
39470
diff
changeset
|
101 | JabberID *jid = jabber_id_new(contact); |
| 7014 | 102 | |
|
29331
9e828e599fc2
jabber: Use some convenience variables here.
Paul Aurich <darkrain42@pidgin.im>
parents:
29330
diff
changeset
|
103 | PurpleConnection *gc; |
|
40997
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40885
diff
changeset
|
104 | PurpleConversationManager *manager; |
|
29331
9e828e599fc2
jabber: Use some convenience variables here.
Paul Aurich <darkrain42@pidgin.im>
parents:
29330
diff
changeset
|
105 | PurpleAccount *account; |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
106 | PurpleMessageFlags flags = 0; |
| 7014 | 107 | JabberBuddy *jb; |
| 108 | JabberBuddyResource *jbr; | |
|
38248
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
109 | GString *body; |
| 7014 | 110 | |
| 7310 | 111 | if(!jid) |
| 112 | return; | |
| 113 | ||
|
40997
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40885
diff
changeset
|
114 | manager = purple_conversation_manager_get_default(); |
|
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40885
diff
changeset
|
115 | |
|
29331
9e828e599fc2
jabber: Use some convenience variables here.
Paul Aurich <darkrain42@pidgin.im>
parents:
29330
diff
changeset
|
116 | gc = jm->js->gc; |
|
9e828e599fc2
jabber: Use some convenience variables here.
Paul Aurich <darkrain42@pidgin.im>
parents:
29330
diff
changeset
|
117 | account = purple_connection_get_account(gc); |
|
9e828e599fc2
jabber: Use some convenience variables here.
Paul Aurich <darkrain42@pidgin.im>
parents:
29330
diff
changeset
|
118 | |
|
40290
0a722071a754
Refactor jm->from to contact in handle_chat()
Koosha Khajehmoogahi <koosha@posteo.de>
parents:
39470
diff
changeset
|
119 | jb = jabber_buddy_find(jm->js, contact, TRUE); |
| 7306 | 120 | jbr = jabber_buddy_find_resource(jb, jid->resource); |
| 7014 | 121 | |
|
38248
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
122 | if (jbr && jm->chat_state != JM_STATE_NONE) |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
123 | jbr->chat_states = JABBER_CHAT_STATES_SUPPORTED; |
|
27750
f25b6a565494
Use Entity Capabilities to pick up Chat States support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents:
27749
diff
changeset
|
124 | |
|
38248
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
125 | switch(jm->chat_state) { |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
126 | case JM_STATE_COMPOSING: |
|
40290
0a722071a754
Refactor jm->from to contact in handle_chat()
Koosha Khajehmoogahi <koosha@posteo.de>
parents:
39470
diff
changeset
|
127 | purple_serv_got_typing(gc, contact, 0, PURPLE_IM_TYPING); |
|
38248
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
128 | break; |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
129 | case JM_STATE_PAUSED: |
|
40290
0a722071a754
Refactor jm->from to contact in handle_chat()
Koosha Khajehmoogahi <koosha@posteo.de>
parents:
39470
diff
changeset
|
130 | purple_serv_got_typing(gc, contact, 0, PURPLE_IM_TYPED); |
|
38248
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
131 | break; |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
132 | case JM_STATE_GONE: { |
|
40997
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40885
diff
changeset
|
133 | PurpleConversation *im = NULL; |
|
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40885
diff
changeset
|
134 | |
|
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40885
diff
changeset
|
135 | im = purple_conversation_manager_find_im(manager, account, contact); |
|
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40885
diff
changeset
|
136 | |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
137 | if (im && jid->node && jid->domain) { |
|
15721
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
138 | char buf[256]; |
| 15884 | 139 | PurpleBuddy *buddy; |
|
15721
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
140 | |
|
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
141 | g_snprintf(buf, sizeof(buf), "%s@%s", jid->node, jid->domain); |
|
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
142 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
143 | if ((buddy = purple_blist_find_buddy(account, buf))) { |
|
15721
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
144 | const char *who; |
|
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
145 | char *escaped; |
|
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
146 | |
| 15884 | 147 | who = purple_buddy_get_alias(buddy); |
|
15721
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
148 | escaped = g_markup_escape_text(who, -1); |
|
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
149 | |
|
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
150 | g_snprintf(buf, sizeof(buf), |
| 16946 | 151 | _("%s has left the conversation."), escaped); |
|
21193
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20361
diff
changeset
|
152 | g_free(escaped); |
|
15721
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
153 | |
| 15884 | 154 | /* At some point when we restructure PurpleConversation, |
|
15721
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
155 | * this should be able to be implemented by removing the |
|
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
156 | * user from the conversation like we do with chats now. */ |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40798
diff
changeset
|
157 | purple_conversation_write_system_message(im, buf, 0); |
|
15721
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
158 | } |
|
15710
fbc4a200c853
Receiving XEP 85 'gone' messages. Doesn't do anything because of the string freeze. This is akin to the MSN 'so-and-so has closed the conversation window' messages. Rlaager made a strong point to me that they're not altogether stalky, but can be useful.
Sean Egan <seanegan@pidgin.im>
parents:
15709
diff
changeset
|
159 | } |
|
40290
0a722071a754
Refactor jm->from to contact in handle_chat()
Koosha Khajehmoogahi <koosha@posteo.de>
parents:
39470
diff
changeset
|
160 | purple_serv_got_typing_stopped(gc, contact); |
|
38248
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
161 | break; |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
162 | } |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
163 | default: |
|
40290
0a722071a754
Refactor jm->from to contact in handle_chat()
Koosha Khajehmoogahi <koosha@posteo.de>
parents:
39470
diff
changeset
|
164 | purple_serv_got_typing_stopped(gc, contact); |
|
38248
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
165 | } |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
166 | |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
167 | body = jm_body_with_oob(jm); |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
168 | |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
169 | if(body && body->len) { |
|
29840
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
170 | if (jid->resource) { |
|
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
171 | /* |
|
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
172 | * We received a message from a specific resource, so |
|
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
173 | * we probably want a reply to go to this specific |
|
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
174 | * resource (i.e. bind/lock the conversation to this |
|
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
175 | * resource). |
|
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
176 | * |
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
33722
diff
changeset
|
177 | * This works because purple_im_conversation_send gets the name |
|
29840
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
178 | * from purple_conversation_get_name() |
|
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
179 | */ |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40798
diff
changeset
|
180 | PurpleConversation *im; |
|
29840
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
181 | |
|
40997
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40885
diff
changeset
|
182 | im = purple_conversation_manager_find_im(manager, account, contact); |
|
40290
0a722071a754
Refactor jm->from to contact in handle_chat()
Koosha Khajehmoogahi <koosha@posteo.de>
parents:
39470
diff
changeset
|
183 | if (im && !purple_strequal(contact, |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40798
diff
changeset
|
184 | purple_conversation_get_name(im))) { |
|
29840
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
185 | purple_debug_info("jabber", "Binding conversation to %s\n", |
|
40290
0a722071a754
Refactor jm->from to contact in handle_chat()
Koosha Khajehmoogahi <koosha@posteo.de>
parents:
39470
diff
changeset
|
186 | contact); |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40798
diff
changeset
|
187 | purple_conversation_set_name(im, contact); |
|
29840
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
188 | } |
|
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
189 | } |
|
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
190 | |
| 8400 | 191 | if(jbr) { |
|
30239
88550c8e461b
jabber: Refined logic for determining "is typing" support.
Paul Aurich <darkrain42@pidgin.im>
parents:
30235
diff
changeset
|
192 | /* Treat SUPPORTED as a terminal with no escape :) */ |
|
88550c8e461b
jabber: Refined logic for determining "is typing" support.
Paul Aurich <darkrain42@pidgin.im>
parents:
30235
diff
changeset
|
193 | if (jbr->chat_states != JABBER_CHAT_STATES_SUPPORTED) { |
|
88550c8e461b
jabber: Refined logic for determining "is typing" support.
Paul Aurich <darkrain42@pidgin.im>
parents:
30235
diff
changeset
|
194 | if (jm->chat_state != JM_STATE_NONE) |
|
88550c8e461b
jabber: Refined logic for determining "is typing" support.
Paul Aurich <darkrain42@pidgin.im>
parents:
30235
diff
changeset
|
195 | jbr->chat_states = JABBER_CHAT_STATES_SUPPORTED; |
|
88550c8e461b
jabber: Refined logic for determining "is typing" support.
Paul Aurich <darkrain42@pidgin.im>
parents:
30235
diff
changeset
|
196 | else |
|
88550c8e461b
jabber: Refined logic for determining "is typing" support.
Paul Aurich <darkrain42@pidgin.im>
parents:
30235
diff
changeset
|
197 | jbr->chat_states = JABBER_CHAT_STATES_UNSUPPORTED; |
|
88550c8e461b
jabber: Refined logic for determining "is typing" support.
Paul Aurich <darkrain42@pidgin.im>
parents:
30235
diff
changeset
|
198 | } |
| 13708 | 199 | |
|
37423
d2f0259aa43f
Remove NULL-checks before free(). No functional change.
Michael McConville <mmcco@mykolab.com>
parents:
37153
diff
changeset
|
200 | g_free(jbr->thread_id); |
|
39470
92dbadc3c6e4
Fix jabber message thread handling.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39433
diff
changeset
|
201 | jbr->thread_id = g_strdup(jm->thread_id); |
| 8400 | 202 | } |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
203 | |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
204 | if(jm->forwarded) { |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
205 | flags |= PURPLE_MESSAGE_FORWARDED; |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
206 | } |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
207 | flags |= jm->outgoing ? PURPLE_MESSAGE_SEND : PURPLE_MESSAGE_RECV; |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
208 | |
|
41239
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
209 | purple_serv_got_im(gc, contact, body->str, flags, |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
210 | (time_t)g_date_time_to_unix(jm->sent)); |
| 7014 | 211 | } |
| 212 | ||
| 213 | jabber_id_free(jid); | |
|
38248
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
214 | |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
215 | if(body) |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
216 | g_string_free(body, TRUE); |
| 7014 | 217 | } |
| 218 | ||
| 7145 | 219 | static void handle_headline(JabberMessage *jm) |
| 220 | { | |
| 221 | char *title; | |
|
17819
862fe0f947a9
Added buzz support using a private extension. Maybe I should write a XEP about that.
Andreas Monitzer <am@adiumx.com>
parents:
17811
diff
changeset
|
222 | GString *body; |
| 7145 | 223 | |
|
17819
862fe0f947a9
Added buzz support using a private extension. Maybe I should write a XEP about that.
Andreas Monitzer <am@adiumx.com>
parents:
17811
diff
changeset
|
224 | if(!jm->xhtml && !jm->body) |
|
862fe0f947a9
Added buzz support using a private extension. Maybe I should write a XEP about that.
Andreas Monitzer <am@adiumx.com>
parents:
17811
diff
changeset
|
225 | return; /* ignore headlines without any content */ |
| 7145 | 226 | |
|
38248
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
227 | body = jm_body_with_oob(jm); |
| 7145 | 228 | title = g_strdup_printf(_("Message from %s"), jm->from); |
| 229 | ||
| 15884 | 230 | purple_notify_formatted(jm->js->gc, title, jm->subject ? jm->subject : title, |
| 7145 | 231 | NULL, body->str, NULL, NULL); |
| 232 | ||
| 233 | g_free(title); | |
| 234 | g_string_free(body, TRUE); | |
| 235 | } | |
| 236 | ||
| 237 | static void handle_groupchat(JabberMessage *jm) | |
| 7014 | 238 | { |
| 239 | JabberID *jid = jabber_id_new(jm->from); | |
| 7310 | 240 | JabberChat *chat; |
|
36108
69b4fce85ffa
Switch _purple_conversation_write_common and (writing|wrote)-(chat|im)-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36098
diff
changeset
|
241 | PurpleMessageFlags messageFlags = 0; |
| 7310 | 242 | |
| 243 | if(!jid) | |
| 244 | return; | |
| 245 | ||
| 246 | chat = jabber_chat_find(jm->js, jid->node, jid->domain); | |
| 7014 | 247 | |
| 248 | if(!chat) | |
| 249 | return; | |
| 250 | ||
| 7971 | 251 | if(jm->subject) { |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
252 | purple_chat_conversation_set_topic(chat->conv, jid->resource, |
| 7183 | 253 | jm->subject); |
|
33722
dd2cec2beaf6
Don't log system messages, that appear on *every* MUC entry/exit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32323
diff
changeset
|
254 | messageFlags |= PURPLE_MESSAGE_NO_LOG; |
| 7971 | 255 | if(!jm->xhtml && !jm->body) { |
| 9762 | 256 | char *msg, *tmp, *tmp2; |
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10607
diff
changeset
|
257 | tmp = g_markup_escape_text(jm->subject, -1); |
| 15884 | 258 | tmp2 = purple_markup_linkify(tmp); |
| 7971 | 259 | if(jid->resource) |
| 9762 | 260 | msg = g_strdup_printf(_("%s has set the topic to: %s"), jid->resource, tmp2); |
| 7971 | 261 | else |
| 9762 | 262 | msg = g_strdup_printf(_("The topic is: %s"), tmp2); |
|
36084
2172bd6dad3e
Add purple_conversation_write_system_message
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36077
diff
changeset
|
263 | purple_conversation_write_system_message(PURPLE_CONVERSATION(chat->conv), |
|
2172bd6dad3e
Add purple_conversation_write_system_message
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36077
diff
changeset
|
264 | msg, messageFlags); |
| 9762 | 265 | g_free(tmp); |
| 266 | g_free(tmp2); | |
| 7971 | 267 | g_free(msg); |
| 268 | } | |
| 269 | } | |
| 7014 | 270 | |
| 7630 | 271 | if(jm->xhtml || jm->body) { |
|
41239
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
272 | if(jid->resource) { |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
273 | time_t sent = (time_t)g_date_time_to_unix(jm->sent); |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
274 | |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35070
diff
changeset
|
275 | purple_serv_got_chat_in(jm->js->gc, chat->id, jid->resource, |
|
33722
dd2cec2beaf6
Don't log system messages, that appear on *every* MUC entry/exit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32323
diff
changeset
|
276 | messageFlags | (jm->delayed ? PURPLE_MESSAGE_DELAYED : 0), |
|
41239
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
277 | jm->xhtml ? jm->xhtml : jm->body, sent); |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
278 | } else if(chat->muc) { |
|
36084
2172bd6dad3e
Add purple_conversation_write_system_message
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36077
diff
changeset
|
279 | purple_conversation_write_system_message( |
|
2172bd6dad3e
Add purple_conversation_write_system_message
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36077
diff
changeset
|
280 | PURPLE_CONVERSATION(chat->conv), |
|
2172bd6dad3e
Add purple_conversation_write_system_message
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36077
diff
changeset
|
281 | jm->xhtml ? jm->xhtml : jm->body, messageFlags); |
|
41239
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
282 | } |
| 7630 | 283 | } |
| 284 | ||
| 7014 | 285 | jabber_id_free(jid); |
| 286 | } | |
| 287 | ||
| 7145 | 288 | static void handle_groupchat_invite(JabberMessage *jm) |
| 7014 | 289 | { |
| 7310 | 290 | GHashTable *components; |
| 7014 | 291 | JabberID *jid = jabber_id_new(jm->to); |
| 292 | ||
| 7310 | 293 | if(!jid) |
| 294 | return; | |
| 295 | ||
|
15598
834a88c83e95
Get rid of some unnecessary string duping
Mark Doliner <markdoliner@pidgin.im>
parents:
15587
diff
changeset
|
296 | components = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); |
| 7310 | 297 | |
|
15598
834a88c83e95
Get rid of some unnecessary string duping
Mark Doliner <markdoliner@pidgin.im>
parents:
15587
diff
changeset
|
298 | g_hash_table_replace(components, "room", g_strdup(jid->node)); |
|
834a88c83e95
Get rid of some unnecessary string duping
Mark Doliner <markdoliner@pidgin.im>
parents:
15587
diff
changeset
|
299 | g_hash_table_replace(components, "server", g_strdup(jid->domain)); |
|
834a88c83e95
Get rid of some unnecessary string duping
Mark Doliner <markdoliner@pidgin.im>
parents:
15587
diff
changeset
|
300 | g_hash_table_replace(components, "handle", g_strdup(jm->js->user->node)); |
|
834a88c83e95
Get rid of some unnecessary string duping
Mark Doliner <markdoliner@pidgin.im>
parents:
15587
diff
changeset
|
301 | g_hash_table_replace(components, "password", g_strdup(jm->password)); |
| 7014 | 302 | |
| 303 | jabber_id_free(jid); | |
| 35501 | 304 | purple_serv_got_chat_invite(jm->js->gc, jm->to, jm->from, jm->body, components); |
| 7014 | 305 | } |
| 306 | ||
| 7145 | 307 | static void handle_error(JabberMessage *jm) |
| 7014 | 308 | { |
| 309 | char *buf; | |
| 310 | ||
| 311 | if(!jm->body) | |
| 312 | return; | |
| 313 | ||
| 314 | buf = g_strdup_printf(_("Message delivery to %s failed: %s"), | |
|
13766
6b92ce47f7e5
[gaim-migrate @ 16176]
Daniel Atallah <datallah@pidgin.im>
parents:
13708
diff
changeset
|
315 | jm->from, jm->error ? jm->error : ""); |
| 7014 | 316 | |
|
16961
b6955f946f8f
s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@pidgin.im>
parents:
16946
diff
changeset
|
317 | purple_notify_formatted(jm->js->gc, _("XMPP Message Error"), _("XMPP Message Error"), buf, |
| 7944 | 318 | jm->xhtml ? jm->xhtml : jm->body, NULL, NULL); |
| 7014 | 319 | |
| 320 | g_free(buf); | |
| 321 | } | |
| 322 | ||
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
323 | static gchar * |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
324 | jabber_message_xml_to_string_strip_img_smileys(PurpleXmlNode *xhtml) |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
325 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
326 | gchar *markup = purple_xmlnode_to_str(xhtml, NULL); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
327 | int len = strlen(markup); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
328 | int pos = 0; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
329 | GString *out = g_string_new(NULL); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
330 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
331 | while (pos < len) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
332 | /* this is a bit cludgy, maybe there is a better way to do this... |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
333 | we need to find all <img> tags within the XHTML and replace those |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
334 | tags with the value of their "alt" attributes */ |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
335 | if (g_str_has_prefix(&(markup[pos]), "<img")) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
336 | PurpleXmlNode *img = NULL; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
337 | int pos2 = pos; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
338 | const gchar *src; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
339 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
340 | for (; pos2 < len ; pos2++) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
341 | if (g_str_has_prefix(&(markup[pos2]), "/>")) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
342 | pos2 += 2; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
343 | break; |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
344 | } else if (g_str_has_prefix(&(markup[pos2]), "</img>")) { |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
345 | pos2 += 5; |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
346 | break; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
347 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
348 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
349 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
350 | /* note, if the above loop didn't find the end of the <img> tag, |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
351 | it the parsed string will be until the end of the input string, |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
352 | in which case purple_xmlnode_from_str will bail out and return NULL, |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
353 | in this case the "if" statement below doesn't trigger and the |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
354 | text is copied unchanged */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
355 | img = purple_xmlnode_from_str(&(markup[pos]), pos2 - pos); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
356 | src = purple_xmlnode_get_attrib(img, "src"); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
357 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
358 | if (g_str_has_prefix(src, "cid:")) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
359 | const gchar *alt = purple_xmlnode_get_attrib(img, "alt"); |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
360 | /* if the "alt" attribute is empty, put the cid as smiley string */ |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
361 | if (alt && alt[0] != '\0') { |
|
24259
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
362 | /* if the "alt" is the same as the CID, as Jabbim does, |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
363 | this prevents linkification... */ |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
364 | if (purple_email_is_valid(alt)) { |
|
24386
0710eb7a41c5
A couple of compile warning fixes, a couple of memory leak plugs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24259
diff
changeset
|
365 | gchar *safe_alt = g_strdup_printf("smiley:%s", alt); |
|
24259
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
366 | out = g_string_append(out, safe_alt); |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
367 | g_free(safe_alt); |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
368 | } else { |
|
35783
dcff8ce68d1b
Remote smileys: fix a xmpp bug of non-escaped custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35764
diff
changeset
|
369 | gchar *alt_escaped = g_markup_escape_text(alt, -1); |
|
dcff8ce68d1b
Remote smileys: fix a xmpp bug of non-escaped custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35764
diff
changeset
|
370 | out = g_string_append(out, alt_escaped); |
|
dcff8ce68d1b
Remote smileys: fix a xmpp bug of non-escaped custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35764
diff
changeset
|
371 | g_free(alt_escaped); |
|
24259
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
372 | } |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
373 | } else { |
|
24258
9ae10fafad7a
When receiving an <img/> without the "alt" attribute, set
Marcus Lundblad <malu@pidgin.im>
parents:
24257
diff
changeset
|
374 | out = g_string_append(out, src); |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
375 | } |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
376 | pos += pos2 - pos; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
377 | } else { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
378 | out = g_string_append_c(out, markup[pos]); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
379 | pos++; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
380 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
381 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
382 | purple_xmlnode_free(img); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
383 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
384 | } else { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
385 | out = g_string_append_c(out, markup[pos]); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
386 | pos++; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
387 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
388 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
389 | |
|
24387
cba0cfba936e
Another memory leak fix. Also, keep a copy of the alt-text in
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24386
diff
changeset
|
390 | g_free(markup); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
391 | return g_string_free(out, FALSE); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
392 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
393 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
394 | void jabber_message_parse(JabberStream *js, PurpleXmlNode *packet) |
| 7014 | 395 | { |
| 396 | JabberMessage *jm; | |
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27061
diff
changeset
|
397 | const char *id, *from, *to, *type; |
|
40594
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
398 | PurpleXmlNode *child = NULL, *received = NULL; |
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27061
diff
changeset
|
399 | gboolean signal_return; |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
400 | gboolean delayed = FALSE, is_outgoing = FALSE, is_forwarded = FALSE; |
|
41239
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
401 | GDateTime *timestamp = g_date_time_new_now_utc(); |
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27061
diff
changeset
|
402 | |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
403 | /* Check if we have a carbons received element from our own account. */ |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
404 | from = purple_xmlnode_get_attrib(packet, "from"); |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
405 | if(from != NULL && jabber_is_own_account(js, from)) { |
|
40594
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
406 | PurpleXmlNode *forwarded = NULL; |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
407 | |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
408 | /* We check if this is a received carbon first. */ |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
409 | received = purple_xmlnode_get_child_with_namespace(packet, "received", |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
410 | NS_MESSAGE_CARBONS); |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
411 | if(received != NULL) { |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
412 | forwarded = purple_xmlnode_get_child_with_namespace(received, |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
413 | "forwarded", |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
414 | NS_FORWARD); |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
415 | } else { |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
416 | PurpleXmlNode *sent = NULL; |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
417 | |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
418 | sent = purple_xmlnode_get_child_with_namespace(packet, "sent", |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
419 | NS_MESSAGE_CARBONS); |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
420 | if(sent != NULL) { |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
421 | forwarded = purple_xmlnode_get_child_with_namespace(sent, |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
422 | "forwarded", |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
423 | NS_FORWARD); |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
424 | is_outgoing = TRUE; |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
425 | } |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
426 | } |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
427 | |
|
40594
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
428 | if(forwarded != NULL) { |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
429 | PurpleXmlNode *fwd_msg = NULL; |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
430 | |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
431 | fwd_msg = purple_xmlnode_get_child_with_namespace(forwarded, |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
432 | "message", |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
433 | NS_XMPP_CLIENT); |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
434 | if(fwd_msg != NULL) { |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
435 | PurpleXmlNode *delay = NULL; |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
436 | |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
437 | /* We have a forwarded message, so update the packet to point |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
438 | * to it directly. |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
439 | */ |
|
40594
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
440 | packet = fwd_msg; |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
441 | is_forwarded = TRUE; |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
442 | |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
443 | /* Now check if it was a delayed message and if so, grab the |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
444 | * timestamp that the server sent. |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
445 | */ |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
446 | delay = purple_xmlnode_get_child_with_namespace(forwarded, |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
447 | "delay", |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
448 | NS_DELAYED_DELIVERY); |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
449 | if(delay != NULL) { |
|
41239
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
450 | GDateTime *delayed_ts = NULL; |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
451 | GTimeZone *tz = g_time_zone_new_utc(); |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
452 | const gchar *ts = purple_xmlnode_get_attrib(delay, |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
453 | "stamp"); |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
454 | |
|
41239
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
455 | delayed_ts = g_date_time_new_from_iso8601(ts, tz); |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
456 | g_time_zone_unref(tz); |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
457 | |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
458 | if(delayed_ts != NULL) { |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
459 | delayed = TRUE; |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
460 | g_date_time_unref(timestamp); |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
461 | timestamp = delayed_ts; |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
462 | } |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
463 | } |
|
40594
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
464 | } |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
465 | } |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
466 | } |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
467 | |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
468 | /* If the message was forwarded, packet is now pointing to the forwarded |
|
40594
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
469 | * message. |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
470 | */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
471 | from = purple_xmlnode_get_attrib(packet, "from"); |
|
40594
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
472 | id = purple_xmlnode_get_attrib(packet, "id"); |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
473 | to = purple_xmlnode_get_attrib(packet, "to"); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
474 | type = purple_xmlnode_get_attrib(packet, "type"); |
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27061
diff
changeset
|
475 | |
|
36623
caaadef03507
Renamed purple_connection_get_protocol_info() to purple_connection_get_protocol()
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
476 | signal_return = GPOINTER_TO_INT(purple_signal_emit_return_1(purple_connection_get_protocol(js->gc), |
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27061
diff
changeset
|
477 | "jabber-receiving-message", js->gc, type, id, from, to, packet)); |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27061
diff
changeset
|
478 | if (signal_return) |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27061
diff
changeset
|
479 | return; |
| 7014 | 480 | |
| 481 | jm = g_new0(JabberMessage, 1); | |
| 482 | jm->js = js; | |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
483 | jm->sent = timestamp; |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
484 | jm->delayed = delayed; |
|
27429
3313d7d74962
Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
485 | jm->chat_state = JM_STATE_NONE; |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
486 | jm->forwarded = is_forwarded; |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
487 | jm->outgoing = is_outgoing; |
| 7014 | 488 | |
| 489 | if(type) { | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
490 | if(purple_strequal(type, "normal")) |
| 7014 | 491 | jm->type = JABBER_MESSAGE_NORMAL; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
492 | else if(purple_strequal(type, "chat")) |
| 7014 | 493 | jm->type = JABBER_MESSAGE_CHAT; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
494 | else if(purple_strequal(type, "groupchat")) |
| 7014 | 495 | jm->type = JABBER_MESSAGE_GROUPCHAT; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
496 | else if(purple_strequal(type, "headline")) |
| 7014 | 497 | jm->type = JABBER_MESSAGE_HEADLINE; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
498 | else if(purple_strequal(type, "error")) |
| 7014 | 499 | jm->type = JABBER_MESSAGE_ERROR; |
| 500 | else | |
| 501 | jm->type = JABBER_MESSAGE_OTHER; | |
| 502 | } else { | |
| 503 | jm->type = JABBER_MESSAGE_NORMAL; | |
| 504 | } | |
| 505 | ||
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27061
diff
changeset
|
506 | jm->from = g_strdup(from); |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27061
diff
changeset
|
507 | jm->to = g_strdup(to); |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27061
diff
changeset
|
508 | jm->id = g_strdup(id); |
| 7014 | 509 | |
| 510 | for(child = packet->child; child; child = child->next) { | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
511 | const char *xmlns = purple_xmlnode_get_namespace(child); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
512 | if(child->type != PURPLE_XMLNODE_TYPE_TAG) |
| 7014 | 513 | continue; |
| 514 | ||
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
515 | if(purple_strequal(child->name, "error")) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
516 | const char *code = purple_xmlnode_get_attrib(child, "code"); |
|
25154
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
517 | char *code_txt = NULL; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
518 | char *text = purple_xmlnode_get_data(child); |
|
25154
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
519 | if (!text) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
520 | PurpleXmlNode *enclosed_text_node; |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
521 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
522 | if ((enclosed_text_node = purple_xmlnode_get_child(child, "text"))) |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
523 | text = purple_xmlnode_get_data(enclosed_text_node); |
|
25154
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
524 | } |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
525 | |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
526 | if(code) |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
527 | code_txt = g_strdup_printf(_("(Code %s)"), code); |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
528 | |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
529 | if(!jm->error) |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
530 | jm->error = g_strdup_printf("%s%s%s", |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
531 | text ? text : "", |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
532 | text && code_txt ? " " : "", |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
533 | code_txt ? code_txt : ""); |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
534 | |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
535 | g_free(code_txt); |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
536 | g_free(text); |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
537 | } else if (xmlns == NULL) { |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
538 | /* QuLogic: Not certain this is correct, but it would have happened |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
539 | with the previous code. */ |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
540 | if(purple_strequal(child->name, "x")) |
|
25154
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
541 | jm->etc = g_list_append(jm->etc, child); |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
542 | /* The following tests expect xmlns != NULL */ |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
543 | continue; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
544 | } else if(purple_strequal(child->name, "subject") && purple_strequal(xmlns, NS_XMPP_CLIENT)) { |
|
26859
8175186cf34a
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents:
26711
diff
changeset
|
545 | if(!jm->subject) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
546 | jm->subject = purple_xmlnode_get_data(child); |
|
26859
8175186cf34a
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents:
26711
diff
changeset
|
547 | if(!jm->subject) |
|
8175186cf34a
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents:
26711
diff
changeset
|
548 | jm->subject = g_strdup(""); |
|
8175186cf34a
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents:
26711
diff
changeset
|
549 | } |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
550 | } else if(purple_strequal(child->name, "thread") && purple_strequal(xmlns, NS_XMPP_CLIENT)) { |
| 8400 | 551 | if(!jm->thread_id) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
552 | jm->thread_id = purple_xmlnode_get_data(child); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
553 | } else if(purple_strequal(child->name, "body") && purple_strequal(xmlns, NS_XMPP_CLIENT)) { |
| 13385 | 554 | if(!jm->body) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
555 | char *msg = purple_xmlnode_get_data(child); |
|
41940
fa0478036eaf
Remove purple_markup_escape_text
Gary Kramlich <grim@reaperworld.com>
parents:
41784
diff
changeset
|
556 | char *escaped = g_markup_escape_text(msg, -1); |
|
30583
2482f350d8f5
jabber: Fix the last commit to pass escaped text off to the core.
Paul Aurich <darkrain42@pidgin.im>
parents:
30582
diff
changeset
|
557 | jm->body = purple_strdup_withhtml(escaped); |
|
2482f350d8f5
jabber: Fix the last commit to pass escaped text off to the core.
Paul Aurich <darkrain42@pidgin.im>
parents:
30582
diff
changeset
|
558 | g_free(escaped); |
| 13385 | 559 | g_free(msg); |
| 560 | } | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
561 | } else if(purple_strequal(child->name, "html") && purple_strequal(xmlns, NS_XHTML_IM)) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
562 | if(!jm->xhtml && purple_xmlnode_get_child(child, "body")) { |
|
17328
7a5668fb7bad
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents:
16961
diff
changeset
|
563 | char *c; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
564 | gchar *reformatted_xhtml; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
565 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
566 | purple_xmlnode_strip_prefixes(child); |
|
32323
df78cc32b2cd
jabber: Strip element prefixes on XHTML-IM content.
Paul Aurich <darkrain42@pidgin.im>
parents:
32277
diff
changeset
|
567 | |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
568 | /* reformat xhtml so that img tags with a "cid:" src gets |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
569 | translated to the bare text of the emoticon (the "alt" attrib) */ |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
570 | /* this is done also when custom smiley retrieval is turned off, |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
571 | this way the receiver always sees the shortcut instead */ |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
572 | reformatted_xhtml = |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
573 | jabber_message_xml_to_string_strip_img_smileys(child); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
574 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
575 | jm->xhtml = reformatted_xhtml; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
576 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
577 | /* Convert all newlines to whitespace. Technically, even regular, non-XML HTML is supposed to ignore newlines, but Pidgin has, as convention |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
578 | * treated \n as a newline for compatibility with other protocols |
|
17328
7a5668fb7bad
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents:
16961
diff
changeset
|
579 | */ |
|
7a5668fb7bad
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents:
16961
diff
changeset
|
580 | for (c = jm->xhtml; *c != '\0'; c++) { |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
581 | if (*c == '\n') |
|
17328
7a5668fb7bad
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents:
16961
diff
changeset
|
582 | *c = ' '; |
|
7a5668fb7bad
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents:
16961
diff
changeset
|
583 | } |
|
7a5668fb7bad
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents:
16961
diff
changeset
|
584 | } |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
585 | } else if(purple_strequal(child->name, "active") && purple_strequal(xmlns,"http://jabber.org/protocol/chatstates")) { |
| 13708 | 586 | jm->chat_state = JM_STATE_ACTIVE; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
587 | } else if(purple_strequal(child->name, "composing") && purple_strequal(xmlns,"http://jabber.org/protocol/chatstates")) { |
| 13708 | 588 | jm->chat_state = JM_STATE_COMPOSING; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
589 | } else if(purple_strequal(child->name, "paused") && purple_strequal(xmlns,"http://jabber.org/protocol/chatstates")) { |
| 13708 | 590 | jm->chat_state = JM_STATE_PAUSED; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
591 | } else if(purple_strequal(child->name, "inactive") && purple_strequal(xmlns,"http://jabber.org/protocol/chatstates")) { |
| 13708 | 592 | jm->chat_state = JM_STATE_INACTIVE; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
593 | } else if(purple_strequal(child->name, "gone") && purple_strequal(xmlns,"http://jabber.org/protocol/chatstates")) { |
| 13708 | 594 | jm->chat_state = JM_STATE_GONE; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
595 | } else if(purple_strequal(child->name, "event") && purple_strequal(xmlns,"http://jabber.org/protocol/pubsub#event")) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
596 | PurpleXmlNode *items; |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17776
diff
changeset
|
597 | jm->type = JABBER_MESSAGE_EVENT; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
598 | for(items = purple_xmlnode_get_child(child,"items"); items; items = items->next) |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17776
diff
changeset
|
599 | jm->eventitems = g_list_append(jm->eventitems, items); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
600 | } else if(purple_strequal(child->name, "delay") && purple_strequal(xmlns, NS_DELAYED_DELIVERY)) { |
|
41239
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
601 | const char *stamp = purple_xmlnode_get_attrib(child, "stamp"); |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
602 | if(stamp != NULL) { |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
603 | GDateTime *delayed_ts = NULL; |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
604 | GTimeZone *tz = g_time_zone_new_utc(); |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
605 | |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
606 | delayed_ts = g_date_time_new_from_iso8601(stamp, tz); |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
607 | g_time_zone_unref(tz); |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
608 | |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
609 | if(delayed_ts != NULL) { |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
610 | jm->delayed = TRUE; |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
611 | g_date_time_unref(jm->sent); |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
612 | jm->sent = delayed_ts; |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
613 | } |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
614 | } |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
615 | } else if(purple_strequal(child->name, "x")) { |
|
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
616 | if(purple_strequal(xmlns, NS_DELAYED_DELIVERY_LEGACY)) { |
|
41239
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
617 | const char *stamp = purple_xmlnode_get_attrib(child, "stamp"); |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
618 | |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
619 | if(stamp != NULL) { |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
620 | GDateTime *delayed_ts = NULL; |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
621 | GTimeZone *tz = g_time_zone_new_utc(); |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
622 | |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
623 | delayed_ts = g_date_time_new_from_iso8601(stamp, tz); |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
624 | g_time_zone_unref(tz); |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
625 | |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
626 | if(delayed_ts != NULL) { |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
627 | jm->delayed = TRUE; |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
628 | g_date_time_unref(jm->sent); |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
629 | jm->sent = delayed_ts; |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
630 | } |
|
735f7114318d
Port JabberMessage->sent to GDateTime and use g_date_time_new_from_iso8601 instead of purple_str_to_time.
Gary Kramlich <grim@reaperworld.com>
parents:
41176
diff
changeset
|
631 | } |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
632 | } else if(purple_strequal(xmlns, "jabber:x:conference") && |
| 11230 | 633 | jm->type != JABBER_MESSAGE_GROUPCHAT_INVITE && |
| 634 | jm->type != JABBER_MESSAGE_ERROR) { | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
635 | const char *jid = purple_xmlnode_get_attrib(child, "jid"); |
| 7014 | 636 | if(jid) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
637 | const char *reason = purple_xmlnode_get_attrib(child, "reason"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
638 | const char *password = purple_xmlnode_get_attrib(child, "password"); |
|
28703
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
639 | |
| 7014 | 640 | jm->type = JABBER_MESSAGE_GROUPCHAT_INVITE; |
| 641 | g_free(jm->to); | |
| 642 | jm->to = g_strdup(jid); | |
|
28703
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
643 | |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
644 | if (reason) { |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
645 | g_free(jm->body); |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
646 | jm->body = g_strdup(reason); |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
647 | } |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
648 | |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
649 | if (password) { |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
650 | g_free(jm->password); |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
651 | jm->password = g_strdup(password); |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
652 | } |
| 7014 | 653 | } |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
654 | } else if(purple_strequal(xmlns, "http://jabber.org/protocol/muc#user") && |
| 11230 | 655 | jm->type != JABBER_MESSAGE_ERROR) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
656 | PurpleXmlNode *invite = purple_xmlnode_get_child(child, "invite"); |
| 7014 | 657 | if(invite) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
658 | PurpleXmlNode *reason, *password; |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
659 | const char *jid = purple_xmlnode_get_attrib(invite, "from"); |
| 7014 | 660 | g_free(jm->to); |
| 661 | jm->to = jm->from; | |
| 662 | jm->from = g_strdup(jid); | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
663 | if((reason = purple_xmlnode_get_child(invite, "reason"))) { |
| 7014 | 664 | g_free(jm->body); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
665 | jm->body = purple_xmlnode_get_data(reason); |
| 7014 | 666 | } |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
667 | if((password = purple_xmlnode_get_child(child, "password"))) { |
|
28703
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
668 | g_free(jm->password); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
669 | jm->password = purple_xmlnode_get_data(password); |
|
28703
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
670 | } |
| 7014 | 671 | |
| 672 | jm->type = JABBER_MESSAGE_GROUPCHAT_INVITE; | |
| 673 | } | |
| 7145 | 674 | } else { |
| 675 | jm->etc = g_list_append(jm->etc, child); | |
| 7014 | 676 | } |
|
38256
035f00c4fd87
Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
31512
diff
changeset
|
677 | } else if (purple_strequal(child->name, "query")) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
678 | const char *node = purple_xmlnode_get_attrib(child, "node"); |
|
28984
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28979
diff
changeset
|
679 | if (purple_strequal(xmlns, NS_DISCO_ITEMS) |
|
26871
d62964222795
Add a new signal which is emitted (after the account is connected) if the
Paul Aurich <darkrain42@pidgin.im>
parents:
26867
diff
changeset
|
680 | && purple_strequal(node, "http://jabber.org/protocol/commands")) { |
|
d62964222795
Add a new signal which is emitted (after the account is connected) if the
Paul Aurich <darkrain42@pidgin.im>
parents:
26867
diff
changeset
|
681 | jabber_adhoc_got_list(js, jm->from, child); |
|
d62964222795
Add a new signal which is emitted (after the account is connected) if the
Paul Aurich <darkrain42@pidgin.im>
parents:
26867
diff
changeset
|
682 | } |
| 7014 | 683 | } |
| 684 | } | |
| 685 | ||
| 686 | switch(jm->type) { | |
|
27900
23b6b4dfeb82
Allow fallback for broken XMPP <message/> types. Closes #7837.
Paul Aurich <darkrain42@pidgin.im>
parents:
27844
diff
changeset
|
687 | case JABBER_MESSAGE_OTHER: |
|
28828
7c1855f037e7
jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <darkrain42@pidgin.im>
parents:
28726
diff
changeset
|
688 | purple_debug_info("jabber", |
|
27900
23b6b4dfeb82
Allow fallback for broken XMPP <message/> types. Closes #7837.
Paul Aurich <darkrain42@pidgin.im>
parents:
27844
diff
changeset
|
689 | "Received message of unknown type: %s\n", type); |
|
41967
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41940
diff
changeset
|
690 | G_GNUC_FALLTHROUGH; |
| 7014 | 691 | case JABBER_MESSAGE_NORMAL: |
| 692 | case JABBER_MESSAGE_CHAT: | |
| 7145 | 693 | handle_chat(jm); |
| 694 | break; | |
| 7014 | 695 | case JABBER_MESSAGE_HEADLINE: |
| 7145 | 696 | handle_headline(jm); |
| 7014 | 697 | break; |
| 698 | case JABBER_MESSAGE_GROUPCHAT: | |
| 699 | handle_groupchat(jm); | |
| 700 | break; | |
| 701 | case JABBER_MESSAGE_GROUPCHAT_INVITE: | |
| 702 | handle_groupchat_invite(jm); | |
| 703 | break; | |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17776
diff
changeset
|
704 | case JABBER_MESSAGE_EVENT: |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17776
diff
changeset
|
705 | jabber_handle_event(jm); |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17776
diff
changeset
|
706 | break; |
| 7014 | 707 | case JABBER_MESSAGE_ERROR: |
| 708 | handle_error(jm); | |
| 709 | break; | |
| 710 | } | |
| 711 | jabber_message_free(jm); | |
| 712 | } | |
| 713 | ||
| 714 | void jabber_message_send(JabberMessage *jm) | |
| 715 | { | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
716 | PurpleXmlNode *message, *child; |
| 7014 | 717 | const char *type = NULL; |
| 718 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
719 | message = purple_xmlnode_new("message"); |
| 7014 | 720 | |
| 721 | switch(jm->type) { | |
| 722 | case JABBER_MESSAGE_NORMAL: | |
| 723 | type = "normal"; | |
| 724 | break; | |
| 725 | case JABBER_MESSAGE_CHAT: | |
| 726 | case JABBER_MESSAGE_GROUPCHAT_INVITE: | |
| 727 | type = "chat"; | |
| 728 | break; | |
| 729 | case JABBER_MESSAGE_HEADLINE: | |
| 730 | type = "headline"; | |
| 731 | break; | |
| 732 | case JABBER_MESSAGE_GROUPCHAT: | |
| 733 | type = "groupchat"; | |
| 734 | break; | |
| 735 | case JABBER_MESSAGE_ERROR: | |
| 736 | type = "error"; | |
| 737 | break; | |
| 738 | case JABBER_MESSAGE_OTHER: | |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17776
diff
changeset
|
739 | default: |
| 7014 | 740 | type = NULL; |
| 741 | break; | |
| 742 | } | |
| 743 | ||
| 744 | if(type) | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
745 | purple_xmlnode_set_attrib(message, "type", type); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
746 | |
| 13484 | 747 | if (jm->id) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
748 | purple_xmlnode_set_attrib(message, "id", jm->id); |
| 7014 | 749 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
750 | purple_xmlnode_set_attrib(message, "to", jm->to); |
| 7014 | 751 | |
| 8400 | 752 | if(jm->thread_id) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
753 | child = purple_xmlnode_new_child(message, "thread"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
754 | purple_xmlnode_insert_data(child, jm->thread_id, -1); |
| 8400 | 755 | } |
| 756 | ||
| 27432 | 757 | child = NULL; |
| 758 | switch(jm->chat_state) | |
| 759 | { | |
| 760 | case JM_STATE_ACTIVE: | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
761 | child = purple_xmlnode_new_child(message, "active"); |
| 27432 | 762 | break; |
| 763 | case JM_STATE_COMPOSING: | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
764 | child = purple_xmlnode_new_child(message, "composing"); |
| 27432 | 765 | break; |
| 766 | case JM_STATE_PAUSED: | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
767 | child = purple_xmlnode_new_child(message, "paused"); |
| 27432 | 768 | break; |
| 769 | case JM_STATE_INACTIVE: | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
770 | child = purple_xmlnode_new_child(message, "inactive"); |
| 27432 | 771 | break; |
| 772 | case JM_STATE_GONE: | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
773 | child = purple_xmlnode_new_child(message, "gone"); |
| 27432 | 774 | break; |
| 775 | case JM_STATE_NONE: | |
| 776 | /* yep, nothing */ | |
| 777 | break; | |
| 7014 | 778 | } |
| 27432 | 779 | if(child) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
780 | purple_xmlnode_set_namespace(child, "http://jabber.org/protocol/chatstates"); |
| 13708 | 781 | |
| 7014 | 782 | if(jm->subject) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
783 | child = purple_xmlnode_new_child(message, "subject"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
784 | purple_xmlnode_insert_data(child, jm->subject, -1); |
| 7014 | 785 | } |
| 786 | ||
| 787 | if(jm->body) { | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
788 | child = purple_xmlnode_new_child(message, "body"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
789 | purple_xmlnode_insert_data(child, jm->body, -1); |
| 7014 | 790 | } |
| 791 | ||
| 792 | if(jm->xhtml) { | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
793 | if ((child = purple_xmlnode_from_str(jm->xhtml, -1))) { |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
794 | purple_xmlnode_insert_child(message, child); |
| 7014 | 795 | } else { |
|
28828
7c1855f037e7
jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <darkrain42@pidgin.im>
parents:
28726
diff
changeset
|
796 | purple_debug_error("jabber", |
| 7014 | 797 | "XHTML translation/validation failed, returning: %s\n", |
| 798 | jm->xhtml); | |
| 799 | } | |
| 800 | } | |
| 801 | ||
| 802 | jabber_send(jm->js, message); | |
| 803 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
804 | purple_xmlnode_free(message); |
| 7014 | 805 | } |
| 806 | ||
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
807 | /* |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
808 | * Compare the XHTML and plain strings passed in for "equality". Any HTML markup |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
809 | * other than <br/> (matches a newline) in the XHTML will cause this to return |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
810 | * FALSE. |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
811 | */ |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
812 | static gboolean |
|
40293
c60c4f96749d
Fix some line wrapping
Richard Laager <rlaager@pidgin.im>
parents:
40290
diff
changeset
|
813 | jabber_xhtml_plain_equal(const char *xhtml_escaped, const char *plain) |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
814 | { |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
815 | int i = 0; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
816 | int j = 0; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
817 | gboolean ret; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
818 | char *xhtml = purple_unescape_html(xhtml_escaped); |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
819 | |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
820 | while (xhtml[i] && plain[j]) { |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
821 | if (xhtml[i] == plain[j]) { |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
822 | i += 1; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
823 | j += 1; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
824 | continue; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
825 | } |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
826 | |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
827 | if (plain[j] == '\n' && !strncmp(xhtml+i, "<br/>", 5)) { |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
828 | i += 5; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
829 | j += 1; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
830 | continue; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
831 | } |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
832 | |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
833 | g_free(xhtml); |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
834 | return FALSE; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
835 | } |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
836 | |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
837 | /* Are we at the end of both strings? */ |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
838 | ret = (xhtml[i] == plain[j]) && (xhtml[i] == '\0'); |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
839 | g_free(xhtml); |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
840 | return ret; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
841 | } |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
842 | |
|
41967
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41940
diff
changeset
|
843 | int |
|
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41940
diff
changeset
|
844 | jabber_message_send_im(G_GNUC_UNUSED PurpleProtocolIM *pim, |
|
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41940
diff
changeset
|
845 | PurpleConnection *gc, PurpleMessage *msg) |
| 7014 | 846 | { |
| 847 | JabberMessage *jm; | |
| 848 | JabberBuddy *jb; | |
| 849 | JabberBuddyResource *jbr; | |
| 7135 | 850 | char *xhtml; |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
851 | char *tmp; |
| 7306 | 852 | char *resource; |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
853 | const gchar *rcpt = purple_message_get_recipient(msg); |
| 7014 | 854 | |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
855 | if (!rcpt || purple_message_is_empty(msg)) |
| 7014 | 856 | return 0; |
| 857 | ||
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
858 | resource = jabber_get_resource(rcpt); |
|
31512
b1c0ce2787e6
jabber: Verbose printing of the exact message passed in to jabber_message_send_im.
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
859 | |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
860 | jb = jabber_buddy_find(purple_connection_get_protocol_data(gc), rcpt, TRUE); |
| 7306 | 861 | jbr = jabber_buddy_find_resource(jb, resource); |
| 862 | ||
| 863 | g_free(resource); | |
| 7014 | 864 | |
| 865 | jm = g_new0(JabberMessage, 1); | |
|
32277
97f16af01a05
Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
31512
diff
changeset
|
866 | jm->js = purple_connection_get_protocol_data(gc); |
| 7014 | 867 | jm->type = JABBER_MESSAGE_CHAT; |
| 13708 | 868 | jm->chat_state = JM_STATE_ACTIVE; |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
869 | jm->to = g_strdup(rcpt); |
| 13484 | 870 | jm->id = jabber_get_next_id(jm->js); |
| 13708 | 871 | |
| 872 | if(jbr) { | |
| 873 | if(jbr->thread_id) | |
| 874 | jm->thread_id = jbr->thread_id; | |
| 875 | ||
|
27429
3313d7d74962
Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
876 | if (jbr->chat_states == JABBER_CHAT_STATES_UNSUPPORTED) |
|
3313d7d74962
Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
877 | jm->chat_state = JM_STATE_NONE; |
|
3313d7d74962
Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
878 | else { |
| 13708 | 879 | /* if(JABBER_CHAT_STATES_UNKNOWN == jbr->chat_states) |
| 880 | jbr->chat_states = JABBER_CHAT_STATES_UNSUPPORTED; */ | |
| 881 | } | |
| 882 | } | |
| 7014 | 883 | |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35838
diff
changeset
|
884 | tmp = purple_utf8_strip_unprintables(purple_message_get_contents(msg)); |
|
27237
0643ac0e5658
Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages.
Paul Aurich <darkrain42@pidgin.im>
parents:
27155
diff
changeset
|
885 | purple_markup_html_to_xhtml(tmp, &xhtml, &jm->body); |
|
0643ac0e5658
Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages.
Paul Aurich <darkrain42@pidgin.im>
parents:
27155
diff
changeset
|
886 | g_free(tmp); |
|
29229
1fd36e207795
jabber: Wrap XHTML-IM messages in <p/> for greater interoperability justice. Closes #11253
Paul Aurich <darkrain42@pidgin.im>
parents:
28996
diff
changeset
|
887 | |
|
27746
4b3f015977d9
For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
888 | /* |
|
4b3f015977d9
For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
889 | * For backward compatibility with user expectations or for those not on |
|
4b3f015977d9
For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
890 | * the user's roster, allow sending XHTML-IM markup. |
|
4b3f015977d9
For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
891 | */ |
|
41784
f864fee87775
Remove support for XEP 0115 Legacy Format
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41239
diff
changeset
|
892 | if (jbr == NULL || jbr->caps == NULL || |
|
28984
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28979
diff
changeset
|
893 | jabber_resource_has_capability(jbr, NS_XHTML_IM)) { |
|
27746
4b3f015977d9
For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
894 | if (!jabber_xhtml_plain_equal(xhtml, jm->body)) |
|
29229
1fd36e207795
jabber: Wrap XHTML-IM messages in <p/> for greater interoperability justice. Closes #11253
Paul Aurich <darkrain42@pidgin.im>
parents:
28996
diff
changeset
|
895 | /* Wrap the message in <p/> for great interoperability justice. */ |
|
1fd36e207795
jabber: Wrap XHTML-IM messages in <p/> for greater interoperability justice. Closes #11253
Paul Aurich <darkrain42@pidgin.im>
parents:
28996
diff
changeset
|
896 | jm->xhtml = g_strdup_printf("<html xmlns='" NS_XHTML_IM "'><body xmlns='" NS_XHTML "'><p>%s</p></body></html>", xhtml); |
|
27746
4b3f015977d9
For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
897 | } |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
898 | |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
899 | g_free(xhtml); |
| 7014 | 900 | |
| 901 | jabber_message_send(jm); | |
| 902 | jabber_message_free(jm); | |
| 903 | return 1; | |
| 904 | } | |
| 905 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40594
diff
changeset
|
906 | gint |
|
41967
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41940
diff
changeset
|
907 | jabber_message_send_chat(G_GNUC_UNUSED PurpleProtocolChat *protocol_chat, |
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40594
diff
changeset
|
908 | PurpleConnection *gc, gint id, PurpleMessage *msg) |
| 7014 | 909 | { |
| 910 | JabberChat *chat; | |
| 911 | JabberMessage *jm; | |
| 8042 | 912 | JabberStream *js; |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
913 | char *xhtml; |
|
27110
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27103
diff
changeset
|
914 | char *tmp; |
| 7014 | 915 | |
|
36077
b7328f4317c7
Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36076
diff
changeset
|
916 | if (!gc || purple_message_is_empty(msg)) |
| 7014 | 917 | return 0; |
| 918 | ||
|
32277
97f16af01a05
Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
31512
diff
changeset
|
919 | js = purple_connection_get_protocol_data(gc); |
| 7014 | 920 | chat = jabber_chat_find_by_id(js, id); |
| 921 | ||
| 8043 | 922 | if(!chat) |
| 923 | return 0; | |
| 924 | ||
| 9130 | 925 | jm = g_new0(JabberMessage, 1); |
|
32277
97f16af01a05
Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
31512
diff
changeset
|
926 | jm->js = purple_connection_get_protocol_data(gc); |
| 9130 | 927 | jm->type = JABBER_MESSAGE_GROUPCHAT; |
| 928 | jm->to = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 13484 | 929 | jm->id = jabber_get_next_id(jm->js); |
| 9130 | 930 | |
|
36077
b7328f4317c7
Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36076
diff
changeset
|
931 | tmp = purple_utf8_strip_unprintables(purple_message_get_contents(msg)); |
|
28534
df58e9ce5eca
Oops, it helps to actually use the stripped message.
Paul Aurich <darkrain42@pidgin.im>
parents:
28442
diff
changeset
|
932 | purple_markup_html_to_xhtml(tmp, &xhtml, &jm->body); |
|
27237
0643ac0e5658
Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages.
Paul Aurich <darkrain42@pidgin.im>
parents:
27155
diff
changeset
|
933 | g_free(tmp); |
| 8858 | 934 | |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
935 | if (chat->xhtml && !jabber_xhtml_plain_equal(xhtml, jm->body)) |
|
29229
1fd36e207795
jabber: Wrap XHTML-IM messages in <p/> for greater interoperability justice. Closes #11253
Paul Aurich <darkrain42@pidgin.im>
parents:
28996
diff
changeset
|
936 | /* Wrap the message in <p/> for greater interoperability justice. */ |
|
1fd36e207795
jabber: Wrap XHTML-IM messages in <p/> for greater interoperability justice. Closes #11253
Paul Aurich <darkrain42@pidgin.im>
parents:
28996
diff
changeset
|
937 | jm->xhtml = g_strdup_printf("<html xmlns='" NS_XHTML_IM "'><body xmlns='" NS_XHTML "'><p>%s</p></body></html>", xhtml); |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
938 | |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
939 | g_free(xhtml); |
| 7923 | 940 | |
| 9130 | 941 | jabber_message_send(jm); |
| 942 | jabber_message_free(jm); | |
| 943 | ||
| 7014 | 944 | return 1; |
| 945 | } | |
| 946 | ||
|
41967
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41940
diff
changeset
|
947 | unsigned int |
|
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41940
diff
changeset
|
948 | jabber_send_typing(G_GNUC_UNUSED PurpleProtocolIM *pim, PurpleConnection *gc, |
|
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41940
diff
changeset
|
949 | const char *who, PurpleIMTypingState state) |
| 7014 | 950 | { |
|
30454
4e9bf65cfe9a
jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents:
30239
diff
changeset
|
951 | JabberStream *js; |
| 7014 | 952 | JabberMessage *jm; |
| 953 | JabberBuddy *jb; | |
| 954 | JabberBuddyResource *jbr; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30744
diff
changeset
|
955 | char *resource; |
| 7014 | 956 | |
|
30454
4e9bf65cfe9a
jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents:
30239
diff
changeset
|
957 | js = purple_connection_get_protocol_data(gc); |
|
4e9bf65cfe9a
jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents:
30239
diff
changeset
|
958 | jb = jabber_buddy_find(js, who, TRUE); |
|
4e9bf65cfe9a
jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents:
30239
diff
changeset
|
959 | if (!jb) |
|
4e9bf65cfe9a
jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents:
30239
diff
changeset
|
960 | return 0; |
|
4e9bf65cfe9a
jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents:
30239
diff
changeset
|
961 | |
|
4e9bf65cfe9a
jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents:
30239
diff
changeset
|
962 | resource = jabber_get_resource(who); |
| 7306 | 963 | jbr = jabber_buddy_find_resource(jb, resource); |
| 964 | g_free(resource); | |
| 7014 | 965 | |
|
30235
d37c441d6a48
jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <darkrain42@pidgin.im>
parents:
30121
diff
changeset
|
966 | /* We know this entity doesn't support chat states */ |
|
d37c441d6a48
jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <darkrain42@pidgin.im>
parents:
30121
diff
changeset
|
967 | if (jbr && jbr->chat_states == JABBER_CHAT_STATES_UNSUPPORTED) |
|
d37c441d6a48
jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <darkrain42@pidgin.im>
parents:
30121
diff
changeset
|
968 | return 0; |
|
d37c441d6a48
jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <darkrain42@pidgin.im>
parents:
30121
diff
changeset
|
969 | |
|
d37c441d6a48
jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <darkrain42@pidgin.im>
parents:
30121
diff
changeset
|
970 | /* *If* we don't have presence /and/ the buddy can't see our |
|
d37c441d6a48
jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <darkrain42@pidgin.im>
parents:
30121
diff
changeset
|
971 | * presence, don't send typing notifications. |
|
d37c441d6a48
jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <darkrain42@pidgin.im>
parents:
30121
diff
changeset
|
972 | */ |
|
d37c441d6a48
jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <darkrain42@pidgin.im>
parents:
30121
diff
changeset
|
973 | if (!jbr && !(jb->subscription & JABBER_SUB_FROM)) |
| 7014 | 974 | return 0; |
| 975 | ||
| 13708 | 976 | /* TODO: figure out threading */ |
| 7014 | 977 | jm = g_new0(JabberMessage, 1); |
|
30454
4e9bf65cfe9a
jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents:
30239
diff
changeset
|
978 | jm->js = js; |
| 7014 | 979 | jm->type = JABBER_MESSAGE_CHAT; |
| 980 | jm->to = g_strdup(who); | |
| 13484 | 981 | jm->id = jabber_get_next_id(jm->js); |
| 7014 | 982 | |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34634
diff
changeset
|
983 | if(PURPLE_IM_TYPING == state) |
| 13708 | 984 | jm->chat_state = JM_STATE_COMPOSING; |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34634
diff
changeset
|
985 | else if(PURPLE_IM_TYPED == state) |
| 13708 | 986 | jm->chat_state = JM_STATE_PAUSED; |
| 987 | else | |
| 988 | jm->chat_state = JM_STATE_ACTIVE; | |
| 989 | ||
|
27429
3313d7d74962
Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
990 | /* if(JABBER_CHAT_STATES_UNKNOWN == jbr->chat_states) |
|
3313d7d74962
Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
991 | jbr->chat_states = JABBER_CHAT_STATES_UNSUPPORTED; */ |
| 7014 | 992 | |
| 993 | jabber_message_send(jm); | |
| 994 | jabber_message_free(jm); | |
| 995 | ||
| 13708 | 996 | return 0; |
| 7014 | 997 | } |