libpurple/protocols/gg/utils.c

Tue, 07 Jan 2014 19:02:19 +0100

author
Tomasz Wasilczyk <twasilczyk@pidgin.im>
date
Tue, 07 Jan 2014 19:02:19 +0100
changeset 35144
3590ceb242b5
parent 34429
f0ae13a29cdf
child 35357
389e413e3414
permissions
-rw-r--r--

Gadu-Gadu: multilogon / other sessions dialog implementation. Refs #14366

33348
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33347
diff changeset
1 /* purple
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33347
diff changeset
2 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33347
diff changeset
3 * Purple is the legal property of its developers, whose names are too numerous
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33347
diff changeset
4 * to list here. Please refer to the COPYRIGHT file distributed with this
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33347
diff changeset
5 * source distribution.
11414
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
6 *
33348
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33347
diff changeset
7 * Rewritten from scratch during Google Summer of Code 2012
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33347
diff changeset
8 * by Tomek Wasilczyk (http://www.wasilczyk.pl).
11414
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
9 *
33348
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33347
diff changeset
10 * Previously implemented by:
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33347
diff changeset
11 * - Arkadiusz Miskiewicz <misiek@pld.org.pl> - first implementation (2001);
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33347
diff changeset
12 * - Bartosz Oler <bartosz@bzimage.us> - reimplemented during GSoC 2005;
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33347
diff changeset
13 * - Krzysztof Klinikowski <grommasher@gmail.com> - some parts (2009-2011).
11414
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
14 *
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
15 * This program is free software; you can redistribute it and/or modify
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
16 * it under the terms of the GNU General Public License as published by
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
17 * the Free Software Foundation; either version 2 of the License, or
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
18 * (at your option) any later version.
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
19 *
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
20 * This program is distributed in the hope that it will be useful,
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
23 * GNU General Public License for more details.
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
24 *
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
25 * You should have received a copy of the GNU General Public License
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
26 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 15884
diff changeset
27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
11414
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
28 */
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
29
33299
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
30 #include "utils.h"
11414
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
31
33299
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
32 #include "gg.h"
11414
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
33
33299
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
34 #include <debug.h>
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
35
12224
bf547f7989a4 [gaim-migrate @ 14526]
Richard Laager <rlaager@pidgin.im>
parents: 12223
diff changeset
36 uin_t ggp_str_to_uin(const char *str)
11414
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
37 {
33299
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
38 char *endptr;
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
39 uin_t uin;
11414
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
40
33299
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
41 if (!str || str[0] < '0' || str[0] > '9')
11414
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
42 return 0;
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
43
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
44 errno = 0;
33299
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
45 uin = strtoul(str, &endptr, 10);
11414
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
46
33299
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
47 if (errno == ERANGE || endptr[0] != '\0')
11414
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
48 return 0;
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
49
33299
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
50 return uin;
11414
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
51 }
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
52
33298
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 32438
diff changeset
53 const char * ggp_uin_to_str(uin_t uin)
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 32438
diff changeset
54 {
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 32438
diff changeset
55 static char buff[GGP_UIN_LEN_MAX + 1];
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 32438
diff changeset
56
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 32438
diff changeset
57 g_snprintf(buff, GGP_UIN_LEN_MAX + 1, "%u", uin);
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 32438
diff changeset
58
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 32438
diff changeset
59 return buff;
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 32438
diff changeset
60 }
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 32438
diff changeset
61
34394
ed78b0fc180e Gadu-Gadu: file transfer code tidying, first stage of receiving a file
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34389
diff changeset
62 uin_t ggp_get_my_uin(PurpleConnection *gc)
ed78b0fc180e Gadu-Gadu: file transfer code tidying, first stage of receiving a file
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34389
diff changeset
63 {
ed78b0fc180e Gadu-Gadu: file transfer code tidying, first stage of receiving a file
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34389
diff changeset
64 g_return_val_if_fail(gc != NULL, 0);
ed78b0fc180e Gadu-Gadu: file transfer code tidying, first stage of receiving a file
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34389
diff changeset
65
ed78b0fc180e Gadu-Gadu: file transfer code tidying, first stage of receiving a file
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34389
diff changeset
66 return ggp_str_to_uin(purple_account_get_username(
ed78b0fc180e Gadu-Gadu: file transfer code tidying, first stage of receiving a file
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34389
diff changeset
67 purple_connection_get_account(gc)));
ed78b0fc180e Gadu-Gadu: file transfer code tidying, first stage of receiving a file
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34389
diff changeset
68 }
ed78b0fc180e Gadu-Gadu: file transfer code tidying, first stage of receiving a file
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34389
diff changeset
69
33299
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
70 static gchar * ggp_convert(const gchar *src, const char *srcenc,
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
71 const char *dstenc)
15288
ee9ffc3db216 [gaim-migrate @ 18016]
Bartosz Oler <bartosz@pidgin.im>
parents: 14254
diff changeset
72 {
33299
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
73 gchar *dst;
11414
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
74 GError *err = NULL;
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
75
33299
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
76 if (src == NULL)
11414
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
77 return NULL;
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
78
33299
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
79 dst = g_convert_with_fallback(src, strlen(src), dstenc, srcenc, "?",
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
80 NULL, NULL, &err);
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
81 if (err != NULL)
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
82 {
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
83 purple_debug_error("gg", "error converting from %s to %s: %s\n",
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
84 srcenc, dstenc, err->message);
11414
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
85 g_error_free(err);
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
86 }
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
87
33299
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
88 if (dst == NULL)
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
89 dst = g_strdup(src);
11414
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
90
33299
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
91 return dst;
11414
10b74079ef15 [gaim-migrate @ 13651]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
92 }
20289
5c844288fbec applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19859
diff changeset
93
33299
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
94 gchar * ggp_convert_to_cp1250(const gchar *src)
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
95 {
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
96 return ggp_convert(src, "UTF-8", "CP1250");
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
97 }
20289
5c844288fbec applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19859
diff changeset
98
33299
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
99 gchar * ggp_convert_from_cp1250(const gchar *src)
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
100 {
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
101 return ggp_convert(src, "CP1250", "UTF-8");
20289
5c844288fbec applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19859
diff changeset
102 }
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33305
diff changeset
103
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33305
diff changeset
104 gboolean ggp_password_validate(const gchar *password)
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33305
diff changeset
105 {
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33305
diff changeset
106 const int len = strlen(password);
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33305
diff changeset
107 if (len < 6 || len > 15)
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33305
diff changeset
108 return FALSE;
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33305
diff changeset
109 return g_regex_match_simple("^[ a-zA-Z0-9~`!@#$%^&*()_+=[\\]{};':\",./?"
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33305
diff changeset
110 "<>\\\\|-]+$", password, 0, 0);
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33305
diff changeset
111 }
33334
734fc6da6179 Gadu-Gadu: initial multilogon support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
112
33337
458d578d553d Gadu-Gadu: status refactoring - fix bug with long status
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33334
diff changeset
113 gchar * ggp_utf8_strndup(const gchar *str, gsize n)
458d578d553d Gadu-Gadu: status refactoring - fix bug with long status
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33334
diff changeset
114 {
34304
faf0414a8b51 Fix most of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33757
diff changeset
115 size_t raw_len = strlen(str);
33337
458d578d553d Gadu-Gadu: status refactoring - fix bug with long status
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33334
diff changeset
116 gchar *end_ptr;
458d578d553d Gadu-Gadu: status refactoring - fix bug with long status
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33334
diff changeset
117 if (str == NULL)
458d578d553d Gadu-Gadu: status refactoring - fix bug with long status
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33334
diff changeset
118 return NULL;
458d578d553d Gadu-Gadu: status refactoring - fix bug with long status
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33334
diff changeset
119 if (raw_len <= n)
458d578d553d Gadu-Gadu: status refactoring - fix bug with long status
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33334
diff changeset
120 return g_strdup(str);
458d578d553d Gadu-Gadu: status refactoring - fix bug with long status
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33334
diff changeset
121
458d578d553d Gadu-Gadu: status refactoring - fix bug with long status
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33334
diff changeset
122 end_ptr = g_utf8_offset_to_pointer(str, g_utf8_pointer_to_offset(str, &str[n]));
458d578d553d Gadu-Gadu: status refactoring - fix bug with long status
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33334
diff changeset
123 raw_len = end_ptr - str;
458d578d553d Gadu-Gadu: status refactoring - fix bug with long status
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33334
diff changeset
124
458d578d553d Gadu-Gadu: status refactoring - fix bug with long status
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33334
diff changeset
125 if (raw_len > n)
458d578d553d Gadu-Gadu: status refactoring - fix bug with long status
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33334
diff changeset
126 {
458d578d553d Gadu-Gadu: status refactoring - fix bug with long status
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33334
diff changeset
127 end_ptr = g_utf8_prev_char(end_ptr);
458d578d553d Gadu-Gadu: status refactoring - fix bug with long status
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33334
diff changeset
128 raw_len = end_ptr - str;
458d578d553d Gadu-Gadu: status refactoring - fix bug with long status
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33334
diff changeset
129 }
458d578d553d Gadu-Gadu: status refactoring - fix bug with long status
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33334
diff changeset
130
458d578d553d Gadu-Gadu: status refactoring - fix bug with long status
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33334
diff changeset
131 g_assert(raw_len <= n);
458d578d553d Gadu-Gadu: status refactoring - fix bug with long status
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33334
diff changeset
132
458d578d553d Gadu-Gadu: status refactoring - fix bug with long status
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33334
diff changeset
133 return g_strndup(str, raw_len);
458d578d553d Gadu-Gadu: status refactoring - fix bug with long status
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33334
diff changeset
134 }
33339
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
135
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
136 GSList * ggp_list_copy_to_slist_deep(GList *list, GCopyFunc func,
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
137 gpointer user_data)
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
138 {
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
139 GSList *new_list = NULL;
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
140 GList *it;
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
141
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
142 it = g_list_first(list);
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
143 while (it)
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
144 {
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
145 new_list = g_slist_append(new_list, func(it->data, user_data));
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
146 it = g_list_next(it);
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
147 }
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
148 return new_list;
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
149 }
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
150
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
151 GList * ggp_strsplit_list(const gchar *string, const gchar *delimiter,
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
152 gint max_tokens)
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
153 {
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
154 gchar **splitted, **it;
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
155 GList *list = NULL;
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
156
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
157 it = splitted = g_strsplit(string, delimiter, max_tokens);
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
158 while (*it)
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
159 {
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
160 list = g_list_append(list, *it);
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
161 it++;
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
162 }
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
163 g_free(splitted);
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
164
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
165 return list;
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
166 }
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
167
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
168 gchar * ggp_strjoin_list(const gchar *separator, GList *list)
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
169 {
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
170 gchar **str_array;
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
171 gchar *joined;
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
172 gint list_len, i;
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
173 GList *it;
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
174
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
175 list_len = g_list_length(list);
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
176 str_array = g_new(gchar*, list_len + 1);
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
177
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
178 it = g_list_first(list);
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
179 i = 0;
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
180 while (it)
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
181 {
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
182 str_array[i++] = it->data;
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
183 it = g_list_next(it);
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
184 }
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
185 str_array[i] = NULL;
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
186
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
187 joined = g_strjoinv(separator, str_array);
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
188 g_free(str_array);
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
189
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
190 return joined;
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
191 }
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
192
35144
3590ceb242b5 Gadu-Gadu: multilogon / other sessions dialog implementation. Refs #14366
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34429
diff changeset
193 const gchar * ggp_ipv4_to_str(uint32_t raw_ip)
3590ceb242b5 Gadu-Gadu: multilogon / other sessions dialog implementation. Refs #14366
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34429
diff changeset
194 {
3590ceb242b5 Gadu-Gadu: multilogon / other sessions dialog implementation. Refs #14366
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34429
diff changeset
195 static gchar buff[INET_ADDRSTRLEN];
3590ceb242b5 Gadu-Gadu: multilogon / other sessions dialog implementation. Refs #14366
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34429
diff changeset
196 buff[0] = '\0';
3590ceb242b5 Gadu-Gadu: multilogon / other sessions dialog implementation. Refs #14366
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34429
diff changeset
197
3590ceb242b5 Gadu-Gadu: multilogon / other sessions dialog implementation. Refs #14366
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34429
diff changeset
198 g_snprintf(buff, sizeof(buff), "%d.%d.%d.%d",
3590ceb242b5 Gadu-Gadu: multilogon / other sessions dialog implementation. Refs #14366
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34429
diff changeset
199 ((raw_ip >> 0) & 0xFF),
3590ceb242b5 Gadu-Gadu: multilogon / other sessions dialog implementation. Refs #14366
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34429
diff changeset
200 ((raw_ip >> 8) & 0xFF),
3590ceb242b5 Gadu-Gadu: multilogon / other sessions dialog implementation. Refs #14366
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34429
diff changeset
201 ((raw_ip >> 16) & 0xFF),
3590ceb242b5 Gadu-Gadu: multilogon / other sessions dialog implementation. Refs #14366
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34429
diff changeset
202 ((raw_ip >> 24) & 0xFF));
3590ceb242b5 Gadu-Gadu: multilogon / other sessions dialog implementation. Refs #14366
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34429
diff changeset
203
3590ceb242b5 Gadu-Gadu: multilogon / other sessions dialog implementation. Refs #14366
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34429
diff changeset
204 return buff;
3590ceb242b5 Gadu-Gadu: multilogon / other sessions dialog implementation. Refs #14366
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34429
diff changeset
205 }
3590ceb242b5 Gadu-Gadu: multilogon / other sessions dialog implementation. Refs #14366
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34429
diff changeset
206
34304
faf0414a8b51 Fix most of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33757
diff changeset
207 GList * ggp_list_truncate(GList *list, guint length, GDestroyNotify free_func)
33339
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
208 {
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
209 while (g_list_length(list) > length)
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
210 {
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
211 GList *last = g_list_last(list);
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
212 free_func(last->data);
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
213 list = g_list_delete_link(list, last);
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
214 }
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
215 return list;
02ee2834030c Gadu-Gadu: servers history feature
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33337
diff changeset
216 }
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
217
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
218 gchar * ggp_free_if_equal(gchar *str, const gchar *pattern)
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
219 {
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
220 if (g_strcmp0(str, pattern) == 0)
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
221 {
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
222 g_free(str);
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
223 return NULL;
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
224 }
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
225 return str;
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
226 }
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
227
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
228 const gchar * ggp_date_strftime(const gchar *format, time_t date)
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
229 {
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
230 GDate g_date;
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
231 static gchar buff[30];
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
232
33757
878c94d4ffb3 Use g_date_set_time_t instead of g_date_set_time
Mark Doliner <mark@kingant.net>
parents: 33348
diff changeset
233 g_date_set_time_t(&g_date, date);
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
234 if (0 == g_date_strftime(buff, sizeof(buff), format, &g_date))
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
235 return NULL;
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
236 return buff;
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
237 }
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
238
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
239 time_t ggp_date_from_iso8601(const gchar *str)
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
240 {
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
241 GTimeVal g_timeval;
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
242
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
243 if (!str)
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
244 return 0;
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
245 if (!g_time_val_from_iso8601(str, &g_timeval))
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
246 return 0;
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
247 return g_timeval.tv_sec;
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33339
diff changeset
248 }
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
249
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
250 uint64_t * ggp_uint64dup(uint64_t val)
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
251 {
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
252 uint64_t *ptr = g_new(uint64_t, 1);
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
253 *ptr = val;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
254 return ptr;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
255 }
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
256
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
257 gint ggp_int64_compare(gconstpointer _a, gconstpointer _b)
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
258 {
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
259 const int64_t *ap = _a, *bp = _b;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
260 const int64_t a = *ap, b = *bp;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
261 if (a == b)
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
262 return 0;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
263 if (a < b)
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
264 return -1;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
265 else
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
266 return 1;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
267 }
34384
c81441091162 Simple, but (partially) working outgoing file transfer
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34374
diff changeset
268
c81441091162 Simple, but (partially) working outgoing file transfer
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34374
diff changeset
269 JsonParser * ggp_json_parse(const gchar *data)
c81441091162 Simple, but (partially) working outgoing file transfer
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34374
diff changeset
270 {
c81441091162 Simple, but (partially) working outgoing file transfer
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34374
diff changeset
271 JsonParser *parser;
c81441091162 Simple, but (partially) working outgoing file transfer
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34374
diff changeset
272
c81441091162 Simple, but (partially) working outgoing file transfer
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34374
diff changeset
273 parser = json_parser_new();
c81441091162 Simple, but (partially) working outgoing file transfer
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34374
diff changeset
274 if (json_parser_load_from_data(parser, data, -1, NULL))
c81441091162 Simple, but (partially) working outgoing file transfer
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34374
diff changeset
275 return parser;
c81441091162 Simple, but (partially) working outgoing file transfer
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34374
diff changeset
276
c81441091162 Simple, but (partially) working outgoing file transfer
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34374
diff changeset
277 if (purple_debug_is_unsafe())
c81441091162 Simple, but (partially) working outgoing file transfer
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34374
diff changeset
278 purple_debug_warning("gg", "Invalid JSON: %s\n", data);
c81441091162 Simple, but (partially) working outgoing file transfer
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34374
diff changeset
279 return NULL;
c81441091162 Simple, but (partially) working outgoing file transfer
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34374
diff changeset
280 }

mercurial