Mon, 10 Feb 2014 02:22:24 +0530
Merge gtkdoc-conversion
| 7014 | 1 | /* |
| 15884 | 2 | * purple - Jabber Protocol Plugin |
| 7014 | 3 | * |
|
28322
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
27900
diff
changeset
|
4 | * Purple is the legal property of its developers, whose names are too numerous |
|
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
27900
diff
changeset
|
5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
27900
diff
changeset
|
6 | * source distribution. |
| 7014 | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19419
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 7014 | 21 | * |
| 22 | */ | |
| 23 | #include "internal.h" | |
| 24 | ||
| 25 | #include "debug.h" | |
| 26 | #include "notify.h" | |
| 27 | #include "server.h" | |
|
7095
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7014
diff
changeset
|
28 | #include "util.h" |
|
26871
d62964222795
Add a new signal which is emitted (after the account is connected) if the
Paul Aurich <darkrain42@pidgin.im>
parents:
26867
diff
changeset
|
29 | #include "adhoccommands.h" |
| 7014 | 30 | #include "buddy.h" |
| 31 | #include "chat.h" | |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
32 | #include "data.h" |
|
29913
58f5122fbcd3
First shot at refactoring the Google-specific XMPP code.
Marcus Lundblad <malu@pidgin.im>
parents:
29910
diff
changeset
|
33 | #include "google/google.h" |
| 7014 | 34 | #include "message.h" |
| 35 | #include "xmlnode.h" | |
|
17768
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
17351
diff
changeset
|
36 | #include "pep.h" |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
37 | #include "smiley.h" |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
38 | #include "iq.h" |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
39 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
40 | #include <string.h> |
| 7014 | 41 | |
| 42 | void jabber_message_free(JabberMessage *jm) | |
| 43 | { | |
| 15980 | 44 | g_free(jm->from); |
| 13484 | 45 | g_free(jm->to); |
| 46 | g_free(jm->id); | |
| 47 | g_free(jm->subject); | |
| 48 | g_free(jm->body); | |
| 49 | g_free(jm->xhtml); | |
| 50 | g_free(jm->password); | |
|
20057
728a7dce565e
grab revision 41389df89a4a6a007d41cec33e33043cd41ea159
Luke Schierer <lschiere@pidgin.im>
parents:
19917
diff
changeset
|
51 | g_free(jm->error); |
|
728a7dce565e
grab revision 41389df89a4a6a007d41cec33e33043cd41ea159
Luke Schierer <lschiere@pidgin.im>
parents:
19917
diff
changeset
|
52 | g_free(jm->thread_id); |
| 13484 | 53 | g_list_free(jm->etc); |
|
20057
728a7dce565e
grab revision 41389df89a4a6a007d41cec33e33043cd41ea159
Luke Schierer <lschiere@pidgin.im>
parents:
19917
diff
changeset
|
54 | g_list_free(jm->eventitems); |
| 7014 | 55 | |
| 56 | g_free(jm); | |
| 57 | } | |
| 58 | ||
| 7145 | 59 | static void handle_chat(JabberMessage *jm) |
| 7014 | 60 | { |
| 61 | JabberID *jid = jabber_id_new(jm->from); | |
| 62 | ||
|
29331
9e828e599fc2
jabber: Use some convenience variables here.
Paul Aurich <darkrain42@pidgin.im>
parents:
29330
diff
changeset
|
63 | PurpleConnection *gc; |
|
9e828e599fc2
jabber: Use some convenience variables here.
Paul Aurich <darkrain42@pidgin.im>
parents:
29330
diff
changeset
|
64 | PurpleAccount *account; |
| 7014 | 65 | JabberBuddy *jb; |
| 66 | JabberBuddyResource *jbr; | |
| 67 | ||
| 7310 | 68 | if(!jid) |
| 69 | return; | |
| 70 | ||
|
29331
9e828e599fc2
jabber: Use some convenience variables here.
Paul Aurich <darkrain42@pidgin.im>
parents:
29330
diff
changeset
|
71 | gc = jm->js->gc; |
|
9e828e599fc2
jabber: Use some convenience variables here.
Paul Aurich <darkrain42@pidgin.im>
parents:
29330
diff
changeset
|
72 | account = purple_connection_get_account(gc); |
|
9e828e599fc2
jabber: Use some convenience variables here.
Paul Aurich <darkrain42@pidgin.im>
parents:
29330
diff
changeset
|
73 | |
| 7014 | 74 | jb = jabber_buddy_find(jm->js, jm->from, TRUE); |
| 7306 | 75 | jbr = jabber_buddy_find_resource(jb, jid->resource); |
| 7014 | 76 | |
| 77 | if(!jm->xhtml && !jm->body) { | |
|
30239
88550c8e461b
jabber: Refined logic for determining "is typing" support.
Paul Aurich <darkrain42@pidgin.im>
parents:
30235
diff
changeset
|
78 | if (jbr && jm->chat_state != JM_STATE_NONE) |
|
88550c8e461b
jabber: Refined logic for determining "is typing" support.
Paul Aurich <darkrain42@pidgin.im>
parents:
30235
diff
changeset
|
79 | jbr->chat_states = JABBER_CHAT_STATES_SUPPORTED; |
|
27750
f25b6a565494
Use Entity Capabilities to pick up Chat States support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents:
27749
diff
changeset
|
80 | |
|
15710
fbc4a200c853
Receiving XEP 85 'gone' messages. Doesn't do anything because of the string freeze. This is akin to the MSN 'so-and-so has closed the conversation window' messages. Rlaager made a strong point to me that they're not altogether stalky, but can be useful.
Sean Egan <seanegan@pidgin.im>
parents:
15709
diff
changeset
|
81 | if(JM_STATE_COMPOSING == jm->chat_state) { |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35070
diff
changeset
|
82 | purple_serv_got_typing(gc, jm->from, 0, PURPLE_IM_TYPING); |
|
15710
fbc4a200c853
Receiving XEP 85 'gone' messages. Doesn't do anything because of the string freeze. This is akin to the MSN 'so-and-so has closed the conversation window' messages. Rlaager made a strong point to me that they're not altogether stalky, but can be useful.
Sean Egan <seanegan@pidgin.im>
parents:
15709
diff
changeset
|
83 | } else if(JM_STATE_PAUSED == jm->chat_state) { |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35070
diff
changeset
|
84 | purple_serv_got_typing(gc, jm->from, 0, PURPLE_IM_TYPED); |
|
15710
fbc4a200c853
Receiving XEP 85 'gone' messages. Doesn't do anything because of the string freeze. This is akin to the MSN 'so-and-so has closed the conversation window' messages. Rlaager made a strong point to me that they're not altogether stalky, but can be useful.
Sean Egan <seanegan@pidgin.im>
parents:
15709
diff
changeset
|
85 | } else if(JM_STATE_GONE == jm->chat_state) { |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
86 | PurpleIMConversation *im = purple_conversations_find_im_with_account( |
|
29336
11ae11b31743
jabber: Cleanup (and drop that unnormalized find function)!
Paul Aurich <darkrain42@pidgin.im>
parents:
29332
diff
changeset
|
87 | jm->from, account); |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
88 | if (im && jid->node && jid->domain) { |
|
15721
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
89 | char buf[256]; |
| 15884 | 90 | PurpleBuddy *buddy; |
|
15721
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
91 | |
|
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
92 | g_snprintf(buf, sizeof(buf), "%s@%s", jid->node, jid->domain); |
|
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
93 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
94 | if ((buddy = purple_blist_find_buddy(account, buf))) { |
|
15721
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
95 | const char *who; |
|
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
96 | char *escaped; |
|
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
97 | |
| 15884 | 98 | who = purple_buddy_get_alias(buddy); |
|
15721
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
99 | escaped = g_markup_escape_text(who, -1); |
|
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
100 | |
|
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
101 | g_snprintf(buf, sizeof(buf), |
| 16946 | 102 | _("%s has left the conversation."), escaped); |
|
21193
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20361
diff
changeset
|
103 | g_free(escaped); |
|
15721
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
104 | |
| 15884 | 105 | /* At some point when we restructure PurpleConversation, |
|
15721
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
106 | * this should be able to be implemented by removing the |
|
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
107 | * user from the conversation like we do with chats now. */ |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
108 | purple_conversation_write(PURPLE_CONVERSATION(im), "", buf, |
| 15884 | 109 | PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
15721
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
110 | } |
|
15710
fbc4a200c853
Receiving XEP 85 'gone' messages. Doesn't do anything because of the string freeze. This is akin to the MSN 'so-and-so has closed the conversation window' messages. Rlaager made a strong point to me that they're not altogether stalky, but can be useful.
Sean Egan <seanegan@pidgin.im>
parents:
15709
diff
changeset
|
111 | } |
| 35501 | 112 | purple_serv_got_typing_stopped(gc, jm->from); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
113 | |
|
15710
fbc4a200c853
Receiving XEP 85 'gone' messages. Doesn't do anything because of the string freeze. This is akin to the MSN 'so-and-so has closed the conversation window' messages. Rlaager made a strong point to me that they're not altogether stalky, but can be useful.
Sean Egan <seanegan@pidgin.im>
parents:
15709
diff
changeset
|
114 | } else { |
| 35501 | 115 | purple_serv_got_typing_stopped(gc, jm->from); |
|
15710
fbc4a200c853
Receiving XEP 85 'gone' messages. Doesn't do anything because of the string freeze. This is akin to the MSN 'so-and-so has closed the conversation window' messages. Rlaager made a strong point to me that they're not altogether stalky, but can be useful.
Sean Egan <seanegan@pidgin.im>
parents:
15709
diff
changeset
|
116 | } |
| 7014 | 117 | } else { |
|
29840
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
118 | if (jid->resource) { |
|
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
119 | /* |
|
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
120 | * We received a message from a specific resource, so |
|
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
121 | * we probably want a reply to go to this specific |
|
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
122 | * resource (i.e. bind/lock the conversation to this |
|
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
123 | * resource). |
|
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
124 | * |
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
33722
diff
changeset
|
125 | * This works because purple_im_conversation_send gets the name |
|
29840
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
126 | * from purple_conversation_get_name() |
|
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
127 | */ |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
128 | PurpleIMConversation *im; |
|
29840
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
129 | |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
130 | im = purple_conversations_find_im_with_account(jm->from, account); |
|
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
131 | if (im && !g_str_equal(jm->from, |
|
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
132 | purple_conversation_get_name(PURPLE_CONVERSATION(im)))) { |
|
29840
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
133 | purple_debug_info("jabber", "Binding conversation to %s\n", |
|
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
134 | jm->from); |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
135 | purple_conversation_set_name(PURPLE_CONVERSATION(im), jm->from); |
|
29840
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
136 | } |
|
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
137 | } |
|
8792e8fbaa18
jabber: Unlock from locked resource on a message *with content*, as opposed to any message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29366
diff
changeset
|
138 | |
| 8400 | 139 | if(jbr) { |
|
30239
88550c8e461b
jabber: Refined logic for determining "is typing" support.
Paul Aurich <darkrain42@pidgin.im>
parents:
30235
diff
changeset
|
140 | /* Treat SUPPORTED as a terminal with no escape :) */ |
|
88550c8e461b
jabber: Refined logic for determining "is typing" support.
Paul Aurich <darkrain42@pidgin.im>
parents:
30235
diff
changeset
|
141 | if (jbr->chat_states != JABBER_CHAT_STATES_SUPPORTED) { |
|
88550c8e461b
jabber: Refined logic for determining "is typing" support.
Paul Aurich <darkrain42@pidgin.im>
parents:
30235
diff
changeset
|
142 | if (jm->chat_state != JM_STATE_NONE) |
|
88550c8e461b
jabber: Refined logic for determining "is typing" support.
Paul Aurich <darkrain42@pidgin.im>
parents:
30235
diff
changeset
|
143 | jbr->chat_states = JABBER_CHAT_STATES_SUPPORTED; |
|
88550c8e461b
jabber: Refined logic for determining "is typing" support.
Paul Aurich <darkrain42@pidgin.im>
parents:
30235
diff
changeset
|
144 | else |
|
88550c8e461b
jabber: Refined logic for determining "is typing" support.
Paul Aurich <darkrain42@pidgin.im>
parents:
30235
diff
changeset
|
145 | jbr->chat_states = JABBER_CHAT_STATES_UNSUPPORTED; |
|
88550c8e461b
jabber: Refined logic for determining "is typing" support.
Paul Aurich <darkrain42@pidgin.im>
parents:
30235
diff
changeset
|
146 | } |
| 13708 | 147 | |
| 8400 | 148 | if(jbr->thread_id) |
| 149 | g_free(jbr->thread_id); | |
| 150 | jbr->thread_id = g_strdup(jbr->thread_id); | |
| 151 | } | |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
152 | |
|
15587
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
153 | if (jm->js->googletalk && jm->xhtml == NULL) { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
154 | char *tmp = jm->body; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
155 | jm->body = jabber_google_format_to_html(jm->body); |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
156 | g_free(tmp); |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
157 | } |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35070
diff
changeset
|
158 | purple_serv_got_im(gc, jm->from, jm->xhtml ? jm->xhtml : jm->body, 0, jm->sent); |
| 7014 | 159 | } |
| 160 | ||
| 161 | jabber_id_free(jid); | |
| 162 | } | |
| 163 | ||
| 7145 | 164 | static void handle_headline(JabberMessage *jm) |
| 165 | { | |
| 166 | char *title; | |
|
17819
862fe0f947a9
Added buzz support using a private extension. Maybe I should write a XEP about that.
Andreas Monitzer <am@adiumx.com>
parents:
17811
diff
changeset
|
167 | GString *body; |
| 7145 | 168 | GList *etc; |
| 169 | ||
|
17819
862fe0f947a9
Added buzz support using a private extension. Maybe I should write a XEP about that.
Andreas Monitzer <am@adiumx.com>
parents:
17811
diff
changeset
|
170 | if(!jm->xhtml && !jm->body) |
|
862fe0f947a9
Added buzz support using a private extension. Maybe I should write a XEP about that.
Andreas Monitzer <am@adiumx.com>
parents:
17811
diff
changeset
|
171 | return; /* ignore headlines without any content */ |
| 7145 | 172 | |
|
17819
862fe0f947a9
Added buzz support using a private extension. Maybe I should write a XEP about that.
Andreas Monitzer <am@adiumx.com>
parents:
17811
diff
changeset
|
173 | body = g_string_new(""); |
| 7145 | 174 | title = g_strdup_printf(_("Message from %s"), jm->from); |
| 175 | ||
| 176 | if(jm->xhtml) | |
| 177 | g_string_append(body, jm->xhtml); | |
| 178 | else if(jm->body) | |
| 179 | g_string_append(body, jm->body); | |
| 180 | ||
| 181 | for(etc = jm->etc; etc; etc = etc->next) { | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
182 | PurpleXmlNode *x = etc->data; |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
183 | const char *xmlns = purple_xmlnode_get_namespace(x); |
|
28984
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28979
diff
changeset
|
184 | if(xmlns && !strcmp(xmlns, NS_OOB_X_DATA)) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
185 | PurpleXmlNode *url, *desc; |
| 7145 | 186 | char *urltxt, *desctxt; |
| 187 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
188 | url = purple_xmlnode_get_child(x, "url"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
189 | desc = purple_xmlnode_get_child(x, "desc"); |
| 7145 | 190 | |
| 191 | if(!url || !desc) | |
| 192 | continue; | |
| 193 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
194 | urltxt = purple_xmlnode_get_data(url); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
195 | desctxt = purple_xmlnode_get_data(desc); |
| 7145 | 196 | |
| 197 | /* I'm all about ugly hacks */ | |
|
14790
a0226bec3707
[gaim-migrate @ 17484]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14254
diff
changeset
|
198 | if(body->len && jm->body && !strcmp(body->str, jm->body)) |
| 7145 | 199 | g_string_printf(body, "<a href='%s'>%s</a>", |
| 200 | urltxt, desctxt); | |
| 201 | else | |
| 202 | g_string_append_printf(body, "<br/><a href='%s'>%s</a>", | |
| 203 | urltxt, desctxt); | |
| 204 | ||
| 205 | g_free(urltxt); | |
| 206 | g_free(desctxt); | |
| 207 | } | |
| 208 | } | |
| 209 | ||
| 15884 | 210 | purple_notify_formatted(jm->js->gc, title, jm->subject ? jm->subject : title, |
| 7145 | 211 | NULL, body->str, NULL, NULL); |
| 212 | ||
| 213 | g_free(title); | |
| 214 | g_string_free(body, TRUE); | |
| 215 | } | |
| 216 | ||
| 217 | static void handle_groupchat(JabberMessage *jm) | |
| 7014 | 218 | { |
| 219 | JabberID *jid = jabber_id_new(jm->from); | |
| 7310 | 220 | JabberChat *chat; |
|
33722
dd2cec2beaf6
Don't log system messages, that appear on *every* MUC entry/exit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32323
diff
changeset
|
221 | PurpleMessageFlags messageFlags = 0; |
| 7310 | 222 | |
| 223 | if(!jid) | |
| 224 | return; | |
| 225 | ||
| 226 | chat = jabber_chat_find(jm->js, jid->node, jid->domain); | |
| 7014 | 227 | |
| 228 | if(!chat) | |
| 229 | return; | |
| 230 | ||
| 7971 | 231 | if(jm->subject) { |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
232 | purple_chat_conversation_set_topic(chat->conv, jid->resource, |
| 7183 | 233 | jm->subject); |
|
33722
dd2cec2beaf6
Don't log system messages, that appear on *every* MUC entry/exit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32323
diff
changeset
|
234 | messageFlags |= PURPLE_MESSAGE_NO_LOG; |
| 7971 | 235 | if(!jm->xhtml && !jm->body) { |
| 9762 | 236 | char *msg, *tmp, *tmp2; |
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10607
diff
changeset
|
237 | tmp = g_markup_escape_text(jm->subject, -1); |
| 15884 | 238 | tmp2 = purple_markup_linkify(tmp); |
| 7971 | 239 | if(jid->resource) |
| 9762 | 240 | msg = g_strdup_printf(_("%s has set the topic to: %s"), jid->resource, tmp2); |
| 7971 | 241 | else |
| 9762 | 242 | msg = g_strdup_printf(_("The topic is: %s"), tmp2); |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
243 | purple_conversation_write_message(PURPLE_CONVERSATION(chat->conv), "", msg, messageFlags | PURPLE_MESSAGE_SYSTEM, jm->sent); |
| 9762 | 244 | g_free(tmp); |
| 245 | g_free(tmp2); | |
| 7971 | 246 | g_free(msg); |
| 247 | } | |
| 248 | } | |
| 7014 | 249 | |
| 7630 | 250 | if(jm->xhtml || jm->body) { |
| 251 | if(jid->resource) | |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35070
diff
changeset
|
252 | purple_serv_got_chat_in(jm->js->gc, chat->id, jid->resource, |
|
33722
dd2cec2beaf6
Don't log system messages, that appear on *every* MUC entry/exit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32323
diff
changeset
|
253 | messageFlags | (jm->delayed ? PURPLE_MESSAGE_DELAYED : 0), |
| 7630 | 254 | jm->xhtml ? jm->xhtml : jm->body, jm->sent); |
| 255 | else if(chat->muc) | |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
256 | purple_conversation_write_message(PURPLE_CONVERSATION(chat->conv), "", |
| 7630 | 257 | jm->xhtml ? jm->xhtml : jm->body, |
|
33722
dd2cec2beaf6
Don't log system messages, that appear on *every* MUC entry/exit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32323
diff
changeset
|
258 | messageFlags | PURPLE_MESSAGE_SYSTEM, jm->sent); |
| 7630 | 259 | } |
| 260 | ||
| 7014 | 261 | jabber_id_free(jid); |
| 262 | } | |
| 263 | ||
| 7145 | 264 | static void handle_groupchat_invite(JabberMessage *jm) |
| 7014 | 265 | { |
| 7310 | 266 | GHashTable *components; |
| 7014 | 267 | JabberID *jid = jabber_id_new(jm->to); |
| 268 | ||
| 7310 | 269 | if(!jid) |
| 270 | return; | |
| 271 | ||
|
15598
834a88c83e95
Get rid of some unnecessary string duping
Mark Doliner <markdoliner@pidgin.im>
parents:
15587
diff
changeset
|
272 | components = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); |
| 7310 | 273 | |
|
15598
834a88c83e95
Get rid of some unnecessary string duping
Mark Doliner <markdoliner@pidgin.im>
parents:
15587
diff
changeset
|
274 | g_hash_table_replace(components, "room", g_strdup(jid->node)); |
|
834a88c83e95
Get rid of some unnecessary string duping
Mark Doliner <markdoliner@pidgin.im>
parents:
15587
diff
changeset
|
275 | g_hash_table_replace(components, "server", g_strdup(jid->domain)); |
|
834a88c83e95
Get rid of some unnecessary string duping
Mark Doliner <markdoliner@pidgin.im>
parents:
15587
diff
changeset
|
276 | g_hash_table_replace(components, "handle", g_strdup(jm->js->user->node)); |
|
834a88c83e95
Get rid of some unnecessary string duping
Mark Doliner <markdoliner@pidgin.im>
parents:
15587
diff
changeset
|
277 | g_hash_table_replace(components, "password", g_strdup(jm->password)); |
| 7014 | 278 | |
| 279 | jabber_id_free(jid); | |
| 35501 | 280 | purple_serv_got_chat_invite(jm->js->gc, jm->to, jm->from, jm->body, components); |
| 7014 | 281 | } |
| 282 | ||
| 7145 | 283 | static void handle_error(JabberMessage *jm) |
| 7014 | 284 | { |
| 285 | char *buf; | |
| 286 | ||
| 287 | if(!jm->body) | |
| 288 | return; | |
| 289 | ||
| 290 | buf = g_strdup_printf(_("Message delivery to %s failed: %s"), | |
|
13766
6b92ce47f7e5
[gaim-migrate @ 16176]
Daniel Atallah <datallah@pidgin.im>
parents:
13708
diff
changeset
|
291 | jm->from, jm->error ? jm->error : ""); |
| 7014 | 292 | |
|
16961
b6955f946f8f
s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@pidgin.im>
parents:
16946
diff
changeset
|
293 | purple_notify_formatted(jm->js->gc, _("XMPP Message Error"), _("XMPP Message Error"), buf, |
| 7944 | 294 | jm->xhtml ? jm->xhtml : jm->body, NULL, NULL); |
| 7014 | 295 | |
| 296 | g_free(buf); | |
| 297 | } | |
| 298 | ||
|
17822
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
299 | static void handle_buzz(JabberMessage *jm) { |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
300 | PurpleAccount *account; |
|
25316
8b6461a2f967
Use purple_prpl_got_attention() for XMPP notifications
Evan Schoenberg <evands@pidgin.im>
parents:
25154
diff
changeset
|
301 | |
|
17823
2ca25e7e65dd
Switched buzz namespace and tag name to be libpurple-specific and use a more professionally-sounding name ('attention' instead of 'buzz').
Andreas Monitzer <am@adiumx.com>
parents:
17822
diff
changeset
|
302 | /* Delayed buzz MUST NOT be accepted */ |
|
2ca25e7e65dd
Switched buzz namespace and tag name to be libpurple-specific and use a more professionally-sounding name ('attention' instead of 'buzz').
Andreas Monitzer <am@adiumx.com>
parents:
17822
diff
changeset
|
303 | if(jm->delayed) |
|
2ca25e7e65dd
Switched buzz namespace and tag name to be libpurple-specific and use a more professionally-sounding name ('attention' instead of 'buzz').
Andreas Monitzer <am@adiumx.com>
parents:
17822
diff
changeset
|
304 | return; |
|
25316
8b6461a2f967
Use purple_prpl_got_attention() for XMPP notifications
Evan Schoenberg <evands@pidgin.im>
parents:
25154
diff
changeset
|
305 | |
|
17824
52683dfc1f7d
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents:
17823
diff
changeset
|
306 | /* Reject buzz when it's not enabled */ |
|
52683dfc1f7d
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents:
17823
diff
changeset
|
307 | if(!jm->js->allowBuzz) |
|
52683dfc1f7d
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents:
17823
diff
changeset
|
308 | return; |
|
25316
8b6461a2f967
Use purple_prpl_got_attention() for XMPP notifications
Evan Schoenberg <evands@pidgin.im>
parents:
25154
diff
changeset
|
309 | |
|
17822
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
310 | account = purple_connection_get_account(jm->js->gc); |
|
25316
8b6461a2f967
Use purple_prpl_got_attention() for XMPP notifications
Evan Schoenberg <evands@pidgin.im>
parents:
25154
diff
changeset
|
311 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
312 | if (purple_blist_find_buddy(account, jm->from) == NULL) |
|
17823
2ca25e7e65dd
Switched buzz namespace and tag name to be libpurple-specific and use a more professionally-sounding name ('attention' instead of 'buzz').
Andreas Monitzer <am@adiumx.com>
parents:
17822
diff
changeset
|
313 | return; /* Do not accept buzzes from unknown people */ |
|
2ca25e7e65dd
Switched buzz namespace and tag name to be libpurple-specific and use a more professionally-sounding name ('attention' instead of 'buzz').
Andreas Monitzer <am@adiumx.com>
parents:
17822
diff
changeset
|
314 | |
|
25316
8b6461a2f967
Use purple_prpl_got_attention() for XMPP notifications
Evan Schoenberg <evands@pidgin.im>
parents:
25154
diff
changeset
|
315 | /* xmpp only has 1 attention type, so index is 0 */ |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36362
diff
changeset
|
316 | purple_protocol_got_attention(jm->js->gc, jm->from, 0); |
|
17822
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
317 | } |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
318 | |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
319 | /* used internally by the functions below */ |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
320 | typedef struct { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
321 | gchar *cid; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
322 | gchar *alt; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
323 | } JabberSmileyRef; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
324 | |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
325 | |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
326 | static void |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
327 | jabber_message_get_refs_from_xmlnode_internal(const PurpleXmlNode *message, |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
328 | GHashTable *table) |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
329 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
330 | PurpleXmlNode *child; |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
331 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
332 | for (child = purple_xmlnode_get_child(message, "img") ; child ; |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
333 | child = purple_xmlnode_get_next_twin(child)) { |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
334 | const gchar *src = purple_xmlnode_get_attrib(child, "src"); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
335 | |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
336 | if (g_str_has_prefix(src, "cid:")) { |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
337 | const gchar *cid = src + 4; |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
338 | |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
339 | /* if we haven't "fetched" this yet... */ |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
340 | if (!g_hash_table_lookup(table, cid)) { |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
341 | /* take a copy of the cid and let the SmileyRef own it... */ |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
342 | gchar *temp_cid = g_strdup(cid); |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
343 | JabberSmileyRef *ref = g_new0(JabberSmileyRef, 1); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
344 | const gchar *alt = purple_xmlnode_get_attrib(child, "alt"); |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
345 | ref->cid = temp_cid; |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
346 | /* if there is no "alt" string, use the cid... |
|
24258
9ae10fafad7a
When receiving an <img/> without the "alt" attribute, set
Marcus Lundblad <malu@pidgin.im>
parents:
24257
diff
changeset
|
347 | include the entire src, eg. "cid:.." to avoid linkification */ |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
348 | if (alt && alt[0] != '\0') { |
|
24259
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
349 | /* workaround for when "alt" is set to the value of the |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
350 | CID (which Jabbim seems to do), to avoid it showing up |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
351 | as an mailto: link */ |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
352 | if (purple_email_is_valid(alt)) { |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
353 | ref->alt = g_strdup_printf("smiley:%s", alt); |
|
24259
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
354 | } else { |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
355 | ref->alt = g_strdup(alt); |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
356 | } |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
357 | } else { |
|
24258
9ae10fafad7a
When receiving an <img/> without the "alt" attribute, set
Marcus Lundblad <malu@pidgin.im>
parents:
24257
diff
changeset
|
358 | ref->alt = g_strdup(src); |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
359 | } |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
360 | g_hash_table_insert(table, temp_cid, ref); |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
361 | } |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
362 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
363 | } |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
364 | |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
365 | for (child = message->child ; child ; child = child->next) { |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
366 | jabber_message_get_refs_from_xmlnode_internal(child, table); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
367 | } |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
368 | } |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
369 | |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
370 | static gboolean |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
371 | jabber_message_get_refs_steal(gpointer key, gpointer value, gpointer user_data) |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
372 | { |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
373 | GList **refs = (GList **) user_data; |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
374 | JabberSmileyRef *ref = (JabberSmileyRef *) value; |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
375 | |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
376 | *refs = g_list_append(*refs, ref); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
377 | |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
378 | return TRUE; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
379 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
380 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
381 | static GList * |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
382 | jabber_message_get_refs_from_xmlnode(const PurpleXmlNode *message) |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
383 | { |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
384 | GList *refs = NULL; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
385 | GHashTable *unique_refs = g_hash_table_new(g_str_hash, g_str_equal); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
386 | |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
387 | jabber_message_get_refs_from_xmlnode_internal(message, unique_refs); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
388 | (void) g_hash_table_foreach_steal(unique_refs, |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
389 | jabber_message_get_refs_steal, (gpointer) &refs); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
390 | g_hash_table_destroy(unique_refs); |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
391 | return refs; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
392 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
393 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
394 | static gchar * |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
395 | jabber_message_xml_to_string_strip_img_smileys(PurpleXmlNode *xhtml) |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
396 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
397 | gchar *markup = purple_xmlnode_to_str(xhtml, NULL); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
398 | int len = strlen(markup); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
399 | int pos = 0; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
400 | GString *out = g_string_new(NULL); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
401 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
402 | while (pos < len) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
403 | /* this is a bit cludgy, maybe there is a better way to do this... |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
404 | we need to find all <img> tags within the XHTML and replace those |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
405 | tags with the value of their "alt" attributes */ |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
406 | if (g_str_has_prefix(&(markup[pos]), "<img")) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
407 | PurpleXmlNode *img = NULL; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
408 | int pos2 = pos; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
409 | const gchar *src; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
410 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
411 | for (; pos2 < len ; pos2++) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
412 | if (g_str_has_prefix(&(markup[pos2]), "/>")) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
413 | pos2 += 2; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
414 | break; |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
415 | } else if (g_str_has_prefix(&(markup[pos2]), "</img>")) { |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
416 | pos2 += 5; |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
417 | break; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
418 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
419 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
420 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
421 | /* note, if the above loop didn't find the end of the <img> tag, |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
422 | it the parsed string will be until the end of the input string, |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
423 | in which case purple_xmlnode_from_str will bail out and return NULL, |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
424 | in this case the "if" statement below doesn't trigger and the |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
425 | text is copied unchanged */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
426 | img = purple_xmlnode_from_str(&(markup[pos]), pos2 - pos); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
427 | src = purple_xmlnode_get_attrib(img, "src"); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
428 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
429 | if (g_str_has_prefix(src, "cid:")) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
430 | const gchar *alt = purple_xmlnode_get_attrib(img, "alt"); |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
431 | /* if the "alt" attribute is empty, put the cid as smiley string */ |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
432 | if (alt && alt[0] != '\0') { |
|
24259
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
433 | /* if the "alt" is the same as the CID, as Jabbim does, |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
434 | this prevents linkification... */ |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
435 | if (purple_email_is_valid(alt)) { |
|
24386
0710eb7a41c5
A couple of compile warning fixes, a couple of memory leak plugs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24259
diff
changeset
|
436 | gchar *safe_alt = g_strdup_printf("smiley:%s", alt); |
|
24259
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
437 | out = g_string_append(out, safe_alt); |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
438 | g_free(safe_alt); |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
439 | } else { |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
440 | out = g_string_append(out, alt); |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
441 | } |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
442 | } else { |
|
24258
9ae10fafad7a
When receiving an <img/> without the "alt" attribute, set
Marcus Lundblad <malu@pidgin.im>
parents:
24257
diff
changeset
|
443 | out = g_string_append(out, src); |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
444 | } |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
445 | pos += pos2 - pos; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
446 | } else { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
447 | out = g_string_append_c(out, markup[pos]); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
448 | pos++; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
449 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
450 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
451 | purple_xmlnode_free(img); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
452 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
453 | } else { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
454 | out = g_string_append_c(out, markup[pos]); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
455 | pos++; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
456 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
457 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
458 | |
|
24387
cba0cfba936e
Another memory leak fix. Also, keep a copy of the alt-text in
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24386
diff
changeset
|
459 | g_free(markup); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
460 | return g_string_free(out, FALSE); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
461 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
462 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
463 | static void |
|
29912
4f8e1c3bbc4a
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <malu@pidgin.im>
parents:
29910
diff
changeset
|
464 | jabber_message_add_remote_smileys(JabberStream *js, const gchar *who, |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
465 | const PurpleXmlNode *message) |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
466 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
467 | PurpleXmlNode *data_tag; |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
468 | for (data_tag = purple_xmlnode_get_child_with_namespace(message, "data", NS_BOB) ; |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
469 | data_tag ; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
470 | data_tag = purple_xmlnode_get_next_twin(data_tag)) { |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
471 | const gchar *cid = purple_xmlnode_get_attrib(data_tag, "cid"); |
|
29912
4f8e1c3bbc4a
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <malu@pidgin.im>
parents:
29910
diff
changeset
|
472 | const JabberData *data = jabber_data_find_remote_by_cid(js, who, cid); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
473 | |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
474 | if (!data && cid != NULL) { |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
475 | /* we haven't cached this already, let's add it */ |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
476 | JabberData *new_data = jabber_data_create_from_xml(data_tag); |
|
29910
f1c6e586e5c1
jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <malu@pidgin.im>
parents:
29906
diff
changeset
|
477 | |
|
f1c6e586e5c1
jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <malu@pidgin.im>
parents:
29906
diff
changeset
|
478 | if (new_data) { |
|
29912
4f8e1c3bbc4a
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <malu@pidgin.im>
parents:
29910
diff
changeset
|
479 | jabber_data_associate_remote(js, who, new_data); |
|
29910
f1c6e586e5c1
jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <malu@pidgin.im>
parents:
29906
diff
changeset
|
480 | } |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
481 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
482 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
483 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
484 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
485 | static void |
|
29906
2403e9d40e4a
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <malu@pidgin.im>
parents:
29840
diff
changeset
|
486 | jabber_message_request_data_cb(JabberData *data, gchar *alt, |
|
2403e9d40e4a
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <malu@pidgin.im>
parents:
29840
diff
changeset
|
487 | gpointer userdata) |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
488 | { |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
489 | PurpleConversation *conv = PURPLE_CONVERSATION(userdata); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
490 | |
|
29906
2403e9d40e4a
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <malu@pidgin.im>
parents:
29840
diff
changeset
|
491 | if (data) { |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
492 | purple_conversation_custom_smiley_write(conv, alt, |
|
29906
2403e9d40e4a
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <malu@pidgin.im>
parents:
29840
diff
changeset
|
493 | jabber_data_get_data(data), |
|
2403e9d40e4a
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <malu@pidgin.im>
parents:
29840
diff
changeset
|
494 | jabber_data_get_size(data)); |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
495 | purple_conversation_custom_smiley_close(conv, alt); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
496 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
497 | |
|
29906
2403e9d40e4a
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <malu@pidgin.im>
parents:
29840
diff
changeset
|
498 | g_free(alt); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
499 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
500 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
501 | void jabber_message_parse(JabberStream *js, PurpleXmlNode *packet) |
| 7014 | 502 | { |
| 503 | JabberMessage *jm; | |
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27061
diff
changeset
|
504 | const char *id, *from, *to, *type; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
505 | PurpleXmlNode *child; |
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27061
diff
changeset
|
506 | gboolean signal_return; |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27061
diff
changeset
|
507 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
508 | from = purple_xmlnode_get_attrib(packet, "from"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
509 | id = purple_xmlnode_get_attrib(packet, "id"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
510 | to = purple_xmlnode_get_attrib(packet, "to"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
511 | type = purple_xmlnode_get_attrib(packet, "type"); |
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27061
diff
changeset
|
512 | |
|
36623
caaadef03507
Renamed purple_connection_get_protocol_info() to purple_connection_get_protocol()
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
513 | signal_return = GPOINTER_TO_INT(purple_signal_emit_return_1(purple_connection_get_protocol(js->gc), |
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27061
diff
changeset
|
514 | "jabber-receiving-message", js->gc, type, id, from, to, packet)); |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27061
diff
changeset
|
515 | if (signal_return) |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27061
diff
changeset
|
516 | return; |
| 7014 | 517 | |
| 518 | jm = g_new0(JabberMessage, 1); | |
| 519 | jm->js = js; | |
| 520 | jm->sent = time(NULL); | |
|
9584
1a6198375303
[gaim-migrate @ 10427]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9130
diff
changeset
|
521 | jm->delayed = FALSE; |
|
27429
3313d7d74962
Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
522 | jm->chat_state = JM_STATE_NONE; |
| 7014 | 523 | |
| 524 | if(type) { | |
| 525 | if(!strcmp(type, "normal")) | |
| 526 | jm->type = JABBER_MESSAGE_NORMAL; | |
|
20320
6337e101f6ab
Plug some memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19917
diff
changeset
|
527 | else if(!strcmp(type, "chat")) |
| 7014 | 528 | jm->type = JABBER_MESSAGE_CHAT; |
| 529 | else if(!strcmp(type, "groupchat")) | |
| 530 | jm->type = JABBER_MESSAGE_GROUPCHAT; | |
| 531 | else if(!strcmp(type, "headline")) | |
| 532 | jm->type = JABBER_MESSAGE_HEADLINE; | |
| 533 | else if(!strcmp(type, "error")) | |
| 534 | jm->type = JABBER_MESSAGE_ERROR; | |
| 535 | else | |
| 536 | jm->type = JABBER_MESSAGE_OTHER; | |
| 537 | } else { | |
| 538 | jm->type = JABBER_MESSAGE_NORMAL; | |
| 539 | } | |
| 540 | ||
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27061
diff
changeset
|
541 | jm->from = g_strdup(from); |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27061
diff
changeset
|
542 | jm->to = g_strdup(to); |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
27061
diff
changeset
|
543 | jm->id = g_strdup(id); |
| 7014 | 544 | |
| 545 | for(child = packet->child; child; child = child->next) { | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
546 | const char *xmlns = purple_xmlnode_get_namespace(child); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
547 | if(child->type != PURPLE_XMLNODE_TYPE_TAG) |
| 7014 | 548 | continue; |
| 549 | ||
|
25154
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
550 | if(!strcmp(child->name, "error")) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
551 | const char *code = purple_xmlnode_get_attrib(child, "code"); |
|
25154
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
552 | char *code_txt = NULL; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
553 | char *text = purple_xmlnode_get_data(child); |
|
25154
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
554 | if (!text) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
555 | PurpleXmlNode *enclosed_text_node; |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
556 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
557 | if ((enclosed_text_node = purple_xmlnode_get_child(child, "text"))) |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
558 | text = purple_xmlnode_get_data(enclosed_text_node); |
|
25154
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
559 | } |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
560 | |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
561 | if(code) |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
562 | code_txt = g_strdup_printf(_("(Code %s)"), code); |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
563 | |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
564 | if(!jm->error) |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
565 | jm->error = g_strdup_printf("%s%s%s", |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
566 | text ? text : "", |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
567 | text && code_txt ? " " : "", |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
568 | code_txt ? code_txt : ""); |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
569 | |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
570 | g_free(code_txt); |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
571 | g_free(text); |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
572 | } else if (xmlns == NULL) { |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
573 | /* QuLogic: Not certain this is correct, but it would have happened |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
574 | with the previous code. */ |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
575 | if(!strcmp(child->name, "x")) |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
576 | jm->etc = g_list_append(jm->etc, child); |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
577 | /* The following tests expect xmlns != NULL */ |
|
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
578 | continue; |
|
28984
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28979
diff
changeset
|
579 | } else if(!strcmp(child->name, "subject") && !strcmp(xmlns, NS_XMPP_CLIENT)) { |
|
26859
8175186cf34a
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents:
26711
diff
changeset
|
580 | if(!jm->subject) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
581 | jm->subject = purple_xmlnode_get_data(child); |
|
26859
8175186cf34a
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents:
26711
diff
changeset
|
582 | if(!jm->subject) |
|
8175186cf34a
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents:
26711
diff
changeset
|
583 | jm->subject = g_strdup(""); |
|
8175186cf34a
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
Paul Aurich <darkrain42@pidgin.im>
parents:
26711
diff
changeset
|
584 | } |
|
28984
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28979
diff
changeset
|
585 | } else if(!strcmp(child->name, "thread") && !strcmp(xmlns, NS_XMPP_CLIENT)) { |
| 8400 | 586 | if(!jm->thread_id) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
587 | jm->thread_id = purple_xmlnode_get_data(child); |
|
28984
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28979
diff
changeset
|
588 | } else if(!strcmp(child->name, "body") && !strcmp(xmlns, NS_XMPP_CLIENT)) { |
| 13385 | 589 | if(!jm->body) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
590 | char *msg = purple_xmlnode_get_data(child); |
|
30583
2482f350d8f5
jabber: Fix the last commit to pass escaped text off to the core.
Paul Aurich <darkrain42@pidgin.im>
parents:
30582
diff
changeset
|
591 | char *escaped = purple_markup_escape_text(msg, -1); |
|
2482f350d8f5
jabber: Fix the last commit to pass escaped text off to the core.
Paul Aurich <darkrain42@pidgin.im>
parents:
30582
diff
changeset
|
592 | jm->body = purple_strdup_withhtml(escaped); |
|
2482f350d8f5
jabber: Fix the last commit to pass escaped text off to the core.
Paul Aurich <darkrain42@pidgin.im>
parents:
30582
diff
changeset
|
593 | g_free(escaped); |
| 13385 | 594 | g_free(msg); |
| 595 | } | |
|
28984
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28979
diff
changeset
|
596 | } else if(!strcmp(child->name, "html") && !strcmp(xmlns, NS_XHTML_IM)) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
597 | if(!jm->xhtml && purple_xmlnode_get_child(child, "body")) { |
|
17328
7a5668fb7bad
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents:
16961
diff
changeset
|
598 | char *c; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
599 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
600 | const PurpleConnection *gc = js->gc; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
601 | PurpleAccount *account = purple_connection_get_account(gc); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
602 | PurpleConversation *conv = NULL; |
|
24386
0710eb7a41c5
A couple of compile warning fixes, a couple of memory leak plugs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24259
diff
changeset
|
603 | GList *smiley_refs = NULL; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
604 | gchar *reformatted_xhtml; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
605 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
606 | if (purple_account_get_bool(account, "custom_smileys", TRUE)) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
607 | /* find a list of smileys ("cid" and "alt" text pairs) |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
608 | occuring in the message */ |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
609 | smiley_refs = jabber_message_get_refs_from_xmlnode(child); |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
610 | purple_debug_info("jabber", "found %d smileys\n", |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
611 | g_list_length(smiley_refs)); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
612 | |
|
27155
53502d71efdd
Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents:
27131
diff
changeset
|
613 | if (smiley_refs) { |
|
26711
07cfe1520055
Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <malu@pidgin.im>
parents:
26687
diff
changeset
|
614 | if (jm->type == JABBER_MESSAGE_GROUPCHAT) { |
|
07cfe1520055
Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <malu@pidgin.im>
parents:
26687
diff
changeset
|
615 | JabberID *jid = jabber_id_new(jm->from); |
|
07cfe1520055
Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <malu@pidgin.im>
parents:
26687
diff
changeset
|
616 | JabberChat *chat = NULL; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
617 | |
|
26711
07cfe1520055
Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <malu@pidgin.im>
parents:
26687
diff
changeset
|
618 | if (jid) { |
|
07cfe1520055
Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <malu@pidgin.im>
parents:
26687
diff
changeset
|
619 | chat = jabber_chat_find(js, jid->node, jid->domain); |
|
27782
68314a2ac01b
Break the 'if' onto two lines and don't bother calling jabber_id_free()
Mark Doliner <markdoliner@pidgin.im>
parents:
27750
diff
changeset
|
620 | if (chat) |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
621 | conv = PURPLE_CONVERSATION(chat->conv); |
|
27782
68314a2ac01b
Break the 'if' onto two lines and don't bother calling jabber_id_free()
Mark Doliner <markdoliner@pidgin.im>
parents:
27750
diff
changeset
|
622 | jabber_id_free(jid); |
|
26711
07cfe1520055
Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <malu@pidgin.im>
parents:
26687
diff
changeset
|
623 | } |
|
26867
20bf84d510d8
Only look for and add custom smileys to incoming messages that are going to
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
624 | } else if (jm->type == JABBER_MESSAGE_NORMAL || |
|
20bf84d510d8
Only look for and add custom smileys to incoming messages that are going to
Paul Aurich <darkrain42@pidgin.im>
parents:
26859
diff
changeset
|
625 | jm->type == JABBER_MESSAGE_CHAT) { |
|
26711
07cfe1520055
Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <malu@pidgin.im>
parents:
26687
diff
changeset
|
626 | conv = |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
627 | purple_conversations_find_with_account(from, account); |
|
26711
07cfe1520055
Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <malu@pidgin.im>
parents:
26687
diff
changeset
|
628 | if (!conv) { |
|
07cfe1520055
Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <malu@pidgin.im>
parents:
26687
diff
changeset
|
629 | /* we need to create the conversation here */ |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
630 | conv = PURPLE_CONVERSATION( |
|
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
631 | purple_im_conversation_new(account, from)); |
|
26711
07cfe1520055
Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <malu@pidgin.im>
parents:
26687
diff
changeset
|
632 | } |
|
24257
d6402f066933
Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <malu@pidgin.im>
parents:
24254
diff
changeset
|
633 | } |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
634 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
635 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
636 | /* process any newly provided smileys */ |
|
29912
4f8e1c3bbc4a
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <malu@pidgin.im>
parents:
29910
diff
changeset
|
637 | jabber_message_add_remote_smileys(js, to, packet); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
638 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
639 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
640 | purple_xmlnode_strip_prefixes(child); |
|
32323
df78cc32b2cd
jabber: Strip element prefixes on XHTML-IM content.
Paul Aurich <darkrain42@pidgin.im>
parents:
32277
diff
changeset
|
641 | |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
642 | /* reformat xhtml so that img tags with a "cid:" src gets |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
643 | translated to the bare text of the emoticon (the "alt" attrib) */ |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
644 | /* this is done also when custom smiley retrieval is turned off, |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
645 | this way the receiver always sees the shortcut instead */ |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
646 | reformatted_xhtml = |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
647 | jabber_message_xml_to_string_strip_img_smileys(child); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
648 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
649 | jm->xhtml = reformatted_xhtml; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
650 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
651 | /* add known custom emoticons to the conversation */ |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
652 | /* note: if there were no smileys in the incoming message, or |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
653 | if receiving custom smileys is turned off, smiley_refs will |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
654 | be NULL */ |
|
24669
5642bb588664
I got a crash happened at dereferencing chat when it's NULL, I think this
Ka-Hing Cheung <khc@pidgin.im>
parents:
24387
diff
changeset
|
655 | for (; conv && smiley_refs ; smiley_refs = g_list_delete_link(smiley_refs, smiley_refs)) { |
|
24387
cba0cfba936e
Another memory leak fix. Also, keep a copy of the alt-text in
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24386
diff
changeset
|
656 | JabberSmileyRef *ref = (JabberSmileyRef *) smiley_refs->data; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
657 | const gchar *cid = ref->cid; |
|
29906
2403e9d40e4a
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <malu@pidgin.im>
parents:
29840
diff
changeset
|
658 | gchar *alt = g_strdup(ref->alt); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
659 | |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
660 | purple_debug_info("jabber", |
|
24257
d6402f066933
Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <malu@pidgin.im>
parents:
24254
diff
changeset
|
661 | "about to add custom smiley %s to the conv\n", alt); |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
662 | if (purple_conversation_custom_smiley_add(conv, alt, "cid", cid, |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
663 | TRUE)) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
664 | const JabberData *data = |
|
29912
4f8e1c3bbc4a
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <malu@pidgin.im>
parents:
29910
diff
changeset
|
665 | jabber_data_find_remote_by_cid(js, from, cid); |
|
26711
07cfe1520055
Only pre-create a PurpleConversation (if there was none yet) if an incoming
Marcus Lundblad <malu@pidgin.im>
parents:
26687
diff
changeset
|
666 | /* if data is already known, we write it immediatly */ |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
667 | if (data) { |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
668 | purple_debug_info("jabber", |
|
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
669 | "data is already known\n"); |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
670 | purple_conversation_custom_smiley_write(conv, alt, |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
671 | jabber_data_get_data(data), |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
672 | jabber_data_get_size(data)); |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
673 | purple_conversation_custom_smiley_close(conv, alt); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
674 | } else { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
675 | /* we need to request the smiley (data) */ |
|
24257
d6402f066933
Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <malu@pidgin.im>
parents:
24254
diff
changeset
|
676 | purple_debug_info("jabber", |
|
d6402f066933
Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <malu@pidgin.im>
parents:
24254
diff
changeset
|
677 | "data is unknown, need to request it\n"); |
|
29906
2403e9d40e4a
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <malu@pidgin.im>
parents:
29840
diff
changeset
|
678 | jabber_data_request(js, cid, from, alt, FALSE, |
|
2403e9d40e4a
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <malu@pidgin.im>
parents:
29840
diff
changeset
|
679 | jabber_message_request_data_cb, conv); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
680 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
681 | } |
|
24387
cba0cfba936e
Another memory leak fix. Also, keep a copy of the alt-text in
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24386
diff
changeset
|
682 | g_free(ref->cid); |
|
cba0cfba936e
Another memory leak fix. Also, keep a copy of the alt-text in
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24386
diff
changeset
|
683 | g_free(ref->alt); |
|
cba0cfba936e
Another memory leak fix. Also, keep a copy of the alt-text in
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24386
diff
changeset
|
684 | g_free(ref); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
685 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
686 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
687 | /* Convert all newlines to whitespace. Technically, even regular, non-XML HTML is supposed to ignore newlines, but Pidgin has, as convention |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
688 | * treated \n as a newline for compatibility with other protocols |
|
17328
7a5668fb7bad
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents:
16961
diff
changeset
|
689 | */ |
|
7a5668fb7bad
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents:
16961
diff
changeset
|
690 | for (c = jm->xhtml; *c != '\0'; c++) { |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
691 | if (*c == '\n') |
|
17328
7a5668fb7bad
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents:
16961
diff
changeset
|
692 | *c = ' '; |
|
7a5668fb7bad
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents:
16961
diff
changeset
|
693 | } |
|
7a5668fb7bad
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents:
16961
diff
changeset
|
694 | } |
|
17768
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
17351
diff
changeset
|
695 | } else if(!strcmp(child->name, "active") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) { |
| 13708 | 696 | jm->chat_state = JM_STATE_ACTIVE; |
|
17768
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
17351
diff
changeset
|
697 | } else if(!strcmp(child->name, "composing") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) { |
| 13708 | 698 | jm->chat_state = JM_STATE_COMPOSING; |
|
17768
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
17351
diff
changeset
|
699 | } else if(!strcmp(child->name, "paused") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) { |
| 13708 | 700 | jm->chat_state = JM_STATE_PAUSED; |
|
17768
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
17351
diff
changeset
|
701 | } else if(!strcmp(child->name, "inactive") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) { |
| 13708 | 702 | jm->chat_state = JM_STATE_INACTIVE; |
|
17768
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
17351
diff
changeset
|
703 | } else if(!strcmp(child->name, "gone") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) { |
| 13708 | 704 | jm->chat_state = JM_STATE_GONE; |
|
17774
fdb76fddd16a
Implemented <required/> for x-data forms, simplified malloc/sprintf, message type headline is not a requirement for incoming PEP messages (it is just recommended to avoid offline message storage).
Andreas Monitzer <am@adiumx.com>
parents:
17768
diff
changeset
|
705 | } else if(!strcmp(child->name, "event") && !strcmp(xmlns,"http://jabber.org/protocol/pubsub#event")) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
706 | PurpleXmlNode *items; |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17776
diff
changeset
|
707 | jm->type = JABBER_MESSAGE_EVENT; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
708 | for(items = purple_xmlnode_get_child(child,"items"); items; items = items->next) |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17776
diff
changeset
|
709 | jm->eventitems = g_list_append(jm->eventitems, items); |
|
28979
191942cc7747
jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <darkrain42@pidgin.im>
parents:
28832
diff
changeset
|
710 | } else if(!strcmp(child->name, "attention") && !strcmp(xmlns, NS_ATTENTION)) { |
|
17822
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
711 | jm->hasBuzz = TRUE; |
|
28996
8296bccbfd50
jabber: Delayed Delivery namespaces
Paul Aurich <darkrain42@pidgin.im>
parents:
28984
diff
changeset
|
712 | } else if(!strcmp(child->name, "delay") && !strcmp(xmlns, NS_DELAYED_DELIVERY)) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
713 | const char *timestamp = purple_xmlnode_get_attrib(child, "stamp"); |
|
17811
d9a7ec9277f6
Implemented XEP-0203: Delayed Delivery
Andreas Monitzer <am@adiumx.com>
parents:
17792
diff
changeset
|
714 | jm->delayed = TRUE; |
|
d9a7ec9277f6
Implemented XEP-0203: Delayed Delivery
Andreas Monitzer <am@adiumx.com>
parents:
17792
diff
changeset
|
715 | if(timestamp) |
|
d9a7ec9277f6
Implemented XEP-0203: Delayed Delivery
Andreas Monitzer <am@adiumx.com>
parents:
17792
diff
changeset
|
716 | jm->sent = purple_str_to_time(timestamp, TRUE, NULL, NULL, NULL); |
| 7014 | 717 | } else if(!strcmp(child->name, "x")) { |
|
28996
8296bccbfd50
jabber: Delayed Delivery namespaces
Paul Aurich <darkrain42@pidgin.im>
parents:
28984
diff
changeset
|
718 | if(!strcmp(xmlns, NS_DELAYED_DELIVERY_LEGACY)) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
719 | const char *timestamp = purple_xmlnode_get_attrib(child, "stamp"); |
|
27434
7d8b32345d10
disapproval of revision '0c1545afc98299c6d7004554eb7443091d42e8ca'
Paul Aurich <darkrain42@pidgin.im>
parents:
27431
diff
changeset
|
720 | jm->delayed = TRUE; |
|
7d8b32345d10
disapproval of revision '0c1545afc98299c6d7004554eb7443091d42e8ca'
Paul Aurich <darkrain42@pidgin.im>
parents:
27431
diff
changeset
|
721 | if(timestamp) |
|
7d8b32345d10
disapproval of revision '0c1545afc98299c6d7004554eb7443091d42e8ca'
Paul Aurich <darkrain42@pidgin.im>
parents:
27431
diff
changeset
|
722 | jm->sent = purple_str_to_time(timestamp, TRUE, NULL, NULL, NULL); |
|
7d8b32345d10
disapproval of revision '0c1545afc98299c6d7004554eb7443091d42e8ca'
Paul Aurich <darkrain42@pidgin.im>
parents:
27431
diff
changeset
|
723 | } else if(!strcmp(xmlns, "jabber:x:conference") && |
| 11230 | 724 | jm->type != JABBER_MESSAGE_GROUPCHAT_INVITE && |
| 725 | jm->type != JABBER_MESSAGE_ERROR) { | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
726 | const char *jid = purple_xmlnode_get_attrib(child, "jid"); |
| 7014 | 727 | if(jid) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
728 | const char *reason = purple_xmlnode_get_attrib(child, "reason"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
729 | const char *password = purple_xmlnode_get_attrib(child, "password"); |
|
28703
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
730 | |
| 7014 | 731 | jm->type = JABBER_MESSAGE_GROUPCHAT_INVITE; |
| 732 | g_free(jm->to); | |
| 733 | jm->to = g_strdup(jid); | |
|
28703
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
734 | |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
735 | if (reason) { |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
736 | g_free(jm->body); |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
737 | jm->body = g_strdup(reason); |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
738 | } |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
739 | |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
740 | if (password) { |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
741 | g_free(jm->password); |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
742 | jm->password = g_strdup(password); |
|
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
743 | } |
| 7014 | 744 | } |
|
25154
492b9d6b48a5
Remove a double call to xmlnode_get_namespace and multiple tests for xmlns
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24800
diff
changeset
|
745 | } else if(!strcmp(xmlns, "http://jabber.org/protocol/muc#user") && |
| 11230 | 746 | jm->type != JABBER_MESSAGE_ERROR) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
747 | PurpleXmlNode *invite = purple_xmlnode_get_child(child, "invite"); |
| 7014 | 748 | if(invite) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
749 | PurpleXmlNode *reason, *password; |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
750 | const char *jid = purple_xmlnode_get_attrib(invite, "from"); |
| 7014 | 751 | g_free(jm->to); |
| 752 | jm->to = jm->from; | |
| 753 | jm->from = g_strdup(jid); | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
754 | if((reason = purple_xmlnode_get_child(invite, "reason"))) { |
| 7014 | 755 | g_free(jm->body); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
756 | jm->body = purple_xmlnode_get_data(reason); |
| 7014 | 757 | } |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
758 | if((password = purple_xmlnode_get_child(child, "password"))) { |
|
28703
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
759 | g_free(jm->password); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
760 | jm->password = purple_xmlnode_get_data(password); |
|
28703
521344e75710
jabber: Improved support for XEP-0249 (and document the legacy stuff).
Paul Aurich <darkrain42@pidgin.im>
parents:
28534
diff
changeset
|
761 | } |
| 7014 | 762 | |
| 763 | jm->type = JABBER_MESSAGE_GROUPCHAT_INVITE; | |
| 764 | } | |
| 7145 | 765 | } else { |
| 766 | jm->etc = g_list_append(jm->etc, child); | |
| 7014 | 767 | } |
|
26871
d62964222795
Add a new signal which is emitted (after the account is connected) if the
Paul Aurich <darkrain42@pidgin.im>
parents:
26867
diff
changeset
|
768 | } else if (g_str_equal(child->name, "query")) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
769 | const char *node = purple_xmlnode_get_attrib(child, "node"); |
|
28984
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28979
diff
changeset
|
770 | if (purple_strequal(xmlns, NS_DISCO_ITEMS) |
|
26871
d62964222795
Add a new signal which is emitted (after the account is connected) if the
Paul Aurich <darkrain42@pidgin.im>
parents:
26867
diff
changeset
|
771 | && purple_strequal(node, "http://jabber.org/protocol/commands")) { |
|
d62964222795
Add a new signal which is emitted (after the account is connected) if the
Paul Aurich <darkrain42@pidgin.im>
parents:
26867
diff
changeset
|
772 | jabber_adhoc_got_list(js, jm->from, child); |
|
d62964222795
Add a new signal which is emitted (after the account is connected) if the
Paul Aurich <darkrain42@pidgin.im>
parents:
26867
diff
changeset
|
773 | } |
| 7014 | 774 | } |
| 775 | } | |
| 776 | ||
|
17822
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
777 | if(jm->hasBuzz) |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
778 | handle_buzz(jm); |
| 7014 | 779 | |
| 780 | switch(jm->type) { | |
|
27900
23b6b4dfeb82
Allow fallback for broken XMPP <message/> types. Closes #7837.
Paul Aurich <darkrain42@pidgin.im>
parents:
27844
diff
changeset
|
781 | case JABBER_MESSAGE_OTHER: |
|
28828
7c1855f037e7
jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <darkrain42@pidgin.im>
parents:
28726
diff
changeset
|
782 | purple_debug_info("jabber", |
|
27900
23b6b4dfeb82
Allow fallback for broken XMPP <message/> types. Closes #7837.
Paul Aurich <darkrain42@pidgin.im>
parents:
27844
diff
changeset
|
783 | "Received message of unknown type: %s\n", type); |
|
23b6b4dfeb82
Allow fallback for broken XMPP <message/> types. Closes #7837.
Paul Aurich <darkrain42@pidgin.im>
parents:
27844
diff
changeset
|
784 | /* Fall-through is intentional */ |
| 7014 | 785 | case JABBER_MESSAGE_NORMAL: |
| 786 | case JABBER_MESSAGE_CHAT: | |
| 7145 | 787 | handle_chat(jm); |
| 788 | break; | |
| 7014 | 789 | case JABBER_MESSAGE_HEADLINE: |
| 7145 | 790 | handle_headline(jm); |
| 7014 | 791 | break; |
| 792 | case JABBER_MESSAGE_GROUPCHAT: | |
| 793 | handle_groupchat(jm); | |
| 794 | break; | |
| 795 | case JABBER_MESSAGE_GROUPCHAT_INVITE: | |
| 796 | handle_groupchat_invite(jm); | |
| 797 | break; | |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17776
diff
changeset
|
798 | case JABBER_MESSAGE_EVENT: |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17776
diff
changeset
|
799 | jabber_handle_event(jm); |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17776
diff
changeset
|
800 | break; |
| 7014 | 801 | case JABBER_MESSAGE_ERROR: |
| 802 | handle_error(jm); | |
| 803 | break; | |
| 804 | } | |
| 805 | jabber_message_free(jm); | |
| 806 | } | |
| 807 | ||
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
808 | static const gchar * |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
809 | jabber_message_get_mimetype_from_ext(const gchar *ext) |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
810 | { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
811 | if (strcmp(ext, "png") == 0) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
812 | return "image/png"; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
813 | } else if (strcmp(ext, "gif") == 0) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
814 | return "image/gif"; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
815 | } else if (strcmp(ext, "jpg") == 0) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
816 | return "image/jpeg"; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
817 | } else if (strcmp(ext, "tif") == 0) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
818 | return "image/tif"; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
819 | } else { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
820 | return "image/x-icon"; /* or something... */ |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
821 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
822 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
823 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
824 | static GList * |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
825 | jabber_message_xhtml_find_smileys(const char *xhtml) |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
826 | { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
827 | GList *smileys = purple_smileys_get_all(); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
828 | GList *found_smileys = NULL; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
829 | |
|
23628
3d540eeb2e74
Ooops ... compile\!
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23627
diff
changeset
|
830 | for (; smileys ; smileys = g_list_delete_link(smileys, smileys)) { |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
831 | PurpleSmiley *smiley = (PurpleSmiley *) smileys->data; |
|
29269
8145c8ab4935
jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <malu@pidgin.im>
parents:
29229
diff
changeset
|
832 | |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
833 | const gchar *shortcut = purple_smiley_get_shortcut(smiley); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
834 | const gssize len = strlen(shortcut); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
835 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
836 | gchar *escaped = g_markup_escape_text(shortcut, len); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
837 | const char *pos = strstr(xhtml, escaped); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
838 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
839 | if (pos) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
840 | found_smileys = g_list_append(found_smileys, smiley); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
841 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
842 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
843 | g_free(escaped); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
844 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
845 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
846 | return found_smileys; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
847 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
848 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
849 | static gchar * |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
850 | jabber_message_get_smileyfied_xhtml(const gchar *xhtml, const GList *smileys) |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
851 | { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
852 | /* create XML element for all smileys (img tags) */ |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
853 | GString *result = g_string_new(NULL); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
854 | int pos = 0; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
855 | int length = strlen(xhtml); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
856 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
857 | while (pos < length) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
858 | const GList *iterator; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
859 | gboolean found_smiley = FALSE; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
860 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
861 | for (iterator = smileys ; iterator ; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
862 | iterator = g_list_next(iterator)) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
863 | const PurpleSmiley *smiley = (PurpleSmiley *) iterator->data; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
864 | const gchar *shortcut = purple_smiley_get_shortcut(smiley); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
865 | const gssize len = strlen(shortcut); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
866 | gchar *escaped = g_markup_escape_text(shortcut, len); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
867 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
868 | if (g_str_has_prefix(&(xhtml[pos]), escaped)) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
869 | /* we found the current smiley at this position */ |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
870 | const JabberData *data = |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
871 | jabber_data_find_local_by_alt(shortcut); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
872 | PurpleXmlNode *img = jabber_data_get_xhtml_im(data, shortcut); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
873 | int len; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
874 | gchar *img_text = purple_xmlnode_to_str(img, &len); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
875 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
876 | found_smiley = TRUE; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
877 | result = g_string_append(result, img_text); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
878 | g_free(img_text); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
879 | pos += strlen(escaped); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
880 | g_free(escaped); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
881 | purple_xmlnode_free(img); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
882 | break; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
883 | } else { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
884 | /* cleanup from the before the next round... */ |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
885 | g_free(escaped); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
886 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
887 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
888 | if (!found_smiley) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
889 | /* there was no smiley here, just copy one byte */ |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
890 | result = g_string_append_c(result, xhtml[pos]); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
891 | pos++; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
892 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
893 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
894 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
895 | return g_string_free(result, FALSE); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
896 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
897 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
898 | static gboolean |
| 29366 | 899 | jabber_conv_support_custom_smileys(JabberStream *js, |
|
27110
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27103
diff
changeset
|
900 | PurpleConversation *conv, |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
901 | const gchar *who) |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
902 | { |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
903 | JabberBuddy *jb; |
|
27110
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27103
diff
changeset
|
904 | JabberChat *chat; |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
905 | |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
906 | if (PURPLE_IS_IM_CONVERSATION(conv)) { |
|
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
907 | jb = jabber_buddy_find(js, who, FALSE); |
|
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
908 | if (jb) { |
|
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
909 | return jabber_buddy_has_capability(jb, NS_BOB); |
|
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
910 | } else { |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
911 | return FALSE; |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
912 | } |
|
35070
d7350d876fda
libpurple: Don't assume a conversation is always an IM or a chat
Ankit Vani <a@nevitus.org>
parents:
34935
diff
changeset
|
913 | } else if (PURPLE_IS_CHAT_CONVERSATION(conv)) { |
|
34634
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
914 | chat = jabber_chat_find_by_conv(PURPLE_CHAT_CONVERSATION(conv)); |
|
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
915 | if (chat) { |
|
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
916 | /* do not attempt to send custom smileys in a MUC with more than |
|
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
917 | 10 people, to avoid getting too many BoB requests */ |
|
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
918 | return jabber_chat_get_num_participants(chat) <= 10 && |
|
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
919 | jabber_chat_all_participants_have_capability(chat, |
|
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
920 | NS_BOB); |
|
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
921 | } else { |
|
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
922 | return FALSE; |
|
90fa70aa7e28
Refactored the jabber protocol to use GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
923 | } |
|
35070
d7350d876fda
libpurple: Don't assume a conversation is always an IM or a chat
Ankit Vani <a@nevitus.org>
parents:
34935
diff
changeset
|
924 | } else { |
|
d7350d876fda
libpurple: Don't assume a conversation is always an IM or a chat
Ankit Vani <a@nevitus.org>
parents:
34935
diff
changeset
|
925 | return FALSE; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
926 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
927 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
928 | |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
929 | static char * |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
930 | jabber_message_smileyfy_xhtml(JabberMessage *jm, const char *xhtml) |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
931 | { |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
932 | PurpleAccount *account = purple_connection_get_account(jm->js->gc); |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
933 | PurpleConversation *conv = |
|
34625
03d62b1660fc
Refactor code to remove conversation type from some instances of purple_conversations_find_with_account()
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
934 | purple_conversations_find_with_account(jm->to, |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
935 | account); |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
936 | |
| 29366 | 937 | if (jabber_conv_support_custom_smileys(jm->js, conv, jm->to)) { |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
938 | GList *found_smileys = jabber_message_xhtml_find_smileys(xhtml); |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
939 | |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
940 | if (found_smileys) { |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
941 | gchar *smileyfied_xhtml = NULL; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
942 | const GList *iterator; |
|
29269
8145c8ab4935
jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <malu@pidgin.im>
parents:
29229
diff
changeset
|
943 | GList *valid_smileys = NULL; |
|
29270
642d7a9e5f0a
jabber: Don't print the smiley shortcut in the error message when trying to
Marcus Lundblad <malu@pidgin.im>
parents:
29269
diff
changeset
|
944 | gboolean has_too_large_smiley = FALSE; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30744
diff
changeset
|
945 | |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
946 | for (iterator = found_smileys; iterator ; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
947 | iterator = g_list_next(iterator)) { |
|
29269
8145c8ab4935
jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <malu@pidgin.im>
parents:
29229
diff
changeset
|
948 | PurpleSmiley *smiley = (PurpleSmiley *) iterator->data; |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
949 | const gchar *shortcut = purple_smiley_get_shortcut(smiley); |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
950 | const JabberData *data = |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
951 | jabber_data_find_local_by_alt(shortcut); |
|
29269
8145c8ab4935
jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <malu@pidgin.im>
parents:
29229
diff
changeset
|
952 | PurpleStoredImage *image = purple_smiley_get_stored_image(smiley); |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
953 | |
|
29269
8145c8ab4935
jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <malu@pidgin.im>
parents:
29229
diff
changeset
|
954 | if (purple_imgstore_get_size(image) <= JABBER_DATA_MAX_SIZE) { |
|
8145c8ab4935
jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <malu@pidgin.im>
parents:
29229
diff
changeset
|
955 | /* the object has not been sent before */ |
|
8145c8ab4935
jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <malu@pidgin.im>
parents:
29229
diff
changeset
|
956 | if (!data) { |
|
8145c8ab4935
jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <malu@pidgin.im>
parents:
29229
diff
changeset
|
957 | const gchar *ext = purple_imgstore_get_extension(image); |
|
8145c8ab4935
jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <malu@pidgin.im>
parents:
29229
diff
changeset
|
958 | JabberStream *js = jm->js; |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
959 | |
|
29269
8145c8ab4935
jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <malu@pidgin.im>
parents:
29229
diff
changeset
|
960 | JabberData *new_data = |
|
8145c8ab4935
jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <malu@pidgin.im>
parents:
29229
diff
changeset
|
961 | jabber_data_create_from_data(purple_imgstore_get_data(image), |
|
8145c8ab4935
jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <malu@pidgin.im>
parents:
29229
diff
changeset
|
962 | purple_imgstore_get_size(image), |
|
29732
8a8fef36b57a
Make it compile again after merge
Marcus Lundblad <malu@pidgin.im>
parents:
29731
diff
changeset
|
963 | jabber_message_get_mimetype_from_ext(ext), FALSE, js); |
|
29269
8145c8ab4935
jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <malu@pidgin.im>
parents:
29229
diff
changeset
|
964 | purple_debug_info("jabber", |
|
8145c8ab4935
jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <malu@pidgin.im>
parents:
29229
diff
changeset
|
965 | "cache local smiley alt = %s, cid = %s\n", |
|
8145c8ab4935
jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <malu@pidgin.im>
parents:
29229
diff
changeset
|
966 | shortcut, jabber_data_get_cid(new_data)); |
|
8145c8ab4935
jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <malu@pidgin.im>
parents:
29229
diff
changeset
|
967 | jabber_data_associate_local(new_data, shortcut); |
|
8145c8ab4935
jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <malu@pidgin.im>
parents:
29229
diff
changeset
|
968 | } |
|
8145c8ab4935
jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <malu@pidgin.im>
parents:
29229
diff
changeset
|
969 | valid_smileys = g_list_append(valid_smileys, smiley); |
|
8145c8ab4935
jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <malu@pidgin.im>
parents:
29229
diff
changeset
|
970 | } else { |
|
29270
642d7a9e5f0a
jabber: Don't print the smiley shortcut in the error message when trying to
Marcus Lundblad <malu@pidgin.im>
parents:
29269
diff
changeset
|
971 | has_too_large_smiley = TRUE; |
|
29277
ff5a56fae229
jabber: Log a warning (with the shortcut) when refusing to send a smiley.
Paul Aurich <darkrain42@pidgin.im>
parents:
29270
diff
changeset
|
972 | purple_debug_warning("jabber", "Refusing to send smiley %s " |
|
ff5a56fae229
jabber: Log a warning (with the shortcut) when refusing to send a smiley.
Paul Aurich <darkrain42@pidgin.im>
parents:
29270
diff
changeset
|
973 | "(too large, max is %d)\n", |
|
ff5a56fae229
jabber: Log a warning (with the shortcut) when refusing to send a smiley.
Paul Aurich <darkrain42@pidgin.im>
parents:
29270
diff
changeset
|
974 | purple_smiley_get_shortcut(smiley), |
|
ff5a56fae229
jabber: Log a warning (with the shortcut) when refusing to send a smiley.
Paul Aurich <darkrain42@pidgin.im>
parents:
29270
diff
changeset
|
975 | JABBER_DATA_MAX_SIZE); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30744
diff
changeset
|
976 | } |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
977 | } |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
978 | |
|
29270
642d7a9e5f0a
jabber: Don't print the smiley shortcut in the error message when trying to
Marcus Lundblad <malu@pidgin.im>
parents:
29269
diff
changeset
|
979 | if (has_too_large_smiley) { |
|
642d7a9e5f0a
jabber: Don't print the smiley shortcut in the error message when trying to
Marcus Lundblad <malu@pidgin.im>
parents:
29269
diff
changeset
|
980 | purple_conversation_write(conv, NULL, |
|
642d7a9e5f0a
jabber: Don't print the smiley shortcut in the error message when trying to
Marcus Lundblad <malu@pidgin.im>
parents:
29269
diff
changeset
|
981 | _("A custom smiley in the message is too large to send."), |
|
642d7a9e5f0a
jabber: Don't print the smiley shortcut in the error message when trying to
Marcus Lundblad <malu@pidgin.im>
parents:
29269
diff
changeset
|
982 | PURPLE_MESSAGE_ERROR, time(NULL)); |
|
642d7a9e5f0a
jabber: Don't print the smiley shortcut in the error message when trying to
Marcus Lundblad <malu@pidgin.im>
parents:
29269
diff
changeset
|
983 | } |
|
642d7a9e5f0a
jabber: Don't print the smiley shortcut in the error message when trying to
Marcus Lundblad <malu@pidgin.im>
parents:
29269
diff
changeset
|
984 | |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
985 | smileyfied_xhtml = |
|
29269
8145c8ab4935
jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <malu@pidgin.im>
parents:
29229
diff
changeset
|
986 | jabber_message_get_smileyfied_xhtml(xhtml, valid_smileys); |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
987 | g_list_free(found_smileys); |
|
29269
8145c8ab4935
jabber: Don't send custom smileys larger than the recommended maximum BoB size
Marcus Lundblad <malu@pidgin.im>
parents:
29229
diff
changeset
|
988 | g_list_free(valid_smileys); |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
989 | |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
990 | return smileyfied_xhtml; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
991 | } |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
992 | } |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
993 | |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
994 | return NULL; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
995 | } |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
996 | |
| 7014 | 997 | void jabber_message_send(JabberMessage *jm) |
| 998 | { | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
999 | PurpleXmlNode *message, *child; |
| 7014 | 1000 | const char *type = NULL; |
| 1001 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1002 | message = purple_xmlnode_new("message"); |
| 7014 | 1003 | |
| 1004 | switch(jm->type) { | |
| 1005 | case JABBER_MESSAGE_NORMAL: | |
| 1006 | type = "normal"; | |
| 1007 | break; | |
| 1008 | case JABBER_MESSAGE_CHAT: | |
| 1009 | case JABBER_MESSAGE_GROUPCHAT_INVITE: | |
| 1010 | type = "chat"; | |
| 1011 | break; | |
| 1012 | case JABBER_MESSAGE_HEADLINE: | |
| 1013 | type = "headline"; | |
| 1014 | break; | |
| 1015 | case JABBER_MESSAGE_GROUPCHAT: | |
| 1016 | type = "groupchat"; | |
| 1017 | break; | |
| 1018 | case JABBER_MESSAGE_ERROR: | |
| 1019 | type = "error"; | |
| 1020 | break; | |
| 1021 | case JABBER_MESSAGE_OTHER: | |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17776
diff
changeset
|
1022 | default: |
| 7014 | 1023 | type = NULL; |
| 1024 | break; | |
| 1025 | } | |
| 1026 | ||
| 1027 | if(type) | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1028 | purple_xmlnode_set_attrib(message, "type", type); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25983
diff
changeset
|
1029 | |
| 13484 | 1030 | if (jm->id) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1031 | purple_xmlnode_set_attrib(message, "id", jm->id); |
| 7014 | 1032 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1033 | purple_xmlnode_set_attrib(message, "to", jm->to); |
| 7014 | 1034 | |
| 8400 | 1035 | if(jm->thread_id) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1036 | child = purple_xmlnode_new_child(message, "thread"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1037 | purple_xmlnode_insert_data(child, jm->thread_id, -1); |
| 8400 | 1038 | } |
| 1039 | ||
| 27432 | 1040 | child = NULL; |
| 1041 | switch(jm->chat_state) | |
| 1042 | { | |
| 1043 | case JM_STATE_ACTIVE: | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1044 | child = purple_xmlnode_new_child(message, "active"); |
| 27432 | 1045 | break; |
| 1046 | case JM_STATE_COMPOSING: | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1047 | child = purple_xmlnode_new_child(message, "composing"); |
| 27432 | 1048 | break; |
| 1049 | case JM_STATE_PAUSED: | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1050 | child = purple_xmlnode_new_child(message, "paused"); |
| 27432 | 1051 | break; |
| 1052 | case JM_STATE_INACTIVE: | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1053 | child = purple_xmlnode_new_child(message, "inactive"); |
| 27432 | 1054 | break; |
| 1055 | case JM_STATE_GONE: | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1056 | child = purple_xmlnode_new_child(message, "gone"); |
| 27432 | 1057 | break; |
| 1058 | case JM_STATE_NONE: | |
| 1059 | /* yep, nothing */ | |
| 1060 | break; | |
| 7014 | 1061 | } |
| 27432 | 1062 | if(child) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1063 | purple_xmlnode_set_namespace(child, "http://jabber.org/protocol/chatstates"); |
| 13708 | 1064 | |
| 7014 | 1065 | if(jm->subject) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1066 | child = purple_xmlnode_new_child(message, "subject"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1067 | purple_xmlnode_insert_data(child, jm->subject, -1); |
| 7014 | 1068 | } |
| 1069 | ||
| 1070 | if(jm->body) { | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1071 | child = purple_xmlnode_new_child(message, "body"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1072 | purple_xmlnode_insert_data(child, jm->body, -1); |
| 7014 | 1073 | } |
| 1074 | ||
| 1075 | if(jm->xhtml) { | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1076 | if ((child = purple_xmlnode_from_str(jm->xhtml, -1))) { |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1077 | purple_xmlnode_insert_child(message, child); |
| 7014 | 1078 | } else { |
|
28828
7c1855f037e7
jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <darkrain42@pidgin.im>
parents:
28726
diff
changeset
|
1079 | purple_debug_error("jabber", |
| 7014 | 1080 | "XHTML translation/validation failed, returning: %s\n", |
| 1081 | jm->xhtml); | |
| 1082 | } | |
| 1083 | } | |
| 1084 | ||
| 1085 | jabber_send(jm->js, message); | |
| 1086 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1087 | purple_xmlnode_free(message); |
| 7014 | 1088 | } |
| 1089 | ||
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1090 | /* |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1091 | * Compare the XHTML and plain strings passed in for "equality". Any HTML markup |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1092 | * other than <br/> (matches a newline) in the XHTML will cause this to return |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1093 | * FALSE. |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1094 | */ |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1095 | static gboolean |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1096 | jabber_xhtml_plain_equal(const char *xhtml_escaped, |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1097 | const char *plain) |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1098 | { |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1099 | int i = 0; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1100 | int j = 0; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1101 | gboolean ret; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1102 | char *xhtml = purple_unescape_html(xhtml_escaped); |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1103 | |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1104 | while (xhtml[i] && plain[j]) { |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1105 | if (xhtml[i] == plain[j]) { |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1106 | i += 1; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1107 | j += 1; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1108 | continue; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1109 | } |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1110 | |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1111 | if (plain[j] == '\n' && !strncmp(xhtml+i, "<br/>", 5)) { |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1112 | i += 5; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1113 | j += 1; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1114 | continue; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1115 | } |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1116 | |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1117 | g_free(xhtml); |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1118 | return FALSE; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1119 | } |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1120 | |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1121 | /* Are we at the end of both strings? */ |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1122 | ret = (xhtml[i] == plain[j]) && (xhtml[i] == '\0'); |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1123 | g_free(xhtml); |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1124 | return ret; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1125 | } |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1126 | |
| 15884 | 1127 | int jabber_message_send_im(PurpleConnection *gc, const char *who, const char *msg, |
| 1128 | PurpleMessageFlags flags) | |
| 7014 | 1129 | { |
| 1130 | JabberMessage *jm; | |
| 1131 | JabberBuddy *jb; | |
| 1132 | JabberBuddyResource *jbr; | |
| 7135 | 1133 | char *xhtml; |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1134 | char *tmp; |
| 7306 | 1135 | char *resource; |
| 7014 | 1136 | |
| 1137 | if(!who || !msg) | |
| 1138 | return 0; | |
| 1139 | ||
|
31512
b1c0ce2787e6
jabber: Verbose printing of the exact message passed in to jabber_message_send_im.
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
1140 | if (purple_debug_is_verbose()) { |
|
b1c0ce2787e6
jabber: Verbose printing of the exact message passed in to jabber_message_send_im.
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
1141 | /* TODO: Maybe we need purple_debug_is_really_verbose? :) */ |
|
b1c0ce2787e6
jabber: Verbose printing of the exact message passed in to jabber_message_send_im.
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
1142 | purple_debug_misc("jabber", "jabber_message_send_im: who='%s'\n" |
|
b1c0ce2787e6
jabber: Verbose printing of the exact message passed in to jabber_message_send_im.
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
1143 | "\tmsg='%s'\n", who, msg); |
|
b1c0ce2787e6
jabber: Verbose printing of the exact message passed in to jabber_message_send_im.
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
1144 | } |
|
b1c0ce2787e6
jabber: Verbose printing of the exact message passed in to jabber_message_send_im.
Paul Aurich <darkrain42@pidgin.im>
parents:
31294
diff
changeset
|
1145 | |
| 7306 | 1146 | resource = jabber_get_resource(who); |
| 1147 | ||
|
32277
97f16af01a05
Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
31512
diff
changeset
|
1148 | jb = jabber_buddy_find(purple_connection_get_protocol_data(gc), who, TRUE); |
| 7306 | 1149 | jbr = jabber_buddy_find_resource(jb, resource); |
| 1150 | ||
| 1151 | g_free(resource); | |
| 7014 | 1152 | |
| 1153 | jm = g_new0(JabberMessage, 1); | |
|
32277
97f16af01a05
Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
31512
diff
changeset
|
1154 | jm->js = purple_connection_get_protocol_data(gc); |
| 7014 | 1155 | jm->type = JABBER_MESSAGE_CHAT; |
| 13708 | 1156 | jm->chat_state = JM_STATE_ACTIVE; |
| 7014 | 1157 | jm->to = g_strdup(who); |
| 13484 | 1158 | jm->id = jabber_get_next_id(jm->js); |
| 13708 | 1159 | |
| 1160 | if(jbr) { | |
| 1161 | if(jbr->thread_id) | |
| 1162 | jm->thread_id = jbr->thread_id; | |
| 1163 | ||
|
27429
3313d7d74962
Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
1164 | if (jbr->chat_states == JABBER_CHAT_STATES_UNSUPPORTED) |
|
3313d7d74962
Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
1165 | jm->chat_state = JM_STATE_NONE; |
|
3313d7d74962
Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
1166 | else { |
| 13708 | 1167 | /* if(JABBER_CHAT_STATES_UNKNOWN == jbr->chat_states) |
| 1168 | jbr->chat_states = JABBER_CHAT_STATES_UNSUPPORTED; */ | |
| 1169 | } | |
| 1170 | } | |
| 7014 | 1171 | |
|
27237
0643ac0e5658
Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages.
Paul Aurich <darkrain42@pidgin.im>
parents:
27155
diff
changeset
|
1172 | tmp = purple_utf8_strip_unprintables(msg); |
|
0643ac0e5658
Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages.
Paul Aurich <darkrain42@pidgin.im>
parents:
27155
diff
changeset
|
1173 | purple_markup_html_to_xhtml(tmp, &xhtml, &jm->body); |
|
0643ac0e5658
Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages.
Paul Aurich <darkrain42@pidgin.im>
parents:
27155
diff
changeset
|
1174 | g_free(tmp); |
|
29229
1fd36e207795
jabber: Wrap XHTML-IM messages in <p/> for greater interoperability justice. Closes #11253
Paul Aurich <darkrain42@pidgin.im>
parents:
28996
diff
changeset
|
1175 | |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1176 | tmp = jabber_message_smileyfy_xhtml(jm, xhtml); |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1177 | if (tmp) { |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1178 | g_free(xhtml); |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1179 | xhtml = tmp; |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1180 | } |
| 7014 | 1181 | |
|
27746
4b3f015977d9
For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
1182 | /* |
|
4b3f015977d9
For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
1183 | * For backward compatibility with user expectations or for those not on |
|
4b3f015977d9
For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
1184 | * the user's roster, allow sending XHTML-IM markup. |
|
4b3f015977d9
For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
1185 | */ |
|
4b3f015977d9
For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
1186 | if (!jbr || !jbr->caps.info || |
|
28984
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28979
diff
changeset
|
1187 | jabber_resource_has_capability(jbr, NS_XHTML_IM)) { |
|
27746
4b3f015977d9
For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
1188 | if (!jabber_xhtml_plain_equal(xhtml, jm->body)) |
|
29229
1fd36e207795
jabber: Wrap XHTML-IM messages in <p/> for greater interoperability justice. Closes #11253
Paul Aurich <darkrain42@pidgin.im>
parents:
28996
diff
changeset
|
1189 | /* Wrap the message in <p/> for great interoperability justice. */ |
|
1fd36e207795
jabber: Wrap XHTML-IM messages in <p/> for greater interoperability justice. Closes #11253
Paul Aurich <darkrain42@pidgin.im>
parents:
28996
diff
changeset
|
1190 | jm->xhtml = g_strdup_printf("<html xmlns='" NS_XHTML_IM "'><body xmlns='" NS_XHTML "'><p>%s</p></body></html>", xhtml); |
|
27746
4b3f015977d9
For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
1191 | } |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1192 | |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1193 | g_free(xhtml); |
| 7014 | 1194 | |
| 1195 | jabber_message_send(jm); | |
| 1196 | jabber_message_free(jm); | |
| 1197 | return 1; | |
| 1198 | } | |
| 1199 | ||
| 15884 | 1200 | int jabber_message_send_chat(PurpleConnection *gc, int id, const char *msg, PurpleMessageFlags flags) |
| 7014 | 1201 | { |
| 1202 | JabberChat *chat; | |
| 1203 | JabberMessage *jm; | |
| 8042 | 1204 | JabberStream *js; |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1205 | char *xhtml; |
|
27110
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27103
diff
changeset
|
1206 | char *tmp; |
| 7014 | 1207 | |
| 8042 | 1208 | if(!msg || !gc) |
| 7014 | 1209 | return 0; |
| 1210 | ||
|
32277
97f16af01a05
Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
31512
diff
changeset
|
1211 | js = purple_connection_get_protocol_data(gc); |
| 7014 | 1212 | chat = jabber_chat_find_by_id(js, id); |
| 1213 | ||
| 8043 | 1214 | if(!chat) |
| 1215 | return 0; | |
| 1216 | ||
| 9130 | 1217 | jm = g_new0(JabberMessage, 1); |
|
32277
97f16af01a05
Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
31512
diff
changeset
|
1218 | jm->js = purple_connection_get_protocol_data(gc); |
| 9130 | 1219 | jm->type = JABBER_MESSAGE_GROUPCHAT; |
| 1220 | jm->to = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 13484 | 1221 | jm->id = jabber_get_next_id(jm->js); |
| 9130 | 1222 | |
|
27237
0643ac0e5658
Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages.
Paul Aurich <darkrain42@pidgin.im>
parents:
27155
diff
changeset
|
1223 | tmp = purple_utf8_strip_unprintables(msg); |
|
28534
df58e9ce5eca
Oops, it helps to actually use the stripped message.
Paul Aurich <darkrain42@pidgin.im>
parents:
28442
diff
changeset
|
1224 | purple_markup_html_to_xhtml(tmp, &xhtml, &jm->body); |
|
27237
0643ac0e5658
Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages.
Paul Aurich <darkrain42@pidgin.im>
parents:
27155
diff
changeset
|
1225 | g_free(tmp); |
|
27110
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27103
diff
changeset
|
1226 | tmp = jabber_message_smileyfy_xhtml(jm, xhtml); |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27103
diff
changeset
|
1227 | if (tmp) { |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27103
diff
changeset
|
1228 | g_free(xhtml); |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27103
diff
changeset
|
1229 | xhtml = tmp; |
|
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27103
diff
changeset
|
1230 | } |
| 8858 | 1231 | |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1232 | if (chat->xhtml && !jabber_xhtml_plain_equal(xhtml, jm->body)) |
|
29229
1fd36e207795
jabber: Wrap XHTML-IM messages in <p/> for greater interoperability justice. Closes #11253
Paul Aurich <darkrain42@pidgin.im>
parents:
28996
diff
changeset
|
1233 | /* Wrap the message in <p/> for greater interoperability justice. */ |
|
1fd36e207795
jabber: Wrap XHTML-IM messages in <p/> for greater interoperability justice. Closes #11253
Paul Aurich <darkrain42@pidgin.im>
parents:
28996
diff
changeset
|
1234 | jm->xhtml = g_strdup_printf("<html xmlns='" NS_XHTML_IM "'><body xmlns='" NS_XHTML "'><p>%s</p></body></html>", xhtml); |
|
27061
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1235 | |
|
b1bfbf77cf90
Only include XHTML payload in XMPP message when it's needed. Closes #8738.
Paul Aurich <darkrain42@pidgin.im>
parents:
26984
diff
changeset
|
1236 | g_free(xhtml); |
| 7923 | 1237 | |
| 9130 | 1238 | jabber_message_send(jm); |
| 1239 | jabber_message_free(jm); | |
| 1240 | ||
| 7014 | 1241 | return 1; |
| 1242 | } | |
| 1243 | ||
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34634
diff
changeset
|
1244 | unsigned int jabber_send_typing(PurpleConnection *gc, const char *who, PurpleIMTypingState state) |
| 7014 | 1245 | { |
|
30454
4e9bf65cfe9a
jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents:
30239
diff
changeset
|
1246 | JabberStream *js; |
| 7014 | 1247 | JabberMessage *jm; |
| 1248 | JabberBuddy *jb; | |
| 1249 | JabberBuddyResource *jbr; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30744
diff
changeset
|
1250 | char *resource; |
| 7014 | 1251 | |
|
30454
4e9bf65cfe9a
jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents:
30239
diff
changeset
|
1252 | js = purple_connection_get_protocol_data(gc); |
|
4e9bf65cfe9a
jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents:
30239
diff
changeset
|
1253 | jb = jabber_buddy_find(js, who, TRUE); |
|
4e9bf65cfe9a
jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents:
30239
diff
changeset
|
1254 | if (!jb) |
|
4e9bf65cfe9a
jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents:
30239
diff
changeset
|
1255 | return 0; |
|
4e9bf65cfe9a
jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents:
30239
diff
changeset
|
1256 | |
|
4e9bf65cfe9a
jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents:
30239
diff
changeset
|
1257 | resource = jabber_get_resource(who); |
| 7306 | 1258 | jbr = jabber_buddy_find_resource(jb, resource); |
| 1259 | g_free(resource); | |
| 7014 | 1260 | |
|
30235
d37c441d6a48
jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <darkrain42@pidgin.im>
parents:
30121
diff
changeset
|
1261 | /* We know this entity doesn't support chat states */ |
|
d37c441d6a48
jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <darkrain42@pidgin.im>
parents:
30121
diff
changeset
|
1262 | if (jbr && jbr->chat_states == JABBER_CHAT_STATES_UNSUPPORTED) |
|
d37c441d6a48
jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <darkrain42@pidgin.im>
parents:
30121
diff
changeset
|
1263 | return 0; |
|
d37c441d6a48
jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <darkrain42@pidgin.im>
parents:
30121
diff
changeset
|
1264 | |
|
d37c441d6a48
jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <darkrain42@pidgin.im>
parents:
30121
diff
changeset
|
1265 | /* *If* we don't have presence /and/ the buddy can't see our |
|
d37c441d6a48
jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <darkrain42@pidgin.im>
parents:
30121
diff
changeset
|
1266 | * presence, don't send typing notifications. |
|
d37c441d6a48
jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <darkrain42@pidgin.im>
parents:
30121
diff
changeset
|
1267 | */ |
|
d37c441d6a48
jabber: Send typing notifications to a buddy when it can see our presence
Paul Aurich <darkrain42@pidgin.im>
parents:
30121
diff
changeset
|
1268 | if (!jbr && !(jb->subscription & JABBER_SUB_FROM)) |
| 7014 | 1269 | return 0; |
| 1270 | ||
| 13708 | 1271 | /* TODO: figure out threading */ |
| 7014 | 1272 | jm = g_new0(JabberMessage, 1); |
|
30454
4e9bf65cfe9a
jabber: Fix a crash when sending typing notifications to a malformed buddy
Paul Aurich <darkrain42@pidgin.im>
parents:
30239
diff
changeset
|
1273 | jm->js = js; |
| 7014 | 1274 | jm->type = JABBER_MESSAGE_CHAT; |
| 1275 | jm->to = g_strdup(who); | |
| 13484 | 1276 | jm->id = jabber_get_next_id(jm->js); |
| 7014 | 1277 | |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34634
diff
changeset
|
1278 | if(PURPLE_IM_TYPING == state) |
| 13708 | 1279 | jm->chat_state = JM_STATE_COMPOSING; |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34634
diff
changeset
|
1280 | else if(PURPLE_IM_TYPED == state) |
| 13708 | 1281 | jm->chat_state = JM_STATE_PAUSED; |
| 1282 | else | |
| 1283 | jm->chat_state = JM_STATE_ACTIVE; | |
| 1284 | ||
|
27429
3313d7d74962
Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
1285 | /* if(JABBER_CHAT_STATES_UNKNOWN == jbr->chat_states) |
|
3313d7d74962
Remove code for obsoleted XEP-0022 (Message Events)
Paul Aurich <darkrain42@pidgin.im>
parents:
27237
diff
changeset
|
1286 | jbr->chat_states = JABBER_CHAT_STATES_UNSUPPORTED; */ |
| 7014 | 1287 | |
| 1288 | jabber_message_send(jm); | |
| 1289 | jabber_message_free(jm); | |
| 1290 | ||
| 13708 | 1291 | return 0; |
| 7014 | 1292 | } |
| 1293 | ||
|
23586
e495a4623f76
Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23249
diff
changeset
|
1294 | gboolean jabber_buzz_isenabled(JabberStream *js, const gchar *namespace) { |
|
17824
52683dfc1f7d
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents:
17823
diff
changeset
|
1295 | return js->allowBuzz; |
|
52683dfc1f7d
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents:
17823
diff
changeset
|
1296 | } |
|
52683dfc1f7d
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents:
17823
diff
changeset
|
1297 | |
|
24715
69aaae59e205
Fix compilation errors and many warnings
Paul Aurich <darkrain42@pidgin.im>
parents:
24714
diff
changeset
|
1298 | gboolean jabber_custom_smileys_isenabled(JabberStream *js, const gchar *namespace) |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1299 | { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1300 | const PurpleConnection *gc = js->gc; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1301 | PurpleAccount *account = purple_connection_get_account(gc); |
|
23627
dbdc407798af
A couple of leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23626
diff
changeset
|
1302 | |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1303 | return purple_account_get_bool(account, "custom_smileys", TRUE); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1304 | } |