Mercurial > pidgin
annotate libpurple/protocols/gg/lib/message.c @ 31659:3a3af6ad3166
Use dngettext() for two strings in the MXit protocol so that we handle
the plural case(s) correctly
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 12 Jun 2011 17:52:59 +0000 |
parents | 3b8415185090 |
children |
rev | line source |
---|---|
31410
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1 /* |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2 * (C) Copyright 2001-2010 Wojtek Kaniewski <wojtekka@irc.pl> |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
3 * |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
5 * it under the terms of the GNU Lesser General Public License Version |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
6 * 2.1 as published by the Free Software Foundation. |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
7 * |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
8 * This program is distributed in the hope that it will be useful, |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
11 * GNU Lesser General Public License for more details. |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
12 * |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
13 * You should have received a copy of the GNU Lesser General Public |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
14 * License along with this program; if not, write to the Free Software |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
16 * USA. |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
17 */ |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
18 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
19 /** |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
20 * \file message.c |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
21 * |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
22 * \brief Obsługa wiadomości |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
23 * |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
24 * Plik zawiera funkcje dotyczące obsługi "klasy" gg_message_t, które |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
25 * w przyszłości zostaną dołączone do API. Obecnie używane są funkcje |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
26 * konwersji między tekstem z atrybutami i HTML. |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
27 */ |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
28 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
29 #include <stdlib.h> |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
30 #include <string.h> |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
31 #include <errno.h> |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
32 #include <limits.h> |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
33 #include <ctype.h> |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
34 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
35 #include "message.h" |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
36 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
37 #if 0 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
38 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
39 gg_message_t *gg_message_new(void) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
40 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
41 gg_message_t *gm; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
42 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
43 gm = malloc(sizeof(gg_message_t)); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
44 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
45 if (gm == NULL) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
46 return NULL; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
47 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
48 memset(gm, 0, sizeof(gg_message_t)); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
49 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
50 gm->msgclass = GG_CLASS_CHAT; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
51 gm->seq = (uint32_t) -1; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
52 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
53 return gm; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
54 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
55 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
56 int gg_message_init(gg_message_t *gm, int msgclass, int seq, uin_t *recipients, size_t recipient_count, char *text, char *html, char *attributes, size_t attributes_length, int auto_convert) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
57 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
58 GG_MESSAGE_CHECK(gm, -1); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
59 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
60 memset(gm, 0, sizeof(gg_message_t)); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
61 gm->recipients = recipients; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
62 gm->recipient_count = recipient_count; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
63 gm->text = text; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
64 gm->html = html; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
65 gm->attributes = attributes; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
66 gm->attributes_length = attributes_length; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
67 gm->msgclass = msgclass; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
68 gm->seq = seq; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
69 gm->auto_convert = auto_convert; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
70 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
71 return 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
72 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
73 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
74 void gg_message_free(gg_message_t *gm) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
75 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
76 if (gm == NULL) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
77 errno = EINVAL; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
78 return; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
79 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
80 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
81 free(gm->text); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
82 free(gm->text_converted); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
83 free(gm->html); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
84 free(gm->html_converted); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
85 free(gm->recipients); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
86 free(gm->attributes); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
87 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
88 free(gm); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
89 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
90 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
91 int gg_message_set_auto_convert(gg_message_t *gm, int auto_convert) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
92 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
93 GG_MESSAGE_CHECK(gm, -1); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
94 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
95 gm->auto_convert = !!auto_convert; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
96 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
97 if (!gm->auto_convert) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
98 free(gm->text_converted); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
99 free(gm->html_converted); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
100 gm->text_converted = NULL; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
101 gm->html_converted = NULL; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
102 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
103 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
104 return 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
105 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
106 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
107 int gg_message_get_auto_convert(gg_message_t *gm) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
108 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
109 GG_MESSAGE_CHECK(gm, -1); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
110 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
111 return gm->auto_convert; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
112 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
113 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
114 int gg_message_set_recipients(gg_message_t *gm, const uin_t *recipients, size_t recipient_count) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
115 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
116 GG_MESSAGE_CHECK(gm, -1); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
117 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
118 if (recipient_count >= INT_MAX / sizeof(uin_t)) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
119 errno = EINVAL; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
120 return -1; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
121 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
122 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
123 if ((recipients == NULL) || (recipient_count == 0)) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
124 free(gm->recipients); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
125 gm->recipients = NULL; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
126 gm->recipient_count = 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
127 } else { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
128 uin_t *tmp; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
129 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
130 tmp = realloc(gm->recipients, recipient_count * sizeof(uin_t)); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
131 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
132 if (tmp == NULL) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
133 return -1; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
134 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
135 memcpy(tmp, recipients, recipient_count * sizeof(uin_t)); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
136 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
137 gm->recipients = tmp; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
138 gm->recipient_count = recipient_count; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
139 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
140 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
141 return 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
142 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
143 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
144 int gg_message_set_recipient(gg_message_t *gm, uin_t recipient) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
145 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
146 return gg_message_set_recipients(gm, &recipient, 1); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
147 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
148 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
149 int gg_message_get_recipients(gg_message_t *gm, const uin_t **recipients, size_t *recipient_count) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
150 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
151 GG_MESSAGE_CHECK(gm, -1); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
152 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
153 if (recipients != NULL) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
154 *recipients = gm->recipients; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
155 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
156 if (recipient_count != NULL) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
157 *recipient_count = gm->recipient_count; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
158 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
159 return 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
160 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
161 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
162 uin_t gg_message_get_recipient(gg_message_t *gm) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
163 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
164 GG_MESSAGE_CHECK(gm, (uin_t) -1); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
165 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
166 if ((gm->recipients == NULL) || (gm->recipient_count < 1)) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
167 // errno = XXX; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
168 return (uin_t) -1; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
169 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
170 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
171 return gm->recipients[0]; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
172 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
173 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
174 int gg_message_set_class(gg_message_t *gm, uint32_t msgclass) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
175 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
176 GG_MESSAGE_CHECK(gm, -1); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
177 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
178 gm->msgclass = msgclass; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
179 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
180 return 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
181 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
182 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
183 uint32_t gg_message_get_class(gg_message_t *gm) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
184 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
185 GG_MESSAGE_CHECK(gm, (uint32_t) -1); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
186 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
187 return gm->msgclass; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
188 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
189 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
190 int gg_message_set_seq(gg_message_t *gm, uint32_t seq) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
191 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
192 GG_MESSAGE_CHECK(gm, -1); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
193 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
194 gm->seq = seq; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
195 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
196 return 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
197 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
198 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
199 uint32_t gg_message_get_seq(gg_message_t *gm) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
200 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
201 GG_MESSAGE_CHECK(gm, (uint32_t) -1); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
202 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
203 return gm->seq; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
204 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
205 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
206 int gg_message_set_text(gg_message_t *gm, const char *text) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
207 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
208 GG_MESSAGE_CHECK(gm, -1); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
209 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
210 if (text == NULL) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
211 free(gm->text); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
212 gm->text = NULL; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
213 } else { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
214 char *tmp; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
215 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
216 tmp = strdup(text); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
217 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
218 if (tmp == NULL) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
219 return -1; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
220 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
221 free(gm->text); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
222 gm->text = tmp; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
223 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
224 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
225 free(gm->html_converted); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
226 gm->html_converted = NULL; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
227 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
228 return 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
229 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
230 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
231 const char *gg_message_get_text(gg_message_t *gm) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
232 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
233 GG_MESSAGE_CHECK(gm, NULL); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
234 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
235 if (gm->text_converted != NULL) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
236 return gm->text_converted; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
237 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
238 if (gm->text == NULL && gm->html != NULL && gm->auto_convert) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
239 size_t len; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
240 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
241 free(gm->text_converted); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
242 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
243 len = gg_message_html_to_text(NULL, gm->html); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
244 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
245 gm->text_converted = malloc(len + 1); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
246 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
247 if (gm->text_converted == NULL) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
248 return NULL; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
249 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
250 gg_message_html_to_text(gm->text_converted, gm->html); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
251 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
252 return gm->text_converted; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
253 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
254 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
255 return gm->text; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
256 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
257 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
258 int gg_message_set_html(gg_message_t *gm, const char *html) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
259 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
260 GG_MESSAGE_CHECK(gm, -1); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
261 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
262 if (html == NULL) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
263 free(gm->html); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
264 gm->html = NULL; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
265 } else { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
266 char *tmp; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
267 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
268 tmp = strdup(html); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
269 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
270 if (tmp == NULL) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
271 return -1; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
272 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
273 free(gm->html); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
274 gm->html = tmp; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
275 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
276 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
277 free(gm->text_converted); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
278 gm->text_converted = NULL; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
279 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
280 return 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
281 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
282 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
283 const char *gg_message_get_html(gg_message_t *gm) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
284 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
285 GG_MESSAGE_CHECK(gm, NULL); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
286 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
287 if (gm->html_converted != NULL) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
288 return gm->html_converted; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
289 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
290 if (gm->html == NULL && gm->text != NULL && gm->auto_convert) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
291 size_t len; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
292 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
293 free(gm->html_converted); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
294 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
295 len = gg_message_text_to_html(NULL, gm->text, gm->attributes, gm->attributes_length); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
296 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
297 gm->html_converted = malloc(len + 1); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
298 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
299 if (gm->html_converted == NULL) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
300 return NULL; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
301 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
302 gg_message_text_to_html(gm->html_converted, gm->text, gm->attributes, gm->attributes_length); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
303 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
304 return gm->html_converted; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
305 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
306 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
307 return gm->html; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
308 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
309 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
310 int gg_message_set_attributes(gg_message_t *gm, const char *attributes, size_t length) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
311 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
312 GG_MESSAGE_CHECK(gm, -1); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
313 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
314 if (length > 0xfffd) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
315 // errno = XXX; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
316 return -1; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
317 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
318 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
319 if ((attributes == NULL) || (length == 0)) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
320 free(gm->attributes); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
321 gm->attributes = NULL; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
322 gm->attributes_length = 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
323 } else { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
324 char *tmp; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
325 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
326 tmp = realloc(gm->attributes, length); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
327 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
328 if (tmp == NULL) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
329 return -1; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
330 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
331 gm->attributes = tmp; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
332 gm->attributes_length = length; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
333 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
334 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
335 free(gm->html_converted); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
336 gm->html_converted = NULL; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
337 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
338 return 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
339 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
340 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
341 int gg_message_get_attributes(gg_message_t *gm, const char **attributes, size_t *attributes_length) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
342 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
343 GG_MESSAGE_CHECK(gm, -1); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
344 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
345 if (attributes != NULL) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
346 *attributes = gm->attributes; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
347 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
348 if (attributes_length != NULL) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
349 *attributes_length = gm->attributes_length; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
350 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
351 return 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
352 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
353 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
354 #endif |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
355 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
356 /** |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
357 * \internal Dodaje tekst na koniec bufora. |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
358 * |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
359 * \param dst Wskaźnik na bufor roboczy |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
360 * \param pos Wskaźnik na aktualne położenie w buforze roboczym |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
361 * \param src Dodawany tekst |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
362 * \param len Długość dodawanego tekstu |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
363 */ |
31484
3b8415185090
Accept broken URLs from third-party GG clients same as official GG.
Ethan Blanton <elb@pidgin.im>
parents:
31410
diff
changeset
|
364 static void gg_append(char *dst, size_t *pos, const void *src, int len) |
31410
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
365 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
366 if (dst != NULL) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
367 memcpy(&dst[*pos], src, len); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
368 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
369 *pos += len; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
370 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
371 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
372 /** |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
373 * \internal Zamienia tekst z formatowaniem Gadu-Gadu na HTML. |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
374 * |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
375 * \param dst Bufor wynikowy (może być \c NULL) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
376 * \param src Tekst źródłowy w UTF-8 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
377 * \param format Atrybuty tekstu źródłowego |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
378 * \param format_len Długość bloku atrybutów tekstu źródłowego |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
379 * |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
380 * \note Wynikowy tekst nie jest idealnym kodem HTML, ponieważ ma jak |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
381 * dokładniej odzwierciedlać to, co wygenerowałby oryginalny klient. |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
382 * |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
383 * \note Dokleja \c \\0 na końcu bufora wynikowego. |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
384 * |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
385 * \return Długość tekstu wynikowego bez \c \\0 (nawet jeśli \c dst to \c NULL). |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
386 */ |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
387 size_t gg_message_text_to_html(char *dst, const char *src, const char *format, size_t format_len) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
388 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
389 const char span_fmt[] = "<span style=\"color:#%02x%02x%02x; font-family:'MS Shell Dlg 2'; font-size:9pt; \">"; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
390 const int span_len = 75; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
391 const char img_fmt[] = "<img name=\"%02x%02x%02x%02x%02x%02x%02x%02x\">"; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
392 const int img_len = 29; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
393 int char_pos = 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
394 int format_idx = 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
395 unsigned char old_attr = 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
396 const unsigned char *color = (const unsigned char*) "\x00\x00\x00"; |
31484
3b8415185090
Accept broken URLs from third-party GG clients same as official GG.
Ethan Blanton <elb@pidgin.im>
parents:
31410
diff
changeset
|
397 int i; |
3b8415185090
Accept broken URLs from third-party GG clients same as official GG.
Ethan Blanton <elb@pidgin.im>
parents:
31410
diff
changeset
|
398 size_t len; |
31410
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
399 const unsigned char *format_ = (const unsigned char*) format; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
400 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
401 len = 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
402 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
403 /* Nie mamy atrybutów dla pierwsze znaku, a tekst nie jest pusty, więc |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
404 * tak czy inaczej trzeba otworzyć <span>. */ |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
405 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
406 if (src[0] != 0 && (format_idx + 3 > format_len || (format_[format_idx] | (format_[format_idx + 1] << 8)) != 0)) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
407 if (dst != NULL) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
408 sprintf(&dst[len], span_fmt, 0, 0, 0); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
409 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
410 len += span_len; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
411 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
412 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
413 /* Pętla przechodzi też przez kończące \0, żeby móc dokleić obrazek |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
414 * na końcu tekstu. */ |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
415 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
416 for (i = 0; ; i++) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
417 /* Analizuj atrybuty tak długo jak dotyczą aktualnego znaku. */ |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
418 for (;;) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
419 unsigned char attr; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
420 int attr_pos; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
421 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
422 if (format_idx + 3 > format_len) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
423 break; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
424 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
425 attr_pos = format_[format_idx] | (format_[format_idx + 1] << 8); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
426 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
427 if (attr_pos != char_pos) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
428 break; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
429 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
430 attr = format_[format_idx + 2]; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
431 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
432 /* Nie doklejaj atrybutów na końcu, co najwyżej obrazki. */ |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
433 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
434 if (src[i] == 0) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
435 attr &= ~(GG_FONT_BOLD | GG_FONT_ITALIC | GG_FONT_UNDERLINE | GG_FONT_COLOR); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
436 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
437 format_idx += 3; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
438 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
439 if ((attr & (GG_FONT_BOLD | GG_FONT_ITALIC | GG_FONT_UNDERLINE | GG_FONT_COLOR)) != 0 || (attr == 0 && old_attr != 0)) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
440 if (char_pos != 0) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
441 if ((old_attr & GG_FONT_UNDERLINE) != 0) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
442 gg_append(dst, &len, "</u>", 4); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
443 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
444 if ((old_attr & GG_FONT_ITALIC) != 0) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
445 gg_append(dst, &len, "</i>", 4); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
446 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
447 if ((old_attr & GG_FONT_BOLD) != 0) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
448 gg_append(dst, &len, "</b>", 4); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
449 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
450 if (src[i] != 0) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
451 gg_append(dst, &len, "</span>", 7); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
452 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
453 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
454 if (((attr & GG_FONT_COLOR) != 0) && (format_idx + 3 <= format_len)) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
455 color = &format_[format_idx]; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
456 format_idx += 3; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
457 } else { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
458 color = (unsigned char*) "\x00\x00\x00"; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
459 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
460 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
461 if (src[i] != 0) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
462 if (dst != NULL) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
463 sprintf(&dst[len], span_fmt, color[0], color[1], color[2]); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
464 len += span_len; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
465 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
466 } else if (char_pos == 0 && src[0] != 0) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
467 if (dst != NULL) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
468 sprintf(&dst[len], span_fmt, 0, 0, 0); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
469 len += span_len; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
470 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
471 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
472 if ((attr & GG_FONT_BOLD) != 0) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
473 gg_append(dst, &len, "<b>", 3); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
474 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
475 if ((attr & GG_FONT_ITALIC) != 0) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
476 gg_append(dst, &len, "<i>", 3); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
477 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
478 if ((attr & GG_FONT_UNDERLINE) != 0) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
479 gg_append(dst, &len, "<u>", 3); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
480 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
481 if (((attr & GG_FONT_IMAGE) != 0) && (format_idx + 10 <= format_len)) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
482 if (dst != NULL) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
483 sprintf(&dst[len], img_fmt, |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
484 format_[format_idx + 9], |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
485 format_[format_idx + 8], |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
486 format_[format_idx + 7], |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
487 format_[format_idx + 6], |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
488 format_[format_idx + 5], |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
489 format_[format_idx + 4], |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
490 format_[format_idx + 3], |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
491 format_[format_idx + 2]); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
492 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
493 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
494 len += img_len; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
495 format_idx += 10; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
496 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
497 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
498 old_attr = attr; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
499 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
500 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
501 /* Doklej znak zachowując htmlowe escapowanie. */ |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
502 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
503 switch (src[i]) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
504 case '&': |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
505 gg_append(dst, &len, "&", 5); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
506 break; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
507 case '<': |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
508 gg_append(dst, &len, "<", 4); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
509 break; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
510 case '>': |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
511 gg_append(dst, &len, ">", 4); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
512 break; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
513 case '\'': |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
514 gg_append(dst, &len, "'", 6); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
515 break; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
516 case '\"': |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
517 gg_append(dst, &len, """, 6); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
518 break; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
519 case '\n': |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
520 gg_append(dst, &len, "<br>", 4); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
521 break; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
522 case '\r': |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
523 case 0: |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
524 break; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
525 default: |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
526 if (dst != NULL) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
527 dst[len] = src[i]; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
528 len++; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
529 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
530 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
531 /* Sprawdź, czy bajt nie jest kontynuacją znaku unikodowego. */ |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
532 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
533 if ((src[i] & 0xc0) != 0xc0) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
534 char_pos++; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
535 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
536 if (src[i] == 0) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
537 break; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
538 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
539 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
540 /* Zamknij tagi. */ |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
541 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
542 if ((old_attr & GG_FONT_UNDERLINE) != 0) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
543 gg_append(dst, &len, "</u>", 4); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
544 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
545 if ((old_attr & GG_FONT_ITALIC) != 0) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
546 gg_append(dst, &len, "</i>", 4); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
547 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
548 if ((old_attr & GG_FONT_BOLD) != 0) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
549 gg_append(dst, &len, "</b>", 4); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
550 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
551 if (src[0] != 0) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
552 gg_append(dst, &len, "</span>", 7); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
553 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
554 if (dst != NULL) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
555 dst[len] = 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
556 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
557 return len; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
558 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
559 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
560 /** |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
561 * \internal Zamienia tekst w formacie HTML na czysty tekst. |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
562 * |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
563 * \param dst Bufor wynikowy (może być \c NULL) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
564 * \param html Tekst źródłowy |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
565 * |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
566 * \note Dokleja \c \\0 na końcu bufora wynikowego. |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
567 * |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
568 * \note Funkcja służy do zachowania kompatybilności przy przesyłaniu |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
569 * wiadomości HTML do klientów, które tego formatu nie obsługują. Z tego |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
570 * powodu funkcja nie zachowuje formatowania, a jedynie usuwa tagi i |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
571 * zamienia podstawowe encje na ich odpowiedniki ASCII. |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
572 * |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
573 * \return Długość tekstu wynikowego bez \c \\0 (nawet jeśli \c dst to \c NULL). |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
574 */ |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
575 size_t gg_message_html_to_text(char *dst, const char *html) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
576 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
577 const char *src, *entity, *tag; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
578 int in_tag, in_entity; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
579 size_t len; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
580 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
581 len = 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
582 in_tag = 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
583 tag = NULL; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
584 in_entity = 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
585 entity = NULL; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
586 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
587 for (src = html; *src != 0; src++) { |
31484
3b8415185090
Accept broken URLs from third-party GG clients same as official GG.
Ethan Blanton <elb@pidgin.im>
parents:
31410
diff
changeset
|
588 if (in_entity && !(isalnum(*src) || *src == '#' || *src == ';')) { |
3b8415185090
Accept broken URLs from third-party GG clients same as official GG.
Ethan Blanton <elb@pidgin.im>
parents:
31410
diff
changeset
|
589 in_entity = 0; |
3b8415185090
Accept broken URLs from third-party GG clients same as official GG.
Ethan Blanton <elb@pidgin.im>
parents:
31410
diff
changeset
|
590 gg_append(dst, &len, entity, src - entity); |
3b8415185090
Accept broken URLs from third-party GG clients same as official GG.
Ethan Blanton <elb@pidgin.im>
parents:
31410
diff
changeset
|
591 } |
3b8415185090
Accept broken URLs from third-party GG clients same as official GG.
Ethan Blanton <elb@pidgin.im>
parents:
31410
diff
changeset
|
592 |
31410
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
593 if (*src == '<') { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
594 tag = src; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
595 in_tag = 1; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
596 continue; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
597 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
598 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
599 if (in_tag && (*src == '>')) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
600 if (strncmp(tag, "<br", 3) == 0) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
601 if (dst != NULL) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
602 dst[len] = '\n'; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
603 len++; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
604 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
605 in_tag = 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
606 continue; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
607 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
608 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
609 if (in_tag) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
610 continue; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
611 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
612 if (*src == '&') { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
613 in_entity = 1; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
614 entity = src; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
615 continue; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
616 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
617 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
618 if (in_entity && *src == ';') { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
619 in_entity = 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
620 if (dst != NULL) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
621 if (strncmp(entity, "<", 4) == 0) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
622 dst[len++] = '<'; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
623 else if (strncmp(entity, ">", 4) == 0) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
624 dst[len++] = '>'; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
625 else if (strncmp(entity, """, 6) == 0) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
626 dst[len++] = '"'; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
627 else if (strncmp(entity, "'", 6) == 0) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
628 dst[len++] = '\''; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
629 else if (strncmp(entity, "&", 5) == 0) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
630 dst[len++] = '&'; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
631 else if (strncmp(entity, " ", 6) == 0) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
632 dst[len++] = 0xc2; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
633 dst[len++] = 0xa0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
634 } else |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
635 dst[len++] = '?'; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
636 } else { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
637 if (strncmp(entity, " ", 6) == 0) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
638 len += 2; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
639 else |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
640 len++; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
641 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
642 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
643 continue; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
644 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
645 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
646 if (in_entity && !(isalnum(*src) || *src == '#')) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
647 in_entity = 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
648 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
649 if (in_entity) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
650 continue; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
651 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
652 if (dst != NULL) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
653 dst[len] = *src; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
654 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
655 len++; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
656 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
657 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
658 if (dst != NULL) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
659 dst[len] = 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
660 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
661 return len; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
662 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
663 |