Thu, 11 Sep 2008 19:12:39 +0000
Added a workaround for receiving smileys from Jabbim,
which uses the "cid" string as the "alt" attribute on <img/>s
resulting in the smiley shortcut being formatted as a mailto: link.
This reformats incoming shortcuts if the are formed as email addresses.
Also, we don't need to escape the incoming text, as it is an XML attribute
| 7014 | 1 | /* |
| 15884 | 2 | * purple - Jabber Protocol Plugin |
| 7014 | 3 | * |
| 4 | * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com> | |
| 5 | * | |
| 6 | * This program is free software; you can redistribute it and/or modify | |
| 7 | * it under the terms of the GNU General Public License as published by | |
| 8 | * the Free Software Foundation; either version 2 of the License, or | |
| 9 | * (at your option) any later version. | |
| 10 | * | |
| 11 | * This program is distributed in the hope that it will be useful, | |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | * GNU General Public License for more details. | |
| 15 | * | |
| 16 | * You should have received a copy of the GNU General Public License | |
| 17 | * 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
|
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 7014 | 19 | * |
| 20 | */ | |
| 21 | #include "internal.h" | |
| 22 | ||
| 23 | #include "debug.h" | |
| 24 | #include "notify.h" | |
| 25 | #include "server.h" | |
|
7095
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7014
diff
changeset
|
26 | #include "util.h" |
| 7014 | 27 | #include "buddy.h" |
| 28 | #include "chat.h" | |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
29 | #include "data.h" |
|
15587
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
30 | #include "google.h" |
| 7014 | 31 | #include "message.h" |
| 32 | #include "xmlnode.h" | |
|
17768
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
17351
diff
changeset
|
33 | #include "pep.h" |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
34 | #include "smiley.h" |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
35 | #include "iq.h" |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
36 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
37 | #include <string.h> |
| 7014 | 38 | |
| 39 | void jabber_message_free(JabberMessage *jm) | |
| 40 | { | |
| 15980 | 41 | g_free(jm->from); |
| 13484 | 42 | g_free(jm->to); |
| 43 | g_free(jm->id); | |
| 44 | g_free(jm->subject); | |
| 45 | g_free(jm->body); | |
| 46 | g_free(jm->xhtml); | |
| 47 | g_free(jm->password); | |
|
20057
728a7dce565e
grab revision 41389df89a4a6a007d41cec33e33043cd41ea159
Luke Schierer <lschiere@pidgin.im>
parents:
19917
diff
changeset
|
48 | g_free(jm->error); |
|
728a7dce565e
grab revision 41389df89a4a6a007d41cec33e33043cd41ea159
Luke Schierer <lschiere@pidgin.im>
parents:
19917
diff
changeset
|
49 | g_free(jm->thread_id); |
| 13484 | 50 | g_list_free(jm->etc); |
|
20057
728a7dce565e
grab revision 41389df89a4a6a007d41cec33e33043cd41ea159
Luke Schierer <lschiere@pidgin.im>
parents:
19917
diff
changeset
|
51 | g_list_free(jm->eventitems); |
| 7014 | 52 | |
| 53 | g_free(jm); | |
| 54 | } | |
| 55 | ||
| 7145 | 56 | static void handle_chat(JabberMessage *jm) |
| 7014 | 57 | { |
| 58 | JabberID *jid = jabber_id_new(jm->from); | |
| 59 | char *from; | |
| 60 | ||
| 61 | JabberBuddy *jb; | |
| 62 | JabberBuddyResource *jbr; | |
| 63 | ||
| 7310 | 64 | if(!jid) |
| 65 | return; | |
| 66 | ||
| 7014 | 67 | jb = jabber_buddy_find(jm->js, jm->from, TRUE); |
| 7306 | 68 | jbr = jabber_buddy_find_resource(jb, jid->resource); |
| 7014 | 69 | |
| 8043 | 70 | if(jabber_find_unnormalized_conv(jm->from, jm->js->gc->account)) { |
| 7014 | 71 | from = g_strdup(jm->from); |
| 7258 | 72 | } else if(jid->node) { |
| 10490 | 73 | if(jid->resource) { |
| 15884 | 74 | PurpleConversation *conv; |
| 7258 | 75 | |
| 10490 | 76 | from = g_strdup_printf("%s@%s", jid->node, jid->domain); |
| 15884 | 77 | conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, from, jm->js->gc->account); |
| 10490 | 78 | if(conv) { |
| 15884 | 79 | purple_conversation_set_name(conv, jm->from); |
| 13304 | 80 | } |
| 10490 | 81 | g_free(from); |
| 82 | } | |
| 7258 | 83 | from = g_strdup(jm->from); |
| 84 | } else { | |
| 7014 | 85 | from = g_strdup(jid->domain); |
| 7258 | 86 | } |
| 7014 | 87 | |
| 88 | if(!jm->xhtml && !jm->body) { | |
|
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
|
89 | if(JM_STATE_COMPOSING == jm->chat_state) { |
| 15884 | 90 | serv_got_typing(jm->js->gc, from, 0, PURPLE_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
|
91 | } else if(JM_STATE_PAUSED == jm->chat_state) { |
| 15884 | 92 | serv_got_typing(jm->js->gc, from, 0, PURPLE_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
|
93 | } else if(JM_STATE_GONE == jm->chat_state) { |
| 15884 | 94 | PurpleConversation *conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, |
|
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
|
95 | from, jm->js->gc->account); |
|
15721
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
96 | if (conv && 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
|
97 | char buf[256]; |
| 15884 | 98 | 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
|
99 | |
|
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
100 | 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
|
101 | |
| 15884 | 102 | if ((buddy = purple_find_buddy(jm->js->gc->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
|
103 | 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
|
104 | char *escaped; |
|
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
105 | |
| 15884 | 106 | 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
|
107 | 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
|
108 | |
|
8b054202d398
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@pidgin.im>
parents:
15710
diff
changeset
|
109 | g_snprintf(buf, sizeof(buf), |
| 16946 | 110 | _("%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
|
111 | 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
|
112 | |
| 15884 | 113 | /* 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
|
114 | * 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
|
115 | * user from the conversation like we do with chats now. */ |
| 15884 | 116 | purple_conversation_write(conv, "", buf, |
| 117 | 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
|
118 | } |
|
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
|
119 | } |
| 7014 | 120 | serv_got_typing_stopped(jm->js->gc, 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
|
121 | |
|
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
|
122 | } else { |
|
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
|
123 | serv_got_typing_stopped(jm->js->gc, from); |
|
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
|
124 | } |
| 7014 | 125 | } else { |
| 8400 | 126 | if(jbr) { |
| 13708 | 127 | if(JM_TS_JEP_0085 == (jm->typing_style & JM_TS_JEP_0085)) { |
| 128 | jbr->chat_states = JABBER_CHAT_STATES_SUPPORTED; | |
| 129 | } else { | |
| 130 | jbr->chat_states = JABBER_CHAT_STATES_UNSUPPORTED; | |
| 131 | } | |
| 132 | ||
| 133 | if(JM_TS_JEP_0022 == (jm->typing_style & JM_TS_JEP_0022)) { | |
| 8400 | 134 | jbr->capabilities |= JABBER_CAP_COMPOSING; |
| 13708 | 135 | } |
| 136 | ||
| 8400 | 137 | if(jbr->thread_id) |
| 138 | g_free(jbr->thread_id); | |
| 139 | jbr->thread_id = g_strdup(jbr->thread_id); | |
| 140 | } | |
|
15587
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
141 | |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
142 | 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
|
143 | char *tmp = jm->body; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
144 | 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
|
145 | g_free(tmp); |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
146 | } |
| 7014 | 147 | serv_got_im(jm->js->gc, from, jm->xhtml ? jm->xhtml : jm->body, 0, |
| 148 | jm->sent); | |
| 149 | } | |
| 150 | ||
| 13708 | 151 | |
| 7014 | 152 | g_free(from); |
| 153 | jabber_id_free(jid); | |
| 154 | } | |
| 155 | ||
| 7145 | 156 | static void handle_headline(JabberMessage *jm) |
| 157 | { | |
| 158 | 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
|
159 | GString *body; |
| 7145 | 160 | GList *etc; |
| 161 | ||
|
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
|
162 | 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
|
163 | return; /* ignore headlines without any content */ |
| 7145 | 164 | |
|
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
|
165 | body = g_string_new(""); |
| 7145 | 166 | title = g_strdup_printf(_("Message from %s"), jm->from); |
| 167 | ||
| 168 | if(jm->xhtml) | |
| 169 | g_string_append(body, jm->xhtml); | |
| 170 | else if(jm->body) | |
| 171 | g_string_append(body, jm->body); | |
| 172 | ||
| 173 | for(etc = jm->etc; etc; etc = etc->next) { | |
| 174 | xmlnode *x = etc->data; | |
| 13808 | 175 | const char *xmlns = xmlnode_get_namespace(x); |
| 7145 | 176 | if(xmlns && !strcmp(xmlns, "jabber:x:oob")) { |
| 177 | xmlnode *url, *desc; | |
| 178 | char *urltxt, *desctxt; | |
| 179 | ||
| 180 | url = xmlnode_get_child(x, "url"); | |
| 181 | desc = xmlnode_get_child(x, "desc"); | |
| 182 | ||
| 183 | if(!url || !desc) | |
| 184 | continue; | |
| 185 | ||
| 186 | urltxt = xmlnode_get_data(url); | |
| 187 | desctxt = xmlnode_get_data(desc); | |
| 188 | ||
| 189 | /* I'm all about ugly hacks */ | |
|
14790
a0226bec3707
[gaim-migrate @ 17484]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14254
diff
changeset
|
190 | if(body->len && jm->body && !strcmp(body->str, jm->body)) |
| 7145 | 191 | g_string_printf(body, "<a href='%s'>%s</a>", |
| 192 | urltxt, desctxt); | |
| 193 | else | |
| 194 | g_string_append_printf(body, "<br/><a href='%s'>%s</a>", | |
| 195 | urltxt, desctxt); | |
| 196 | ||
| 197 | g_free(urltxt); | |
| 198 | g_free(desctxt); | |
| 199 | } | |
| 200 | } | |
| 201 | ||
| 15884 | 202 | purple_notify_formatted(jm->js->gc, title, jm->subject ? jm->subject : title, |
| 7145 | 203 | NULL, body->str, NULL, NULL); |
| 204 | ||
| 205 | g_free(title); | |
| 206 | g_string_free(body, TRUE); | |
| 207 | } | |
| 208 | ||
| 209 | static void handle_groupchat(JabberMessage *jm) | |
| 7014 | 210 | { |
| 211 | JabberID *jid = jabber_id_new(jm->from); | |
| 7310 | 212 | JabberChat *chat; |
| 213 | ||
| 214 | if(!jid) | |
| 215 | return; | |
| 216 | ||
| 217 | chat = jabber_chat_find(jm->js, jid->node, jid->domain); | |
| 7014 | 218 | |
| 219 | if(!chat) | |
| 220 | return; | |
| 221 | ||
| 7971 | 222 | if(jm->subject) { |
| 15884 | 223 | purple_conv_chat_set_topic(PURPLE_CONV_CHAT(chat->conv), jid->resource, |
| 7183 | 224 | jm->subject); |
| 7971 | 225 | if(!jm->xhtml && !jm->body) { |
| 9762 | 226 | char *msg, *tmp, *tmp2; |
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10607
diff
changeset
|
227 | tmp = g_markup_escape_text(jm->subject, -1); |
| 15884 | 228 | tmp2 = purple_markup_linkify(tmp); |
| 7971 | 229 | if(jid->resource) |
| 9762 | 230 | msg = g_strdup_printf(_("%s has set the topic to: %s"), jid->resource, tmp2); |
| 7971 | 231 | else |
| 9762 | 232 | msg = g_strdup_printf(_("The topic is: %s"), tmp2); |
| 15884 | 233 | purple_conv_chat_write(PURPLE_CONV_CHAT(chat->conv), "", msg, PURPLE_MESSAGE_SYSTEM, jm->sent); |
| 9762 | 234 | g_free(tmp); |
| 235 | g_free(tmp2); | |
| 7971 | 236 | g_free(msg); |
| 237 | } | |
| 238 | } | |
| 7014 | 239 | |
| 7630 | 240 | if(jm->xhtml || jm->body) { |
| 241 | if(jid->resource) | |
|
9584
1a6198375303
[gaim-migrate @ 10427]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9130
diff
changeset
|
242 | serv_got_chat_in(jm->js->gc, chat->id, jid->resource, |
| 15884 | 243 | jm->delayed ? PURPLE_MESSAGE_DELAYED : 0, |
| 7630 | 244 | jm->xhtml ? jm->xhtml : jm->body, jm->sent); |
| 245 | else if(chat->muc) | |
| 15884 | 246 | purple_conv_chat_write(PURPLE_CONV_CHAT(chat->conv), "", |
| 7630 | 247 | jm->xhtml ? jm->xhtml : jm->body, |
| 15884 | 248 | PURPLE_MESSAGE_SYSTEM, jm->sent); |
| 7630 | 249 | } |
| 250 | ||
| 7014 | 251 | jabber_id_free(jid); |
| 252 | } | |
| 253 | ||
| 7145 | 254 | static void handle_groupchat_invite(JabberMessage *jm) |
| 7014 | 255 | { |
| 7310 | 256 | GHashTable *components; |
| 7014 | 257 | JabberID *jid = jabber_id_new(jm->to); |
| 258 | ||
| 7310 | 259 | if(!jid) |
| 260 | return; | |
| 261 | ||
|
15598
834a88c83e95
Get rid of some unnecessary string duping
Mark Doliner <markdoliner@pidgin.im>
parents:
15587
diff
changeset
|
262 | components = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); |
| 7310 | 263 | |
|
15598
834a88c83e95
Get rid of some unnecessary string duping
Mark Doliner <markdoliner@pidgin.im>
parents:
15587
diff
changeset
|
264 | 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
|
265 | 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
|
266 | 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
|
267 | g_hash_table_replace(components, "password", g_strdup(jm->password)); |
| 7014 | 268 | |
| 269 | jabber_id_free(jid); | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10732
diff
changeset
|
270 | serv_got_chat_invite(jm->js->gc, jm->to, jm->from, jm->body, components); |
| 7014 | 271 | } |
| 272 | ||
| 7145 | 273 | static void handle_error(JabberMessage *jm) |
| 7014 | 274 | { |
| 275 | char *buf; | |
| 276 | ||
| 277 | if(!jm->body) | |
| 278 | return; | |
| 279 | ||
| 280 | buf = g_strdup_printf(_("Message delivery to %s failed: %s"), | |
|
13766
6b92ce47f7e5
[gaim-migrate @ 16176]
Daniel Atallah <datallah@pidgin.im>
parents:
13708
diff
changeset
|
281 | jm->from, jm->error ? jm->error : ""); |
| 7014 | 282 | |
|
16961
b6955f946f8f
s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@pidgin.im>
parents:
16946
diff
changeset
|
283 | purple_notify_formatted(jm->js->gc, _("XMPP Message Error"), _("XMPP Message Error"), buf, |
| 7944 | 284 | jm->xhtml ? jm->xhtml : jm->body, NULL, NULL); |
| 7014 | 285 | |
| 286 | g_free(buf); | |
| 287 | } | |
| 288 | ||
|
17822
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
289 | static void handle_buzz(JabberMessage *jm) { |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
290 | PurpleBuddy *buddy; |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
291 | PurpleAccount *account; |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
292 | PurpleConversation *c; |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
293 | char *username, *str; |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
294 | |
|
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
|
295 | /* 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
|
296 | 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
|
297 | return; |
|
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
|
298 | |
|
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
|
299 | /* 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
|
300 | 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
|
301 | return; |
|
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
|
302 | |
|
17822
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
303 | account = purple_connection_get_account(jm->js->gc); |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
304 | |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
305 | if ((buddy = purple_find_buddy(account, jm->from)) != NULL) |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
306 | username = g_markup_escape_text(purple_buddy_get_alias(buddy), -1); |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
307 | else |
|
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
|
308 | 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
|
309 | |
|
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
|
310 | c = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, jm->from); |
|
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
|
311 | |
|
19917
7b4afc4cb984
Make the XMPP buzz string match the Yahoo one to help the translators.
Richard Laager <rlaager@pidgin.im>
parents:
19897
diff
changeset
|
312 | str = g_strdup_printf(_("%s has buzzed you!"), username); |
|
17822
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
313 | |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
314 | purple_conversation_write(c, NULL, str, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NOTIFY, time(NULL)); |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
315 | g_free(username); |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
316 | g_free(str); |
|
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 |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
327 | jabber_message_get_refs_from_xmlnode_internal(const xmlnode *message, |
|
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 | { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
330 | xmlnode *child; |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
331 | |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
332 | for (child = xmlnode_get_child(message, "img") ; child ; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
333 | child = xmlnode_get_next_twin(child)) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
334 | const gchar *src = xmlnode_get_attrib(child, "src"); |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
335 | |
|
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; |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
338 | |
|
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); |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
344 | const gchar *alt = xmlnode_get_attrib(child, "alt"); |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
345 | ref->cid = temp_cid; |
|
24258
9ae10fafad7a
When receiving an <img/> without the "alt" attribute, set
Marcus Lundblad <malu@pidgin.im>
parents:
24257
diff
changeset
|
346 | /* if there is no "alt" string, use the cid... |
|
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)) { |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
353 | ref->alt = g_strdup_printf("smiley:%s", alt); |
|
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 | } |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
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; |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
375 | |
|
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); |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
377 | |
|
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 * |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
382 | jabber_message_get_refs_from_xmlnode(const xmlnode *message) |
|
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); |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
386 | |
|
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); |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
388 | (void) g_hash_table_foreach_steal(unique_refs, |
|
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 * |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
395 | jabber_message_xml_to_string_strip_img_smileys(xmlnode *xhtml) |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
396 | { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
397 | const gchar *markup = xmlnode_to_str(xhtml, NULL); |
|
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")) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
407 | xmlnode *img = NULL; |
|
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, |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
423 | in which case xmlnode_from_str will bail out and return NULL, |
|
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 */ |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
426 | img = xmlnode_from_str(&(markup[pos]), pos2 - pos); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
427 | src = xmlnode_get_attrib(img, "src"); |
|
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:")) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
430 | const gchar *alt = 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 | gchar *escaped = NULL; |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
432 | /* 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
|
433 | if (alt && alt[0] != '\0') { |
|
24259
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
434 | /* 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
|
435 | this prevents linkification... */ |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
436 | if (purple_email_is_valid(alt)) { |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
437 | const gchar *safe_alt = g_strdup_printf("smiley:%s", alt); |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
438 | 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
|
439 | g_free(safe_alt); |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
440 | } else { |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
441 | out = g_string_append(out, alt); |
|
e69d72917038
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <malu@pidgin.im>
parents:
24258
diff
changeset
|
442 | } |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
443 | } else { |
|
24258
9ae10fafad7a
When receiving an <img/> without the "alt" attribute, set
Marcus Lundblad <malu@pidgin.im>
parents:
24257
diff
changeset
|
444 | 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
|
445 | } |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
446 | pos += pos2 - pos; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
447 | } else { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
448 | 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
|
449 | pos++; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
450 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
451 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
452 | xmlnode_free(img); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
453 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
454 | } else { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
455 | 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
|
456 | pos++; |
|
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 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
459 | |
|
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 |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
464 | jabber_message_add_remote_smileys(const xmlnode *message) |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
465 | { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
466 | xmlnode *data_tag; |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
467 | for (data_tag = xmlnode_get_child_with_namespace(message, "data", XEP_0231_NAMESPACE) ; |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
468 | data_tag ; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
469 | data_tag = xmlnode_get_next_twin(data_tag)) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
470 | const gchar *cid = xmlnode_get_attrib(data_tag, "cid"); |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
471 | const JabberData *data = jabber_data_find_remote_by_cid(cid); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
472 | |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
473 | 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
|
474 | /* 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
|
475 | JabberData *new_data = jabber_data_create_from_xml(data_tag); |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
476 | jabber_data_associate_remote(new_data); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
477 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
478 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
479 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
480 | |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
481 | /* used in the function below to supply a conversation and shortcut for a |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
482 | smiley */ |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
483 | typedef struct { |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
484 | PurpleConversation *conv; |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
485 | const gchar *alt; |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
486 | } JabberDataRef; |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
487 | |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
488 | static void |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
489 | jabber_message_get_data_cb(JabberStream *js, xmlnode *packet, gpointer data) |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
490 | { |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
491 | JabberDataRef *ref = (JabberDataRef *) data; |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
492 | PurpleConversation *conv = ref->conv; |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
493 | const gchar *alt = ref->alt; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
494 | xmlnode *data_element = xmlnode_get_child(packet, "data"); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
495 | xmlnode *item_not_found = xmlnode_get_child(packet, "item-not-found"); |
|
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 | /* did we get a data element as result? */ |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
498 | if (data_element) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
499 | JabberData *data = jabber_data_create_from_xml(data_element); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
500 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
501 | if (data) { |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
502 | jabber_data_associate_remote(data); |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
503 | purple_conv_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
|
504 | 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
|
505 | jabber_data_get_size(data)); |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
506 | purple_conv_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
|
507 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
508 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
509 | } else if (item_not_found) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
510 | purple_debug_info("jabber", |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
511 | "Responder didn't recognize requested data\n"); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
512 | } else { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
513 | purple_debug_error("jabber", "Unknown response to data request\n"); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
514 | } |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
515 | |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
516 | g_free(ref); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
517 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
518 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
519 | static void |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
520 | jabber_message_send_data_request(JabberStream *js, PurpleConversation *conv, |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
521 | const gchar *cid, const gchar *who, |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
522 | const gchar *alt) |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
523 | { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
524 | JabberIq *request = jabber_iq_new(js, JABBER_IQ_GET); |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
525 | JabberDataRef *ref = g_new0(JabberDataRef, 1); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
526 | xmlnode *data_request = jabber_data_get_xml_request(cid); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
527 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
528 | xmlnode_set_attrib(request->node, "to", who); |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
529 | ref->conv = conv; |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
530 | ref->alt = alt; |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
531 | jabber_iq_set_callback(request, jabber_message_get_data_cb, ref); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
532 | xmlnode_insert_child(request->node, data_request); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
533 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
534 | jabber_iq_send(request); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
535 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
536 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
537 | |
| 7014 | 538 | void jabber_message_parse(JabberStream *js, xmlnode *packet) |
| 539 | { | |
| 540 | JabberMessage *jm; | |
| 541 | const char *type; | |
| 542 | xmlnode *child; | |
| 543 | ||
| 544 | jm = g_new0(JabberMessage, 1); | |
| 545 | jm->js = js; | |
| 546 | jm->sent = time(NULL); | |
|
9584
1a6198375303
[gaim-migrate @ 10427]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9130
diff
changeset
|
547 | jm->delayed = FALSE; |
| 7014 | 548 | |
| 549 | type = xmlnode_get_attrib(packet, "type"); | |
| 550 | ||
| 551 | if(type) { | |
| 552 | if(!strcmp(type, "normal")) | |
| 553 | jm->type = JABBER_MESSAGE_NORMAL; | |
|
20169
497e1cd1e059
Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents:
20057
diff
changeset
|
554 | else if(!strcmp(type, "chat")) |
| 7014 | 555 | jm->type = JABBER_MESSAGE_CHAT; |
| 556 | else if(!strcmp(type, "groupchat")) | |
| 557 | jm->type = JABBER_MESSAGE_GROUPCHAT; | |
| 558 | else if(!strcmp(type, "headline")) | |
| 559 | jm->type = JABBER_MESSAGE_HEADLINE; | |
| 560 | else if(!strcmp(type, "error")) | |
| 561 | jm->type = JABBER_MESSAGE_ERROR; | |
| 562 | else | |
| 563 | jm->type = JABBER_MESSAGE_OTHER; | |
| 564 | } else { | |
| 565 | jm->type = JABBER_MESSAGE_NORMAL; | |
| 566 | } | |
| 567 | ||
| 568 | jm->from = g_strdup(xmlnode_get_attrib(packet, "from")); | |
| 569 | jm->to = g_strdup(xmlnode_get_attrib(packet, "to")); | |
| 13484 | 570 | jm->id = g_strdup(xmlnode_get_attrib(packet, "id")); |
| 7014 | 571 | |
| 572 | for(child = packet->child; child; child = child->next) { | |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17776
diff
changeset
|
573 | const char *xmlns = xmlnode_get_namespace(child); |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17776
diff
changeset
|
574 | if(!xmlns) |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17776
diff
changeset
|
575 | xmlns = ""; |
| 8135 | 576 | if(child->type != XMLNODE_TYPE_TAG) |
| 7014 | 577 | continue; |
| 578 | ||
|
17792
d2023e27affd
Fixed a bug that resulted in not being able to receive any messages.
Andreas Monitzer <am@adiumx.com>
parents:
17780
diff
changeset
|
579 | if(!strcmp(child->name, "subject") && !strcmp(xmlns,"jabber:client")) { |
| 7014 | 580 | if(!jm->subject) |
| 581 | jm->subject = xmlnode_get_data(child); | |
|
17792
d2023e27affd
Fixed a bug that resulted in not being able to receive any messages.
Andreas Monitzer <am@adiumx.com>
parents:
17780
diff
changeset
|
582 | } else if(!strcmp(child->name, "thread") && !strcmp(xmlns,"jabber:client")) { |
| 8400 | 583 | if(!jm->thread_id) |
| 584 | jm->thread_id = xmlnode_get_data(child); | |
|
17792
d2023e27affd
Fixed a bug that resulted in not being able to receive any messages.
Andreas Monitzer <am@adiumx.com>
parents:
17780
diff
changeset
|
585 | } else if(!strcmp(child->name, "body") && !strcmp(xmlns,"jabber:client")) { |
| 13385 | 586 | if(!jm->body) { |
| 587 | char *msg = xmlnode_to_str(child, NULL); | |
| 15884 | 588 | jm->body = purple_strdup_withhtml(msg); |
| 13385 | 589 | g_free(msg); |
| 590 | } | |
|
17768
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
17351
diff
changeset
|
591 | } else if(!strcmp(child->name, "html") && !strcmp(xmlns,"http://jabber.org/protocol/xhtml-im")) { |
|
17328
7a5668fb7bad
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents:
16961
diff
changeset
|
592 | if(!jm->xhtml && xmlnode_get_child(child, "body")) { |
|
7a5668fb7bad
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents:
16961
diff
changeset
|
593 | char *c; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
594 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
595 | 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
|
596 | const gchar *who = xmlnode_get_attrib(packet, "from"); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
597 | 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
|
598 | PurpleConversation *conv = NULL; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
599 | const GList *smiley_refs = NULL; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
600 | gchar *reformatted_xhtml; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
601 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
602 | 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
|
603 | /* 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
|
604 | occuring in the message */ |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
605 | 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
|
606 | 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
|
607 | g_list_length(smiley_refs)); |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
608 | |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
609 | if (jm->type == JABBER_MESSAGE_GROUPCHAT) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
610 | JabberID *jid = jabber_id_new(jm->from); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
611 | JabberChat *chat = NULL; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
612 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
613 | if (jid) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
614 | chat = jabber_chat_find(js, jid->node, jid->domain); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
615 | conv = chat->conv; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
616 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
617 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
618 | jabber_id_free(jid); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
619 | } else { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
620 | conv = |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
621 | purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
622 | who, account); |
|
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
|
623 | if (!conv) { |
|
d6402f066933
Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <malu@pidgin.im>
parents:
24254
diff
changeset
|
624 | /* we need to create the conversation here */ |
|
d6402f066933
Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <malu@pidgin.im>
parents:
24254
diff
changeset
|
625 | conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, |
|
d6402f066933
Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <malu@pidgin.im>
parents:
24254
diff
changeset
|
626 | account, who); |
|
d6402f066933
Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <malu@pidgin.im>
parents:
24254
diff
changeset
|
627 | } |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
628 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
629 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
630 | /* process any newly provided smileys */ |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
631 | jabber_message_add_remote_smileys(packet); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
632 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
633 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
634 | /* 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
|
635 | 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
|
636 | /* 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
|
637 | 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
|
638 | reformatted_xhtml = |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
639 | 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
|
640 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
641 | jm->xhtml = reformatted_xhtml; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
642 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
643 | /* 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
|
644 | /* 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
|
645 | 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
|
646 | be NULL */ |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
647 | for (; smiley_refs ; smiley_refs = g_list_next(smiley_refs)) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
648 | const JabberSmileyRef *ref = |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
649 | (JabberSmileyRef *) smiley_refs->data; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
650 | const gchar *cid = ref->cid; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
651 | const gchar *alt = ref->alt; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
652 | |
|
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
|
653 | 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
|
654 | "about to add custom smiley %s to the conv\n", alt); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
655 | if (purple_conv_custom_smiley_add(conv, alt, "cid", cid, |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
656 | TRUE)) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
657 | const JabberData *data = |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
658 | jabber_data_find_remote_by_cid(cid); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
659 | /* if data is already known, we add write it immediatly */ |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
660 | if (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
|
661 | 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
|
662 | "data is already known\n"); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
663 | purple_conv_custom_smiley_write(conv, alt, |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
664 | 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
|
665 | jabber_data_get_size(data)); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
666 | purple_conv_custom_smiley_close(conv, alt); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
667 | } else { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
668 | /* 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
|
669 | 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
|
670 | "data is unknown, need to request it\n"); |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
671 | jabber_message_send_data_request(js, conv, cid, who, |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
672 | alt); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
673 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
674 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
675 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
676 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
677 | /* 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
|
678 | * 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
|
679 | */ |
|
7a5668fb7bad
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents:
16961
diff
changeset
|
680 | 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
|
681 | if (*c == '\n') |
|
17328
7a5668fb7bad
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents:
16961
diff
changeset
|
682 | *c = ' '; |
|
7a5668fb7bad
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents:
16961
diff
changeset
|
683 | } |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
684 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
685 | /* we don't need the list of CIDs anymore */ |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
686 | for (; smiley_refs ; smiley_refs = g_list_next(smiley_refs)) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
687 | JabberSmileyRef *ref = (JabberSmileyRef *) smiley_refs->data; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
688 | g_free(ref->cid); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
689 | g_free(ref->alt); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
690 | g_free(ref); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
691 | } |
|
17328
7a5668fb7bad
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents:
16961
diff
changeset
|
692 | } |
|
17768
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
17351
diff
changeset
|
693 | } else if(!strcmp(child->name, "active") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) { |
| 13708 | 694 | jm->chat_state = JM_STATE_ACTIVE; |
| 695 | jm->typing_style |= JM_TS_JEP_0085; | |
|
17768
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
17351
diff
changeset
|
696 | } else if(!strcmp(child->name, "composing") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) { |
| 13708 | 697 | jm->chat_state = JM_STATE_COMPOSING; |
| 698 | jm->typing_style |= JM_TS_JEP_0085; | |
|
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; |
| 701 | jm->typing_style |= JM_TS_JEP_0085; | |
|
17768
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
17351
diff
changeset
|
702 | } else if(!strcmp(child->name, "inactive") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) { |
| 13708 | 703 | jm->chat_state = JM_STATE_INACTIVE; |
| 704 | jm->typing_style |= JM_TS_JEP_0085; | |
|
17768
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
17351
diff
changeset
|
705 | } else if(!strcmp(child->name, "gone") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) { |
| 13708 | 706 | jm->chat_state = JM_STATE_GONE; |
| 707 | jm->typing_style |= JM_TS_JEP_0085; | |
|
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
|
708 | } else if(!strcmp(child->name, "event") && !strcmp(xmlns,"http://jabber.org/protocol/pubsub#event")) { |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17776
diff
changeset
|
709 | xmlnode *items; |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17776
diff
changeset
|
710 | jm->type = JABBER_MESSAGE_EVENT; |
|
17780
749862fd4a87
Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents:
17779
diff
changeset
|
711 | for(items = 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
|
712 | jm->eventitems = g_list_append(jm->eventitems, items); |
|
18996
9c15c80fec2a
Updated attention namespace to adhere to my new XEP-0224: Attention
Andreas Monitzer <am@adiumx.com>
parents:
17824
diff
changeset
|
713 | } else if(!strcmp(child->name, "attention") && !strcmp(xmlns,"http://www.xmpp.org/extensions/xep-0224.html#ns")) { |
|
17822
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
714 | jm->hasBuzz = TRUE; |
| 7014 | 715 | } else if(!strcmp(child->name, "error")) { |
| 716 | const char *code = xmlnode_get_attrib(child, "code"); | |
| 717 | char *code_txt = NULL; | |
| 718 | char *text = xmlnode_get_data(child); | |
|
23240
e8e5763bfe8e
If we receive a "text" child for an error, include it as the message text
Evan Schoenberg <evands@pidgin.im>
parents:
21453
diff
changeset
|
719 | if (!text) { |
|
e8e5763bfe8e
If we receive a "text" child for an error, include it as the message text
Evan Schoenberg <evands@pidgin.im>
parents:
21453
diff
changeset
|
720 | xmlnode *enclosed_text_node; |
|
e8e5763bfe8e
If we receive a "text" child for an error, include it as the message text
Evan Schoenberg <evands@pidgin.im>
parents:
21453
diff
changeset
|
721 | |
|
e8e5763bfe8e
If we receive a "text" child for an error, include it as the message text
Evan Schoenberg <evands@pidgin.im>
parents:
21453
diff
changeset
|
722 | if ((enclosed_text_node = xmlnode_get_child(child, "text"))) |
|
e8e5763bfe8e
If we receive a "text" child for an error, include it as the message text
Evan Schoenberg <evands@pidgin.im>
parents:
21453
diff
changeset
|
723 | text = xmlnode_get_data(enclosed_text_node); |
|
e8e5763bfe8e
If we receive a "text" child for an error, include it as the message text
Evan Schoenberg <evands@pidgin.im>
parents:
21453
diff
changeset
|
724 | } |
| 7014 | 725 | |
| 726 | if(code) | |
|
23244
b785fbd09111
Don't include the space in the localized text at all for the text/code error separation
Evan Schoenberg <evands@pidgin.im>
parents:
23243
diff
changeset
|
727 | code_txt = g_strdup_printf(_("(Code %s)"), code); |
| 7014 | 728 | |
| 729 | if(!jm->error) | |
|
23244
b785fbd09111
Don't include the space in the localized text at all for the text/code error separation
Evan Schoenberg <evands@pidgin.im>
parents:
23243
diff
changeset
|
730 | jm->error = g_strdup_printf("%s%s%s", |
|
b785fbd09111
Don't include the space in the localized text at all for the text/code error separation
Evan Schoenberg <evands@pidgin.im>
parents:
23243
diff
changeset
|
731 | text ? text : "", |
| 23249 | 732 | text && code_txt ? " " : "", |
| 7014 | 733 | code_txt ? code_txt : ""); |
| 734 | ||
| 735 | g_free(code_txt); | |
| 736 | g_free(text); | |
|
17811
d9a7ec9277f6
Implemented XEP-0203: Delayed Delivery
Andreas Monitzer <am@adiumx.com>
parents:
17792
diff
changeset
|
737 | } else if(!strcmp(child->name, "delay") && xmlns && !strcmp(xmlns,"urn:xmpp:delay")) { |
|
d9a7ec9277f6
Implemented XEP-0203: Delayed Delivery
Andreas Monitzer <am@adiumx.com>
parents:
17792
diff
changeset
|
738 | const char *timestamp = xmlnode_get_attrib(child, "stamp"); |
|
d9a7ec9277f6
Implemented XEP-0203: Delayed Delivery
Andreas Monitzer <am@adiumx.com>
parents:
17792
diff
changeset
|
739 | jm->delayed = TRUE; |
|
d9a7ec9277f6
Implemented XEP-0203: Delayed Delivery
Andreas Monitzer <am@adiumx.com>
parents:
17792
diff
changeset
|
740 | if(timestamp) |
|
d9a7ec9277f6
Implemented XEP-0203: Delayed Delivery
Andreas Monitzer <am@adiumx.com>
parents:
17792
diff
changeset
|
741 | jm->sent = purple_str_to_time(timestamp, TRUE, NULL, NULL, NULL); |
| 7014 | 742 | } else if(!strcmp(child->name, "x")) { |
| 743 | if(xmlns && !strcmp(xmlns, "jabber:x:event")) { | |
| 13708 | 744 | if(xmlnode_get_child(child, "composing")) { |
| 745 | if(jm->chat_state == JM_STATE_ACTIVE) | |
| 746 | jm->chat_state = JM_STATE_COMPOSING; | |
| 747 | jm->typing_style |= JM_TS_JEP_0022; | |
| 748 | } | |
| 7014 | 749 | } else if(xmlns && !strcmp(xmlns, "jabber:x:delay")) { |
| 750 | const char *timestamp = xmlnode_get_attrib(child, "stamp"); | |
|
9584
1a6198375303
[gaim-migrate @ 10427]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9130
diff
changeset
|
751 | jm->delayed = TRUE; |
| 7014 | 752 | if(timestamp) |
| 15884 | 753 | jm->sent = purple_str_to_time(timestamp, TRUE, NULL, NULL, NULL); |
| 7014 | 754 | } else if(xmlns && !strcmp(xmlns, "jabber:x:conference") && |
| 11230 | 755 | jm->type != JABBER_MESSAGE_GROUPCHAT_INVITE && |
| 756 | jm->type != JABBER_MESSAGE_ERROR) { | |
| 7014 | 757 | const char *jid = xmlnode_get_attrib(child, "jid"); |
| 758 | if(jid) { | |
| 759 | jm->type = JABBER_MESSAGE_GROUPCHAT_INVITE; | |
| 760 | g_free(jm->to); | |
| 761 | jm->to = g_strdup(jid); | |
| 762 | } | |
| 763 | } else if(xmlns && !strcmp(xmlns, | |
| 11230 | 764 | "http://jabber.org/protocol/muc#user") && |
| 765 | jm->type != JABBER_MESSAGE_ERROR) { | |
| 7014 | 766 | xmlnode *invite = xmlnode_get_child(child, "invite"); |
| 767 | if(invite) { | |
| 768 | xmlnode *reason, *password; | |
| 7968 | 769 | const char *jid = xmlnode_get_attrib(invite, "from"); |
| 7014 | 770 | g_free(jm->to); |
| 771 | jm->to = jm->from; | |
| 772 | jm->from = g_strdup(jid); | |
| 773 | if((reason = xmlnode_get_child(invite, "reason"))) { | |
| 774 | g_free(jm->body); | |
| 775 | jm->body = xmlnode_get_data(reason); | |
| 776 | } | |
| 11576 | 777 | if((password = xmlnode_get_child(child, "password"))) |
| 7014 | 778 | jm->password = xmlnode_get_data(password); |
| 779 | ||
| 780 | jm->type = JABBER_MESSAGE_GROUPCHAT_INVITE; | |
| 781 | } | |
| 7145 | 782 | } else { |
| 783 | jm->etc = g_list_append(jm->etc, child); | |
| 7014 | 784 | } |
| 785 | } | |
| 786 | } | |
| 787 | ||
|
17822
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
788 | if(jm->hasBuzz) |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
789 | handle_buzz(jm); |
| 7014 | 790 | |
| 791 | switch(jm->type) { | |
| 792 | case JABBER_MESSAGE_NORMAL: | |
| 793 | case JABBER_MESSAGE_CHAT: | |
| 7145 | 794 | handle_chat(jm); |
| 795 | break; | |
| 7014 | 796 | case JABBER_MESSAGE_HEADLINE: |
| 7145 | 797 | handle_headline(jm); |
| 7014 | 798 | break; |
| 799 | case JABBER_MESSAGE_GROUPCHAT: | |
| 800 | handle_groupchat(jm); | |
| 801 | break; | |
| 802 | case JABBER_MESSAGE_GROUPCHAT_INVITE: | |
| 803 | handle_groupchat_invite(jm); | |
| 804 | break; | |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17776
diff
changeset
|
805 | case JABBER_MESSAGE_EVENT: |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17776
diff
changeset
|
806 | jabber_handle_event(jm); |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17776
diff
changeset
|
807 | break; |
| 7014 | 808 | case JABBER_MESSAGE_ERROR: |
| 809 | handle_error(jm); | |
| 810 | break; | |
| 811 | case JABBER_MESSAGE_OTHER: | |
| 15884 | 812 | purple_debug(PURPLE_DEBUG_INFO, "jabber", |
| 7014 | 813 | "Received message of unknown type: %s\n", type); |
| 814 | break; | |
| 815 | } | |
| 816 | jabber_message_free(jm); | |
| 817 | } | |
| 818 | ||
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
819 | static const gchar * |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
820 | 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
|
821 | { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
822 | 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
|
823 | return "image/png"; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
824 | } 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
|
825 | return "image/gif"; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
826 | } 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
|
827 | return "image/jpeg"; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
828 | } 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
|
829 | return "image/tif"; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
830 | } else { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
831 | 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
|
832 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
833 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
834 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
835 | static GList * |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
836 | 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
|
837 | { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
838 | 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
|
839 | GList *found_smileys = NULL; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
840 | |
|
23628
3d540eeb2e74
Ooops ... compile\!
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23627
diff
changeset
|
841 | 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
|
842 | PurpleSmiley *smiley = (PurpleSmiley *) smileys->data; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
843 | 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
|
844 | 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
|
845 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
846 | 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
|
847 | 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
|
848 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
849 | if (pos) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
850 | 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
|
851 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
852 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
853 | g_free(escaped); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
854 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
855 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
856 | return found_smileys; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
857 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
858 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
859 | static gchar * |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
860 | 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
|
861 | { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
862 | /* 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
|
863 | 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
|
864 | int pos = 0; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
865 | int length = strlen(xhtml); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
866 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
867 | while (pos < length) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
868 | const GList *iterator; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
869 | gboolean found_smiley = FALSE; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
870 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
871 | for (iterator = smileys ; iterator ; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
872 | 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
|
873 | 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
|
874 | 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
|
875 | 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
|
876 | 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
|
877 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
878 | 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
|
879 | /* 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
|
880 | const JabberData *data = |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
881 | jabber_data_find_local_by_alt(shortcut); |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
882 | xmlnode *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
|
883 | int len; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
884 | gchar *img_text = xmlnode_to_str(img, &len); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
885 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
886 | found_smiley = TRUE; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
887 | 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
|
888 | g_free(img_text); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
889 | pos += strlen(escaped); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
890 | g_free(escaped); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
891 | break; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
892 | } else { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
893 | /* 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
|
894 | g_free(escaped); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
895 | } |
|
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 | if (!found_smiley) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
898 | /* 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
|
899 | 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
|
900 | pos++; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
901 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
902 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
903 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
904 | 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
|
905 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
906 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
907 | static gboolean |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
908 | jabber_conv_support_custom_smileys(const PurpleConnection *gc, |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
909 | const PurpleConversation *conv, |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
910 | const gchar *who) |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
911 | { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
912 | JabberStream *js = (JabberStream *) gc->proto_data; |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
913 | JabberBuddy *jb; |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
914 | |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
915 | if (!js) { |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
916 | purple_debug_error("jabber", |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
917 | "jabber_conv_support_custom_smileys: could not find stream\n"); |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
918 | return FALSE; |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
919 | } |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
920 | |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
921 | jb = jabber_buddy_find(js, who, FALSE); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
922 | if (!jb) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
923 | purple_debug_error("jabber", |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
924 | "jabber_conv_support_custom smileys: could not find buddy\n"); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
925 | return FALSE; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
926 | } |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
927 | |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
928 | |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
929 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
930 | switch (purple_conversation_get_type(conv)) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
931 | /* for the time being, we will not support custom smileys in MUCs */ |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
932 | case PURPLE_CONV_TYPE_IM: |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
933 | return jabber_buddy_has_capability(jb, XEP_0231_NAMESPACE); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
934 | break; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
935 | default: |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
936 | return FALSE; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
937 | break; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
938 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
939 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
940 | |
| 7014 | 941 | void jabber_message_send(JabberMessage *jm) |
| 942 | { | |
| 943 | xmlnode *message, *child; | |
| 944 | const char *type = NULL; | |
| 945 | ||
| 946 | message = xmlnode_new("message"); | |
| 947 | ||
| 948 | switch(jm->type) { | |
| 949 | case JABBER_MESSAGE_NORMAL: | |
| 950 | type = "normal"; | |
| 951 | break; | |
| 952 | case JABBER_MESSAGE_CHAT: | |
| 953 | case JABBER_MESSAGE_GROUPCHAT_INVITE: | |
| 954 | type = "chat"; | |
| 955 | break; | |
| 956 | case JABBER_MESSAGE_HEADLINE: | |
| 957 | type = "headline"; | |
| 958 | break; | |
| 959 | case JABBER_MESSAGE_GROUPCHAT: | |
| 960 | type = "groupchat"; | |
| 961 | break; | |
| 962 | case JABBER_MESSAGE_ERROR: | |
| 963 | type = "error"; | |
| 964 | break; | |
| 965 | 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
|
966 | default: |
| 7014 | 967 | type = NULL; |
| 968 | break; | |
| 969 | } | |
| 970 | ||
| 971 | if(type) | |
| 972 | xmlnode_set_attrib(message, "type", type); | |
| 13484 | 973 | |
| 974 | if (jm->id) | |
| 975 | xmlnode_set_attrib(message, "id", jm->id); | |
| 7014 | 976 | |
| 977 | xmlnode_set_attrib(message, "to", jm->to); | |
| 978 | ||
| 8400 | 979 | if(jm->thread_id) { |
| 980 | child = xmlnode_new_child(message, "thread"); | |
| 981 | xmlnode_insert_data(child, jm->thread_id, -1); | |
| 982 | } | |
| 983 | ||
| 13708 | 984 | if(JM_TS_JEP_0022 == (jm->typing_style & JM_TS_JEP_0022)) { |
| 7014 | 985 | child = xmlnode_new_child(message, "x"); |
| 13808 | 986 | xmlnode_set_namespace(child, "jabber:x:event"); |
| 13708 | 987 | if(jm->chat_state == JM_STATE_COMPOSING || jm->body) |
| 7014 | 988 | xmlnode_new_child(child, "composing"); |
| 989 | } | |
| 990 | ||
| 13708 | 991 | if(JM_TS_JEP_0085 == (jm->typing_style & JM_TS_JEP_0085)) { |
| 992 | child = NULL; | |
| 993 | switch(jm->chat_state) | |
| 994 | { | |
| 995 | case JM_STATE_ACTIVE: | |
| 996 | child = xmlnode_new_child(message, "active"); | |
| 997 | break; | |
| 998 | case JM_STATE_COMPOSING: | |
| 999 | child = xmlnode_new_child(message, "composing"); | |
| 1000 | break; | |
| 1001 | case JM_STATE_PAUSED: | |
| 1002 | child = xmlnode_new_child(message, "paused"); | |
| 1003 | break; | |
| 1004 | case JM_STATE_INACTIVE: | |
| 1005 | child = xmlnode_new_child(message, "inactive"); | |
| 1006 | break; | |
| 1007 | case JM_STATE_GONE: | |
| 1008 | child = xmlnode_new_child(message, "gone"); | |
| 1009 | break; | |
| 1010 | } | |
| 1011 | if(child) | |
| 13808 | 1012 | xmlnode_set_namespace(child, "http://jabber.org/protocol/chatstates"); |
| 13708 | 1013 | } |
| 1014 | ||
| 7014 | 1015 | if(jm->subject) { |
| 1016 | child = xmlnode_new_child(message, "subject"); | |
| 1017 | xmlnode_insert_data(child, jm->subject, -1); | |
| 1018 | } | |
| 1019 | ||
| 1020 | if(jm->body) { | |
| 1021 | child = xmlnode_new_child(message, "body"); | |
| 1022 | xmlnode_insert_data(child, jm->body, -1); | |
| 1023 | } | |
| 1024 | ||
| 1025 | if(jm->xhtml) { | |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1026 | PurpleAccount *account = purple_connection_get_account(jm->js->gc); |
|
23627
dbdc407798af
A couple of leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23626
diff
changeset
|
1027 | PurpleConversation *conv = |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1028 | purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, jm->to, |
|
23627
dbdc407798af
A couple of leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23626
diff
changeset
|
1029 | account); |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
1030 | |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1031 | if (jabber_conv_support_custom_smileys(jm->js->gc, conv, jm->to)) { |
|
23627
dbdc407798af
A couple of leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23626
diff
changeset
|
1032 | GList *found_smileys = jabber_message_xhtml_find_smileys(jm->xhtml); |
|
dbdc407798af
A couple of leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23626
diff
changeset
|
1033 | |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1034 | if (found_smileys) { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1035 | gchar *smileyfied_xhtml = NULL; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1036 | const GList *iterator; |
|
23627
dbdc407798af
A couple of leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23626
diff
changeset
|
1037 | |
|
dbdc407798af
A couple of leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23626
diff
changeset
|
1038 | for (iterator = found_smileys; iterator ; |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1039 | iterator = g_list_next(iterator)) { |
|
23627
dbdc407798af
A couple of leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23626
diff
changeset
|
1040 | const PurpleSmiley *smiley = |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1041 | (PurpleSmiley *) iterator->data; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1042 | const gchar *shortcut = purple_smiley_get_shortcut(smiley); |
|
23627
dbdc407798af
A couple of leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23626
diff
changeset
|
1043 | const JabberData *data = |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
1044 | jabber_data_find_local_by_alt(shortcut); |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
1045 | |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
1046 | /* the object has not been sent before */ |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1047 | if (!data) { |
|
23627
dbdc407798af
A couple of leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23626
diff
changeset
|
1048 | PurpleStoredImage *image = |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1049 | purple_smiley_get_stored_image(smiley); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1050 | const gchar *ext = purple_imgstore_get_extension(image); |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
1051 | JabberStream *js = jm->js; |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
1052 | |
|
23627
dbdc407798af
A couple of leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23626
diff
changeset
|
1053 | JabberData *new_data = |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1054 | jabber_data_create_from_data(purple_imgstore_get_data(image), |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
1055 | purple_imgstore_get_size(image), |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
1056 | jabber_message_get_mimetype_from_ext(ext), js); |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
1057 | purple_debug_info("jabber", |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
1058 | "cache local smiley alt = %s, cid = %s\n", |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
1059 | shortcut, jabber_data_get_cid(new_data)); |
|
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
1060 | jabber_data_associate_local(new_data, shortcut); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1061 | } |
|
23627
dbdc407798af
A couple of leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23626
diff
changeset
|
1062 | } |
|
dbdc407798af
A couple of leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23626
diff
changeset
|
1063 | |
|
dbdc407798af
A couple of leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23626
diff
changeset
|
1064 | smileyfied_xhtml = |
|
24254
2d990726bf92
Updated to use latest spec. in XEP-0231
Marcus Lundblad <malu@pidgin.im>
parents:
23628
diff
changeset
|
1065 | jabber_message_get_smileyfied_xhtml(jm->xhtml, found_smileys); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1066 | child = xmlnode_from_str(smileyfied_xhtml, -1); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1067 | g_free(smileyfied_xhtml); |
|
23627
dbdc407798af
A couple of leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23626
diff
changeset
|
1068 | g_list_free(found_smileys); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1069 | } else { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1070 | child = xmlnode_from_str(jm->xhtml, -1); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1071 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1072 | } else { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1073 | child = xmlnode_from_str(jm->xhtml, -1); |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1074 | } |
| 7014 | 1075 | if(child) { |
| 1076 | xmlnode_insert_child(message, child); | |
| 1077 | } else { | |
| 15884 | 1078 | purple_debug(PURPLE_DEBUG_ERROR, "jabber", |
| 7014 | 1079 | "XHTML translation/validation failed, returning: %s\n", |
| 1080 | jm->xhtml); | |
| 1081 | } | |
| 1082 | } | |
| 1083 | ||
| 1084 | jabber_send(jm->js, message); | |
| 1085 | ||
| 1086 | xmlnode_free(message); | |
| 1087 | } | |
| 1088 | ||
| 15884 | 1089 | int jabber_message_send_im(PurpleConnection *gc, const char *who, const char *msg, |
| 1090 | PurpleMessageFlags flags) | |
| 7014 | 1091 | { |
| 1092 | JabberMessage *jm; | |
| 1093 | JabberBuddy *jb; | |
| 1094 | JabberBuddyResource *jbr; | |
| 1095 | char *buf; | |
| 7135 | 1096 | char *xhtml; |
| 7306 | 1097 | char *resource; |
| 7014 | 1098 | |
| 1099 | if(!who || !msg) | |
| 1100 | return 0; | |
| 1101 | ||
| 7306 | 1102 | resource = jabber_get_resource(who); |
| 1103 | ||
| 7014 | 1104 | jb = jabber_buddy_find(gc->proto_data, who, TRUE); |
| 7306 | 1105 | jbr = jabber_buddy_find_resource(jb, resource); |
| 1106 | ||
| 1107 | g_free(resource); | |
| 7014 | 1108 | |
| 1109 | jm = g_new0(JabberMessage, 1); | |
| 1110 | jm->js = gc->proto_data; | |
| 1111 | jm->type = JABBER_MESSAGE_CHAT; | |
| 13708 | 1112 | jm->chat_state = JM_STATE_ACTIVE; |
| 7014 | 1113 | jm->to = g_strdup(who); |
| 13484 | 1114 | jm->id = jabber_get_next_id(jm->js); |
| 13708 | 1115 | jm->chat_state = JM_STATE_ACTIVE; |
| 1116 | ||
| 1117 | if(jbr) { | |
| 1118 | if(jbr->thread_id) | |
| 1119 | jm->thread_id = jbr->thread_id; | |
| 1120 | ||
| 1121 | if(jbr->chat_states != JABBER_CHAT_STATES_UNSUPPORTED) { | |
| 1122 | jm->typing_style |= JM_TS_JEP_0085; | |
| 1123 | /* if(JABBER_CHAT_STATES_UNKNOWN == jbr->chat_states) | |
| 1124 | jbr->chat_states = JABBER_CHAT_STATES_UNSUPPORTED; */ | |
| 1125 | } | |
| 1126 | ||
| 1127 | if(jbr->chat_states != JABBER_CHAT_STATES_SUPPORTED) | |
| 1128 | jm->typing_style |= JM_TS_JEP_0022; | |
| 1129 | } | |
| 7014 | 1130 | |
| 7773 | 1131 | buf = g_strdup_printf("<html xmlns='http://jabber.org/protocol/xhtml-im'><body xmlns='http://www.w3.org/1999/xhtml'>%s</body></html>", msg); |
|
17328
7a5668fb7bad
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@pidgin.im>
parents:
16961
diff
changeset
|
1132 | |
| 15884 | 1133 | purple_markup_html_to_xhtml(buf, &xhtml, &jm->body); |
| 7014 | 1134 | g_free(buf); |
| 1135 | ||
| 1136 | if(!jbr || jbr->capabilities & JABBER_CAP_XHTML) | |
| 1137 | jm->xhtml = xhtml; | |
| 1138 | else | |
| 1139 | g_free(xhtml); | |
| 1140 | ||
| 1141 | jabber_message_send(jm); | |
| 1142 | jabber_message_free(jm); | |
| 1143 | return 1; | |
| 1144 | } | |
| 1145 | ||
| 15884 | 1146 | int jabber_message_send_chat(PurpleConnection *gc, int id, const char *msg, PurpleMessageFlags flags) |
| 7014 | 1147 | { |
| 1148 | JabberChat *chat; | |
| 1149 | JabberMessage *jm; | |
| 8042 | 1150 | JabberStream *js; |
| 9130 | 1151 | char *buf; |
| 7014 | 1152 | |
| 8042 | 1153 | if(!msg || !gc) |
| 7014 | 1154 | return 0; |
| 1155 | ||
| 8042 | 1156 | js = gc->proto_data; |
| 7014 | 1157 | chat = jabber_chat_find_by_id(js, id); |
| 1158 | ||
| 8043 | 1159 | if(!chat) |
| 1160 | return 0; | |
| 1161 | ||
| 9130 | 1162 | jm = g_new0(JabberMessage, 1); |
| 1163 | jm->js = gc->proto_data; | |
| 1164 | jm->type = JABBER_MESSAGE_GROUPCHAT; | |
| 1165 | jm->to = g_strdup_printf("%s@%s", chat->room, chat->server); | |
| 13484 | 1166 | jm->id = jabber_get_next_id(jm->js); |
| 9130 | 1167 | |
| 8858 | 1168 | buf = g_strdup_printf("<html xmlns='http://jabber.org/protocol/xhtml-im'><body xmlns='http://www.w3.org/1999/xhtml'>%s</body></html>", msg); |
| 15884 | 1169 | purple_markup_html_to_xhtml(buf, &jm->xhtml, &jm->body); |
| 8858 | 1170 | g_free(buf); |
| 1171 | ||
| 9130 | 1172 | if(!chat->xhtml) { |
| 1173 | g_free(jm->xhtml); | |
| 1174 | jm->xhtml = NULL; | |
| 7923 | 1175 | } |
| 1176 | ||
| 9130 | 1177 | jabber_message_send(jm); |
| 1178 | jabber_message_free(jm); | |
| 1179 | ||
| 7014 | 1180 | return 1; |
| 1181 | } | |
| 1182 | ||
| 15884 | 1183 | unsigned int jabber_send_typing(PurpleConnection *gc, const char *who, PurpleTypingState state) |
| 7014 | 1184 | { |
| 1185 | JabberMessage *jm; | |
| 1186 | JabberBuddy *jb; | |
| 1187 | JabberBuddyResource *jbr; | |
| 7306 | 1188 | char *resource = jabber_get_resource(who); |
| 7014 | 1189 | |
| 1190 | jb = jabber_buddy_find(gc->proto_data, who, TRUE); | |
| 7306 | 1191 | jbr = jabber_buddy_find_resource(jb, resource); |
| 1192 | ||
| 1193 | g_free(resource); | |
| 7014 | 1194 | |
| 13708 | 1195 | if(!jbr || !((jbr->capabilities & JABBER_CAP_COMPOSING) || (jbr->chat_states != JABBER_CHAT_STATES_UNSUPPORTED))) |
| 7014 | 1196 | return 0; |
| 1197 | ||
| 13708 | 1198 | /* TODO: figure out threading */ |
| 7014 | 1199 | jm = g_new0(JabberMessage, 1); |
| 1200 | jm->js = gc->proto_data; | |
| 1201 | jm->type = JABBER_MESSAGE_CHAT; | |
| 1202 | jm->to = g_strdup(who); | |
| 13484 | 1203 | jm->id = jabber_get_next_id(jm->js); |
| 7014 | 1204 | |
| 15884 | 1205 | if(PURPLE_TYPING == state) |
| 13708 | 1206 | jm->chat_state = JM_STATE_COMPOSING; |
| 15884 | 1207 | else if(PURPLE_TYPED == state) |
| 13708 | 1208 | jm->chat_state = JM_STATE_PAUSED; |
| 1209 | else | |
| 1210 | jm->chat_state = JM_STATE_ACTIVE; | |
| 1211 | ||
| 1212 | if(jbr->chat_states != JABBER_CHAT_STATES_UNSUPPORTED) { | |
| 1213 | jm->typing_style |= JM_TS_JEP_0085; | |
| 1214 | /* if(JABBER_CHAT_STATES_UNKNOWN == jbr->chat_states) | |
| 1215 | jbr->chat_states = JABBER_CHAT_STATES_UNSUPPORTED; */ | |
| 1216 | } | |
| 1217 | ||
| 1218 | if(jbr->chat_states != JABBER_CHAT_STATES_SUPPORTED) | |
| 1219 | jm->typing_style |= JM_TS_JEP_0022; | |
| 7014 | 1220 | |
| 1221 | jabber_message_send(jm); | |
| 1222 | jabber_message_free(jm); | |
| 1223 | ||
| 13708 | 1224 | return 0; |
| 7014 | 1225 | } |
| 1226 | ||
|
15709
b58646e3ce63
Sending XEP 85 'gone' messages
Sean Egan <seanegan@pidgin.im>
parents:
15598
diff
changeset
|
1227 | void jabber_message_conv_closed(JabberStream *js, const char *who) |
|
b58646e3ce63
Sending XEP 85 'gone' messages
Sean Egan <seanegan@pidgin.im>
parents:
15598
diff
changeset
|
1228 | { |
|
19419
c4d5b0a8507f
Only send conversation close notices on XMPP when the typing notification preference is turned on
Sean Egan <seanegan@pidgin.im>
parents:
17351
diff
changeset
|
1229 | JabberMessage *jm; |
|
c4d5b0a8507f
Only send conversation close notices on XMPP when the typing notification preference is turned on
Sean Egan <seanegan@pidgin.im>
parents:
17351
diff
changeset
|
1230 | if (!purple_prefs_get_bool("/purple/conversations/im/send_typing")) |
|
c4d5b0a8507f
Only send conversation close notices on XMPP when the typing notification preference is turned on
Sean Egan <seanegan@pidgin.im>
parents:
17351
diff
changeset
|
1231 | return; |
|
c4d5b0a8507f
Only send conversation close notices on XMPP when the typing notification preference is turned on
Sean Egan <seanegan@pidgin.im>
parents:
17351
diff
changeset
|
1232 | |
|
c4d5b0a8507f
Only send conversation close notices on XMPP when the typing notification preference is turned on
Sean Egan <seanegan@pidgin.im>
parents:
17351
diff
changeset
|
1233 | jm = g_new0(JabberMessage, 1); |
|
15709
b58646e3ce63
Sending XEP 85 'gone' messages
Sean Egan <seanegan@pidgin.im>
parents:
15598
diff
changeset
|
1234 | jm->js = js; |
|
b58646e3ce63
Sending XEP 85 'gone' messages
Sean Egan <seanegan@pidgin.im>
parents:
15598
diff
changeset
|
1235 | jm->type = JABBER_MESSAGE_CHAT; |
|
b58646e3ce63
Sending XEP 85 'gone' messages
Sean Egan <seanegan@pidgin.im>
parents:
15598
diff
changeset
|
1236 | jm->to = g_strdup(who); |
|
b58646e3ce63
Sending XEP 85 'gone' messages
Sean Egan <seanegan@pidgin.im>
parents:
15598
diff
changeset
|
1237 | jm->id = jabber_get_next_id(jm->js); |
|
b58646e3ce63
Sending XEP 85 'gone' messages
Sean Egan <seanegan@pidgin.im>
parents:
15598
diff
changeset
|
1238 | jm->typing_style = JM_TS_JEP_0085; |
|
b58646e3ce63
Sending XEP 85 'gone' messages
Sean Egan <seanegan@pidgin.im>
parents:
15598
diff
changeset
|
1239 | jm->chat_state = JM_STATE_GONE; |
|
b58646e3ce63
Sending XEP 85 'gone' messages
Sean Egan <seanegan@pidgin.im>
parents:
15598
diff
changeset
|
1240 | jabber_message_send(jm); |
|
b58646e3ce63
Sending XEP 85 'gone' messages
Sean Egan <seanegan@pidgin.im>
parents:
15598
diff
changeset
|
1241 | jabber_message_free(jm); |
|
b58646e3ce63
Sending XEP 85 'gone' messages
Sean Egan <seanegan@pidgin.im>
parents:
15598
diff
changeset
|
1242 | } |
|
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
|
1243 | |
|
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
|
1244 | gboolean jabber_buzz_isenabled(JabberStream *js, const gchar *shortname, const gchar *namespace) { |
|
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
|
1245 | 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
|
1246 | } |
|
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
|
1247 | |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1248 | gboolean jabber_custom_smileys_isenabled(JabberStream *js, const gchar *shortname, |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1249 | const gchar *namespace) |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1250 | { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1251 | 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
|
1252 | PurpleAccount *account = purple_connection_get_account(gc); |
|
23627
dbdc407798af
A couple of leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23626
diff
changeset
|
1253 | |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23249
diff
changeset
|
1254 | 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
|
1255 | } |