/pidgin/main: 87b96c327216: Merge multiple heads.

Elliott Sales de Andrade qulogic at pidgin.im
Mon Aug 6 03:42:23 EDT 2012


Changeset: 87b96c3272169f5102a227782b1847e7797213a6
Author:	 Elliott Sales de Andrade <qulogic at pidgin.im>
Date:	 2012-08-06 03:41 -0400
Branch:	 default
URL: http://hg.pidgin.im/pidgin/main/rev/87b96c327216

Description:

Merge multiple heads.

diffstat:

 libpurple/request.c |  37 +++++++++++++++++++++----------------
 libpurple/request.h |  19 ++++++++++++++-----
 pidgin/gtkconv.c    |  13 +++++++------
 pidgin/gtkdialogs.c |  11 +++++++++--
 4 files changed, 51 insertions(+), 29 deletions(-)

diffs (218 lines):

diff --git a/libpurple/request.c b/libpurple/request.c
--- a/libpurple/request.c
+++ b/libpurple/request.c
@@ -209,7 +209,7 @@ purple_request_fields_add_group(PurpleRe
 				g_list_append(fields->required_fields, field);
 		}
 
-		if (purple_request_field_is_validated(field)) {
+		if (purple_request_field_is_validatable(field)) {
 			fields->validated_fields =
 				g_list_append(fields->validated_fields, field);
 		}
@@ -234,7 +234,7 @@ purple_request_fields_exists(const Purpl
 	return (g_hash_table_lookup(fields->fields, id) != NULL);
 }
 
-GList *
+const GList *
 purple_request_fields_get_required(const PurpleRequestFields *fields)
 {
 	g_return_val_if_fail(fields != NULL, NULL);
@@ -242,8 +242,8 @@ purple_request_fields_get_required(const
 	return fields->required_fields;
 }
 
-GList *
-purple_request_fields_get_validated(const PurpleRequestFields *fields)
+const GList *
+purple_request_fields_get_validatable(const PurpleRequestFields *fields)
 {
 	g_return_val_if_fail(fields != NULL, NULL);
 
@@ -311,7 +311,7 @@ purple_request_fields_all_valid(const Pu
 	{
 		PurpleRequestField *field = (PurpleRequestField *)l->data;
 
-		if (!purple_request_field_is_valid(field))
+		if (!purple_request_field_is_valid(field, NULL))
 			return FALSE;
 	}
 
@@ -464,7 +464,7 @@ purple_request_field_group_add_field(Pur
 				g_list_append(group->fields_list->required_fields, field);
 		}
 		
-		if (purple_request_field_is_validated(field))
+		if (purple_request_field_is_validatable(field))
 		{
 			group->fields_list->validated_fields =
 				g_list_append(group->fields_list->validated_fields, field);
@@ -716,21 +716,19 @@ purple_request_field_set_validator(Purpl
 
 	if (field->group != NULL)
 	{
+		PurpleRequestFields *flist = field->group->fields_list;
+		flist->validated_fields = g_list_remove(flist->validated_fields,
+			field);
 		if (validator)
 		{
-			field->group->fields_list->validated_fields = g_list_append(
-				field->group->fields_list->validated_fields, field);
-		}
-		else
-		{
-			field->group->fields_list->validated_fields = g_list_remove(
-				field->group->fields_list->validated_fields, field);
+			flist->validated_fields = g_list_append(
+				flist->validated_fields, field);
 		}
 	}
 }
 
 gboolean
-purple_request_field_is_validated(PurpleRequestField *field)
+purple_request_field_is_validatable(PurpleRequestField *field)
 {
 	g_return_val_if_fail(field != NULL, FALSE);
 
@@ -738,8 +736,10 @@ purple_request_field_is_validated(Purple
 }
 
 gboolean
-purple_request_field_is_valid(PurpleRequestField *field)
+purple_request_field_is_valid(PurpleRequestField *field, gchar **errmsg)
 {
+	gboolean valid;
+
 	g_return_val_if_fail(field != NULL, FALSE);
 
 	if (!field->validator)
@@ -749,7 +749,12 @@ purple_request_field_is_valid(PurpleRequ
 		!purple_request_field_is_filled(field))
 		return TRUE;
 
-	return field->validator(field, field->validator_data);
+	valid = field->validator(field, errmsg, field->validator_data);
+
+	if (valid && errmsg)
+		*errmsg = NULL;
+
+	return valid;
 }
 
 PurpleRequestField *
diff --git a/libpurple/request.h b/libpurple/request.h
--- a/libpurple/request.h
+++ b/libpurple/request.h
@@ -150,7 +150,8 @@ typedef struct
 
 typedef void (*PurpleRequestInputCb)(void *, const char *);
 
-typedef gboolean (*PurpleRequestFieldValidator)(PurpleRequestField *field, void *user_data);
+typedef gboolean (*PurpleRequestFieldValidator)(PurpleRequestField *field,
+	gchar **errmsg, void *user_data);
 
 /** The type of callbacks passed to purple_request_action().  The first
  *  argument is the @a user_data parameter; the second is the index in the list
@@ -218,7 +219,8 @@ gboolean purple_request_fields_exists(co
  *
  * @constreturn The list of required fields.
  */
-GList *purple_request_fields_get_required(const PurpleRequestFields *fields);
+const GList *purple_request_fields_get_required(
+	const PurpleRequestFields *fields);
 
 /**
  * Returns a list of all validated fields.
@@ -227,7 +229,8 @@ GList *purple_request_fields_get_require
  *
  * @constreturn The list of validated fields.
  */
-GList *purple_request_fields_get_validated(const PurpleRequestFields *fields);
+const GList *purple_request_fields_get_validatable(
+	const PurpleRequestFields *fields);
 
 /**
  * Returns whether or not a field with the specified ID is required.
@@ -579,18 +582,24 @@ void purple_request_field_set_validator(
  *
  * @return TRUE if the field has validator, or FALSE.
  */
-gboolean purple_request_field_is_validated(PurpleRequestField *field);
+gboolean purple_request_field_is_validatable(PurpleRequestField *field);
 
 /**
  * Checks, if specified field is valid.
  *
+ * If detailed message about failure reason is needed, there is an option to
+ * return (via errmsg argument) pointer to newly allocated error message.
+ * It must be freed with g_free after use.
+ *
  * Note: empty, not required fields are valid.
  *
  * @param field The field.
+ * @param errmsg If non-NULL, the memory area, where the pointer to validation
+ *        failure message will be set.
  *
  * @return TRUE, if the field is valid, FALSE otherwise.
  */
-gboolean purple_request_field_is_valid(PurpleRequestField *field);
+gboolean purple_request_field_is_valid(PurpleRequestField *field, gchar **errmsg);
 
 /**
  * Returns the ui_data for a field.
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -5791,12 +5791,13 @@ private_gtkconv_new(PurpleConversation *
 
 	g_signal_connect(G_OBJECT(pane), "button_press_event",
 	                 G_CALLBACK(ignore_middle_click), NULL);
-	g_signal_connect(G_OBJECT(pane), "drag_data_received",
-	                 G_CALLBACK(conv_dnd_recv), gtkconv);
-	g_signal_connect(G_OBJECT(gtkconv->webview), "drag_data_received",
-	                 G_CALLBACK(conv_dnd_recv), gtkconv);
-	g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received",
-	                 G_CALLBACK(conv_dnd_recv), gtkconv);
+// TODO: this crashes with webkit, fix it
+//	g_signal_connect(G_OBJECT(pane), "drag_data_received",
+//	                 G_CALLBACK(conv_dnd_recv), gtkconv);
+//	g_signal_connect(G_OBJECT(gtkconv->webview), "drag_data_received",
+//	                 G_CALLBACK(conv_dnd_recv), gtkconv);
+//	g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received",
+//	                 G_CALLBACK(conv_dnd_recv), gtkconv);
 
 	g_signal_connect(gtkconv->webview, "style-set", G_CALLBACK(set_typing_font), gtkconv);
 
diff --git a/pidgin/gtkdialogs.c b/pidgin/gtkdialogs.c
--- a/pidgin/gtkdialogs.c
+++ b/pidgin/gtkdialogs.c
@@ -880,18 +880,25 @@ pidgin_dialogs_im_cb(gpointer data, Purp
 }
 
 static gboolean
-pidgin_dialogs_im_name_validator(PurpleRequestField *field, void *_fields)
+pidgin_dialogs_im_name_validator(PurpleRequestField *field, gchar **errmsg,
+	void *_fields)
 {
 	PurpleRequestFields *fields = _fields;
 	PurpleAccount *account;
 	PurplePlugin *prpl;
 	const char *username;
+	gboolean valid;
 
 	account = purple_request_fields_get_account(fields, "account");
 	prpl = purple_find_prpl(purple_account_get_protocol_id(account));
 	username = purple_request_fields_get_string(fields, "screenname");
 
-	return purple_validate(prpl, username);
+	valid = purple_validate(prpl, username);
+
+	if (errmsg && !valid)
+		*errmsg = g_strdup(_("Invalid username"));
+
+	return valid;
 }
 
 void



More information about the Commits mailing list