pidgin: 56d4c983: Gadu-Gadu: Fixed password change dialog ...
tomkiewicz at cpw.pidgin.im
tomkiewicz at cpw.pidgin.im
Mon Oct 10 19:45:53 EDT 2011
----------------------------------------------------------------------
Revision: 56d4c98323cf3913d7d60f1a4a4ea38de518a3bc
Parent: ca31ea1640fbc287e7b420c59c08a7477907d66e
Author: tomkiewicz at cpw.pidgin.im
Date: 10/10/11 19:39:33
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/56d4c98323cf3913d7d60f1a4a4ea38de518a3bc
Changelog:
Gadu-Gadu: Fixed password change dialog and problems with connecting to accounts with non-ASCII passwords. Fixes #14652
Changes against parent ca31ea1640fbc287e7b420c59c08a7477907d66e
patched ChangeLog
patched libpurple/protocols/gg/gg-utils.c
patched libpurple/protocols/gg/gg-utils.h
patched libpurple/protocols/gg/gg.c
patched libpurple/protocols/gg/lib/common.c
-------------- next part --------------
============================================================
--- ChangeLog 45e89201b1cad66e36c7413cc16c3fbf83594ffb
+++ ChangeLog 96420b63108e70998a840e94ff9673a55552370b
@@ -12,6 +12,8 @@ version 3.0.0 (??/??/????):
* Show local time for incoming messages. (Tomasz Wasilczyk) (#4579)
* Detailed descriptions on connection failures. (Tomasz Wasilczyk)
(#14648)
+ * Fixed password change dialog and problems with connecting to accounts
+ with non-ASCII passwords. (Tomasz Wasilczyk) (#14652)
MXit:
* Remove all reference to Hidden Number.
============================================================
--- libpurple/protocols/gg/gg.c 81f7b30f636dad0f71f3ab42697010e5e3fd6fe2
+++ libpurple/protocols/gg/gg.c 831ea3124d6b747746d966e5d0a9c2a13b051334
@@ -616,75 +616,137 @@ static void ggp_find_buddies(PurplePlugi
gc);
}
-/* ----- CHANGE PASSWORD ------------------------------------------------ */
+/* ----- CHANGE PASSWORD ---------------------------------------------------- */
-static void ggp_callback_change_passwd_ok(PurpleConnection *gc, PurpleRequestFields *fields)
+typedef struct
{
+ guint inpa;
+ struct gg_http *http_req;
+ gchar *new_password;
PurpleAccount *account;
+} ggp_change_passwd_request;
+
+static void ggp_callback_change_passwd_handler(gpointer _req, gint fd,
+ PurpleInputCondition cond)
+{
+ ggp_change_passwd_request *req = _req;
+ const char *messagesTitle =
+ _("Change password for the Gadu-Gadu account");
+
+ purple_input_remove(req->inpa);
+
+ if (gg_pubdir_watch_fd(req->http_req) == -1 ||
+ req->http_req->state == GG_STATE_ERROR)
+ goto exit_error;
+
+ if (req->http_req->state != GG_STATE_DONE)
+ {
+ req->inpa = ggp_http_input_add(req->http_req,
+ ggp_callback_change_passwd_handler, req);
+ return;
+ }
+
+ if (req->http_req->data != NULL &&
+ ((struct gg_pubdir*)req->http_req->data)->success == 1)
+ {
+ purple_account_set_password(req->account, req->new_password);
+ purple_notify_info(req->account, messagesTitle,
+ _("Password was changed successfully!"), NULL);
+ goto exit_cleanup;
+ }
+
+exit_error:
+ purple_notify_error(req->account, messagesTitle,
+ _("Unable to change password. Error occurred.\n"), NULL);
+
+exit_cleanup:
+ gg_pubdir_free(req->http_req);
+ g_free(req->new_password);
+ g_free(req);
+}
+
+static void ggp_callback_change_passwd_ok(PurpleConnection *gc,
+ PurpleRequestFields *fields)
+{
+ PurpleAccount *account;
GGPInfo *info = purple_connection_get_protocol_data(gc);
struct gg_http *h;
- gchar *cur, *p1, *p2, *t;
+ gchar *cur, *p1, *p2, *t, *mail;
+ const char *messagesTitle =
+ _("Change password for the Gadu-Gadu account");
- cur = charset_convert(
- purple_request_fields_get_string(fields, "password_cur"),
- "UTF-8", "CP1250");
- p1 = charset_convert(
- purple_request_fields_get_string(fields, "password1"),
- "UTF-8", "CP1250");
- p2 = charset_convert(
- purple_request_fields_get_string(fields, "password2"),
- "UTF-8", "CP1250");
- t = charset_convert(
- purple_request_fields_get_string(fields, "token"),
- "UTF-8", "CP1250");
+ cur = g_strdup(purple_request_fields_get_string(fields,
+ "password_cur"));
+ p1 = g_strdup(purple_request_fields_get_string(fields, "password1"));
+ p2 = g_strdup(purple_request_fields_get_string(fields, "password2"));
+ t = g_strdup(purple_request_fields_get_string(fields, "token"));
+ mail = g_strdup(purple_request_fields_get_string(fields, "email"));
account = purple_connection_get_account(gc);
if (cur == NULL || p1 == NULL || p2 == NULL || t == NULL ||
- *cur == '\0' || *p1 == '\0' || *p2 == '\0' || *t == '\0') {
- purple_notify_error(account, NULL, _("Fill in the fields."), NULL);
+ mail == NULL || *cur == '\0' || *p1 == '\0' || *p2 == '\0' ||
+ *t == '\0' || *mail == '\0') {
+ purple_notify_error(account, messagesTitle,
+ _("Fill in the fields."), NULL);
goto exit_err;
}
if (g_utf8_collate(p1, p2) != 0) {
- purple_notify_error(account, NULL,
- _("New passwords do not match."), NULL);
+ purple_notify_error(account, messagesTitle,
+ _("New passwords do not match."), NULL);
goto exit_err;
}
- if (g_utf8_collate(cur, purple_account_get_password(account)) != 0) {
- purple_notify_error(account, NULL,
- _("Your current password is different from the one that you specified."),
+ if (strlen(p1) > 15) {
+ purple_notify_error(account, messagesTitle,
+ _("New password should be at most 15 characters long."),
NULL);
goto exit_err;
}
- purple_debug_info("gg", "Changing password\n");
+ if (g_utf8_collate(cur, purple_account_get_password(account)) != 0) {
+ purple_notify_error(account, messagesTitle,
+ _("Your current password is different from the one that"
+ " you specified."), NULL);
+ goto exit_err;
+ }
- /* XXX: this email should be a pref... */
- h = gg_change_passwd4(ggp_get_uin(account),
- "user at example.net", purple_account_get_password(account),
- p1, info->token->id, t, 0);
-
- if (h == NULL) {
- purple_notify_error(account, NULL,
- _("Unable to change password. Error occurred.\n"),
- NULL);
+ if (!purple_email_is_valid(mail)) {
+ purple_notify_error(account, messagesTitle,
+ _("Invalid email address"), NULL);
goto exit_err;
}
- purple_account_set_password(account, p1);
+ purple_debug_info("gg", "Changing password with email \"%s\"...\n",
+ mail);
- gg_change_passwd_free(h);
+ h = gg_change_passwd4(ggp_get_uin(account), mail,
+ purple_account_get_password(account), p1, info->token->id, t,
+ 1);
- purple_notify_info(account, _("Change password for the Gadu-Gadu account"),
- _("Password was changed successfully!"), NULL);
-
+ if (h == NULL)
+ purple_notify_error(account, messagesTitle,
+ _("Unable to change password. Error occurred.\n"),
+ NULL);
+ else
+ {
+ ggp_change_passwd_request *req =
+ g_new(ggp_change_passwd_request, 1);
+ req->http_req = h;
+ req->new_password = g_strdup(p1);
+ req->account = account;
+
+ req->inpa = ggp_http_input_add(h,
+ ggp_callback_change_passwd_handler, req);
+ }
+
exit_err:
g_free(cur);
g_free(p1);
g_free(p2);
g_free(t);
+ g_free(mail);
g_free(info->token->id);
g_free(info->token->data);
g_free(info->token);
@@ -701,7 +763,6 @@ static void ggp_change_passwd_dialog(Pur
char *msg;
-
fields = purple_request_fields_new();
group = purple_request_field_group_new(NULL);
purple_request_fields_add_group(fields, group);
@@ -721,6 +782,11 @@ static void ggp_change_passwd_dialog(Pur
purple_request_field_string_set_masked(field, TRUE);
purple_request_field_group_add_field(group, field);
+ field = purple_request_field_string_new("email",
+ _("Email Address"), "", FALSE);
+ purple_request_field_string_set_masked(field, FALSE);
+ purple_request_field_group_add_field(group, field);
+
field = purple_request_field_string_new("token",
_("Enter current token"), "", FALSE);
purple_request_field_string_set_masked(field, FALSE);
@@ -732,8 +798,8 @@ static void ggp_change_passwd_dialog(Pur
purple_request_field_group_add_field(group, field);
msg = g_strdup_printf("%s %d",
- _("Please, enter your current password and your new password for UIN: "),
- ggp_get_uin(purple_connection_get_account(gc)));
+ _("Please, enter your current password and your new password "
+ "for UIN: "), ggp_get_uin(purple_connection_get_account(gc)));
purple_request_fields(gc,
_("Change Gadu-Gadu Password"),
@@ -2188,7 +2254,8 @@ static void ggp_login(PurpleAccount *acc
purple_connection_set_protocol_data(gc, info);
glp->uin = ggp_get_uin(account);
- glp->password = (char *)purple_account_get_password(account);
+ glp->password = charset_convert(purple_account_get_password(account),
+ "UTF-8", "CP1250");
if (glp->uin == 0) {
purple_connection_error(gc,
============================================================
--- libpurple/protocols/gg/lib/common.c 07308be3629d7b020ecad9cc87eb006d42802cff
+++ libpurple/protocols/gg/lib/common.c c87ff20f4efb7f6ce12337dfa0ce241ae9bda840
@@ -92,7 +92,7 @@ char *gg_vsaprintf(const char *format, v
}
buf = tmp;
res = vsnprintf(buf, size, format, ap);
- } while (res == size - 1 || res == -1);
+ } while (res >= size - 1 || res == -1);
}
#else
{
============================================================
--- libpurple/protocols/gg/gg-utils.c eb707940da9b935f2d757dbf03bf4c5f049464d6
+++ libpurple/protocols/gg/gg-utils.c a3c001533a7e7da874e10db724203989e8832e7d
@@ -143,5 +143,18 @@ void ggp_status_fake_to_self(PurpleAccou
msg ? "message" : NULL, msg, NULL);
}
+guint ggp_http_input_add(struct gg_http *http_req, PurpleInputFunction func,
+ gpointer user_data)
+{
+ PurpleInputCondition cond = 0;
+ int check = http_req->check;
+ if (check & GG_CHECK_READ)
+ cond |= PURPLE_INPUT_READ;
+ if (check & GG_CHECK_WRITE)
+ cond |= PURPLE_INPUT_WRITE;
+
+ return purple_input_add(http_req->fd, cond, func, user_data);
+}
+
/* vim: set ts=8 sts=0 sw=8 noet: */
============================================================
--- libpurple/protocols/gg/gg-utils.h 3c97606755256a643037fcd3f075f9819622b0df
+++ libpurple/protocols/gg/gg-utils.h 4e0e8f4418fc5fdf051ea77dc022c2c70ae30200
@@ -101,6 +101,21 @@ ggp_status_fake_to_self(PurpleAccount *a
ggp_status_fake_to_self(PurpleAccount *account);
+/**
+ * Adds an input handler in purple event loop for http request.
+ *
+ * @see purple_input_add
+ *
+ * @param http_req Http connection to watch.
+ * @param func The callback function for data.
+ * @param user_data User-specified data.
+ *
+ * @return The resulting handle (will be greater than 0).
+ */
+guint
+ggp_http_input_add(struct gg_http *http_req, PurpleInputFunction func,
+ gpointer user_data);
+
#endif /* _PURPLE_GG_UTILS_H */
/* vim: set ts=8 sts=0 sw=8 noet: */
More information about the Commits
mailing list