Mercurial > pidgin
annotate libpurple/protocols/jabber/message.c @ 29260:eab9700e6361
propagate from branch 'im.pidgin.pidgin' (head f3891f3348abfe90fbe60a054833c12075aa8df4)
to branch 'im.pidgin.cpw.attention_ui' (head 88ed35a990c2063f7a53548c7d2530db148a4ce2)
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Sun, 16 Nov 2008 15:40:12 +0000 |
parents | 249fee48c3ed fae699fece1f |
children | 558baf33197e |
rev | line source |
---|---|
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /* |
15822 | 2 * purple - Jabber Protocol Plugin |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
6 * This program is free software; you can redistribute it and/or modify |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
8 * the Free Software Foundation; either version 2 of the License, or |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
9 * (at your option) any later version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 * This program is distributed in the hope that it will be useful, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
14 * GNU General Public License for more details. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 * You should have received a copy of the GNU General Public License |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
17 * along with this program; if not, write to the Free Software |
19681
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19310
diff
changeset
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
19 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
20 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
21 #include "internal.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
22 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
23 #include "debug.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
24 #include "notify.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
25 #include "server.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
26 #include "util.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
27 #include "buddy.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
28 #include "chat.h" |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
29 #include "data.h" |
15522
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15373
diff
changeset
|
30 #include "google.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
31 #include "message.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
32 #include "xmlnode.h" |
17834
a75079eae085
added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
17258
diff
changeset
|
33 #include "pep.h" |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
34 #include "smiley.h" |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
35 #include "iq.h" |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
36 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
37 #include <string.h> |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
38 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
39 void jabber_message_free(JabberMessage *jm) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
40 { |
15917 | 41 g_free(jm->from); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
42 g_free(jm->to); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
43 g_free(jm->id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
44 g_free(jm->subject); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
45 g_free(jm->body); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
46 g_free(jm->xhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
47 g_free(jm->password); |
20192
41e39193e247
applied changes from 326d6e6c8c6a955cdba84f1f802fc21ec3e6b662
Richard Laager <rlaager@wiktel.com>
parents:
19718
diff
changeset
|
48 g_free(jm->error); |
41e39193e247
applied changes from 326d6e6c8c6a955cdba84f1f802fc21ec3e6b662
Richard Laager <rlaager@wiktel.com>
parents:
19718
diff
changeset
|
49 g_free(jm->thread_id); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
50 g_list_free(jm->etc); |
20192
41e39193e247
applied changes from 326d6e6c8c6a955cdba84f1f802fc21ec3e6b662
Richard Laager <rlaager@wiktel.com>
parents:
19718
diff
changeset
|
51 g_list_free(jm->eventitems); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
52 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
53 g_free(jm); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
54 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
55 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
56 static void handle_chat(JabberMessage *jm) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
57 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
58 JabberID *jid = jabber_id_new(jm->from); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
59 char *from; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
60 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
61 JabberBuddy *jb; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
62 JabberBuddyResource *jbr; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
64 if(!jid) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
65 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
66 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
67 jb = jabber_buddy_find(jm->js, jm->from, TRUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
68 jbr = jabber_buddy_find_resource(jb, jid->resource); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
69 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
70 if(jabber_find_unnormalized_conv(jm->from, jm->js->gc->account)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
71 from = g_strdup(jm->from); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
72 } else if(jid->node) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
73 if(jid->resource) { |
15822 | 74 PurpleConversation *conv; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
75 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
76 from = g_strdup_printf("%s@%s", jid->node, jid->domain); |
15822 | 77 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, from, jm->js->gc->account); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
78 if(conv) { |
15822 | 79 purple_conversation_set_name(conv, jm->from); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
80 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
81 g_free(from); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
82 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
83 from = g_strdup(jm->from); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
84 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
85 from = g_strdup(jid->domain); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
86 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
87 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
88 if(!jm->xhtml && !jm->body) { |
15648
e86623eb3b79
Receiving XEP 85 'gone' messages. Doesn't do anything because of the string freeze. This is akin to the MSN 'so-and-so has closed the conversation window' messages. Rlaager made a strong point to me that they're not altogether stalky, but can be useful.
Sean Egan <seanegan@gmail.com>
parents:
15647
diff
changeset
|
89 if(JM_STATE_COMPOSING == jm->chat_state) { |
15822 | 90 serv_got_typing(jm->js->gc, from, 0, PURPLE_TYPING); |
15648
e86623eb3b79
Receiving XEP 85 'gone' messages. Doesn't do anything because of the string freeze. This is akin to the MSN 'so-and-so has closed the conversation window' messages. Rlaager made a strong point to me that they're not altogether stalky, but can be useful.
Sean Egan <seanegan@gmail.com>
parents:
15647
diff
changeset
|
91 } else if(JM_STATE_PAUSED == jm->chat_state) { |
15822 | 92 serv_got_typing(jm->js->gc, from, 0, PURPLE_TYPED); |
15648
e86623eb3b79
Receiving XEP 85 'gone' messages. Doesn't do anything because of the string freeze. This is akin to the MSN 'so-and-so has closed the conversation window' messages. Rlaager made a strong point to me that they're not altogether stalky, but can be useful.
Sean Egan <seanegan@gmail.com>
parents:
15647
diff
changeset
|
93 } else if(JM_STATE_GONE == jm->chat_state) { |
15822 | 94 PurpleConversation *conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, |
15648
e86623eb3b79
Receiving XEP 85 'gone' messages. Doesn't do anything because of the string freeze. This is akin to the MSN 'so-and-so has closed the conversation window' messages. Rlaager made a strong point to me that they're not altogether stalky, but can be useful.
Sean Egan <seanegan@gmail.com>
parents:
15647
diff
changeset
|
95 from, jm->js->gc->account); |
15659
94a19bde141d
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents:
15648
diff
changeset
|
96 if (conv && jid->node && jid->domain) { |
94a19bde141d
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents:
15648
diff
changeset
|
97 char buf[256]; |
15822 | 98 PurpleBuddy *buddy; |
15659
94a19bde141d
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents:
15648
diff
changeset
|
99 |
94a19bde141d
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents:
15648
diff
changeset
|
100 g_snprintf(buf, sizeof(buf), "%s@%s", jid->node, jid->domain); |
94a19bde141d
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents:
15648
diff
changeset
|
101 |
15822 | 102 if ((buddy = purple_find_buddy(jm->js->gc->account, buf))) { |
15659
94a19bde141d
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents:
15648
diff
changeset
|
103 const char *who; |
94a19bde141d
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents:
15648
diff
changeset
|
104 char *escaped; |
94a19bde141d
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents:
15648
diff
changeset
|
105 |
15822 | 106 who = purple_buddy_get_alias(buddy); |
15659
94a19bde141d
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents:
15648
diff
changeset
|
107 escaped = g_markup_escape_text(who, -1); |
94a19bde141d
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents:
15648
diff
changeset
|
108 |
94a19bde141d
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents:
15648
diff
changeset
|
109 g_snprintf(buf, sizeof(buf), |
16890 | 110 _("%s has left the conversation."), escaped); |
20570
5913725cbcd6
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20106
diff
changeset
|
111 g_free(escaped); |
15659
94a19bde141d
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents:
15648
diff
changeset
|
112 |
15822 | 113 /* At some point when we restructure PurpleConversation, |
15659
94a19bde141d
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents:
15648
diff
changeset
|
114 * this should be able to be implemented by removing the |
94a19bde141d
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents:
15648
diff
changeset
|
115 * user from the conversation like we do with chats now. */ |
15822 | 116 purple_conversation_write(conv, "", buf, |
117 PURPLE_MESSAGE_SYSTEM, time(NULL)); | |
15659
94a19bde141d
Include the user's name/alias in the XEP 85 "gone" messages.
Richard Laager <rlaager@wiktel.com>
parents:
15648
diff
changeset
|
118 } |
15648
e86623eb3b79
Receiving XEP 85 'gone' messages. Doesn't do anything because of the string freeze. This is akin to the MSN 'so-and-so has closed the conversation window' messages. Rlaager made a strong point to me that they're not altogether stalky, but can be useful.
Sean Egan <seanegan@gmail.com>
parents:
15647
diff
changeset
|
119 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
120 serv_got_typing_stopped(jm->js->gc, from); |
15648
e86623eb3b79
Receiving XEP 85 'gone' messages. Doesn't do anything because of the string freeze. This is akin to the MSN 'so-and-so has closed the conversation window' messages. Rlaager made a strong point to me that they're not altogether stalky, but can be useful.
Sean Egan <seanegan@gmail.com>
parents:
15647
diff
changeset
|
121 |
e86623eb3b79
Receiving XEP 85 'gone' messages. Doesn't do anything because of the string freeze. This is akin to the MSN 'so-and-so has closed the conversation window' messages. Rlaager made a strong point to me that they're not altogether stalky, but can be useful.
Sean Egan <seanegan@gmail.com>
parents:
15647
diff
changeset
|
122 } else { |
e86623eb3b79
Receiving XEP 85 'gone' messages. Doesn't do anything because of the string freeze. This is akin to the MSN 'so-and-so has closed the conversation window' messages. Rlaager made a strong point to me that they're not altogether stalky, but can be useful.
Sean Egan <seanegan@gmail.com>
parents:
15647
diff
changeset
|
123 serv_got_typing_stopped(jm->js->gc, from); |
e86623eb3b79
Receiving XEP 85 'gone' messages. Doesn't do anything because of the string freeze. This is akin to the MSN 'so-and-so has closed the conversation window' messages. Rlaager made a strong point to me that they're not altogether stalky, but can be useful.
Sean Egan <seanegan@gmail.com>
parents:
15647
diff
changeset
|
124 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
125 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
126 if(jbr) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
127 if(JM_TS_JEP_0085 == (jm->typing_style & JM_TS_JEP_0085)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
128 jbr->chat_states = JABBER_CHAT_STATES_SUPPORTED; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
129 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
130 jbr->chat_states = JABBER_CHAT_STATES_UNSUPPORTED; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
131 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
132 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
133 if(JM_TS_JEP_0022 == (jm->typing_style & JM_TS_JEP_0022)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
134 jbr->capabilities |= JABBER_CAP_COMPOSING; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
135 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
136 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
137 if(jbr->thread_id) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
138 g_free(jbr->thread_id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
139 jbr->thread_id = g_strdup(jbr->thread_id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
140 } |
15522
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15373
diff
changeset
|
141 |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15373
diff
changeset
|
142 if (jm->js->googletalk && jm->xhtml == NULL) { |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15373
diff
changeset
|
143 char *tmp = jm->body; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15373
diff
changeset
|
144 jm->body = jabber_google_format_to_html(jm->body); |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15373
diff
changeset
|
145 g_free(tmp); |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15373
diff
changeset
|
146 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
147 serv_got_im(jm->js->gc, from, jm->xhtml ? jm->xhtml : jm->body, 0, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
148 jm->sent); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
149 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
150 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
151 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
152 g_free(from); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
153 jabber_id_free(jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
154 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
155 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
156 static void handle_headline(JabberMessage *jm) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
157 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
158 char *title; |
17885
b8de63d3bf89
Added buzz support using a private extension. Maybe I should write a XEP about that.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17877
diff
changeset
|
159 GString *body; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
160 GList *etc; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
161 |
17885
b8de63d3bf89
Added buzz support using a private extension. Maybe I should write a XEP about that.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17877
diff
changeset
|
162 if(!jm->xhtml && !jm->body) |
b8de63d3bf89
Added buzz support using a private extension. Maybe I should write a XEP about that.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17877
diff
changeset
|
163 return; /* ignore headlines without any content */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
164 |
17885
b8de63d3bf89
Added buzz support using a private extension. Maybe I should write a XEP about that.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17877
diff
changeset
|
165 body = g_string_new(""); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
166 title = g_strdup_printf(_("Message from %s"), jm->from); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
167 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
168 if(jm->xhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
169 g_string_append(body, jm->xhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
170 else if(jm->body) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
171 g_string_append(body, jm->body); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
172 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
173 for(etc = jm->etc; etc; etc = etc->next) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
174 xmlnode *x = etc->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
175 const char *xmlns = xmlnode_get_namespace(x); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
176 if(xmlns && !strcmp(xmlns, "jabber:x:oob")) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
177 xmlnode *url, *desc; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
178 char *urltxt, *desctxt; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
179 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
180 url = xmlnode_get_child(x, "url"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
181 desc = xmlnode_get_child(x, "desc"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
182 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
183 if(!url || !desc) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
184 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
185 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
186 urltxt = xmlnode_get_data(url); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
187 desctxt = xmlnode_get_data(desc); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
188 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
189 /* I'm all about ugly hacks */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
190 if(body->len && jm->body && !strcmp(body->str, jm->body)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
191 g_string_printf(body, "<a href='%s'>%s</a>", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
192 urltxt, desctxt); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
193 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
194 g_string_append_printf(body, "<br/><a href='%s'>%s</a>", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
195 urltxt, desctxt); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
196 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
197 g_free(urltxt); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
198 g_free(desctxt); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
199 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
200 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
201 |
15822 | 202 purple_notify_formatted(jm->js->gc, title, jm->subject ? jm->subject : title, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
203 NULL, body->str, NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
204 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
205 g_free(title); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
206 g_string_free(body, TRUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
207 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
208 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
209 static void handle_groupchat(JabberMessage *jm) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
210 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
211 JabberID *jid = jabber_id_new(jm->from); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
212 JabberChat *chat; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
213 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
214 if(!jid) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
215 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
216 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
217 chat = jabber_chat_find(jm->js, jid->node, jid->domain); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
218 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
219 if(!chat) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
220 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
221 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
222 if(jm->subject) { |
15822 | 223 purple_conv_chat_set_topic(PURPLE_CONV_CHAT(chat->conv), jid->resource, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
224 jm->subject); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
225 if(!jm->xhtml && !jm->body) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
226 char *msg, *tmp, *tmp2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
227 tmp = g_markup_escape_text(jm->subject, -1); |
15822 | 228 tmp2 = purple_markup_linkify(tmp); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
229 if(jid->resource) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
230 msg = g_strdup_printf(_("%s has set the topic to: %s"), jid->resource, tmp2); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
231 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
232 msg = g_strdup_printf(_("The topic is: %s"), tmp2); |
15822 | 233 purple_conv_chat_write(PURPLE_CONV_CHAT(chat->conv), "", msg, PURPLE_MESSAGE_SYSTEM, jm->sent); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
234 g_free(tmp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
235 g_free(tmp2); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
236 g_free(msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
237 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
238 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
239 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
240 if(jm->xhtml || jm->body) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
241 if(jid->resource) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
242 serv_got_chat_in(jm->js->gc, chat->id, jid->resource, |
15822 | 243 jm->delayed ? PURPLE_MESSAGE_DELAYED : 0, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
244 jm->xhtml ? jm->xhtml : jm->body, jm->sent); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
245 else if(chat->muc) |
15822 | 246 purple_conv_chat_write(PURPLE_CONV_CHAT(chat->conv), "", |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
247 jm->xhtml ? jm->xhtml : jm->body, |
15822 | 248 PURPLE_MESSAGE_SYSTEM, jm->sent); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
249 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
250 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
251 jabber_id_free(jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
252 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
253 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
254 static void handle_groupchat_invite(JabberMessage *jm) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
255 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
256 GHashTable *components; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
257 JabberID *jid = jabber_id_new(jm->to); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
258 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
259 if(!jid) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
260 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
261 |
15536
b081c81a4dea
Get rid of some unnecessary string duping
Mark Doliner <mark@kingant.net>
parents:
15522
diff
changeset
|
262 components = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
263 |
15536
b081c81a4dea
Get rid of some unnecessary string duping
Mark Doliner <mark@kingant.net>
parents:
15522
diff
changeset
|
264 g_hash_table_replace(components, "room", g_strdup(jid->node)); |
b081c81a4dea
Get rid of some unnecessary string duping
Mark Doliner <mark@kingant.net>
parents:
15522
diff
changeset
|
265 g_hash_table_replace(components, "server", g_strdup(jid->domain)); |
b081c81a4dea
Get rid of some unnecessary string duping
Mark Doliner <mark@kingant.net>
parents:
15522
diff
changeset
|
266 g_hash_table_replace(components, "handle", g_strdup(jm->js->user->node)); |
b081c81a4dea
Get rid of some unnecessary string duping
Mark Doliner <mark@kingant.net>
parents:
15522
diff
changeset
|
267 g_hash_table_replace(components, "password", g_strdup(jm->password)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
268 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
269 jabber_id_free(jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
270 serv_got_chat_invite(jm->js->gc, jm->to, jm->from, jm->body, components); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
271 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
272 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
273 static void handle_error(JabberMessage *jm) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
274 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
275 char *buf; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
276 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
277 if(!jm->body) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
278 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
279 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
280 buf = g_strdup_printf(_("Message delivery to %s failed: %s"), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
281 jm->from, jm->error ? jm->error : ""); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
282 |
16904
56042b2f8b64
s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@wiktel.com>
parents:
16890
diff
changeset
|
283 purple_notify_formatted(jm->js->gc, _("XMPP Message Error"), _("XMPP Message Error"), buf, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
284 jm->xhtml ? jm->xhtml : jm->body, NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
285 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
286 g_free(buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
287 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
288 |
17888
cca457b9158b
disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents:
17887
diff
changeset
|
289 static void handle_buzz(JabberMessage *jm) { |
cca457b9158b
disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents:
17887
diff
changeset
|
290 PurpleBuddy *buddy; |
cca457b9158b
disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents:
17887
diff
changeset
|
291 PurpleAccount *account; |
cca457b9158b
disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents:
17887
diff
changeset
|
292 PurpleConversation *c; |
cca457b9158b
disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents:
17887
diff
changeset
|
293 char *username, *str; |
cca457b9158b
disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents:
17887
diff
changeset
|
294 |
17889
9686d549f084
Switched buzz namespace and tag name to be libpurple-specific and use a more professionally-sounding name ('attention' instead of 'buzz').
Andreas Monitzer <pidgin@monitzer.com>
parents:
17888
diff
changeset
|
295 /* Delayed buzz MUST NOT be accepted */ |
9686d549f084
Switched buzz namespace and tag name to be libpurple-specific and use a more professionally-sounding name ('attention' instead of 'buzz').
Andreas Monitzer <pidgin@monitzer.com>
parents:
17888
diff
changeset
|
296 if(jm->delayed) |
9686d549f084
Switched buzz namespace and tag name to be libpurple-specific and use a more professionally-sounding name ('attention' instead of 'buzz').
Andreas Monitzer <pidgin@monitzer.com>
parents:
17888
diff
changeset
|
297 return; |
9686d549f084
Switched buzz namespace and tag name to be libpurple-specific and use a more professionally-sounding name ('attention' instead of 'buzz').
Andreas Monitzer <pidgin@monitzer.com>
parents:
17888
diff
changeset
|
298 |
17890
935005186312
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17889
diff
changeset
|
299 /* Reject buzz when it's not enabled */ |
935005186312
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17889
diff
changeset
|
300 if(!jm->js->allowBuzz) |
935005186312
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17889
diff
changeset
|
301 return; |
935005186312
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17889
diff
changeset
|
302 |
17888
cca457b9158b
disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents:
17887
diff
changeset
|
303 account = purple_connection_get_account(jm->js->gc); |
cca457b9158b
disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents:
17887
diff
changeset
|
304 |
cca457b9158b
disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents:
17887
diff
changeset
|
305 if ((buddy = purple_find_buddy(account, jm->from)) != NULL) |
cca457b9158b
disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents:
17887
diff
changeset
|
306 username = g_markup_escape_text(purple_buddy_get_alias(buddy), -1); |
cca457b9158b
disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents:
17887
diff
changeset
|
307 else |
17889
9686d549f084
Switched buzz namespace and tag name to be libpurple-specific and use a more professionally-sounding name ('attention' instead of 'buzz').
Andreas Monitzer <pidgin@monitzer.com>
parents:
17888
diff
changeset
|
308 return; /* Do not accept buzzes from unknown people */ |
9686d549f084
Switched buzz namespace and tag name to be libpurple-specific and use a more professionally-sounding name ('attention' instead of 'buzz').
Andreas Monitzer <pidgin@monitzer.com>
parents:
17888
diff
changeset
|
309 |
9686d549f084
Switched buzz namespace and tag name to be libpurple-specific and use a more professionally-sounding name ('attention' instead of 'buzz').
Andreas Monitzer <pidgin@monitzer.com>
parents:
17888
diff
changeset
|
310 c = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, jm->from); |
9686d549f084
Switched buzz namespace and tag name to be libpurple-specific and use a more professionally-sounding name ('attention' instead of 'buzz').
Andreas Monitzer <pidgin@monitzer.com>
parents:
17888
diff
changeset
|
311 |
19718
159a46ec0e33
Make the XMPP buzz string match the Yahoo one to help the translators.
Richard Laager <rlaager@wiktel.com>
parents:
19697
diff
changeset
|
312 str = g_strdup_printf(_("%s has buzzed you!"), username); |
17888
cca457b9158b
disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents:
17887
diff
changeset
|
313 |
cca457b9158b
disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents:
17887
diff
changeset
|
314 purple_conversation_write(c, NULL, str, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NOTIFY, time(NULL)); |
29244
22b8a92fb5ee
Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <ml@update.uu.se>
parents:
24180
diff
changeset
|
315 purple_conversation_attention(c, username, 0, PURPLE_MESSAGE_RECV, time(NULL)); |
17888
cca457b9158b
disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents:
17887
diff
changeset
|
316 g_free(username); |
cca457b9158b
disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents:
17887
diff
changeset
|
317 g_free(str); |
cca457b9158b
disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents:
17887
diff
changeset
|
318 } |
cca457b9158b
disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents:
17887
diff
changeset
|
319 |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
320 /* used internally by the functions below */ |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
321 typedef struct { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
322 gchar *cid; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
323 gchar *alt; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
324 } JabberSmileyRef; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
325 |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
326 |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
327 static void |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
328 jabber_message_get_refs_from_xmlnode_internal(const xmlnode *message, |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
329 GHashTable *table) |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
330 { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
331 xmlnode *child; |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
332 |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
333 for (child = xmlnode_get_child(message, "img") ; child ; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
334 child = xmlnode_get_next_twin(child)) { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
335 const gchar *src = xmlnode_get_attrib(child, "src"); |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
336 |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
337 if (g_str_has_prefix(src, "cid:")) { |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
338 const gchar *cid = src + 4; |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
339 |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
340 /* if we haven't "fetched" this yet... */ |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
341 if (!g_hash_table_lookup(table, cid)) { |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
342 /* take a copy of the cid and let the SmileyRef own it... */ |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
343 gchar *temp_cid = g_strdup(cid); |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
344 JabberSmileyRef *ref = g_new0(JabberSmileyRef, 1); |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
345 const gchar *alt = xmlnode_get_attrib(child, "alt"); |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
346 ref->cid = temp_cid; |
24062
f1ead28fcc5a
When receiving an <img/> without the "alt" attribute, set
Marcus Lundblad <ml@update.uu.se>
parents:
24061
diff
changeset
|
347 /* if there is no "alt" string, use the cid... |
f1ead28fcc5a
When receiving an <img/> without the "alt" attribute, set
Marcus Lundblad <ml@update.uu.se>
parents:
24061
diff
changeset
|
348 include the entire src, eg. "cid:.." to avoid linkification */ |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
349 if (alt && alt[0] != '\0') { |
24063
463240455f55
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents:
24062
diff
changeset
|
350 /* workaround for when "alt" is set to the value of the |
463240455f55
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents:
24062
diff
changeset
|
351 CID (which Jabbim seems to do), to avoid it showing up |
463240455f55
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents:
24062
diff
changeset
|
352 as an mailto: link */ |
463240455f55
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents:
24062
diff
changeset
|
353 if (purple_email_is_valid(alt)) { |
463240455f55
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents:
24062
diff
changeset
|
354 ref->alt = g_strdup_printf("smiley:%s", alt); |
463240455f55
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents:
24062
diff
changeset
|
355 } else { |
463240455f55
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents:
24062
diff
changeset
|
356 ref->alt = g_strdup(alt); |
463240455f55
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents:
24062
diff
changeset
|
357 } |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
358 } else { |
24062
f1ead28fcc5a
When receiving an <img/> without the "alt" attribute, set
Marcus Lundblad <ml@update.uu.se>
parents:
24061
diff
changeset
|
359 ref->alt = g_strdup(src); |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
360 } |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
361 g_hash_table_insert(table, temp_cid, ref); |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
362 } |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
363 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
364 } |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
365 |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
366 for (child = message->child ; child ; child = child->next) { |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
367 jabber_message_get_refs_from_xmlnode_internal(child, table); |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
368 } |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
369 } |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
370 |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
371 static gboolean |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
372 jabber_message_get_refs_steal(gpointer key, gpointer value, gpointer user_data) |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
373 { |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
374 GList **refs = (GList **) user_data; |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
375 JabberSmileyRef *ref = (JabberSmileyRef *) value; |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
376 |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
377 *refs = g_list_append(*refs, ref); |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
378 |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
379 return TRUE; |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
380 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
381 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
382 static GList * |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
383 jabber_message_get_refs_from_xmlnode(const xmlnode *message) |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
384 { |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
385 GList *refs = NULL; |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
386 GHashTable *unique_refs = g_hash_table_new(g_str_hash, g_str_equal); |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
387 |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
388 jabber_message_get_refs_from_xmlnode_internal(message, unique_refs); |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
389 (void) g_hash_table_foreach_steal(unique_refs, |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
390 jabber_message_get_refs_steal, (gpointer) &refs); |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
391 g_hash_table_destroy(unique_refs); |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
392 return refs; |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
393 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
394 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
395 static gchar * |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
396 jabber_message_xml_to_string_strip_img_smileys(xmlnode *xhtml) |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
397 { |
24180
14915e96311e
Another memory leak fix. Also, keep a copy of the alt-text in
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24179
diff
changeset
|
398 gchar *markup = xmlnode_to_str(xhtml, NULL); |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
399 int len = strlen(markup); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
400 int pos = 0; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
401 GString *out = g_string_new(NULL); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
402 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
403 while (pos < len) { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
404 /* this is a bit cludgy, maybe there is a better way to do this... |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
405 we need to find all <img> tags within the XHTML and replace those |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
406 tags with the value of their "alt" attributes */ |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
407 if (g_str_has_prefix(&(markup[pos]), "<img")) { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
408 xmlnode *img = NULL; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
409 int pos2 = pos; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
410 const gchar *src; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
411 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
412 for (; pos2 < len ; pos2++) { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
413 if (g_str_has_prefix(&(markup[pos2]), "/>")) { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
414 pos2 += 2; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
415 break; |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
416 } else if (g_str_has_prefix(&(markup[pos2]), "</img>")) { |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
417 pos2 += 5; |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
418 break; |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
419 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
420 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
421 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
422 /* note, if the above loop didn't find the end of the <img> tag, |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
423 it the parsed string will be until the end of the input string, |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
424 in which case xmlnode_from_str will bail out and return NULL, |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
425 in this case the "if" statement below doesn't trigger and the |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
426 text is copied unchanged */ |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
427 img = xmlnode_from_str(&(markup[pos]), pos2 - pos); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
428 src = xmlnode_get_attrib(img, "src"); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
429 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
430 if (g_str_has_prefix(src, "cid:")) { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
431 const gchar *alt = xmlnode_get_attrib(img, "alt"); |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
432 /* if the "alt" attribute is empty, put the cid as smiley string */ |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
433 if (alt && alt[0] != '\0') { |
24063
463240455f55
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents:
24062
diff
changeset
|
434 /* if the "alt" is the same as the CID, as Jabbim does, |
463240455f55
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents:
24062
diff
changeset
|
435 this prevents linkification... */ |
463240455f55
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents:
24062
diff
changeset
|
436 if (purple_email_is_valid(alt)) { |
24179
2c6c9d72f54f
A couple of compile warning fixes, a couple of memory leak plugs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24063
diff
changeset
|
437 gchar *safe_alt = g_strdup_printf("smiley:%s", alt); |
24063
463240455f55
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents:
24062
diff
changeset
|
438 out = g_string_append(out, safe_alt); |
463240455f55
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents:
24062
diff
changeset
|
439 g_free(safe_alt); |
463240455f55
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents:
24062
diff
changeset
|
440 } else { |
463240455f55
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents:
24062
diff
changeset
|
441 out = g_string_append(out, alt); |
463240455f55
Added a workaround for receiving smileys from Jabbim,
Marcus Lundblad <ml@update.uu.se>
parents:
24062
diff
changeset
|
442 } |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
443 } else { |
24062
f1ead28fcc5a
When receiving an <img/> without the "alt" attribute, set
Marcus Lundblad <ml@update.uu.se>
parents:
24061
diff
changeset
|
444 out = g_string_append(out, src); |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
445 } |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
446 pos += pos2 - pos; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
447 } else { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
448 out = g_string_append_c(out, markup[pos]); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
449 pos++; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
450 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
451 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
452 xmlnode_free(img); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
453 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
454 } else { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
455 out = g_string_append_c(out, markup[pos]); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
456 pos++; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
457 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
458 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
459 |
24180
14915e96311e
Another memory leak fix. Also, keep a copy of the alt-text in
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24179
diff
changeset
|
460 g_free(markup); |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
461 return g_string_free(out, FALSE); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
462 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
463 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
464 static void |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
465 jabber_message_add_remote_smileys(const xmlnode *message) |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
466 { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
467 xmlnode *data_tag; |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
468 for (data_tag = xmlnode_get_child_with_namespace(message, "data", XEP_0231_NAMESPACE) ; |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
469 data_tag ; |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
470 data_tag = xmlnode_get_next_twin(data_tag)) { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
471 const gchar *cid = xmlnode_get_attrib(data_tag, "cid"); |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
472 const JabberData *data = jabber_data_find_remote_by_cid(cid); |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
473 |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
474 if (!data && cid != NULL) { |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
475 /* we haven't cached this already, let's add it */ |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
476 JabberData *new_data = jabber_data_create_from_xml(data_tag); |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
477 jabber_data_associate_remote(new_data); |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
478 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
479 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
480 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
481 |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
482 /* used in the function below to supply a conversation and shortcut for a |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
483 smiley */ |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
484 typedef struct { |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
485 PurpleConversation *conv; |
24180
14915e96311e
Another memory leak fix. Also, keep a copy of the alt-text in
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24179
diff
changeset
|
486 gchar *alt; |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
487 } JabberDataRef; |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
488 |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
489 static void |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
490 jabber_message_get_data_cb(JabberStream *js, xmlnode *packet, gpointer data) |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
491 { |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
492 JabberDataRef *ref = (JabberDataRef *) data; |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
493 PurpleConversation *conv = ref->conv; |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
494 const gchar *alt = ref->alt; |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
495 xmlnode *data_element = xmlnode_get_child(packet, "data"); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
496 xmlnode *item_not_found = xmlnode_get_child(packet, "item-not-found"); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
497 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
498 /* did we get a data element as result? */ |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
499 if (data_element) { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
500 JabberData *data = jabber_data_create_from_xml(data_element); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
501 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
502 if (data) { |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
503 jabber_data_associate_remote(data); |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
504 purple_conv_custom_smiley_write(conv, alt, |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
505 jabber_data_get_data(data), |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
506 jabber_data_get_size(data)); |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
507 purple_conv_custom_smiley_close(conv, alt); |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
508 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
509 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
510 } else if (item_not_found) { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
511 purple_debug_info("jabber", |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
512 "Responder didn't recognize requested data\n"); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
513 } else { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
514 purple_debug_error("jabber", "Unknown response to data request\n"); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
515 } |
24180
14915e96311e
Another memory leak fix. Also, keep a copy of the alt-text in
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24179
diff
changeset
|
516 g_free(ref->alt); |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
517 g_free(ref); |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
518 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
519 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
520 static void |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
521 jabber_message_send_data_request(JabberStream *js, PurpleConversation *conv, |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
522 const gchar *cid, const gchar *who, |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
523 const gchar *alt) |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
524 { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
525 JabberIq *request = jabber_iq_new(js, JABBER_IQ_GET); |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
526 JabberDataRef *ref = g_new0(JabberDataRef, 1); |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
527 xmlnode *data_request = jabber_data_get_xml_request(cid); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
528 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
529 xmlnode_set_attrib(request->node, "to", who); |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
530 ref->conv = conv; |
24180
14915e96311e
Another memory leak fix. Also, keep a copy of the alt-text in
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24179
diff
changeset
|
531 ref->alt = g_strdup(alt); |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
532 jabber_iq_set_callback(request, jabber_message_get_data_cb, ref); |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
533 xmlnode_insert_child(request->node, data_request); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
534 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
535 jabber_iq_send(request); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
536 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
537 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
538 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
539 void jabber_message_parse(JabberStream *js, xmlnode *packet) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
540 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
541 JabberMessage *jm; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
542 const char *type; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
543 xmlnode *child; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
544 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
545 jm = g_new0(JabberMessage, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
546 jm->js = js; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
547 jm->sent = time(NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
548 jm->delayed = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
549 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
550 type = xmlnode_get_attrib(packet, "type"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
551 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
552 if(type) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
553 if(!strcmp(type, "normal")) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
554 jm->type = JABBER_MESSAGE_NORMAL; |
20058
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19718
diff
changeset
|
555 else if(!strcmp(type, "chat")) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
556 jm->type = JABBER_MESSAGE_CHAT; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
557 else if(!strcmp(type, "groupchat")) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
558 jm->type = JABBER_MESSAGE_GROUPCHAT; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
559 else if(!strcmp(type, "headline")) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
560 jm->type = JABBER_MESSAGE_HEADLINE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
561 else if(!strcmp(type, "error")) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
562 jm->type = JABBER_MESSAGE_ERROR; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
563 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
564 jm->type = JABBER_MESSAGE_OTHER; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
565 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
566 jm->type = JABBER_MESSAGE_NORMAL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
567 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
568 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
569 jm->from = g_strdup(xmlnode_get_attrib(packet, "from")); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
570 jm->to = g_strdup(xmlnode_get_attrib(packet, "to")); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
571 jm->id = g_strdup(xmlnode_get_attrib(packet, "id")); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
572 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
573 for(child = packet->child; child; child = child->next) { |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17842
diff
changeset
|
574 const char *xmlns = xmlnode_get_namespace(child); |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17842
diff
changeset
|
575 if(!xmlns) |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17842
diff
changeset
|
576 xmlns = ""; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
577 if(child->type != XMLNODE_TYPE_TAG) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
578 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
579 |
17858
d8ce7ff7aeb3
Fixed a bug that resulted in not being able to receive any messages.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17846
diff
changeset
|
580 if(!strcmp(child->name, "subject") && !strcmp(xmlns,"jabber:client")) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
581 if(!jm->subject) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
582 jm->subject = xmlnode_get_data(child); |
17858
d8ce7ff7aeb3
Fixed a bug that resulted in not being able to receive any messages.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17846
diff
changeset
|
583 } else if(!strcmp(child->name, "thread") && !strcmp(xmlns,"jabber:client")) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
584 if(!jm->thread_id) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
585 jm->thread_id = xmlnode_get_data(child); |
17858
d8ce7ff7aeb3
Fixed a bug that resulted in not being able to receive any messages.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17846
diff
changeset
|
586 } else if(!strcmp(child->name, "body") && !strcmp(xmlns,"jabber:client")) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
587 if(!jm->body) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
588 char *msg = xmlnode_to_str(child, NULL); |
15822 | 589 jm->body = purple_strdup_withhtml(msg); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
590 g_free(msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
591 } |
17834
a75079eae085
added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
17258
diff
changeset
|
592 } else if(!strcmp(child->name, "html") && !strcmp(xmlns,"http://jabber.org/protocol/xhtml-im")) { |
17236
77b15be2179f
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@gmail.com>
parents:
16904
diff
changeset
|
593 if(!jm->xhtml && xmlnode_get_child(child, "body")) { |
77b15be2179f
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@gmail.com>
parents:
16904
diff
changeset
|
594 char *c; |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
595 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
596 const PurpleConnection *gc = js->gc; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
597 const gchar *who = xmlnode_get_attrib(packet, "from"); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
598 PurpleAccount *account = purple_connection_get_account(gc); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
599 PurpleConversation *conv = NULL; |
24179
2c6c9d72f54f
A couple of compile warning fixes, a couple of memory leak plugs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24063
diff
changeset
|
600 GList *smiley_refs = NULL; |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
601 gchar *reformatted_xhtml; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
602 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
603 if (purple_account_get_bool(account, "custom_smileys", TRUE)) { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
604 /* find a list of smileys ("cid" and "alt" text pairs) |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
605 occuring in the message */ |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
606 smiley_refs = jabber_message_get_refs_from_xmlnode(child); |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
607 purple_debug_info("jabber", "found %d smileys\n", |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
608 g_list_length(smiley_refs)); |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
609 |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
610 if (jm->type == JABBER_MESSAGE_GROUPCHAT) { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
611 JabberID *jid = jabber_id_new(jm->from); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
612 JabberChat *chat = NULL; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
613 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
614 if (jid) { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
615 chat = jabber_chat_find(js, jid->node, jid->domain); |
24448
71c42ce1a1df
I got a crash happened at dereferencing chat when it's NULL, I think this
Ka-Hing Cheung <khc@hxbc.us>
parents:
24180
diff
changeset
|
616 if (chat) conv = chat->conv; |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
617 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
618 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
619 jabber_id_free(jid); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
620 } else { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
621 conv = |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
622 purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
623 who, account); |
24061
fba7c73c8f02
Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <ml@update.uu.se>
parents:
24058
diff
changeset
|
624 if (!conv) { |
fba7c73c8f02
Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <ml@update.uu.se>
parents:
24058
diff
changeset
|
625 /* we need to create the conversation here */ |
fba7c73c8f02
Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <ml@update.uu.se>
parents:
24058
diff
changeset
|
626 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, |
fba7c73c8f02
Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <ml@update.uu.se>
parents:
24058
diff
changeset
|
627 account, who); |
fba7c73c8f02
Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <ml@update.uu.se>
parents:
24058
diff
changeset
|
628 } |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
629 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
630 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
631 /* process any newly provided smileys */ |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
632 jabber_message_add_remote_smileys(packet); |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
633 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
634 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
635 /* reformat xhtml so that img tags with a "cid:" src gets |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
636 translated to the bare text of the emoticon (the "alt" attrib) */ |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
637 /* this is done also when custom smiley retrieval is turned off, |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
638 this way the receiver always sees the shortcut instead */ |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
639 reformatted_xhtml = |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
640 jabber_message_xml_to_string_strip_img_smileys(child); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
641 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
642 jm->xhtml = reformatted_xhtml; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
643 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
644 /* add known custom emoticons to the conversation */ |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
645 /* note: if there were no smileys in the incoming message, or |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
646 if receiving custom smileys is turned off, smiley_refs will |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
647 be NULL */ |
24448
71c42ce1a1df
I got a crash happened at dereferencing chat when it's NULL, I think this
Ka-Hing Cheung <khc@hxbc.us>
parents:
24180
diff
changeset
|
648 for (; conv && smiley_refs ; smiley_refs = g_list_delete_link(smiley_refs, smiley_refs)) { |
24180
14915e96311e
Another memory leak fix. Also, keep a copy of the alt-text in
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24179
diff
changeset
|
649 JabberSmileyRef *ref = (JabberSmileyRef *) smiley_refs->data; |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
650 const gchar *cid = ref->cid; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
651 const gchar *alt = ref->alt; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
652 |
24061
fba7c73c8f02
Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <ml@update.uu.se>
parents:
24058
diff
changeset
|
653 purple_debug_info("jabber", |
fba7c73c8f02
Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <ml@update.uu.se>
parents:
24058
diff
changeset
|
654 "about to add custom smiley %s to the conv\n", alt); |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
655 if (purple_conv_custom_smiley_add(conv, alt, "cid", cid, |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
656 TRUE)) { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
657 const JabberData *data = |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
658 jabber_data_find_remote_by_cid(cid); |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
659 /* if data is already known, we add write it immediatly */ |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
660 if (data) { |
24061
fba7c73c8f02
Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <ml@update.uu.se>
parents:
24058
diff
changeset
|
661 purple_debug_info("jabber", |
fba7c73c8f02
Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <ml@update.uu.se>
parents:
24058
diff
changeset
|
662 "data is already known\n"); |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
663 purple_conv_custom_smiley_write(conv, alt, |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
664 jabber_data_get_data(data), |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
665 jabber_data_get_size(data)); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
666 purple_conv_custom_smiley_close(conv, alt); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
667 } else { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
668 /* we need to request the smiley (data) */ |
24061
fba7c73c8f02
Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <ml@update.uu.se>
parents:
24058
diff
changeset
|
669 purple_debug_info("jabber", |
fba7c73c8f02
Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <ml@update.uu.se>
parents:
24058
diff
changeset
|
670 "data is unknown, need to request it\n"); |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
671 jabber_message_send_data_request(js, conv, cid, who, |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
672 alt); |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
673 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
674 } |
24180
14915e96311e
Another memory leak fix. Also, keep a copy of the alt-text in
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24179
diff
changeset
|
675 g_free(ref->cid); |
14915e96311e
Another memory leak fix. Also, keep a copy of the alt-text in
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24179
diff
changeset
|
676 g_free(ref->alt); |
14915e96311e
Another memory leak fix. Also, keep a copy of the alt-text in
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24179
diff
changeset
|
677 g_free(ref); |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
678 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
679 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
680 /* Convert all newlines to whitespace. Technically, even regular, non-XML HTML is supposed to ignore newlines, but Pidgin has, as convention |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
681 * treated \n as a newline for compatibility with other protocols |
17236
77b15be2179f
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@gmail.com>
parents:
16904
diff
changeset
|
682 */ |
77b15be2179f
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@gmail.com>
parents:
16904
diff
changeset
|
683 for (c = jm->xhtml; *c != '\0'; c++) { |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
684 if (*c == '\n') |
17236
77b15be2179f
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@gmail.com>
parents:
16904
diff
changeset
|
685 *c = ' '; |
77b15be2179f
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@gmail.com>
parents:
16904
diff
changeset
|
686 } |
77b15be2179f
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@gmail.com>
parents:
16904
diff
changeset
|
687 } |
17834
a75079eae085
added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
17258
diff
changeset
|
688 } else if(!strcmp(child->name, "active") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
689 jm->chat_state = JM_STATE_ACTIVE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
690 jm->typing_style |= JM_TS_JEP_0085; |
17834
a75079eae085
added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
17258
diff
changeset
|
691 } else if(!strcmp(child->name, "composing") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
692 jm->chat_state = JM_STATE_COMPOSING; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
693 jm->typing_style |= JM_TS_JEP_0085; |
17834
a75079eae085
added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
17258
diff
changeset
|
694 } else if(!strcmp(child->name, "paused") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
695 jm->chat_state = JM_STATE_PAUSED; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
696 jm->typing_style |= JM_TS_JEP_0085; |
17834
a75079eae085
added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
17258
diff
changeset
|
697 } else if(!strcmp(child->name, "inactive") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
698 jm->chat_state = JM_STATE_INACTIVE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
699 jm->typing_style |= JM_TS_JEP_0085; |
17834
a75079eae085
added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
17258
diff
changeset
|
700 } else if(!strcmp(child->name, "gone") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
701 jm->chat_state = JM_STATE_GONE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
702 jm->typing_style |= JM_TS_JEP_0085; |
17840
cac26c30047a
Implemented <required/> for x-data forms, simplified malloc/sprintf, message type headline is not a requirement for incoming PEP messages (it is just recommended to avoid offline message storage).
Andreas Monitzer <pidgin@monitzer.com>
parents:
17834
diff
changeset
|
703 } else if(!strcmp(child->name, "event") && !strcmp(xmlns,"http://jabber.org/protocol/pubsub#event")) { |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17842
diff
changeset
|
704 xmlnode *items; |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17842
diff
changeset
|
705 jm->type = JABBER_MESSAGE_EVENT; |
17846
2f067d8fb19a
Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17845
diff
changeset
|
706 for(items = xmlnode_get_child(child,"items"); items; items = items->next) |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17842
diff
changeset
|
707 jm->eventitems = g_list_append(jm->eventitems, items); |
25133
f763be370afb
Updated to new namespace for XEP-0224.
Marcus Lundblad <ml@update.uu.se>
parents:
24180
diff
changeset
|
708 } else if(!strcmp(child->name, "attention") && !strcmp(xmlns, XEP_0224_NAMESPACE)) { |
17888
cca457b9158b
disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents:
17887
diff
changeset
|
709 jm->hasBuzz = TRUE; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
710 } else if(!strcmp(child->name, "error")) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
711 const char *code = xmlnode_get_attrib(child, "code"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
712 char *code_txt = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
713 char *text = xmlnode_get_data(child); |
23073
e765c7261f88
If we receive a "text" child for an error, include it as the message text
Evan Schoenberg <evan.s@dreskin.net>
parents:
21284
diff
changeset
|
714 if (!text) { |
e765c7261f88
If we receive a "text" child for an error, include it as the message text
Evan Schoenberg <evan.s@dreskin.net>
parents:
21284
diff
changeset
|
715 xmlnode *enclosed_text_node; |
e765c7261f88
If we receive a "text" child for an error, include it as the message text
Evan Schoenberg <evan.s@dreskin.net>
parents:
21284
diff
changeset
|
716 |
e765c7261f88
If we receive a "text" child for an error, include it as the message text
Evan Schoenberg <evan.s@dreskin.net>
parents:
21284
diff
changeset
|
717 if ((enclosed_text_node = xmlnode_get_child(child, "text"))) |
e765c7261f88
If we receive a "text" child for an error, include it as the message text
Evan Schoenberg <evan.s@dreskin.net>
parents:
21284
diff
changeset
|
718 text = xmlnode_get_data(enclosed_text_node); |
e765c7261f88
If we receive a "text" child for an error, include it as the message text
Evan Schoenberg <evan.s@dreskin.net>
parents:
21284
diff
changeset
|
719 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
720 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
721 if(code) |
23077
8fbfe45506a2
Don't include the space in the localized text at all for the text/code error separation
Evan Schoenberg <evan.s@dreskin.net>
parents:
23076
diff
changeset
|
722 code_txt = g_strdup_printf(_("(Code %s)"), code); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
723 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
724 if(!jm->error) |
23077
8fbfe45506a2
Don't include the space in the localized text at all for the text/code error separation
Evan Schoenberg <evan.s@dreskin.net>
parents:
23076
diff
changeset
|
725 jm->error = g_strdup_printf("%s%s%s", |
8fbfe45506a2
Don't include the space in the localized text at all for the text/code error separation
Evan Schoenberg <evan.s@dreskin.net>
parents:
23076
diff
changeset
|
726 text ? text : "", |
23082 | 727 text && code_txt ? " " : "", |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
728 code_txt ? code_txt : ""); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
729 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
730 g_free(code_txt); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
731 g_free(text); |
17877
34411cc535de
Implemented XEP-0203: Delayed Delivery
Andreas Monitzer <pidgin@monitzer.com>
parents:
17858
diff
changeset
|
732 } else if(!strcmp(child->name, "delay") && xmlns && !strcmp(xmlns,"urn:xmpp:delay")) { |
34411cc535de
Implemented XEP-0203: Delayed Delivery
Andreas Monitzer <pidgin@monitzer.com>
parents:
17858
diff
changeset
|
733 const char *timestamp = xmlnode_get_attrib(child, "stamp"); |
34411cc535de
Implemented XEP-0203: Delayed Delivery
Andreas Monitzer <pidgin@monitzer.com>
parents:
17858
diff
changeset
|
734 jm->delayed = TRUE; |
34411cc535de
Implemented XEP-0203: Delayed Delivery
Andreas Monitzer <pidgin@monitzer.com>
parents:
17858
diff
changeset
|
735 if(timestamp) |
34411cc535de
Implemented XEP-0203: Delayed Delivery
Andreas Monitzer <pidgin@monitzer.com>
parents:
17858
diff
changeset
|
736 jm->sent = purple_str_to_time(timestamp, TRUE, NULL, NULL, NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
737 } else if(!strcmp(child->name, "x")) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
738 if(xmlns && !strcmp(xmlns, "jabber:x:event")) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
739 if(xmlnode_get_child(child, "composing")) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
740 if(jm->chat_state == JM_STATE_ACTIVE) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
741 jm->chat_state = JM_STATE_COMPOSING; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
742 jm->typing_style |= JM_TS_JEP_0022; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
743 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
744 } else if(xmlns && !strcmp(xmlns, "jabber:x:delay")) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
745 const char *timestamp = xmlnode_get_attrib(child, "stamp"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
746 jm->delayed = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
747 if(timestamp) |
15822 | 748 jm->sent = purple_str_to_time(timestamp, TRUE, NULL, NULL, NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
749 } else if(xmlns && !strcmp(xmlns, "jabber:x:conference") && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
750 jm->type != JABBER_MESSAGE_GROUPCHAT_INVITE && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
751 jm->type != JABBER_MESSAGE_ERROR) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
752 const char *jid = xmlnode_get_attrib(child, "jid"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
753 if(jid) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
754 jm->type = JABBER_MESSAGE_GROUPCHAT_INVITE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
755 g_free(jm->to); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
756 jm->to = g_strdup(jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
757 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
758 } else if(xmlns && !strcmp(xmlns, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
759 "http://jabber.org/protocol/muc#user") && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
760 jm->type != JABBER_MESSAGE_ERROR) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
761 xmlnode *invite = xmlnode_get_child(child, "invite"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
762 if(invite) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
763 xmlnode *reason, *password; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
764 const char *jid = xmlnode_get_attrib(invite, "from"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
765 g_free(jm->to); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
766 jm->to = jm->from; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
767 jm->from = g_strdup(jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
768 if((reason = xmlnode_get_child(invite, "reason"))) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
769 g_free(jm->body); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
770 jm->body = xmlnode_get_data(reason); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
771 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
772 if((password = xmlnode_get_child(child, "password"))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
773 jm->password = xmlnode_get_data(password); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
774 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
775 jm->type = JABBER_MESSAGE_GROUPCHAT_INVITE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
776 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
777 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
778 jm->etc = g_list_append(jm->etc, child); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
779 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
780 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
781 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
782 |
17888
cca457b9158b
disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents:
17887
diff
changeset
|
783 if(jm->hasBuzz) |
cca457b9158b
disapproval of revision '217714a0fa711773c0d419f8cd82297ffc339507'
Andreas Monitzer <pidgin@monitzer.com>
parents:
17887
diff
changeset
|
784 handle_buzz(jm); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
785 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
786 switch(jm->type) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
787 case JABBER_MESSAGE_NORMAL: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
788 case JABBER_MESSAGE_CHAT: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
789 handle_chat(jm); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
790 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
791 case JABBER_MESSAGE_HEADLINE: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
792 handle_headline(jm); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
793 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
794 case JABBER_MESSAGE_GROUPCHAT: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
795 handle_groupchat(jm); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
796 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
797 case JABBER_MESSAGE_GROUPCHAT_INVITE: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
798 handle_groupchat_invite(jm); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
799 break; |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17842
diff
changeset
|
800 case JABBER_MESSAGE_EVENT: |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17842
diff
changeset
|
801 jabber_handle_event(jm); |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17842
diff
changeset
|
802 break; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
803 case JABBER_MESSAGE_ERROR: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
804 handle_error(jm); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
805 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
806 case JABBER_MESSAGE_OTHER: |
15822 | 807 purple_debug(PURPLE_DEBUG_INFO, "jabber", |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
808 "Received message of unknown type: %s\n", type); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
809 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
810 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
811 jabber_message_free(jm); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
812 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
813 |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
814 static const gchar * |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
815 jabber_message_get_mimetype_from_ext(const gchar *ext) |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
816 { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
817 if (strcmp(ext, "png") == 0) { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
818 return "image/png"; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
819 } else if (strcmp(ext, "gif") == 0) { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
820 return "image/gif"; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
821 } else if (strcmp(ext, "jpg") == 0) { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
822 return "image/jpeg"; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
823 } else if (strcmp(ext, "tif") == 0) { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
824 return "image/tif"; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
825 } else { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
826 return "image/x-icon"; /* or something... */ |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
827 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
828 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
829 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
830 static GList * |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
831 jabber_message_xhtml_find_smileys(const char *xhtml) |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
832 { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
833 GList *smileys = purple_smileys_get_all(); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
834 GList *found_smileys = NULL; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
835 |
23779
b2697ab66d23
Ooops ... compile\!
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23778
diff
changeset
|
836 for (; smileys ; smileys = g_list_delete_link(smileys, smileys)) { |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
837 PurpleSmiley *smiley = (PurpleSmiley *) smileys->data; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
838 const gchar *shortcut = purple_smiley_get_shortcut(smiley); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
839 const gssize len = strlen(shortcut); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
840 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
841 gchar *escaped = g_markup_escape_text(shortcut, len); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
842 const char *pos = strstr(xhtml, escaped); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
843 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
844 if (pos) { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
845 found_smileys = g_list_append(found_smileys, smiley); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
846 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
847 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
848 g_free(escaped); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
849 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
850 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
851 return found_smileys; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
852 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
853 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
854 static gchar * |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
855 jabber_message_get_smileyfied_xhtml(const gchar *xhtml, const GList *smileys) |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
856 { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
857 /* create XML element for all smileys (img tags) */ |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
858 GString *result = g_string_new(NULL); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
859 int pos = 0; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
860 int length = strlen(xhtml); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
861 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
862 while (pos < length) { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
863 const GList *iterator; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
864 gboolean found_smiley = FALSE; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
865 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
866 for (iterator = smileys ; iterator ; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
867 iterator = g_list_next(iterator)) { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
868 const PurpleSmiley *smiley = (PurpleSmiley *) iterator->data; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
869 const gchar *shortcut = purple_smiley_get_shortcut(smiley); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
870 const gssize len = strlen(shortcut); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
871 gchar *escaped = g_markup_escape_text(shortcut, len); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
872 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
873 if (g_str_has_prefix(&(xhtml[pos]), escaped)) { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
874 /* we found the current smiley at this position */ |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
875 const JabberData *data = |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
876 jabber_data_find_local_by_alt(shortcut); |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
877 xmlnode *img = jabber_data_get_xhtml_im(data, shortcut); |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
878 int len; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
879 gchar *img_text = xmlnode_to_str(img, &len); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
880 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
881 found_smiley = TRUE; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
882 result = g_string_append(result, img_text); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
883 g_free(img_text); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
884 pos += strlen(escaped); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
885 g_free(escaped); |
24179
2c6c9d72f54f
A couple of compile warning fixes, a couple of memory leak plugs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24063
diff
changeset
|
886 xmlnode_free(img); |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
887 break; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
888 } else { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
889 /* cleanup from the before the next round... */ |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
890 g_free(escaped); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
891 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
892 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
893 if (!found_smiley) { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
894 /* there was no smiley here, just copy one byte */ |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
895 result = g_string_append_c(result, xhtml[pos]); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
896 pos++; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
897 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
898 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
899 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
900 return g_string_free(result, FALSE); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
901 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
902 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
903 static gboolean |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
904 jabber_conv_support_custom_smileys(const PurpleConnection *gc, |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
905 const PurpleConversation *conv, |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
906 const gchar *who) |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
907 { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
908 JabberStream *js = (JabberStream *) gc->proto_data; |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
909 JabberBuddy *jb; |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
910 |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
911 if (!js) { |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
912 purple_debug_error("jabber", |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
913 "jabber_conv_support_custom_smileys: could not find stream\n"); |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
914 return FALSE; |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
915 } |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
916 |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
917 jb = jabber_buddy_find(js, who, FALSE); |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
918 if (!jb) { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
919 purple_debug_error("jabber", |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
920 "jabber_conv_support_custom smileys: could not find buddy\n"); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
921 return FALSE; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
922 } |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
923 |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
924 |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
925 |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
926 switch (purple_conversation_get_type(conv)) { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
927 /* for the time being, we will not support custom smileys in MUCs */ |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
928 case PURPLE_CONV_TYPE_IM: |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
929 return jabber_buddy_has_capability(jb, XEP_0231_NAMESPACE); |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
930 break; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
931 default: |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
932 return FALSE; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
933 break; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
934 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
935 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
936 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
937 void jabber_message_send(JabberMessage *jm) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
938 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
939 xmlnode *message, *child; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
940 const char *type = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
941 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
942 message = xmlnode_new("message"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
943 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
944 switch(jm->type) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
945 case JABBER_MESSAGE_NORMAL: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
946 type = "normal"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
947 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
948 case JABBER_MESSAGE_CHAT: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
949 case JABBER_MESSAGE_GROUPCHAT_INVITE: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
950 type = "chat"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
951 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
952 case JABBER_MESSAGE_HEADLINE: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
953 type = "headline"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
954 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
955 case JABBER_MESSAGE_GROUPCHAT: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
956 type = "groupchat"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
957 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
958 case JABBER_MESSAGE_ERROR: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
959 type = "error"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
960 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
961 case JABBER_MESSAGE_OTHER: |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17842
diff
changeset
|
962 default: |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
963 type = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
964 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
965 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
966 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
967 if(type) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
968 xmlnode_set_attrib(message, "type", type); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
969 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
970 if (jm->id) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
971 xmlnode_set_attrib(message, "id", jm->id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
972 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
973 xmlnode_set_attrib(message, "to", jm->to); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
974 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
975 if(jm->thread_id) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
976 child = xmlnode_new_child(message, "thread"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
977 xmlnode_insert_data(child, jm->thread_id, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
978 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
979 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
980 if(JM_TS_JEP_0022 == (jm->typing_style & JM_TS_JEP_0022)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
981 child = xmlnode_new_child(message, "x"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
982 xmlnode_set_namespace(child, "jabber:x:event"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
983 if(jm->chat_state == JM_STATE_COMPOSING || jm->body) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
984 xmlnode_new_child(child, "composing"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
985 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
986 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
987 if(JM_TS_JEP_0085 == (jm->typing_style & JM_TS_JEP_0085)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
988 child = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
989 switch(jm->chat_state) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
990 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
991 case JM_STATE_ACTIVE: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
992 child = xmlnode_new_child(message, "active"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
993 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
994 case JM_STATE_COMPOSING: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
995 child = xmlnode_new_child(message, "composing"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
996 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
997 case JM_STATE_PAUSED: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
998 child = xmlnode_new_child(message, "paused"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
999 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1000 case JM_STATE_INACTIVE: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1001 child = xmlnode_new_child(message, "inactive"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1002 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1003 case JM_STATE_GONE: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1004 child = xmlnode_new_child(message, "gone"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1005 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1006 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1007 if(child) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1008 xmlnode_set_namespace(child, "http://jabber.org/protocol/chatstates"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1009 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1010 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1011 if(jm->subject) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1012 child = xmlnode_new_child(message, "subject"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1013 xmlnode_insert_data(child, jm->subject, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1014 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1015 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1016 if(jm->body) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1017 child = xmlnode_new_child(message, "body"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1018 xmlnode_insert_data(child, jm->body, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1019 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1020 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1021 if(jm->xhtml) { |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
1022 PurpleAccount *account = purple_connection_get_account(jm->js->gc); |
23778
44feef3c885c
A couple of leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23777
diff
changeset
|
1023 PurpleConversation *conv = |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
1024 purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, jm->to, |
23778
44feef3c885c
A couple of leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23777
diff
changeset
|
1025 account); |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
1026 |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
1027 if (jabber_conv_support_custom_smileys(jm->js->gc, conv, jm->to)) { |
23778
44feef3c885c
A couple of leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23777
diff
changeset
|
1028 GList *found_smileys = jabber_message_xhtml_find_smileys(jm->xhtml); |
44feef3c885c
A couple of leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23777
diff
changeset
|
1029 |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
1030 if (found_smileys) { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
1031 gchar *smileyfied_xhtml = NULL; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
1032 const GList *iterator; |
23778
44feef3c885c
A couple of leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23777
diff
changeset
|
1033 |
44feef3c885c
A couple of leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23777
diff
changeset
|
1034 for (iterator = found_smileys; iterator ; |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
1035 iterator = g_list_next(iterator)) { |
23778
44feef3c885c
A couple of leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23777
diff
changeset
|
1036 const PurpleSmiley *smiley = |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
1037 (PurpleSmiley *) iterator->data; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
1038 const gchar *shortcut = purple_smiley_get_shortcut(smiley); |
23778
44feef3c885c
A couple of leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23777
diff
changeset
|
1039 const JabberData *data = |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
1040 jabber_data_find_local_by_alt(shortcut); |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
1041 |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
1042 /* the object has not been sent before */ |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
1043 if (!data) { |
23778
44feef3c885c
A couple of leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23777
diff
changeset
|
1044 PurpleStoredImage *image = |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
1045 purple_smiley_get_stored_image(smiley); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
1046 const gchar *ext = purple_imgstore_get_extension(image); |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
1047 JabberStream *js = jm->js; |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
1048 |
23778
44feef3c885c
A couple of leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23777
diff
changeset
|
1049 JabberData *new_data = |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
1050 jabber_data_create_from_data(purple_imgstore_get_data(image), |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
1051 purple_imgstore_get_size(image), |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
1052 jabber_message_get_mimetype_from_ext(ext), js); |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
1053 purple_debug_info("jabber", |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
1054 "cache local smiley alt = %s, cid = %s\n", |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
1055 shortcut, jabber_data_get_cid(new_data)); |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
1056 jabber_data_associate_local(new_data, shortcut); |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
1057 } |
23778
44feef3c885c
A couple of leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23777
diff
changeset
|
1058 } |
44feef3c885c
A couple of leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23777
diff
changeset
|
1059 |
44feef3c885c
A couple of leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23777
diff
changeset
|
1060 smileyfied_xhtml = |
24058
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23779
diff
changeset
|
1061 jabber_message_get_smileyfied_xhtml(jm->xhtml, found_smileys); |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
1062 child = xmlnode_from_str(smileyfied_xhtml, -1); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
1063 g_free(smileyfied_xhtml); |
23778
44feef3c885c
A couple of leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23777
diff
changeset
|
1064 g_list_free(found_smileys); |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
1065 } else { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
1066 child = xmlnode_from_str(jm->xhtml, -1); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
1067 } |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
1068 } else { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
1069 child = xmlnode_from_str(jm->xhtml, -1); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
1070 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1071 if(child) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1072 xmlnode_insert_child(message, child); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1073 } else { |
15822 | 1074 purple_debug(PURPLE_DEBUG_ERROR, "jabber", |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1075 "XHTML translation/validation failed, returning: %s\n", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1076 jm->xhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1077 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1078 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1079 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1080 jabber_send(jm->js, message); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1081 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1082 xmlnode_free(message); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1083 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1084 |
15822 | 1085 int jabber_message_send_im(PurpleConnection *gc, const char *who, const char *msg, |
1086 PurpleMessageFlags flags) | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1087 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1088 JabberMessage *jm; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1089 JabberBuddy *jb; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1090 JabberBuddyResource *jbr; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1091 char *buf; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1092 char *xhtml; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1093 char *resource; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1094 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1095 if(!who || !msg) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1096 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1097 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1098 resource = jabber_get_resource(who); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1099 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1100 jb = jabber_buddy_find(gc->proto_data, who, TRUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1101 jbr = jabber_buddy_find_resource(jb, resource); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1102 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1103 g_free(resource); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1104 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1105 jm = g_new0(JabberMessage, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1106 jm->js = gc->proto_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1107 jm->type = JABBER_MESSAGE_CHAT; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1108 jm->chat_state = JM_STATE_ACTIVE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1109 jm->to = g_strdup(who); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1110 jm->id = jabber_get_next_id(jm->js); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1111 jm->chat_state = JM_STATE_ACTIVE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1112 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1113 if(jbr) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1114 if(jbr->thread_id) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1115 jm->thread_id = jbr->thread_id; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1116 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1117 if(jbr->chat_states != JABBER_CHAT_STATES_UNSUPPORTED) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1118 jm->typing_style |= JM_TS_JEP_0085; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1119 /* if(JABBER_CHAT_STATES_UNKNOWN == jbr->chat_states) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1120 jbr->chat_states = JABBER_CHAT_STATES_UNSUPPORTED; */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1121 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1122 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1123 if(jbr->chat_states != JABBER_CHAT_STATES_SUPPORTED) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1124 jm->typing_style |= JM_TS_JEP_0022; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1125 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1126 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1127 buf = g_strdup_printf("<html xmlns='http://jabber.org/protocol/xhtml-im'><body xmlns='http://www.w3.org/1999/xhtml'>%s</body></html>", msg); |
17236
77b15be2179f
Convert newlines to ' ' when receiving XHTML from Jabber
Sean Egan <seanegan@gmail.com>
parents:
16904
diff
changeset
|
1128 |
15822 | 1129 purple_markup_html_to_xhtml(buf, &xhtml, &jm->body); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1130 g_free(buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1131 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1132 if(!jbr || jbr->capabilities & JABBER_CAP_XHTML) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1133 jm->xhtml = xhtml; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1134 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1135 g_free(xhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1136 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1137 jabber_message_send(jm); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1138 jabber_message_free(jm); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1139 return 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1140 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1141 |
15822 | 1142 int jabber_message_send_chat(PurpleConnection *gc, int id, const char *msg, PurpleMessageFlags flags) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1143 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1144 JabberChat *chat; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1145 JabberMessage *jm; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1146 JabberStream *js; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1147 char *buf; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1148 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1149 if(!msg || !gc) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1150 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1151 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1152 js = gc->proto_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1153 chat = jabber_chat_find_by_id(js, id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1154 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1155 if(!chat) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1156 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1157 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1158 jm = g_new0(JabberMessage, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1159 jm->js = gc->proto_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1160 jm->type = JABBER_MESSAGE_GROUPCHAT; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1161 jm->to = g_strdup_printf("%s@%s", chat->room, chat->server); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1162 jm->id = jabber_get_next_id(jm->js); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1163 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1164 buf = g_strdup_printf("<html xmlns='http://jabber.org/protocol/xhtml-im'><body xmlns='http://www.w3.org/1999/xhtml'>%s</body></html>", msg); |
15822 | 1165 purple_markup_html_to_xhtml(buf, &jm->xhtml, &jm->body); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1166 g_free(buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1167 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1168 if(!chat->xhtml) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1169 g_free(jm->xhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1170 jm->xhtml = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1171 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1172 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1173 jabber_message_send(jm); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1174 jabber_message_free(jm); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1175 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1176 return 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1177 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1178 |
15822 | 1179 unsigned int jabber_send_typing(PurpleConnection *gc, const char *who, PurpleTypingState state) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1180 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1181 JabberMessage *jm; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1182 JabberBuddy *jb; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1183 JabberBuddyResource *jbr; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1184 char *resource = jabber_get_resource(who); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1185 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1186 jb = jabber_buddy_find(gc->proto_data, who, TRUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1187 jbr = jabber_buddy_find_resource(jb, resource); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1188 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1189 g_free(resource); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1190 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1191 if(!jbr || !((jbr->capabilities & JABBER_CAP_COMPOSING) || (jbr->chat_states != JABBER_CHAT_STATES_UNSUPPORTED))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1192 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1193 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1194 /* TODO: figure out threading */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1195 jm = g_new0(JabberMessage, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1196 jm->js = gc->proto_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1197 jm->type = JABBER_MESSAGE_CHAT; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1198 jm->to = g_strdup(who); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1199 jm->id = jabber_get_next_id(jm->js); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1200 |
15822 | 1201 if(PURPLE_TYPING == state) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1202 jm->chat_state = JM_STATE_COMPOSING; |
15822 | 1203 else if(PURPLE_TYPED == state) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1204 jm->chat_state = JM_STATE_PAUSED; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1205 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1206 jm->chat_state = JM_STATE_ACTIVE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1207 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1208 if(jbr->chat_states != JABBER_CHAT_STATES_UNSUPPORTED) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1209 jm->typing_style |= JM_TS_JEP_0085; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1210 /* if(JABBER_CHAT_STATES_UNKNOWN == jbr->chat_states) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1211 jbr->chat_states = JABBER_CHAT_STATES_UNSUPPORTED; */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1212 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1213 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1214 if(jbr->chat_states != JABBER_CHAT_STATES_SUPPORTED) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1215 jm->typing_style |= JM_TS_JEP_0022; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1216 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1217 jabber_message_send(jm); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1218 jabber_message_free(jm); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1219 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1220 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1221 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1222 |
15647
193456f03b9c
Sending XEP 85 'gone' messages
Sean Egan <seanegan@gmail.com>
parents:
15536
diff
changeset
|
1223 void jabber_message_conv_closed(JabberStream *js, const char *who) |
193456f03b9c
Sending XEP 85 'gone' messages
Sean Egan <seanegan@gmail.com>
parents:
15536
diff
changeset
|
1224 { |
19310
4e55f09f633c
Only send conversation close notices on XMPP when the typing notification preference is turned on
Sean Egan <seanegan@gmail.com>
parents:
17258
diff
changeset
|
1225 JabberMessage *jm; |
4e55f09f633c
Only send conversation close notices on XMPP when the typing notification preference is turned on
Sean Egan <seanegan@gmail.com>
parents:
17258
diff
changeset
|
1226 if (!purple_prefs_get_bool("/purple/conversations/im/send_typing")) |
4e55f09f633c
Only send conversation close notices on XMPP when the typing notification preference is turned on
Sean Egan <seanegan@gmail.com>
parents:
17258
diff
changeset
|
1227 return; |
4e55f09f633c
Only send conversation close notices on XMPP when the typing notification preference is turned on
Sean Egan <seanegan@gmail.com>
parents:
17258
diff
changeset
|
1228 |
4e55f09f633c
Only send conversation close notices on XMPP when the typing notification preference is turned on
Sean Egan <seanegan@gmail.com>
parents:
17258
diff
changeset
|
1229 jm = g_new0(JabberMessage, 1); |
15647
193456f03b9c
Sending XEP 85 'gone' messages
Sean Egan <seanegan@gmail.com>
parents:
15536
diff
changeset
|
1230 jm->js = js; |
193456f03b9c
Sending XEP 85 'gone' messages
Sean Egan <seanegan@gmail.com>
parents:
15536
diff
changeset
|
1231 jm->type = JABBER_MESSAGE_CHAT; |
193456f03b9c
Sending XEP 85 'gone' messages
Sean Egan <seanegan@gmail.com>
parents:
15536
diff
changeset
|
1232 jm->to = g_strdup(who); |
193456f03b9c
Sending XEP 85 'gone' messages
Sean Egan <seanegan@gmail.com>
parents:
15536
diff
changeset
|
1233 jm->id = jabber_get_next_id(jm->js); |
193456f03b9c
Sending XEP 85 'gone' messages
Sean Egan <seanegan@gmail.com>
parents:
15536
diff
changeset
|
1234 jm->typing_style = JM_TS_JEP_0085; |
193456f03b9c
Sending XEP 85 'gone' messages
Sean Egan <seanegan@gmail.com>
parents:
15536
diff
changeset
|
1235 jm->chat_state = JM_STATE_GONE; |
193456f03b9c
Sending XEP 85 'gone' messages
Sean Egan <seanegan@gmail.com>
parents:
15536
diff
changeset
|
1236 jabber_message_send(jm); |
193456f03b9c
Sending XEP 85 'gone' messages
Sean Egan <seanegan@gmail.com>
parents:
15536
diff
changeset
|
1237 jabber_message_free(jm); |
193456f03b9c
Sending XEP 85 'gone' messages
Sean Egan <seanegan@gmail.com>
parents:
15536
diff
changeset
|
1238 } |
17890
935005186312
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17889
diff
changeset
|
1239 |
935005186312
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17889
diff
changeset
|
1240 gboolean jabber_buzz_isenabled(JabberStream *js, const gchar *shortname, const gchar *namespace) { |
935005186312
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17889
diff
changeset
|
1241 return js->allowBuzz; |
935005186312
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17889
diff
changeset
|
1242 } |
935005186312
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17889
diff
changeset
|
1243 |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
1244 gboolean jabber_custom_smileys_isenabled(JabberStream *js, const gchar *shortname, |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
1245 const gchar *namespace) |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
1246 { |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
1247 const PurpleConnection *gc = js->gc; |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
1248 PurpleAccount *account = purple_connection_get_account(gc); |
23778
44feef3c885c
A couple of leak fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23777
diff
changeset
|
1249 |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
1250 return purple_account_get_bool(account, "custom_smileys", TRUE); |
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
23082
diff
changeset
|
1251 } |