libpurple/protocols/gg/message-prpl.c

Wed, 19 Oct 2022 06:25:35 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Wed, 19 Oct 2022 06:25:35 -0500
changeset 41814
f8940ebd4eee
parent 41091
fa2d6b0a4912
child 41979
31c32b8d4bef
permissions
-rw-r--r--

Back out the PurpleProtocol->login change that returned a PurpleConnection

This remains to be a good idea, but this implementation caused more issues than
it solved. I'm working on that better implementation, but we need to revert all
of this first, otherwise the new review request is going to be massive.

This reverts commits 3f96e2b2b03d, d567f89d6a9b, and 6ef5bb284651. These were
backed out manually due to some other commits that made automative backouts
difficult.

Testing Done:
Connected a demo, ircv3, and xmpp accounts without issue.

Reviewed at https://reviews.imfreedom.org/r/1937/

35358
7beae478c905 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
1 /* purple
7beae478c905 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
2 *
7beae478c905 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
3 * Purple is the legal property of its developers, whose names are too numerous
7beae478c905 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
4 * to list here. Please refer to the COPYRIGHT file distributed with this
7beae478c905 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
5 * source distribution.
7beae478c905 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
6 *
7beae478c905 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
7 * Component written by Tomek Wasilczyk (http://www.wasilczyk.pl).
7beae478c905 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
8 *
7beae478c905 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
9 * This file is dual-licensed under the GPL2+ and the X11 (MIT) licences.
7beae478c905 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
10 * As a recipient of this file you may choose, which license to receive the
7beae478c905 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
11 * code under. As a contributor, you have to ensure the new code is
7beae478c905 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
12 * compatible with both.
7beae478c905 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
13 *
7beae478c905 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
14 * This program is free software; you can redistribute it and/or modify
7beae478c905 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
15 * it under the terms of the GNU General Public License as published by
7beae478c905 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
16 * the Free Software Foundation; either version 2 of the License, or
7beae478c905 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
17 * (at your option) any later version.
7beae478c905 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
18 *
7beae478c905 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
19 * This program is distributed in the hope that it will be useful,
7beae478c905 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7beae478c905 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7beae478c905 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
22 * GNU General Public License for more details.
7beae478c905 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
23 *
7beae478c905 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
24 * You should have received a copy of the GNU General Public License
7beae478c905 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
25 * along with this program; if not, write to the Free Software
7beae478c905 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
26 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
7beae478c905 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
27 */
40441
f23c7e772667 Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents: 40358
diff changeset
28
f23c7e772667 Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents: 40358
diff changeset
29 #include <glib/gi18n-lib.h>
f23c7e772667 Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents: 40358
diff changeset
30
40523
9bcf96663cb9 Make gstreamer-1.0 a required dependency
Gary Kramlich <grim@reaperworld.com>
parents: 40507
diff changeset
31 #include <errno.h>
9bcf96663cb9 Make gstreamer-1.0 a required dependency
Gary Kramlich <grim@reaperworld.com>
parents: 40507
diff changeset
32
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
33 #include "message-prpl.h"
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
34
34357
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
35 #include "gg.h"
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
36 #include "chat.h"
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
37 #include "utils.h"
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
38 #include "html.h"
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
39
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
40 #define GGP_GG10_DEFAULT_FORMAT "<span style=\"color:#000000; " \
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
41 "font-family:'MS Shell Dlg 2'; font-size:9pt; \">"
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
42 #define GGP_GG10_DEFAULT_FORMAT_REPLACEMENT "<span>"
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
43 #define GGP_GG11_FORCE_COMPAT FALSE
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
44
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
45 typedef struct
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
46 {
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
47 enum
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
48 {
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
49 GGP_MESSAGE_GOT_TYPE_IM,
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
50 GGP_MESSAGE_GOT_TYPE_CHAT,
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
51 GGP_MESSAGE_GOT_TYPE_MULTILOGON
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
52 } type;
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
53
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
54 uin_t user;
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
55 gchar *text;
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
56 time_t time;
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
57 uint64_t chat_id;
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
58
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
59 PurpleConnection *gc;
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
60 } ggp_message_got_data;
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
61
34359
7cf367cc1141 Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34358
diff changeset
62 typedef struct
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
63 {
34359
7cf367cc1141 Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34358
diff changeset
64 GRegex *re_html_tag;
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
65 GRegex *re_gg_img;
34359
7cf367cc1141 Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34358
diff changeset
66 } ggp_message_global_data;
7cf367cc1141 Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34358
diff changeset
67
7cf367cc1141 Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34358
diff changeset
68 static ggp_message_global_data global_data;
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
69
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
70 struct _ggp_message_session_data
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
71 {
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
72 };
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
73
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
74 typedef struct
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
75 {
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
76 int size;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
77 gchar *face;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
78 int color, bgcolor;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
79 gboolean b, i, u, s;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
80 } ggp_font;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
81
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
82 static ggp_font * ggp_font_new(void);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
83 static ggp_font * ggp_font_clone(ggp_font *font);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
84 static void ggp_font_free(gpointer font);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
85
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
86 static PurpleConversation * ggp_message_get_conv(PurpleConnection *gc,
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
87 uin_t uin);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
88 static void ggp_message_got_data_free(ggp_message_got_data *msg);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
89 static void ggp_message_got_display(PurpleConnection *gc,
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
90 ggp_message_got_data *msg);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
91 static void ggp_message_format_from_gg(ggp_message_got_data *msg,
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
92 const gchar *text);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
93
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
94 /**************/
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
95
34359
7cf367cc1141 Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34358
diff changeset
96 void ggp_message_setup_global(void)
7cf367cc1141 Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34358
diff changeset
97 {
7cf367cc1141 Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34358
diff changeset
98 global_data.re_html_tag = g_regex_new(
34413
a578366cd35e Gadu-Gadu: fix sending links
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34370
diff changeset
99 "<(/)?([a-zA-Z]+)( [^>]+)?>",
34359
7cf367cc1141 Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34358
diff changeset
100 G_REGEX_OPTIMIZE, 0, NULL);
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
101 global_data.re_gg_img = g_regex_new(
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
102 "<img name=\"([0-9a-fA-F]+)\"/?>",
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
103 G_REGEX_OPTIMIZE, 0, NULL);
34359
7cf367cc1141 Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34358
diff changeset
104 }
7cf367cc1141 Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34358
diff changeset
105
7cf367cc1141 Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34358
diff changeset
106 void ggp_message_cleanup_global(void)
7cf367cc1141 Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34358
diff changeset
107 {
7cf367cc1141 Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34358
diff changeset
108 g_regex_unref(global_data.re_html_tag);
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
109 g_regex_unref(global_data.re_gg_img);
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
110 }
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
111
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
112 static inline ggp_message_session_data *
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
113 ggp_message_get_sdata(PurpleConnection *gc)
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
114 {
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
115 GGPInfo *accdata = purple_connection_get_protocol_data(gc);
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
116 return accdata->message_data;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
117 }
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
118
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
119 void ggp_message_setup(PurpleConnection *gc)
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
120 {
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
121 GGPInfo *accdata = purple_connection_get_protocol_data(gc);
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
122 ggp_message_session_data *sdata = g_new0(ggp_message_session_data, 1);
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
123
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
124 accdata->message_data = sdata;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
125 }
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
126
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
127 void ggp_message_cleanup(PurpleConnection *gc)
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
128 {
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
129 ggp_message_session_data *sdata = ggp_message_get_sdata(gc);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35190
diff changeset
130
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
131 g_free(sdata);
34359
7cf367cc1141 Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34358
diff changeset
132 }
7cf367cc1141 Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34358
diff changeset
133
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
134 static ggp_font * ggp_font_new(void)
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
135 {
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
136 ggp_font *font;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
137
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
138 font = g_new0(ggp_font, 1);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
139 font->color = -1;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
140 font->bgcolor = -1;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
141
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
142 return font;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
143 }
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
144
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
145 static ggp_font * ggp_font_clone(ggp_font * font)
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
146 {
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
147 ggp_font *clone = g_new0(ggp_font, 1);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
148
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
149 *clone = *font;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
150 clone->face = g_strdup(font->face);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
151
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
152 return clone;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
153 }
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
154
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
155 static void ggp_font_free(gpointer _font)
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
156 {
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
157 ggp_font *font = _font;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
158
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
159 g_free(font->face);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
160 g_free(font);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
161 }
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
162
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
163 /**/
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
164
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
165 static PurpleConversation * ggp_message_get_conv(PurpleConnection *gc,
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
166 uin_t uin)
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
167 {
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
168 PurpleAccount *account = purple_connection_get_account(gc);
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
169 PurpleConversation *im;
40997
997ab408c113 Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents: 40885
diff changeset
170 PurpleConversationManager *manager;
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
171 const gchar *who = ggp_uin_to_str(uin);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
172
40997
997ab408c113 Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents: 40885
diff changeset
173 manager = purple_conversation_manager_get_default();
997ab408c113 Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents: 40885
diff changeset
174 im = purple_conversation_manager_find_im(manager, account, who);
997ab408c113 Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents: 40885
diff changeset
175 if (im) {
34946
76aa2e0f8701 Merged default branch
Ankit Vani <a@nevitus.org>
parents: 34437
diff changeset
176 return im;
40997
997ab408c113 Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents: 40885
diff changeset
177 }
34946
76aa2e0f8701 Merged default branch
Ankit Vani <a@nevitus.org>
parents: 34437
diff changeset
178 im = purple_im_conversation_new(account, who);
76aa2e0f8701 Merged default branch
Ankit Vani <a@nevitus.org>
parents: 34437
diff changeset
179 return im;
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
180 }
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
181
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
182 static void ggp_message_got_data_free(ggp_message_got_data *msg)
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
183 {
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
184 g_free(msg->text);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
185 g_free(msg);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
186 }
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
187
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
188 void ggp_message_got(PurpleConnection *gc, const struct gg_event_msg *ev)
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
189 {
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
190 ggp_message_got_data *msg = g_new0(ggp_message_got_data, 1);
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
191
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
192 msg->gc = gc;
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
193 msg->time = ev->time;
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
194 msg->user = ev->sender;
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
195
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
196 if (ev->chat_id != 0) {
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
197 msg->type = GGP_MESSAGE_GOT_TYPE_CHAT;
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
198 msg->chat_id = ev->chat_id;
36124
3dcb9b9b7c11 Drop libgadu legacy API compatibility code
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36098
diff changeset
199 } else {
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
200 msg->type = GGP_MESSAGE_GOT_TYPE_IM;
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
201 }
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
202
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
203 ggp_message_format_from_gg(msg, ev->xhtml_message);
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
204
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
205 ggp_message_got_display(gc, msg);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
206 ggp_message_got_data_free(msg);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
207 }
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
208
34360
c6bd55f526f9 Gadu-Gadu: code polishing for messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34359
diff changeset
209 void ggp_message_got_multilogon(PurpleConnection *gc,
c6bd55f526f9 Gadu-Gadu: code polishing for messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34359
diff changeset
210 const struct gg_event_msg *ev)
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
211 {
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
212 ggp_message_got_data *msg = g_new0(ggp_message_got_data, 1);
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
213
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
214 msg->gc = gc;
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
215 msg->time = ev->time;
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
216 msg->user = ev->sender; /* not really a sender*/
34368
b5341ea06a72 Gadu-Gadu: fix conferences used together with multilogon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34365
diff changeset
217
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
218 if (ev->chat_id != 0) {
34368
b5341ea06a72 Gadu-Gadu: fix conferences used together with multilogon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34365
diff changeset
219 msg->type = GGP_MESSAGE_GOT_TYPE_CHAT;
b5341ea06a72 Gadu-Gadu: fix conferences used together with multilogon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34365
diff changeset
220 msg->chat_id = ev->chat_id;
36124
3dcb9b9b7c11 Drop libgadu legacy API compatibility code
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36098
diff changeset
221 } else {
34368
b5341ea06a72 Gadu-Gadu: fix conferences used together with multilogon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34365
diff changeset
222 msg->type = GGP_MESSAGE_GOT_TYPE_MULTILOGON;
b5341ea06a72 Gadu-Gadu: fix conferences used together with multilogon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34365
diff changeset
223 }
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
224
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
225 ggp_message_format_from_gg(msg, ev->xhtml_message);
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
226
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
227 ggp_message_got_display(gc, msg);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
228 ggp_message_got_data_free(msg);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
229 }
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
230
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
231 static void ggp_message_got_display(PurpleConnection *gc,
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
232 ggp_message_got_data *msg)
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
233 {
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
234 if (msg->type == GGP_MESSAGE_GOT_TYPE_IM) {
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 35361
diff changeset
235 purple_serv_got_im(gc, ggp_uin_to_str(msg->user), msg->text,
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
236 PURPLE_MESSAGE_RECV, msg->time);
36124
3dcb9b9b7c11 Drop libgadu legacy API compatibility code
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36098
diff changeset
237 } else if (msg->type == GGP_MESSAGE_GOT_TYPE_CHAT) {
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
238 ggp_chat_got_message(gc, msg->chat_id, msg->text, msg->time,
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
239 msg->user);
36124
3dcb9b9b7c11 Drop libgadu legacy API compatibility code
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36098
diff changeset
240 } else if (msg->type == GGP_MESSAGE_GOT_TYPE_MULTILOGON) {
40541
9ceb8d25d4d9 PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents: 40538
diff changeset
241 GDateTime *dt = NULL;
9ceb8d25d4d9 PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents: 40538
diff changeset
242 PurpleAccount *account = NULL;
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
243 PurpleConversation *im = ggp_message_get_conv(gc, msg->user);
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36076
diff changeset
244 PurpleMessage *pmsg;
40541
9ceb8d25d4d9 PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents: 40538
diff changeset
245 const gchar *me = NULL;
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
246
40541
9ceb8d25d4d9 PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents: 40538
diff changeset
247 account = purple_connection_get_account(gc);
9ceb8d25d4d9 PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents: 40538
diff changeset
248 me = purple_account_get_name_for_display(account);
9ceb8d25d4d9 PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents: 40538
diff changeset
249
9ceb8d25d4d9 PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents: 40538
diff changeset
250 pmsg = purple_message_new_outgoing(me, NULL, msg->text, 0);
9ceb8d25d4d9 PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents: 40538
diff changeset
251
9ceb8d25d4d9 PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents: 40538
diff changeset
252 dt = g_date_time_new_from_unix_local((gint64)msg->time);
9ceb8d25d4d9 PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents: 40538
diff changeset
253 purple_message_set_timestamp(pmsg, dt);
9ceb8d25d4d9 PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents: 40538
diff changeset
254 g_date_time_unref(dt);
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36076
diff changeset
255
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
256 purple_conversation_write_message(im, pmsg);
40541
9ceb8d25d4d9 PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents: 40538
diff changeset
257
9ceb8d25d4d9 PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents: 40538
diff changeset
258 g_object_unref(G_OBJECT(pmsg));
9ceb8d25d4d9 PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents: 40538
diff changeset
259 } else {
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
260 purple_debug_error("gg", "ggp_message_got_display: "
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
261 "unexpected message type: %d\n", msg->type);
40541
9ceb8d25d4d9 PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents: 40538
diff changeset
262 }
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
263 }
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
264
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
265 static gboolean ggp_message_format_from_gg_found_img(const GMatchInfo *info,
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
266 GString *res, gpointer data)
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
267 {
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
268 ggp_message_got_data *msg = data;
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
269 gchar *name, *replacement;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
270 int64_t id;
35820
9b4fccc8ceac GG: reference images, not their ids
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35819
diff changeset
271 PurpleImage *image;
35843
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35831
diff changeset
272 guint image_id;
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
273
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
274 name = g_match_info_fetch(info, 1);
34418
c27e31267e8d Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34413
diff changeset
275 if (sscanf(name, "%" G_GINT64_MODIFIER "x", &id) != 1)
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
276 id = 0;
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
277 g_free(name);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
278 if (!id) {
35843
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35831
diff changeset
279 /* TODO: stock broken image? */
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35831
diff changeset
280 g_string_append_printf(res, "[%s]", _("broken image"));
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
281 return FALSE;
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
282 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35190
diff changeset
283
35843
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35831
diff changeset
284 image = ggp_image_request(msg->gc, msg->user, id);
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35831
diff changeset
285 if (!image) {
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35831
diff changeset
286 purple_debug_warning("gg", "ggp_message_format_from_gg_"
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35831
diff changeset
287 "found_img: couldn't request image");
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35831
diff changeset
288 g_string_append_printf(res, "[%s]", _("broken image"));
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
289 return FALSE;
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
290 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35190
diff changeset
291
35843
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35831
diff changeset
292 image_id = purple_image_store_add_weak(image);
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35831
diff changeset
293 replacement = g_strdup_printf("<img src=\""
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35831
diff changeset
294 PURPLE_IMAGE_STORE_PROTOCOL "%u\">", image_id);
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
295 g_string_append(res, replacement);
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
296 g_free(replacement);
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
297
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
298 return FALSE;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
299 }
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
300
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
301 static void ggp_message_format_from_gg(ggp_message_got_data *msg,
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
302 const gchar *text)
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
303 {
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
304 gchar *text_new, *tmp;
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
305
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
306 if (text == NULL) {
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
307 msg->text = g_strdup("");
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
308 return;
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
309 }
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
310
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
311 text_new = g_strdup(text);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
312 purple_str_strip_char(text_new, '\r');
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
313
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
314 tmp = text_new;
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
315 text_new = purple_strreplace(text_new, GGP_GG10_DEFAULT_FORMAT,
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
316 GGP_GG10_DEFAULT_FORMAT_REPLACEMENT);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
317 g_free(tmp);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
318
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
319 tmp = text_new;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
320 text_new = g_regex_replace_eval(global_data.re_gg_img, text_new, -1, 0,
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
321 0, ggp_message_format_from_gg_found_img, msg, NULL);
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
322 g_free(tmp);
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
323
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
324 msg->text = text_new;
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
325 }
34357
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
326
40538
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
327 gchar *
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
328 ggp_message_format_to_gg(PurpleConversation *conv, const gchar *text)
34357
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
329 {
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
330 gchar *text_new, *tmp;
40538
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
331 GString *reformatted_text = NULL;
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
332 GMatchInfo *match;
34430
15639e15839e Gadu-Gadu: fix -Wsign-compare errors
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34418
diff changeset
333 guint pos = 0;
40538
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
334 GString *pending_objects = NULL;
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
335 GList *font_stack = NULL;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
336 static int html_sizes_pt[7] = { 7, 8, 9, 10, 12, 14, 16 };
34357
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
337
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
338 ggp_font *font_new, *font_current, *font_base;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
339 gboolean font_changed = FALSE;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
340 gboolean in_any_tag = FALSE;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
341
35843
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35831
diff changeset
342 if (purple_debug_is_verbose())
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35831
diff changeset
343 purple_debug_info("gg", "ggp formatting text: [%s]", text);
34357
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
344
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
345 /* default font */
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
346 font_base = ggp_font_new();
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
347 font_current = ggp_font_new();
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
348 font_new = ggp_font_new();
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
349
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
350 /* GG11 doesn't use nbsp, it just print spaces */
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
351 text_new = purple_strreplace(text, "&nbsp;", " ");
34357
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
352
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
353 /* add end-of-message tag */
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
354 if (strstr(text_new, "<eom>") != NULL) {
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
355 tmp = text_new;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
356 text_new = purple_strreplace(text_new, "<eom>", "");
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
357 g_free(tmp);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
358 purple_debug_warning("gg", "ggp_message_format_to_gg: "
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
359 "unexpected <eom> tag\n");
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
360 }
34357
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
361 tmp = text_new;
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
362 text_new = g_strdup_printf("%s<eom></eom>", text_new);
34357
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
363 g_free(tmp);
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
364
40538
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
365 reformatted_text = g_string_new(NULL);
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
366 pending_objects = g_string_new(NULL);
34359
7cf367cc1141 Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34358
diff changeset
367 g_regex_match(global_data.re_html_tag, text_new, 0, &match);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
368 while (g_match_info_matches(match)) {
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
369 int m_start, m_end, m_pos;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
370 gboolean tag_close;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
371 gchar *tag_str, *attribs_str;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
372 ggp_html_tag tag;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
373 gboolean text_before;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
374
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
375 /* reading tag and its contents */
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
376 g_match_info_fetch_pos(match, 0, &m_start, &m_end);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
377 g_assert(m_start >= 0 && m_end >= 0);
34430
15639e15839e Gadu-Gadu: fix -Wsign-compare errors
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34418
diff changeset
378 text_before = ((guint)m_start > pos);
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
379 g_match_info_fetch_pos(match, 1, &m_pos, NULL);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
380 tag_close = (m_pos >= 0);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
381 tag_str = g_match_info_fetch(match, 2);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
382 tag = ggp_html_parse_tag(tag_str);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
383 attribs_str = g_match_info_fetch(match, 3);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
384 g_match_info_next(match, NULL);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
385
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
386 if (tag == GGP_HTML_TAG_UNKNOWN) {
41084
72d6941bfa2e Fix typos in protocol plugins
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40997
diff changeset
387 purple_debug_warning(
72d6941bfa2e Fix typos in protocol plugins
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40997
diff changeset
388 "gg",
72d6941bfa2e Fix typos in protocol plugins
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40997
diff changeset
389 "ggp_message_format_to_gg: unknown tag %s",
72d6941bfa2e Fix typos in protocol plugins
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40997
diff changeset
390 tag_str);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
391 }
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
392
40538
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
393 /* closing *all* formatting-related tags (GG11 weirdness)
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
394 * and adding pending objects */
40538
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
395 if ((text_before && (font_changed || pending_objects->len > 0)) ||
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
396 (tag == GGP_HTML_TAG_EOM && tag_close)) {
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
397 font_changed = FALSE;
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
398 if (in_any_tag) {
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
399 in_any_tag = FALSE;
40538
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
400 if (font_current->s && !GGP_GG11_FORCE_COMPAT) {
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
401 g_string_append(reformatted_text, "</s>");
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
402 }
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
403 if (font_current->u) {
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
404 g_string_append(reformatted_text, "</u>");
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
405 }
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
406 if (font_current->i) {
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
407 g_string_append(reformatted_text, "</i>");
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
408 }
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
409 if (font_current->b) {
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
410 g_string_append(reformatted_text, "</b>");
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
411 }
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
412 g_string_append(reformatted_text, "</span>");
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
413 }
40538
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
414 if (pending_objects->len > 0) {
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
415 g_string_append(reformatted_text, pending_objects->str);
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
416 g_string_truncate(pending_objects, 0);
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
417 }
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
418 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35190
diff changeset
419
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
420 /* opening formatting-related tags again */
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
421 if (text_before && !in_any_tag) {
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
422 gboolean has_size = (font_new->size > 0 &&
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
423 font_new->size <= 7 && font_new->size != 3);
40538
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
424 gboolean has_style =
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
425 has_size || font_new->face ||
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
426 (font_new->bgcolor >= 0 && !GGP_GG11_FORCE_COMPAT) ||
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
427 font_new->color >= 0;
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35190
diff changeset
428
40538
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
429 if (has_style) {
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
430 g_string_append(reformatted_text, "<span style=\"");
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35190
diff changeset
431
40538
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
432 if (has_size) {
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
433 g_string_append_printf(reformatted_text, "font-size:%dpt;",
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
434 html_sizes_pt[font_new->size - 1]);
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
435 }
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
436 if (font_new->face) {
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
437 g_string_append_printf(reformatted_text, "font-family:%s;",
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
438 font_new->face);
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
439 }
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
440 if (font_new->bgcolor >= 0 && !GGP_GG11_FORCE_COMPAT) {
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
441 g_string_append_printf(reformatted_text,
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
442 "background-color:#%06x;",
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
443 font_new->bgcolor);
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
444 }
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
445 if (font_new->color >= 0) {
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
446 g_string_append_printf(reformatted_text, "color:#%06x;",
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
447 font_new->color);
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
448 }
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
449
40538
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
450 g_string_append(reformatted_text, "\">");
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
451 } else {
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
452 g_string_append(reformatted_text, "<span>");
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
453 }
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
454
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
455 if (font_new->b) {
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
456 g_string_append(reformatted_text, "<b>");
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
457 }
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
458 if (font_new->i) {
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
459 g_string_append(reformatted_text, "<i>");
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
460 }
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
461 if (font_new->u) {
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
462 g_string_append(reformatted_text, "<u>");
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
463 }
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
464 if (font_new->s && !GGP_GG11_FORCE_COMPAT) {
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
465 g_string_append(reformatted_text, "<s>");
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
466 }
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
467
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
468 ggp_font_free(font_current);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
469 font_current = font_new;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
470 font_new = ggp_font_clone(font_current);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
471
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
472 in_any_tag = TRUE;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
473 }
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
474 if (text_before) {
40538
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
475 g_string_append_len(reformatted_text, text_new + pos,
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
476 m_start - pos);
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
477 }
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
478
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
479 /* set formatting of a following text */
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
480 if (tag == GGP_HTML_TAG_B) {
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
481 font_changed |= (font_new->b != !tag_close);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
482 font_new->b = !tag_close;
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
483 } else if (tag == GGP_HTML_TAG_I) {
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
484 font_changed |= (font_new->i != !tag_close);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
485 font_new->i = !tag_close;
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
486 } else if (tag == GGP_HTML_TAG_U) {
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
487 font_changed |= (font_new->u != !tag_close);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
488 font_new->u = !tag_close;
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
489 } else if (tag == GGP_HTML_TAG_S) {
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
490 font_changed |= (font_new->s != !tag_close);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
491 font_new->s = !tag_close;
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
492 } else if (tag == GGP_HTML_TAG_IMG && !tag_close) {
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
493 GHashTable *attribs = ggp_html_tag_attribs(attribs_str);
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
494 gchar *val = NULL;
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
495 uint64_t id;
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
496 ggp_image_prepare_result res = -1;
35820
9b4fccc8ceac GG: reference images, not their ids
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35819
diff changeset
497 PurpleImage *image = NULL;
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35190
diff changeset
498
35831
86b7a6d3d267 PurpleImage: use purple_image_store_get_from_uri where possible
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35825
diff changeset
499 val = g_hash_table_lookup(attribs, "src");
86b7a6d3d267 PurpleImage: use purple_image_store_get_from_uri where possible
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35825
diff changeset
500 if (val)
86b7a6d3d267 PurpleImage: use purple_image_store_get_from_uri where possible
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35825
diff changeset
501 image = purple_image_store_get_from_uri(val);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35190
diff changeset
502
35825
4c1e8623b7c7 Fix warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35820
diff changeset
503 if (image != NULL)
35820
9b4fccc8ceac GG: reference images, not their ids
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35819
diff changeset
504 res = ggp_image_prepare(conv, image, &id);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35190
diff changeset
505
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
506 if (res == GGP_IMAGE_PREPARE_OK) {
40538
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
507 g_string_append_printf(pending_objects,
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
508 "<img name=\"" GGP_IMAGE_ID_FORMAT "\">",
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
509 id);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
510 } else if (res == GGP_IMAGE_PREPARE_TOO_BIG) {
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36076
diff changeset
511 purple_conversation_write_system_message(conv,
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
512 _("Image is too large, please try "
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36076
diff changeset
513 "smaller one."), PURPLE_MESSAGE_ERROR);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
514 } else {
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36076
diff changeset
515 purple_conversation_write_system_message(conv,
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
516 _("Image cannot be sent."),
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36076
diff changeset
517 PURPLE_MESSAGE_ERROR);
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
518 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35190
diff changeset
519
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
520 g_hash_table_destroy(attribs);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
521 } else if (tag == GGP_HTML_TAG_FONT && !tag_close) {
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
522 GHashTable *attribs = ggp_html_tag_attribs(attribs_str);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
523 gchar *val = NULL;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
524
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
525 font_stack = g_list_prepend(font_stack,
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
526 ggp_font_clone(font_new));
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
527
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
528 if ((val = g_hash_table_lookup(attribs, "size")) != NULL
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
529 && val[0] >= '1' && val[0] <= '7' &&
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
530 val[1] == '\0')
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
531 {
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
532 int size = val[0] - '0';
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
533 font_changed |= (font_new->size != size);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
534 font_new->size = size;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
535 }
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
536
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
537 if ((val = g_hash_table_lookup(attribs, "face"))
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
538 != NULL)
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
539 {
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
540 font_changed |=
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
541 (g_strcmp0(font_new->face, val) != 0);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
542 g_free(font_new->face);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
543 font_new->face = g_strdup(val);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
544 }
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
545
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
546 if ((val = g_hash_table_lookup(attribs, "color"))
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
547 != NULL && val[0] == '#' && strlen(val) == 7)
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
548 {
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
549 int color = ggp_html_decode_color(val);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
550 font_changed |= (font_new->color != color);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
551 font_new->color = color;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
552 }
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
553
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
554 g_hash_table_destroy(attribs);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
555 }
34360
c6bd55f526f9 Gadu-Gadu: code polishing for messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34359
diff changeset
556 else if ((tag == GGP_HTML_TAG_SPAN || tag == GGP_HTML_TAG_DIV)
c6bd55f526f9 Gadu-Gadu: code polishing for messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34359
diff changeset
557 && !tag_close)
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
558 {
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
559 GHashTable *attribs, *styles = NULL;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
560 gchar *style = NULL;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
561 gchar *val = NULL;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
562
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
563 attribs = ggp_html_tag_attribs(attribs_str);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
564
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
565 font_stack = g_list_prepend(font_stack,
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
566 ggp_font_clone(font_new));
40538
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
567 if (tag == GGP_HTML_TAG_DIV) {
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
568 g_string_append(pending_objects, "<br>");
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
569 }
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
570
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
571 style = g_hash_table_lookup(attribs, "style");
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
572 if (style)
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
573 styles = ggp_html_css_attribs(style);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
574
35796
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35499
diff changeset
575 if (styles && (val = g_hash_table_lookup(styles,
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
576 "background-color")) != NULL)
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
577 {
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
578 int color = ggp_html_decode_color(val);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
579 font_changed |= (font_new->bgcolor != color);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
580 font_new->bgcolor = color;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
581 }
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
582
35796
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35499
diff changeset
583 if (styles && (val = g_hash_table_lookup(styles,
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
584 "color")) != NULL)
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
585 {
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
586 int color = ggp_html_decode_color(val);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
587 font_changed |= (font_new->color != color);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
588 font_new->color = color;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
589 }
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
590
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
591 if (styles)
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
592 g_hash_table_destroy(styles);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
593 g_hash_table_destroy(attribs);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
594 }
34360
c6bd55f526f9 Gadu-Gadu: code polishing for messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34359
diff changeset
595 else if ((tag == GGP_HTML_TAG_FONT || tag == GGP_HTML_TAG_SPAN
c6bd55f526f9 Gadu-Gadu: code polishing for messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34359
diff changeset
596 || tag == GGP_HTML_TAG_DIV) && tag_close)
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
597 {
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
598 font_changed = TRUE;
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35190
diff changeset
599
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
600 ggp_font_free(font_new);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
601 if (font_stack) {
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
602 font_new = (ggp_font*)font_stack->data;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
603 font_stack = g_list_delete_link(
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
604 font_stack, font_stack);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
605 }
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
606 else
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
607 font_new = ggp_font_clone(font_base);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
608 } else if (tag == GGP_HTML_TAG_BR) {
40538
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
609 g_string_append(pending_objects, "<br>");
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
610 } else if (tag == GGP_HTML_TAG_HR) {
40538
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
611 g_string_append(pending_objects, "<br><span>---</span><br>");
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
612 } else if (tag == GGP_HTML_TAG_A || tag == GGP_HTML_TAG_EOM) {
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
613 /* do nothing */
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
614 } else if (tag == GGP_HTML_TAG_UNKNOWN) {
41084
72d6941bfa2e Fix typos in protocol plugins
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40997
diff changeset
615 purple_debug_warning(
72d6941bfa2e Fix typos in protocol plugins
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40997
diff changeset
616 "gg",
72d6941bfa2e Fix typos in protocol plugins
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40997
diff changeset
617 "ggp_message_format_to_gg: unknown tag %s",
72d6941bfa2e Fix typos in protocol plugins
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40997
diff changeset
618 tag_str);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
619 } else {
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
620 purple_debug_error("gg", "ggp_message_format_to_gg: "
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
621 "not handled tag %s\n", tag_str);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
622 }
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
623
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
624 pos = m_end;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
625 g_free(tag_str);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
626 g_free(attribs_str);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
627 }
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
628 g_match_info_free(match);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
629
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
630 if (pos < strlen(text_new) || in_any_tag) {
41091
fa2d6b0a4912 Use purple_debug_fatal only if actually fatal
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41084
diff changeset
631 purple_debug_error(
fa2d6b0a4912 Use purple_debug_fatal only if actually fatal
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41084
diff changeset
632 "gg",
fa2d6b0a4912 Use purple_debug_fatal only if actually fatal
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41084
diff changeset
633 "ggp_message_format_to_gg: end of message not reached");
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
634 }
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
635
41084
72d6941bfa2e Fix typos in protocol plugins
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40997
diff changeset
636 /* releasing fonts resources */
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
637 ggp_font_free(font_new);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
638 ggp_font_free(font_current);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
639 ggp_font_free(font_base);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
640 g_list_free_full(font_stack, ggp_font_free);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
641
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
642 /* combining reformatted text info one string */
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
643 g_free(text_new);
40538
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
644 g_string_free(pending_objects, TRUE);
222423055d93 Cleanup some GG utility functions
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40523
diff changeset
645 text_new = g_string_free(reformatted_text, FALSE);
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
646
35844
612658031317 Gadu-Gadu: add missing verbose block
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35843
diff changeset
647 if (purple_debug_is_verbose())
612658031317 Gadu-Gadu: add missing verbose block
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35843
diff changeset
648 purple_debug_info("gg", "reformatted text: [%s]", text_new);
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
649
34357
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
650 return text_new;
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
651 }
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
652
40507
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
653 int ggp_message_send_im(PurpleProtocolIM *pim, PurpleConnection *gc,
77d7bc9e5151 Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
654 PurpleMessage *msg)
34357
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
655 {
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
656 GGPInfo *info = purple_connection_get_protocol_data(gc);
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
657 PurpleConversation *im;
40997
997ab408c113 Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents: 40885
diff changeset
658 PurpleConversationManager *manager;
34357
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
659 ggp_buddy_data *buddy_data;
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
660 gchar *gg_msg;
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
661 gboolean succ;
36098
4951752ad038 Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36089
diff changeset
662 const gchar *rcpt = purple_message_get_recipient(msg);
34357
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
663
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
664 /* TODO: return -ENOTCONN, if not connected */
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
665
36076
a0e5b68ff4ef Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35844
diff changeset
666 if (purple_message_is_empty(msg))
34357
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
667 return 0;
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
668
34946
76aa2e0f8701 Merged default branch
Ankit Vani <a@nevitus.org>
parents: 34437
diff changeset
669 buddy_data = ggp_buddy_get_data(purple_blist_find_buddy(
36098
4951752ad038 Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36089
diff changeset
670 purple_connection_get_account(gc), rcpt));
34357
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
671
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
672 if (buddy_data->blocked)
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
673 return -1;
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
674
40997
997ab408c113 Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents: 40885
diff changeset
675 manager = purple_conversation_manager_get_default();
997ab408c113 Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents: 40885
diff changeset
676 im = purple_conversation_manager_find_im(manager,
997ab408c113 Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents: 40885
diff changeset
677 purple_connection_get_account(gc),
997ab408c113 Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents: 40885
diff changeset
678 rcpt);
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
679
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
680 gg_msg = ggp_message_format_to_gg(im,
36076
a0e5b68ff4ef Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35844
diff changeset
681 purple_message_get_contents(msg));
34357
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
682
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
683 /* TODO: splitting messages */
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
684 if (strlen(gg_msg) > GG_MSG_MAXSIZE) {
34357
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
685 g_free(gg_msg);
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
686 return -E2BIG;
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
687 }
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
688
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
689 succ = (gg_send_message_html(info->session, GG_CLASS_CHAT,
36098
4951752ad038 Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36089
diff changeset
690 ggp_str_to_uin(rcpt), (unsigned char *)gg_msg) >= 0);
34357
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
691
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
692 g_free(gg_msg);
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
693
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
694 return succ ? 1 : -1;
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
695 }

mercurial