libpurple/protocols/gg/account.c

Sun, 22 Jun 2014 16:21:22 -0700

author
Mark Doliner <mark@kingant.net>
date
Sun, 22 Jun 2014 16:21:22 -0700
changeset 36128
e590b053f8af
parent 36124
3dcb9b9b7c11
child 38854
086e15ec656d
permissions
-rw-r--r--

s/Captcha/CAPTCHA/ in a few places.

Suggested by a Norwegian Bokmål translator on our Transifex project.

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

mercurial