/soc/2013/ankitkv/gobjectification: e31ee6f00ff8: Merged default...

Ankit Vani a at nevitus.org
Tue Sep 17 12:52:51 EDT 2013


Changeset: e31ee6f00ff826d18368dfc287ab264cb09e20f1
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-09-17 22:22 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/e31ee6f00ff8

Description:

Merged default branch

diffstat:

 finch/gntrequest.c                 |    3 +-
 libpurple/protocols/gg/gg.c        |    8 ++
 libpurple/protocols/gg/tcpsocket.c |    8 +-
 libpurple/request.c                |  122 ++++++++++++++++++++++++++++++++++++-
 libpurple/request.h                |   64 ++++++++++++++++++-
 pidgin/gtkrequest.c                |   55 ++++++++++++++--
 6 files changed, 245 insertions(+), 15 deletions(-)

diffs (truncated from 503 to 300 lines):

diff --git a/finch/gntrequest.c b/finch/gntrequest.c
--- a/finch/gntrequest.c
+++ b/finch/gntrequest.c
@@ -814,10 +814,11 @@ static PurpleRequestUiOps uiops =
 	finch_request_input,
 	finch_request_choice,
 	finch_request_action,
+	NULL,
 	finch_request_fields,
 	finch_request_file,
+	finch_request_folder,
 	finch_close_request,
-	finch_request_folder,
 	NULL,
 	NULL,
 	NULL,
