libpurple/protocols/gg/account.c

Tue, 19 May 2020 10:29:23 +0000

author
Gary Kramlich <grim@reaperworld.com>
date
Tue, 19 May 2020 10:29:23 +0000
changeset 40417
48c621e76141
parent 40358
e6fe6fc1f516
child 40756
3a58ef28ee44
permissions
-rw-r--r--

Merged in default (pull request #697)

simple: Fix search for message headers

Approved-by: Gary Kramlich

33348
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33331
diff changeset
1 /* purple
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33331
diff changeset
2 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33331
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: 33331
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: 33331
diff changeset
5 * source distribution.
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33331
diff changeset
6 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33331
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: 33331
diff changeset
8 * by Tomek Wasilczyk (http://www.wasilczyk.pl).
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33331
diff changeset
9 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33331
diff changeset
10 * Previously implemented by:
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33331
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: 33331
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: 33331
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: 33331
diff changeset
14 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33331
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: 33331
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: 33331
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: 33331
diff changeset
18 * (at your option) any later version.
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33331
diff changeset
19 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33331
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: 33331
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: 33331
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: 33331
diff changeset
23 * GNU General Public License for more details.
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33331
diff changeset
24 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33331
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: 33331
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: 33331
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: 33331
diff changeset
28 */
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33331
diff changeset
29
33303
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
30 #include "account.h"
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
31
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
32 #include <libgadu.h>
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
33
33306
b1bef9a92b4c Gadu-Gadu: rename purple.(c|h) to purplew.(c|h) - purple wrappers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33305
diff changeset
34 #include "purplew.h"
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
35 #include "utils.h"
33307
45147502ceab Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33306
diff changeset
36 #include "libgaduw.h"
33331
16c66b40f60d Gadu-Gadu: let's use brand new validation for Request API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33310
diff changeset
37 #include "validator.h"
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
38
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
39 /*******************************************************************************
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
40 * Token requesting.
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
41 ******************************************************************************/
33303
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
42
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
43 typedef struct
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
44 {
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
45 ggp_account_token_cb callback;
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
46 PurpleConnection *gc;
33303
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
47 void *user_data;
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
48 } ggp_account_token_reqdata;
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
49
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
50 static void ggp_account_token_response(struct gg_http *h, gboolean success,
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
51 gboolean cancelled, gpointer _reqdata);
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
52
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
53 /******************************************************************************/
33303
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
54
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
55 void ggp_account_token_free(ggp_account_token *token)
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
56 {
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
57 if (!token)
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
58 return;
33303
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
59 g_free(token->id);
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
60 g_free(token->data);
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
61 g_free(token);
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
62 }
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
63
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
64 void ggp_account_token_request(PurpleConnection *gc,
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
65 ggp_account_token_cb callback, void *user_data)
33303
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
66 {
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
67 struct gg_http *h;
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
68 ggp_account_token_reqdata *reqdata;
33308
140aa3ad4cae Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33307
diff changeset
69
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
70 purple_debug_info("gg", "ggp_account_token_request: "
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
71 "requesting token...\n");
33308
140aa3ad4cae Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33307
diff changeset
72
140aa3ad4cae Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33307
diff changeset
73 h = gg_token(TRUE);
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
74
35360
29d788c72350 Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35354
diff changeset
75 if (!h) {
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
76 callback(gc, NULL, user_data);
33303
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
77 return;
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
78 }
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
79
33303
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
80 reqdata = g_new(ggp_account_token_reqdata, 1);
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
81 reqdata->callback = callback;
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
82 reqdata->gc = gc;
33303
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
83 reqdata->user_data = user_data;
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
84 ggp_libgaduw_http_watch(gc, h, ggp_account_token_response, reqdata,
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
85 TRUE);
33303
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
86 }
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
87
33308
140aa3ad4cae Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33307
diff changeset
88 static void ggp_account_token_response(struct gg_http *h, gboolean success,
140aa3ad4cae Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33307
diff changeset
89 gboolean cancelled, gpointer _reqdata)
33303
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
90 {
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
91 ggp_account_token_reqdata *reqdata = _reqdata;
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
92 struct gg_token *token_info;
33308
140aa3ad4cae Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33307
diff changeset
93 ggp_account_token *token = NULL;
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
94
33308
140aa3ad4cae Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33307
diff changeset
95 g_assert(!(success && cancelled));
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
96
33308
140aa3ad4cae Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33307
diff changeset
97 if (cancelled)
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
98 purple_debug_info("gg", "ggp_account_token_handler: "
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
99 "cancelled\n");
35360
29d788c72350 Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35354
diff changeset
100 else if (success) {
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
101 purple_debug_info("gg", "ggp_account_token_handler: "
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
102 "got token\n");
35351
b48e08029b65 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
103
33308
140aa3ad4cae Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33307
diff changeset
104 token = g_new(ggp_account_token, 1);
35351
b48e08029b65 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
105
33308
140aa3ad4cae Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33307
diff changeset
106 token_info = h->data;
140aa3ad4cae Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33307
diff changeset
107 token->id = g_strdup(token_info->tokenid);
140aa3ad4cae Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33307
diff changeset
108 token->size = h->body_size;
140aa3ad4cae Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33307
diff changeset
109 token->data = g_memdup(h->body, token->size);
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
110 token->length = token_info->length;
35360
29d788c72350 Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35354
diff changeset
111 } else {
33308
140aa3ad4cae Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33307
diff changeset
112 purple_debug_error("gg", "ggp_account_token_handler: error\n");
140aa3ad4cae Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33307
diff changeset
113 purple_notify_error(
140aa3ad4cae Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33307
diff changeset
114 purple_connection_get_account(reqdata->gc),
140aa3ad4cae Gadu-Gadu: cancellable gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33307
diff changeset
115 _("Token Error"),
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34332
diff changeset
116 _("Unable to fetch the token."), NULL,
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34332
diff changeset
117 purple_request_cpar_from_connection(reqdata->gc));
33303
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
118 }
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
119
33307
45147502ceab Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33306
diff changeset
120 reqdata->callback(reqdata->gc, token, reqdata->user_data);
45147502ceab Gadu-Gadu: refactoring - gg_http watcher
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33306
diff changeset
121 g_free(reqdata);
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
122 }
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
123
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
124 gboolean ggp_account_token_validate(ggp_account_token *token,
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
125 const gchar *value)
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
126 {
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
127 if (strlen(value) != token->length)
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
128 return FALSE;
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
129 return g_regex_match_simple("^[a-zA-Z0-9]+$", value, 0, 0);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
130 }
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
131
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
132 /*******************************************************************************
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
133 * New account registration.
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
134 ******************************************************************************/
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
135
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
136 typedef struct
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
137 {
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
138 ggp_account_token *token;
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
139 PurpleConnection *gc;
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
140
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
141 gchar *email;
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
142 gchar *password;
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
143 gchar *token_value;
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
144 gboolean password_remember;
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
145 } ggp_account_register_data;
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
146
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
147 static void ggp_account_register_dialog(PurpleConnection *gc,
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
148 ggp_account_token *token, gpointer _register_data);
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
149 static void ggp_account_register_dialog_ok(
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
150 ggp_account_register_data *register_data, PurpleRequestFields *fields);
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
151 static void ggp_account_register_dialog_cancel(
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
152 ggp_account_register_data *register_data, PurpleRequestFields *fields);
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
153 static void ggp_account_register_response(struct gg_http *h, gboolean success,
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
154 gboolean cancelled, gpointer _reqdata);
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
155 static void ggp_account_register_completed(
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
156 ggp_account_register_data *register_data, gboolean success);
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
157
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
158 #define GGP_ACCOUNT_REGISTER_TITLE _("Register New Gadu-Gadu Account")
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
159
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
160 /******************************************************************************/
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
161
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
162 void ggp_account_register(PurpleAccount *account)
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
163 {
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
164 PurpleConnection *gc = purple_account_get_connection(account);
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
165 ggp_account_register_data *register_data;
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
166
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
167 purple_debug_info("gg", "ggp_account_register\n");
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
168
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
169 register_data = g_new0(ggp_account_register_data, 1);
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
170 register_data->gc = gc;
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
171 register_data->password_remember = TRUE;
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
172
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
173 ggp_account_token_request(gc, ggp_account_register_dialog,
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
174 register_data);
33303
50f7a92eeb90 Gadu-Gadu: code refactoring - token request, proxy setup (deprecated)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
175 }
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
176
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
177 static void ggp_account_register_dialog(PurpleConnection *gc,
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
178 ggp_account_token *token, gpointer _register_data)
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
179 {
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
180 PurpleRequestFields *fields;
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
181 PurpleRequestFieldGroup *main_group, *password_group, *token_group;
33331
16c66b40f60d Gadu-Gadu: let's use brand new validation for Request API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33310
diff changeset
182 PurpleRequestField *field, *field_password;
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
183 ggp_account_register_data *register_data = _register_data;
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
184
33351
bd15903d0d89 Gadu-Gadu: fix compilation on 64bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
185 purple_debug_info("gg", "ggp_account_register_dialog(%p, %p, %p)\n",
bd15903d0d89 Gadu-Gadu: fix compilation on 64bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
186 gc, token, _register_data);
35360
29d788c72350 Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35354
diff changeset
187 if (!token) {
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
188 ggp_account_register_completed(register_data, FALSE);
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
189 return;
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
190 }
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
191
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
192 fields = purple_request_fields_new();
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
193 main_group = purple_request_field_group_new(NULL);
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
194 purple_request_fields_add_group(fields, main_group);
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
195
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
196 field = purple_request_field_string_new("email", _("Email"),
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
197 register_data->email, FALSE);
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
198 purple_request_field_set_required(field, TRUE);
33331
16c66b40f60d Gadu-Gadu: let's use brand new validation for Request API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33310
diff changeset
199 purple_request_field_set_validator(field,
16c66b40f60d Gadu-Gadu: let's use brand new validation for Request API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33310
diff changeset
200 purple_request_field_email_validator, NULL);
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
201 purple_request_field_group_add_field(main_group, field);
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
202
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
203 password_group = purple_request_field_group_new(_("Password"));
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
204 purple_request_fields_add_group(fields, password_group);
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
205
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
206 field = purple_request_field_string_new("password1", _("Password"),
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
207 register_data->password, FALSE);
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
208 purple_request_field_set_required(field, TRUE);
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
209 purple_request_field_string_set_masked(field, TRUE);
33331
16c66b40f60d Gadu-Gadu: let's use brand new validation for Request API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33310
diff changeset
210 purple_request_field_set_validator(field, ggp_validator_password, NULL);
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
211 purple_request_field_group_add_field(password_group, field);
33331
16c66b40f60d Gadu-Gadu: let's use brand new validation for Request API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33310
diff changeset
212 field_password = field;
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
213
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
214 field = purple_request_field_string_new("password2",
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
215 _("Password (again)"), register_data->password, FALSE);
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
216 purple_request_field_set_required(field, TRUE);
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
217 purple_request_field_string_set_masked(field, TRUE);
33331
16c66b40f60d Gadu-Gadu: let's use brand new validation for Request API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33310
diff changeset
218 purple_request_field_set_validator(field, ggp_validator_password_equal,
16c66b40f60d Gadu-Gadu: let's use brand new validation for Request API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33310
diff changeset
219 field_password);
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
220 purple_request_field_group_add_field(password_group, field);
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
221
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
222 field = purple_request_field_bool_new("password_remember",
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
223 _("Remember password"), register_data->password_remember);
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
224 purple_request_field_group_add_field(password_group, field);
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
225
36128
e590b053f8af s/Captcha/CAPTCHA/ in a few places.
Mark Doliner <mark@kingant.net>
parents: 36124
diff changeset
226 token_group = purple_request_field_group_new(_("CAPTCHA"));
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
227 purple_request_fields_add_group(fields, token_group);
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
228
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
229 field = purple_request_field_string_new("token_value",
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
230 _("Enter text from image below"), register_data->token_value,
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
231 FALSE);
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
232 purple_request_field_set_required(field, TRUE);
33331
16c66b40f60d Gadu-Gadu: let's use brand new validation for Request API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33310
diff changeset
233 purple_request_field_set_validator(field, ggp_validator_token, token);
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
234 purple_request_field_group_add_field(token_group, field);
33331
16c66b40f60d Gadu-Gadu: let's use brand new validation for Request API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33310
diff changeset
235 purple_debug_info("gg", "token set %p\n", register_data->token);
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
236
36128
e590b053f8af s/Captcha/CAPTCHA/ in a few places.
Mark Doliner <mark@kingant.net>
parents: 36124
diff changeset
237 field = purple_request_field_image_new("token_image", _("CAPTCHA"),
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
238 token->data, token->size);
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
239 purple_request_field_group_add_field(token_group, field);
33331
16c66b40f60d Gadu-Gadu: let's use brand new validation for Request API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33310
diff changeset
240
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
241 register_data->token = token;
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
242
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
243 purple_request_fields(gc,
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
244 GGP_ACCOUNT_REGISTER_TITLE,
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
245 GGP_ACCOUNT_REGISTER_TITLE,
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
246 _("Please, fill in the following fields"), fields,
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
247 _("OK"), G_CALLBACK(ggp_account_register_dialog_ok),
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
248 _("Cancel"), G_CALLBACK(ggp_account_register_dialog_cancel),
34332
876483829700 Request API refactoring: switch purple_request_fields to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34148
diff changeset
249 purple_request_cpar_from_connection(gc), register_data);
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
250 }
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
251
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
252 static void ggp_account_register_dialog_cancel(
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
253 ggp_account_register_data *register_data, PurpleRequestFields *fields)
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
254 {
33351
bd15903d0d89 Gadu-Gadu: fix compilation on 64bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
255 purple_debug_info("gg", "ggp_account_register_dialog_cancel(%p, %p)\n",
bd15903d0d89 Gadu-Gadu: fix compilation on 64bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
256 register_data, fields);
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
257
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
258 ggp_account_register_completed(register_data, FALSE);
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
259 }
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
260
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
261 static void ggp_account_register_dialog_ok(
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
262 ggp_account_register_data *register_data, PurpleRequestFields *fields)
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
263 {
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
264 struct gg_http *h;
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
265
33351
bd15903d0d89 Gadu-Gadu: fix compilation on 64bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
266 purple_debug_misc("gg", "ggp_account_register_dialog_ok(%p, %p)\n",
bd15903d0d89 Gadu-Gadu: fix compilation on 64bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
267 register_data, fields);
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
268
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
269 g_free(register_data->email);
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
270 g_free(register_data->password);
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
271 g_free(register_data->token_value);
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
272
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
273 register_data->email = g_strdup(
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
274 purple_request_fields_get_string(fields, "email"));
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
275 register_data->password = g_strdup(
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
276 purple_request_fields_get_string(fields, "password1"));
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
277 register_data->password_remember =
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
278 purple_request_fields_get_bool(fields, "password_remember");
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
279 register_data->token_value = g_strdup(
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
280 purple_request_fields_get_string(fields, "token_value"));
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
281
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
282 g_assert(register_data->email != NULL);
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
283 g_assert(register_data->password != NULL);
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
284 g_assert(register_data->token_value != NULL);
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
285
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
286 h = gg_register3(register_data->email, register_data->password,
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
287 register_data->token->id, register_data->token_value, TRUE);
35351
b48e08029b65 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
288
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
289 ggp_libgaduw_http_watch(register_data->gc, h,
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
290 ggp_account_register_response, register_data, TRUE);
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
291 }
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
292
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
293 static void ggp_account_register_response(struct gg_http *h, gboolean success,
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
294 gboolean cancelled, gpointer _register_data)
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
295 {
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
296 ggp_account_register_data *register_data = _register_data;
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
297 PurpleAccount *account =
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
298 purple_connection_get_account(register_data->gc);
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
299 struct gg_pubdir *register_result = h->data;
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
300 uin_t uin;
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
301 gchar *tmp;
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
302
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
303 g_assert(!(success && cancelled));
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
304
35360
29d788c72350 Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35354
diff changeset
305 if (cancelled) {
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
306 purple_debug_info("gg", "ggp_account_register_response: "
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
307 "cancelled\n");
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
308 ggp_account_register_completed(register_data, FALSE);
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
309 return;
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
310 }
35360
29d788c72350 Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35354
diff changeset
311 if (!success || !register_result->success) {
35354
aa1f0e988567 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35353
diff changeset
312 /* TODO (libgadu 1.12.x): check register_result->error */
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
313 purple_debug_error("gg", "ggp_account_register_response: "
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
314 "error\n");
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
315 purple_notify_error(NULL,
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
316 GGP_ACCOUNT_REGISTER_TITLE,
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
317 _("Unable to register new account. "
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34332
diff changeset
318 "An unknown error occurred."), NULL,
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34332
diff changeset
319 purple_request_cpar_from_account(account));
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
320 ggp_account_register_completed(register_data, FALSE);
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
321 return;
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
322 }
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
323
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
324 uin = register_result->uin;
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
325 purple_debug_info("gg", "ggp_account_register_response: "
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
326 "registered uin %u\n", uin);
35351
b48e08029b65 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
327
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
328 purple_account_set_username(account, ggp_uin_to_str(uin));
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
329 purple_account_set_remember_password(account,
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
330 register_data->password_remember);
34145
fa72f1e5cd77 Some polishing on files modified on this branch (mostly formatting)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34106
diff changeset
331 purple_account_set_password(account, register_data->password,
fa72f1e5cd77 Some polishing on files modified on this branch (mostly formatting)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34106
diff changeset
332 NULL, NULL);
35351
b48e08029b65 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
333
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
334 tmp = g_strdup_printf(_("Your new GG number: %u."), uin);
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
335 purple_notify_info(account, GGP_ACCOUNT_REGISTER_TITLE,
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34332
diff changeset
336 _("Registration completed successfully!"), tmp,
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34332
diff changeset
337 purple_request_cpar_from_account(account));
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
338 g_free(tmp);
35351
b48e08029b65 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
339
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
340 ggp_account_register_completed(register_data, TRUE);
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33303
diff changeset
341 }
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
342
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
343 static void ggp_account_register_completed(
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
344 ggp_account_register_data *register_data, gboolean success)
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
345 {
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
346 PurpleAccount *account =
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
347 purple_connection_get_account(register_data->gc);
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
348
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
349 purple_debug_misc("gg", "ggp_account_register_completed: %d\n",
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
350 success);
35351
b48e08029b65 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
351
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
352 g_free(register_data->email);
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
353 g_free(register_data->password);
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
354 g_free(register_data->token_value);
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
355 ggp_account_token_free(register_data->token);
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
356 g_free(register_data);
35351
b48e08029b65 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
357
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
358 purple_account_disconnect(account);
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
359 purple_account_register_completed(account, success);
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33308
diff changeset
360 }
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
361
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
362 /*******************************************************************************
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
363 * Password change.
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
364 ******************************************************************************/
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
365
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
366 typedef struct
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
367 {
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
368 ggp_account_token *token;
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
369 PurpleConnection *gc;
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
370
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
371 gchar *email;
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
372 gchar *password_current;
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
373 gchar *password_new;
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
374 gchar *token_value;
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
375 } ggp_account_chpass_data;
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
376
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
377 static void ggp_account_chpass_data_free(ggp_account_chpass_data *chpass_data);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
378 static void ggp_account_chpass_dialog(PurpleConnection *gc,
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
379 ggp_account_token *token, gpointer _chpass_data);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
380 static void ggp_account_chpass_dialog_ok(
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
381 ggp_account_chpass_data *chpass_data, PurpleRequestFields *fields);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
382 static void ggp_account_chpass_dialog_invalid(
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
383 ggp_account_chpass_data *chpass_data, const gchar *message);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
384 static void ggp_account_chpass_dialog_cancel(
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
385 ggp_account_chpass_data *chpass_data, PurpleRequestFields *fields);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
386 static void ggp_account_chpass_response(struct gg_http *h, gboolean success,
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
387 gboolean cancelled, gpointer _chpass_data);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
388
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
389 #define GGP_ACCOUNT_CHPASS_TITLE _("Password change")
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
390
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
391 /******************************************************************************/
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
392
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
393 static void ggp_account_chpass_data_free(ggp_account_chpass_data *chpass_data)
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
394 {
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
395 g_free(chpass_data->email);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
396 g_free(chpass_data->password_current);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
397 g_free(chpass_data->password_new);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
398 g_free(chpass_data->token_value);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
399 ggp_account_token_free(chpass_data->token);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
400 g_free(chpass_data);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
401 }
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
402
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
403 void ggp_account_chpass(PurpleConnection *gc)
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
404 {
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
405 ggp_account_chpass_data *chpass_data;
33865
3f1be2d7ae11 Gadu-Gadu: fix some warnings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33351
diff changeset
406
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
407 purple_debug_info("gg", "ggp_account_chpass\n");
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
408
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
409 chpass_data = g_new0(ggp_account_chpass_data, 1);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
410 chpass_data->gc = gc;
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
411
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
412 ggp_account_token_request(gc, ggp_account_chpass_dialog, chpass_data);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
413 }
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
414
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
415 static void ggp_account_chpass_dialog(PurpleConnection *gc,
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
416 ggp_account_token *token, gpointer _chpass_data)
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
417 {
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
418 ggp_account_chpass_data *chpass_data = _chpass_data;
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
419 PurpleAccount *account = purple_connection_get_account(chpass_data->gc);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
420 PurpleRequestFields *fields;
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
421 PurpleRequestFieldGroup *main_group, *password_group, *token_group;
33331
16c66b40f60d Gadu-Gadu: let's use brand new validation for Request API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33310
diff changeset
422 PurpleRequestField *field, *field_password;
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
423 gchar *primary;
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
424
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
425 purple_debug_info("gg", "ggp_account_chpass_dialog(%p, %p, %p)\n",
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
426 gc, token, _chpass_data);
35360
29d788c72350 Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35354
diff changeset
427 if (!token) {
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
428 ggp_account_chpass_data_free(chpass_data);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
429 return;
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
430 }
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
431
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
432 fields = purple_request_fields_new();
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
433 main_group = purple_request_field_group_new(NULL);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
434 purple_request_fields_add_group(fields, main_group);
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
435
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
436 field = purple_request_field_string_new("email",
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
437 _("New email address"), chpass_data->email, FALSE);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
438 purple_request_field_set_required(field, TRUE);
33331
16c66b40f60d Gadu-Gadu: let's use brand new validation for Request API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33310
diff changeset
439 purple_request_field_set_validator(field,
16c66b40f60d Gadu-Gadu: let's use brand new validation for Request API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33310
diff changeset
440 purple_request_field_email_validator, NULL);
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
441 purple_request_field_group_add_field(main_group, field);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
442
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
443 password_group = purple_request_field_group_new(_("Password"));
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
444 purple_request_fields_add_group(fields, password_group);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
445
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
446 field = purple_request_field_string_new("password_current",
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
447 _("Current password"), chpass_data->password_current, FALSE);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
448 purple_request_field_set_required(field, TRUE);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
449 purple_request_field_string_set_masked(field, TRUE);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
450 purple_request_field_group_add_field(password_group, field);
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
451
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
452 field = purple_request_field_string_new("password_new1",
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
453 _("Password"), chpass_data->password_new, FALSE);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
454 purple_request_field_set_required(field, TRUE);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
455 purple_request_field_string_set_masked(field, TRUE);
33331
16c66b40f60d Gadu-Gadu: let's use brand new validation for Request API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33310
diff changeset
456 purple_request_field_set_validator(field, ggp_validator_password, NULL);
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
457 purple_request_field_group_add_field(password_group, field);
33331
16c66b40f60d Gadu-Gadu: let's use brand new validation for Request API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33310
diff changeset
458 field_password = field;
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
459
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
460 field = purple_request_field_string_new("password_new2",
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
461 _("Password (retype)"), chpass_data->password_new, FALSE);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
462 purple_request_field_set_required(field, TRUE);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
463 purple_request_field_string_set_masked(field, TRUE);
33331
16c66b40f60d Gadu-Gadu: let's use brand new validation for Request API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33310
diff changeset
464 purple_request_field_set_validator(field, ggp_validator_password_equal,
16c66b40f60d Gadu-Gadu: let's use brand new validation for Request API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33310
diff changeset
465 field_password);
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
466 purple_request_field_group_add_field(password_group, field);
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
467
36128
e590b053f8af s/Captcha/CAPTCHA/ in a few places.
Mark Doliner <mark@kingant.net>
parents: 36124
diff changeset
468 token_group = purple_request_field_group_new(_("CAPTCHA"));
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
469 purple_request_fields_add_group(fields, token_group);
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
470
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
471 field = purple_request_field_string_new("token_value",
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
472 _("Enter text from image below"), chpass_data->token_value,
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
473 FALSE);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
474 purple_request_field_set_required(field, TRUE);
33331
16c66b40f60d Gadu-Gadu: let's use brand new validation for Request API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33310
diff changeset
475 purple_request_field_set_validator(field, ggp_validator_token, token);
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
476 purple_request_field_group_add_field(token_group, field);
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
477
36128
e590b053f8af s/Captcha/CAPTCHA/ in a few places.
Mark Doliner <mark@kingant.net>
parents: 36124
diff changeset
478 field = purple_request_field_image_new("token_image", _("CAPTCHA"),
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
479 token->data, token->size);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
480 purple_request_field_group_add_field(token_group, field);
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
481
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
482 chpass_data->token = token;
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
483
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
484 primary = g_strdup_printf(_("Change password for %s"),
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
485 purple_account_get_username(account));
35351
b48e08029b65 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
486
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
487 purple_request_fields(gc, GGP_ACCOUNT_CHPASS_TITLE, primary,
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
488 _("Please enter your current password and your new password."),
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
489 fields,
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
490 _("OK"), G_CALLBACK(ggp_account_chpass_dialog_ok),
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
491 _("Cancel"), G_CALLBACK(ggp_account_chpass_dialog_cancel),
34332
876483829700 Request API refactoring: switch purple_request_fields to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34148
diff changeset
492 purple_request_cpar_from_connection(gc), chpass_data);
35351
b48e08029b65 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
493
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
494 g_free(primary);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
495 }
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
496
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
497 static void ggp_account_chpass_dialog_ok(
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
498 ggp_account_chpass_data *chpass_data, PurpleRequestFields *fields)
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
499 {
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
500 PurpleAccount *account = purple_connection_get_account(chpass_data->gc);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
501 struct gg_http *h;
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
502 uin_t uin;
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
503
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
504 purple_debug_misc("gg", "ggp_account_chpass_dialog_ok(%p, %p)\n",
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
505 chpass_data, fields);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
506
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
507 g_free(chpass_data->email);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
508 g_free(chpass_data->password_current);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
509 g_free(chpass_data->password_new);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
510 g_free(chpass_data->token_value);
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
511
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
512 chpass_data->email = g_strdup(
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
513 purple_request_fields_get_string(fields, "email"));
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
514 chpass_data->password_current = g_strdup(
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
515 purple_request_fields_get_string(fields, "password_current"));
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
516 chpass_data->password_new = g_strdup(
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
517 purple_request_fields_get_string(fields, "password_new1"));
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
518 chpass_data->token_value = g_strdup(
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
519 purple_request_fields_get_string(fields, "token_value"));
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
520
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
521 g_assert(chpass_data->email != NULL);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
522 g_assert(chpass_data->password_current != NULL);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
523 g_assert(chpass_data->password_new != NULL);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
524 g_assert(chpass_data->token_value != NULL);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
525
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
526 if (g_utf8_collate(chpass_data->password_current,
34106
1b0c94670bcc Merge with default.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33351
diff changeset
527 purple_connection_get_password(chpass_data->gc)) != 0)
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
528 {
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
529 g_free(chpass_data->password_current);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
530 chpass_data->password_current = NULL;
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
531 ggp_account_chpass_dialog_invalid(chpass_data,
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
532 _("Your current password is different from the one that"
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
533 " you specified."));
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
534 return;
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
535 }
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
536 if (g_utf8_collate(chpass_data->password_current,
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
537 chpass_data->password_new) == 0)
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
538 {
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
539 g_free(chpass_data->password_new);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
540 chpass_data->password_new = NULL;
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
541 ggp_account_chpass_dialog_invalid(chpass_data,
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
542 _("New password have to be different from the current "
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
543 "one."));
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
544 return;
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
545 }
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
546
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
547 uin = ggp_str_to_uin(purple_account_get_username(account));
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
548 purple_debug_info("gg", "ggp_account_chpass_dialog_ok: validation ok "
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
549 "[token id=%s, value=%s]\n",
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
550 chpass_data->token->id, chpass_data->token_value);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
551 h = gg_change_passwd4(uin, chpass_data->email,
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
552 chpass_data->password_current, chpass_data->password_new,
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
553 chpass_data->token->id, chpass_data->token_value, TRUE);
35351
b48e08029b65 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
554
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
555 ggp_libgaduw_http_watch(chpass_data->gc, h,
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
556 ggp_account_chpass_response, chpass_data, TRUE);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
557 }
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
558
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
559 static void ggp_account_chpass_dialog_invalid(
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
560 ggp_account_chpass_data *chpass_data, const gchar *message)
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
561 {
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
562 purple_debug_warning("gg", "ggp_account_chpass_dialog_invalid: %s\n",
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
563 message);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
564 ggp_account_chpass_dialog(chpass_data->gc, chpass_data->token,
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
565 chpass_data);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
566 purple_notify_error(purple_connection_get_account(chpass_data->gc),
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34332
diff changeset
567 GGP_ACCOUNT_CHPASS_TITLE, message, NULL,
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34332
diff changeset
568 purple_request_cpar_from_connection(chpass_data->gc));
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
569 }
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
570
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
571 static void ggp_account_chpass_dialog_cancel(
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
572 ggp_account_chpass_data *chpass_data, PurpleRequestFields *fields)
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
573 {
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
574 ggp_account_chpass_data_free(chpass_data);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
575 }
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
576
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
577 static void ggp_account_chpass_response(struct gg_http *h, gboolean success,
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
578 gboolean cancelled, gpointer _chpass_data)
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
579 {
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
580 ggp_account_chpass_data *chpass_data = _chpass_data;
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
581 PurpleAccount *account =
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
582 purple_connection_get_account(chpass_data->gc);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
583 struct gg_pubdir *chpass_result = h->data;
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
584
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
585 g_assert(!(success && cancelled));
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
586
35360
29d788c72350 Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35354
diff changeset
587 if (cancelled) {
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
588 purple_debug_info("gg", "ggp_account_chpass_response: "
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
589 "cancelled\n");
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
590 ggp_account_chpass_data_free(chpass_data);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
591 return;
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
592 }
35360
29d788c72350 Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35354
diff changeset
593 if (!success || !chpass_result->success) {
35354
aa1f0e988567 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35353
diff changeset
594 /* TODO (libgadu 1.12.x): check chpass_result->error */
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
595 purple_debug_error("gg", "ggp_account_chpass_response: "
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
596 "error\n");
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
597 purple_notify_error(NULL,
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
598 GGP_ACCOUNT_CHPASS_TITLE,
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
599 _("Unable to change password. "
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34332
diff changeset
600 "An unknown error occurred."), NULL,
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34332
diff changeset
601 purple_request_cpar_from_connection(chpass_data->gc));
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
602 ggp_account_chpass_data_free(chpass_data);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
603 return;
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
604 }
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
605
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
606 purple_debug_info("gg", "ggp_account_chpass_response: "
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
607 "password changed\n");
35351
b48e08029b65 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
608
34145
fa72f1e5cd77 Some polishing on files modified on this branch (mostly formatting)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34106
diff changeset
609 purple_account_set_password(account, chpass_data->password_new,
fa72f1e5cd77 Some polishing on files modified on this branch (mostly formatting)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34106
diff changeset
610 NULL, NULL);
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
611
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
612 purple_notify_info(account, GGP_ACCOUNT_CHPASS_TITLE,
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34332
diff changeset
613 _("Your password has been changed."), NULL,
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34332
diff changeset
614 purple_request_cpar_from_connection(chpass_data->gc));
35351
b48e08029b65 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
615
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
616 ggp_account_chpass_data_free(chpass_data);
35353
1f5964260577 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35351
diff changeset
617
35354
aa1f0e988567 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35353
diff changeset
618 /* TODO: reconnect / check how it is done in original client */
33310
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
619 purple_account_disconnect(account);
5d38cff87be2 Gadu-Gadu: refactoring of password change
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
620 }

mercurial