libpurple/protocols/gg/account.c

Tue, 07 Aug 2012 00:12:39 +0200

author
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
date
Tue, 07 Aug 2012 00:12:39 +0200
branch
soc.2012.gg
changeset 33333
b20aed44c357
parent 33331
16c66b40f60d
child 33348
2394cd23ce8f
permissions
-rw-r--r--

Gadu-Gadu: setting own buddy icon

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

mercurial