annotate libpurple/protocols/jabber/message.c @ 32345:e323c2f84872

merge of '8e3c82b6770042fa4b42cfd0dee9cbcd54ed894a' and 'e9fceac2dee9c0b9c449263d63857762c7fe7715'
author Mark Doliner <mark@kingant.net>
date Mon, 31 Oct 2011 02:29:25 +0000
parents afdbf45fa861
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /*
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15659
diff changeset
2 * purple - Jabber Protocol Plugin
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
28048
c585572e80dd Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
c585572e80dd Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
c585572e80dd Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents: 27637
diff changeset
6 * source distribution.
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
19681
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19310
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 #include "internal.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 #include "debug.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 #include "notify.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include "server.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "util.h"
26694
83e6e710cbf3 Add a new signal which is emitted (after the account is connected) if the
Paul Aurich <paul@darkrain42.org>
parents: 26690
diff changeset
29 #include "adhoccommands.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include "buddy.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include "chat.h"
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
32 #include "data.h"
30472
ae615b3d3e47 First shot at refactoring the Google-specific XMPP code.
Marcus Lundblad <ml@update.uu.se>
parents: 29630
diff changeset
33 #include "google/google.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 #include "message.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 #include "xmlnode.h"
17834
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents: 17258
diff changeset
36 #include "pep.h"
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
37 #include "smiley.h"
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
38 #include "iq.h"
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
39
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
40 #include <string.h>
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 void jabber_message_free(JabberMessage *jm)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 {
15917
26593bef6568 Minor code cleanup
Mark Doliner <mark@kingant.net>
parents: 15822
diff changeset
44 g_free(jm->from);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 g_free(jm->to);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 g_free(jm->id);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 g_free(jm->subject);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 g_free(jm->body);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 g_free(jm->xhtml);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 g_free(jm->password);
20192
41e39193e247 applied changes from 326d6e6c8c6a955cdba84f1f802fc21ec3e6b662
Richard Laager <rlaager@wiktel.com>
parents: 19718
diff changeset
51 g_free(jm->error);
41e39193e247 applied changes from 326d6e6c8c6a955cdba84f1f802fc21ec3e6b662
Richard Laager <rlaager@wiktel.com>
parents: 19718
diff changeset
52 g_free(jm->thread_id);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 g_list_free(jm->etc);
20192
41e39193e247 applied changes from 326d6e6c8c6a955cdba84f1f802fc21ec3e6b662
Richard Laager <rlaager@wiktel.com>
parents: 19718
diff changeset
54 g_list_free(jm->eventitems);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 g_free(jm);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 static void handle_chat(JabberMessage *jm)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 JabberID *jid = jabber_id_new(jm->from);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62
29009
4fb74d76c2df jabber: Use some convenience variables here.
Paul Aurich <paul@darkrain42.org>
parents: 29008
diff changeset
63 PurpleConnection *gc;
4fb74d76c2df jabber: Use some convenience variables here.
Paul Aurich <paul@darkrain42.org>
parents: 29008
diff changeset
64 PurpleAccount *account;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 JabberBuddy *jb;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 JabberBuddyResource *jbr;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 if(!jid)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70
29009
4fb74d76c2df jabber: Use some convenience variables here.
Paul Aurich <paul@darkrain42.org>
parents: 29008
diff changeset
71 gc = jm->js->gc;
4fb74d76c2df jabber: Use some convenience variables here.
Paul Aurich <paul@darkrain42.org>
parents: 29008
diff changeset
72 account = purple_connection_get_account(gc);
4fb74d76c2df jabber: Use some convenience variables here.
Paul Aurich <paul@darkrain42.org>
parents: 29008
diff changeset
73
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74 jb = jabber_buddy_find(jm->js, jm->from, TRUE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 jbr = jabber_buddy_find_resource(jb, jid->resource);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 if(!jm->xhtml && !jm->body) {
29919
716d6bb38829 jabber: Refined logic for determining "is typing" support.
Paul Aurich <paul@darkrain42.org>
parents: 29915
diff changeset
78 if (jbr && jm->chat_state != JM_STATE_NONE)
716d6bb38829 jabber: Refined logic for determining "is typing" support.
Paul Aurich <paul@darkrain42.org>
parents: 29915
diff changeset
79 jbr->chat_states = JABBER_CHAT_STATES_SUPPORTED;
27512
ed284238509b Use Entity Capabilities to pick up Chat States support. Refs #4650.
Paul Aurich <paul@darkrain42.org>
parents: 27511
diff changeset
80
15648
e86623eb3b79 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@gmail.com>
parents: 15647
diff changeset
81 if(JM_STATE_COMPOSING == jm->chat_state) {
29014
b676cb5b4595 jabber: Cleanup (and drop that unnormalized find function)!
Paul Aurich <paul@darkrain42.org>
parents: 29010
diff changeset
82 serv_got_typing(gc, jm->from, 0, PURPLE_TYPING);
15648
e86623eb3b79 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@gmail.com>
parents: 15647
diff changeset
83 } else if(JM_STATE_PAUSED == jm->chat_state) {
29014
b676cb5b4595 jabber: Cleanup (and drop that unnormalized find function)!
Paul Aurich <paul@darkrain42.org>
parents: 29010
diff changeset
84 serv_got_typing(gc, jm->from, 0, PURPLE_TYPED);
15648
e86623eb3b79 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@gmail.com>
parents: 15647
diff changeset
85 } else if(JM_STATE_GONE == jm->chat_state) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15659
diff changeset
86 PurpleConversation *conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM,
29014
b676cb5b4595 jabber: Cleanup (and drop that unnormalized find function)!
Paul Aurich <paul@darkrain42.org>
parents: 29010
diff changeset
87 jm->from, account);
15659
94a19bde141d Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents: 15648
diff changeset
88 if (conv && jid->node && jid->domain) {
94a19bde141d Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents: 15648
diff changeset
89 char buf[256];
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15659
diff changeset
90 PurpleBuddy *buddy;
15659
94a19bde141d Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents: 15648
diff changeset
91
94a19bde141d Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents: 15648
diff changeset
92 g_snprintf(buf, sizeof(buf), "%s@%s", jid->node, jid->domain);
94a19bde141d Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents: 15648
diff changeset
93
29009
4fb74d76c2df jabber: Use some convenience variables here.
Paul Aurich <paul@darkrain42.org>
parents: 29008
diff changeset
94 if ((buddy = purple_find_buddy(account, buf))) {
15659
94a19bde141d Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents: 15648
diff changeset
95 const char *who;
94a19bde141d Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents: 15648
diff changeset
96 char *escaped;
94a19bde141d Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents: 15648
diff changeset
97
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15659
diff changeset
98 who = purple_buddy_get_alias(buddy);
15659
94a19bde141d Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents: 15648
diff changeset
99 escaped = g_markup_escape_text(who, -1);
94a19bde141d Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents: 15648
diff changeset
100
94a19bde141d Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents: 15648
diff changeset
101 g_snprintf(buf, sizeof(buf),
16890
7c28e457563f New string
Sean Egan <seanegan@gmail.com>
parents: 16719
diff changeset
102 _("%s has left the conversation."), escaped);
20570
5913725cbcd6 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20106
diff changeset
103 g_free(escaped);
15659
94a19bde141d Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents: 15648
diff changeset
104
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15659
diff changeset
105 /* At some point when we restructure PurpleConversation,
15659
94a19bde141d Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents: 15648
diff changeset
106 * this should be able to be implemented by removing the
94a19bde141d Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents: 15648
diff changeset
107 * user from the conversation like we do with chats now. */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15659
diff changeset
108 purple_conversation_write(conv, "", buf,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15659
diff changeset
109 PURPLE_MESSAGE_SYSTEM, time(NULL));
15659
94a19bde141d Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents: 15648
diff changeset
110 }
15648
e86623eb3b79 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@gmail.com>
parents: 15647
diff changeset
111 }
29014
b676cb5b4595 jabber: Cleanup (and drop that unnormalized find function)!
Paul Aurich <paul@darkrain42.org>
parents: 29010
diff changeset
112 serv_got_typing_stopped(gc, jm->from);
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25716
diff changeset
113
15648
e86623eb3b79 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@gmail.com>
parents: 15647
diff changeset
114 } else {
29014
b676cb5b4595 jabber: Cleanup (and drop that unnormalized find function)!
Paul Aurich <paul@darkrain42.org>
parents: 29010
diff changeset
115 serv_got_typing_stopped(gc, jm->from);
15648
e86623eb3b79 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@gmail.com>
parents: 15647
diff changeset
116 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 } else {
29552
b71821db0516 jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <paul@darkrain42.org>
parents: 29043
diff changeset
118 if (jid->resource) {
b71821db0516 jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <paul@darkrain42.org>
parents: 29043
diff changeset
119 /*
b71821db0516 jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <paul@darkrain42.org>
parents: 29043
diff changeset
120 * We received a message from a specific resource, so
b71821db0516 jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <paul@darkrain42.org>
parents: 29043
diff changeset
121 * we probably want a reply to go to this specific
b71821db0516 jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <paul@darkrain42.org>
parents: 29043
diff changeset
122 * resource (i.e. bind/lock the conversation to this
b71821db0516 jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <paul@darkrain42.org>
parents: 29043
diff changeset
123 * resource).
b71821db0516 jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <paul@darkrain42.org>
parents: 29043
diff changeset
124 *
b71821db0516 jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <paul@darkrain42.org>
parents: 29043
diff changeset
125 * This works because purple_conv_im_send gets the name
b71821db0516 jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <paul@darkrain42.org>
parents: 29043
diff changeset
126 * from purple_conversation_get_name()
b71821db0516 jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <paul@darkrain42.org>
parents: 29043
diff changeset
127 */
b71821db0516 jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <paul@darkrain42.org>
parents: 29043
diff changeset
128 PurpleConversation *conv;
b71821db0516 jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <paul@darkrain42.org>
parents: 29043
diff changeset
129
b71821db0516 jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <paul@darkrain42.org>
parents: 29043
diff changeset
130 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM,
b71821db0516 jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <paul@darkrain42.org>
parents: 29043
diff changeset
131 jm->from, account);
b71821db0516 jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <paul@darkrain42.org>
parents: 29043
diff changeset
132 if (conv && !g_str_equal(jm->from,
b71821db0516 jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <paul@darkrain42.org>
parents: 29043
diff changeset
133 purple_conversation_get_name(conv))) {
b71821db0516 jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <paul@darkrain42.org>
parents: 29043
diff changeset
134 purple_debug_info("jabber", "Binding conversation to %s\n",
b71821db0516 jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <paul@darkrain42.org>
parents: 29043
diff changeset
135 jm->from);
b71821db0516 jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <paul@darkrain42.org>
parents: 29043
diff changeset
136 purple_conversation_set_name(conv, jm->from);
b71821db0516 jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <paul@darkrain42.org>
parents: 29043
diff changeset
137 }
b71821db0516 jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <paul@darkrain42.org>
parents: 29043
diff changeset
138 }
b71821db0516 jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <paul@darkrain42.org>
parents: 29043
diff changeset
139
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 if(jbr) {
29919
716d6bb38829 jabber: Refined logic for determining "is typing" support.
Paul Aurich <paul@darkrain42.org>
parents: 29915
diff changeset
141 /* Treat SUPPORTED as a terminal with no escape :) */
716d6bb38829 jabber: Refined logic for determining "is typing" support.
Paul Aurich <paul@darkrain42.org>
parents: 29915
diff changeset
142 if (jbr->chat_states != JABBER_CHAT_STATES_SUPPORTED) {
716d6bb38829 jabber: Refined logic for determining "is typing" support.
Paul Aurich <paul@darkrain42.org>
parents: 29915
diff changeset
143 if (jm->chat_state != JM_STATE_NONE)
716d6bb38829 jabber: Refined logic for determining "is typing" support.
Paul Aurich <paul@darkrain42.org>
parents: 29915
diff changeset
144 jbr->chat_states = JABBER_CHAT_STATES_SUPPORTED;
716d6bb38829 jabber: Refined logic for determining "is typing" support.
Paul Aurich <paul@darkrain42.org>
parents: 29915
diff changeset
145 else
716d6bb38829 jabber: Refined logic for determining "is typing" support.
Paul Aurich <paul@darkrain42.org>
parents: 29915
diff changeset
146 jbr->chat_states = JABBER_CHAT_STATES_UNSUPPORTED;
716d6bb38829 jabber: Refined logic for determining "is typing" support.
Paul Aurich <paul@darkrain42.org>
parents: 29915
diff changeset
147 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 if(jbr->thread_id)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150 g_free(jbr->thread_id);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 jbr->thread_id = g_strdup(jbr->thread_id);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 }
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25716
diff changeset
153
15522
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
154 if (jm->js->googletalk && jm->xhtml == NULL) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
155 char *tmp = jm->body;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
156 jm->body = jabber_google_format_to_html(jm->body);
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
157 g_free(tmp);
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
158 }
29014
b676cb5b4595 jabber: Cleanup (and drop that unnormalized find function)!
Paul Aurich <paul@darkrain42.org>
parents: 29010
diff changeset
159 serv_got_im(gc, jm->from, jm->xhtml ? jm->xhtml : jm->body, 0, jm->sent);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 jabber_id_free(jid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 static void handle_headline(JabberMessage *jm)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 char *title;
17885
b8de63d3bf89 Added buzz support using a private extension. Maybe I should write a XEP about that.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17877
diff changeset
168 GString *body;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 GList *etc;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170
17885
b8de63d3bf89 Added buzz support using a private extension. Maybe I should write a XEP about that.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17877
diff changeset
171 if(!jm->xhtml && !jm->body)
b8de63d3bf89 Added buzz support using a private extension. Maybe I should write a XEP about that.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17877
diff changeset
172 return; /* ignore headlines without any content */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173
17885
b8de63d3bf89 Added buzz support using a private extension. Maybe I should write a XEP about that.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17877
diff changeset
174 body = g_string_new("");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 title = g_strdup_printf(_("Message from %s"), jm->from);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 if(jm->xhtml)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 g_string_append(body, jm->xhtml);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 else if(jm->body)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 g_string_append(body, jm->body);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 for(etc = jm->etc; etc; etc = etc->next) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183 xmlnode *x = etc->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 const char *xmlns = xmlnode_get_namespace(x);
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28645
diff changeset
185 if(xmlns && !strcmp(xmlns, NS_OOB_X_DATA)) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186 xmlnode *url, *desc;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187 char *urltxt, *desctxt;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 url = xmlnode_get_child(x, "url");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190 desc = xmlnode_get_child(x, "desc");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192 if(!url || !desc)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 urltxt = xmlnode_get_data(url);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196 desctxt = xmlnode_get_data(desc);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198 /* I'm all about ugly hacks */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
199 if(body->len && jm->body && !strcmp(body->str, jm->body))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200 g_string_printf(body, "<a href='%s'>%s</a>",
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201 urltxt, desctxt);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 g_string_append_printf(body, "<br/><a href='%s'>%s</a>",
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 urltxt, desctxt);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 g_free(urltxt);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 g_free(desctxt);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15659
diff changeset
211 purple_notify_formatted(jm->js->gc, title, jm->subject ? jm->subject : title,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 NULL, body->str, NULL, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 g_free(title);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 g_string_free(body, TRUE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 static void handle_groupchat(JabberMessage *jm)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 JabberID *jid = jabber_id_new(jm->from);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 JabberChat *chat;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 if(!jid)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 chat = jabber_chat_find(jm->js, jid->node, jid->domain);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 if(!chat)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 if(jm->subject) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15659
diff changeset
232 purple_conv_chat_set_topic(PURPLE_CONV_CHAT(chat->conv), jid->resource,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 jm->subject);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 if(!jm->xhtml && !jm->body) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235 char *msg, *tmp, *tmp2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 tmp = g_markup_escape_text(jm->subject, -1);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15659
diff changeset
237 tmp2 = purple_markup_linkify(tmp);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238 if(jid->resource)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239 msg = g_strdup_printf(_("%s has set the topic to: %s"), jid->resource, tmp2);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 msg = g_strdup_printf(_("The topic is: %s"), tmp2);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15659
diff changeset
242 purple_conv_chat_write(PURPLE_CONV_CHAT(chat->conv), "", msg, PURPLE_MESSAGE_SYSTEM, jm->sent);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 g_free(tmp);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244 g_free(tmp2);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245 g_free(msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249 if(jm->xhtml || jm->body) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250 if(jid->resource)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251 serv_got_chat_in(jm->js->gc, chat->id, jid->resource,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15659
diff changeset
252 jm->delayed ? PURPLE_MESSAGE_DELAYED : 0,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 jm->xhtml ? jm->xhtml : jm->body, jm->sent);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254 else if(chat->muc)
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15659
diff changeset
255 purple_conv_chat_write(PURPLE_CONV_CHAT(chat->conv), "",
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256 jm->xhtml ? jm->xhtml : jm->body,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15659
diff changeset
257 PURPLE_MESSAGE_SYSTEM, jm->sent);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 jabber_id_free(jid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
261 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263 static void handle_groupchat_invite(JabberMessage *jm)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
265 GHashTable *components;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266 JabberID *jid = jabber_id_new(jm->to);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268 if(!jid)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270
15536
b081c81a4dea Get rid of some unnecessary string duping
Mark Doliner <mark@kingant.net>
parents: 15522
diff changeset
271 components = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
272
15536
b081c81a4dea Get rid of some unnecessary string duping
Mark Doliner <mark@kingant.net>
parents: 15522
diff changeset
273 g_hash_table_replace(components, "room", g_strdup(jid->node));
b081c81a4dea Get rid of some unnecessary string duping
Mark Doliner <mark@kingant.net>
parents: 15522
diff changeset
274 g_hash_table_replace(components, "server", g_strdup(jid->domain));
b081c81a4dea Get rid of some unnecessary string duping
Mark Doliner <mark@kingant.net>
parents: 15522
diff changeset
275 g_hash_table_replace(components, "handle", g_strdup(jm->js->user->node));
b081c81a4dea Get rid of some unnecessary string duping
Mark Doliner <mark@kingant.net>
parents: 15522
diff changeset
276 g_hash_table_replace(components, "password", g_strdup(jm->password));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 jabber_id_free(jid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279 serv_got_chat_invite(jm->js->gc, jm->to, jm->from, jm->body, components);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282 static void handle_error(JabberMessage *jm)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284 char *buf;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286 if(!jm->body)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
287 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 buf = g_strdup_printf(_("Message delivery to %s failed: %s"),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290 jm->from, jm->error ? jm->error : "");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
291
16904
56042b2f8b64 s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@wiktel.com>
parents: 16890
diff changeset
292 purple_notify_formatted(jm->js->gc, _("XMPP Message Error"), _("XMPP Message Error"), buf,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293 jm->xhtml ? jm->xhtml : jm->body, NULL, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295 g_free(buf);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
297
17888
cca457b9158b disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents: 17887
diff changeset
298 static void handle_buzz(JabberMessage *jm) {
cca457b9158b disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents: 17887
diff changeset
299 PurpleAccount *account;
24878
689cfb82242e Use purple_prpl_got_attention() for XMPP notifications
Evan Schoenberg <evan.s@dreskin.net>
parents: 24721
diff changeset
300
17889
9686d549f084 Switched buzz namespace and tag name to be libpurple-specific and use a more professionally-sounding name ('attention' instead of 'buzz').
Andreas Monitzer <pidgin@monitzer.com>
parents: 17888
diff changeset
301 /* Delayed buzz MUST NOT be accepted */
9686d549f084 Switched buzz namespace and tag name to be libpurple-specific and use a more professionally-sounding name ('attention' instead of 'buzz').
Andreas Monitzer <pidgin@monitzer.com>
parents: 17888
diff changeset
302 if(jm->delayed)
9686d549f084 Switched buzz namespace and tag name to be libpurple-specific and use a more professionally-sounding name ('attention' instead of 'buzz').
Andreas Monitzer <pidgin@monitzer.com>
parents: 17888
diff changeset
303 return;
24878
689cfb82242e Use purple_prpl_got_attention() for XMPP notifications
Evan Schoenberg <evan.s@dreskin.net>
parents: 24721
diff changeset
304
17890
935005186312 Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17889
diff changeset
305 /* Reject buzz when it's not enabled */
935005186312 Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17889
diff changeset
306 if(!jm->js->allowBuzz)
935005186312 Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17889
diff changeset
307 return;
24878
689cfb82242e Use purple_prpl_got_attention() for XMPP notifications
Evan Schoenberg <evan.s@dreskin.net>
parents: 24721
diff changeset
308
17888
cca457b9158b disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents: 17887
diff changeset
309 account = purple_connection_get_account(jm->js->gc);
24878
689cfb82242e Use purple_prpl_got_attention() for XMPP notifications
Evan Schoenberg <evan.s@dreskin.net>
parents: 24721
diff changeset
310
30413
7c871249318b Fix some "Dead nested assignment"s and then kill off some useless
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30316
diff changeset
311 if (purple_find_buddy(account, jm->from) == NULL)
17889
9686d549f084 Switched buzz namespace and tag name to be libpurple-specific and use a more professionally-sounding name ('attention' instead of 'buzz').
Andreas Monitzer <pidgin@monitzer.com>
parents: 17888
diff changeset
312 return; /* Do not accept buzzes from unknown people */
9686d549f084 Switched buzz namespace and tag name to be libpurple-specific and use a more professionally-sounding name ('attention' instead of 'buzz').
Andreas Monitzer <pidgin@monitzer.com>
parents: 17888
diff changeset
313
24878
689cfb82242e Use purple_prpl_got_attention() for XMPP notifications
Evan Schoenberg <evan.s@dreskin.net>
parents: 24721
diff changeset
314 /* xmpp only has 1 attention type, so index is 0 */
25707
b707ec143eee Give username (JID) to purple_prpl_got_attention, not alias
Marcus Lundblad <ml@update.uu.se>
parents: 25701
diff changeset
315 purple_prpl_got_attention(jm->js->gc, jm->from, 0);
17888
cca457b9158b disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents: 17887
diff changeset
316 }
cca457b9158b disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents: 17887
diff changeset
317
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
318 /* used internally by the functions below */
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
319 typedef struct {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
320 gchar *cid;
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
321 gchar *alt;
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
322 } JabberSmileyRef;
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
323
24058
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
324
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
325 static void
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
326 jabber_message_get_refs_from_xmlnode_internal(const xmlnode *message,
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
327 GHashTable *table)
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
328 {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
329 xmlnode *child;
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25716
diff changeset
330
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
331 for (child = xmlnode_get_child(message, "img") ; child ;
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
332 child = xmlnode_get_next_twin(child)) {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
333 const gchar *src = xmlnode_get_attrib(child, "src");
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25716
diff changeset
334
24058
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
335 if (g_str_has_prefix(src, "cid:")) {
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
336 const gchar *cid = src + 4;
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25716
diff changeset
337
24058
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
338 /* if we haven't "fetched" this yet... */
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
339 if (!g_hash_table_lookup(table, cid)) {
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
340 /* take a copy of the cid and let the SmileyRef own it... */
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
341 gchar *temp_cid = g_strdup(cid);
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
342 JabberSmileyRef *ref = g_new0(JabberSmileyRef, 1);
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
343 const gchar *alt = xmlnode_get_attrib(child, "alt");
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
344 ref->cid = temp_cid;
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25716
diff changeset
345 /* if there is no "alt" string, use the cid...
24062
f1ead28fcc5a When receiving an <img/> without the "alt" attribute, set
Marcus Lundblad <ml@update.uu.se>
parents: 24061
diff changeset
346 include the entire src, eg. "cid:.." to avoid linkification */
24058
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
347 if (alt && alt[0] != '\0') {
24063
463240455f55 Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents: 24062
diff changeset
348 /* workaround for when "alt" is set to the value of the
463240455f55 Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents: 24062
diff changeset
349 CID (which Jabbim seems to do), to avoid it showing up
463240455f55 Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents: 24062
diff changeset
350 as an mailto: link */
463240455f55 Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents: 24062
diff changeset
351 if (purple_email_is_valid(alt)) {
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25716
diff changeset
352 ref->alt = g_strdup_printf("smiley:%s", alt);
24063
463240455f55 Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents: 24062
diff changeset
353 } else {
463240455f55 Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents: 24062
diff changeset
354 ref->alt = g_strdup(alt);
463240455f55 Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents: 24062
diff changeset
355 }
24058
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
356 } else {
24062
f1ead28fcc5a When receiving an <img/> without the "alt" attribute, set
Marcus Lundblad <ml@update.uu.se>
parents: 24061
diff changeset
357 ref->alt = g_strdup(src);
24058
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
358 }
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
359 g_hash_table_insert(table, temp_cid, ref);
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
360 }
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
361 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
362 }
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25716
diff changeset
363
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
364 for (child = message->child ; child ; child = child->next) {
24058
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
365 jabber_message_get_refs_from_xmlnode_internal(child, table);
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
366 }
24058
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
367 }
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
368
24058
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
369 static gboolean
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
370 jabber_message_get_refs_steal(gpointer key, gpointer value, gpointer user_data)
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
371 {
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
372 GList **refs = (GList **) user_data;
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
373 JabberSmileyRef *ref = (JabberSmileyRef *) value;
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25716
diff changeset
374
24058
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
375 *refs = g_list_append(*refs, ref);
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25716
diff changeset
376
24058
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
377 return TRUE;
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
378 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
379
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
380 static GList *
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
381 jabber_message_get_refs_from_xmlnode(const xmlnode *message)
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
382 {
24058
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
383 GList *refs = NULL;
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
384 GHashTable *unique_refs = g_hash_table_new(g_str_hash, g_str_equal);
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25716
diff changeset
385
24058
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
386 jabber_message_get_refs_from_xmlnode_internal(message, unique_refs);
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25716
diff changeset
387 (void) g_hash_table_foreach_steal(unique_refs,
24058
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
388 jabber_message_get_refs_steal, (gpointer) &refs);
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
389 g_hash_table_destroy(unique_refs);
24058
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
390 return refs;
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
391 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
392
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
393 static gchar *
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
394 jabber_message_xml_to_string_strip_img_smileys(xmlnode *xhtml)
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
395 {
24180
14915e96311e Another memory leak fix. Also, keep a copy of the alt-text in
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24179
diff changeset
396 gchar *markup = xmlnode_to_str(xhtml, NULL);
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
397 int len = strlen(markup);
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
398 int pos = 0;
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
399 GString *out = g_string_new(NULL);
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
400
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
401 while (pos < len) {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
402 /* this is a bit cludgy, maybe there is a better way to do this...
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
403 we need to find all <img> tags within the XHTML and replace those
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
404 tags with the value of their "alt" attributes */
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
405 if (g_str_has_prefix(&(markup[pos]), "<img")) {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
406 xmlnode *img = NULL;
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
407 int pos2 = pos;
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
408 const gchar *src;
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
409
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
410 for (; pos2 < len ; pos2++) {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
411 if (g_str_has_prefix(&(markup[pos2]), "/>")) {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
412 pos2 += 2;
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
413 break;
24058
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
414 } else if (g_str_has_prefix(&(markup[pos2]), "</img>")) {
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
415 pos2 += 5;
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
416 break;
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
417 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
418 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
419
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
420 /* note, if the above loop didn't find the end of the <img> tag,
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
421 it the parsed string will be until the end of the input string,
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
422 in which case xmlnode_from_str will bail out and return NULL,
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
423 in this case the "if" statement below doesn't trigger and the
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
424 text is copied unchanged */
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
425 img = xmlnode_from_str(&(markup[pos]), pos2 - pos);
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
426 src = xmlnode_get_attrib(img, "src");
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
427
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
428 if (g_str_has_prefix(src, "cid:")) {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
429 const gchar *alt = xmlnode_get_attrib(img, "alt");
24058
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
430 /* if the "alt" attribute is empty, put the cid as smiley string */
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
431 if (alt && alt[0] != '\0') {
24063
463240455f55 Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents: 24062
diff changeset
432 /* if the "alt" is the same as the CID, as Jabbim does,
463240455f55 Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents: 24062
diff changeset
433 this prevents linkification... */
463240455f55 Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents: 24062
diff changeset
434 if (purple_email_is_valid(alt)) {
24179
2c6c9d72f54f A couple of compile warning fixes, a couple of memory leak plugs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24063
diff changeset
435 gchar *safe_alt = g_strdup_printf("smiley:%s", alt);
24063
463240455f55 Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents: 24062
diff changeset
436 out = g_string_append(out, safe_alt);
463240455f55 Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents: 24062
diff changeset
437 g_free(safe_alt);
463240455f55 Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents: 24062
diff changeset
438 } else {
463240455f55 Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents: 24062
diff changeset
439 out = g_string_append(out, alt);
463240455f55 Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents: 24062
diff changeset
440 }
24058
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
441 } else {
24062
f1ead28fcc5a When receiving an <img/> without the "alt" attribute, set
Marcus Lundblad <ml@update.uu.se>
parents: 24061
diff changeset
442 out = g_string_append(out, src);
24058
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
443 }
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
444 pos += pos2 - pos;
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
445 } else {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
446 out = g_string_append_c(out, markup[pos]);
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
447 pos++;
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
448 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
449
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
450 xmlnode_free(img);
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
451
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
452 } else {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
453 out = g_string_append_c(out, markup[pos]);
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
454 pos++;
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
455 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
456 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
457
24180
14915e96311e Another memory leak fix. Also, keep a copy of the alt-text in
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24179
diff changeset
458 g_free(markup);
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
459 return g_string_free(out, FALSE);
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
460 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
461
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
462 static void
29633
1bde873d1b94 jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents: 29630
diff changeset
463 jabber_message_add_remote_smileys(JabberStream *js, const gchar *who,
1bde873d1b94 jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents: 29630
diff changeset
464 const xmlnode *message)
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
465 {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
466 xmlnode *data_tag;
28645
7b4ade7c6d8a jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <paul@darkrain42.org>
parents: 28517
diff changeset
467 for (data_tag = xmlnode_get_child_with_namespace(message, "data", NS_BOB) ;
24058
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
468 data_tag ;
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
469 data_tag = xmlnode_get_next_twin(data_tag)) {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
470 const gchar *cid = xmlnode_get_attrib(data_tag, "cid");
29633
1bde873d1b94 jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents: 29630
diff changeset
471 const JabberData *data = jabber_data_find_remote_by_cid(js, who, cid);
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
472
24058
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
473 if (!data && cid != NULL) {
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
474 /* we haven't cached this already, let's add it */
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
475 JabberData *new_data = jabber_data_create_from_xml(data_tag);
29630
9f59abd49def jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <ml@update.uu.se>
parents: 29626
diff changeset
476
9f59abd49def jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <ml@update.uu.se>
parents: 29626
diff changeset
477 if (new_data) {
29633
1bde873d1b94 jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents: 29630
diff changeset
478 jabber_data_associate_remote(js, who, new_data);
29630
9f59abd49def jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <ml@update.uu.se>
parents: 29626
diff changeset
479 }
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
480 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
481 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
482 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
483
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
484 static void
29626
fce17268c9ec jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents: 29552
diff changeset
485 jabber_message_request_data_cb(JabberData *data, gchar *alt,
fce17268c9ec jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents: 29552
diff changeset
486 gpointer userdata)
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
487 {
29626
fce17268c9ec jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents: 29552
diff changeset
488 PurpleConversation *conv = (PurpleConversation *) userdata;
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
489
29626
fce17268c9ec jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents: 29552
diff changeset
490 if (data) {
fce17268c9ec jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents: 29552
diff changeset
491 purple_conv_custom_smiley_write(conv, alt,
fce17268c9ec jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents: 29552
diff changeset
492 jabber_data_get_data(data),
fce17268c9ec jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents: 29552
diff changeset
493 jabber_data_get_size(data));
fce17268c9ec jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents: 29552
diff changeset
494 purple_conv_custom_smiley_close(conv, alt);
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
495 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
496
29626
fce17268c9ec jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents: 29552
diff changeset
497 g_free(alt);
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
498 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
499
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
500 void jabber_message_parse(JabberStream *js, xmlnode *packet)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
501 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
502 JabberMessage *jm;
26870
92565c8e1e3a 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 <paul@darkrain42.org>
parents: 26838
diff changeset
503 const char *id, *from, *to, *type;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
504 xmlnode *child;
26870
92565c8e1e3a 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 <paul@darkrain42.org>
parents: 26838
diff changeset
505 gboolean signal_return;
92565c8e1e3a 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 <paul@darkrain42.org>
parents: 26838
diff changeset
506
92565c8e1e3a 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 <paul@darkrain42.org>
parents: 26838
diff changeset
507 from = xmlnode_get_attrib(packet, "from");
92565c8e1e3a 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 <paul@darkrain42.org>
parents: 26838
diff changeset
508 id = xmlnode_get_attrib(packet, "id");
92565c8e1e3a 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 <paul@darkrain42.org>
parents: 26838
diff changeset
509 to = xmlnode_get_attrib(packet, "to");
92565c8e1e3a 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 <paul@darkrain42.org>
parents: 26838
diff changeset
510 type = xmlnode_get_attrib(packet, "type");
92565c8e1e3a 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 <paul@darkrain42.org>
parents: 26838
diff changeset
511
28517
96ba7fd24177 jabber: Use purple_connection_get_prpl() instead of jabber_plugin.
Paul Aurich <paul@darkrain42.org>
parents: 28513
diff changeset
512 signal_return = GPOINTER_TO_INT(purple_signal_emit_return_1(purple_connection_get_prpl(js->gc),
26870
92565c8e1e3a 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 <paul@darkrain42.org>
parents: 26838
diff changeset
513 "jabber-receiving-message", js->gc, type, id, from, to, packet));
92565c8e1e3a 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 <paul@darkrain42.org>
parents: 26838
diff changeset
514 if (signal_return)
92565c8e1e3a 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 <paul@darkrain42.org>
parents: 26838
diff changeset
515 return;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
516
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
517 jm = g_new0(JabberMessage, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
518 jm->js = js;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
519 jm->sent = time(NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
520 jm->delayed = FALSE;
27101
ad04d94e6ddf Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <paul@darkrain42.org>
parents: 27019
diff changeset
521 jm->chat_state = JM_STATE_NONE;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
522
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
523 if(type) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
524 if(!strcmp(type, "normal"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
525 jm->type = JABBER_MESSAGE_NORMAL;
20058
5103485b4b26 Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19718
diff changeset
526 else if(!strcmp(type, "chat"))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
527 jm->type = JABBER_MESSAGE_CHAT;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
528 else if(!strcmp(type, "groupchat"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
529 jm->type = JABBER_MESSAGE_GROUPCHAT;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
530 else if(!strcmp(type, "headline"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
531 jm->type = JABBER_MESSAGE_HEADLINE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
532 else if(!strcmp(type, "error"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
533 jm->type = JABBER_MESSAGE_ERROR;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
534 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
535 jm->type = JABBER_MESSAGE_OTHER;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
536 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
537 jm->type = JABBER_MESSAGE_NORMAL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
538 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
539
26870
92565c8e1e3a 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 <paul@darkrain42.org>
parents: 26838
diff changeset
540 jm->from = g_strdup(from);
92565c8e1e3a 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 <paul@darkrain42.org>
parents: 26838
diff changeset
541 jm->to = g_strdup(to);
92565c8e1e3a 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 <paul@darkrain42.org>
parents: 26838
diff changeset
542 jm->id = g_strdup(id);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
543
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
544 for(child = packet->child; child; child = child->next) {
17845
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17842
diff changeset
545 const char *xmlns = xmlnode_get_namespace(child);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
546 if(child->type != XMLNODE_TYPE_TAG)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
547 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
548
24721
bba38f03085d Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24538
diff changeset
549 if(!strcmp(child->name, "error")) {
bba38f03085d Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24538
diff changeset
550 const char *code = xmlnode_get_attrib(child, "code");
bba38f03085d Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24538
diff changeset
551 char *code_txt = NULL;
bba38f03085d Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24538
diff changeset
552 char *text = xmlnode_get_data(child);
bba38f03085d Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24538
diff changeset
553 if (!text) {
bba38f03085d Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24538
diff changeset
554 xmlnode *enclosed_text_node;
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25716
diff changeset
555
24721
bba38f03085d Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24538
diff changeset
556 if ((enclosed_text_node = xmlnode_get_child(child, "text")))
bba38f03085d Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24538
diff changeset
557 text = xmlnode_get_data(enclosed_text_node);
bba38f03085d Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24538
diff changeset
558 }
bba38f03085d Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24538
diff changeset
559
bba38f03085d Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24538
diff changeset
560 if(code)
bba38f03085d Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24538
diff changeset
561 code_txt = g_strdup_printf(_("(Code %s)"), code);
bba38f03085d Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24538
diff changeset
562
bba38f03085d Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24538
diff changeset
563 if(!jm->error)
bba38f03085d Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24538
diff changeset
564 jm->error = g_strdup_printf("%s%s%s",
bba38f03085d Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24538
diff changeset
565 text ? text : "",
bba38f03085d Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24538
diff changeset
566 text && code_txt ? " " : "",
bba38f03085d Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24538
diff changeset
567 code_txt ? code_txt : "");
bba38f03085d Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24538
diff changeset
568
bba38f03085d Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24538
diff changeset
569 g_free(code_txt);
bba38f03085d Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24538
diff changeset
570 g_free(text);
bba38f03085d Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24538
diff changeset
571 } else if (xmlns == NULL) {
bba38f03085d Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24538
diff changeset
572 /* QuLogic: Not certain this is correct, but it would have happened
bba38f03085d Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24538
diff changeset
573 with the previous code. */
bba38f03085d Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24538
diff changeset
574 if(!strcmp(child->name, "x"))
bba38f03085d Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24538
diff changeset
575 jm->etc = g_list_append(jm->etc, child);
bba38f03085d Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24538
diff changeset
576 /* The following tests expect xmlns != NULL */
bba38f03085d Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24538
diff changeset
577 continue;
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28645
diff changeset
578 } else if(!strcmp(child->name, "subject") && !strcmp(xmlns, NS_XMPP_CLIENT)) {
26684
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26617
diff changeset
579 if(!jm->subject) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
580 jm->subject = xmlnode_get_data(child);
26684
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26617
diff changeset
581 if(!jm->subject)
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26617
diff changeset
582 jm->subject = g_strdup("");
06da00c70eae Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <paul@darkrain42.org>
parents: 26617
diff changeset
583 }
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28645
diff changeset
584 } else if(!strcmp(child->name, "thread") && !strcmp(xmlns, NS_XMPP_CLIENT)) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
585 if(!jm->thread_id)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
586 jm->thread_id = xmlnode_get_data(child);
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28645
diff changeset
587 } else if(!strcmp(child->name, "body") && !strcmp(xmlns, NS_XMPP_CLIENT)) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
588 if(!jm->body) {
30315
c492cef26b88 jabber: Only take the character data from a <body/> element (non-XHTML)
Paul Aurich <paul@darkrain42.org>
parents: 30201
diff changeset
589 char *msg = xmlnode_get_data(child);
30316
66c175a474a6 jabber: Fix the last commit to pass escaped text off to the core.
Paul Aurich <paul@darkrain42.org>
parents: 30315
diff changeset
590 char *escaped = purple_markup_escape_text(msg, -1);
66c175a474a6 jabber: Fix the last commit to pass escaped text off to the core.
Paul Aurich <paul@darkrain42.org>
parents: 30315
diff changeset
591 jm->body = purple_strdup_withhtml(escaped);
66c175a474a6 jabber: Fix the last commit to pass escaped text off to the core.
Paul Aurich <paul@darkrain42.org>
parents: 30315
diff changeset
592 g_free(escaped);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
593 g_free(msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
594 }
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28645
diff changeset
595 } else if(!strcmp(child->name, "html") && !strcmp(xmlns, NS_XHTML_IM)) {
17236
77b15be2179f Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@gmail.com>
parents: 16904
diff changeset
596 if(!jm->xhtml && xmlnode_get_child(child, "body")) {
77b15be2179f Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@gmail.com>
parents: 16904
diff changeset
597 char *c;
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
598
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
599 const PurpleConnection *gc = js->gc;
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
600 PurpleAccount *account = purple_connection_get_account(gc);
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
601 PurpleConversation *conv = NULL;
24179
2c6c9d72f54f A couple of compile warning fixes, a couple of memory leak plugs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24063
diff changeset
602 GList *smiley_refs = NULL;
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
603 gchar *reformatted_xhtml;
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
604
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
605 if (purple_account_get_bool(account, "custom_smileys", TRUE)) {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
606 /* find a list of smileys ("cid" and "alt" text pairs)
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
607 occuring in the message */
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
608 smiley_refs = jabber_message_get_refs_from_xmlnode(child);
24058
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
609 purple_debug_info("jabber", "found %d smileys\n",
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
610 g_list_length(smiley_refs));
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25716
diff changeset
611
26932
a8537bbcfb79 Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents: 26899
diff changeset
612 if (smiley_refs) {
26617
cb6dd7ee9df3 Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <ml@update.uu.se>
parents: 26465
diff changeset
613 if (jm->type == JABBER_MESSAGE_GROUPCHAT) {
cb6dd7ee9df3 Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <ml@update.uu.se>
parents: 26465
diff changeset
614 JabberID *jid = jabber_id_new(jm->from);
cb6dd7ee9df3 Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <ml@update.uu.se>
parents: 26465
diff changeset
615 JabberChat *chat = NULL;
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
616
26617
cb6dd7ee9df3 Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <ml@update.uu.se>
parents: 26465
diff changeset
617 if (jid) {
cb6dd7ee9df3 Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <ml@update.uu.se>
parents: 26465
diff changeset
618 chat = jabber_chat_find(js, jid->node, jid->domain);
27530
459e17946686 Break the 'if' onto two lines and don't bother calling jabber_id_free()
Mark Doliner <mark@kingant.net>
parents: 27512
diff changeset
619 if (chat)
459e17946686 Break the 'if' onto two lines and don't bother calling jabber_id_free()
Mark Doliner <mark@kingant.net>
parents: 27512
diff changeset
620 conv = chat->conv;
459e17946686 Break the 'if' onto two lines and don't bother calling jabber_id_free()
Mark Doliner <mark@kingant.net>
parents: 27512
diff changeset
621 jabber_id_free(jid);
26617
cb6dd7ee9df3 Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <ml@update.uu.se>
parents: 26465
diff changeset
622 }
26690
0054bf136314 Only look for and add custom smileys to incoming messages that are going to
Paul Aurich <paul@darkrain42.org>
parents: 26684
diff changeset
623 } else if (jm->type == JABBER_MESSAGE_NORMAL ||
0054bf136314 Only look for and add custom smileys to incoming messages that are going to
Paul Aurich <paul@darkrain42.org>
parents: 26684
diff changeset
624 jm->type == JABBER_MESSAGE_CHAT) {
26617
cb6dd7ee9df3 Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <ml@update.uu.se>
parents: 26465
diff changeset
625 conv =
cb6dd7ee9df3 Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <ml@update.uu.se>
parents: 26465
diff changeset
626 purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY,
27511
5d82a9298ed5 Remove a superfluous variable.
Paul Aurich <paul@darkrain42.org>
parents: 27510
diff changeset
627 from, account);
26617
cb6dd7ee9df3 Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <ml@update.uu.se>
parents: 26465
diff changeset
628 if (!conv) {
cb6dd7ee9df3 Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <ml@update.uu.se>
parents: 26465
diff changeset
629 /* we need to create the conversation here */
26932
a8537bbcfb79 Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents: 26899
diff changeset
630 conv =
26617
cb6dd7ee9df3 Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <ml@update.uu.se>
parents: 26465
diff changeset
631 purple_conversation_new(PURPLE_CONV_TYPE_IM,
27511
5d82a9298ed5 Remove a superfluous variable.
Paul Aurich <paul@darkrain42.org>
parents: 27510
diff changeset
632 account, from);
26617
cb6dd7ee9df3 Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <ml@update.uu.se>
parents: 26465
diff changeset
633 }
24061
fba7c73c8f02 Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <ml@update.uu.se>
parents: 24058
diff changeset
634 }
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
635 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
636
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
637 /* process any newly provided smileys */
29633
1bde873d1b94 jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents: 29630
diff changeset
638 jabber_message_add_remote_smileys(js, to, packet);
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
639 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
640
32039
afdbf45fa861 jabber: Strip element prefixes on XHTML-IM content.
Paul Aurich <paul@darkrain42.org>
parents: 31995
diff changeset
641 xmlnode_strip_prefixes(child);
afdbf45fa861 jabber: Strip element prefixes on XHTML-IM content.
Paul Aurich <paul@darkrain42.org>
parents: 31995
diff changeset
642
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
643 /* reformat xhtml so that img tags with a "cid:" src gets
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
644 translated to the bare text of the emoticon (the "alt" attrib) */
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
645 /* this is done also when custom smiley retrieval is turned off,
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
646 this way the receiver always sees the shortcut instead */
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
647 reformatted_xhtml =
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
648 jabber_message_xml_to_string_strip_img_smileys(child);
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
649
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
650 jm->xhtml = reformatted_xhtml;
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
651
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
652 /* add known custom emoticons to the conversation */
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
653 /* note: if there were no smileys in the incoming message, or
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
654 if receiving custom smileys is turned off, smiley_refs will
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
655 be NULL */
24448
71c42ce1a1df I got a crash happened at dereferencing chat when it's NULL, I think this
Ka-Hing Cheung <khc@hxbc.us>
parents: 24180
diff changeset
656 for (; conv && smiley_refs ; smiley_refs = g_list_delete_link(smiley_refs, smiley_refs)) {
24180
14915e96311e Another memory leak fix. Also, keep a copy of the alt-text in
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24179
diff changeset
657 JabberSmileyRef *ref = (JabberSmileyRef *) smiley_refs->data;
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
658 const gchar *cid = ref->cid;
29626
fce17268c9ec jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents: 29552
diff changeset
659 gchar *alt = g_strdup(ref->alt);
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
660
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25716
diff changeset
661 purple_debug_info("jabber",
24061
fba7c73c8f02 Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <ml@update.uu.se>
parents: 24058
diff changeset
662 "about to add custom smiley %s to the conv\n", alt);
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
663 if (purple_conv_custom_smiley_add(conv, alt, "cid", cid,
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
664 TRUE)) {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
665 const JabberData *data =
29633
1bde873d1b94 jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents: 29630
diff changeset
666 jabber_data_find_remote_by_cid(js, from, cid);
26617
cb6dd7ee9df3 Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <ml@update.uu.se>
parents: 26465
diff changeset
667 /* if data is already known, we write it immediatly */
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
668 if (data) {
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25716
diff changeset
669 purple_debug_info("jabber",
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25716
diff changeset
670 "data is already known\n");
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
671 purple_conv_custom_smiley_write(conv, alt,
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
672 jabber_data_get_data(data),
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
673 jabber_data_get_size(data));
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
674 purple_conv_custom_smiley_close(conv, alt);
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
675 } else {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
676 /* we need to request the smiley (data) */
24061
fba7c73c8f02 Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <ml@update.uu.se>
parents: 24058
diff changeset
677 purple_debug_info("jabber",
fba7c73c8f02 Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <ml@update.uu.se>
parents: 24058
diff changeset
678 "data is unknown, need to request it\n");
29626
fce17268c9ec jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents: 29552
diff changeset
679 jabber_data_request(js, cid, from, alt, FALSE,
fce17268c9ec jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents: 29552
diff changeset
680 jabber_message_request_data_cb, conv);
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
681 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
682 }
24180
14915e96311e Another memory leak fix. Also, keep a copy of the alt-text in
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24179
diff changeset
683 g_free(ref->cid);
14915e96311e Another memory leak fix. Also, keep a copy of the alt-text in
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24179
diff changeset
684 g_free(ref->alt);
14915e96311e Another memory leak fix. Also, keep a copy of the alt-text in
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24179
diff changeset
685 g_free(ref);
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
686 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
687
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
688 /* Convert all newlines to whitespace. Technically, even regular, non-XML HTML is supposed to ignore newlines, but Pidgin has, as convention
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
689 * treated \n as a newline for compatibility with other protocols
17236
77b15be2179f Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@gmail.com>
parents: 16904
diff changeset
690 */
77b15be2179f Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@gmail.com>
parents: 16904
diff changeset
691 for (c = jm->xhtml; *c != '\0'; c++) {
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
692 if (*c == '\n')
17236
77b15be2179f Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@gmail.com>
parents: 16904
diff changeset
693 *c = ' ';
77b15be2179f Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@gmail.com>
parents: 16904
diff changeset
694 }
77b15be2179f Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@gmail.com>
parents: 16904
diff changeset
695 }
17834
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents: 17258
diff changeset
696 } else if(!strcmp(child->name, "active") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
697 jm->chat_state = JM_STATE_ACTIVE;
17834
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents: 17258
diff changeset
698 } else if(!strcmp(child->name, "composing") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
699 jm->chat_state = JM_STATE_COMPOSING;
17834
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents: 17258
diff changeset
700 } else if(!strcmp(child->name, "paused") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
701 jm->chat_state = JM_STATE_PAUSED;
17834
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents: 17258
diff changeset
702 } else if(!strcmp(child->name, "inactive") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
703 jm->chat_state = JM_STATE_INACTIVE;
17834
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents: 17258
diff changeset
704 } else if(!strcmp(child->name, "gone") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
705 jm->chat_state = JM_STATE_GONE;
17840
cac26c30047a 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 <pidgin@monitzer.com>
parents: 17834
diff changeset
706 } else if(!strcmp(child->name, "event") && !strcmp(xmlns,"http://jabber.org/protocol/pubsub#event")) {
17845
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17842
diff changeset
707 xmlnode *items;
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17842
diff changeset
708 jm->type = JABBER_MESSAGE_EVENT;
17846
2f067d8fb19a Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17845
diff changeset
709 for(items = xmlnode_get_child(child,"items"); items; items = items->next)
17845
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17842
diff changeset
710 jm->eventitems = g_list_append(jm->eventitems, items);
28645
7b4ade7c6d8a jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <paul@darkrain42.org>
parents: 28517
diff changeset
711 } else if(!strcmp(child->name, "attention") && !strcmp(xmlns, NS_ATTENTION)) {
17888
cca457b9158b disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents: 17887
diff changeset
712 jm->hasBuzz = TRUE;
28663
5b449584fead jabber: Delayed Delivery namespaces
Paul Aurich <paul@darkrain42.org>
parents: 28650
diff changeset
713 } else if(!strcmp(child->name, "delay") && !strcmp(xmlns, NS_DELAYED_DELIVERY)) {
17877
34411cc535de Implemented XEP-0203: Delayed Delivery
Andreas Monitzer <pidgin@monitzer.com>
parents: 17858
diff changeset
714 const char *timestamp = xmlnode_get_attrib(child, "stamp");
34411cc535de Implemented XEP-0203: Delayed Delivery
Andreas Monitzer <pidgin@monitzer.com>
parents: 17858
diff changeset
715 jm->delayed = TRUE;
34411cc535de Implemented XEP-0203: Delayed Delivery
Andreas Monitzer <pidgin@monitzer.com>
parents: 17858
diff changeset
716 if(timestamp)
34411cc535de Implemented XEP-0203: Delayed Delivery
Andreas Monitzer <pidgin@monitzer.com>
parents: 17858
diff changeset
717 jm->sent = purple_str_to_time(timestamp, TRUE, NULL, NULL, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
718 } else if(!strcmp(child->name, "x")) {
28663
5b449584fead jabber: Delayed Delivery namespaces
Paul Aurich <paul@darkrain42.org>
parents: 28650
diff changeset
719 if(!strcmp(xmlns, NS_DELAYED_DELIVERY_LEGACY)) {
27104
048bcf41deef disapproval of revision 'a383ad6a4ae7e98bbcb32b4193531ccf960eb2bb'
Paul Aurich <paul@darkrain42.org>
parents: 27103
diff changeset
720 const char *timestamp = xmlnode_get_attrib(child, "stamp");
048bcf41deef disapproval of revision 'a383ad6a4ae7e98bbcb32b4193531ccf960eb2bb'
Paul Aurich <paul@darkrain42.org>
parents: 27103
diff changeset
721 jm->delayed = TRUE;
048bcf41deef disapproval of revision 'a383ad6a4ae7e98bbcb32b4193531ccf960eb2bb'
Paul Aurich <paul@darkrain42.org>
parents: 27103
diff changeset
722 if(timestamp)
048bcf41deef disapproval of revision 'a383ad6a4ae7e98bbcb32b4193531ccf960eb2bb'
Paul Aurich <paul@darkrain42.org>
parents: 27103
diff changeset
723 jm->sent = purple_str_to_time(timestamp, TRUE, NULL, NULL, NULL);
048bcf41deef disapproval of revision 'a383ad6a4ae7e98bbcb32b4193531ccf960eb2bb'
Paul Aurich <paul@darkrain42.org>
parents: 27103
diff changeset
724 } else if(!strcmp(xmlns, "jabber:x:conference") &&
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
725 jm->type != JABBER_MESSAGE_GROUPCHAT_INVITE &&
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
726 jm->type != JABBER_MESSAGE_ERROR) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
727 const char *jid = xmlnode_get_attrib(child, "jid");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
728 if(jid) {
28404
41992511531f jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <paul@darkrain42.org>
parents: 28251
diff changeset
729 const char *reason = xmlnode_get_attrib(child, "reason");
41992511531f jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <paul@darkrain42.org>
parents: 28251
diff changeset
730 const char *password = xmlnode_get_attrib(child, "password");
41992511531f jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <paul@darkrain42.org>
parents: 28251
diff changeset
731
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
732 jm->type = JABBER_MESSAGE_GROUPCHAT_INVITE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
733 g_free(jm->to);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
734 jm->to = g_strdup(jid);
28404
41992511531f jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <paul@darkrain42.org>
parents: 28251
diff changeset
735
41992511531f jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <paul@darkrain42.org>
parents: 28251
diff changeset
736 if (reason) {
41992511531f jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <paul@darkrain42.org>
parents: 28251
diff changeset
737 g_free(jm->body);
41992511531f jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <paul@darkrain42.org>
parents: 28251
diff changeset
738 jm->body = g_strdup(reason);
41992511531f jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <paul@darkrain42.org>
parents: 28251
diff changeset
739 }
41992511531f jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <paul@darkrain42.org>
parents: 28251
diff changeset
740
41992511531f jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <paul@darkrain42.org>
parents: 28251
diff changeset
741 if (password) {
41992511531f jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <paul@darkrain42.org>
parents: 28251
diff changeset
742 g_free(jm->password);
41992511531f jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <paul@darkrain42.org>
parents: 28251
diff changeset
743 jm->password = g_strdup(password);
41992511531f jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <paul@darkrain42.org>
parents: 28251
diff changeset
744 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
745 }
24721
bba38f03085d Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24538
diff changeset
746 } else if(!strcmp(xmlns, "http://jabber.org/protocol/muc#user") &&
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
747 jm->type != JABBER_MESSAGE_ERROR) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
748 xmlnode *invite = xmlnode_get_child(child, "invite");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
749 if(invite) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
750 xmlnode *reason, *password;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
751 const char *jid = xmlnode_get_attrib(invite, "from");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
752 g_free(jm->to);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
753 jm->to = jm->from;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
754 jm->from = g_strdup(jid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
755 if((reason = xmlnode_get_child(invite, "reason"))) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
756 g_free(jm->body);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
757 jm->body = xmlnode_get_data(reason);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
758 }
28404
41992511531f jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <paul@darkrain42.org>
parents: 28251
diff changeset
759 if((password = xmlnode_get_child(child, "password"))) {
41992511531f jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <paul@darkrain42.org>
parents: 28251
diff changeset
760 g_free(jm->password);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
761 jm->password = xmlnode_get_data(password);
28404
41992511531f jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <paul@darkrain42.org>
parents: 28251
diff changeset
762 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
763
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
764 jm->type = JABBER_MESSAGE_GROUPCHAT_INVITE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
765 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
766 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
767 jm->etc = g_list_append(jm->etc, child);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
768 }
26694
83e6e710cbf3 Add a new signal which is emitted (after the account is connected) if the
Paul Aurich <paul@darkrain42.org>
parents: 26690
diff changeset
769 } else if (g_str_equal(child->name, "query")) {
83e6e710cbf3 Add a new signal which is emitted (after the account is connected) if the
Paul Aurich <paul@darkrain42.org>
parents: 26690
diff changeset
770 const char *node = xmlnode_get_attrib(child, "node");
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28645
diff changeset
771 if (purple_strequal(xmlns, NS_DISCO_ITEMS)
26694
83e6e710cbf3 Add a new signal which is emitted (after the account is connected) if the
Paul Aurich <paul@darkrain42.org>
parents: 26690
diff changeset
772 && purple_strequal(node, "http://jabber.org/protocol/commands")) {
83e6e710cbf3 Add a new signal which is emitted (after the account is connected) if the
Paul Aurich <paul@darkrain42.org>
parents: 26690
diff changeset
773 jabber_adhoc_got_list(js, jm->from, child);
83e6e710cbf3 Add a new signal which is emitted (after the account is connected) if the
Paul Aurich <paul@darkrain42.org>
parents: 26690
diff changeset
774 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
775 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
776 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
777
17888
cca457b9158b disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents: 17887
diff changeset
778 if(jm->hasBuzz)
cca457b9158b disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents: 17887
diff changeset
779 handle_buzz(jm);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
780
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
781 switch(jm->type) {
27637
cbf7072fb372 Allow fallback for broken XMPP <message/> types. Closes #7837.
Paul Aurich <paul@darkrain42.org>
parents: 27591
diff changeset
782 case JABBER_MESSAGE_OTHER:
28513
fa7f3426ed13 jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <paul@darkrain42.org>
parents: 28414
diff changeset
783 purple_debug_info("jabber",
27637
cbf7072fb372 Allow fallback for broken XMPP <message/> types. Closes #7837.
Paul Aurich <paul@darkrain42.org>
parents: 27591
diff changeset
784 "Received message of unknown type: %s\n", type);
cbf7072fb372 Allow fallback for broken XMPP <message/> types. Closes #7837.
Paul Aurich <paul@darkrain42.org>
parents: 27591
diff changeset
785 /* Fall-through is intentional */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
786 case JABBER_MESSAGE_NORMAL:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
787 case JABBER_MESSAGE_CHAT:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
788 handle_chat(jm);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
789 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
790 case JABBER_MESSAGE_HEADLINE:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
791 handle_headline(jm);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
792 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
793 case JABBER_MESSAGE_GROUPCHAT:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
794 handle_groupchat(jm);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
795 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
796 case JABBER_MESSAGE_GROUPCHAT_INVITE:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
797 handle_groupchat_invite(jm);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
798 break;
17845
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17842
diff changeset
799 case JABBER_MESSAGE_EVENT:
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17842
diff changeset
800 jabber_handle_event(jm);
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17842
diff changeset
801 break;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
802 case JABBER_MESSAGE_ERROR:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
803 handle_error(jm);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
804 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
805 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
806 jabber_message_free(jm);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
807 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
808
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
809 static const gchar *
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
810 jabber_message_get_mimetype_from_ext(const gchar *ext)
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
811 {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
812 if (strcmp(ext, "png") == 0) {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
813 return "image/png";
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
814 } else if (strcmp(ext, "gif") == 0) {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
815 return "image/gif";
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
816 } else if (strcmp(ext, "jpg") == 0) {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
817 return "image/jpeg";
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
818 } else if (strcmp(ext, "tif") == 0) {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
819 return "image/tif";
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
820 } else {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
821 return "image/x-icon"; /* or something... */
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
822 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
823 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
824
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
825 static GList *
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
826 jabber_message_xhtml_find_smileys(const char *xhtml)
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
827 {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
828 GList *smileys = purple_smileys_get_all();
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
829 GList *found_smileys = NULL;
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
830
23779
b2697ab66d23 Ooops ... compile\!
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23778
diff changeset
831 for (; smileys ; smileys = g_list_delete_link(smileys, smileys)) {
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
832 PurpleSmiley *smiley = (PurpleSmiley *) smileys->data;
28948
8271e42acdcb jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <ml@update.uu.se>
parents: 28909
diff changeset
833
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
834 const gchar *shortcut = purple_smiley_get_shortcut(smiley);
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
835 const gssize len = strlen(shortcut);
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
836
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
837 gchar *escaped = g_markup_escape_text(shortcut, len);
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
838 const char *pos = strstr(xhtml, escaped);
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
839
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
840 if (pos) {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
841 found_smileys = g_list_append(found_smileys, smiley);
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
842 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
843
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
844 g_free(escaped);
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
845 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
846
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
847 return found_smileys;
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
848 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
849
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
850 static gchar *
24058
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
851 jabber_message_get_smileyfied_xhtml(const gchar *xhtml, const GList *smileys)
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
852 {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
853 /* create XML element for all smileys (img tags) */
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
854 GString *result = g_string_new(NULL);
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
855 int pos = 0;
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
856 int length = strlen(xhtml);
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
857
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
858 while (pos < length) {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
859 const GList *iterator;
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
860 gboolean found_smiley = FALSE;
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
861
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
862 for (iterator = smileys ; iterator ;
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
863 iterator = g_list_next(iterator)) {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
864 const PurpleSmiley *smiley = (PurpleSmiley *) iterator->data;
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
865 const gchar *shortcut = purple_smiley_get_shortcut(smiley);
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
866 const gssize len = strlen(shortcut);
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
867 gchar *escaped = g_markup_escape_text(shortcut, len);
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
868
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
869 if (g_str_has_prefix(&(xhtml[pos]), escaped)) {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
870 /* we found the current smiley at this position */
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
871 const JabberData *data =
24058
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
872 jabber_data_find_local_by_alt(shortcut);
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
873 xmlnode *img = jabber_data_get_xhtml_im(data, shortcut);
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
874 int len;
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
875 gchar *img_text = xmlnode_to_str(img, &len);
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
876
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
877 found_smiley = TRUE;
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
878 result = g_string_append(result, img_text);
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
879 g_free(img_text);
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
880 pos += strlen(escaped);
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
881 g_free(escaped);
24179
2c6c9d72f54f A couple of compile warning fixes, a couple of memory leak plugs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24063
diff changeset
882 xmlnode_free(img);
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
883 break;
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
884 } else {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
885 /* cleanup from the before the next round... */
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
886 g_free(escaped);
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
887 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
888 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
889 if (!found_smiley) {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
890 /* there was no smiley here, just copy one byte */
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
891 result = g_string_append_c(result, xhtml[pos]);
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
892 pos++;
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
893 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
894 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
895
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
896 return g_string_free(result, FALSE);
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
897 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
898
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
899 static gboolean
29043
97974856c920 jabber: Simplify.
Paul Aurich <paul@darkrain42.org>
parents: 29016
diff changeset
900 jabber_conv_support_custom_smileys(JabberStream *js,
26874
eeee4309d3d8 Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents: 26870
diff changeset
901 PurpleConversation *conv,
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
902 const gchar *who)
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
903 {
24058
305fac6af8f9 Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents: 23779
diff changeset
904 JabberBuddy *jb;
26874
eeee4309d3d8 Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents: 26870
diff changeset
905 JabberChat *chat;
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25716
diff changeset
906
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
907 switch (purple_conversation_get_type(conv)) {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
908 case PURPLE_CONV_TYPE_IM:
24527
1b61f62e5240 Removed som extranious debug output
Marcus Lundblad <ml@update.uu.se>
parents: 24451
diff changeset
909 jb = jabber_buddy_find(js, who, FALSE);
1b61f62e5240 Removed som extranious debug output
Marcus Lundblad <ml@update.uu.se>
parents: 24451
diff changeset
910 if (jb) {
28645
7b4ade7c6d8a jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <paul@darkrain42.org>
parents: 28517
diff changeset
911 return jabber_buddy_has_capability(jb, NS_BOB);
24527
1b61f62e5240 Removed som extranious debug output
Marcus Lundblad <ml@update.uu.se>
parents: 24451
diff changeset
912 } else {
24538
f48bfb88c7cb Whoops, should return FALSE, not NULL, when jabber_buddy_find returns NULL
Marcus Lundblad <ml@update.uu.se>
parents: 24527
diff changeset
913 return FALSE;
24527
1b61f62e5240 Removed som extranious debug output
Marcus Lundblad <ml@update.uu.se>
parents: 24451
diff changeset
914 }
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
915 break;
26874
eeee4309d3d8 Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents: 26870
diff changeset
916 case PURPLE_CONV_TYPE_CHAT:
eeee4309d3d8 Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents: 26870
diff changeset
917 chat = jabber_chat_find_by_conv(conv);
eeee4309d3d8 Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents: 26870
diff changeset
918 if (chat) {
eeee4309d3d8 Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents: 26870
diff changeset
919 /* do not attempt to send custom smileys in a MUC with more than
eeee4309d3d8 Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents: 26870
diff changeset
920 10 people, to avoid getting too many BoB requests */
eeee4309d3d8 Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents: 26870
diff changeset
921 return jabber_chat_get_num_participants(chat) <= 10 &&
26932
a8537bbcfb79 Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents: 26899
diff changeset
922 jabber_chat_all_participants_have_capability(chat,
28645
7b4ade7c6d8a jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <paul@darkrain42.org>
parents: 28517
diff changeset
923 NS_BOB);
26874
eeee4309d3d8 Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents: 26870
diff changeset
924 } else {
eeee4309d3d8 Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents: 26870
diff changeset
925 return FALSE;
eeee4309d3d8 Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents: 26870
diff changeset
926 }
eeee4309d3d8 Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents: 26870
diff changeset
927 break;
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
928 default:
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
929 return FALSE;
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
930 break;
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
931 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
932 }
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
933
26838
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
934 static char *
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
935 jabber_message_smileyfy_xhtml(JabberMessage *jm, const char *xhtml)
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
936 {
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
937 PurpleAccount *account = purple_connection_get_account(jm->js->gc);
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
938 PurpleConversation *conv =
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
939 purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, jm->to,
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
940 account);
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
941
29043
97974856c920 jabber: Simplify.
Paul Aurich <paul@darkrain42.org>
parents: 29016
diff changeset
942 if (jabber_conv_support_custom_smileys(jm->js, conv, jm->to)) {
26838
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
943 GList *found_smileys = jabber_message_xhtml_find_smileys(xhtml);
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
944
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
945 if (found_smileys) {
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
946 gchar *smileyfied_xhtml = NULL;
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
947 const GList *iterator;
28948
8271e42acdcb jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <ml@update.uu.se>
parents: 28909
diff changeset
948 GList *valid_smileys = NULL;
28953
bf0db10b0e3c jabber: Don't print the smiley shortcut in the error message when trying to
Marcus Lundblad <ml@update.uu.se>
parents: 28948
diff changeset
949 gboolean has_too_large_smiley = FALSE;
31086
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30476
diff changeset
950
26838
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
951 for (iterator = found_smileys; iterator ;
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
952 iterator = g_list_next(iterator)) {
28948
8271e42acdcb jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <ml@update.uu.se>
parents: 28909
diff changeset
953 PurpleSmiley *smiley = (PurpleSmiley *) iterator->data;
26838
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
954 const gchar *shortcut = purple_smiley_get_shortcut(smiley);
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
955 const JabberData *data =
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
956 jabber_data_find_local_by_alt(shortcut);
28948
8271e42acdcb jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <ml@update.uu.se>
parents: 28909
diff changeset
957 PurpleStoredImage *image = purple_smiley_get_stored_image(smiley);
26838
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
958
28948
8271e42acdcb jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <ml@update.uu.se>
parents: 28909
diff changeset
959 if (purple_imgstore_get_size(image) <= JABBER_DATA_MAX_SIZE) {
8271e42acdcb jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <ml@update.uu.se>
parents: 28909
diff changeset
960 /* the object has not been sent before */
8271e42acdcb jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <ml@update.uu.se>
parents: 28909
diff changeset
961 if (!data) {
8271e42acdcb jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <ml@update.uu.se>
parents: 28909
diff changeset
962 const gchar *ext = purple_imgstore_get_extension(image);
8271e42acdcb jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <ml@update.uu.se>
parents: 28909
diff changeset
963 JabberStream *js = jm->js;
26838
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
964
28948
8271e42acdcb jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <ml@update.uu.se>
parents: 28909
diff changeset
965 JabberData *new_data =
8271e42acdcb jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <ml@update.uu.se>
parents: 28909
diff changeset
966 jabber_data_create_from_data(purple_imgstore_get_data(image),
8271e42acdcb jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <ml@update.uu.se>
parents: 28909
diff changeset
967 purple_imgstore_get_size(image),
29813
221cebbc35d8 Make it compile again after merge
Marcus Lundblad <ml@update.uu.se>
parents: 29812
diff changeset
968 jabber_message_get_mimetype_from_ext(ext), FALSE, js);
28948
8271e42acdcb jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <ml@update.uu.se>
parents: 28909
diff changeset
969 purple_debug_info("jabber",
8271e42acdcb jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <ml@update.uu.se>
parents: 28909
diff changeset
970 "cache local smiley alt = %s, cid = %s\n",
8271e42acdcb jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <ml@update.uu.se>
parents: 28909
diff changeset
971 shortcut, jabber_data_get_cid(new_data));
8271e42acdcb jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <ml@update.uu.se>
parents: 28909
diff changeset
972 jabber_data_associate_local(new_data, shortcut);
8271e42acdcb jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <ml@update.uu.se>
parents: 28909
diff changeset
973 }
8271e42acdcb jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <ml@update.uu.se>
parents: 28909
diff changeset
974 valid_smileys = g_list_append(valid_smileys, smiley);
8271e42acdcb jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <ml@update.uu.se>
parents: 28909
diff changeset
975 } else {
28953
bf0db10b0e3c jabber: Don't print the smiley shortcut in the error message when trying to
Marcus Lundblad <ml@update.uu.se>
parents: 28948
diff changeset
976 has_too_large_smiley = TRUE;
28955
57550ffb7870 jabber: Log a warning (with the shortcut) when refusing to send a smiley.
Paul Aurich <paul@darkrain42.org>
parents: 28953
diff changeset
977 purple_debug_warning("jabber", "Refusing to send smiley %s "
57550ffb7870 jabber: Log a warning (with the shortcut) when refusing to send a smiley.
Paul Aurich <paul@darkrain42.org>
parents: 28953
diff changeset
978 "(too large, max is %d)\n",
57550ffb7870 jabber: Log a warning (with the shortcut) when refusing to send a smiley.
Paul Aurich <paul@darkrain42.org>
parents: 28953
diff changeset
979 purple_smiley_get_shortcut(smiley),
57550ffb7870 jabber: Log a warning (with the shortcut) when refusing to send a smiley.
Paul Aurich <paul@darkrain42.org>
parents: 28953
diff changeset
980 JABBER_DATA_MAX_SIZE);
31086
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30476
diff changeset
981 }
26838
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
982 }
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
983
28953
bf0db10b0e3c jabber: Don't print the smiley shortcut in the error message when trying to
Marcus Lundblad <ml@update.uu.se>
parents: 28948
diff changeset
984 if (has_too_large_smiley) {
bf0db10b0e3c jabber: Don't print the smiley shortcut in the error message when trying to
Marcus Lundblad <ml@update.uu.se>
parents: 28948
diff changeset
985 purple_conversation_write(conv, NULL,
bf0db10b0e3c jabber: Don't print the smiley shortcut in the error message when trying to
Marcus Lundblad <ml@update.uu.se>
parents: 28948
diff changeset
986 _("A custom smiley in the message is too large to send."),
bf0db10b0e3c jabber: Don't print the smiley shortcut in the error message when trying to
Marcus Lundblad <ml@update.uu.se>
parents: 28948
diff changeset
987 PURPLE_MESSAGE_ERROR, time(NULL));
bf0db10b0e3c jabber: Don't print the smiley shortcut in the error message when trying to
Marcus Lundblad <ml@update.uu.se>
parents: 28948
diff changeset
988 }
bf0db10b0e3c jabber: Don't print the smiley shortcut in the error message when trying to
Marcus Lundblad <ml@update.uu.se>
parents: 28948
diff changeset
989
26838
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
990 smileyfied_xhtml =
28948
8271e42acdcb jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <ml@update.uu.se>
parents: 28909
diff changeset
991 jabber_message_get_smileyfied_xhtml(xhtml, valid_smileys);
26838
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
992 g_list_free(found_smileys);
28948
8271e42acdcb jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <ml@update.uu.se>
parents: 28909
diff changeset
993 g_list_free(valid_smileys);
26838
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
994
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
995 return smileyfied_xhtml;
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
996 }
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
997 }
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
998
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
999 return NULL;
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1000 }
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1001
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1002 void jabber_message_send(JabberMessage *jm)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1003 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1004 xmlnode *message, *child;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1005 const char *type = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1006
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1007 message = xmlnode_new("message");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1008
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1009 switch(jm->type) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1010 case JABBER_MESSAGE_NORMAL:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1011 type = "normal";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1012 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1013 case JABBER_MESSAGE_CHAT:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1014 case JABBER_MESSAGE_GROUPCHAT_INVITE:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1015 type = "chat";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1016 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1017 case JABBER_MESSAGE_HEADLINE:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1018 type = "headline";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1019 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1020 case JABBER_MESSAGE_GROUPCHAT:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1021 type = "groupchat";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1022 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1023 case JABBER_MESSAGE_ERROR:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1024 type = "error";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1025 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1026 case JABBER_MESSAGE_OTHER:
17845
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17842
diff changeset
1027 default:
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1028 type = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1029 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1030 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1031
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1032 if(type)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1033 xmlnode_set_attrib(message, "type", type);
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25716
diff changeset
1034
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1035 if (jm->id)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1036 xmlnode_set_attrib(message, "id", jm->id);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1037
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1038 xmlnode_set_attrib(message, "to", jm->to);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1039
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1040 if(jm->thread_id) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1041 child = xmlnode_new_child(message, "thread");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1042 xmlnode_insert_data(child, jm->thread_id, -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1043 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1044
27105
ea9cbfcbfd19 --warnings
Paul Aurich <paul@darkrain42.org>
parents: 27103
diff changeset
1045 child = NULL;
ea9cbfcbfd19 --warnings
Paul Aurich <paul@darkrain42.org>
parents: 27103
diff changeset
1046 switch(jm->chat_state)
ea9cbfcbfd19 --warnings
Paul Aurich <paul@darkrain42.org>
parents: 27103
diff changeset
1047 {
ea9cbfcbfd19 --warnings
Paul Aurich <paul@darkrain42.org>
parents: 27103
diff changeset
1048 case JM_STATE_ACTIVE:
ea9cbfcbfd19 --warnings
Paul Aurich <paul@darkrain42.org>
parents: 27103
diff changeset
1049 child = xmlnode_new_child(message, "active");
ea9cbfcbfd19 --warnings
Paul Aurich <paul@darkrain42.org>
parents: 27103
diff changeset
1050 break;
ea9cbfcbfd19 --warnings
Paul Aurich <paul@darkrain42.org>
parents: 27103
diff changeset
1051 case JM_STATE_COMPOSING:
ea9cbfcbfd19 --warnings
Paul Aurich <paul@darkrain42.org>
parents: 27103
diff changeset
1052 child = xmlnode_new_child(message, "composing");
ea9cbfcbfd19 --warnings
Paul Aurich <paul@darkrain42.org>
parents: 27103
diff changeset
1053 break;
ea9cbfcbfd19 --warnings
Paul Aurich <paul@darkrain42.org>
parents: 27103
diff changeset
1054 case JM_STATE_PAUSED:
ea9cbfcbfd19 --warnings
Paul Aurich <paul@darkrain42.org>
parents: 27103
diff changeset
1055 child = xmlnode_new_child(message, "paused");
ea9cbfcbfd19 --warnings
Paul Aurich <paul@darkrain42.org>
parents: 27103
diff changeset
1056 break;
ea9cbfcbfd19 --warnings
Paul Aurich <paul@darkrain42.org>
parents: 27103
diff changeset
1057 case JM_STATE_INACTIVE:
ea9cbfcbfd19 --warnings
Paul Aurich <paul@darkrain42.org>
parents: 27103
diff changeset
1058 child = xmlnode_new_child(message, "inactive");
ea9cbfcbfd19 --warnings
Paul Aurich <paul@darkrain42.org>
parents: 27103
diff changeset
1059 break;
ea9cbfcbfd19 --warnings
Paul Aurich <paul@darkrain42.org>
parents: 27103
diff changeset
1060 case JM_STATE_GONE:
ea9cbfcbfd19 --warnings
Paul Aurich <paul@darkrain42.org>
parents: 27103
diff changeset
1061 child = xmlnode_new_child(message, "gone");
ea9cbfcbfd19 --warnings
Paul Aurich <paul@darkrain42.org>
parents: 27103
diff changeset
1062 break;
ea9cbfcbfd19 --warnings
Paul Aurich <paul@darkrain42.org>
parents: 27103
diff changeset
1063 case JM_STATE_NONE:
ea9cbfcbfd19 --warnings
Paul Aurich <paul@darkrain42.org>
parents: 27103
diff changeset
1064 /* yep, nothing */
ea9cbfcbfd19 --warnings
Paul Aurich <paul@darkrain42.org>
parents: 27103
diff changeset
1065 break;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1066 }
27105
ea9cbfcbfd19 --warnings
Paul Aurich <paul@darkrain42.org>
parents: 27103
diff changeset
1067 if(child)
ea9cbfcbfd19 --warnings
Paul Aurich <paul@darkrain42.org>
parents: 27103
diff changeset
1068 xmlnode_set_namespace(child, "http://jabber.org/protocol/chatstates");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1069
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1070 if(jm->subject) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1071 child = xmlnode_new_child(message, "subject");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1072 xmlnode_insert_data(child, jm->subject, -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1073 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1074
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1075 if(jm->body) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1076 child = xmlnode_new_child(message, "body");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1077 xmlnode_insert_data(child, jm->body, -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1078 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1079
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1080 if(jm->xhtml) {
26838
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1081 if ((child = xmlnode_from_str(jm->xhtml, -1))) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1082 xmlnode_insert_child(message, child);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1083 } else {
28513
fa7f3426ed13 jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <paul@darkrain42.org>
parents: 28414
diff changeset
1084 purple_debug_error("jabber",
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1085 "XHTML translation/validation failed, returning: %s\n",
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1086 jm->xhtml);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1087 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1088 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1089
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1090 jabber_send(jm->js, message);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1091
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1092 xmlnode_free(message);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1093 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1094
26838
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1095 /*
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1096 * Compare the XHTML and plain strings passed in for "equality". Any HTML markup
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1097 * other than <br/> (matches a newline) in the XHTML will cause this to return
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1098 * FALSE.
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1099 */
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1100 static gboolean
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1101 jabber_xhtml_plain_equal(const char *xhtml_escaped,
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1102 const char *plain)
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1103 {
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1104 int i = 0;
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1105 int j = 0;
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1106 gboolean ret;
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1107 char *xhtml = purple_unescape_html(xhtml_escaped);
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1108
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1109 while (xhtml[i] && plain[j]) {
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1110 if (xhtml[i] == plain[j]) {
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1111 i += 1;
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1112 j += 1;
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1113 continue;
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1114 }
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1115
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1116 if (plain[j] == '\n' && !strncmp(xhtml+i, "<br/>", 5)) {
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1117 i += 5;
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1118 j += 1;
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1119 continue;
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1120 }
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1121
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1122 g_free(xhtml);
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1123 return FALSE;
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1124 }
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1125
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1126 /* Are we at the end of both strings? */
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1127 ret = (xhtml[i] == plain[j]) && (xhtml[i] == '\0');
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1128 g_free(xhtml);
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1129 return ret;
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1130 }
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1131
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15659
diff changeset
1132 int jabber_message_send_im(PurpleConnection *gc, const char *who, const char *msg,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15659
diff changeset
1133 PurpleMessageFlags flags)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1134 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1135 JabberMessage *jm;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1136 JabberBuddy *jb;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1137 JabberBuddyResource *jbr;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1138 char *xhtml;
26838
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1139 char *tmp;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1140 char *resource;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1141
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1142 if(!who || !msg)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1143 return 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1144
31309
356adba49dae jabber: Verbose printing of the exact message passed in to jabber_message_send_im.
Paul Aurich <paul@darkrain42.org>
parents: 31086
diff changeset
1145 if (purple_debug_is_verbose()) {
356adba49dae jabber: Verbose printing of the exact message passed in to jabber_message_send_im.
Paul Aurich <paul@darkrain42.org>
parents: 31086
diff changeset
1146 /* TODO: Maybe we need purple_debug_is_really_verbose? :) */
356adba49dae jabber: Verbose printing of the exact message passed in to jabber_message_send_im.
Paul Aurich <paul@darkrain42.org>
parents: 31086
diff changeset
1147 purple_debug_misc("jabber", "jabber_message_send_im: who='%s'\n"
356adba49dae jabber: Verbose printing of the exact message passed in to jabber_message_send_im.
Paul Aurich <paul@darkrain42.org>
parents: 31086
diff changeset
1148 "\tmsg='%s'\n", who, msg);
356adba49dae jabber: Verbose printing of the exact message passed in to jabber_message_send_im.
Paul Aurich <paul@darkrain42.org>
parents: 31086
diff changeset
1149 }
356adba49dae jabber: Verbose printing of the exact message passed in to jabber_message_send_im.
Paul Aurich <paul@darkrain42.org>
parents: 31086
diff changeset
1150
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1151 resource = jabber_get_resource(who);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1152
31995
3caef255ad47 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
andrew.victor@mxit.com
parents: 31309
diff changeset
1153 jb = jabber_buddy_find(purple_connection_get_protocol_data(gc), who, TRUE);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1154 jbr = jabber_buddy_find_resource(jb, resource);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1155
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1156 g_free(resource);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1157
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1158 jm = g_new0(JabberMessage, 1);
31995
3caef255ad47 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
andrew.victor@mxit.com
parents: 31309
diff changeset
1159 jm->js = purple_connection_get_protocol_data(gc);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1160 jm->type = JABBER_MESSAGE_CHAT;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1161 jm->chat_state = JM_STATE_ACTIVE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1162 jm->to = g_strdup(who);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1163 jm->id = jabber_get_next_id(jm->js);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1164
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1165 if(jbr) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1166 if(jbr->thread_id)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1167 jm->thread_id = jbr->thread_id;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1168
27101
ad04d94e6ddf Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <paul@darkrain42.org>
parents: 27019
diff changeset
1169 if (jbr->chat_states == JABBER_CHAT_STATES_UNSUPPORTED)
ad04d94e6ddf Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <paul@darkrain42.org>
parents: 27019
diff changeset
1170 jm->chat_state = JM_STATE_NONE;
ad04d94e6ddf Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <paul@darkrain42.org>
parents: 27019
diff changeset
1171 else {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1172 /* if(JABBER_CHAT_STATES_UNKNOWN == jbr->chat_states)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1173 jbr->chat_states = JABBER_CHAT_STATES_UNSUPPORTED; */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1174 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1175 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1176
27019
bf9db4c67679 Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages.
Paul Aurich <paul@darkrain42.org>
parents: 26932
diff changeset
1177 tmp = purple_utf8_strip_unprintables(msg);
bf9db4c67679 Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages.
Paul Aurich <paul@darkrain42.org>
parents: 26932
diff changeset
1178 purple_markup_html_to_xhtml(tmp, &xhtml, &jm->body);
bf9db4c67679 Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages.
Paul Aurich <paul@darkrain42.org>
parents: 26932
diff changeset
1179 g_free(tmp);
28909
5bacbd78e2b4 jabber: Wrap XHTML-IM messages in <p/> for greater interoperability justice. Closes #11253
Paul Aurich <paul@darkrain42.org>
parents: 28663
diff changeset
1180
26838
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1181 tmp = jabber_message_smileyfy_xhtml(jm, xhtml);
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1182 if (tmp) {
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1183 g_free(xhtml);
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1184 xhtml = tmp;
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1185 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1186
27508
95c56191d26c For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <paul@darkrain42.org>
parents: 27019
diff changeset
1187 /*
95c56191d26c For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <paul@darkrain42.org>
parents: 27019
diff changeset
1188 * For backward compatibility with user expectations or for those not on
95c56191d26c For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <paul@darkrain42.org>
parents: 27019
diff changeset
1189 * the user's roster, allow sending XHTML-IM markup.
95c56191d26c For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <paul@darkrain42.org>
parents: 27019
diff changeset
1190 */
95c56191d26c For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <paul@darkrain42.org>
parents: 27019
diff changeset
1191 if (!jbr || !jbr->caps.info ||
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28645
diff changeset
1192 jabber_resource_has_capability(jbr, NS_XHTML_IM)) {
27508
95c56191d26c For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <paul@darkrain42.org>
parents: 27019
diff changeset
1193 if (!jabber_xhtml_plain_equal(xhtml, jm->body))
28909
5bacbd78e2b4 jabber: Wrap XHTML-IM messages in <p/> for greater interoperability justice. Closes #11253
Paul Aurich <paul@darkrain42.org>
parents: 28663
diff changeset
1194 /* Wrap the message in <p/> for great interoperability justice. */
5bacbd78e2b4 jabber: Wrap XHTML-IM messages in <p/> for greater interoperability justice. Closes #11253
Paul Aurich <paul@darkrain42.org>
parents: 28663
diff changeset
1195 jm->xhtml = g_strdup_printf("<html xmlns='" NS_XHTML_IM "'><body xmlns='" NS_XHTML "'><p>%s</p></body></html>", xhtml);
27508
95c56191d26c For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <paul@darkrain42.org>
parents: 27019
diff changeset
1196 }
26838
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1197
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1198 g_free(xhtml);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1199
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1200 jabber_message_send(jm);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1201 jabber_message_free(jm);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1202 return 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1203 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1204
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15659
diff changeset
1205 int jabber_message_send_chat(PurpleConnection *gc, int id, const char *msg, PurpleMessageFlags flags)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1206 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1207 JabberChat *chat;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1208 JabberMessage *jm;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1209 JabberStream *js;
26838
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1210 char *xhtml;
26874
eeee4309d3d8 Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents: 26870
diff changeset
1211 char *tmp;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1212
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1213 if(!msg || !gc)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1214 return 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1215
31995
3caef255ad47 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
andrew.victor@mxit.com
parents: 31309
diff changeset
1216 js = purple_connection_get_protocol_data(gc);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1217 chat = jabber_chat_find_by_id(js, id);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1218
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1219 if(!chat)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1220 return 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1221
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1222 jm = g_new0(JabberMessage, 1);
31995
3caef255ad47 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
andrew.victor@mxit.com
parents: 31309
diff changeset
1223 jm->js = purple_connection_get_protocol_data(gc);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1224 jm->type = JABBER_MESSAGE_GROUPCHAT;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1225 jm->to = g_strdup_printf("%s@%s", chat->room, chat->server);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1226 jm->id = jabber_get_next_id(jm->js);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1227
27019
bf9db4c67679 Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages.
Paul Aurich <paul@darkrain42.org>
parents: 26932
diff changeset
1228 tmp = purple_utf8_strip_unprintables(msg);
28251
e8717ca47d25 Oops, it helps to actually use the stripped message.
Paul Aurich <paul@darkrain42.org>
parents: 28156
diff changeset
1229 purple_markup_html_to_xhtml(tmp, &xhtml, &jm->body);
27019
bf9db4c67679 Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages.
Paul Aurich <paul@darkrain42.org>
parents: 26932
diff changeset
1230 g_free(tmp);
26874
eeee4309d3d8 Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents: 26870
diff changeset
1231 tmp = jabber_message_smileyfy_xhtml(jm, xhtml);
eeee4309d3d8 Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents: 26870
diff changeset
1232 if (tmp) {
eeee4309d3d8 Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents: 26870
diff changeset
1233 g_free(xhtml);
eeee4309d3d8 Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents: 26870
diff changeset
1234 xhtml = tmp;
eeee4309d3d8 Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <ml@update.uu.se>
parents: 26870
diff changeset
1235 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1236
26838
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1237 if (chat->xhtml && !jabber_xhtml_plain_equal(xhtml, jm->body))
28909
5bacbd78e2b4 jabber: Wrap XHTML-IM messages in <p/> for greater interoperability justice. Closes #11253
Paul Aurich <paul@darkrain42.org>
parents: 28663
diff changeset
1238 /* Wrap the message in <p/> for greater interoperability justice. */
5bacbd78e2b4 jabber: Wrap XHTML-IM messages in <p/> for greater interoperability justice. Closes #11253
Paul Aurich <paul@darkrain42.org>
parents: 28663
diff changeset
1239 jm->xhtml = g_strdup_printf("<html xmlns='" NS_XHTML_IM "'><body xmlns='" NS_XHTML "'><p>%s</p></body></html>", xhtml);
26838
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1240
aa29dac7924f Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <paul@darkrain42.org>
parents: 26760
diff changeset
1241 g_free(xhtml);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1242
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1243 jabber_message_send(jm);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1244 jabber_message_free(jm);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1245
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1246 return 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1247 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1248
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15659
diff changeset
1249 unsigned int jabber_send_typing(PurpleConnection *gc, const char *who, PurpleTypingState state)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1250 {
30201
7227c51730b0 jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <paul@darkrain42.org>
parents: 29919
diff changeset
1251 JabberStream *js;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1252 JabberMessage *jm;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1253 JabberBuddy *jb;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1254 JabberBuddyResource *jbr;
31086
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30476
diff changeset
1255 char *resource;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1256
30201
7227c51730b0 jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <paul@darkrain42.org>
parents: 29919
diff changeset
1257 js = purple_connection_get_protocol_data(gc);
7227c51730b0 jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <paul@darkrain42.org>
parents: 29919
diff changeset
1258 jb = jabber_buddy_find(js, who, TRUE);
7227c51730b0 jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <paul@darkrain42.org>
parents: 29919
diff changeset
1259 if (!jb)
7227c51730b0 jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <paul@darkrain42.org>
parents: 29919
diff changeset
1260 return 0;
7227c51730b0 jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <paul@darkrain42.org>
parents: 29919
diff changeset
1261
7227c51730b0 jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <paul@darkrain42.org>
parents: 29919
diff changeset
1262 resource = jabber_get_resource(who);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1263 jbr = jabber_buddy_find_resource(jb, resource);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1264 g_free(resource);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1265
29915
097569720d68 jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <paul@darkrain42.org>
parents: 29830
diff changeset
1266 /* We know this entity doesn't support chat states */
097569720d68 jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <paul@darkrain42.org>
parents: 29830
diff changeset
1267 if (jbr && jbr->chat_states == JABBER_CHAT_STATES_UNSUPPORTED)
097569720d68 jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <paul@darkrain42.org>
parents: 29830
diff changeset
1268 return 0;
097569720d68 jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <paul@darkrain42.org>
parents: 29830
diff changeset
1269
097569720d68 jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <paul@darkrain42.org>
parents: 29830
diff changeset
1270 /* *If* we don't have presence /and/ the buddy can't see our
097569720d68 jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <paul@darkrain42.org>
parents: 29830
diff changeset
1271 * presence, don't send typing notifications.
097569720d68 jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <paul@darkrain42.org>
parents: 29830
diff changeset
1272 */
097569720d68 jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <paul@darkrain42.org>
parents: 29830
diff changeset
1273 if (!jbr && !(jb->subscription & JABBER_SUB_FROM))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1274 return 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1275
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1276 /* TODO: figure out threading */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1277 jm = g_new0(JabberMessage, 1);
30201
7227c51730b0 jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <paul@darkrain42.org>
parents: 29919
diff changeset
1278 jm->js = js;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1279 jm->type = JABBER_MESSAGE_CHAT;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1280 jm->to = g_strdup(who);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1281 jm->id = jabber_get_next_id(jm->js);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1282
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15659
diff changeset
1283 if(PURPLE_TYPING == state)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1284 jm->chat_state = JM_STATE_COMPOSING;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15659
diff changeset
1285 else if(PURPLE_TYPED == state)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1286 jm->chat_state = JM_STATE_PAUSED;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1287 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1288 jm->chat_state = JM_STATE_ACTIVE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1289
27101
ad04d94e6ddf Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <paul@darkrain42.org>
parents: 27019
diff changeset
1290 /* if(JABBER_CHAT_STATES_UNKNOWN == jbr->chat_states)
ad04d94e6ddf Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <paul@darkrain42.org>
parents: 27019
diff changeset
1291 jbr->chat_states = JABBER_CHAT_STATES_UNSUPPORTED; */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1292
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1293 jabber_message_send(jm);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1294 jabber_message_free(jm);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1295
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1296 return 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1297 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1298
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23082
diff changeset
1299 gboolean jabber_buzz_isenabled(JabberStream *js, const gchar *namespace) {
17890
935005186312 Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17889
diff changeset
1300 return js->allowBuzz;
935005186312 Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17889
diff changeset
1301 }
935005186312 Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17889
diff changeset
1302
25145
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25144
diff changeset
1303 gboolean jabber_custom_smileys_isenabled(JabberStream *js, const gchar *namespace)
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
1304 {
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
1305 const PurpleConnection *gc = js->gc;
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
1306 PurpleAccount *account = purple_connection_get_account(gc);
23778
44feef3c885c A couple of leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23777
diff changeset
1307
23777
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
1308 return purple_account_get_bool(account, "custom_smileys", TRUE);
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 23082
diff changeset
1309 }