libpurple/protocols/jabber/message.c

Mon, 22 Aug 2016 04:24:11 -0400

author
Elliott Sales de Andrade <qulogic@pidgin.im>
date
Mon, 22 Aug 2016 04:24:11 -0400
branch
meson
changeset 38448
18c8f9843c82
parent 37423
d2f0259aa43f
child 38281
df274be2afa2
permissions
-rw-r--r--

Add jabber to meson build.

7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1 /*
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15721
diff changeset
2 * purple - Jabber Protocol Plugin
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
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
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
7 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
12 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
16 * GNU General Public License for more details.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
17 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
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
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
21 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
22 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
23 #include "internal.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
24
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
25 #include "debug.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
26 #include "notify.h"
35757
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
27 #include "smiley-custom.h"
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
28 #include "smiley-parser.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
29 #include "server.h"
7095
17d2b54254f8 [gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents: 7014
diff changeset
30 #include "util.h"
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
31 #include "adhoccommands.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
32 #include "buddy.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
33 #include "chat.h"
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
34 #include "data.h"
29913
58f5122fbcd3 First shot at refactoring the Google-specific XMPP code.
Marcus Lundblad <malu@pidgin.im>
parents: 29910
diff changeset
35 #include "google/google.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
36 #include "message.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
37 #include "xmlnode.h"
17768
7be011945a1b added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents: 17351
diff changeset
38 #include "pep.h"
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
39 #include "smiley.h"
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
40 #include "iq.h"
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
41
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
42 #include <string.h>
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
43
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
44 void jabber_message_free(JabberMessage *jm)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
45 {
15980
77057c4f658a Minor code cleanup
Mark Doliner <markdoliner@pidgin.im>
parents: 15884
diff changeset
46 g_free(jm->from);
13484
350fd422b021 [gaim-migrate @ 15859]
Sean Egan <seanegan@pidgin.im>
parents: 13385
diff changeset
47 g_free(jm->to);
350fd422b021 [gaim-migrate @ 15859]
Sean Egan <seanegan@pidgin.im>
parents: 13385
diff changeset
48 g_free(jm->id);
350fd422b021 [gaim-migrate @ 15859]
Sean Egan <seanegan@pidgin.im>
parents: 13385
diff changeset
49 g_free(jm->subject);
350fd422b021 [gaim-migrate @ 15859]
Sean Egan <seanegan@pidgin.im>
parents: 13385
diff changeset
50 g_free(jm->body);
350fd422b021 [gaim-migrate @ 15859]
Sean Egan <seanegan@pidgin.im>
parents: 13385
diff changeset
51 g_free(jm->xhtml);
350fd422b021 [gaim-migrate @ 15859]
Sean Egan <seanegan@pidgin.im>
parents: 13385
diff changeset
52 g_free(jm->password);
20057
728a7dce565e grab revision 41389df89a4a6a007d41cec33e33043cd41ea159
Luke Schierer <lschiere@pidgin.im>
parents: 19917
diff changeset
53 g_free(jm->error);
728a7dce565e grab revision 41389df89a4a6a007d41cec33e33043cd41ea159
Luke Schierer <lschiere@pidgin.im>
parents: 19917
diff changeset
54 g_free(jm->thread_id);
13484
350fd422b021 [gaim-migrate @ 15859]
Sean Egan <seanegan@pidgin.im>
parents: 13385
diff changeset
55 g_list_free(jm->etc);
20057
728a7dce565e grab revision 41389df89a4a6a007d41cec33e33043cd41ea159
Luke Schierer <lschiere@pidgin.im>
parents: 19917
diff changeset
56 g_list_free(jm->eventitems);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
57
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
58 g_free(jm);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
59 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
60
7145
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
61 static void handle_chat(JabberMessage *jm)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
62 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
63 JabberID *jid = jabber_id_new(jm->from);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
64
29331
9e828e599fc2 jabber: Use some convenience variables here.
Paul Aurich <darkrain42@pidgin.im>
parents: 29330
diff changeset
65 PurpleConnection *gc;
9e828e599fc2 jabber: Use some convenience variables here.
Paul Aurich <darkrain42@pidgin.im>
parents: 29330
diff changeset
66 PurpleAccount *account;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
67 JabberBuddy *jb;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
68 JabberBuddyResource *jbr;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
69
7310
1346a99cba40 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
70 if(!jid)
1346a99cba40 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
71 return;
1346a99cba40 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
72
29331
9e828e599fc2 jabber: Use some convenience variables here.
Paul Aurich <darkrain42@pidgin.im>
parents: 29330
diff changeset
73 gc = jm->js->gc;
9e828e599fc2 jabber: Use some convenience variables here.
Paul Aurich <darkrain42@pidgin.im>
parents: 29330
diff changeset
74 account = purple_connection_get_account(gc);
9e828e599fc2 jabber: Use some convenience variables here.
Paul Aurich <darkrain42@pidgin.im>
parents: 29330
diff changeset
75
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
76 jb = jabber_buddy_find(jm->js, jm->from, TRUE);
7306
61d7324411f8 [gaim-migrate @ 7890]
Nathan Walp <nwalp@pidgin.im>
parents: 7261
diff changeset
77 jbr = jabber_buddy_find_resource(jb, jid->resource);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
78
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
79 if(!jm->xhtml && !jm->body) {
30239
88550c8e461b jabber: Refined logic for determining "is typing" support.
Paul Aurich <darkrain42@pidgin.im>
parents: 30235
diff changeset
80 if (jbr && jm->chat_state != JM_STATE_NONE)
88550c8e461b jabber: Refined logic for determining "is typing" support.
Paul Aurich <darkrain42@pidgin.im>
parents: 30235
diff changeset
81 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
82
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
83 if(JM_STATE_COMPOSING == jm->chat_state) {
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 35070
diff changeset
84 purple_serv_got_typing(gc, jm->from, 0, PURPLE_IM_TYPING);
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
85 } else if(JM_STATE_PAUSED == jm->chat_state) {
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 35070
diff changeset
86 purple_serv_got_typing(gc, jm->from, 0, PURPLE_IM_TYPED);
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
87 } else if(JM_STATE_GONE == jm->chat_state) {
34634
90fa70aa7e28 Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
88 PurpleIMConversation *im = purple_conversations_find_im_with_account(
29336
11ae11b31743 jabber: Cleanup (and drop that unnormalized find function)!
Paul Aurich <darkrain42@pidgin.im>
parents: 29332
diff changeset
89 jm->from, account);
34634
90fa70aa7e28 Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
90 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
91 char buf[256];
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15721
diff changeset
92 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
93
8b054202d398 Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents: 15710
diff changeset
94 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
95
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34670
diff changeset
96 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
97 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
98 char *escaped;
8b054202d398 Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents: 15710
diff changeset
99
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15721
diff changeset
100 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
101 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
102
8b054202d398 Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents: 15710
diff changeset
103 g_snprintf(buf, sizeof(buf),
16946
6ca2bb9f6039 New string
Sean Egan <seanegan@pidgin.im>
parents: 16799
diff changeset
104 _("%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
105 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
106
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15721
diff changeset
107 /* 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
108 * 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
109 * 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
110 purple_conversation_write_system_message(
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36084
diff changeset
111 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
112 }
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
113 }
35501
602747bb4af9 Fix duplicate prefixes
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
114 purple_serv_got_typing_stopped(gc, jm->from);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25983
diff changeset
115
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
116 } else {
35501
602747bb4af9 Fix duplicate prefixes
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
117 purple_serv_got_typing_stopped(gc, jm->from);
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
118 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
119 } else {
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
120 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
121 /*
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
122 * 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
123 * 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
124 * 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
125 * 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
126 *
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 33722
diff changeset
127 * 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
128 * 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
129 */
34634
90fa70aa7e28 Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
130 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
131
34634
90fa70aa7e28 Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
132 im = purple_conversations_find_im_with_account(jm->from, account);
90fa70aa7e28 Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
133 if (im && !g_str_equal(jm->from,
90fa70aa7e28 Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
134 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
135 purple_debug_info("jabber", "Binding conversation to %s\n",
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
136 jm->from);
34634
90fa70aa7e28 Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
137 purple_conversation_set_name(PURPLE_CONVERSATION(im), jm->from);
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
138 }
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
139 }
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
140
8400
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
141 if(jbr) {
30239
88550c8e461b jabber: Refined logic for determining "is typing" support.
Paul Aurich <darkrain42@pidgin.im>
parents: 30235
diff changeset
142 /* 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
143 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
144 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
145 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
146 else
88550c8e461b jabber: Refined logic for determining "is typing" support.
Paul Aurich <darkrain42@pidgin.im>
parents: 30235
diff changeset
147 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
148 }
13708
37d5bc24e5bf [gaim-migrate @ 16110]
Nathan Walp <nwalp@pidgin.im>
parents: 13484
diff changeset
149
37423
d2f0259aa43f Remove NULL-checks before free(). No functional change.
Michael McConville <mmcco@mykolab.com>
parents: 37153
diff changeset
150 g_free(jbr->thread_id);
8400
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
151 jbr->thread_id = g_strdup(jbr->thread_id);
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
152 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25983
diff changeset
153
15587
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
154 if (jm->js->googletalk && jm->xhtml == NULL) {
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
155 char *tmp = jm->body;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
156 jm->body = jabber_google_format_to_html(jm->body);
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
157 g_free(tmp);
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
158 }
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 35070
diff changeset
159 purple_serv_got_im(gc, jm->from, jm->xhtml ? jm->xhtml : jm->body, 0, jm->sent);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
160 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
161
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
162 jabber_id_free(jid);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
163 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
164
7145
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
165 static void handle_headline(JabberMessage *jm)
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
166 {
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
167 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
168 GString *body;
7145
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
169 GList *etc;
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
170
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
171 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
172 return; /* ignore headlines without any content */
7145
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
173
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
174 body = g_string_new("");
7145
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
175 title = g_strdup_printf(_("Message from %s"), jm->from);
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
176
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
177 if(jm->xhtml)
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
178 g_string_append(body, jm->xhtml);
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
179 else if(jm->body)
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
180 g_string_append(body, jm->body);
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
181
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
182 for(etc = jm->etc; etc; etc = etc->next) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
183 PurpleXmlNode *x = etc->data;
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
184 const char *xmlns = purple_xmlnode_get_namespace(x);
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28979
diff changeset
185 if(xmlns && !strcmp(xmlns, NS_OOB_X_DATA)) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
186 PurpleXmlNode *url, *desc;
7145
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
187 char *urltxt, *desctxt;
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
188
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
189 url = purple_xmlnode_get_child(x, "url");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
190 desc = purple_xmlnode_get_child(x, "desc");
7145
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
191
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
192 if(!url || !desc)
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
193 continue;
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
194
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
195 urltxt = purple_xmlnode_get_data(url);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
196 desctxt = purple_xmlnode_get_data(desc);
7145
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
197
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
198 /* I'm all about ugly hacks */
14790
a0226bec3707 [gaim-migrate @ 17484]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 14254
diff changeset
199 if(body->len && jm->body && !strcmp(body->str, jm->body))
7145
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
200 g_string_printf(body, "<a href='%s'>%s</a>",
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
201 urltxt, desctxt);
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
202 else
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
203 g_string_append_printf(body, "<br/><a href='%s'>%s</a>",
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
204 urltxt, desctxt);
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
205
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
206 g_free(urltxt);
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
207 g_free(desctxt);
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
208 }
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
209 }
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
210
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15721
diff changeset
211 purple_notify_formatted(jm->js->gc, title, jm->subject ? jm->subject : title,
7145
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
212 NULL, body->str, NULL, NULL);
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
213
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
214 g_free(title);
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
215 g_string_free(body, TRUE);
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
216 }
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
217
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
218 static void handle_groupchat(JabberMessage *jm)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
219 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
220 JabberID *jid = jabber_id_new(jm->from);
7310
1346a99cba40 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
221 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
222 PurpleMessageFlags messageFlags = 0;
7310
1346a99cba40 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
223
1346a99cba40 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
224 if(!jid)
1346a99cba40 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
225 return;
1346a99cba40 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
226
1346a99cba40 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
227 chat = jabber_chat_find(jm->js, jid->node, jid->domain);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
228
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
229 if(!chat)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
230 return;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
231
7971
a9309feca3c8 [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7968
diff changeset
232 if(jm->subject) {
34634
90fa70aa7e28 Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
233 purple_chat_conversation_set_topic(chat->conv, jid->resource,
7183
ee17c7833501 [gaim-migrate @ 7751]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
234 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
235 messageFlags |= PURPLE_MESSAGE_NO_LOG;
7971
a9309feca3c8 [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7968
diff changeset
236 if(!jm->xhtml && !jm->body) {
9762
125f77c00102 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9584
diff changeset
237 char *msg, *tmp, *tmp2;
10732
5e314ab498bf [gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents: 10607
diff changeset
238 tmp = g_markup_escape_text(jm->subject, -1);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15721
diff changeset
239 tmp2 = purple_markup_linkify(tmp);
7971
a9309feca3c8 [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7968
diff changeset
240 if(jid->resource)
9762
125f77c00102 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9584
diff changeset
241 msg = g_strdup_printf(_("%s has set the topic to: %s"), jid->resource, tmp2);
7971
a9309feca3c8 [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7968
diff changeset
242 else
9762
125f77c00102 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9584
diff changeset
243 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
244 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
245 msg, messageFlags);
9762
125f77c00102 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9584
diff changeset
246 g_free(tmp);
125f77c00102 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9584
diff changeset
247 g_free(tmp2);
7971
a9309feca3c8 [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7968
diff changeset
248 g_free(msg);
a9309feca3c8 [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7968
diff changeset
249 }
a9309feca3c8 [gaim-migrate @ 8648]
Nathan Walp <nwalp@pidgin.im>
parents: 7968
diff changeset
250 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
251
7630
23e09fd7cbeb [gaim-migrate @ 8254]
Nathan Walp <nwalp@pidgin.im>
parents: 7448
diff changeset
252 if(jm->xhtml || jm->body) {
23e09fd7cbeb [gaim-migrate @ 8254]
Nathan Walp <nwalp@pidgin.im>
parents: 7448
diff changeset
253 if(jid->resource)
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 35070
diff changeset
254 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
255 messageFlags | (jm->delayed ? PURPLE_MESSAGE_DELAYED : 0),
7630
23e09fd7cbeb [gaim-migrate @ 8254]
Nathan Walp <nwalp@pidgin.im>
parents: 7448
diff changeset
256 jm->xhtml ? jm->xhtml : jm->body, jm->sent);
23e09fd7cbeb [gaim-migrate @ 8254]
Nathan Walp <nwalp@pidgin.im>
parents: 7448
diff changeset
257 else if(chat->muc)
36084
2172bd6dad3e Add purple_conversation_write_system_message
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36077
diff changeset
258 purple_conversation_write_system_message(
2172bd6dad3e Add purple_conversation_write_system_message
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36077
diff changeset
259 PURPLE_CONVERSATION(chat->conv),
2172bd6dad3e Add purple_conversation_write_system_message
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36077
diff changeset
260 jm->xhtml ? jm->xhtml : jm->body, messageFlags);
7630
23e09fd7cbeb [gaim-migrate @ 8254]
Nathan Walp <nwalp@pidgin.im>
parents: 7448
diff changeset
261 }
23e09fd7cbeb [gaim-migrate @ 8254]
Nathan Walp <nwalp@pidgin.im>
parents: 7448
diff changeset
262
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
263 jabber_id_free(jid);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
264 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
265
7145
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
266 static void handle_groupchat_invite(JabberMessage *jm)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
267 {
7310
1346a99cba40 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
268 GHashTable *components;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
269 JabberID *jid = jabber_id_new(jm->to);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
270
7310
1346a99cba40 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
271 if(!jid)
1346a99cba40 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
272 return;
1346a99cba40 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
273
15598
834a88c83e95 Get rid of some unnecessary string duping
Mark Doliner <markdoliner@pidgin.im>
parents: 15587
diff changeset
274 components = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
7310
1346a99cba40 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
275
15598
834a88c83e95 Get rid of some unnecessary string duping
Mark Doliner <markdoliner@pidgin.im>
parents: 15587
diff changeset
276 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
277 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
278 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
279 g_hash_table_replace(components, "password", g_strdup(jm->password));
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
280
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
281 jabber_id_free(jid);
35501
602747bb4af9 Fix duplicate prefixes
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
282 purple_serv_got_chat_invite(jm->js->gc, jm->to, jm->from, jm->body, components);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
283 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
284
7145
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
285 static void handle_error(JabberMessage *jm)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
286 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
287 char *buf;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
288
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
289 if(!jm->body)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
290 return;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
291
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
292 buf = g_strdup_printf(_("Message delivery to %s failed: %s"),
13766
6b92ce47f7e5 [gaim-migrate @ 16176]
Daniel Atallah <datallah@pidgin.im>
parents: 13708
diff changeset
293 jm->from, jm->error ? jm->error : "");
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
294
16961
b6955f946f8f s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@pidgin.im>
parents: 16946
diff changeset
295 purple_notify_formatted(jm->js->gc, _("XMPP Message Error"), _("XMPP Message Error"), buf,
7944
619ec16df2c8 [gaim-migrate @ 8615]
Nathan Walp <nwalp@pidgin.im>
parents: 7923
diff changeset
296 jm->xhtml ? jm->xhtml : jm->body, NULL, NULL);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
297
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
298 g_free(buf);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
299 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
300
17822
1a183f3fa9d7 disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents: 17821
diff changeset
301 static void handle_buzz(JabberMessage *jm) {
1a183f3fa9d7 disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents: 17821
diff changeset
302 PurpleAccount *account;
25316
8b6461a2f967 Use purple_prpl_got_attention() for XMPP notifications
Evan Schoenberg <evands@pidgin.im>
parents: 25154
diff changeset
303
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
304 /* 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
305 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
306 return;
25316
8b6461a2f967 Use purple_prpl_got_attention() for XMPP notifications
Evan Schoenberg <evands@pidgin.im>
parents: 25154
diff changeset
307
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
308 /* 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
309 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
310 return;
25316
8b6461a2f967 Use purple_prpl_got_attention() for XMPP notifications
Evan Schoenberg <evands@pidgin.im>
parents: 25154
diff changeset
311
17822
1a183f3fa9d7 disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents: 17821
diff changeset
312 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
313
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34670
diff changeset
314 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
315 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
316
25316
8b6461a2f967 Use purple_prpl_got_attention() for XMPP notifications
Evan Schoenberg <evands@pidgin.im>
parents: 25154
diff changeset
317 /* 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
318 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
319 }
1a183f3fa9d7 disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents: 17821
diff changeset
320
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
321 /* 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
322 typedef struct {
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
323 gchar *cid;
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
324 gchar *alt;
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
325 } JabberSmileyRef;
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
326
24254
2d990726bf92 Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents: 23628
diff changeset
327
2d990726bf92 Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents: 23628
diff changeset
328 static void
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
329 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
330 GHashTable *table)
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
331 {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
332 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
333
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
334 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
335 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
336 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
337
24254
2d990726bf92 Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents: 23628
diff changeset
338 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
339 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
340
24254
2d990726bf92 Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents: 23628
diff changeset
341 /* 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
342 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
343 /* 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
344 gchar *temp_cid = g_strdup(cid);
2d990726bf92 Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents: 23628
diff changeset
345 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
346 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
347 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
348 /* 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
349 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
350 if (alt && alt[0] != '\0') {
24259
e69d72917038 Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents: 24258
diff changeset
351 /* 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
352 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
353 as an mailto: link */
e69d72917038 Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents: 24258
diff changeset
354 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
355 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
356 } else {
e69d72917038 Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents: 24258
diff changeset
357 ref->alt = g_strdup(alt);
e69d72917038 Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents: 24258
diff changeset
358 }
24254
2d990726bf92 Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents: 23628
diff changeset
359 } else {
24258
9ae10fafad7a When receiving an <img/> without the "alt" attribute, set
Marcus Lundblad <malu@pidgin.im>
parents: 24257
diff changeset
360 ref->alt = g_strdup(src);
24254
2d990726bf92 Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents: 23628
diff changeset
361 }
2d990726bf92 Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents: 23628
diff changeset
362 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
363 }
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
364 }
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
365 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25983
diff changeset
366
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
367 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
368 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
369 }
24254
2d990726bf92 Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents: 23628
diff changeset
370 }
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
371
24254
2d990726bf92 Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents: 23628
diff changeset
372 static gboolean
2d990726bf92 Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents: 23628
diff changeset
373 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
374 {
2d990726bf92 Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents: 23628
diff changeset
375 GList **refs = (GList **) user_data;
2d990726bf92 Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents: 23628
diff changeset
376 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
377
24254
2d990726bf92 Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents: 23628
diff changeset
378 *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
379
24254
2d990726bf92 Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents: 23628
diff changeset
380 return TRUE;
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
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
383 static GList *
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
384 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
385 {
24254
2d990726bf92 Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents: 23628
diff changeset
386 GList *refs = NULL;
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
387 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
388
24254
2d990726bf92 Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents: 23628
diff changeset
389 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
390 (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
391 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
392 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
393 return refs;
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
394 }
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
395
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
396 static gchar *
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
397 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
398 {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
399 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
400 int len = strlen(markup);
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
401 int pos = 0;
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
402 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
403
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
404 while (pos < len) {
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
405 /* 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
406 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
407 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
408 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
409 PurpleXmlNode *img = NULL;
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
410 int pos2 = pos;
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
411 const gchar *src;
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 for (; pos2 < len ; pos2++) {
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
414 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
415 pos2 += 2;
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
416 break;
24254
2d990726bf92 Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents: 23628
diff changeset
417 } 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
418 pos2 += 5;
2d990726bf92 Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents: 23628
diff changeset
419 break;
23626
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 }
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
422
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
423 /* 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
424 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
425 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
426 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
427 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
428 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
429 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
430
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(src, "cid:")) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
432 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
433 /* 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
434 if (alt && alt[0] != '\0') {
24259
e69d72917038 Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents: 24258
diff changeset
435 /* 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
436 this prevents linkification... */
e69d72917038 Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents: 24258
diff changeset
437 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
438 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
439 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
440 g_free(safe_alt);
e69d72917038 Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents: 24258
diff changeset
441 } else {
35783
dcff8ce68d1b Remote smileys: fix a xmpp bug of non-escaped custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35764
diff changeset
442 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
443 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
444 g_free(alt_escaped);
24259
e69d72917038 Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents: 24258
diff changeset
445 }
24254
2d990726bf92 Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents: 23628
diff changeset
446 } else {
24258
9ae10fafad7a When receiving an <img/> without the "alt" attribute, set
Marcus Lundblad <malu@pidgin.im>
parents: 24257
diff changeset
447 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
448 }
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
449 pos += pos2 - pos;
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
450 } else {
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
451 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
452 pos++;
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
453 }
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
454
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
455 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
456
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
457 } else {
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
458 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
459 pos++;
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
460 }
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
461 }
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
462
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
463 g_free(markup);
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
464 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
465 }
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
466
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
467 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
468 jabber_message_add_remote_smileys(JabberStream *js, const gchar *who,
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
469 const PurpleXmlNode *message)
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
470 {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
471 PurpleXmlNode *data_tag;
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
472 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
473 data_tag ;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
474 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
475 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
476 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
477
24254
2d990726bf92 Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents: 23628
diff changeset
478 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
479 /* 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
480 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
481
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
482 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
483 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
484 }
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
485 }
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
486 }
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
487 }
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
488
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
489 static void
35746
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
490 jabber_message_remote_smiley_got(JabberData *data, gchar *alt, gpointer _smiley)
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
491 {
35838
64f331a1eaa0 Drop remote smileys in favor of remote images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35823
diff changeset
492 PurpleSmiley *smiley = _smiley;
64f331a1eaa0 Drop remote smileys in favor of remote images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35823
diff changeset
493 PurpleImage *image = purple_smiley_get_image(smiley);
35746
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
494
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
495 g_free(alt); /* we really don't need it */
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
496
29906
2403e9d40e4a jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <malu@pidgin.im>
parents: 29840
diff changeset
497 if (data) {
35746
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
498 purple_debug_info("jabber",
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
499 "smiley data retrieved successfully");
35838
64f331a1eaa0 Drop remote smileys in favor of remote images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35823
diff changeset
500 purple_image_transfer_write(image, jabber_data_get_data(data),
35746
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
501 jabber_data_get_size(data));
35838
64f331a1eaa0 Drop remote smileys in favor of remote images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35823
diff changeset
502 purple_image_transfer_close(image);
35746
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
503 } else {
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
504 purple_debug_error("jabber", "failed retrieving smiley data");
35838
64f331a1eaa0 Drop remote smileys in favor of remote images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35823
diff changeset
505 purple_image_transfer_failed(image);
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
506 }
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
507
35746
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
508 g_object_unref(smiley);
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
509 }
35746
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
510
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
511 static void
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
512 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
513 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
514 {
35838
64f331a1eaa0 Drop remote smileys in favor of remote images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35823
diff changeset
515 PurpleSmiley *smiley;
35746
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
516 const JabberData *jdata;
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
517
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
518 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
519 shortcut);
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
520
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
521 smiley = purple_conversation_add_remote_smiley(conv, shortcut);
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
522 if (!smiley) {
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
523 purple_debug_misc("jabber", "smiley was already present");
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
524 return;
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
525 }
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
526
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
527 /* TODO: cache lookup by "cid" */
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
528
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
529 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
530 if (jdata) {
35838
64f331a1eaa0 Drop remote smileys in favor of remote images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35823
diff changeset
531 PurpleImage *image = purple_smiley_get_image(smiley);
64f331a1eaa0 Drop remote smileys in favor of remote images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35823
diff changeset
532
35746
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
533 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
534
35838
64f331a1eaa0 Drop remote smileys in favor of remote images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35823
diff changeset
535 purple_image_transfer_write(image, jabber_data_get_data(jdata),
35746
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
536 jabber_data_get_size(jdata));
35838
64f331a1eaa0 Drop remote smileys in favor of remote images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35823
diff changeset
537 purple_image_transfer_close(image);
35746
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
538 } else {
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
539 gchar *alt = g_strdup(shortcut); /* it it really necessary? */
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_info("jabber", "smiley data is unknown, "
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
542 "need to request it");
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
543
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
544 g_object_ref(smiley);
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
545 jabber_data_request(js, cid, from, alt, FALSE,
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
546 jabber_message_remote_smiley_got, smiley);
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
547 }
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
548 }
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
549
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
550 void jabber_message_parse(JabberStream *js, PurpleXmlNode *packet)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
551 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
552 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
553 const char *id, *from, *to, *type;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
554 PurpleXmlNode *child;
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
555 gboolean 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
556
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
557 from = purple_xmlnode_get_attrib(packet, "from");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
558 id = purple_xmlnode_get_attrib(packet, "id");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
559 to = purple_xmlnode_get_attrib(packet, "to");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
560 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
561
36623
caaadef03507 Renamed purple_connection_get_protocol_info() to purple_connection_get_protocol()
Ankit Vani <a@nevitus.org>
parents: 36545
diff changeset
562 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
563 "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
564 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
565 return;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
566
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
567 jm = g_new0(JabberMessage, 1);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
568 jm->js = js;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
569 jm->sent = time(NULL);
9584
1a6198375303 [gaim-migrate @ 10427]
Nathan Fredrickson <nathan@silverorange.com>
parents: 9130
diff changeset
570 jm->delayed = FALSE;
27429
3313d7d74962 Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <darkrain42@pidgin.im>
parents: 27237
diff changeset
571 jm->chat_state = JM_STATE_NONE;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
572
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
573 if(type) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
574 if(!strcmp(type, "normal"))
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
575 jm->type = JABBER_MESSAGE_NORMAL;
20320
6337e101f6ab Plug some memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19917
diff changeset
576 else if(!strcmp(type, "chat"))
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
577 jm->type = JABBER_MESSAGE_CHAT;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
578 else if(!strcmp(type, "groupchat"))
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
579 jm->type = JABBER_MESSAGE_GROUPCHAT;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
580 else if(!strcmp(type, "headline"))
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
581 jm->type = JABBER_MESSAGE_HEADLINE;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
582 else if(!strcmp(type, "error"))
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
583 jm->type = JABBER_MESSAGE_ERROR;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
584 else
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
585 jm->type = JABBER_MESSAGE_OTHER;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
586 } else {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
587 jm->type = JABBER_MESSAGE_NORMAL;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
588 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
589
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
590 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
591 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
592 jm->id = g_strdup(id);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
593
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
594 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
595 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
596 if(child->type != PURPLE_XMLNODE_TYPE_TAG)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
597 continue;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
598
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
599 if(!strcmp(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
600 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
601 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
602 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
603 if (!text) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
604 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
605
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
606 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
607 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
608 }
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
609
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
610 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
611 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
612
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
613 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
614 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
615 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
616 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
617 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
618
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
619 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
620 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
621 } 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
622 /* 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
623 with the previous 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
624 if(!strcmp(child->name, "x"))
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
625 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
626 /* 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
627 continue;
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28979
diff changeset
628 } else if(!strcmp(child->name, "subject") && !strcmp(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
629 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
630 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
631 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
632 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
633 }
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28979
diff changeset
634 } else if(!strcmp(child->name, "thread") && !strcmp(xmlns, NS_XMPP_CLIENT)) {
8400
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
635 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
636 jm->thread_id = purple_xmlnode_get_data(child);
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28979
diff changeset
637 } else if(!strcmp(child->name, "body") && !strcmp(xmlns, NS_XMPP_CLIENT)) {
13385
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 13304
diff changeset
638 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
639 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
640 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
641 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
642 g_free(escaped);
13385
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 13304
diff changeset
643 g_free(msg);
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 13304
diff changeset
644 }
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28979
diff changeset
645 } else if(!strcmp(child->name, "html") && !strcmp(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
646 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
647 char *c;
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
648
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
649 const PurpleConnection *gc = js->gc;
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
650 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
651 PurpleConversation *conv = NULL;
35746
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
652 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
653 gchar *reformatted_xhtml;
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
654
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
655 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
656 /* 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
657 occuring in the message */
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
658 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
659 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
660 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
661
27155
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27131
diff changeset
662 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
663 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
664 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
665 JabberChat *chat = NULL;
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
666
26711
07cfe1520055 Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <malu@pidgin.im>
parents: 26687
diff changeset
667 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
668 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
669 if (chat)
34634
90fa70aa7e28 Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
670 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
671 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
672 }
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
673 } 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
674 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
675 conv =
34634
90fa70aa7e28 Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
676 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
677 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
678 /* 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
679 conv = PURPLE_CONVERSATION(
90fa70aa7e28 Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
680 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
681 }
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
682 }
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
683 }
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
684
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
685 /* 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
686 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
687 }
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
688
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
689 purple_xmlnode_strip_prefixes(child);
32323
df78cc32b2cd jabber: Strip element prefixes on XHTML-IM content.
Paul Aurich <darkrain42@pidgin.im>
parents: 32277
diff changeset
690
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
691 /* 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
692 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
693 /* 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
694 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
695 reformatted_xhtml =
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
696 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
697
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
698 jm->xhtml = reformatted_xhtml;
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
699
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
700 /* 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
701 /* 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
702 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
703 be NULL */
35746
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
704 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
705 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
706
35746
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
707 if (conv) {
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
708 jabber_message_remote_smiley_add(js,
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
709 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
710 }
35746
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
711
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
712 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
713 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
714 g_free(ref);
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
715 }
35746
e4a656378516 Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35745
diff changeset
716 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
717
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
718 /* 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
719 * 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
720 */
7a5668fb7bad Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents: 16961
diff changeset
721 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
722 if (*c == '\n')
17328
7a5668fb7bad Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents: 16961
diff changeset
723 *c = ' ';
7a5668fb7bad Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents: 16961
diff changeset
724 }
7a5668fb7bad Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents: 16961
diff changeset
725 }
17768
7be011945a1b added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents: 17351
diff changeset
726 } else if(!strcmp(child->name, "active") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) {
13708
37d5bc24e5bf [gaim-migrate @ 16110]
Nathan Walp <nwalp@pidgin.im>
parents: 13484
diff changeset
727 jm->chat_state = JM_STATE_ACTIVE;
17768
7be011945a1b added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents: 17351
diff changeset
728 } else if(!strcmp(child->name, "composing") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) {
13708
37d5bc24e5bf [gaim-migrate @ 16110]
Nathan Walp <nwalp@pidgin.im>
parents: 13484
diff changeset
729 jm->chat_state = JM_STATE_COMPOSING;
17768
7be011945a1b added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents: 17351
diff changeset
730 } else if(!strcmp(child->name, "paused") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) {
13708
37d5bc24e5bf [gaim-migrate @ 16110]
Nathan Walp <nwalp@pidgin.im>
parents: 13484
diff changeset
731 jm->chat_state = JM_STATE_PAUSED;
17768
7be011945a1b added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents: 17351
diff changeset
732 } else if(!strcmp(child->name, "inactive") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) {
13708
37d5bc24e5bf [gaim-migrate @ 16110]
Nathan Walp <nwalp@pidgin.im>
parents: 13484
diff changeset
733 jm->chat_state = JM_STATE_INACTIVE;
17768
7be011945a1b added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents: 17351
diff changeset
734 } else if(!strcmp(child->name, "gone") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) {
13708
37d5bc24e5bf [gaim-migrate @ 16110]
Nathan Walp <nwalp@pidgin.im>
parents: 13484
diff changeset
735 jm->chat_state = JM_STATE_GONE;
17774
fdb76fddd16a Implemented <required/> for x-data forms, simplified malloc/sprintf, message type headline is not a requirement for incoming PEP messages (it is just recommended to avoid offline message storage).
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
736 } else if(!strcmp(child->name, "event") && !strcmp(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
737 PurpleXmlNode *items;
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17776
diff changeset
738 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
739 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
740 jm->eventitems = g_list_append(jm->eventitems, items);
28979
191942cc7747 jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <darkrain42@pidgin.im>
parents: 28832
diff changeset
741 } else if(!strcmp(child->name, "attention") && !strcmp(xmlns, NS_ATTENTION)) {
17822
1a183f3fa9d7 disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents: 17821
diff changeset
742 jm->hasBuzz = TRUE;
28996
8296bccbfd50 jabber: Delayed Delivery namespaces
Paul Aurich <darkrain42@pidgin.im>
parents: 28984
diff changeset
743 } else if(!strcmp(child->name, "delay") && !strcmp(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
744 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
745 jm->delayed = TRUE;
d9a7ec9277f6 Implemented XEP-0203: Delayed Delivery
Andreas Monitzer <am@adiumx.com>
parents: 17792
diff changeset
746 if(timestamp)
d9a7ec9277f6 Implemented XEP-0203: Delayed Delivery
Andreas Monitzer <am@adiumx.com>
parents: 17792
diff changeset
747 jm->sent = purple_str_to_time(timestamp, TRUE, NULL, NULL, NULL);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
748 } else if(!strcmp(child->name, "x")) {
28996
8296bccbfd50 jabber: Delayed Delivery namespaces
Paul Aurich <darkrain42@pidgin.im>
parents: 28984
diff changeset
749 if(!strcmp(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
750 const char *timestamp = purple_xmlnode_get_attrib(child, "stamp");
27434
7d8b32345d10 disapproval of revision '0c1545afc98299c6d7004554eb7443091d42e8ca'
Paul Aurich <darkrain42@pidgin.im>
parents: 27431
diff changeset
751 jm->delayed = TRUE;
7d8b32345d10 disapproval of revision '0c1545afc98299c6d7004554eb7443091d42e8ca'
Paul Aurich <darkrain42@pidgin.im>
parents: 27431
diff changeset
752 if(timestamp)
7d8b32345d10 disapproval of revision '0c1545afc98299c6d7004554eb7443091d42e8ca'
Paul Aurich <darkrain42@pidgin.im>
parents: 27431
diff changeset
753 jm->sent = purple_str_to_time(timestamp, TRUE, NULL, NULL, NULL);
7d8b32345d10 disapproval of revision '0c1545afc98299c6d7004554eb7443091d42e8ca'
Paul Aurich <darkrain42@pidgin.im>
parents: 27431
diff changeset
754 } else if(!strcmp(xmlns, "jabber:x:conference") &&
11230
a8f28f1058f6 [gaim-migrate @ 13370]
Nathan Walp <nwalp@pidgin.im>
parents: 10774
diff changeset
755 jm->type != JABBER_MESSAGE_GROUPCHAT_INVITE &&
a8f28f1058f6 [gaim-migrate @ 13370]
Nathan Walp <nwalp@pidgin.im>
parents: 10774
diff changeset
756 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
757 const char *jid = purple_xmlnode_get_attrib(child, "jid");
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
758 if(jid) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
759 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
760 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
761
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
762 jm->type = JABBER_MESSAGE_GROUPCHAT_INVITE;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
763 g_free(jm->to);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
764 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
765
521344e75710 jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents: 28534
diff changeset
766 if (reason) {
521344e75710 jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents: 28534
diff changeset
767 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
768 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
769 }
521344e75710 jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents: 28534
diff changeset
770
521344e75710 jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents: 28534
diff changeset
771 if (password) {
521344e75710 jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents: 28534
diff changeset
772 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
773 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
774 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
775 }
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
776 } else if(!strcmp(xmlns, "http://jabber.org/protocol/muc#user") &&
11230
a8f28f1058f6 [gaim-migrate @ 13370]
Nathan Walp <nwalp@pidgin.im>
parents: 10774
diff changeset
777 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
778 PurpleXmlNode *invite = purple_xmlnode_get_child(child, "invite");
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
779 if(invite) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
780 PurpleXmlNode *reason, *password;
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
781 const char *jid = purple_xmlnode_get_attrib(invite, "from");
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
782 g_free(jm->to);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
783 jm->to = jm->from;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
784 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
785 if((reason = purple_xmlnode_get_child(invite, "reason"))) {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
786 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
787 jm->body = purple_xmlnode_get_data(reason);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
788 }
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
789 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
790 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
791 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
792 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
793
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
794 jm->type = JABBER_MESSAGE_GROUPCHAT_INVITE;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
795 }
7145
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
796 } else {
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
797 jm->etc = g_list_append(jm->etc, child);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
798 }
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
799 } else if (g_str_equal(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
800 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
801 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
802 && 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
803 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
804 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
805 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
806 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
807
17822
1a183f3fa9d7 disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents: 17821
diff changeset
808 if(jm->hasBuzz)
1a183f3fa9d7 disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents: 17821
diff changeset
809 handle_buzz(jm);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
810
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
811 switch(jm->type) {
27900
23b6b4dfeb82 Allow fallback for broken XMPP <message/> types. Closes #7837.
Paul Aurich <darkrain42@pidgin.im>
parents: 27844
diff changeset
812 case JABBER_MESSAGE_OTHER:
28828
7c1855f037e7 jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 28726
diff changeset
813 purple_debug_info("jabber",
27900
23b6b4dfeb82 Allow fallback for broken XMPP <message/> types. Closes #7837.
Paul Aurich <darkrain42@pidgin.im>
parents: 27844
diff changeset
814 "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
815 /* Fall-through is intentional */
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
816 case JABBER_MESSAGE_NORMAL:
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
817 case JABBER_MESSAGE_CHAT:
7145
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
818 handle_chat(jm);
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
819 break;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
820 case JABBER_MESSAGE_HEADLINE:
7145
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7135
diff changeset
821 handle_headline(jm);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
822 break;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
823 case JABBER_MESSAGE_GROUPCHAT:
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
824 handle_groupchat(jm);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
825 break;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
826 case JABBER_MESSAGE_GROUPCHAT_INVITE:
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
827 handle_groupchat_invite(jm);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
828 break;
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17776
diff changeset
829 case JABBER_MESSAGE_EVENT:
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17776
diff changeset
830 jabber_handle_event(jm);
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17776
diff changeset
831 break;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
832 case JABBER_MESSAGE_ERROR:
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
833 handle_error(jm);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
834 break;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
835 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
836 jabber_message_free(jm);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
837 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
838
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
839 static gboolean
29366
e10e6d4f89e0 jabber: Simplify.
Paul Aurich <darkrain42@pidgin.im>
parents: 29338
diff changeset
840 jabber_conv_support_custom_smileys(JabberStream *js,
27110
05ca719b901b Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents: 27103
diff changeset
841 PurpleConversation *conv,
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
842 const gchar *who)
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
843 {
24254
2d990726bf92 Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents: 23628
diff changeset
844 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
845 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
846
34634
90fa70aa7e28 Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
847 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
848 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
849 if (jb) {
90fa70aa7e28 Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
850 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
851 } else {
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
852 return FALSE;
34634
90fa70aa7e28 Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
853 }
35070
d7350d876fda libpurple: Don't assume a conversation is always an IM or a chat
Ankit Vani <a@nevitus.org>
parents: 34935
diff changeset
854 } 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
855 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
856 if (chat) {
90fa70aa7e28 Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
857 /* 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
858 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
859 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
860 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
861 NS_BOB);
90fa70aa7e28 Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
862 } else {
90fa70aa7e28 Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
863 return FALSE;
90fa70aa7e28 Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
864 }
35070
d7350d876fda libpurple: Don't assume a conversation is always an IM or a chat
Ankit Vani <a@nevitus.org>
parents: 34935
diff changeset
865 } else {
d7350d876fda libpurple: Don't assume a conversation is always an IM or a chat
Ankit Vani <a@nevitus.org>
parents: 34935
diff changeset
866 return FALSE;
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
867 }
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
868 }
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
869
35788
afa6d777bc7c Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35787
diff changeset
870 static gboolean
afa6d777bc7c Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35787
diff changeset
871 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
872 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
873 {
afa6d777bc7c Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35787
diff changeset
874 const gchar *shortcut;
afa6d777bc7c Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35787
diff changeset
875 const JabberData *data;
afa6d777bc7c Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35787
diff changeset
876 PurpleXmlNode *smiley_node;
afa6d777bc7c Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35787
diff changeset
877 gchar *node_xml;
afa6d777bc7c Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35787
diff changeset
878
afa6d777bc7c Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35787
diff changeset
879 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
880 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
881
afa6d777bc7c Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35787
diff changeset
882 if (!data)
afa6d777bc7c Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35787
diff changeset
883 return FALSE;
afa6d777bc7c Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35787
diff changeset
884
afa6d777bc7c Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35787
diff changeset
885 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
886 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
887
afa6d777bc7c Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35787
diff changeset
888 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
889
afa6d777bc7c Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35787
diff changeset
890 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
891 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
892
afa6d777bc7c Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35787
diff changeset
893 return TRUE;
afa6d777bc7c Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35787
diff changeset
894 }
afa6d777bc7c Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35787
diff changeset
895
27061
b1bfbf77cf90 Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents: 26984
diff changeset
896 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
897 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
898 {
b1bfbf77cf90 Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents: 26984
diff changeset
899 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
900 GList *found_smileys, *it, *it_next;
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
901 PurpleConversation *conv;
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
902 gboolean has_too_large_smiley = FALSE;
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
903 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
904
35757
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
905 conv = purple_conversations_find_with_account(jm->to, account);
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30744
diff changeset
906
35758
87c51487e197 Fix g_slist_remove_link misuse, remove debug printfs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35757
diff changeset
907 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
908 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
909
35792
d18a48a68edf Smiley parser: better symbol names
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35788
diff changeset
910 found_smileys = purple_smiley_parser_find(
d18a48a68edf Smiley parser: better symbol names
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35788
diff changeset
911 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
912 if (!found_smileys)
35757
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
913 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
914
35757
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
915 for (it = found_smileys; it; it = it_next) {
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
916 PurpleSmiley *smiley = it->data;
35823
268a9d3b3fd7 imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35792
diff changeset
917 PurpleImage *smiley_image;
35757
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
918 gboolean valid = TRUE;
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
919
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
920 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
921
35757
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
922 smiley_image = purple_smiley_get_image(smiley);
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
923 if (!smiley_image) {
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
924 valid = FALSE;
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
925 purple_debug_warning("jabber", "broken smiley %s",
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
926 purple_smiley_get_shortcut(smiley));
35823
268a9d3b3fd7 imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35792
diff changeset
927 } else if (purple_image_get_size(smiley_image) >
35757
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
928 JABBER_DATA_MAX_SIZE)
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
929 {
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
930 has_too_large_smiley = TRUE;
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
931 valid = FALSE;
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
932 purple_debug_warning("jabber", "Refusing to send "
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
933 "smiley %s (too large, max is %d)",
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
934 purple_smiley_get_shortcut(smiley),
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
935 JABBER_DATA_MAX_SIZE);
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
936 }
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
937
35757
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
938 if (!valid)
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
939 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
940 }
b1bfbf77cf90 Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents: 26984
diff changeset
941
35757
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
942 if (has_too_large_smiley) {
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36084
diff changeset
943 purple_conversation_write_system_message(conv,
35757
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
944 _("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
945 PURPLE_MESSAGE_ERROR);
35757
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
946 }
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
947
35758
87c51487e197 Fix g_slist_remove_link misuse, remove debug printfs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35757
diff changeset
948 if (!found_smileys)
35757
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
949 return NULL;
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
950
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
951 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
952 PurpleSmiley *smiley = it->data;
35823
268a9d3b3fd7 imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35792
diff changeset
953 PurpleImage *smiley_image;
35757
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
954 const gchar *shortcut = purple_smiley_get_shortcut(smiley);
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
955 const gchar *mimetype;
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
956 JabberData *jdata;
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
957
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
958 /* the object has been sent before */
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
959 if (jabber_data_find_local_by_alt(shortcut))
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
960 continue;
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
961
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
962 smiley_image = purple_smiley_get_image(smiley);
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
963 g_assert(smiley_image != NULL);
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
964
35823
268a9d3b3fd7 imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35792
diff changeset
965 mimetype = purple_image_get_mimetype(smiley_image);
268a9d3b3fd7 imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35792
diff changeset
966 if (!mimetype) {
268a9d3b3fd7 imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35792
diff changeset
967 purple_debug_error("jabber",
268a9d3b3fd7 imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35792
diff changeset
968 "unknown mime type for image");
268a9d3b3fd7 imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35792
diff changeset
969 continue;
268a9d3b3fd7 imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35792
diff changeset
970 }
35757
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
971
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
972 jdata = jabber_data_create_from_data(
35823
268a9d3b3fd7 imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35792
diff changeset
973 purple_image_get_data(smiley_image),
268a9d3b3fd7 imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35792
diff changeset
974 purple_image_get_size(smiley_image),
35757
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
975 mimetype, FALSE, jm->js);
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
976
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
977 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
978 shortcut, jabber_data_get_cid(jdata));
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
979 jabber_data_associate_local(jdata, shortcut);
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
980 }
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
981
35788
afa6d777bc7c Smileys: avoid breaking (x)html by not replacing smileys inside tags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35787
diff changeset
982 g_list_free(found_smileys);
35757
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
983
35792
d18a48a68edf Smiley parser: better symbol names
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35788
diff changeset
984 smileyfied_xhtml = purple_smiley_parser_replace(
d18a48a68edf Smiley parser: better symbol names
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35788
diff changeset
985 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
986 jabber_message_smileyify_cb, NULL);
35757
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
987
05981ff3fb7b Custom smileys: send them with xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35746
diff changeset
988 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
989 }
b1bfbf77cf90 Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents: 26984
diff changeset
990
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
991 void jabber_message_send(JabberMessage *jm)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
992 {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
993 PurpleXmlNode *message, *child;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
994 const char *type = NULL;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
995
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
996 message = purple_xmlnode_new("message");
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
997
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
998 switch(jm->type) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
999 case JABBER_MESSAGE_NORMAL:
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1000 type = "normal";
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1001 break;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1002 case JABBER_MESSAGE_CHAT:
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1003 case JABBER_MESSAGE_GROUPCHAT_INVITE:
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1004 type = "chat";
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1005 break;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1006 case JABBER_MESSAGE_HEADLINE:
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1007 type = "headline";
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1008 break;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1009 case JABBER_MESSAGE_GROUPCHAT:
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1010 type = "groupchat";
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1011 break;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1012 case JABBER_MESSAGE_ERROR:
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1013 type = "error";
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1014 break;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1015 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
1016 default:
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1017 type = NULL;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1018 break;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1019 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1020
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1021 if(type)
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
1022 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
1023
13484
350fd422b021 [gaim-migrate @ 15859]
Sean Egan <seanegan@pidgin.im>
parents: 13385
diff changeset
1024 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
1025 purple_xmlnode_set_attrib(message, "id", jm->id);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1026
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
1027 purple_xmlnode_set_attrib(message, "to", jm->to);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1028
8400
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
1029 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
1030 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
1031 purple_xmlnode_insert_data(child, jm->thread_id, -1);
8400
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
1032 }
09cd5dba5ca4 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
1033
27432
cf4a335fd0ec --warnings
Paul Aurich <darkrain42@pidgin.im>
parents: 27431
diff changeset
1034 child = NULL;
cf4a335fd0ec --warnings
Paul Aurich <darkrain42@pidgin.im>
parents: 27431
diff changeset
1035 switch(jm->chat_state)
cf4a335fd0ec --warnings
Paul Aurich <darkrain42@pidgin.im>
parents: 27431
diff changeset
1036 {
cf4a335fd0ec --warnings
Paul Aurich <darkrain42@pidgin.im>
parents: 27431
diff changeset
1037 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
1038 child = purple_xmlnode_new_child(message, "active");
27432
cf4a335fd0ec --warnings
Paul Aurich <darkrain42@pidgin.im>
parents: 27431
diff changeset
1039 break;
cf4a335fd0ec --warnings
Paul Aurich <darkrain42@pidgin.im>
parents: 27431
diff changeset
1040 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
1041 child = purple_xmlnode_new_child(message, "composing");
27432
cf4a335fd0ec --warnings
Paul Aurich <darkrain42@pidgin.im>
parents: 27431
diff changeset
1042 break;
cf4a335fd0ec --warnings
Paul Aurich <darkrain42@pidgin.im>
parents: 27431
diff changeset
1043 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
1044 child = purple_xmlnode_new_child(message, "paused");
27432
cf4a335fd0ec --warnings
Paul Aurich <darkrain42@pidgin.im>
parents: 27431
diff changeset
1045 break;
cf4a335fd0ec --warnings
Paul Aurich <darkrain42@pidgin.im>
parents: 27431
diff changeset
1046 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
1047 child = purple_xmlnode_new_child(message, "inactive");
27432
cf4a335fd0ec --warnings
Paul Aurich <darkrain42@pidgin.im>
parents: 27431
diff changeset
1048 break;
cf4a335fd0ec --warnings
Paul Aurich <darkrain42@pidgin.im>
parents: 27431
diff changeset
1049 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
1050 child = purple_xmlnode_new_child(message, "gone");
27432
cf4a335fd0ec --warnings
Paul Aurich <darkrain42@pidgin.im>
parents: 27431
diff changeset
1051 break;
cf4a335fd0ec --warnings
Paul Aurich <darkrain42@pidgin.im>
parents: 27431
diff changeset
1052 case JM_STATE_NONE:
cf4a335fd0ec --warnings
Paul Aurich <darkrain42@pidgin.im>
parents: 27431
diff changeset
1053 /* yep, nothing */
cf4a335fd0ec --warnings
Paul Aurich <darkrain42@pidgin.im>
parents: 27431
diff changeset
1054 break;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1055 }
27432
cf4a335fd0ec --warnings
Paul Aurich <darkrain42@pidgin.im>
parents: 27431
diff changeset
1056 if(child)
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
1057 purple_xmlnode_set_namespace(child, "http://jabber.org/protocol/chatstates");
13708
37d5bc24e5bf [gaim-migrate @ 16110]
Nathan Walp <nwalp@pidgin.im>
parents: 13484
diff changeset
1058
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1059 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
1060 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
1061 purple_xmlnode_insert_data(child, jm->subject, -1);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1062 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1063
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1064 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
1065 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
1066 purple_xmlnode_insert_data(child, jm->body, -1);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1067 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1068
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1069 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
1070 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
1071 purple_xmlnode_insert_child(message, child);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1072 } else {
28828
7c1855f037e7 jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 28726
diff changeset
1073 purple_debug_error("jabber",
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1074 "XHTML translation/validation failed, returning: %s\n",
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1075 jm->xhtml);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1076 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1077 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1078
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1079 jabber_send(jm->js, message);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1080
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
1081 purple_xmlnode_free(message);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1082 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1083
27061
b1bfbf77cf90 Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents: 26984
diff changeset
1084 /*
b1bfbf77cf90 Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents: 26984
diff changeset
1085 * 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
1086 * 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
1087 * FALSE.
b1bfbf77cf90 Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents: 26984
diff changeset
1088 */
b1bfbf77cf90 Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents: 26984
diff changeset
1089 static gboolean
b1bfbf77cf90 Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents: 26984
diff changeset
1090 jabber_xhtml_plain_equal(const char *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
1091 const char *plain)
b1bfbf77cf90 Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents: 26984
diff changeset
1092 {
b1bfbf77cf90 Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents: 26984
diff changeset
1093 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
1094 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
1095 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
1096 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
1097
b1bfbf77cf90 Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents: 26984
diff changeset
1098 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
1099 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
1100 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
1101 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
1102 continue;
b1bfbf77cf90 Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents: 26984
diff changeset
1103 }
b1bfbf77cf90 Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents: 26984
diff changeset
1104
b1bfbf77cf90 Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents: 26984
diff changeset
1105 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
1106 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
1107 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
1108 continue;
b1bfbf77cf90 Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents: 26984
diff changeset
1109 }
b1bfbf77cf90 Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents: 26984
diff changeset
1110
b1bfbf77cf90 Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents: 26984
diff changeset
1111 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
1112 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
1113 }
b1bfbf77cf90 Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents: 26984
diff changeset
1114
b1bfbf77cf90 Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents: 26984
diff changeset
1115 /* 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
1116 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
1117 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
1118 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
1119 }
b1bfbf77cf90 Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents: 26984
diff changeset
1120
36076
a0e5b68ff4ef Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35838
diff changeset
1121 int jabber_message_send_im(PurpleConnection *gc, PurpleMessage *msg)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1122 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1123 JabberMessage *jm;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1124 JabberBuddy *jb;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1125 JabberBuddyResource *jbr;
7135
8a92e2e034f9 [gaim-migrate @ 7702]
Nathan Walp <nwalp@pidgin.im>
parents: 7118
diff changeset
1126 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
1127 char *tmp;
7306
61d7324411f8 [gaim-migrate @ 7890]
Nathan Walp <nwalp@pidgin.im>
parents: 7261
diff changeset
1128 char *resource;
36098
4951752ad038 Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36092
diff changeset
1129 const gchar *rcpt = purple_message_get_recipient(msg);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1130
36098
4951752ad038 Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36092
diff changeset
1131 if (!rcpt || purple_message_is_empty(msg))
36076
a0e5b68ff4ef Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35838
diff changeset
1132 return 0;
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
1133
36098
4951752ad038 Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36092
diff changeset
1134 resource = jabber_get_resource(rcpt);
7306
61d7324411f8 [gaim-migrate @ 7890]
Nathan Walp <nwalp@pidgin.im>
parents: 7261
diff changeset
1135
36098
4951752ad038 Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36092
diff changeset
1136 jb = jabber_buddy_find(purple_connection_get_protocol_data(gc), rcpt, TRUE);
7306
61d7324411f8 [gaim-migrate @ 7890]
Nathan Walp <nwalp@pidgin.im>
parents: 7261
diff changeset
1137 jbr = jabber_buddy_find_resource(jb, resource);
61d7324411f8 [gaim-migrate @ 7890]
Nathan Walp <nwalp@pidgin.im>
parents: 7261
diff changeset
1138
61d7324411f8 [gaim-migrate @ 7890]
Nathan Walp <nwalp@pidgin.im>
parents: 7261
diff changeset
1139 g_free(resource);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1140
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1141 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
1142 jm->js = purple_connection_get_protocol_data(gc);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1143 jm->type = JABBER_MESSAGE_CHAT;
13708
37d5bc24e5bf [gaim-migrate @ 16110]
Nathan Walp <nwalp@pidgin.im>
parents: 13484
diff changeset
1144 jm->chat_state = JM_STATE_ACTIVE;
36098
4951752ad038 Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36092
diff changeset
1145 jm->to = g_strdup(rcpt);
13484
350fd422b021 [gaim-migrate @ 15859]
Sean Egan <seanegan@pidgin.im>
parents: 13385
diff changeset
1146 jm->id = jabber_get_next_id(jm->js);
13708
37d5bc24e5bf [gaim-migrate @ 16110]
Nathan Walp <nwalp@pidgin.im>
parents: 13484
diff changeset
1147
37d5bc24e5bf [gaim-migrate @ 16110]
Nathan Walp <nwalp@pidgin.im>
parents: 13484
diff changeset
1148 if(jbr) {
37d5bc24e5bf [gaim-migrate @ 16110]
Nathan Walp <nwalp@pidgin.im>
parents: 13484
diff changeset
1149 if(jbr->thread_id)
37d5bc24e5bf [gaim-migrate @ 16110]
Nathan Walp <nwalp@pidgin.im>
parents: 13484
diff changeset
1150 jm->thread_id = jbr->thread_id;
37d5bc24e5bf [gaim-migrate @ 16110]
Nathan Walp <nwalp@pidgin.im>
parents: 13484
diff changeset
1151
27429
3313d7d74962 Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <darkrain42@pidgin.im>
parents: 27237
diff changeset
1152 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
1153 jm->chat_state = JM_STATE_NONE;
3313d7d74962 Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <darkrain42@pidgin.im>
parents: 27237
diff changeset
1154 else {
13708
37d5bc24e5bf [gaim-migrate @ 16110]
Nathan Walp <nwalp@pidgin.im>
parents: 13484
diff changeset
1155 /* if(JABBER_CHAT_STATES_UNKNOWN == jbr->chat_states)
37d5bc24e5bf [gaim-migrate @ 16110]
Nathan Walp <nwalp@pidgin.im>
parents: 13484
diff changeset
1156 jbr->chat_states = JABBER_CHAT_STATES_UNSUPPORTED; */
37d5bc24e5bf [gaim-migrate @ 16110]
Nathan Walp <nwalp@pidgin.im>
parents: 13484
diff changeset
1157 }
37d5bc24e5bf [gaim-migrate @ 16110]
Nathan Walp <nwalp@pidgin.im>
parents: 13484
diff changeset
1158 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1159
36076
a0e5b68ff4ef Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35838
diff changeset
1160 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
1161 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
1162 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
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 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
1165 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
1166 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
1167 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
1168 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1169
27746
4b3f015977d9 For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents: 27237
diff changeset
1170 /*
4b3f015977d9 For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents: 27237
diff changeset
1171 * 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
1172 * 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
1173 */
4b3f015977d9 For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents: 27237
diff changeset
1174 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
1175 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
1176 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
1177 /* 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
1178 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
1179 }
27061
b1bfbf77cf90 Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents: 26984
diff changeset
1180
b1bfbf77cf90 Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents: 26984
diff changeset
1181 g_free(xhtml);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1182
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1183 jabber_message_send(jm);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1184 jabber_message_free(jm);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1185 return 1;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1186 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1187
36077
b7328f4317c7 Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36076
diff changeset
1188 int jabber_message_send_chat(PurpleConnection *gc, int id, PurpleMessage *msg)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1189 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1190 JabberChat *chat;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1191 JabberMessage *jm;
8042
3643df1e6e78 [gaim-migrate @ 8726]
Nathan Walp <nwalp@pidgin.im>
parents: 8016
diff changeset
1192 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
1193 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
1194 char *tmp;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1195
36077
b7328f4317c7 Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36076
diff changeset
1196 if (!gc || purple_message_is_empty(msg))
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1197 return 0;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1198
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
1199 js = purple_connection_get_protocol_data(gc);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1200 chat = jabber_chat_find_by_id(js, id);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1201
8043
86a087e9624c [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8042
diff changeset
1202 if(!chat)
86a087e9624c [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8042
diff changeset
1203 return 0;
86a087e9624c [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8042
diff changeset
1204
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8858
diff changeset
1205 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
1206 jm->js = purple_connection_get_protocol_data(gc);
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8858
diff changeset
1207 jm->type = JABBER_MESSAGE_GROUPCHAT;
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8858
diff changeset
1208 jm->to = g_strdup_printf("%s@%s", chat->room, chat->server);
13484
350fd422b021 [gaim-migrate @ 15859]
Sean Egan <seanegan@pidgin.im>
parents: 13385
diff changeset
1209 jm->id = jabber_get_next_id(jm->js);
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8858
diff changeset
1210
36077
b7328f4317c7 Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36076
diff changeset
1211 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
1212 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
1213 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
1214 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
1215 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
1216 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
1217 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
1218 }
8858
99c635a80a26 [gaim-migrate @ 9626]
Nathan Walp <nwalp@pidgin.im>
parents: 8577
diff changeset
1219
27061
b1bfbf77cf90 Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents: 26984
diff changeset
1220 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
1221 /* 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
1222 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
1223
b1bfbf77cf90 Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents: 26984
diff changeset
1224 g_free(xhtml);
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7894
diff changeset
1225
9130
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8858
diff changeset
1226 jabber_message_send(jm);
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8858
diff changeset
1227 jabber_message_free(jm);
2e67295dd047 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8858
diff changeset
1228
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1229 return 1;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1230 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1231
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
1232 unsigned int jabber_send_typing(PurpleConnection *gc, const char *who, PurpleIMTypingState state)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1233 {
30454
4e9bf65cfe9a jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents: 30239
diff changeset
1234 JabberStream *js;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1235 JabberMessage *jm;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1236 JabberBuddy *jb;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1237 JabberBuddyResource *jbr;
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30744
diff changeset
1238 char *resource;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1239
30454
4e9bf65cfe9a jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents: 30239
diff changeset
1240 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
1241 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
1242 if (!jb)
4e9bf65cfe9a jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents: 30239
diff changeset
1243 return 0;
4e9bf65cfe9a jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents: 30239
diff changeset
1244
4e9bf65cfe9a jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents: 30239
diff changeset
1245 resource = jabber_get_resource(who);
7306
61d7324411f8 [gaim-migrate @ 7890]
Nathan Walp <nwalp@pidgin.im>
parents: 7261
diff changeset
1246 jbr = jabber_buddy_find_resource(jb, resource);
61d7324411f8 [gaim-migrate @ 7890]
Nathan Walp <nwalp@pidgin.im>
parents: 7261
diff changeset
1247 g_free(resource);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1248
30235
d37c441d6a48 jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <darkrain42@pidgin.im>
parents: 30121
diff changeset
1249 /* 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
1250 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
1251 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
1252
d37c441d6a48 jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <darkrain42@pidgin.im>
parents: 30121
diff changeset
1253 /* *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
1254 * 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
1255 */
d37c441d6a48 jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <darkrain42@pidgin.im>
parents: 30121
diff changeset
1256 if (!jbr && !(jb->subscription & JABBER_SUB_FROM))
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1257 return 0;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1258
13708
37d5bc24e5bf [gaim-migrate @ 16110]
Nathan Walp <nwalp@pidgin.im>
parents: 13484
diff changeset
1259 /* TODO: figure out threading */
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1260 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
1261 jm->js = js;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1262 jm->type = JABBER_MESSAGE_CHAT;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1263 jm->to = g_strdup(who);
13484
350fd422b021 [gaim-migrate @ 15859]
Sean Egan <seanegan@pidgin.im>
parents: 13385
diff changeset
1264 jm->id = jabber_get_next_id(jm->js);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1265
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
1266 if(PURPLE_IM_TYPING == state)
13708
37d5bc24e5bf [gaim-migrate @ 16110]
Nathan Walp <nwalp@pidgin.im>
parents: 13484
diff changeset
1267 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
1268 else if(PURPLE_IM_TYPED == state)
13708
37d5bc24e5bf [gaim-migrate @ 16110]
Nathan Walp <nwalp@pidgin.im>
parents: 13484
diff changeset
1269 jm->chat_state = JM_STATE_PAUSED;
37d5bc24e5bf [gaim-migrate @ 16110]
Nathan Walp <nwalp@pidgin.im>
parents: 13484
diff changeset
1270 else
37d5bc24e5bf [gaim-migrate @ 16110]
Nathan Walp <nwalp@pidgin.im>
parents: 13484
diff changeset
1271 jm->chat_state = JM_STATE_ACTIVE;
37d5bc24e5bf [gaim-migrate @ 16110]
Nathan Walp <nwalp@pidgin.im>
parents: 13484
diff changeset
1272
27429
3313d7d74962 Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <darkrain42@pidgin.im>
parents: 27237
diff changeset
1273 /* 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
1274 jbr->chat_states = JABBER_CHAT_STATES_UNSUPPORTED; */
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1275
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1276 jabber_message_send(jm);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1277 jabber_message_free(jm);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1278
13708
37d5bc24e5bf [gaim-migrate @ 16110]
Nathan Walp <nwalp@pidgin.im>
parents: 13484
diff changeset
1279 return 0;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1280 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1281
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23249
diff changeset
1282 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
1283 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
1284 }
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
1285
24715
69aaae59e205 Fix compilation errors and many warnings
Paul Aurich <darkrain42@pidgin.im>
parents: 24714
diff changeset
1286 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
1287 {
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
1288 const PurpleConnection *gc = js->gc;
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
1289 PurpleAccount *account = purple_connection_get_account(gc);
23627
dbdc407798af A couple of leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23626
diff changeset
1290
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23249
diff changeset
1291 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
1292 }

mercurial