diff --git a/libpurple/protocols/gg/gg.c b/libpurple/protocols/gg/gg.c
--- a/libpurple/protocols/gg/gg.c
+++ b/libpurple/protocols/gg/gg.c
@@ -414,6 +414,9 @@ void ggp_async_login_handler(gpointer _g
 			info->session->check, info->session->state);
 
 	switch (info->session->state) {
+		case GG_STATE_ERROR:
+			purple_debug_info("gg", "GG_STATE_ERROR\n");
+			break;
 		case GG_STATE_RESOLVING:
 			purple_debug_info("gg", "GG_STATE_RESOLVING\n");
 			break;
@@ -550,6 +553,11 @@ void ggp_async_login_handler(gpointer _g
 						_("Error connecting to master "
 						"server"));
 					break;
+				case GG_FAILURE_INTERNAL:
+					purple_connection_error(gc,
+						PURPLE_CONNECTION_ERROR_OTHER_ERROR,
+						_("Internal error"));
+					break;
 				default:
 					purple_connection_error(gc,
 						PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
diff --git a/libpurple/protocols/gg/tcpsocket.c b/libpurple/protocols/gg/tcpsocket.c
--- a/libpurple/protocols/gg/tcpsocket.c
+++ b/libpurple/protocols/gg/tcpsocket.c
@@ -20,13 +20,15 @@ ggp_tcpsocket_connected(PurpleSocket *ps
 	if (!gg_socket_manager_connected(ps, priv_gg, fd)) {
 		purple_debug_error("gg", "socket not handled");
 		purple_socket_destroy(ps);
-		return;
 	}
 
 	if (info->inpa > 0)
 		purple_input_remove(info->inpa);
-	info->inpa = purple_input_add(fd, ggp_tcpsocket_inputcond_gg_to_purple(
-		info->session->check), ggp_async_login_handler, gc);
+	if (info->session->fd < 0)
+		return;
+	info->inpa = purple_input_add(info->session->fd,
+		ggp_tcpsocket_inputcond_gg_to_purple(info->session->check),
+		ggp_async_login_handler, gc);
 }
 
 static void*
diff --git a/libpurple/request.c b/libpurple/request.c
--- a/libpurple/request.c
+++ b/libpurple/request.c
@@ -173,6 +173,8 @@ struct _PurpleRequestCommonParameters
 
 	PurpleRequestHelpCb help_cb;
 	gpointer help_data;
+
+	GSList *extra_actions;
 };
 
 PurpleRequestCommonParameters *
@@ -236,6 +238,7 @@ purple_request_cpar_unref(PurpleRequestC
 	if (--cpar->ref_count > 0)
 		return cpar;
 
+	purple_request_cpar_set_extra_actions(cpar, NULL);
 	g_free(cpar);
 	return NULL;
 }
@@ -289,7 +292,7 @@ PurpleRequestIconType
 purple_request_cpar_get_icon(PurpleRequestCommonParameters *cpar)
 {
 	if (cpar == NULL)
-		return PURPLE_REQUEST_ICON_REQUEST;
+		return PURPLE_REQUEST_ICON_DEFAULT;
 
 	return cpar->icon_type;
 }
@@ -378,6 +381,49 @@ purple_request_cpar_get_help_cb(PurpleRe
 	return cpar->help_cb;
 }
 
+void
+purple_request_cpar_set_extra_actions(PurpleRequestCommonParameters *cpar, ...)
+{
+	va_list args;
+	GSList *extra = NULL, *it;
+
+	it = cpar->extra_actions;
+	while (it != NULL) {
+		gchar *label = it->data;
+
+		g_free(label);
+		it = g_slist_next(it);
+		if (it == NULL)
+			break;
+		it = g_slist_next(it);
+	}
+
+	va_start(args, cpar);
+
+	while (TRUE) {
+		const gchar *label;
+		PurpleRequestFieldsCb cb;
+
+		label = va_arg(args, const gchar*);
+		if (label == NULL)
+			break;
+		cb = va_arg(args, PurpleRequestFieldsCb);
+
+		extra = g_slist_append(extra, g_strdup(label));
+		extra = g_slist_append(extra, cb);
+	}
+
+	va_end(args);
+
+	cpar->extra_actions = extra;
+}
+
+GSList *
+purple_request_cpar_get_extra_actions(PurpleRequestCommonParameters *cpar)
+{
+	return cpar->extra_actions;
+}
+
 PurpleRequestFields *
 purple_request_fields_new(void)
 {
@@ -2011,6 +2057,74 @@ purple_request_action_varg(void *handle,
 }
 
 void *
+purple_request_wait(void *handle, const char *title, const char *primary,
+	const char *secondary, GCallback cancel_cb,
+	PurpleRequestCommonParameters *cpar, void *user_data)
+{
+	PurpleRequestUiOps *ops;
+
+	if (title == NULL)
+		title = _("Please wait");
+	if (primary == NULL)
+		primary = _("Please wait...");
+
+	ops = purple_request_get_ui_ops();
+
+	if (ops != NULL && ops->request_wait != NULL) {
+		PurpleRequestInfo *info;
+		gchar **tmp;
+
+		tmp = purple_request_strip_html(cpar, &primary, &secondary);
+
+		info            = g_new0(PurpleRequestInfo, 1);
+		info->type      = PURPLE_REQUEST_WAIT;
+		info->handle    = handle;
+		info->ui_handle = ops->request_wait(title, primary, secondary,
+			cancel_cb, cpar, user_data);
+
+		handles = g_list_append(handles, info);
+
+		g_strfreev(tmp);
+		purple_request_cpar_unref(cpar);
+		return info->ui_handle;
+	}
+
+	if (cpar == NULL)
+		cpar = purple_request_cpar_new();
+	if (purple_request_cpar_get_icon(cpar) == PURPLE_REQUEST_ICON_DEFAULT)
+		purple_request_cpar_set_icon(cpar, PURPLE_REQUEST_ICON_WAIT);
+
+	return purple_request_action(handle, title, primary, secondary,
+		PURPLE_DEFAULT_ACTION_NONE, cpar, user_data,
+		cancel_cb ? 1 : 0, _("Cancel"), cancel_cb);
+}
+
+static void
+purple_request_fields_strip_html(PurpleRequestFields *fields)
+{
+	GList *itg;
+
+	for (itg = fields->groups; itg != NULL; itg = g_list_next(itg)) {
+		PurpleRequestFieldGroup *group = itg->data;
+		GList *itf;
+
+		for (itf = group->fields; itf != NULL; itf = g_list_next(itf)) {
+			PurpleRequestField *field = itf->data;
+			gchar *new_label;
+
+			new_label = purple_request_strip_html_custom(
+				field->label);
+			if (g_strcmp0(new_label, field->label) == 0) {
+				g_free(new_label);
+				continue;
+			}
+			g_free(field->label);
+			field->label = new_label;
+		}
+	}
+}
+
+void *
 purple_request_fields(void *handle, const char *title, const char *primary,
 	const char *secondary, PurpleRequestFields *fields, const char *ok_text,
 	GCallback ok_cb, const char *cancel_text, GCallback cancel_cb,
@@ -2031,6 +2145,12 @@ purple_request_fields(void *handle, cons
 
 	ops = purple_request_get_ui_ops();
 
+	if (purple_request_cpar_is_html(cpar) &&
+		!((ops->features & PURPLE_REQUEST_FEATURE_HTML)))
+	{
+		purple_request_fields_strip_html(fields);
+	}
+
 	if (ops != NULL && ops->request_fields != NULL) {
 		PurpleRequestInfo *info;
 		gchar **tmp;
diff --git a/libpurple/request.h b/libpurple/request.h
--- a/libpurple/request.h
+++ b/libpurple/request.h
@@ -64,6 +64,7 @@ typedef enum
 	PURPLE_REQUEST_INPUT = 0,  /**< Text input request.        */
 	PURPLE_REQUEST_CHOICE,     /**< Multiple-choice request.   */
 	PURPLE_REQUEST_ACTION,     /**< Action request.            */
+	PURPLE_REQUEST_WAIT,       /**< Please wait dialog.        */
 	PURPLE_REQUEST_FIELDS,     /**< Multiple fields request.   */
 	PURPLE_REQUEST_FILE,       /**< File open or save request. */
 	PURPLE_REQUEST_FOLDER      /**< Folder selection request.  */
@@ -95,8 +96,10 @@ typedef enum
 
 typedef enum
 {
-	PURPLE_REQUEST_ICON_REQUEST = 0,
+	PURPLE_REQUEST_ICON_DEFAULT = 0,
+	PURPLE_REQUEST_ICON_REQUEST,
 	PURPLE_REQUEST_ICON_DIALOG,
+	PURPLE_REQUEST_ICON_WAIT,
 	PURPLE_REQUEST_ICON_INFO,
 	PURPLE_REQUEST_ICON_WARNING,
 	PURPLE_REQUEST_ICON_ERROR
@@ -130,6 +133,11 @@ typedef struct
 		PurpleRequestCommonParameters *cpar, void *user_data,
 		size_t action_count, va_list actions);
 
+	/** @see purple_request_wait(). */
+	void *(*request_wait)(const char *title, const char *primary,
+		const char *secondary, GCallback cancel_cb,
+		PurpleRequestCommonParameters *cpar, void *user_data);
+
 	/** @see purple_request_fields(). */
 	void *(*request_fields)(const char *title, const char *primary,
 		const char *secondary, PurpleRequestFields *fields,
@@ -142,13 +150,13 @@ typedef struct
 		gboolean savedialog, GCallback ok_cb, GCallback cancel_cb,
 		PurpleRequestCommonParameters *cpar, void *user_data);
 
-	void (*close_request)(PurpleRequestType type, void *ui_handle);
-
 	/** @see purple_request_folder(). */
 	void *(*request_folder)(const char *title, const char *dirname,
 		GCallback ok_cb, GCallback cancel_cb,
 		PurpleRequestCommonParameters *cpar, void *user_data);
 
+	void (*close_request)(PurpleRequestType type, void *ui_handle);
+
 	void (*_purple_reserved1)(void);
 	void (*_purple_reserved2)(void);
 	void (*_purple_reserved3)(void);
@@ -374,11 +382,37 @@ purple_request_cpar_set_help_cb(PurpleRe
  * @param cpar      The parameters set (may be @c NULL).
  * @param user_data The pointer to the variable, where user data (to be passed
  *                  to callback function) should be stored.
+ *
+ * @return The callback.
  */
 PurpleRequestHelpCb
 purple_request_cpar_get_help_cb(PurpleRequestCommonParameters *cpar,
 	gpointer *user_data);
 
+/**
+ * Sets extra actions for the PurpleRequestFields dialog.
+ *
+ * @param cpar The parameters set.
+ * @param ...  A list of actions. These are pairs of arguments. The first of
+ *             each pair is the <tt>char *</tt> label that appears on the
+ *             button. It should have an underscore before the letter you want
+ *             to use as the accelerator key for the button. The second of each



More information about the Commits mailing list