Tue, 02 Nov 2021 00:30:07 -0500
Fix some bugs with proxies for xmpp
Testing Done:
Compiled and ran, was unable to get it to actually use charles proxy though.
Reviewed at https://reviews.imfreedom.org/r/1118/
| 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 | |
| 93 | g_free(jm); | |
| 94 | } | |
| 95 | ||
| 7145 | 96 | static void handle_chat(JabberMessage *jm) |
| 7014 | 97 | { |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
98 | 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
|
99 | JabberID *jid = jabber_id_new(contact); |
| 7014 | 100 | |
|
29331
9e828e599fc2
jabber: Use some convenience variables here.
Paul Aurich <darkrain42@pidgin.im>
parents:
29330
diff
changeset
|
101 | PurpleConnection *gc; |
|
40997
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40885
diff
changeset
|
102 | PurpleConversationManager *manager; |
|
29331
9e828e599fc2
jabber: Use some convenience variables here.
Paul Aurich <darkrain42@pidgin.im>
parents:
29330
diff
changeset
|
103 | PurpleAccount *account; |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
104 | PurpleMessageFlags flags = 0; |
| 7014 | 105 | JabberBuddy *jb; |
| 106 | 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
|
107 | GString *body; |
| 7014 | 108 | |
| 7310 | 109 | if(!jid) |
| 110 | return; | |
| 111 | ||
|
40997
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40885
diff
changeset
|
112 | 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
|
113 | |
|
29331
9e828e599fc2
jabber: Use some convenience variables here.
Paul Aurich <darkrain42@pidgin.im>
parents:
29330
diff
changeset
|
114 | gc = jm->js->gc; |
|
9e828e599fc2
jabber: Use some convenience variables here.
Paul Aurich <darkrain42@pidgin.im>
parents:
29330
diff
changeset
|
115 | account = purple_connection_get_account(gc); |
|
9e828e599fc2
jabber: Use some convenience variables here.
Paul Aurich <darkrain42@pidgin.im>
parents:
29330
diff
changeset
|
116 | |
|
40290
0a722071a754
Refactor jm->from to contact in handle_chat()
Koosha Khajehmoogahi <koosha@posteo.de>
parents:
39470
diff
changeset
|
117 | jb = jabber_buddy_find(jm->js, contact, TRUE); |
| 7306 | 118 | jbr = jabber_buddy_find_resource(jb, jid->resource); |
| 7014 | 119 | |
|
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
|
120 | 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
|
121 | 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
|
122 | |
|
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
|
123 | 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
|
124 | case JM_STATE_COMPOSING: |
|
40290
0a722071a754
Refactor jm->from to contact in handle_chat()
Koosha Khajehmoogahi <koosha@posteo.de>
parents:
39470
diff
changeset
|
125 | 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
|
126 | 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
|
127 | case JM_STATE_PAUSED: |
|
40290
0a722071a754
Refactor jm->from to contact in handle_chat()
Koosha Khajehmoogahi <koosha@posteo.de>
parents:
39470
diff
changeset
|
128 | 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
|
129 | 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
|
130 | 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
|
131 | PurpleConversation *im = NULL; |
|
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40885
diff
changeset
|
132 | |
|
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40885
diff
changeset
|
133 | 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
|
134 | |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
135 | 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
|
136 | char buf[256]; |
| 15884 | 137 | 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
|
138 | |
|
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
139 | 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
|
140 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
141 | 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
|
142 | 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
|
143 | char *escaped; |
|
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
144 | |
| 15884 | 145 | 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
|
146 | 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
|
147 | |
|
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
148 | g_snprintf(buf, sizeof(buf), |
| 16946 | 149 | _("%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
|
150 | 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
|
151 | |
| 15884 | 152 | /* 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
|
153 | * 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
|
154 | * 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
|
155 | 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
|
156 | } |
|
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
|
157 | } |
|
40290
0a722071a754
Refactor jm->from to contact in handle_chat()
Koosha Khajehmoogahi <koosha@posteo.de>
parents:
39470
diff
changeset
|
158 | 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
|
159 | 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
|
160 | } |
|
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 | default: |
|
40290
0a722071a754
Refactor jm->from to contact in handle_chat()
Koosha Khajehmoogahi <koosha@posteo.de>
parents:
39470
diff
changeset
|
162 | 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
|
163 | } |
|
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
|
164 | |
|
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 | 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
|
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 | 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
|
168 | 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
|
169 | /* |
|
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 | * 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
|
171 | * 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
|
172 | * 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
|
173 | * 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
|
174 | * |
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
33722
diff
changeset
|
175 | * 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
|
176 | * 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
|
177 | */ |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40798
diff
changeset
|
178 | 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
|
179 | |
|
40997
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40885
diff
changeset
|
180 | 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
|
181 | 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
|
182 | 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
|
183 | 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
|
184 | contact); |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40798
diff
changeset
|
185 | 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
|
186 | } |
|
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
|
187 | } |
|
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 | |
| 8400 | 189 | if(jbr) { |
|
30239
88550c8e461b
jabber: Refined logic for determining "is typing" support.
Paul Aurich <darkrain42@pidgin.im>
parents:
30235
diff
changeset
|
190 | /* 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
|
191 | 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
|
192 | 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
|
193 | 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 | else |
|
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_UNSUPPORTED; |
|
88550c8e461b
jabber: Refined logic for determining "is typing" support.
Paul Aurich <darkrain42@pidgin.im>
parents:
30235
diff
changeset
|
196 | } |
| 13708 | 197 | |
|
37423
d2f0259aa43f
Remove NULL-checks before free(). No functional change.
Michael McConville <mmcco@mykolab.com>
parents:
37153
diff
changeset
|
198 | g_free(jbr->thread_id); |
|
39470
92dbadc3c6e4
Fix jabber message thread handling.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39433
diff
changeset
|
199 | jbr->thread_id = g_strdup(jm->thread_id); |
| 8400 | 200 | } |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
201 | |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
202 | if(jm->forwarded) { |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
203 | flags |= PURPLE_MESSAGE_FORWARDED; |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
204 | } |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
205 | 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
|
206 | |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
207 | purple_serv_got_im(gc, contact, body->str, flags, jm->sent); |
| 7014 | 208 | } |
| 209 | ||
| 210 | 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
|
211 | |
|
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
|
212 | 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
|
213 | g_string_free(body, TRUE); |
| 7014 | 214 | } |
| 215 | ||
| 7145 | 216 | static void handle_headline(JabberMessage *jm) |
| 217 | { | |
| 218 | 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
|
219 | GString *body; |
| 7145 | 220 | |
|
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
|
221 | 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
|
222 | return; /* ignore headlines without any content */ |
| 7145 | 223 | |
|
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
|
224 | body = jm_body_with_oob(jm); |
| 7145 | 225 | title = g_strdup_printf(_("Message from %s"), jm->from); |
| 226 | ||
| 15884 | 227 | purple_notify_formatted(jm->js->gc, title, jm->subject ? jm->subject : title, |
| 7145 | 228 | NULL, body->str, NULL, NULL); |
| 229 | ||
| 230 | g_free(title); | |
| 231 | g_string_free(body, TRUE); | |
| 232 | } | |
| 233 | ||
| 234 | static void handle_groupchat(JabberMessage *jm) | |
| 7014 | 235 | { |
| 236 | JabberID *jid = jabber_id_new(jm->from); | |
| 7310 | 237 | 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
|
238 | PurpleMessageFlags messageFlags = 0; |
| 7310 | 239 | |
| 240 | if(!jid) | |
| 241 | return; | |
| 242 | ||
| 243 | chat = jabber_chat_find(jm->js, jid->node, jid->domain); | |
| 7014 | 244 | |
| 245 | if(!chat) | |
| 246 | return; | |
| 247 | ||
| 7971 | 248 | if(jm->subject) { |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
249 | purple_chat_conversation_set_topic(chat->conv, jid->resource, |
| 7183 | 250 | 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
|
251 | messageFlags |= PURPLE_MESSAGE_NO_LOG; |
| 7971 | 252 | if(!jm->xhtml && !jm->body) { |
| 9762 | 253 | char *msg, *tmp, *tmp2; |
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10607
diff
changeset
|
254 | tmp = g_markup_escape_text(jm->subject, -1); |
| 15884 | 255 | tmp2 = purple_markup_linkify(tmp); |
| 7971 | 256 | if(jid->resource) |
| 9762 | 257 | msg = g_strdup_printf(_("%s has set the topic to: %s"), jid->resource, tmp2); |
| 7971 | 258 | else |
| 9762 | 259 | 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
|
260 | 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
|
261 | msg, messageFlags); |
| 9762 | 262 | g_free(tmp); |
| 263 | g_free(tmp2); | |
| 7971 | 264 | g_free(msg); |
| 265 | } | |
| 266 | } | |
| 7014 | 267 | |
| 7630 | 268 | if(jm->xhtml || jm->body) { |
| 269 | if(jid->resource) | |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35070
diff
changeset
|
270 | 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
|
271 | messageFlags | (jm->delayed ? PURPLE_MESSAGE_DELAYED : 0), |
| 7630 | 272 | jm->xhtml ? jm->xhtml : jm->body, jm->sent); |
| 273 | else if(chat->muc) | |
|
36084
2172bd6dad3e
Add purple_conversation_write_system_message
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36077
diff
changeset
|
274 | purple_conversation_write_system_message( |
|
2172bd6dad3e
Add purple_conversation_write_system_message
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36077
diff
changeset
|
275 | PURPLE_CONVERSATION(chat->conv), |
|
2172bd6dad3e
Add purple_conversation_write_system_message
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36077
diff
changeset
|
276 | jm->xhtml ? jm->xhtml : jm->body, messageFlags); |
| 7630 | 277 | } |
| 278 | ||
| 7014 | 279 | jabber_id_free(jid); |
| 280 | } | |
| 281 | ||
| 7145 | 282 | static void handle_groupchat_invite(JabberMessage *jm) |
| 7014 | 283 | { |
| 7310 | 284 | GHashTable *components; |
| 7014 | 285 | JabberID *jid = jabber_id_new(jm->to); |
| 286 | ||
| 7310 | 287 | if(!jid) |
| 288 | return; | |
| 289 | ||
|
15598
834a88c83e95
Get rid of some unnecessary string duping
Mark Doliner <markdoliner@pidgin.im>
parents:
15587
diff
changeset
|
290 | components = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); |
| 7310 | 291 | |
|
15598
834a88c83e95
Get rid of some unnecessary string duping
Mark Doliner <markdoliner@pidgin.im>
parents:
15587
diff
changeset
|
292 | 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
|
293 | 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
|
294 | 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
|
295 | g_hash_table_replace(components, "password", g_strdup(jm->password)); |
| 7014 | 296 | |
| 297 | jabber_id_free(jid); | |
| 35501 | 298 | purple_serv_got_chat_invite(jm->js->gc, jm->to, jm->from, jm->body, components); |
| 7014 | 299 | } |
| 300 | ||
| 7145 | 301 | static void handle_error(JabberMessage *jm) |
| 7014 | 302 | { |
| 303 | char *buf; | |
| 304 | ||
| 305 | if(!jm->body) | |
| 306 | return; | |
| 307 | ||
| 308 | buf = g_strdup_printf(_("Message delivery to %s failed: %s"), | |
|
13766
6b92ce47f7e5
[gaim-migrate @ 16176]
Daniel Atallah <datallah@pidgin.im>
parents:
13708
diff
changeset
|
309 | jm->from, jm->error ? jm->error : ""); |
| 7014 | 310 | |
|
16961
b6955f946f8f
s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@pidgin.im>
parents:
16946
diff
changeset
|
311 | purple_notify_formatted(jm->js->gc, _("XMPP Message Error"), _("XMPP Message Error"), buf, |
| 7944 | 312 | jm->xhtml ? jm->xhtml : jm->body, NULL, NULL); |
| 7014 | 313 | |
| 314 | g_free(buf); | |
| 315 | } | |
| 316 | ||
|
17822
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
317 | static void handle_buzz(JabberMessage *jm) { |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
318 | PurpleAccount *account; |
|
25316
8b6461a2f967
Use purple_prpl_got_attention() for XMPP notifications
Evan Schoenberg <evands@pidgin.im>
parents:
25154
diff
changeset
|
319 | |
|
17823
2ca25e7e65dd
Switched buzz namespace and tag name to be libpurple-specific and use a more professionally-sounding name ('attention' instead of 'buzz').
Andreas Monitzer <am@adiumx.com>
parents:
17822
diff
changeset
|
320 | /* Delayed buzz MUST NOT be accepted */ |
|
2ca25e7e65dd
Switched buzz namespace and tag name to be libpurple-specific and use a more professionally-sounding name ('attention' instead of 'buzz').
Andreas Monitzer <am@adiumx.com>
parents:
17822
diff
changeset
|
321 | if(jm->delayed) |
|
2ca25e7e65dd
Switched buzz namespace and tag name to be libpurple-specific and use a more professionally-sounding name ('attention' instead of 'buzz').
Andreas Monitzer <am@adiumx.com>
parents:
17822
diff
changeset
|
322 | return; |
|
25316
8b6461a2f967
Use purple_prpl_got_attention() for XMPP notifications
Evan Schoenberg <evands@pidgin.im>
parents:
25154
diff
changeset
|
323 | |
|
17824
52683dfc1f7d
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents:
17823
diff
changeset
|
324 | /* Reject buzz when it's not enabled */ |
|
52683dfc1f7d
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents:
17823
diff
changeset
|
325 | if(!jm->js->allowBuzz) |
|
52683dfc1f7d
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents:
17823
diff
changeset
|
326 | return; |
|
25316
8b6461a2f967
Use purple_prpl_got_attention() for XMPP notifications
Evan Schoenberg <evands@pidgin.im>
parents:
25154
diff
changeset
|
327 | |
|
17822
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
328 | account = purple_connection_get_account(jm->js->gc); |
|
25316
8b6461a2f967
Use purple_prpl_got_attention() for XMPP notifications
Evan Schoenberg <evands@pidgin.im>
parents:
25154
diff
changeset
|
329 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
330 | if (purple_blist_find_buddy(account, jm->from) == NULL) |
|
17823
2ca25e7e65dd
Switched buzz namespace and tag name to be libpurple-specific and use a more professionally-sounding name ('attention' instead of 'buzz').
Andreas Monitzer <am@adiumx.com>
parents:
17822
diff
changeset
|
331 | return; /* Do not accept buzzes from unknown people */ |
|
2ca25e7e65dd
Switched buzz namespace and tag name to be libpurple-specific and use a more professionally-sounding name ('attention' instead of 'buzz').
Andreas Monitzer <am@adiumx.com>
parents:
17822
diff
changeset
|
332 | |
|
25316
8b6461a2f967
Use purple_prpl_got_attention() for XMPP notifications
Evan Schoenberg <evands@pidgin.im>
parents:
25154
diff
changeset
|
333 | /* xmpp only has 1 attention type, so index is 0 */ |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36362
diff
changeset
|
334 | purple_protocol_got_attention(jm->js->gc, jm->from, 0); |
|
17822
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
335 | } |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
336 | |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
337 | static gchar * |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
338 | 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
|
339 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
340 | 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
|
341 | int len = strlen(markup); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
342 | int pos = 0; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
343 | 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
|
344 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
345 | while (pos < len) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
346 | /* 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
|
347 | 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
|
348 | 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
|
349 | 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
|
350 | PurpleXmlNode *img = NULL; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
351 | int pos2 = pos; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
352 | const gchar *src; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
353 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
354 | for (; pos2 < len ; pos2++) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
355 | 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
|
356 | pos2 += 2; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
357 | break; |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
358 | } 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
|
359 | pos2 += 5; |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
360 | break; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
361 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
362 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
363 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
364 | /* 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
|
365 | 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
|
366 | 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
|
367 | 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
|
368 | 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
|
369 | 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
|
370 | 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
|
371 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
372 | 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
|
373 | 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
|
374 | /* 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
|
375 | if (alt && alt[0] != '\0') { |
|
24259
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
376 | /* 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
|
377 | this prevents linkification... */ |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
378 | 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
|
379 | 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
|
380 | 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
|
381 | g_free(safe_alt); |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
382 | } else { |
|
35783
dcff8ce68d1b
Remote smileys: fix a xmpp bug of non-escaped custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35764
diff
changeset
|
383 | 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
|
384 | 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
|
385 | g_free(alt_escaped); |
|
24259
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
386 | } |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
387 | } else { |
|
24258
9ae10fafad7a
When receiving an <img/> without the "alt" attribute, set
Marcus Lundblad <malu@pidgin.im>
parents:
24257
diff
changeset
|
388 | 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
|
389 | } |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
390 | pos += pos2 - pos; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
391 | } else { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
392 | 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
|
393 | pos++; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
394 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
395 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
396 | 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
|
397 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
398 | } else { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
399 | 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
|
400 | pos++; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
401 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
402 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
403 | |
|
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
|
404 | g_free(markup); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
405 | 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
|
406 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
407 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
408 | void jabber_message_parse(JabberStream *js, PurpleXmlNode *packet) |
| 7014 | 409 | { |
| 410 | 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
|
411 | const char *id, *from, *to, *type; |
|
40594
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
412 | 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
|
413 | gboolean signal_return; |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
414 | gboolean delayed = FALSE, is_outgoing = FALSE, is_forwarded = FALSE; |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
415 | time_t timestamp = time(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
|
416 | |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
417 | /* 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
|
418 | from = purple_xmlnode_get_attrib(packet, "from"); |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
419 | 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
|
420 | PurpleXmlNode *forwarded = NULL; |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
421 | |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
422 | /* 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
|
423 | 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
|
424 | NS_MESSAGE_CARBONS); |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
425 | if(received != NULL) { |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
426 | 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
|
427 | "forwarded", |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
428 | NS_FORWARD); |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
429 | } else { |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
430 | PurpleXmlNode *sent = NULL; |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
431 | |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
432 | 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
|
433 | NS_MESSAGE_CARBONS); |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
434 | if(sent != NULL) { |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
435 | 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
|
436 | "forwarded", |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
437 | NS_FORWARD); |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
438 | is_outgoing = TRUE; |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
439 | } |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
440 | } |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
441 | |
|
40594
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
442 | if(forwarded != NULL) { |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
443 | PurpleXmlNode *fwd_msg = NULL; |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
444 | |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
445 | 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
|
446 | "message", |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
447 | NS_XMPP_CLIENT); |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
448 | if(fwd_msg != NULL) { |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
449 | PurpleXmlNode *delay = NULL; |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
450 | |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
451 | /* 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
|
452 | * to it directly. |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
453 | */ |
|
40594
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
454 | packet = fwd_msg; |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
455 | is_forwarded = TRUE; |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
456 | |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
457 | /* 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
|
458 | * timestamp that the server sent. |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
459 | */ |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
460 | 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
|
461 | "delay", |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
462 | NS_DELAYED_DELIVERY); |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
463 | if(delay != NULL) { |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
464 | 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
|
465 | "stamp"); |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
466 | |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
467 | timestamp = purple_str_to_time(ts, TRUE, NULL, NULL, NULL); |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
468 | delayed = TRUE; |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
469 | } |
|
40594
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
470 | } |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
471 | } |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
472 | } |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
473 | |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
474 | /* 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
|
475 | * message. |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
476 | */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
477 | 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
|
478 | id = purple_xmlnode_get_attrib(packet, "id"); |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
479 | 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
|
480 | 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
|
481 | |
|
36623
caaadef03507
Renamed purple_connection_get_protocol_info() to purple_connection_get_protocol()
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
482 | 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
|
483 | "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
|
484 | 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
|
485 | return; |
| 7014 | 486 | |
| 487 | jm = g_new0(JabberMessage, 1); | |
| 488 | jm->js = js; | |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
489 | jm->sent = timestamp; |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
490 | jm->delayed = delayed; |
|
27429
3313d7d74962
Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
491 | jm->chat_state = JM_STATE_NONE; |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
492 | jm->forwarded = is_forwarded; |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
493 | jm->outgoing = is_outgoing; |
| 7014 | 494 | |
| 495 | if(type) { | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
496 | if(purple_strequal(type, "normal")) |
| 7014 | 497 | jm->type = JABBER_MESSAGE_NORMAL; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
498 | else if(purple_strequal(type, "chat")) |
| 7014 | 499 | jm->type = JABBER_MESSAGE_CHAT; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
500 | else if(purple_strequal(type, "groupchat")) |
| 7014 | 501 | jm->type = JABBER_MESSAGE_GROUPCHAT; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
502 | else if(purple_strequal(type, "headline")) |
| 7014 | 503 | jm->type = JABBER_MESSAGE_HEADLINE; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
504 | else if(purple_strequal(type, "error")) |
| 7014 | 505 | jm->type = JABBER_MESSAGE_ERROR; |
| 506 | else | |
| 507 | jm->type = JABBER_MESSAGE_OTHER; | |
| 508 | } else { | |
| 509 | jm->type = JABBER_MESSAGE_NORMAL; | |
| 510 | } | |
| 511 | ||
|
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
|
512 | 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
|
513 | 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
|
514 | jm->id = g_strdup(id); |
| 7014 | 515 | |
| 516 | 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
|
517 | 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
|
518 | if(child->type != PURPLE_XMLNODE_TYPE_TAG) |
| 7014 | 519 | continue; |
| 520 | ||
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
521 | 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
|
522 | 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
|
523 | 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
|
524 | 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
|
525 | if (!text) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
526 | 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
|
527 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
528 | 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
|
529 | 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
|
530 | } |
|
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 | |
|
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 | 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
|
533 | 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
|
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 | 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
|
536 | 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
|
537 | 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
|
538 | 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
|
539 | 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
|
540 | |
|
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 | 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
|
542 | 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
|
543 | } 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
|
544 | /* 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
|
545 | with the previous code. */ |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
546 | 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
|
547 | 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
|
548 | /* 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
|
549 | continue; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
550 | } 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
|
551 | 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
|
552 | 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
|
553 | 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
|
554 | 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
|
555 | } |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
556 | } else if(purple_strequal(child->name, "thread") && purple_strequal(xmlns, NS_XMPP_CLIENT)) { |
| 8400 | 557 | 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
|
558 | jm->thread_id = purple_xmlnode_get_data(child); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
559 | } else if(purple_strequal(child->name, "body") && purple_strequal(xmlns, NS_XMPP_CLIENT)) { |
| 13385 | 560 | 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
|
561 | char *msg = purple_xmlnode_get_data(child); |
|
30583
2482f350d8f5
jabber: Fix the last commit to pass escaped text off to the core.
Paul Aurich <darkrain42@pidgin.im>
parents:
30582
diff
changeset
|
562 | char *escaped = purple_markup_escape_text(msg, -1); |
|
2482f350d8f5
jabber: Fix the last commit to pass escaped text off to the core.
Paul Aurich <darkrain42@pidgin.im>
parents:
30582
diff
changeset
|
563 | 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
|
564 | g_free(escaped); |
| 13385 | 565 | g_free(msg); |
| 566 | } | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
567 | } 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
|
568 | 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
|
569 | char *c; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
570 | gchar *reformatted_xhtml; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
571 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
572 | purple_xmlnode_strip_prefixes(child); |
|
32323
df78cc32b2cd
jabber: Strip element prefixes on XHTML-IM content.
Paul Aurich <darkrain42@pidgin.im>
parents:
32277
diff
changeset
|
573 | |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
574 | /* 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
|
575 | 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
|
576 | /* 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
|
577 | 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
|
578 | reformatted_xhtml = |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
579 | 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
|
580 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
581 | jm->xhtml = reformatted_xhtml; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
582 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
583 | /* 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
|
584 | * 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
|
585 | */ |
|
7a5668fb7bad
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents:
16961
diff
changeset
|
586 | 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
|
587 | if (*c == '\n') |
|
17328
7a5668fb7bad
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents:
16961
diff
changeset
|
588 | *c = ' '; |
|
7a5668fb7bad
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents:
16961
diff
changeset
|
589 | } |
|
7a5668fb7bad
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents:
16961
diff
changeset
|
590 | } |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
591 | } else if(purple_strequal(child->name, "active") && purple_strequal(xmlns,"http://jabber.org/protocol/chatstates")) { |
| 13708 | 592 | jm->chat_state = JM_STATE_ACTIVE; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
593 | } else if(purple_strequal(child->name, "composing") && purple_strequal(xmlns,"http://jabber.org/protocol/chatstates")) { |
| 13708 | 594 | jm->chat_state = JM_STATE_COMPOSING; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
595 | } else if(purple_strequal(child->name, "paused") && purple_strequal(xmlns,"http://jabber.org/protocol/chatstates")) { |
| 13708 | 596 | jm->chat_state = JM_STATE_PAUSED; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
597 | } else if(purple_strequal(child->name, "inactive") && purple_strequal(xmlns,"http://jabber.org/protocol/chatstates")) { |
| 13708 | 598 | jm->chat_state = JM_STATE_INACTIVE; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
599 | } else if(purple_strequal(child->name, "gone") && purple_strequal(xmlns,"http://jabber.org/protocol/chatstates")) { |
| 13708 | 600 | jm->chat_state = JM_STATE_GONE; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
601 | } 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
|
602 | PurpleXmlNode *items; |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17776
diff
changeset
|
603 | 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
|
604 | 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
|
605 | jm->eventitems = g_list_append(jm->eventitems, items); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
606 | } else if(purple_strequal(child->name, "attention") && purple_strequal(xmlns, NS_ATTENTION)) { |
|
17822
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
607 | jm->hasBuzz = TRUE; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
608 | } else if(purple_strequal(child->name, "delay") && purple_strequal(xmlns, NS_DELAYED_DELIVERY)) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
609 | const char *timestamp = purple_xmlnode_get_attrib(child, "stamp"); |
|
17811
d9a7ec9277f6
Implemented XEP-0203: Delayed Delivery
Andreas Monitzer <am@adiumx.com>
parents:
17792
diff
changeset
|
610 | jm->delayed = TRUE; |
|
d9a7ec9277f6
Implemented XEP-0203: Delayed Delivery
Andreas Monitzer <am@adiumx.com>
parents:
17792
diff
changeset
|
611 | if(timestamp) |
|
d9a7ec9277f6
Implemented XEP-0203: Delayed Delivery
Andreas Monitzer <am@adiumx.com>
parents:
17792
diff
changeset
|
612 | jm->sent = purple_str_to_time(timestamp, TRUE, NULL, NULL, NULL); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
613 | } else if(purple_strequal(child->name, "x")) { |
|
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
614 | if(purple_strequal(xmlns, NS_DELAYED_DELIVERY_LEGACY)) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
615 | const char *timestamp = purple_xmlnode_get_attrib(child, "stamp"); |
|
27434
7d8b32345d10
disapproval of revision '0c1545afc98299c6d7004554eb7443091d42e8ca'
Paul Aurich <darkrain42@pidgin.im>
parents:
27431
diff
changeset
|
616 | jm->delayed = TRUE; |
|
7d8b32345d10
disapproval of revision '0c1545afc98299c6d7004554eb7443091d42e8ca'
Paul Aurich <darkrain42@pidgin.im>
parents:
27431
diff
changeset
|
617 | if(timestamp) |
|
7d8b32345d10
disapproval of revision '0c1545afc98299c6d7004554eb7443091d42e8ca'
Paul Aurich <darkrain42@pidgin.im>
parents:
27431
diff
changeset
|
618 | jm->sent = purple_str_to_time(timestamp, TRUE, NULL, NULL, NULL); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
619 | } else if(purple_strequal(xmlns, "jabber:x:conference") && |
| 11230 | 620 | jm->type != JABBER_MESSAGE_GROUPCHAT_INVITE && |
| 621 | 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
|
622 | const char *jid = purple_xmlnode_get_attrib(child, "jid"); |
| 7014 | 623 | if(jid) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
624 | 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
|
625 | 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
|
626 | |
| 7014 | 627 | jm->type = JABBER_MESSAGE_GROUPCHAT_INVITE; |
| 628 | g_free(jm->to); | |
| 629 | 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
|
630 | |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
631 | if (reason) { |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
632 | 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
|
633 | 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
|
634 | } |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
635 | |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
636 | if (password) { |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
637 | 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
|
638 | 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
|
639 | } |
| 7014 | 640 | } |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
641 | } else if(purple_strequal(xmlns, "http://jabber.org/protocol/muc#user") && |
| 11230 | 642 | 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
|
643 | PurpleXmlNode *invite = purple_xmlnode_get_child(child, "invite"); |
| 7014 | 644 | if(invite) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
645 | PurpleXmlNode *reason, *password; |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
646 | const char *jid = purple_xmlnode_get_attrib(invite, "from"); |
| 7014 | 647 | g_free(jm->to); |
| 648 | jm->to = jm->from; | |
| 649 | 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
|
650 | if((reason = purple_xmlnode_get_child(invite, "reason"))) { |
| 7014 | 651 | 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
|
652 | jm->body = purple_xmlnode_get_data(reason); |
| 7014 | 653 | } |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
654 | 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
|
655 | 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
|
656 | 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
|
657 | } |
| 7014 | 658 | |
| 659 | jm->type = JABBER_MESSAGE_GROUPCHAT_INVITE; | |
| 660 | } | |
| 7145 | 661 | } else { |
| 662 | jm->etc = g_list_append(jm->etc, child); | |
| 7014 | 663 | } |
|
38256
035f00c4fd87
Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
31512
diff
changeset
|
664 | } 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
|
665 | 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
|
666 | 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
|
667 | && 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
|
668 | 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
|
669 | } |
| 7014 | 670 | } |
| 671 | } | |
| 672 | ||
|
17822
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
673 | if(jm->hasBuzz) |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
674 | handle_buzz(jm); |
| 7014 | 675 | |
| 676 | switch(jm->type) { | |
|
27900
23b6b4dfeb82
Allow fallback for broken XMPP <message/> types. Closes #7837.
Paul Aurich <darkrain42@pidgin.im>
parents:
27844
diff
changeset
|
677 | case JABBER_MESSAGE_OTHER: |
|
28828
7c1855f037e7
jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <darkrain42@pidgin.im>
parents:
28726
diff
changeset
|
678 | purple_debug_info("jabber", |
|
27900
23b6b4dfeb82
Allow fallback for broken XMPP <message/> types. Closes #7837.
Paul Aurich <darkrain42@pidgin.im>
parents:
27844
diff
changeset
|
679 | "Received message of unknown type: %s\n", type); |
|
23b6b4dfeb82
Allow fallback for broken XMPP <message/> types. Closes #7837.
Paul Aurich <darkrain42@pidgin.im>
parents:
27844
diff
changeset
|
680 | /* Fall-through is intentional */ |
| 7014 | 681 | case JABBER_MESSAGE_NORMAL: |
| 682 | case JABBER_MESSAGE_CHAT: | |
| 7145 | 683 | handle_chat(jm); |
| 684 | break; | |
| 7014 | 685 | case JABBER_MESSAGE_HEADLINE: |
| 7145 | 686 | handle_headline(jm); |
| 7014 | 687 | break; |
| 688 | case JABBER_MESSAGE_GROUPCHAT: | |
| 689 | handle_groupchat(jm); | |
| 690 | break; | |
| 691 | case JABBER_MESSAGE_GROUPCHAT_INVITE: | |
| 692 | handle_groupchat_invite(jm); | |
| 693 | break; | |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17776
diff
changeset
|
694 | case JABBER_MESSAGE_EVENT: |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17776
diff
changeset
|
695 | jabber_handle_event(jm); |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17776
diff
changeset
|
696 | break; |
| 7014 | 697 | case JABBER_MESSAGE_ERROR: |
| 698 | handle_error(jm); | |
| 699 | break; | |
| 700 | } | |
| 701 | jabber_message_free(jm); | |
| 702 | } | |
| 703 | ||
| 704 | void jabber_message_send(JabberMessage *jm) | |
| 705 | { | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
706 | PurpleXmlNode *message, *child; |
| 7014 | 707 | const char *type = NULL; |
| 708 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
709 | message = purple_xmlnode_new("message"); |
| 7014 | 710 | |
| 711 | switch(jm->type) { | |
| 712 | case JABBER_MESSAGE_NORMAL: | |
| 713 | type = "normal"; | |
| 714 | break; | |
| 715 | case JABBER_MESSAGE_CHAT: | |
| 716 | case JABBER_MESSAGE_GROUPCHAT_INVITE: | |
| 717 | type = "chat"; | |
| 718 | break; | |
| 719 | case JABBER_MESSAGE_HEADLINE: | |
| 720 | type = "headline"; | |
| 721 | break; | |
| 722 | case JABBER_MESSAGE_GROUPCHAT: | |
| 723 | type = "groupchat"; | |
| 724 | break; | |
| 725 | case JABBER_MESSAGE_ERROR: | |
| 726 | type = "error"; | |
| 727 | break; | |
| 728 | 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
|
729 | default: |
| 7014 | 730 | type = NULL; |
| 731 | break; | |
| 732 | } | |
| 733 | ||
| 734 | if(type) | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
735 | 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
|
736 | |
| 13484 | 737 | 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
|
738 | purple_xmlnode_set_attrib(message, "id", jm->id); |
| 7014 | 739 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
740 | purple_xmlnode_set_attrib(message, "to", jm->to); |
| 7014 | 741 | |
| 8400 | 742 | 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
|
743 | 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
|
744 | purple_xmlnode_insert_data(child, jm->thread_id, -1); |
| 8400 | 745 | } |
| 746 | ||
| 27432 | 747 | child = NULL; |
| 748 | switch(jm->chat_state) | |
| 749 | { | |
| 750 | 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
|
751 | child = purple_xmlnode_new_child(message, "active"); |
| 27432 | 752 | break; |
| 753 | 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
|
754 | child = purple_xmlnode_new_child(message, "composing"); |
| 27432 | 755 | break; |
| 756 | 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
|
757 | child = purple_xmlnode_new_child(message, "paused"); |
| 27432 | 758 | break; |
| 759 | 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
|
760 | child = purple_xmlnode_new_child(message, "inactive"); |
| 27432 | 761 | break; |
| 762 | 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
|
763 | child = purple_xmlnode_new_child(message, "gone"); |
| 27432 | 764 | break; |
| 765 | case JM_STATE_NONE: | |
| 766 | /* yep, nothing */ | |
| 767 | break; | |
| 7014 | 768 | } |
| 27432 | 769 | if(child) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
770 | purple_xmlnode_set_namespace(child, "http://jabber.org/protocol/chatstates"); |
| 13708 | 771 | |
| 7014 | 772 | 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
|
773 | 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
|
774 | purple_xmlnode_insert_data(child, jm->subject, -1); |
| 7014 | 775 | } |
| 776 | ||
| 777 | 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
|
778 | 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
|
779 | purple_xmlnode_insert_data(child, jm->body, -1); |
| 7014 | 780 | } |
| 781 | ||
| 782 | 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
|
783 | 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
|
784 | purple_xmlnode_insert_child(message, child); |
| 7014 | 785 | } else { |
|
28828
7c1855f037e7
jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <darkrain42@pidgin.im>
parents:
28726
diff
changeset
|
786 | purple_debug_error("jabber", |
| 7014 | 787 | "XHTML translation/validation failed, returning: %s\n", |
| 788 | jm->xhtml); | |
| 789 | } | |
| 790 | } | |
| 791 | ||
| 792 | jabber_send(jm->js, message); | |
| 793 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
794 | purple_xmlnode_free(message); |
| 7014 | 795 | } |
| 796 | ||
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
797 | /* |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
798 | * 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
|
799 | * 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
|
800 | * FALSE. |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
801 | */ |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
802 | static gboolean |
|
40293
c60c4f96749d
Fix some line wrapping
Richard Laager <rlaager@pidgin.im>
parents:
40290
diff
changeset
|
803 | 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
|
804 | { |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
805 | 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
|
806 | 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
|
807 | 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
|
808 | 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
|
809 | |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
810 | 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
|
811 | 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
|
812 | 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
|
813 | 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
|
814 | continue; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
815 | } |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
816 | |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
817 | 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
|
818 | 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
|
819 | 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
|
820 | continue; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
821 | } |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
822 | |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
823 | 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
|
824 | 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
|
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 | /* 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
|
828 | 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
|
829 | 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
|
830 | 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
|
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 | |
|
40507
77d7bc9e5151
Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
833 | int jabber_message_send_im(PurpleProtocolIM *pim, PurpleConnection *gc, |
|
77d7bc9e5151
Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
834 | PurpleMessage *msg) |
| 7014 | 835 | { |
| 836 | JabberMessage *jm; | |
| 837 | JabberBuddy *jb; | |
| 838 | JabberBuddyResource *jbr; | |
| 7135 | 839 | 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
|
840 | char *tmp; |
| 7306 | 841 | char *resource; |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
842 | const gchar *rcpt = purple_message_get_recipient(msg); |
| 7014 | 843 | |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
844 | if (!rcpt || purple_message_is_empty(msg)) |
| 7014 | 845 | return 0; |
| 846 | ||
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
847 | 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
|
848 | |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
849 | jb = jabber_buddy_find(purple_connection_get_protocol_data(gc), rcpt, TRUE); |
| 7306 | 850 | jbr = jabber_buddy_find_resource(jb, resource); |
| 851 | ||
| 852 | g_free(resource); | |
| 7014 | 853 | |
| 854 | 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
|
855 | jm->js = purple_connection_get_protocol_data(gc); |
| 7014 | 856 | jm->type = JABBER_MESSAGE_CHAT; |
| 13708 | 857 | jm->chat_state = JM_STATE_ACTIVE; |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
858 | jm->to = g_strdup(rcpt); |
| 13484 | 859 | jm->id = jabber_get_next_id(jm->js); |
| 13708 | 860 | |
| 861 | if(jbr) { | |
| 862 | if(jbr->thread_id) | |
| 863 | jm->thread_id = jbr->thread_id; | |
| 864 | ||
|
27429
3313d7d74962
Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
865 | 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
|
866 | jm->chat_state = JM_STATE_NONE; |
|
3313d7d74962
Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
867 | else { |
| 13708 | 868 | /* if(JABBER_CHAT_STATES_UNKNOWN == jbr->chat_states) |
| 869 | jbr->chat_states = JABBER_CHAT_STATES_UNSUPPORTED; */ | |
| 870 | } | |
| 871 | } | |
| 7014 | 872 | |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35838
diff
changeset
|
873 | 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
|
874 | 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
|
875 | 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
|
876 | |
|
27746
4b3f015977d9
For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
877 | /* |
|
4b3f015977d9
For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
878 | * 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
|
879 | * 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
|
880 | */ |
|
4b3f015977d9
For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
881 | if (!jbr || !jbr->caps.info || |
|
28984
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28979
diff
changeset
|
882 | 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
|
883 | 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
|
884 | /* 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
|
885 | 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
|
886 | } |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
887 | |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
888 | g_free(xhtml); |
| 7014 | 889 | |
| 890 | jabber_message_send(jm); | |
| 891 | jabber_message_free(jm); | |
| 892 | return 1; | |
| 893 | } | |
| 894 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40594
diff
changeset
|
895 | gint |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40594
diff
changeset
|
896 | jabber_message_send_chat(PurpleProtocolChat *protocol_chat, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40594
diff
changeset
|
897 | PurpleConnection *gc, gint id, PurpleMessage *msg) |
| 7014 | 898 | { |
| 899 | JabberChat *chat; | |
| 900 | JabberMessage *jm; | |
| 8042 | 901 | 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
|
902 | 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
|
903 | char *tmp; |
| 7014 | 904 | |
|
36077
b7328f4317c7
Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36076
diff
changeset
|
905 | if (!gc || purple_message_is_empty(msg)) |
| 7014 | 906 | return 0; |
| 907 | ||
|
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
|
908 | js = purple_connection_get_protocol_data(gc); |
| 7014 | 909 | chat = jabber_chat_find_by_id(js, id); |
| 910 | ||
| 8043 | 911 | if(!chat) |
| 912 | return 0; | |
| 913 | ||
| 9130 | 914 | 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
|
915 | jm->js = purple_connection_get_protocol_data(gc); |
| 9130 | 916 | jm->type = JABBER_MESSAGE_GROUPCHAT; |
| 917 | jm->to = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 13484 | 918 | jm->id = jabber_get_next_id(jm->js); |
| 9130 | 919 | |
|
36077
b7328f4317c7
Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36076
diff
changeset
|
920 | 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
|
921 | 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
|
922 | g_free(tmp); |
| 8858 | 923 | |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
924 | 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
|
925 | /* 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
|
926 | 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
|
927 | |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
928 | g_free(xhtml); |
| 7923 | 929 | |
| 9130 | 930 | jabber_message_send(jm); |
| 931 | jabber_message_free(jm); | |
| 932 | ||
| 7014 | 933 | return 1; |
| 934 | } | |
| 935 | ||
|
40507
77d7bc9e5151
Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
936 | unsigned int jabber_send_typing(PurpleProtocolIM *pim, PurpleConnection *gc, |
|
77d7bc9e5151
Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
937 | const char *who, PurpleIMTypingState state) |
| 7014 | 938 | { |
|
30454
4e9bf65cfe9a
jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents:
30239
diff
changeset
|
939 | JabberStream *js; |
| 7014 | 940 | JabberMessage *jm; |
| 941 | JabberBuddy *jb; | |
| 942 | JabberBuddyResource *jbr; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30744
diff
changeset
|
943 | char *resource; |
| 7014 | 944 | |
|
30454
4e9bf65cfe9a
jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents:
30239
diff
changeset
|
945 | 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
|
946 | 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
|
947 | if (!jb) |
|
4e9bf65cfe9a
jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents:
30239
diff
changeset
|
948 | return 0; |
|
4e9bf65cfe9a
jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents:
30239
diff
changeset
|
949 | |
|
4e9bf65cfe9a
jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents:
30239
diff
changeset
|
950 | resource = jabber_get_resource(who); |
| 7306 | 951 | jbr = jabber_buddy_find_resource(jb, resource); |
| 952 | g_free(resource); | |
| 7014 | 953 | |
|
30235
d37c441d6a48
jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <darkrain42@pidgin.im>
parents:
30121
diff
changeset
|
954 | /* 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
|
955 | 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
|
956 | 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
|
957 | |
|
d37c441d6a48
jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <darkrain42@pidgin.im>
parents:
30121
diff
changeset
|
958 | /* *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
|
959 | * 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
|
960 | */ |
|
d37c441d6a48
jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <darkrain42@pidgin.im>
parents:
30121
diff
changeset
|
961 | if (!jbr && !(jb->subscription & JABBER_SUB_FROM)) |
| 7014 | 962 | return 0; |
| 963 | ||
| 13708 | 964 | /* TODO: figure out threading */ |
| 7014 | 965 | 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
|
966 | jm->js = js; |
| 7014 | 967 | jm->type = JABBER_MESSAGE_CHAT; |
| 968 | jm->to = g_strdup(who); | |
| 13484 | 969 | jm->id = jabber_get_next_id(jm->js); |
| 7014 | 970 | |
|
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
|
971 | if(PURPLE_IM_TYPING == state) |
| 13708 | 972 | 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
|
973 | else if(PURPLE_IM_TYPED == state) |
| 13708 | 974 | jm->chat_state = JM_STATE_PAUSED; |
| 975 | else | |
| 976 | jm->chat_state = JM_STATE_ACTIVE; | |
| 977 | ||
|
27429
3313d7d74962
Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
978 | /* 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
|
979 | jbr->chat_states = JABBER_CHAT_STATES_UNSUPPORTED; */ |
| 7014 | 980 | |
| 981 | jabber_message_send(jm); | |
| 982 | jabber_message_free(jm); | |
| 983 | ||
| 13708 | 984 | return 0; |
| 7014 | 985 | } |
| 986 | ||
|
23586
e495a4623f76
Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23249
diff
changeset
|
987 | gboolean jabber_buzz_isenabled(JabberStream *js, const gchar *namespace) { |
|
17824
52683dfc1f7d
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents:
17823
diff
changeset
|
988 | return js->allowBuzz; |
|
52683dfc1f7d
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents:
17823
diff
changeset
|
989 | } |