Tue, 04 Feb 2014 00:53:44 +0100
Style: fix gg braces (part 2)
|
33348
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33309
diff
changeset
|
1 | /* purple |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33309
diff
changeset
|
2 | * |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33309
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:
33309
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:
33309
diff
changeset
|
5 | * source distribution. |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33309
diff
changeset
|
6 | * |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33309
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:
33309
diff
changeset
|
8 | * by Tomek Wasilczyk (http://www.wasilczyk.pl). |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33309
diff
changeset
|
9 | * |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33309
diff
changeset
|
10 | * Previously implemented by: |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33309
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:
33309
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:
33309
diff
changeset
|
13 | * - Krzysztof Klinikowski <grommasher@gmail.com> - some parts (2009-2011). |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33309
diff
changeset
|
14 | * |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33309
diff
changeset
|
15 | * This program is free software; you can redistribute it and/or modify |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33309
diff
changeset
|
16 | * it under the terms of the GNU General Public License as published by |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33309
diff
changeset
|
17 | * the Free Software Foundation; either version 2 of the License, or |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33309
diff
changeset
|
18 | * (at your option) any later version. |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33309
diff
changeset
|
19 | * |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33309
diff
changeset
|
20 | * This program is distributed in the hope that it will be useful, |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33309
diff
changeset
|
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33309
diff
changeset
|
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33309
diff
changeset
|
23 | * GNU General Public License for more details. |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33309
diff
changeset
|
24 | * |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33309
diff
changeset
|
25 | * You should have received a copy of the GNU General Public License |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33309
diff
changeset
|
26 | * along with this program; if not, write to the Free Software |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33309
diff
changeset
|
27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33309
diff
changeset
|
28 | */ |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33309
diff
changeset
|
29 | |
|
33307
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
30 | #include "libgaduw.h" |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
31 | |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
32 | #include <debug.h> |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
33 | |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
34 | #include "purplew.h" |
|
34373
169db6aa5e08
Gadu-Gadu: very initial GGDrive authentication support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33351
diff
changeset
|
35 | #include "gg.h" |
|
33307
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
36 | |
|
34408
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
37 | static void ggp_libgaduw_debug_handler(int level, const char * format, |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
38 | va_list args); |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
39 | |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
40 | /******************************************************************************* |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
41 | * Setup/cleanup. |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
42 | ******************************************************************************/ |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
43 | |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
44 | void ggp_libgaduw_setup(void) |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
45 | { |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
46 | gg_debug_handler = ggp_libgaduw_debug_handler; |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
47 | } |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
48 | |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
49 | void ggp_libgaduw_cleanup(void) |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
50 | { |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
51 | gg_debug_handler = NULL; |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
52 | } |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
53 | |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
54 | /******************************************************************************* |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
55 | * General. |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
56 | ******************************************************************************/ |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
57 | |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
58 | const gchar * ggp_libgaduw_version(PurpleConnection *gc) |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
59 | { |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
60 | GGPInfo *accdata = purple_connection_get_protocol_data(gc); |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
61 | const gchar *ver = accdata->session->client_version; |
|
35355
3be5d45ba972
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34437
diff
changeset
|
62 | |
|
34408
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
63 | if (ver != NULL && isdigit(ver[0])) |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
64 | return ver; |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
65 | return GG_DEFAULT_CLIENT_VERSION; |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
66 | } |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
67 | |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
68 | static void ggp_libgaduw_debug_handler(int level, const char * format, |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
69 | va_list args) |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
70 | { |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
71 | PurpleDebugLevel purple_level; |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
72 | char *msg; |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
73 | |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
74 | if ((level & GG_DEBUG_NET) || |
|
34437
ca6d1b4d24b5
Gadu-Gadu: add an option to disable new libgadu API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34412
diff
changeset
|
75 | (level & GG_DEBUG_FUNCTION) |
|
ca6d1b4d24b5
Gadu-Gadu: add an option to disable new libgadu API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34412
diff
changeset
|
76 | #if GGP_ENABLE_GG11 |
|
ca6d1b4d24b5
Gadu-Gadu: add an option to disable new libgadu API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34412
diff
changeset
|
77 | || (level & GG_DEBUG_VERBOSE) |
|
ca6d1b4d24b5
Gadu-Gadu: add an option to disable new libgadu API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34412
diff
changeset
|
78 | #endif |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35355
diff
changeset
|
79 | ) |
|
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35355
diff
changeset
|
80 | { |
|
34408
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
81 | if (!purple_debug_is_verbose()) |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
82 | return; |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
83 | } |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
84 | |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
85 | if ((level & GG_DEBUG_DUMP) || /* GG session protocol packets */ |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35355
diff
changeset
|
86 | (level & GG_DEBUG_TRAFFIC)) /* HTTP traffic */ |
|
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35355
diff
changeset
|
87 | { |
|
34408
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
88 | if (!purple_debug_is_verbose() || !purple_debug_is_unsafe()) |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
89 | return; |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
90 | } |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
91 | |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
92 | msg = g_strdup_vprintf(format, args); |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
93 | |
|
34437
ca6d1b4d24b5
Gadu-Gadu: add an option to disable new libgadu API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34412
diff
changeset
|
94 | #if GGP_ENABLE_GG11 |
|
34408
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
95 | if (level & GG_DEBUG_ERROR) |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
96 | purple_level = PURPLE_DEBUG_ERROR; |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
97 | else if (level & GG_DEBUG_WARNING) |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
98 | purple_level = PURPLE_DEBUG_WARNING; |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
99 | else |
|
34437
ca6d1b4d24b5
Gadu-Gadu: add an option to disable new libgadu API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34412
diff
changeset
|
100 | #endif |
|
34408
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
101 | purple_level = PURPLE_DEBUG_MISC; |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
102 | |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
103 | purple_debug(purple_level, "gg", "%s", msg); |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
104 | g_free(msg); |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
105 | } |
|
ee5663c0ffe8
Gadu-Gadu: new libgadu debug handler
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34373
diff
changeset
|
106 | |
|
33307
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
107 | /******************************************************************************* |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
108 | * HTTP requests. |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
109 | ******************************************************************************/ |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
110 | |
|
33308
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
111 | static void ggp_libgaduw_http_processing_cancel(PurpleConnection *gc, |
|
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
112 | void *_req); |
|
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
113 | |
|
33307
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
114 | static void ggp_libgaduw_http_handler(gpointer _req, gint fd, |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
115 | PurpleInputCondition cond); |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
116 | |
|
33308
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
117 | static void ggp_libgaduw_http_finish(ggp_libgaduw_http_req *req, |
|
33307
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
118 | gboolean success); |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
119 | |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
120 | /******************************************************************************/ |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
121 | |
|
33308
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
122 | ggp_libgaduw_http_req * ggp_libgaduw_http_watch(PurpleConnection *gc, |
|
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
123 | struct gg_http *h, ggp_libgaduw_http_cb cb, |
|
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
124 | gpointer user_data, gboolean show_processing) |
|
33307
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
125 | { |
|
33308
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
126 | ggp_libgaduw_http_req *req; |
|
33351
bd15903d0d89
Gadu-Gadu: fix compilation on 64bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33348
diff
changeset
|
127 | purple_debug_misc("gg", "ggp_libgaduw_http_watch(h=%p, " |
|
bd15903d0d89
Gadu-Gadu: fix compilation on 64bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33348
diff
changeset
|
128 | "show_processing=%d)\n", h, show_processing); |
|
35355
3be5d45ba972
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34437
diff
changeset
|
129 | |
|
33308
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
130 | req = g_new(ggp_libgaduw_http_req, 1); |
|
33307
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
131 | req->user_data = user_data; |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
132 | req->cb = cb; |
|
33308
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
133 | req->cancelled = FALSE; |
|
33307
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
134 | req->h = h; |
|
33308
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
135 | req->processing = NULL; |
|
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
136 | if (show_processing) |
|
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
137 | req->processing = ggp_purplew_request_processing(gc, NULL, |
|
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
138 | req, ggp_libgaduw_http_processing_cancel); |
|
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
139 | req->inpa = ggp_purplew_http_input_add(h, ggp_libgaduw_http_handler, |
|
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
140 | req); |
|
35355
3be5d45ba972
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34437
diff
changeset
|
141 | |
|
33307
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
142 | return req; |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
143 | } |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
144 | |
|
33308
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
145 | static void ggp_libgaduw_http_processing_cancel(PurpleConnection *gc, |
|
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
146 | void *_req) |
|
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
147 | { |
|
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
148 | ggp_libgaduw_http_req *req = _req; |
|
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
149 | req->processing = NULL; |
|
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
150 | ggp_libgaduw_http_cancel(req); |
|
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
151 | } |
|
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
152 | |
|
33307
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
153 | static void ggp_libgaduw_http_handler(gpointer _req, gint fd, |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
154 | PurpleInputCondition cond) |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
155 | { |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
156 | ggp_libgaduw_http_req *req = _req; |
|
35355
3be5d45ba972
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34437
diff
changeset
|
157 | |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35355
diff
changeset
|
158 | if (req->h->callback(req->h) == -1 || req->h->state == GG_STATE_ERROR) { |
|
33307
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
159 | purple_debug_error("gg", "ggp_libgaduw_http_handler: failed to " |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
160 | "make http request: %d\n", req->h->error); |
|
33308
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
161 | ggp_libgaduw_http_finish(req, FALSE); |
|
33307
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
162 | return; |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
163 | } |
|
35355
3be5d45ba972
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34437
diff
changeset
|
164 | |
|
3be5d45ba972
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34437
diff
changeset
|
165 | if (purple_debug_is_verbose()) { |
|
3be5d45ba972
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34437
diff
changeset
|
166 | purple_debug_misc("gg", "ggp_libgaduw_http_handler: got fd " |
|
3be5d45ba972
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34437
diff
changeset
|
167 | "update [check=%d, state=%d]\n", req->h->check, |
|
3be5d45ba972
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34437
diff
changeset
|
168 | req->h->state); |
|
3be5d45ba972
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34437
diff
changeset
|
169 | } |
|
3be5d45ba972
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34437
diff
changeset
|
170 | |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35355
diff
changeset
|
171 | if (req->h->state != GG_STATE_DONE) { |
|
33307
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
172 | purple_input_remove(req->inpa); |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
173 | req->inpa = ggp_purplew_http_input_add(req->h, |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
174 | ggp_libgaduw_http_handler, req); |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
175 | return; |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
176 | } |
|
35355
3be5d45ba972
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34437
diff
changeset
|
177 | |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35355
diff
changeset
|
178 | if (!req->h->data || !req->h->body) { |
|
33307
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
179 | purple_debug_error("gg", "ggp_libgaduw_http_handler: got empty " |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
180 | "http response: %d\n", req->h->error); |
|
33308
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
181 | ggp_libgaduw_http_finish(req, FALSE); |
|
33307
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
182 | return; |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
183 | } |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
184 | |
|
33308
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
185 | ggp_libgaduw_http_finish(req, TRUE); |
|
33307
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
186 | } |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
187 | |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
188 | void ggp_libgaduw_http_cancel(ggp_libgaduw_http_req *req) |
|
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
189 | { |
|
33308
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
190 | purple_debug_misc("gg", "ggp_libgaduw_http_cancel\n"); |
|
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
191 | req->cancelled = TRUE; |
|
33307
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
192 | gg_http_stop(req->h); |
|
33308
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
193 | ggp_libgaduw_http_finish(req, FALSE); |
|
33307
45147502ceab
Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
194 | } |
|
33308
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
195 | |
|
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
196 | static void ggp_libgaduw_http_finish(ggp_libgaduw_http_req *req, |
|
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
197 | gboolean success) |
|
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
198 | { |
|
33351
bd15903d0d89
Gadu-Gadu: fix compilation on 64bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33348
diff
changeset
|
199 | purple_debug_misc("gg", "ggp_libgaduw_http_finish(h=%p, processing=%p):" |
|
bd15903d0d89
Gadu-Gadu: fix compilation on 64bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33348
diff
changeset
|
200 | " success=%d\n", req->h, req->processing, success); |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35355
diff
changeset
|
201 | if (req->processing) { |
|
33308
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
202 | ggp_purplew_request_processing_done(req->processing); |
|
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
203 | req->processing = NULL; |
|
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
204 | } |
|
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
205 | purple_input_remove(req->inpa); |
|
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
206 | req->cb(req->h, success, req->cancelled, req->user_data); |
|
33309
bc2f2ea7b5ab
Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33308
diff
changeset
|
207 | req->h->destroy(req->h); |
|
33308
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
208 | g_free(req); |
|
140aa3ad4cae
Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33307
diff
changeset
|
209 | } |