pidgin: 0759b483: Allow changing to or from an empty passw...

nosnilmot at pidgin.im nosnilmot at pidgin.im
Wed Apr 23 12:40:50 EDT 2008


-----------------------------------------------------------------
Revision: 0759b48350286e0478dc7ba737fd7956a0dbf6f8
Ancestor: 0a066500ab718cb86302e0e4dbc30c2bb40ac366
Author: nosnilmot at pidgin.im
Date: 2008-04-23T16:38:08
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/0759b48350286e0478dc7ba737fd7956a0dbf6f8

Modified files:
        libpurple/account.c

ChangeLog: 

Allow changing to or from an empty password when the protocol specifies
that passwords are optional

-------------- next part --------------
============================================================
--- libpurple/account.c	58c6887bd18eff690346524ba6830de177c6cd8c
+++ libpurple/account.c	c868e8cb151bd6f346ea4e9826733ab64680188c
@@ -1359,8 +1359,12 @@ change_password_cb(PurpleAccount *accoun
 		return;
 	}
 
-	if (orig_pass == NULL || new_pass_1 == NULL || new_pass_2 == NULL ||
-		*orig_pass == '\0' || *new_pass_1 == '\0' || *new_pass_2 == '\0')
+	if ((purple_request_fields_is_field_required(fields, "password") &&
+			(orig_pass == NULL || *orig_pass == '\0')) ||
+		(purple_request_fields_is_field_required(fields, "new_password_1") &&
+			(new_pass_1 == NULL || *new_pass_1 == '\0')) ||
+		(purple_request_fields_is_field_required(fields, "new_password_2") &&
+			(new_pass_2 == NULL || *new_pass_2 == '\0')))
 	{
 		purple_notify_error(account, NULL,
 						  _("Fill out all fields completely."), NULL);
@@ -1376,11 +1380,20 @@ purple_account_request_change_password(P
 	PurpleRequestFields *fields;
 	PurpleRequestFieldGroup *group;
 	PurpleRequestField *field;
+	PurpleConnection *gc;
+	PurplePlugin *prpl = NULL;
+	PurplePluginProtocolInfo *prpl_info = NULL;
 	char primary[256];
 
 	g_return_if_fail(account != NULL);
 	g_return_if_fail(purple_account_is_connected(account));
 
+	gc = purple_account_get_connection(account);
+	if (gc != NULL)
+		prpl = purple_connection_get_prpl(gc);
+	if (prpl != NULL)
+		prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+
 	fields = purple_request_fields_new();
 
 	group = purple_request_field_group_new(NULL);
@@ -1389,21 +1402,24 @@ purple_account_request_change_password(P
 	field = purple_request_field_string_new("password", _("Original password"),
 										  NULL, FALSE);
 	purple_request_field_string_set_masked(field, TRUE);
-	purple_request_field_set_required(field, TRUE);
+	if (!(prpl_info && (prpl_info->options | OPT_PROTO_PASSWORD_OPTIONAL)))
+		purple_request_field_set_required(field, TRUE);
 	purple_request_field_group_add_field(group, field);
 
 	field = purple_request_field_string_new("new_password_1",
 										  _("New password"),
 										  NULL, FALSE);
 	purple_request_field_string_set_masked(field, TRUE);
-	purple_request_field_set_required(field, TRUE);
+	if (!(prpl_info && (prpl_info->options | OPT_PROTO_PASSWORD_OPTIONAL)))
+		purple_request_field_set_required(field, TRUE);
 	purple_request_field_group_add_field(group, field);
 
 	field = purple_request_field_string_new("new_password_2",
 										  _("New password (again)"),
 										  NULL, FALSE);
 	purple_request_field_string_set_masked(field, TRUE);
-	purple_request_field_set_required(field, TRUE);
+	if (!(prpl_info && (prpl_info->options | OPT_PROTO_PASSWORD_OPTIONAL)))
+		purple_request_field_set_required(field, TRUE);
 	purple_request_field_group_add_field(group, field);
 
 	g_snprintf(primary, sizeof(primary), _("Change password for %s"),


More information about the Commits mailing list