libpurple/protocols/gg/message-prpl.c

Mon, 24 Feb 2014 21:22:04 +0100

author
Tomasz Wasilczyk <twasilczyk@pidgin.im>
date
Mon, 24 Feb 2014 21:22:04 +0100
changeset 35605
8a0ae6cc73fc
parent 35499
c4c5e0a670b1
child 35796
bc5253318167
permissions
-rw-r--r--

Fix win32 build

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 */
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
28 #include "message-prpl.h"
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
29
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
30 #include <debug.h>
35190
5986ee34c476 libpurple: Fix build and warnings with glib 2.24
Ankit Vani <a@nevitus.org>
parents: 34946
diff changeset
31 #include <glibcompat.h>
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
32
34357
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
33 #include "gg.h"
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
34 #include "chat.h"
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
35 #include "utils.h"
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
36 #include "html.h"
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
37
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
38 #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
39 "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
40 #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
41 #define GGP_GG11_FORCE_COMPAT FALSE
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
42
34418
c27e31267e8d Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34413
diff changeset
43 #define GGP_IMAGE_REPLACEMENT "<img id=\"gg-pending-image-" GGP_IMAGE_ID_FORMAT "\">"
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
44 #define GGP_IMAGE_DESTINATION "<img src=\"" PURPLE_STORED_IMAGE_PROTOCOL "%u\">"
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
45
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
46 typedef struct
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
47 {
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
48 enum
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
49 {
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
50 GGP_MESSAGE_GOT_TYPE_IM,
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
51 GGP_MESSAGE_GOT_TYPE_CHAT,
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
52 GGP_MESSAGE_GOT_TYPE_MULTILOGON
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
53 } type;
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
54
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
55 uin_t user;
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
56 gchar *text;
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
57 time_t time;
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
58 uint64_t chat_id;
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
59 GList *pending_images;
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
60
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
61 PurpleConnection *gc;
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
62 } ggp_message_got_data;
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
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 typedef struct
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
65 {
34359
7cf367cc1141 Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34358
diff changeset
66 GRegex *re_html_tag;
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
67 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
68 } 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
69
7cf367cc1141 Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34358
diff changeset
70 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
71
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
72 struct _ggp_message_session_data
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
73 {
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
74 GList *pending_messages;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
75 };
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
76
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
77 typedef struct
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
78 {
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
79 int size;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
80 gchar *face;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
81 int color, bgcolor;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
82 gboolean b, i, u, s;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
83 } ggp_font;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
84
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
85 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
86 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
87 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
88
34946
76aa2e0f8701 Merged default branch
Ankit Vani <a@nevitus.org>
parents: 34437
diff changeset
89 static PurpleIMConversation * ggp_message_get_conv(PurpleConnection *gc,
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
90 uin_t uin);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
91 static void ggp_message_got_data_free(ggp_message_got_data *msg);
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
92 static gboolean ggp_message_request_images(PurpleConnection *gc,
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
93 ggp_message_got_data *msg);
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
94 static void ggp_message_got_display(PurpleConnection *gc,
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
95 ggp_message_got_data *msg);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
96 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
97 const gchar *text);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
98
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
99 /**************/
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
100
34359
7cf367cc1141 Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34358
diff changeset
101 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
102 {
7cf367cc1141 Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34358
diff changeset
103 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
104 "<(/)?([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
105 G_REGEX_OPTIMIZE, 0, NULL);
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
106 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
107 "<img name=\"([0-9a-fA-F]+)\"/?>",
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
108 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
109 }
7cf367cc1141 Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34358
diff changeset
110
7cf367cc1141 Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34358
diff changeset
111 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
112 {
7cf367cc1141 Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34358
diff changeset
113 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
114 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
115 }
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
116
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
117 static inline ggp_message_session_data *
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
118 ggp_message_get_sdata(PurpleConnection *gc)
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
119 {
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
120 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
121 return accdata->message_data;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
122 }
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 void ggp_message_setup(PurpleConnection *gc)
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 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
127 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
128
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
129 accdata->message_data = sdata;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
130 }
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
131
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
132 void ggp_message_cleanup(PurpleConnection *gc)
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
133 {
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
134 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
135
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
136 g_list_free_full(sdata->pending_messages,
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
137 (GDestroyNotify)ggp_message_got_data_free);
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
138 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
139 }
7cf367cc1141 Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34358
diff changeset
140
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
141 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
142 {
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
143 ggp_font *font;
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 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
146 font->color = -1;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
147 font->bgcolor = -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 return font;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
150 }
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 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
153 {
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
154 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
155
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
156 *clone = *font;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
157 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
158
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
159 return clone;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
160 }
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 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
163 {
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
164 ggp_font *font = _font;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
165
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
166 g_free(font->face);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
167 g_free(font);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
168 }
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
169
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
170 /**/
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
171
34946
76aa2e0f8701 Merged default branch
Ankit Vani <a@nevitus.org>
parents: 34437
diff changeset
172 static PurpleIMConversation * ggp_message_get_conv(PurpleConnection *gc,
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
173 uin_t uin)
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
174 {
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
175 PurpleAccount *account = purple_connection_get_account(gc);
34946
76aa2e0f8701 Merged default branch
Ankit Vani <a@nevitus.org>
parents: 34437
diff changeset
176 PurpleIMConversation *im;
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
177 const gchar *who = ggp_uin_to_str(uin);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
178
34946
76aa2e0f8701 Merged default branch
Ankit Vani <a@nevitus.org>
parents: 34437
diff changeset
179 im = purple_conversations_find_im_with_account(who, account);
76aa2e0f8701 Merged default branch
Ankit Vani <a@nevitus.org>
parents: 34437
diff changeset
180 if (im)
76aa2e0f8701 Merged default branch
Ankit Vani <a@nevitus.org>
parents: 34437
diff changeset
181 return im;
76aa2e0f8701 Merged default branch
Ankit Vani <a@nevitus.org>
parents: 34437
diff changeset
182 im = purple_im_conversation_new(account, who);
76aa2e0f8701 Merged default branch
Ankit Vani <a@nevitus.org>
parents: 34437
diff changeset
183 return im;
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
184 }
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
185
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
186 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
187 {
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
188 g_list_free_full(msg->pending_images, g_free);
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
189 g_free(msg->text);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
190 g_free(msg);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
191 }
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
192
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
193 static void ggp_message_request_images_got(PurpleConnection *gc, uint64_t id,
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
194 int stored_id, gpointer _msg)
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
195 {
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
196 ggp_message_session_data *sdata = ggp_message_get_sdata(gc);
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
197 ggp_message_got_data *msg = _msg;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
198 GList *m_it, *i_it;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
199 gchar *tmp, *tag_search, *tag_replace;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
200
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
201 m_it = g_list_find(sdata->pending_messages, msg);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
202 if (!m_it) {
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
203 purple_debug_error("gg", "ggp_message_request_images_got: "
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
204 "message %p is not in queue\n", msg);
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
205 return;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
206 }
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
207
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
208 i_it = g_list_find_custom(msg->pending_images, &id, ggp_int64_compare);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
209 if (!i_it) {
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
210 purple_debug_error("gg", "ggp_message_request_images_got: "
34418
c27e31267e8d Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34413
diff changeset
211 "image " GGP_IMAGE_ID_FORMAT " is not present in this "
c27e31267e8d Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34413
diff changeset
212 "message\n", id);
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
213 return;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
214 }
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
215
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
216 tag_search = g_strdup_printf(GGP_IMAGE_REPLACEMENT, id);
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
217 tag_replace = g_strdup_printf(GGP_IMAGE_DESTINATION, stored_id);
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
218
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
219 tmp = msg->text;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
220 msg->text = purple_strreplace(msg->text, tag_search, tag_replace);
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
221 g_free(tmp);
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
222
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
223 g_free(tag_search);
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
224 g_free(tag_replace);
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
225
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
226 g_free(i_it->data);
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
227 msg->pending_images = g_list_delete_link(msg->pending_images, i_it);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
228 if (msg->pending_images != NULL) {
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
229 purple_debug_info("gg", "ggp_message_request_images_got: "
34418
c27e31267e8d Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34413
diff changeset
230 "got image " GGP_IMAGE_ID_FORMAT ", but the message "
c27e31267e8d Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34413
diff changeset
231 "contains more of them\n", id);
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
232 return;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
233 }
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
234
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
235 ggp_message_got_display(gc, msg);
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
236 ggp_message_got_data_free(msg);
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
237 sdata->pending_messages = g_list_delete_link(sdata->pending_messages,
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
238 m_it);
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
239 }
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
240
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
241 static gboolean ggp_message_request_images(PurpleConnection *gc,
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
242 ggp_message_got_data *msg)
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
243 {
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
244 ggp_message_session_data *sdata = ggp_message_get_sdata(gc);
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
245 GList *it;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
246 if (msg->pending_images == NULL)
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
247 return FALSE;
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35190
diff changeset
248
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
249 it = msg->pending_images;
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
250 while (it) {
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
251 ggp_image_request(gc, msg->user, *(uint64_t*)it->data,
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
252 ggp_message_request_images_got, msg);
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
253 it = g_list_next(it);
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
254 }
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
255
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
256 sdata->pending_messages = g_list_append(sdata->pending_messages, msg);
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
257
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
258 return TRUE;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
259 }
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
260
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
261 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
262 {
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
263 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
264
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
265 msg->gc = gc;
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
266 msg->time = ev->time;
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
267 msg->user = ev->sender;
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
268
34437
ca6d1b4d24b5 Gadu-Gadu: add an option to disable new libgadu API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34430
diff changeset
269 #if GGP_ENABLE_GG11
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
270 if (ev->chat_id != 0) {
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
271 msg->type = GGP_MESSAGE_GOT_TYPE_CHAT;
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
272 msg->chat_id = ev->chat_id;
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
273 } else
34437
ca6d1b4d24b5 Gadu-Gadu: add an option to disable new libgadu API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34430
diff changeset
274 #endif
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
275 {
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
276 msg->type = GGP_MESSAGE_GOT_TYPE_IM;
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
277 }
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
278
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
279 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
280 if (ggp_message_request_images(gc, msg))
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
281 return;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
282
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
283 ggp_message_got_display(gc, msg);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
284 ggp_message_got_data_free(msg);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
285 }
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
286
34360
c6bd55f526f9 Gadu-Gadu: code polishing for messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34359
diff changeset
287 void ggp_message_got_multilogon(PurpleConnection *gc,
c6bd55f526f9 Gadu-Gadu: code polishing for messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34359
diff changeset
288 const struct gg_event_msg *ev)
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
289 {
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
290 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
291
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
292 msg->gc = gc;
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
293 msg->time = ev->time;
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
294 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
295
34437
ca6d1b4d24b5 Gadu-Gadu: add an option to disable new libgadu API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34430
diff changeset
296 #if GGP_ENABLE_GG11
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
297 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
298 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
299 msg->chat_id = ev->chat_id;
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
300 } else
34437
ca6d1b4d24b5 Gadu-Gadu: add an option to disable new libgadu API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34430
diff changeset
301 #endif
34368
b5341ea06a72 Gadu-Gadu: fix conferences used together with multilogon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34365
diff changeset
302 {
b5341ea06a72 Gadu-Gadu: fix conferences used together with multilogon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34365
diff changeset
303 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
304 }
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
305
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
306 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
307 if (ggp_message_request_images(gc, msg))
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
308 return;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
309
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
310 ggp_message_got_display(gc, msg);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
311 ggp_message_got_data_free(msg);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
312 }
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 static void ggp_message_got_display(PurpleConnection *gc,
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
315 ggp_message_got_data *msg)
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
316 {
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
317 if (msg->type == GGP_MESSAGE_GOT_TYPE_IM) {
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 35361
diff changeset
318 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
319 PURPLE_MESSAGE_RECV, msg->time);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
320 }
34437
ca6d1b4d24b5 Gadu-Gadu: add an option to disable new libgadu API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34430
diff changeset
321 #if GGP_ENABLE_GG11
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
322 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
323 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
324 msg->user);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
325 }
34437
ca6d1b4d24b5 Gadu-Gadu: add an option to disable new libgadu API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34430
diff changeset
326 #endif
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
327 else if (msg->type == GGP_MESSAGE_GOT_TYPE_MULTILOGON) {
34946
76aa2e0f8701 Merged default branch
Ankit Vani <a@nevitus.org>
parents: 34437
diff changeset
328 PurpleIMConversation *im = ggp_message_get_conv(gc, msg->user);
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
329 const gchar *me = purple_account_get_username(
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
330 purple_connection_get_account(gc));
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
331
34946
76aa2e0f8701 Merged default branch
Ankit Vani <a@nevitus.org>
parents: 34437
diff changeset
332 purple_conversation_write(PURPLE_CONVERSATION(im), me, msg->text,
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
333 PURPLE_MESSAGE_SEND, msg->time);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
334 } else
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
335 purple_debug_error("gg", "ggp_message_got_display: "
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
336 "unexpected message type: %d\n", msg->type);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
337 }
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
338
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
339 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
340 GString *res, gpointer data)
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
341 {
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
342 ggp_message_got_data *msg = data;
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
343 gchar *name, *replacement;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
344 int64_t id;
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
345 int stored_id;
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
346
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
347 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
348 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
349 id = 0;
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
350 g_free(name);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
351 if (!id) {
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
352 g_string_append(res, "[");
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
353 g_string_append(res, _("broken image"));
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
354 g_string_append(res, "]");
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
355 return FALSE;
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
356 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35190
diff changeset
357
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
358 stored_id = ggp_image_get_cached(msg->gc, id);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35190
diff changeset
359
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
360 if (stored_id > 0) {
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
361 purple_debug_info("gg", "ggp_message_format_from_gg_found_img: "
34418
c27e31267e8d Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34413
diff changeset
362 "getting image " GGP_IMAGE_ID_FORMAT " from cache\n",
c27e31267e8d Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34413
diff changeset
363 id);
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
364 replacement = g_strdup_printf(GGP_IMAGE_DESTINATION, stored_id);
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
365 g_string_append(res, replacement);
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
366 g_free(replacement);
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
367 return FALSE;
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
368 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35190
diff changeset
369
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
370 if (NULL == g_list_find_custom(msg->pending_images, &id,
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
371 ggp_int64_compare))
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
372 {
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
373 msg->pending_images = g_list_append(msg->pending_images,
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
374 ggp_uint64dup(id));
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
375 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35190
diff changeset
376
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
377 replacement = g_strdup_printf(GGP_IMAGE_REPLACEMENT, id);
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
378 g_string_append(res, replacement);
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
379 g_free(replacement);
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
380
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
381 return FALSE;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
382 }
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
383
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
384 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
385 const gchar *text)
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
386 {
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
387 gchar *text_new, *tmp;
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
388
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
389 if (text == NULL) {
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
390 msg->text = g_strdup("");
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
391 return;
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
392 }
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
393
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
394 text_new = g_strdup(text);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
395 purple_str_strip_char(text_new, '\r');
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
396
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
397 tmp = text_new;
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
398 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
399 GGP_GG10_DEFAULT_FORMAT_REPLACEMENT);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
400 g_free(tmp);
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
401
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
402 tmp = text_new;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
403 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
404 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
405 g_free(tmp);
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34360
diff changeset
406
34356
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
407 msg->text = text_new;
5d59fd4d5b2d Gadu-Gadu: reimplementation of receiving messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
408 }
34357
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
409
34369
6ae053435538 Gadu-Gadu: enable inline images and GG11 formatting for conferences
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34368
diff changeset
410 gchar * 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
411 {
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
412 gchar *text_new, *tmp;
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
413 GList *rt = NULL; /* reformatted text */
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
414 GMatchInfo *match;
34430
15639e15839e Gadu-Gadu: fix -Wsign-compare errors
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34418
diff changeset
415 guint pos = 0;
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
416 GList *pending_objects = NULL;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
417 GList *font_stack = NULL;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
418 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
419
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
420 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
421 gboolean font_changed = FALSE;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
422 gboolean in_any_tag = FALSE;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
423
34360
c6bd55f526f9 Gadu-Gadu: code polishing for messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34359
diff changeset
424 /* TODO: verbose
c6bd55f526f9 Gadu-Gadu: code polishing for messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34359
diff changeset
425 * purple_debug_info("gg", "ggp formatting text: [%s]\n", text);
c6bd55f526f9 Gadu-Gadu: code polishing for messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34359
diff changeset
426 */
34357
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
427
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
428 /* default font */
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
429 font_base = ggp_font_new();
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
430 font_current = ggp_font_new();
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
431 font_new = ggp_font_new();
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
432
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
433 /* 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
434 text_new = purple_strreplace(text, "&nbsp;", " ");
34357
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
435
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
436 /* add end-of-message tag */
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
437 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
438 tmp = text_new;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
439 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
440 g_free(tmp);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
441 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
442 "unexpected <eom> tag\n");
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
443 }
34357
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
444 tmp = text_new;
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
445 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
446 g_free(tmp);
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
447
34359
7cf367cc1141 Gadu-Gadu: compile regular expressions only once per plugin load
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34358
diff changeset
448 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
449 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
450 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
451 gboolean tag_close;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
452 gchar *tag_str, *attribs_str;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
453 ggp_html_tag tag;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
454 gboolean text_before;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
455
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
456 /* reading tag and its contents */
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
457 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
458 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
459 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
460 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
461 tag_close = (m_pos >= 0);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
462 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
463 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
464 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
465 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
466
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
467 if (tag == GGP_HTML_TAG_UNKNOWN) {
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
468 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
469 "uknown tag %s\n", tag_str);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
470 }
34358
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 /* closing *all* formatting-related tags (GG11 weirness)
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
473 * and adding pending objects */
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
474 if ((text_before && (font_changed || pending_objects)) ||
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
475 (tag == GGP_HTML_TAG_EOM && tag_close))
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
476 {
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
477 font_changed = FALSE;
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
478 if (in_any_tag) {
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
479 in_any_tag = FALSE;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
480 if (font_current->s && !GGP_GG11_FORCE_COMPAT)
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
481 rt = g_list_prepend(rt,
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
482 g_strdup("</s>"));
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
483 if (font_current->u)
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
484 rt = g_list_prepend(rt,
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
485 g_strdup("</u>"));
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
486 if (font_current->i)
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
487 rt = g_list_prepend(rt,
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
488 g_strdup("</i>"));
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
489 if (font_current->b)
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
490 rt = g_list_prepend(rt,
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
491 g_strdup("</b>"));
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
492 rt = g_list_prepend(rt, g_strdup("</span>"));
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
493 }
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
494 if (pending_objects) {
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
495 rt = g_list_concat(pending_objects, rt);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
496 pending_objects = NULL;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
497 }
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
498 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35190
diff changeset
499
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
500 /* opening formatting-related tags again */
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
501 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
502 gchar *style;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
503 GList *styles = NULL;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
504 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
505 font_new->size <= 7 && font_new->size != 3);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35190
diff changeset
506
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
507 if (has_size)
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
508 styles = g_list_append(styles, g_strdup_printf(
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
509 "font-size:%dpt;",
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
510 html_sizes_pt[font_new->size - 1]));
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
511 if (font_new->face)
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
512 styles = g_list_append(styles, g_strdup_printf(
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
513 "font-family:%s;", font_new->face));
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
514 if (font_new->bgcolor >= 0 && !GGP_GG11_FORCE_COMPAT)
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
515 styles = g_list_append(styles, g_strdup_printf(
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
516 "background-color:#%06x;",
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
517 font_new->bgcolor));
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
518 if (font_new->color >= 0)
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
519 styles = g_list_append(styles, g_strdup_printf(
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
520 "color:#%06x;", font_new->color));
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35190
diff changeset
521
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
522 if (styles) {
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
523 gchar *combined = ggp_strjoin_list(" ", styles);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
524 g_list_free_full(styles, g_free);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
525 style = g_strdup_printf(" style=\"%s\"",
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
526 combined);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
527 g_free(combined);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
528 } else
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
529 style = g_strdup("");
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
530 rt = g_list_prepend(rt, g_strdup_printf("<span%s>",
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
531 style));
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
532 g_free(style);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
533
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
534 if (font_new->b)
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
535 rt = g_list_prepend(rt, g_strdup("<b>"));
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
536 if (font_new->i)
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
537 rt = g_list_prepend(rt, g_strdup("<i>"));
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
538 if (font_new->u)
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
539 rt = g_list_prepend(rt, g_strdup("<u>"));
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
540 if (font_new->s && !GGP_GG11_FORCE_COMPAT)
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
541 rt = g_list_prepend(rt, g_strdup("<s>"));
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
542
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
543 ggp_font_free(font_current);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
544 font_current = font_new;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
545 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
546
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
547 in_any_tag = TRUE;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
548 }
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
549 if (text_before) {
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
550 rt = g_list_prepend(rt,
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
551 g_strndup(text_new + pos, m_start - pos));
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 /* set formatting of a following text */
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
555 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
556 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
557 font_new->b = !tag_close;
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
558 } 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
559 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
560 font_new->i = !tag_close;
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
561 } 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
562 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
563 font_new->u = !tag_close;
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
564 } 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
565 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
566 font_new->s = !tag_close;
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
567 } 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
568 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
569 gchar *val = NULL;
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
570 uint64_t id;
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
571 int stored_id = -1;
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
572 ggp_image_prepare_result res = -1;
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35190
diff changeset
573
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
574 if ((val = g_hash_table_lookup(attribs, "src")) != NULL
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
575 && g_str_has_prefix(val,
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
576 PURPLE_STORED_IMAGE_PROTOCOL))
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
577 {
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
578 val += strlen(PURPLE_STORED_IMAGE_PROTOCOL);
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
579 if (sscanf(val, "%u", &stored_id) != 1)
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
580 stored_id = -1;
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
581 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35190
diff changeset
582
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
583 if (stored_id >= 0)
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
584 res = ggp_image_prepare(conv, stored_id, &id);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35190
diff changeset
585
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
586 if (res == GGP_IMAGE_PREPARE_OK) {
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
587 pending_objects = g_list_prepend(
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
588 pending_objects, g_strdup_printf(
34418
c27e31267e8d Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34413
diff changeset
589 "<img name=\"" GGP_IMAGE_ID_FORMAT
c27e31267e8d Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34413
diff changeset
590 "\">", id));
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
591 } else if (res == GGP_IMAGE_PREPARE_TOO_BIG) {
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
592 purple_conversation_write(conv, "",
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
593 _("Image is too large, please try "
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
594 "smaller one."), PURPLE_MESSAGE_ERROR,
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
595 time(NULL));
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
596 } else {
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
597 purple_conversation_write(conv, "",
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
598 _("Image cannot be sent."),
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
599 PURPLE_MESSAGE_ERROR, time(NULL));
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
600 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35190
diff changeset
601
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
602 g_hash_table_destroy(attribs);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
603 } 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
604 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
605 gchar *val = NULL;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
606
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
607 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
608 ggp_font_clone(font_new));
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
609
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
610 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
611 && 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
612 val[1] == '\0')
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
613 {
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
614 int size = val[0] - '0';
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
615 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
616 font_new->size = size;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
617 }
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
618
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
619 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
620 != NULL)
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
621 {
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
622 font_changed |=
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
623 (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
624 g_free(font_new->face);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
625 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
626 }
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 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
629 != 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
630 {
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
631 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
632 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
633 font_new->color = color;
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
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
636 g_hash_table_destroy(attribs);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
637 }
34360
c6bd55f526f9 Gadu-Gadu: code polishing for messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34359
diff changeset
638 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
639 && !tag_close)
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
640 {
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
641 GHashTable *attribs, *styles = NULL;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
642 gchar *style = NULL;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
643 gchar *val = NULL;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
644
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
645 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
646
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
647 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
648 ggp_font_clone(font_new));
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
649 if (tag == GGP_HTML_TAG_DIV)
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
650 pending_objects = g_list_prepend(
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
651 pending_objects, g_strdup("<br>"));
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
652
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
653 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
654 if (style)
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
655 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
656
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
657 if ((val = g_hash_table_lookup(styles,
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
658 "background-color")) != NULL)
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
659 {
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
660 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
661 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
662 font_new->bgcolor = color;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
663 }
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
664
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
665 if ((val = g_hash_table_lookup(styles,
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
666 "color")) != NULL)
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
667 {
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
668 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
669 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
670 font_new->color = color;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
671 }
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
672
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
673 if (styles)
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
674 g_hash_table_destroy(styles);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
675 g_hash_table_destroy(attribs);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
676 }
34360
c6bd55f526f9 Gadu-Gadu: code polishing for messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34359
diff changeset
677 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
678 || 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
679 {
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
680 font_changed = TRUE;
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35190
diff changeset
681
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
682 ggp_font_free(font_new);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
683 if (font_stack) {
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
684 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
685 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
686 font_stack, font_stack);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
687 }
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
688 else
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
689 font_new = ggp_font_clone(font_base);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
690 } else if (tag == GGP_HTML_TAG_BR) {
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
691 pending_objects = g_list_prepend(pending_objects,
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
692 g_strdup("<br>"));
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
693 } else if (tag == GGP_HTML_TAG_HR) {
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
694 pending_objects = g_list_prepend(pending_objects,
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
695 g_strdup("<br><span>---</span><br>"));
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
696 } 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
697 /* do nothing */
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
698 } else if (tag == GGP_HTML_TAG_UNKNOWN) {
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
699 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
700 "uknown tag %s\n", tag_str);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
701 } else {
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
702 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
703 "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
704 }
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
705
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
706 pos = m_end;
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
707 g_free(tag_str);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
708 g_free(attribs_str);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
709 }
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
710 g_match_info_free(match);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
711
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
712 if (pos < strlen(text_new) || in_any_tag) {
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
713 purple_debug_fatal("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
714 "end of message not reached\n");
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
715 }
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
716
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
717 /* releasing fonts recources */
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
718 ggp_font_free(font_new);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
719 ggp_font_free(font_current);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
720 ggp_font_free(font_base);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
721 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
722
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
723 /* 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
724 rt = g_list_reverse(rt);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
725 g_free(text_new);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
726 text_new = ggp_strjoin_list("", rt);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
727 g_list_free_full(rt, g_free);
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
728
34360
c6bd55f526f9 Gadu-Gadu: code polishing for messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34359
diff changeset
729 /* TODO: verbose
c6bd55f526f9 Gadu-Gadu: code polishing for messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34359
diff changeset
730 * purple_debug_info("gg", "reformatted text: [%s]\n", text_new);
c6bd55f526f9 Gadu-Gadu: code polishing for messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34359
diff changeset
731 */
34358
845e66c9a20d Gadu-Gadu: sent messages reformatting, as in GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34357
diff changeset
732
34357
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
733 return text_new;
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
734 }
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
735
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
736 int ggp_message_send_im(PurpleConnection *gc, const char *who,
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
737 const char *message, PurpleMessageFlags flags)
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
738 {
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
739 GGPInfo *info = purple_connection_get_protocol_data(gc);
34946
76aa2e0f8701 Merged default branch
Ankit Vani <a@nevitus.org>
parents: 34437
diff changeset
740 PurpleIMConversation *im;
34357
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
741 ggp_buddy_data *buddy_data;
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
742 gchar *gg_msg;
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
743 gboolean succ;
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
744
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
745 /* TODO: return -ENOTCONN, if not connected */
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
746
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
747 if (message == NULL || message[0] == '\0')
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
748 return 0;
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
749
34946
76aa2e0f8701 Merged default branch
Ankit Vani <a@nevitus.org>
parents: 34437
diff changeset
750 buddy_data = ggp_buddy_get_data(purple_blist_find_buddy(
34357
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
751 purple_connection_get_account(gc), who));
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
752
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
753 if (buddy_data->blocked)
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
754 return -1;
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
755
34946
76aa2e0f8701 Merged default branch
Ankit Vani <a@nevitus.org>
parents: 34437
diff changeset
756 im = purple_conversations_find_im_with_account(
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
757 who, purple_connection_get_account(gc));
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
758
34946
76aa2e0f8701 Merged default branch
Ankit Vani <a@nevitus.org>
parents: 34437
diff changeset
759 gg_msg = ggp_message_format_to_gg(PURPLE_CONVERSATION(im), message);
34357
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
760
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
761 /* TODO: splitting messages */
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
762 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
763 g_free(gg_msg);
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
764 return -E2BIG;
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
765 }
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
766
34437
ca6d1b4d24b5 Gadu-Gadu: add an option to disable new libgadu API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34430
diff changeset
767 #if GGP_ENABLE_GG11
34357
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
768 succ = (gg_send_message_html(info->session, GG_CLASS_CHAT,
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
769 ggp_str_to_uin(who), (unsigned char *)gg_msg) >= 0);
34437
ca6d1b4d24b5 Gadu-Gadu: add an option to disable new libgadu API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34430
diff changeset
770 #else
ca6d1b4d24b5 Gadu-Gadu: add an option to disable new libgadu API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34430
diff changeset
771 {
ca6d1b4d24b5 Gadu-Gadu: add an option to disable new libgadu API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34430
diff changeset
772 gchar *plain = purple_markup_strip_html(gg_msg);
ca6d1b4d24b5 Gadu-Gadu: add an option to disable new libgadu API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34430
diff changeset
773 succ = (gg_send_message(info->session, GG_CLASS_CHAT,
ca6d1b4d24b5 Gadu-Gadu: add an option to disable new libgadu API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34430
diff changeset
774 ggp_str_to_uin(who), (unsigned char *)plain) >= 0);
ca6d1b4d24b5 Gadu-Gadu: add an option to disable new libgadu API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34430
diff changeset
775 g_free(plain);
ca6d1b4d24b5 Gadu-Gadu: add an option to disable new libgadu API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34430
diff changeset
776 }
ca6d1b4d24b5 Gadu-Gadu: add an option to disable new libgadu API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34430
diff changeset
777 #endif
34357
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
778
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
779 g_free(gg_msg);
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
780
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
781 return succ ? 1 : -1;
74dff2310289 Gadu-Gadu: reimplementation of sending messages
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34356
diff changeset
782 }

mercurial