Sat, 30 Jan 2021 01:26:47 -0600
Fix up the XEP-0280 carbons support.
My initial port of this wasn't great, this is much better.
Testing Done:
sent messages between pidgin2 with gkdr/carbons, conversations on my phone, and pidgin3. I sent messages from all clients and received them on all three clients.
Reviewed at https://reviews.imfreedom.org/r/462/
| 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 | |
|
38282
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
37 | typedef struct { |
|
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
38 | PurpleConversation *conv; |
|
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
39 | gchar *shortcut; |
|
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
40 | } JabberMessageRemoteSmileyAddData; |
|
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
41 | |
|
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
|
42 | 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
|
43 | 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
|
44 | 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
|
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 | 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
|
47 | 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
|
48 | 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
|
49 | 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
|
50 | |
|
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 | for(etc = jm->etc; etc; etc = etc->next) { |
| 38358 | 52 | PurpleXmlNode *x = etc->data; |
| 53 | const char *xmlns = purple_xmlnode_get_namespace(x); | |
|
38264
99356e68aff5
Merge release-2.x.y changes, resolve conflicts
qarkai <qarkai@gmail.com>
diff
changeset
|
54 | if(purple_strequal(xmlns, NS_OOB_X_DATA)) { |
| 38358 | 55 | 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
|
56 | 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
|
57 | |
| 38358 | 58 | url = purple_xmlnode_get_child(x, "url"); |
| 59 | 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
|
60 | |
|
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 | 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
|
62 | 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
|
63 | |
| 38358 | 64 | urltxt = purple_xmlnode_get_data(url); |
| 65 | 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
|
66 | |
|
38264
99356e68aff5
Merge release-2.x.y changes, resolve conflicts
qarkai <qarkai@gmail.com>
diff
changeset
|
67 | 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
|
68 | 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
|
69 | 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
|
70 | 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
|
71 | 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
|
72 | 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
|
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 | 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
|
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 | 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
|
77 | 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
|
78 | } |
|
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
|
79 | } |
|
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
|
80 | |
|
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
|
81 | 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
|
82 | } |
|
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
|
83 | |
| 7014 | 84 | void jabber_message_free(JabberMessage *jm) |
| 85 | { | |
| 15980 | 86 | g_free(jm->from); |
| 13484 | 87 | g_free(jm->to); |
| 88 | g_free(jm->id); | |
| 89 | g_free(jm->subject); | |
| 90 | g_free(jm->body); | |
| 91 | g_free(jm->xhtml); | |
| 92 | g_free(jm->password); | |
|
20057
728a7dce565e
grab revision 41389df89a4a6a007d41cec33e33043cd41ea159
Luke Schierer <lschiere@pidgin.im>
parents:
19917
diff
changeset
|
93 | g_free(jm->error); |
|
728a7dce565e
grab revision 41389df89a4a6a007d41cec33e33043cd41ea159
Luke Schierer <lschiere@pidgin.im>
parents:
19917
diff
changeset
|
94 | g_free(jm->thread_id); |
| 13484 | 95 | g_list_free(jm->etc); |
|
20057
728a7dce565e
grab revision 41389df89a4a6a007d41cec33e33043cd41ea159
Luke Schierer <lschiere@pidgin.im>
parents:
19917
diff
changeset
|
96 | g_list_free(jm->eventitems); |
| 7014 | 97 | |
| 98 | g_free(jm); | |
| 99 | } | |
| 100 | ||
| 7145 | 101 | static void handle_chat(JabberMessage *jm) |
| 7014 | 102 | { |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
103 | 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
|
104 | JabberID *jid = jabber_id_new(contact); |
| 7014 | 105 | |
|
29331
9e828e599fc2
jabber: Use some convenience variables here.
Paul Aurich <darkrain42@pidgin.im>
parents:
29330
diff
changeset
|
106 | PurpleConnection *gc; |
|
9e828e599fc2
jabber: Use some convenience variables here.
Paul Aurich <darkrain42@pidgin.im>
parents:
29330
diff
changeset
|
107 | PurpleAccount *account; |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
108 | PurpleMessageFlags flags = 0; |
| 7014 | 109 | JabberBuddy *jb; |
| 110 | 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
|
111 | GString *body; |
| 7014 | 112 | |
| 7310 | 113 | if(!jid) |
| 114 | return; | |
| 115 | ||
|
29331
9e828e599fc2
jabber: Use some convenience variables here.
Paul Aurich <darkrain42@pidgin.im>
parents:
29330
diff
changeset
|
116 | gc = jm->js->gc; |
|
9e828e599fc2
jabber: Use some convenience variables here.
Paul Aurich <darkrain42@pidgin.im>
parents:
29330
diff
changeset
|
117 | account = purple_connection_get_account(gc); |
|
9e828e599fc2
jabber: Use some convenience variables here.
Paul Aurich <darkrain42@pidgin.im>
parents:
29330
diff
changeset
|
118 | |
|
40290
0a722071a754
Refactor jm->from to contact in handle_chat()
Koosha Khajehmoogahi <koosha@posteo.de>
parents:
39470
diff
changeset
|
119 | jb = jabber_buddy_find(jm->js, contact, TRUE); |
| 7306 | 120 | jbr = jabber_buddy_find_resource(jb, jid->resource); |
| 7014 | 121 | |
|
38248
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
122 | if (jbr && jm->chat_state != JM_STATE_NONE) |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
123 | jbr->chat_states = JABBER_CHAT_STATES_SUPPORTED; |
|
27750
f25b6a565494
Use Entity Capabilities to pick up Chat States support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents:
27749
diff
changeset
|
124 | |
|
38248
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
125 | switch(jm->chat_state) { |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
126 | case JM_STATE_COMPOSING: |
|
40290
0a722071a754
Refactor jm->from to contact in handle_chat()
Koosha Khajehmoogahi <koosha@posteo.de>
parents:
39470
diff
changeset
|
127 | purple_serv_got_typing(gc, contact, 0, PURPLE_IM_TYPING); |
|
38248
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
128 | break; |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
129 | case JM_STATE_PAUSED: |
|
40290
0a722071a754
Refactor jm->from to contact in handle_chat()
Koosha Khajehmoogahi <koosha@posteo.de>
parents:
39470
diff
changeset
|
130 | purple_serv_got_typing(gc, contact, 0, PURPLE_IM_TYPED); |
|
38248
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
131 | break; |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
132 | case JM_STATE_GONE: { |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
133 | PurpleIMConversation *im = purple_conversations_find_im_with_account( |
|
40290
0a722071a754
Refactor jm->from to contact in handle_chat()
Koosha Khajehmoogahi <koosha@posteo.de>
parents:
39470
diff
changeset
|
134 | contact, account); |
|
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. */ |
|
36089
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36084
diff
changeset
|
155 | purple_conversation_write_system_message( |
|
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36084
diff
changeset
|
156 | PURPLE_CONVERSATION(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
|
157 | } |
|
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
|
158 | } |
|
40290
0a722071a754
Refactor jm->from to contact in handle_chat()
Koosha Khajehmoogahi <koosha@posteo.de>
parents:
39470
diff
changeset
|
159 | 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
|
160 | 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
|
161 | } |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
162 | default: |
|
40290
0a722071a754
Refactor jm->from to contact in handle_chat()
Koosha Khajehmoogahi <koosha@posteo.de>
parents:
39470
diff
changeset
|
163 | 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
|
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 | |
|
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 | 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
|
167 | |
|
1034c641ec6c
Previously only OOB URLs attached to headline messages were processed. Now any message can show the attached URL.
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
31512
diff
changeset
|
168 | 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
|
169 | 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
|
170 | /* |
|
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 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
|
172 | * 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
|
173 | * 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
|
174 | * 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
|
175 | * |
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
33722
diff
changeset
|
176 | * 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
|
177 | * 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
|
178 | */ |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
179 | PurpleIMConversation *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
|
180 | |
|
40290
0a722071a754
Refactor jm->from to contact in handle_chat()
Koosha Khajehmoogahi <koosha@posteo.de>
parents:
39470
diff
changeset
|
181 | im = purple_conversations_find_im_with_account(contact, account); |
|
0a722071a754
Refactor jm->from to contact in handle_chat()
Koosha Khajehmoogahi <koosha@posteo.de>
parents:
39470
diff
changeset
|
182 | if (im && !purple_strequal(contact, |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
183 | purple_conversation_get_name(PURPLE_CONVERSATION(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
|
184 | 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
|
185 | contact); |
|
0a722071a754
Refactor jm->from to contact in handle_chat()
Koosha Khajehmoogahi <koosha@posteo.de>
parents:
39470
diff
changeset
|
186 | purple_conversation_set_name(PURPLE_CONVERSATION(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
|
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 | } |
|
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
189 | |
| 8400 | 190 | if(jbr) { |
|
30239
88550c8e461b
jabber: Refined logic for determining "is typing" support.
Paul Aurich <darkrain42@pidgin.im>
parents:
30235
diff
changeset
|
191 | /* 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
|
192 | 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
|
193 | 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
|
194 | 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
|
195 | else |
|
88550c8e461b
jabber: Refined logic for determining "is typing" support.
Paul Aurich <darkrain42@pidgin.im>
parents:
30235
diff
changeset
|
196 | 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
|
197 | } |
| 13708 | 198 | |
|
37423
d2f0259aa43f
Remove NULL-checks before free(). No functional change.
Michael McConville <mmcco@mykolab.com>
parents:
37153
diff
changeset
|
199 | g_free(jbr->thread_id); |
|
39470
92dbadc3c6e4
Fix jabber message thread handling.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39433
diff
changeset
|
200 | jbr->thread_id = g_strdup(jm->thread_id); |
| 8400 | 201 | } |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
202 | |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
203 | if(jm->forwarded) { |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
204 | flags |= PURPLE_MESSAGE_FORWARDED; |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
205 | } |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
206 | 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
|
207 | |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
208 | purple_serv_got_im(gc, contact, body->str, flags, jm->sent); |
| 7014 | 209 | } |
| 210 | ||
| 211 | 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
|
212 | |
|
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 | 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
|
214 | g_string_free(body, TRUE); |
| 7014 | 215 | } |
| 216 | ||
| 7145 | 217 | static void handle_headline(JabberMessage *jm) |
| 218 | { | |
| 219 | 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
|
220 | GString *body; |
| 7145 | 221 | |
|
17819
862fe0f947a9
Added buzz support using a private extension. Maybe I should write a XEP about that.
Andreas Monitzer <am@adiumx.com>
parents:
17811
diff
changeset
|
222 | 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
|
223 | return; /* ignore headlines without any content */ |
| 7145 | 224 | |
|
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
|
225 | body = jm_body_with_oob(jm); |
| 7145 | 226 | title = g_strdup_printf(_("Message from %s"), jm->from); |
| 227 | ||
| 15884 | 228 | purple_notify_formatted(jm->js->gc, title, jm->subject ? jm->subject : title, |
| 7145 | 229 | NULL, body->str, NULL, NULL); |
| 230 | ||
| 231 | g_free(title); | |
| 232 | g_string_free(body, TRUE); | |
| 233 | } | |
| 234 | ||
| 235 | static void handle_groupchat(JabberMessage *jm) | |
| 7014 | 236 | { |
| 237 | JabberID *jid = jabber_id_new(jm->from); | |
| 7310 | 238 | 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
|
239 | PurpleMessageFlags messageFlags = 0; |
| 7310 | 240 | |
| 241 | if(!jid) | |
| 242 | return; | |
| 243 | ||
| 244 | chat = jabber_chat_find(jm->js, jid->node, jid->domain); | |
| 7014 | 245 | |
| 246 | if(!chat) | |
| 247 | return; | |
| 248 | ||
| 7971 | 249 | if(jm->subject) { |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
250 | purple_chat_conversation_set_topic(chat->conv, jid->resource, |
| 7183 | 251 | 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
|
252 | messageFlags |= PURPLE_MESSAGE_NO_LOG; |
| 7971 | 253 | if(!jm->xhtml && !jm->body) { |
| 9762 | 254 | char *msg, *tmp, *tmp2; |
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10607
diff
changeset
|
255 | tmp = g_markup_escape_text(jm->subject, -1); |
| 15884 | 256 | tmp2 = purple_markup_linkify(tmp); |
| 7971 | 257 | if(jid->resource) |
| 9762 | 258 | msg = g_strdup_printf(_("%s has set the topic to: %s"), jid->resource, tmp2); |
| 7971 | 259 | else |
| 9762 | 260 | 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
|
261 | 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
|
262 | msg, messageFlags); |
| 9762 | 263 | g_free(tmp); |
| 264 | g_free(tmp2); | |
| 7971 | 265 | g_free(msg); |
| 266 | } | |
| 267 | } | |
| 7014 | 268 | |
| 7630 | 269 | if(jm->xhtml || jm->body) { |
| 270 | if(jid->resource) | |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35070
diff
changeset
|
271 | 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
|
272 | messageFlags | (jm->delayed ? PURPLE_MESSAGE_DELAYED : 0), |
| 7630 | 273 | jm->xhtml ? jm->xhtml : jm->body, jm->sent); |
| 274 | else if(chat->muc) | |
|
36084
2172bd6dad3e
Add purple_conversation_write_system_message
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36077
diff
changeset
|
275 | purple_conversation_write_system_message( |
|
2172bd6dad3e
Add purple_conversation_write_system_message
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36077
diff
changeset
|
276 | PURPLE_CONVERSATION(chat->conv), |
|
2172bd6dad3e
Add purple_conversation_write_system_message
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36077
diff
changeset
|
277 | jm->xhtml ? jm->xhtml : jm->body, messageFlags); |
| 7630 | 278 | } |
| 279 | ||
| 7014 | 280 | jabber_id_free(jid); |
| 281 | } | |
| 282 | ||
| 7145 | 283 | static void handle_groupchat_invite(JabberMessage *jm) |
| 7014 | 284 | { |
| 7310 | 285 | GHashTable *components; |
| 7014 | 286 | JabberID *jid = jabber_id_new(jm->to); |
| 287 | ||
| 7310 | 288 | if(!jid) |
| 289 | return; | |
| 290 | ||
|
15598
834a88c83e95
Get rid of some unnecessary string duping
Mark Doliner <markdoliner@pidgin.im>
parents:
15587
diff
changeset
|
291 | components = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); |
| 7310 | 292 | |
|
15598
834a88c83e95
Get rid of some unnecessary string duping
Mark Doliner <markdoliner@pidgin.im>
parents:
15587
diff
changeset
|
293 | 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
|
294 | 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
|
295 | 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
|
296 | g_hash_table_replace(components, "password", g_strdup(jm->password)); |
| 7014 | 297 | |
| 298 | jabber_id_free(jid); | |
| 35501 | 299 | purple_serv_got_chat_invite(jm->js->gc, jm->to, jm->from, jm->body, components); |
| 7014 | 300 | } |
| 301 | ||
| 7145 | 302 | static void handle_error(JabberMessage *jm) |
| 7014 | 303 | { |
| 304 | char *buf; | |
| 305 | ||
| 306 | if(!jm->body) | |
| 307 | return; | |
| 308 | ||
| 309 | buf = g_strdup_printf(_("Message delivery to %s failed: %s"), | |
|
13766
6b92ce47f7e5
[gaim-migrate @ 16176]
Daniel Atallah <datallah@pidgin.im>
parents:
13708
diff
changeset
|
310 | jm->from, jm->error ? jm->error : ""); |
| 7014 | 311 | |
|
16961
b6955f946f8f
s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@pidgin.im>
parents:
16946
diff
changeset
|
312 | purple_notify_formatted(jm->js->gc, _("XMPP Message Error"), _("XMPP Message Error"), buf, |
| 7944 | 313 | jm->xhtml ? jm->xhtml : jm->body, NULL, NULL); |
| 7014 | 314 | |
| 315 | g_free(buf); | |
| 316 | } | |
| 317 | ||
|
17822
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
318 | static void handle_buzz(JabberMessage *jm) { |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
319 | PurpleAccount *account; |
|
25316
8b6461a2f967
Use purple_prpl_got_attention() for XMPP notifications
Evan Schoenberg <evands@pidgin.im>
parents:
25154
diff
changeset
|
320 | |
|
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
|
321 | /* 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
|
322 | 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
|
323 | return; |
|
25316
8b6461a2f967
Use purple_prpl_got_attention() for XMPP notifications
Evan Schoenberg <evands@pidgin.im>
parents:
25154
diff
changeset
|
324 | |
|
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
|
325 | /* 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
|
326 | 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
|
327 | return; |
|
25316
8b6461a2f967
Use purple_prpl_got_attention() for XMPP notifications
Evan Schoenberg <evands@pidgin.im>
parents:
25154
diff
changeset
|
328 | |
|
17822
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
329 | 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
|
330 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
331 | 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
|
332 | 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
|
333 | |
|
25316
8b6461a2f967
Use purple_prpl_got_attention() for XMPP notifications
Evan Schoenberg <evands@pidgin.im>
parents:
25154
diff
changeset
|
334 | /* 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
|
335 | 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
|
336 | } |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
337 | |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
338 | /* used internally by the functions below */ |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
339 | typedef struct { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
340 | gchar *cid; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
341 | gchar *alt; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
342 | } JabberSmileyRef; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
343 | |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
344 | |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
345 | static void |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
346 | jabber_message_get_refs_from_xmlnode_internal(const PurpleXmlNode *message, |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
347 | GHashTable *table) |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
348 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
349 | PurpleXmlNode *child; |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
350 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
351 | for (child = purple_xmlnode_get_child(message, "img") ; child ; |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
352 | child = purple_xmlnode_get_next_twin(child)) { |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
353 | const gchar *src = purple_xmlnode_get_attrib(child, "src"); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
354 | |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
355 | if (g_str_has_prefix(src, "cid:")) { |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
356 | const gchar *cid = src + 4; |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
357 | |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
358 | /* if we haven't "fetched" this yet... */ |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
359 | if (!g_hash_table_lookup(table, cid)) { |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
360 | /* take a copy of the cid and let the SmileyRef own it... */ |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
361 | gchar *temp_cid = g_strdup(cid); |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
362 | JabberSmileyRef *ref = g_new0(JabberSmileyRef, 1); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
363 | const gchar *alt = purple_xmlnode_get_attrib(child, "alt"); |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
364 | ref->cid = temp_cid; |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
365 | /* if there is no "alt" string, use the cid... |
|
24258
9ae10fafad7a
When receiving an <img/> without the "alt" attribute, set
Marcus Lundblad <malu@pidgin.im>
parents:
24257
diff
changeset
|
366 | include the entire src, eg. "cid:.." to avoid linkification */ |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
367 | if (alt && alt[0] != '\0') { |
|
24259
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
368 | /* workaround for when "alt" is set to the value of the |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
369 | CID (which Jabbim seems to do), to avoid it showing up |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
370 | as an mailto: link */ |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
371 | if (purple_email_is_valid(alt)) { |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
372 | ref->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
|
373 | } else { |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
374 | ref->alt = g_strdup(alt); |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
375 | } |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
376 | } else { |
|
24258
9ae10fafad7a
When receiving an <img/> without the "alt" attribute, set
Marcus Lundblad <malu@pidgin.im>
parents:
24257
diff
changeset
|
377 | ref->alt = g_strdup(src); |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
378 | } |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
379 | g_hash_table_insert(table, temp_cid, ref); |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
380 | } |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
381 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
382 | } |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
383 | |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
384 | for (child = message->child ; child ; child = child->next) { |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
385 | jabber_message_get_refs_from_xmlnode_internal(child, table); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
386 | } |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
387 | } |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
388 | |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
389 | static gboolean |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
390 | jabber_message_get_refs_steal(gpointer key, gpointer value, gpointer user_data) |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
391 | { |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
392 | GList **refs = (GList **) user_data; |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
393 | JabberSmileyRef *ref = (JabberSmileyRef *) value; |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
394 | |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
395 | *refs = g_list_append(*refs, ref); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
396 | |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
397 | return TRUE; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
398 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
399 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
400 | static GList * |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
401 | jabber_message_get_refs_from_xmlnode(const PurpleXmlNode *message) |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
402 | { |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
403 | GList *refs = NULL; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
404 | GHashTable *unique_refs = g_hash_table_new(g_str_hash, g_str_equal); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
405 | |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
406 | jabber_message_get_refs_from_xmlnode_internal(message, unique_refs); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
407 | (void) g_hash_table_foreach_steal(unique_refs, |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
408 | jabber_message_get_refs_steal, (gpointer) &refs); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
409 | g_hash_table_destroy(unique_refs); |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
410 | return refs; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
411 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
412 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
413 | static gchar * |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
414 | 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
|
415 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
416 | 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
|
417 | int len = strlen(markup); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
418 | int pos = 0; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
419 | 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
|
420 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
421 | while (pos < len) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
422 | /* 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
|
423 | 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
|
424 | 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
|
425 | 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
|
426 | PurpleXmlNode *img = NULL; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
427 | int pos2 = pos; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
428 | const gchar *src; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
429 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
430 | for (; pos2 < len ; pos2++) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
431 | 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
|
432 | pos2 += 2; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
433 | break; |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
434 | } 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
|
435 | pos2 += 5; |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
436 | break; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
437 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
438 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
439 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
440 | /* 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
|
441 | 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
|
442 | 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
|
443 | 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
|
444 | 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
|
445 | 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
|
446 | 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
|
447 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
448 | 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
|
449 | 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
|
450 | /* 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
|
451 | if (alt && alt[0] != '\0') { |
|
24259
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
452 | /* 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
|
453 | this prevents linkification... */ |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
454 | 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
|
455 | 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
|
456 | 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
|
457 | g_free(safe_alt); |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
458 | } else { |
|
35783
dcff8ce68d1b
Remote smileys: fix a xmpp bug of non-escaped custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35764
diff
changeset
|
459 | 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
|
460 | 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
|
461 | g_free(alt_escaped); |
|
24259
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
462 | } |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
463 | } else { |
|
24258
9ae10fafad7a
When receiving an <img/> without the "alt" attribute, set
Marcus Lundblad <malu@pidgin.im>
parents:
24257
diff
changeset
|
464 | 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
|
465 | } |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
466 | pos += pos2 - pos; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
467 | } else { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
468 | 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
|
469 | pos++; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
470 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
471 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
472 | 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
|
473 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
474 | } else { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
475 | 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
|
476 | pos++; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
477 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
478 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
479 | |
|
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
|
480 | g_free(markup); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
481 | 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
|
482 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
483 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
484 | static void |
|
29912
4f8e1c3bbc4a
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <malu@pidgin.im>
parents:
29910
diff
changeset
|
485 | jabber_message_add_remote_smileys(JabberStream *js, const gchar *who, |
|
40293
c60c4f96749d
Fix some line wrapping
Richard Laager <rlaager@pidgin.im>
parents:
40290
diff
changeset
|
486 | const PurpleXmlNode *message) |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
487 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
488 | PurpleXmlNode *data_tag; |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
489 | for (data_tag = purple_xmlnode_get_child_with_namespace(message, "data", NS_BOB) ; |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
490 | data_tag ; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
491 | data_tag = purple_xmlnode_get_next_twin(data_tag)) { |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
492 | const gchar *cid = purple_xmlnode_get_attrib(data_tag, "cid"); |
|
29912
4f8e1c3bbc4a
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <malu@pidgin.im>
parents:
29910
diff
changeset
|
493 | const JabberData *data = jabber_data_find_remote_by_cid(js, who, cid); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
494 | |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
495 | if (!data && cid != NULL) { |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
496 | /* we haven't cached this already, let's add it */ |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
497 | JabberData *new_data = jabber_data_create_from_xml(data_tag); |
|
29910
f1c6e586e5c1
jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <malu@pidgin.im>
parents:
29906
diff
changeset
|
498 | |
|
f1c6e586e5c1
jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <malu@pidgin.im>
parents:
29906
diff
changeset
|
499 | if (new_data) { |
|
29912
4f8e1c3bbc4a
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <malu@pidgin.im>
parents:
29910
diff
changeset
|
500 | jabber_data_associate_remote(js, who, new_data); |
|
29910
f1c6e586e5c1
jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <malu@pidgin.im>
parents:
29906
diff
changeset
|
501 | } |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
502 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
503 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
504 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
505 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
506 | static void |
|
38282
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
507 | jabber_message_remote_smiley_got(JabberData *jdata, gchar *alt, gpointer d) { |
|
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
508 | JabberMessageRemoteSmileyAddData *data = (JabberMessageRemoteSmileyAddData *)d; |
|
35746
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
509 | |
|
38282
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
510 | if (jdata) { |
|
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
511 | PurpleSmiley *smiley = NULL; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
512 | |
|
35746
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
513 | purple_debug_info("jabber", |
|
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
514 | "smiley data retrieved successfully"); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
515 | |
|
38282
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
516 | smiley = purple_smiley_new_from_data( |
|
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
517 | data->shortcut, |
|
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
518 | jabber_data_get_data(jdata), |
|
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
519 | jabber_data_get_size(jdata) |
|
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
520 | ); |
|
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
521 | |
|
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
522 | purple_conversation_add_smiley(data->conv, smiley); |
|
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
523 | |
|
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
524 | g_object_unref(G_OBJECT(smiley)); |
|
35746
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
525 | } else { |
|
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
526 | purple_debug_error("jabber", "failed retrieving smiley data"); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
527 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
528 | |
|
38282
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
529 | g_object_unref(G_OBJECT(data->conv)); |
|
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
530 | g_free(data->shortcut); |
|
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
531 | g_slice_free(JabberMessageRemoteSmileyAddData, data); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
532 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
533 | |
|
35746
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
534 | static void |
|
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
535 | jabber_message_remote_smiley_add(JabberStream *js, PurpleConversation *conv, |
|
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
536 | const gchar *from, const gchar *shortcut, const gchar *cid) |
|
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
537 | { |
|
38281
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
37423
diff
changeset
|
538 | PurpleSmiley *smiley = NULL; |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
37423
diff
changeset
|
539 | const JabberData *jdata = NULL; |
|
35746
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
540 | |
|
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
541 | purple_debug_misc("jabber", "about to add remote smiley %s to the conv", |
|
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
542 | shortcut); |
|
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
543 | |
|
38281
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
37423
diff
changeset
|
544 | smiley = purple_conversation_get_smiley(conv, shortcut); |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
37423
diff
changeset
|
545 | if(PURPLE_IS_SMILEY(smiley)) { |
|
35746
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
546 | purple_debug_misc("jabber", "smiley was already present"); |
|
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
547 | return; |
|
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
548 | } |
|
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
549 | |
|
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
550 | /* TODO: cache lookup by "cid" */ |
|
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
551 | jdata = jabber_data_find_remote_by_cid(js, from, cid); |
|
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
552 | if (jdata) { |
|
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
553 | purple_debug_info("jabber", "smiley data is already known"); |
|
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
554 | |
|
38282
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
555 | smiley = purple_smiley_new_from_data( |
|
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
556 | shortcut, |
|
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
557 | jabber_data_get_data(jdata), |
|
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
558 | jabber_data_get_size(jdata) |
|
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
559 | ); |
|
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
560 | |
|
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
561 | purple_conversation_add_smiley(conv, smiley); |
|
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
562 | |
|
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
563 | g_object_unref(G_OBJECT(smiley)); |
|
35746
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
564 | } else { |
|
38282
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
565 | JabberMessageRemoteSmileyAddData *data = NULL; |
|
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
566 | |
|
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
567 | data = g_slice_new(JabberMessageRemoteSmileyAddData); |
|
39065
3997b9da75e8
jabber: Fix assignment from incompatible pointer type warning
Mike Ruprecht <cmaiku@gmail.com>
parents:
38358
diff
changeset
|
568 | data->conv = g_object_ref(conv); |
|
38282
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
569 | data->shortcut = g_strdup(shortcut); |
|
35746
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
570 | |
|
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
571 | purple_debug_info("jabber", "smiley data is unknown, " |
|
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
572 | "need to request it"); |
|
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
573 | |
|
38282
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
574 | jabber_data_request(js, cid, from, NULL, FALSE, |
|
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
575 | jabber_message_remote_smiley_got, data); |
|
35746
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
576 | } |
|
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
577 | } |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
578 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
579 | void jabber_message_parse(JabberStream *js, PurpleXmlNode *packet) |
| 7014 | 580 | { |
| 581 | 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
|
582 | const char *id, *from, *to, *type; |
|
40594
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
583 | 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
|
584 | gboolean signal_return; |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
585 | 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
|
586 | 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
|
587 | |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
588 | /* 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
|
589 | from = purple_xmlnode_get_attrib(packet, "from"); |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
590 | 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
|
591 | PurpleXmlNode *forwarded = NULL; |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
592 | |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
593 | /* 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
|
594 | 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
|
595 | NS_MESSAGE_CARBONS); |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
596 | if(received != NULL) { |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
597 | 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
|
598 | "forwarded", |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
599 | NS_FORWARD); |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
600 | } else { |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
601 | PurpleXmlNode *sent = NULL; |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
602 | |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
603 | 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
|
604 | NS_MESSAGE_CARBONS); |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
605 | if(sent != NULL) { |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
606 | 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
|
607 | "forwarded", |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
608 | NS_FORWARD); |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
609 | is_outgoing = TRUE; |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
610 | } |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
611 | } |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
612 | |
|
40594
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
613 | if(forwarded != NULL) { |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
614 | PurpleXmlNode *fwd_msg = NULL; |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
615 | |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
616 | 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
|
617 | "message", |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
618 | NS_XMPP_CLIENT); |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
619 | if(fwd_msg != NULL) { |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
620 | PurpleXmlNode *delay = NULL; |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
621 | |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
622 | /* 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
|
623 | * to it directly. |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
624 | */ |
|
40594
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
625 | packet = fwd_msg; |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
626 | is_forwarded = TRUE; |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
627 | |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
628 | /* 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
|
629 | * timestamp that the server sent. |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
630 | */ |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
631 | 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
|
632 | "delay", |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
633 | NS_DELAYED_DELIVERY); |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
634 | if(delay != NULL) { |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
635 | 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
|
636 | "stamp"); |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
637 | |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
638 | 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
|
639 | delayed = TRUE; |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
640 | } |
|
40594
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
641 | } |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
642 | } |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
643 | } |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
644 | |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
645 | /* 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
|
646 | * message. |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
647 | */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
648 | 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
|
649 | id = purple_xmlnode_get_attrib(packet, "id"); |
|
e32ab786a04f
Finally add XMPP Message Carbons XEP-0280
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
650 | 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
|
651 | 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
|
652 | |
|
36623
caaadef03507
Renamed purple_connection_get_protocol_info() to purple_connection_get_protocol()
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
653 | 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
|
654 | "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
|
655 | 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
|
656 | return; |
| 7014 | 657 | |
| 658 | jm = g_new0(JabberMessage, 1); | |
| 659 | jm->js = js; | |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
660 | jm->sent = timestamp; |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
661 | jm->delayed = delayed; |
|
27429
3313d7d74962
Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
662 | jm->chat_state = JM_STATE_NONE; |
|
40742
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
663 | jm->forwarded = is_forwarded; |
|
2fc55152b79c
Fix up the XEP-0280 carbons support.
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
664 | jm->outgoing = is_outgoing; |
| 7014 | 665 | |
| 666 | if(type) { | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
667 | if(purple_strequal(type, "normal")) |
| 7014 | 668 | jm->type = JABBER_MESSAGE_NORMAL; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
669 | else if(purple_strequal(type, "chat")) |
| 7014 | 670 | jm->type = JABBER_MESSAGE_CHAT; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
671 | else if(purple_strequal(type, "groupchat")) |
| 7014 | 672 | jm->type = JABBER_MESSAGE_GROUPCHAT; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
673 | else if(purple_strequal(type, "headline")) |
| 7014 | 674 | jm->type = JABBER_MESSAGE_HEADLINE; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
675 | else if(purple_strequal(type, "error")) |
| 7014 | 676 | jm->type = JABBER_MESSAGE_ERROR; |
| 677 | else | |
| 678 | jm->type = JABBER_MESSAGE_OTHER; | |
| 679 | } else { | |
| 680 | jm->type = JABBER_MESSAGE_NORMAL; | |
| 681 | } | |
| 682 | ||
|
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
|
683 | 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
|
684 | 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
|
685 | jm->id = g_strdup(id); |
| 7014 | 686 | |
| 687 | 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
|
688 | 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
|
689 | if(child->type != PURPLE_XMLNODE_TYPE_TAG) |
| 7014 | 690 | continue; |
| 691 | ||
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
692 | 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
|
693 | 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
|
694 | 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
|
695 | 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
|
696 | if (!text) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
697 | 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
|
698 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
699 | 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
|
700 | 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
|
701 | } |
|
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
|
702 | |
|
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
|
703 | 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
|
704 | 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
|
705 | |
|
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
|
706 | 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
|
707 | 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
|
708 | 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
|
709 | 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
|
710 | 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
|
711 | |
|
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
|
712 | 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
|
713 | 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
|
714 | } 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
|
715 | /* 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
|
716 | with the previous code. */ |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
717 | 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
|
718 | 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
|
719 | /* 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
|
720 | continue; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
721 | } 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
|
722 | 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
|
723 | 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
|
724 | 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
|
725 | 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
|
726 | } |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
727 | } else if(purple_strequal(child->name, "thread") && purple_strequal(xmlns, NS_XMPP_CLIENT)) { |
| 8400 | 728 | 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
|
729 | jm->thread_id = purple_xmlnode_get_data(child); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
730 | } else if(purple_strequal(child->name, "body") && purple_strequal(xmlns, NS_XMPP_CLIENT)) { |
| 13385 | 731 | 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
|
732 | 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
|
733 | 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
|
734 | 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
|
735 | g_free(escaped); |
| 13385 | 736 | g_free(msg); |
| 737 | } | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
738 | } 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
|
739 | 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
|
740 | char *c; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
741 | |
|
39433
f033955d125a
Use G_DEFINE_TYPE_WITH_PRIVATE for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39065
diff
changeset
|
742 | PurpleConnection *gc = js->gc; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
743 | PurpleAccount *account = purple_connection_get_account(gc); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
744 | PurpleConversation *conv = NULL; |
|
35746
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
745 | GList *smiley_refs = NULL, *it; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
746 | gchar *reformatted_xhtml; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
747 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
748 | if (purple_account_get_bool(account, "custom_smileys", TRUE)) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
749 | /* find a list of smileys ("cid" and "alt" text pairs) |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
750 | occuring in the message */ |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
751 | smiley_refs = jabber_message_get_refs_from_xmlnode(child); |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
752 | purple_debug_info("jabber", "found %d smileys\n", |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
753 | g_list_length(smiley_refs)); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
754 | |
|
27155
53502d71efdd
Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents:
27131
diff
changeset
|
755 | if (smiley_refs) { |
|
26711
07cfe1520055
Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <malu@pidgin.im>
parents:
26687
diff
changeset
|
756 | if (jm->type == JABBER_MESSAGE_GROUPCHAT) { |
|
07cfe1520055
Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <malu@pidgin.im>
parents:
26687
diff
changeset
|
757 | JabberID *jid = jabber_id_new(jm->from); |
|
07cfe1520055
Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <malu@pidgin.im>
parents:
26687
diff
changeset
|
758 | JabberChat *chat = NULL; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
759 | |
|
26711
07cfe1520055
Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <malu@pidgin.im>
parents:
26687
diff
changeset
|
760 | if (jid) { |
|
07cfe1520055
Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <malu@pidgin.im>
parents:
26687
diff
changeset
|
761 | chat = jabber_chat_find(js, jid->node, jid->domain); |
|
27782
68314a2ac01b
Break the 'if' onto two lines and don't bother calling jabber_id_free()
Mark Doliner <markdoliner@pidgin.im>
parents:
27750
diff
changeset
|
762 | if (chat) |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
763 | conv = PURPLE_CONVERSATION(chat->conv); |
|
27782
68314a2ac01b
Break the 'if' onto two lines and don't bother calling jabber_id_free()
Mark Doliner <markdoliner@pidgin.im>
parents:
27750
diff
changeset
|
764 | jabber_id_free(jid); |
|
26711
07cfe1520055
Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <malu@pidgin.im>
parents:
26687
diff
changeset
|
765 | } |
|
26867
20bf84d510d8
Only look for and add custom smileys to incoming messages that are going to
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
766 | } else if (jm->type == JABBER_MESSAGE_NORMAL || |
|
20bf84d510d8
Only look for and add custom smileys to incoming messages that are going to
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
767 | jm->type == JABBER_MESSAGE_CHAT) { |
|
26711
07cfe1520055
Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <malu@pidgin.im>
parents:
26687
diff
changeset
|
768 | conv = |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
769 | purple_conversations_find_with_account(from, account); |
|
26711
07cfe1520055
Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <malu@pidgin.im>
parents:
26687
diff
changeset
|
770 | if (!conv) { |
|
07cfe1520055
Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <malu@pidgin.im>
parents:
26687
diff
changeset
|
771 | /* we need to create the conversation here */ |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
772 | conv = PURPLE_CONVERSATION( |
|
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
773 | purple_im_conversation_new(account, from)); |
|
26711
07cfe1520055
Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <malu@pidgin.im>
parents:
26687
diff
changeset
|
774 | } |
|
24257
d6402f066933
Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <malu@pidgin.im>
parents:
24254
diff
changeset
|
775 | } |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
776 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
777 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
778 | /* process any newly provided smileys */ |
|
29912
4f8e1c3bbc4a
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <malu@pidgin.im>
parents:
29910
diff
changeset
|
779 | jabber_message_add_remote_smileys(js, to, packet); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
780 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
781 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
782 | purple_xmlnode_strip_prefixes(child); |
|
32323
df78cc32b2cd
jabber: Strip element prefixes on XHTML-IM content.
Paul Aurich <darkrain42@pidgin.im>
parents:
32277
diff
changeset
|
783 | |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
784 | /* 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
|
785 | 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
|
786 | /* 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
|
787 | 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
|
788 | reformatted_xhtml = |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
789 | 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
|
790 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
791 | jm->xhtml = reformatted_xhtml; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
792 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
793 | /* add known custom emoticons to the conversation */ |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
794 | /* note: if there were no smileys in the incoming message, or |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
795 | if receiving custom smileys is turned off, smiley_refs will |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
796 | be NULL */ |
|
35746
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
797 | for (it = smiley_refs; it; it = g_list_next(it)) { |
|
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
798 | JabberSmileyRef *ref = it->data; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
799 | |
|
35746
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
800 | if (conv) { |
|
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
801 | jabber_message_remote_smiley_add(js, |
|
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
802 | conv, from, ref->alt, ref->cid); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
803 | } |
|
35746
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
804 | |
|
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
|
805 | g_free(ref->cid); |
|
cba0cfba936e
Another memory leak fix. Also, keep a copy of the alt-text in
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24386
diff
changeset
|
806 | g_free(ref->alt); |
|
cba0cfba936e
Another memory leak fix. Also, keep a copy of the alt-text in
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24386
diff
changeset
|
807 | g_free(ref); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
808 | } |
|
35746
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35745
diff
changeset
|
809 | g_list_free(smiley_refs); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
810 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
811 | /* 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
|
812 | * 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
|
813 | */ |
|
7a5668fb7bad
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents:
16961
diff
changeset
|
814 | 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
|
815 | if (*c == '\n') |
|
17328
7a5668fb7bad
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents:
16961
diff
changeset
|
816 | *c = ' '; |
|
7a5668fb7bad
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents:
16961
diff
changeset
|
817 | } |
|
7a5668fb7bad
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents:
16961
diff
changeset
|
818 | } |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
819 | } else if(purple_strequal(child->name, "active") && purple_strequal(xmlns,"http://jabber.org/protocol/chatstates")) { |
| 13708 | 820 | jm->chat_state = JM_STATE_ACTIVE; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
821 | } else if(purple_strequal(child->name, "composing") && purple_strequal(xmlns,"http://jabber.org/protocol/chatstates")) { |
| 13708 | 822 | jm->chat_state = JM_STATE_COMPOSING; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
823 | } else if(purple_strequal(child->name, "paused") && purple_strequal(xmlns,"http://jabber.org/protocol/chatstates")) { |
| 13708 | 824 | jm->chat_state = JM_STATE_PAUSED; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
825 | } else if(purple_strequal(child->name, "inactive") && purple_strequal(xmlns,"http://jabber.org/protocol/chatstates")) { |
| 13708 | 826 | jm->chat_state = JM_STATE_INACTIVE; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
827 | } else if(purple_strequal(child->name, "gone") && purple_strequal(xmlns,"http://jabber.org/protocol/chatstates")) { |
| 13708 | 828 | jm->chat_state = JM_STATE_GONE; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
829 | } 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
|
830 | PurpleXmlNode *items; |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17776
diff
changeset
|
831 | 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
|
832 | 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
|
833 | jm->eventitems = g_list_append(jm->eventitems, items); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
834 | } 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
|
835 | jm->hasBuzz = TRUE; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
836 | } 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
|
837 | 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
|
838 | jm->delayed = TRUE; |
|
d9a7ec9277f6
Implemented XEP-0203: Delayed Delivery
Andreas Monitzer <am@adiumx.com>
parents:
17792
diff
changeset
|
839 | if(timestamp) |
|
d9a7ec9277f6
Implemented XEP-0203: Delayed Delivery
Andreas Monitzer <am@adiumx.com>
parents:
17792
diff
changeset
|
840 | 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
|
841 | } else if(purple_strequal(child->name, "x")) { |
|
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
842 | 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
|
843 | const char *timestamp = purple_xmlnode_get_attrib(child, "stamp"); |
|
27434
7d8b32345d10
disapproval of revision '0c1545afc98299c6d7004554eb7443091d42e8ca'
Paul Aurich <darkrain42@pidgin.im>
parents:
27431
diff
changeset
|
844 | jm->delayed = TRUE; |
|
7d8b32345d10
disapproval of revision '0c1545afc98299c6d7004554eb7443091d42e8ca'
Paul Aurich <darkrain42@pidgin.im>
parents:
27431
diff
changeset
|
845 | if(timestamp) |
|
7d8b32345d10
disapproval of revision '0c1545afc98299c6d7004554eb7443091d42e8ca'
Paul Aurich <darkrain42@pidgin.im>
parents:
27431
diff
changeset
|
846 | 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
|
847 | } else if(purple_strequal(xmlns, "jabber:x:conference") && |
| 11230 | 848 | jm->type != JABBER_MESSAGE_GROUPCHAT_INVITE && |
| 849 | 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
|
850 | const char *jid = purple_xmlnode_get_attrib(child, "jid"); |
| 7014 | 851 | if(jid) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
852 | 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
|
853 | 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
|
854 | |
| 7014 | 855 | jm->type = JABBER_MESSAGE_GROUPCHAT_INVITE; |
| 856 | g_free(jm->to); | |
| 857 | 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
|
858 | |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
859 | if (reason) { |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
860 | 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
|
861 | 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
|
862 | } |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
863 | |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
864 | if (password) { |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
865 | 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
|
866 | 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
|
867 | } |
| 7014 | 868 | } |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
869 | } else if(purple_strequal(xmlns, "http://jabber.org/protocol/muc#user") && |
| 11230 | 870 | 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
|
871 | PurpleXmlNode *invite = purple_xmlnode_get_child(child, "invite"); |
| 7014 | 872 | if(invite) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
873 | PurpleXmlNode *reason, *password; |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
874 | const char *jid = purple_xmlnode_get_attrib(invite, "from"); |
| 7014 | 875 | g_free(jm->to); |
| 876 | jm->to = jm->from; | |
| 877 | 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
|
878 | if((reason = purple_xmlnode_get_child(invite, "reason"))) { |
| 7014 | 879 | 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
|
880 | jm->body = purple_xmlnode_get_data(reason); |
| 7014 | 881 | } |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
882 | 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
|
883 | 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
|
884 | 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
|
885 | } |
| 7014 | 886 | |
| 887 | jm->type = JABBER_MESSAGE_GROUPCHAT_INVITE; | |
| 888 | } | |
| 7145 | 889 | } else { |
| 890 | jm->etc = g_list_append(jm->etc, child); | |
| 7014 | 891 | } |
|
38256
035f00c4fd87
Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
31512
diff
changeset
|
892 | } 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
|
893 | 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
|
894 | 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
|
895 | && 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
|
896 | 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
|
897 | } |
| 7014 | 898 | } |
| 899 | } | |
| 900 | ||
|
17822
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
901 | if(jm->hasBuzz) |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
902 | handle_buzz(jm); |
| 7014 | 903 | |
| 904 | switch(jm->type) { | |
|
27900
23b6b4dfeb82
Allow fallback for broken XMPP <message/> types. Closes #7837.
Paul Aurich <darkrain42@pidgin.im>
parents:
27844
diff
changeset
|
905 | case JABBER_MESSAGE_OTHER: |
|
28828
7c1855f037e7
jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <darkrain42@pidgin.im>
parents:
28726
diff
changeset
|
906 | purple_debug_info("jabber", |
|
27900
23b6b4dfeb82
Allow fallback for broken XMPP <message/> types. Closes #7837.
Paul Aurich <darkrain42@pidgin.im>
parents:
27844
diff
changeset
|
907 | "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
|
908 | /* Fall-through is intentional */ |
| 7014 | 909 | case JABBER_MESSAGE_NORMAL: |
| 910 | case JABBER_MESSAGE_CHAT: | |
| 7145 | 911 | handle_chat(jm); |
| 912 | break; | |
| 7014 | 913 | case JABBER_MESSAGE_HEADLINE: |
| 7145 | 914 | handle_headline(jm); |
| 7014 | 915 | break; |
| 916 | case JABBER_MESSAGE_GROUPCHAT: | |
| 917 | handle_groupchat(jm); | |
| 918 | break; | |
| 919 | case JABBER_MESSAGE_GROUPCHAT_INVITE: | |
| 920 | handle_groupchat_invite(jm); | |
| 921 | break; | |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17776
diff
changeset
|
922 | case JABBER_MESSAGE_EVENT: |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17776
diff
changeset
|
923 | jabber_handle_event(jm); |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17776
diff
changeset
|
924 | break; |
| 7014 | 925 | case JABBER_MESSAGE_ERROR: |
| 926 | handle_error(jm); | |
| 927 | break; | |
| 928 | } | |
| 929 | jabber_message_free(jm); | |
| 930 | } | |
| 931 | ||
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
932 | static gboolean |
| 29366 | 933 | jabber_conv_support_custom_smileys(JabberStream *js, |
|
40293
c60c4f96749d
Fix some line wrapping
Richard Laager <rlaager@pidgin.im>
parents:
40290
diff
changeset
|
934 | PurpleConversation *conv, const gchar *who) |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
935 | { |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
936 | JabberBuddy *jb; |
|
27110
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27103
diff
changeset
|
937 | JabberChat *chat; |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
938 | |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
939 | if (PURPLE_IS_IM_CONVERSATION(conv)) { |
|
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
940 | jb = jabber_buddy_find(js, who, FALSE); |
|
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
941 | if (jb) { |
|
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
942 | return jabber_buddy_has_capability(jb, NS_BOB); |
|
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
943 | } else { |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
944 | return FALSE; |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
945 | } |
|
35070
d7350d876fda
libpurple: Don't assume a conversation is always an IM or a chat
Ankit Vani <a@nevitus.org>
parents:
34935
diff
changeset
|
946 | } else if (PURPLE_IS_CHAT_CONVERSATION(conv)) { |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
947 | chat = jabber_chat_find_by_conv(PURPLE_CHAT_CONVERSATION(conv)); |
|
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
948 | if (chat) { |
|
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
949 | /* do not attempt to send custom smileys in a MUC with more than |
|
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
950 | 10 people, to avoid getting too many BoB requests */ |
|
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
951 | return jabber_chat_get_num_participants(chat) <= 10 && |
|
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
952 | jabber_chat_all_participants_have_capability(chat, |
|
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
953 | NS_BOB); |
|
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
954 | } else { |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
955 | return FALSE; |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
956 | } |
|
35070
d7350d876fda
libpurple: Don't assume a conversation is always an IM or a chat
Ankit Vani <a@nevitus.org>
parents:
34935
diff
changeset
|
957 | } else { |
|
d7350d876fda
libpurple: Don't assume a conversation is always an IM or a chat
Ankit Vani <a@nevitus.org>
parents:
34935
diff
changeset
|
958 | return FALSE; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
959 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
960 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
961 | |
|
35788
afa6d777bc7c
Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35787
diff
changeset
|
962 | static gboolean |
|
afa6d777bc7c
Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35787
diff
changeset
|
963 | jabber_message_smileyify_cb(GString *out, PurpleSmiley *smiley, |
|
afa6d777bc7c
Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35787
diff
changeset
|
964 | PurpleConversation *_empty, gpointer _unused) |
|
afa6d777bc7c
Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35787
diff
changeset
|
965 | { |
|
afa6d777bc7c
Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35787
diff
changeset
|
966 | const gchar *shortcut; |
|
afa6d777bc7c
Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35787
diff
changeset
|
967 | const JabberData *data; |
|
afa6d777bc7c
Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35787
diff
changeset
|
968 | PurpleXmlNode *smiley_node; |
|
afa6d777bc7c
Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35787
diff
changeset
|
969 | gchar *node_xml; |
|
afa6d777bc7c
Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35787
diff
changeset
|
970 | |
|
afa6d777bc7c
Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35787
diff
changeset
|
971 | shortcut = purple_smiley_get_shortcut(smiley); |
|
afa6d777bc7c
Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35787
diff
changeset
|
972 | data = jabber_data_find_local_by_alt(shortcut); |
|
afa6d777bc7c
Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35787
diff
changeset
|
973 | |
|
afa6d777bc7c
Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35787
diff
changeset
|
974 | if (!data) |
|
afa6d777bc7c
Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35787
diff
changeset
|
975 | return FALSE; |
|
afa6d777bc7c
Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35787
diff
changeset
|
976 | |
|
afa6d777bc7c
Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35787
diff
changeset
|
977 | smiley_node = jabber_data_get_xhtml_im(data, shortcut); |
|
afa6d777bc7c
Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35787
diff
changeset
|
978 | node_xml = purple_xmlnode_to_str(smiley_node, NULL); |
|
afa6d777bc7c
Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35787
diff
changeset
|
979 | |
|
afa6d777bc7c
Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35787
diff
changeset
|
980 | g_string_append(out, node_xml); |
|
afa6d777bc7c
Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35787
diff
changeset
|
981 | |
|
afa6d777bc7c
Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35787
diff
changeset
|
982 | purple_xmlnode_free(smiley_node); |
|
afa6d777bc7c
Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35787
diff
changeset
|
983 | g_free(node_xml); |
|
afa6d777bc7c
Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35787
diff
changeset
|
984 | |
|
afa6d777bc7c
Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35787
diff
changeset
|
985 | return TRUE; |
|
afa6d777bc7c
Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35787
diff
changeset
|
986 | } |
|
afa6d777bc7c
Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35787
diff
changeset
|
987 | |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
988 | static char * |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
989 | jabber_message_smileyfy_xhtml(JabberMessage *jm, const char *xhtml) |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
990 | { |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
991 | PurpleAccount *account = purple_connection_get_account(jm->js->gc); |
|
35757
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
992 | GList *found_smileys, *it, *it_next; |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
993 | PurpleConversation *conv; |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
994 | gboolean has_too_large_smiley = FALSE; |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
995 | gchar *smileyfied_xhtml = NULL; |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
996 | |
|
35757
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
997 | conv = purple_conversations_find_with_account(jm->to, account); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30744
diff
changeset
|
998 | |
|
35758
87c51487e197
Fix g_slist_remove_link misuse, remove debug printfs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35757
diff
changeset
|
999 | if (!jabber_conv_support_custom_smileys(jm->js, conv, jm->to)) |
|
35757
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1000 | return NULL; |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1001 | |
|
35792
d18a48a68edf
Smiley parser: better symbol names
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35788
diff
changeset
|
1002 | found_smileys = purple_smiley_parser_find( |
|
d18a48a68edf
Smiley parser: better symbol names
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35788
diff
changeset
|
1003 | purple_smiley_custom_get_list(), xhtml, TRUE); |
|
35758
87c51487e197
Fix g_slist_remove_link misuse, remove debug printfs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35757
diff
changeset
|
1004 | if (!found_smileys) |
|
35757
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1005 | return NULL; |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1006 | |
|
35757
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1007 | for (it = found_smileys; it; it = it_next) { |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1008 | PurpleSmiley *smiley = it->data; |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1009 | gboolean valid = TRUE; |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1010 | |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1011 | it_next = g_list_next(it); |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1012 | |
|
38298
f0a8f63f9312
rename purple_image_get_size to purple_image_get_data_size and deal with the fallout
Gary Kramlich <grim@reaperworld.com>
parents:
38287
diff
changeset
|
1013 | if (purple_image_get_data_size(PURPLE_IMAGE(smiley)) > JABBER_DATA_MAX_SIZE) { |
|
35757
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1014 | has_too_large_smiley = TRUE; |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1015 | valid = FALSE; |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1016 | purple_debug_warning("jabber", "Refusing to send " |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1017 | "smiley %s (too large, max is %d)", |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1018 | purple_smiley_get_shortcut(smiley), |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1019 | JABBER_DATA_MAX_SIZE); |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1020 | } |
|
29270
642d7a9e5f0a
jabber: Don't print the smiley shortcut in the error message when trying to
Marcus Lundblad <malu@pidgin.im>
parents:
29269
diff
changeset
|
1021 | |
|
35757
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1022 | if (!valid) |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1023 | found_smileys = g_list_delete_link(found_smileys, it); |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1024 | } |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1025 | |
|
35757
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1026 | if (has_too_large_smiley) { |
|
36089
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36084
diff
changeset
|
1027 | purple_conversation_write_system_message(conv, |
|
35757
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1028 | _("A custom smiley in the message is too large to send."), |
|
36089
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36084
diff
changeset
|
1029 | PURPLE_MESSAGE_ERROR); |
|
35757
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1030 | } |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1031 | |
|
35758
87c51487e197
Fix g_slist_remove_link misuse, remove debug printfs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35757
diff
changeset
|
1032 | if (!found_smileys) |
|
35757
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1033 | return NULL; |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1034 | |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1035 | for (it = found_smileys; it; it = g_list_next(it)) { |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1036 | PurpleSmiley *smiley = it->data; |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1037 | const gchar *shortcut = purple_smiley_get_shortcut(smiley); |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1038 | const gchar *mimetype; |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1039 | JabberData *jdata; |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1040 | |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1041 | /* the object has been sent before */ |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1042 | if (jabber_data_find_local_by_alt(shortcut)) |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1043 | continue; |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1044 | |
|
38282
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
1045 | mimetype = purple_image_get_mimetype(PURPLE_IMAGE(smiley)); |
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35792
diff
changeset
|
1046 | if (!mimetype) { |
|
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35792
diff
changeset
|
1047 | purple_debug_error("jabber", |
|
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35792
diff
changeset
|
1048 | "unknown mime type for image"); |
|
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35792
diff
changeset
|
1049 | continue; |
|
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35792
diff
changeset
|
1050 | } |
|
35757
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1051 | |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1052 | jdata = jabber_data_create_from_data( |
|
38282
be08ec8b8628
This should finish off the jabber issues with smileys now being an image subclass
Gary Kramlich <grim@reaperworld.com>
parents:
38281
diff
changeset
|
1053 | purple_image_get_data(PURPLE_IMAGE(smiley)), |
|
38298
f0a8f63f9312
rename purple_image_get_size to purple_image_get_data_size and deal with the fallout
Gary Kramlich <grim@reaperworld.com>
parents:
38287
diff
changeset
|
1054 | purple_image_get_data_size(PURPLE_IMAGE(smiley)), |
|
35757
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1055 | mimetype, FALSE, jm->js); |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1056 | |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1057 | purple_debug_info("jabber", "cache local smiley alt=%s, cid=%s", |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1058 | shortcut, jabber_data_get_cid(jdata)); |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1059 | jabber_data_associate_local(jdata, shortcut); |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1060 | } |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1061 | |
|
35788
afa6d777bc7c
Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35787
diff
changeset
|
1062 | g_list_free(found_smileys); |
|
35757
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1063 | |
|
35792
d18a48a68edf
Smiley parser: better symbol names
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35788
diff
changeset
|
1064 | smileyfied_xhtml = purple_smiley_parser_replace( |
|
d18a48a68edf
Smiley parser: better symbol names
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35788
diff
changeset
|
1065 | purple_smiley_custom_get_list(), xhtml, |
|
35788
afa6d777bc7c
Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35787
diff
changeset
|
1066 | jabber_message_smileyify_cb, NULL); |
|
35757
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1067 | |
|
05981ff3fb7b
Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
1068 | return smileyfied_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
|
1069 | } |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1070 | |
| 7014 | 1071 | void jabber_message_send(JabberMessage *jm) |
| 1072 | { | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1073 | PurpleXmlNode *message, *child; |
| 7014 | 1074 | const char *type = NULL; |
| 1075 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1076 | message = purple_xmlnode_new("message"); |
| 7014 | 1077 | |
| 1078 | switch(jm->type) { | |
| 1079 | case JABBER_MESSAGE_NORMAL: | |
| 1080 | type = "normal"; | |
| 1081 | break; | |
| 1082 | case JABBER_MESSAGE_CHAT: | |
| 1083 | case JABBER_MESSAGE_GROUPCHAT_INVITE: | |
| 1084 | type = "chat"; | |
| 1085 | break; | |
| 1086 | case JABBER_MESSAGE_HEADLINE: | |
| 1087 | type = "headline"; | |
| 1088 | break; | |
| 1089 | case JABBER_MESSAGE_GROUPCHAT: | |
| 1090 | type = "groupchat"; | |
| 1091 | break; | |
| 1092 | case JABBER_MESSAGE_ERROR: | |
| 1093 | type = "error"; | |
| 1094 | break; | |
| 1095 | 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
|
1096 | default: |
| 7014 | 1097 | type = NULL; |
| 1098 | break; | |
| 1099 | } | |
| 1100 | ||
| 1101 | if(type) | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1102 | 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
|
1103 | |
| 13484 | 1104 | 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
|
1105 | purple_xmlnode_set_attrib(message, "id", jm->id); |
| 7014 | 1106 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1107 | purple_xmlnode_set_attrib(message, "to", jm->to); |
| 7014 | 1108 | |
| 8400 | 1109 | 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
|
1110 | 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
|
1111 | purple_xmlnode_insert_data(child, jm->thread_id, -1); |
| 8400 | 1112 | } |
| 1113 | ||
| 27432 | 1114 | child = NULL; |
| 1115 | switch(jm->chat_state) | |
| 1116 | { | |
| 1117 | 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
|
1118 | child = purple_xmlnode_new_child(message, "active"); |
| 27432 | 1119 | break; |
| 1120 | 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
|
1121 | child = purple_xmlnode_new_child(message, "composing"); |
| 27432 | 1122 | break; |
| 1123 | 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
|
1124 | child = purple_xmlnode_new_child(message, "paused"); |
| 27432 | 1125 | break; |
| 1126 | 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
|
1127 | child = purple_xmlnode_new_child(message, "inactive"); |
| 27432 | 1128 | break; |
| 1129 | 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
|
1130 | child = purple_xmlnode_new_child(message, "gone"); |
| 27432 | 1131 | break; |
| 1132 | case JM_STATE_NONE: | |
| 1133 | /* yep, nothing */ | |
| 1134 | break; | |
| 7014 | 1135 | } |
| 27432 | 1136 | if(child) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1137 | purple_xmlnode_set_namespace(child, "http://jabber.org/protocol/chatstates"); |
| 13708 | 1138 | |
| 7014 | 1139 | 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
|
1140 | 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
|
1141 | purple_xmlnode_insert_data(child, jm->subject, -1); |
| 7014 | 1142 | } |
| 1143 | ||
| 1144 | 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
|
1145 | 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
|
1146 | purple_xmlnode_insert_data(child, jm->body, -1); |
| 7014 | 1147 | } |
| 1148 | ||
| 1149 | 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
|
1150 | 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
|
1151 | purple_xmlnode_insert_child(message, child); |
| 7014 | 1152 | } else { |
|
28828
7c1855f037e7
jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <darkrain42@pidgin.im>
parents:
28726
diff
changeset
|
1153 | purple_debug_error("jabber", |
| 7014 | 1154 | "XHTML translation/validation failed, returning: %s\n", |
| 1155 | jm->xhtml); | |
| 1156 | } | |
| 1157 | } | |
| 1158 | ||
| 1159 | jabber_send(jm->js, message); | |
| 1160 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1161 | purple_xmlnode_free(message); |
| 7014 | 1162 | } |
| 1163 | ||
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1164 | /* |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1165 | * 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
|
1166 | * 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
|
1167 | * FALSE. |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1168 | */ |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1169 | static gboolean |
|
40293
c60c4f96749d
Fix some line wrapping
Richard Laager <rlaager@pidgin.im>
parents:
40290
diff
changeset
|
1170 | 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
|
1171 | { |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1172 | 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
|
1173 | 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
|
1174 | 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
|
1175 | 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
|
1176 | |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1177 | 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
|
1178 | 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
|
1179 | 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
|
1180 | 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
|
1181 | continue; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1182 | } |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1183 | |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1184 | 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
|
1185 | 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
|
1186 | 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
|
1187 | continue; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1188 | } |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1189 | |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1190 | 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
|
1191 | 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
|
1192 | } |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1193 | |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1194 | /* 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
|
1195 | 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
|
1196 | 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
|
1197 | 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
|
1198 | } |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1199 | |
|
40507
77d7bc9e5151
Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
1200 | int jabber_message_send_im(PurpleProtocolIM *pim, PurpleConnection *gc, |
|
77d7bc9e5151
Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
1201 | PurpleMessage *msg) |
| 7014 | 1202 | { |
| 1203 | JabberMessage *jm; | |
| 1204 | JabberBuddy *jb; | |
| 1205 | JabberBuddyResource *jbr; | |
| 7135 | 1206 | 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
|
1207 | char *tmp; |
| 7306 | 1208 | char *resource; |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
1209 | const gchar *rcpt = purple_message_get_recipient(msg); |
| 7014 | 1210 | |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
1211 | if (!rcpt || purple_message_is_empty(msg)) |
| 7014 | 1212 | return 0; |
| 1213 | ||
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
1214 | 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
|
1215 | |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
1216 | jb = jabber_buddy_find(purple_connection_get_protocol_data(gc), rcpt, TRUE); |
| 7306 | 1217 | jbr = jabber_buddy_find_resource(jb, resource); |
| 1218 | ||
| 1219 | g_free(resource); | |
| 7014 | 1220 | |
| 1221 | 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
|
1222 | jm->js = purple_connection_get_protocol_data(gc); |
| 7014 | 1223 | jm->type = JABBER_MESSAGE_CHAT; |
| 13708 | 1224 | jm->chat_state = JM_STATE_ACTIVE; |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
1225 | jm->to = g_strdup(rcpt); |
| 13484 | 1226 | jm->id = jabber_get_next_id(jm->js); |
| 13708 | 1227 | |
| 1228 | if(jbr) { | |
| 1229 | if(jbr->thread_id) | |
| 1230 | jm->thread_id = jbr->thread_id; | |
| 1231 | ||
|
27429
3313d7d74962
Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
1232 | 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
|
1233 | jm->chat_state = JM_STATE_NONE; |
|
3313d7d74962
Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
1234 | else { |
| 13708 | 1235 | /* if(JABBER_CHAT_STATES_UNKNOWN == jbr->chat_states) |
| 1236 | jbr->chat_states = JABBER_CHAT_STATES_UNSUPPORTED; */ | |
| 1237 | } | |
| 1238 | } | |
| 7014 | 1239 | |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35838
diff
changeset
|
1240 | 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
|
1241 | 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
|
1242 | 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
|
1243 | |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1244 | tmp = jabber_message_smileyfy_xhtml(jm, xhtml); |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1245 | if (tmp) { |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1246 | 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
|
1247 | xhtml = tmp; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1248 | } |
| 7014 | 1249 | |
|
27746
4b3f015977d9
For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
1250 | /* |
|
4b3f015977d9
For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
1251 | * 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
|
1252 | * 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
|
1253 | */ |
|
4b3f015977d9
For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
1254 | 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
|
1255 | 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
|
1256 | 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
|
1257 | /* 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
|
1258 | 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
|
1259 | } |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1260 | |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1261 | g_free(xhtml); |
| 7014 | 1262 | |
| 1263 | jabber_message_send(jm); | |
| 1264 | jabber_message_free(jm); | |
| 1265 | return 1; | |
| 1266 | } | |
| 1267 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40594
diff
changeset
|
1268 | gint |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40594
diff
changeset
|
1269 | 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
|
1270 | PurpleConnection *gc, gint id, PurpleMessage *msg) |
| 7014 | 1271 | { |
| 1272 | JabberChat *chat; | |
| 1273 | JabberMessage *jm; | |
| 8042 | 1274 | 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
|
1275 | 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
|
1276 | char *tmp; |
| 7014 | 1277 | |
|
36077
b7328f4317c7
Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36076
diff
changeset
|
1278 | if (!gc || purple_message_is_empty(msg)) |
| 7014 | 1279 | return 0; |
| 1280 | ||
|
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
|
1281 | js = purple_connection_get_protocol_data(gc); |
| 7014 | 1282 | chat = jabber_chat_find_by_id(js, id); |
| 1283 | ||
| 8043 | 1284 | if(!chat) |
| 1285 | return 0; | |
| 1286 | ||
| 9130 | 1287 | 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
|
1288 | jm->js = purple_connection_get_protocol_data(gc); |
| 9130 | 1289 | jm->type = JABBER_MESSAGE_GROUPCHAT; |
| 1290 | jm->to = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 13484 | 1291 | jm->id = jabber_get_next_id(jm->js); |
| 9130 | 1292 | |
|
36077
b7328f4317c7
Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36076
diff
changeset
|
1293 | 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
|
1294 | 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
|
1295 | g_free(tmp); |
|
27110
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27103
diff
changeset
|
1296 | tmp = jabber_message_smileyfy_xhtml(jm, xhtml); |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27103
diff
changeset
|
1297 | if (tmp) { |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27103
diff
changeset
|
1298 | g_free(xhtml); |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27103
diff
changeset
|
1299 | xhtml = tmp; |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27103
diff
changeset
|
1300 | } |
| 8858 | 1301 | |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1302 | 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
|
1303 | /* 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
|
1304 | 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
|
1305 | |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1306 | g_free(xhtml); |
| 7923 | 1307 | |
| 9130 | 1308 | jabber_message_send(jm); |
| 1309 | jabber_message_free(jm); | |
| 1310 | ||
| 7014 | 1311 | return 1; |
| 1312 | } | |
| 1313 | ||
|
40507
77d7bc9e5151
Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
1314 | unsigned int jabber_send_typing(PurpleProtocolIM *pim, PurpleConnection *gc, |
|
77d7bc9e5151
Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
1315 | const char *who, PurpleIMTypingState state) |
| 7014 | 1316 | { |
|
30454
4e9bf65cfe9a
jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents:
30239
diff
changeset
|
1317 | JabberStream *js; |
| 7014 | 1318 | JabberMessage *jm; |
| 1319 | JabberBuddy *jb; | |
| 1320 | JabberBuddyResource *jbr; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30744
diff
changeset
|
1321 | char *resource; |
| 7014 | 1322 | |
|
30454
4e9bf65cfe9a
jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents:
30239
diff
changeset
|
1323 | 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
|
1324 | 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
|
1325 | if (!jb) |
|
4e9bf65cfe9a
jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents:
30239
diff
changeset
|
1326 | return 0; |
|
4e9bf65cfe9a
jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents:
30239
diff
changeset
|
1327 | |
|
4e9bf65cfe9a
jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents:
30239
diff
changeset
|
1328 | resource = jabber_get_resource(who); |
| 7306 | 1329 | jbr = jabber_buddy_find_resource(jb, resource); |
| 1330 | g_free(resource); | |
| 7014 | 1331 | |
|
30235
d37c441d6a48
jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <darkrain42@pidgin.im>
parents:
30121
diff
changeset
|
1332 | /* 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
|
1333 | 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
|
1334 | 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
|
1335 | |
|
d37c441d6a48
jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <darkrain42@pidgin.im>
parents:
30121
diff
changeset
|
1336 | /* *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
|
1337 | * 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
|
1338 | */ |
|
d37c441d6a48
jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <darkrain42@pidgin.im>
parents:
30121
diff
changeset
|
1339 | if (!jbr && !(jb->subscription & JABBER_SUB_FROM)) |
| 7014 | 1340 | return 0; |
| 1341 | ||
| 13708 | 1342 | /* TODO: figure out threading */ |
| 7014 | 1343 | 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
|
1344 | jm->js = js; |
| 7014 | 1345 | jm->type = JABBER_MESSAGE_CHAT; |
| 1346 | jm->to = g_strdup(who); | |
| 13484 | 1347 | jm->id = jabber_get_next_id(jm->js); |
| 7014 | 1348 | |
|
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
|
1349 | if(PURPLE_IM_TYPING == state) |
| 13708 | 1350 | 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
|
1351 | else if(PURPLE_IM_TYPED == state) |
| 13708 | 1352 | jm->chat_state = JM_STATE_PAUSED; |
| 1353 | else | |
| 1354 | jm->chat_state = JM_STATE_ACTIVE; | |
| 1355 | ||
|
27429
3313d7d74962
Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
1356 | /* 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
|
1357 | jbr->chat_states = JABBER_CHAT_STATES_UNSUPPORTED; */ |
| 7014 | 1358 | |
| 1359 | jabber_message_send(jm); | |
| 1360 | jabber_message_free(jm); | |
| 1361 | ||
| 13708 | 1362 | return 0; |
| 7014 | 1363 | } |
| 1364 | ||
|
23586
e495a4623f76
Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23249
diff
changeset
|
1365 | 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
|
1366 | 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
|
1367 | } |
|
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
|
1368 | |
|
24715
69aaae59e205
Fix compilation errors and many warnings
Paul Aurich <darkrain42@pidgin.im>
parents:
24714
diff
changeset
|
1369 | gboolean jabber_custom_smileys_isenabled(JabberStream *js, const gchar *namespace) |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1370 | { |
|
39433
f033955d125a
Use G_DEFINE_TYPE_WITH_PRIVATE for PurpleConnection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39065
diff
changeset
|
1371 | PurpleAccount *account = purple_connection_get_account(js->gc); |
|
23627
dbdc407798af
A couple of leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23626
diff
changeset
|
1372 | |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1373 | return purple_account_get_bool(account, "custom_smileys", TRUE); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1374 | } |