Fri, 11 Oct 2019 21:47:21 -0400
Re-arrange GG oauth-purple code to avoid prototypes.
|
33349
d4a017428f4d
Gadu-Gadu: missing copyright notes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
1 | /* purple |
|
d4a017428f4d
Gadu-Gadu: missing copyright notes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
2 | * |
|
d4a017428f4d
Gadu-Gadu: missing copyright notes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
3 | * Purple is the legal property of its developers, whose names are too numerous |
|
d4a017428f4d
Gadu-Gadu: missing copyright notes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
4 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
d4a017428f4d
Gadu-Gadu: missing copyright notes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
5 | * source distribution. |
|
d4a017428f4d
Gadu-Gadu: missing copyright notes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
6 | * |
|
d4a017428f4d
Gadu-Gadu: missing copyright notes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
7 | * Rewritten from scratch during Google Summer of Code 2012 |
|
d4a017428f4d
Gadu-Gadu: missing copyright notes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
8 | * by Tomek Wasilczyk (http://www.wasilczyk.pl). |
|
d4a017428f4d
Gadu-Gadu: missing copyright notes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
9 | * |
|
d4a017428f4d
Gadu-Gadu: missing copyright notes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
10 | * Previously implemented by: |
|
d4a017428f4d
Gadu-Gadu: missing copyright notes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
11 | * - Arkadiusz Miskiewicz <misiek@pld.org.pl> - first implementation (2001); |
|
d4a017428f4d
Gadu-Gadu: missing copyright notes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
12 | * - Bartosz Oler <bartosz@bzimage.us> - reimplemented during GSoC 2005; |
|
d4a017428f4d
Gadu-Gadu: missing copyright notes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
13 | * - Krzysztof Klinikowski <grommasher@gmail.com> - some parts (2009-2011). |
|
d4a017428f4d
Gadu-Gadu: missing copyright notes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
14 | * |
|
d4a017428f4d
Gadu-Gadu: missing copyright notes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
15 | * This program is free software; you can redistribute it and/or modify |
|
d4a017428f4d
Gadu-Gadu: missing copyright notes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
16 | * it under the terms of the GNU General Public License as published by |
|
d4a017428f4d
Gadu-Gadu: missing copyright notes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
17 | * the Free Software Foundation; either version 2 of the License, or |
|
d4a017428f4d
Gadu-Gadu: missing copyright notes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
18 | * (at your option) any later version. |
|
d4a017428f4d
Gadu-Gadu: missing copyright notes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
19 | * |
|
d4a017428f4d
Gadu-Gadu: missing copyright notes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
20 | * This program is distributed in the hope that it will be useful, |
|
d4a017428f4d
Gadu-Gadu: missing copyright notes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
d4a017428f4d
Gadu-Gadu: missing copyright notes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
d4a017428f4d
Gadu-Gadu: missing copyright notes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
23 | * GNU General Public License for more details. |
|
d4a017428f4d
Gadu-Gadu: missing copyright notes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
24 | * |
|
d4a017428f4d
Gadu-Gadu: missing copyright notes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
25 | * You should have received a copy of the GNU General Public License |
|
d4a017428f4d
Gadu-Gadu: missing copyright notes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
26 | * along with this program; if not, write to the Free Software |
|
d4a017428f4d
Gadu-Gadu: missing copyright notes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
d4a017428f4d
Gadu-Gadu: missing copyright notes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
28 | */ |
|
d4a017428f4d
Gadu-Gadu: missing copyright notes
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
29 | |
|
33329
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
30 | #include "oauth-purple.h" |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
31 | |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
32 | #include "oauth.h" |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
33 | #include "../utils.h" |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
34 | #include "../xml.h" |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
35 | |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
36 | #include <debug.h> |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
37 | #include <http.h> |
|
33329
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
38 | |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
39 | #define GGP_OAUTH_RESPONSE_MAX 10240 |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
40 | |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
41 | typedef struct |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
42 | { |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
43 | PurpleConnection *gc; |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
44 | ggp_oauth_request_cb callback; |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
45 | gpointer user_data; |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
46 | gchar *token; |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
47 | gchar *token_secret; |
|
35359
d8aa47a78f55
Style: fix all remaining gg warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34999
diff
changeset
|
48 | |
|
33343
09f740724036
Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33329
diff
changeset
|
49 | gchar *sign_method, *sign_url; |
|
33329
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
50 | } ggp_oauth_data; |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
51 | |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
52 | static void ggp_oauth_data_free(ggp_oauth_data *data) |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
53 | { |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
54 | g_free(data->token); |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
55 | g_free(data->token_secret); |
|
33343
09f740724036
Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33329
diff
changeset
|
56 | g_free(data->sign_method); |
|
09f740724036
Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33329
diff
changeset
|
57 | g_free(data->sign_url); |
|
33329
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
58 | g_free(data); |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
59 | } |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
60 | |
|
40012
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
61 | static void |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
62 | ggp_oauth_access_token_got(PurpleHttpConnection *http_conn, |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
63 | PurpleHttpResponse *response, gpointer user_data) |
|
33329
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
64 | { |
|
40012
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
65 | ggp_oauth_data *data = user_data; |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
66 | gchar *token, *token_secret; |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
67 | PurpleXmlNode *xml; |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
68 | const gchar *xml_raw; |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
69 | gboolean succ = TRUE; |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
70 | |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
71 | xml_raw = purple_http_response_get_data(response, NULL); |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
72 | xml = purple_xmlnode_from_str(xml_raw, -1); |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
73 | if (xml == NULL) { |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
74 | purple_debug_error("gg", "ggp_oauth_access_token_got: invalid xml"); |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
75 | ggp_oauth_data_free(data); |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
76 | return; |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
77 | } |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
78 | |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
79 | succ &= ggp_xml_get_string(xml, "oauth_token", &token); |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
80 | succ &= ggp_xml_get_string(xml, "oauth_token_secret", &token_secret); |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
81 | purple_xmlnode_free(xml); |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
82 | if (!succ || strlen(token) < 10) { |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
83 | purple_debug_error("gg", "ggp_oauth_access_token_got: invalid xml - " |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
84 | "token is not present"); |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
85 | ggp_oauth_data_free(data); |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
86 | return; |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
87 | } |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
88 | |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
89 | if (data->sign_url) { |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
90 | PurpleAccount *account; |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
91 | gchar *auth; |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
92 | |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
93 | purple_debug_misc("gg", "ggp_oauth_access_token_got: got access token, " |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
94 | "returning signed url"); |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
95 | |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
96 | account = purple_connection_get_account(data->gc); |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
97 | auth = gg_oauth_generate_header( |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
98 | data->sign_method, data->sign_url, |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
99 | purple_account_get_username(account), |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
100 | purple_connection_get_password(data->gc), token, token_secret); |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
101 | data->callback(data->gc, auth, data->user_data); |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
102 | } else { |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
103 | purple_debug_misc( |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
104 | "gg", |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
105 | "ggp_oauth_access_token_got: got access token, returning it"); |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
106 | data->callback(data->gc, token, data->user_data); |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
107 | } |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
108 | |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
109 | g_free(token); |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
110 | g_free(token_secret); |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
111 | ggp_oauth_data_free(data); |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
112 | } |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
113 | |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
114 | static void |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
115 | ggp_oauth_authorization_done(PurpleHttpConnection *http_conn, |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
116 | PurpleHttpResponse *response, gpointer user_data) |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
117 | { |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
118 | ggp_oauth_data *data = user_data; |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
119 | PurpleAccount *account; |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
120 | PurpleHttpRequest *req; |
|
33329
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
121 | char *auth; |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
122 | const char *method = "POST"; |
|
40012
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
123 | const char *url = "http://api.gadu-gadu.pl/access_token"; |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
124 | int response_code; |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
125 | |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
126 | PURPLE_ASSERT_CONNECTION_IS_VALID(data->gc); |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
127 | |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
128 | account = purple_connection_get_account(data->gc); |
|
33329
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
129 | |
|
40012
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
130 | response_code = purple_http_response_get_code(response); |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
131 | if (response_code != 302) { |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
132 | purple_debug_error("gg", |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
133 | "ggp_oauth_authorization_done: failed (code = %d)", |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
134 | response_code); |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
135 | ggp_oauth_data_free(data); |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
136 | return; |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
137 | } |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
138 | |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
139 | purple_debug_misc("gg", "ggp_oauth_authorization_done: authorization done, " |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
140 | "requesting access token..."); |
|
33329
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
141 | |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
142 | auth = gg_oauth_generate_header(method, url, |
|
40012
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
143 | purple_account_get_username(account), |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
144 | purple_connection_get_password(data->gc), |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
145 | data->token, data->token_secret); |
|
33329
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
146 | |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
147 | req = purple_http_request_new(url); |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
148 | purple_http_request_set_max_len(req, GGP_OAUTH_RESPONSE_MAX); |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
149 | purple_http_request_set_method(req, method); |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
150 | purple_http_request_header_set(req, "Authorization", auth); |
|
40012
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
151 | purple_http_request(data->gc, req, ggp_oauth_access_token_got, data); |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
152 | purple_http_request_unref(req); |
|
33329
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
153 | |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
154 | free(auth); |
|
33329
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
155 | } |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
156 | |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
157 | static void ggp_oauth_request_token_got(PurpleHttpConnection *http_conn, |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
158 | PurpleHttpResponse *response, gpointer user_data) |
|
33329
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
159 | { |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
160 | ggp_oauth_data *data = user_data; |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
161 | PurpleAccount *account; |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
162 | PurpleHttpRequest *req; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34287
diff
changeset
|
163 | PurpleXmlNode *xml; |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
164 | gchar *request_data; |
|
33329
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
165 | gboolean succ = TRUE; |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
166 | const gchar *xml_raw; |
|
33329
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
167 | |
|
36068
e9b9320a985a
Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35361
diff
changeset
|
168 | PURPLE_ASSERT_CONNECTION_IS_VALID(data->gc); |
|
e9b9320a985a
Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35361
diff
changeset
|
169 | |
|
33329
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
170 | account = purple_connection_get_account(data->gc); |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
171 | |
|
35361
efdbd45604f1
Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35359
diff
changeset
|
172 | if (!purple_http_response_is_successful(response)) { |
|
33329
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
173 | purple_debug_error("gg", "ggp_oauth_request_token_got: " |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
174 | "requested token not received\n"); |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
175 | ggp_oauth_data_free(data); |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
176 | return; |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
177 | } |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
178 | |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
179 | purple_debug_misc("gg", "ggp_oauth_request_token_got: " |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
180 | "got request token, doing authorization...\n"); |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
181 | |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
182 | xml_raw = purple_http_response_get_data(response, NULL); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34287
diff
changeset
|
183 | xml = purple_xmlnode_from_str(xml_raw, -1); |
|
35361
efdbd45604f1
Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35359
diff
changeset
|
184 | if (xml == NULL) { |
|
33329
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
185 | purple_debug_error("gg", "ggp_oauth_request_token_got: " |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
186 | "invalid xml\n"); |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
187 | ggp_oauth_data_free(data); |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
188 | return; |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
189 | } |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
190 | |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
191 | succ &= ggp_xml_get_string(xml, "oauth_token", &data->token); |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
192 | succ &= ggp_xml_get_string(xml, "oauth_token_secret", |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
193 | &data->token_secret); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34287
diff
changeset
|
194 | purple_xmlnode_free(xml); |
|
35361
efdbd45604f1
Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35359
diff
changeset
|
195 | if (!succ) { |
|
33329
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
196 | purple_debug_error("gg", "ggp_oauth_request_token_got: " |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
197 | "invalid xml - token is not present\n"); |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
198 | ggp_oauth_data_free(data); |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
199 | return; |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
200 | } |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
201 | |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
202 | request_data = g_strdup_printf( |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
203 | "callback_url=http://www.mojageneracja.pl&request_token=%s&" |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
204 | "uin=%s&password=%s", data->token, |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
205 | purple_account_get_username(account), |
|
34106
1b0c94670bcc
Merge with default.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33351
diff
changeset
|
206 | purple_connection_get_password(data->gc)); |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
207 | |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
208 | req = purple_http_request_new("https://login.gadu-gadu.pl/authorize"); |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
209 | purple_http_request_set_max_len(req, GGP_OAUTH_RESPONSE_MAX); |
|
35359
d8aa47a78f55
Style: fix all remaining gg warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34999
diff
changeset
|
210 | /* we don't need any results, nor 302 redirection */ |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
211 | purple_http_request_set_max_redirects(req, 0); |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
212 | purple_http_request_set_method(req, "POST"); |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
213 | purple_http_request_header_set(req, "Content-Type", "application/x-www-form-urlencoded"); |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
214 | purple_http_request_set_contents(req, request_data, -1); |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
215 | purple_http_request(data->gc, req, ggp_oauth_authorization_done, data); |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
216 | purple_http_request_unref(req); |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
217 | |
|
33329
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
218 | g_free(request_data); |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
219 | } |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
220 | |
|
40012
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
221 | void |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
222 | ggp_oauth_request(PurpleConnection *gc, ggp_oauth_request_cb callback, |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
223 | gpointer user_data, const gchar *sign_method, |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
224 | const gchar *sign_url) |
|
33329
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
225 | { |
|
40012
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
226 | PurpleAccount *account = purple_connection_get_account(gc); |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
227 | PurpleHttpRequest *req; |
|
33329
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
228 | char *auth; |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
229 | const char *method = "POST"; |
|
40012
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
230 | const char *url = "http://api.gadu-gadu.pl/request_token"; |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
231 | ggp_oauth_data *data; |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
232 | |
|
40012
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
233 | purple_debug_misc("gg", "ggp_oauth_request: requesting token...\n"); |
|
33329
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
234 | |
|
40012
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
235 | auth = gg_oauth_generate_header( |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
236 | method, url, purple_account_get_username(account), |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
237 | purple_connection_get_password(gc), NULL, NULL); |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
238 | |
|
40012
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
239 | data = g_new0(ggp_oauth_data, 1); |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
240 | data->gc = gc; |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
241 | data->callback = callback; |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
242 | data->user_data = user_data; |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
243 | data->sign_method = g_strdup(sign_method); |
|
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
244 | data->sign_url = g_strdup(sign_url); |
|
33329
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
245 | |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
246 | req = purple_http_request_new(url); |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
247 | purple_http_request_set_max_len(req, GGP_OAUTH_RESPONSE_MAX); |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
248 | purple_http_request_set_method(req, method); |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
249 | purple_http_request_header_set(req, "Authorization", auth); |
|
40012
d76cbf47c896
Re-arrange GG oauth-purple code to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
250 | purple_http_request(gc, req, ggp_oauth_request_token_got, data); |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
251 | purple_http_request_unref(req); |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34148
diff
changeset
|
252 | |
|
33329
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
253 | free(auth); |
|
cf23e0f1861a
Gadu-Gadu: OAuth support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
254 | } |