/pidgin/main: b92698241603: Request API refactoring: switch purp...

Tomasz Wasilczyk twasilczyk at pidgin.im
Tue Sep 10 17:04:30 EDT 2013


Changeset: b92698241603e3b028af422cdd3e872519d79cc4
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2013-09-10 23:04 +0200
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/b92698241603

Description:

Request API refactoring: switch purple_request_file to PurpleRequestCommonParameters

diffstat:

 finch/gntcertmgr.c                       |   5 +-
 finch/gntplugin.c                        |   2 +-
 finch/gntrequest.c                       |   8 +--
 libpurple/ft.c                           |  10 ++--
 libpurple/plugins/perl/common/Request.xs |   2 +-
 libpurple/protocols/gg/gg.c              |  11 ++----
 libpurple/protocols/sametime/sametime.c  |   4 +-
 libpurple/protocols/silc/buddy.c         |   2 +-
 libpurple/protocols/silc/chat.c          |   2 +-
 libpurple/request.c                      |  12 +++---
 libpurple/request.h                      |  56 +++++++++++++------------------
 pidgin/gtkcertmgr.c                      |   4 +-
 pidgin/gtkconv.c                         |  11 ++----
 pidgin/gtkdebug.c                        |   4 +-
 pidgin/gtkpounce.c                       |   4 +-
 pidgin/gtkprefs.c                        |   5 +-
 pidgin/gtkrequest.c                      |   6 +--
 pidgin/gtkutils.c                        |   6 +-
 18 files changed, 64 insertions(+), 90 deletions(-)

diffs (truncated from 404 to 300 lines):

diff --git a/finch/gntcertmgr.c b/finch/gntcertmgr.c
--- a/finch/gntcertmgr.c
+++ b/finch/gntcertmgr.c
@@ -111,7 +111,7 @@ add_cert_cb(GntWidget *button, gpointer 
 			FALSE,
 			G_CALLBACK(tls_peers_mgmt_import_ok_cb),
 			NULL,
-			NULL, NULL, NULL, NULL );
+			NULL, NULL );
 }
 
 /* Save certs in some file */
@@ -159,8 +159,7 @@ save_cert_cb(GntWidget *button, gpointer
 			"certificate.pem", TRUE,
 			G_CALLBACK(tls_peers_mgmt_export_ok_cb),
 			G_CALLBACK(purple_certificate_destroy),
-			NULL, NULL, NULL,
-			crt);
+			NULL, crt);
 }
 
 /* Show information about a cert */
diff --git a/finch/gntplugin.c b/finch/gntplugin.c
--- a/finch/gntplugin.c
+++ b/finch/gntplugin.c
@@ -332,7 +332,7 @@ install_plugin_cb(GntWidget *w, gpointer
 	purple_request_close_with_handle(&handle);
 	purple_request_file(&handle, _("Select plugin to install"), NULL,
 			FALSE, G_CALLBACK(install_selected_file_cb), NULL,
-			NULL, NULL, NULL, &handle);
+			NULL, &handle);
 	g_signal_connect_swapped(G_OBJECT(w), "destroy", G_CALLBACK(purple_request_close_with_handle), &handle);
 }
 
diff --git a/finch/gntrequest.c b/finch/gntrequest.c
--- a/finch/gntrequest.c
+++ b/finch/gntrequest.c
@@ -768,11 +768,9 @@ finch_file_request_window(const char *ti
 }
 
 static void *
-finch_request_file(const char *title, const char *filename,
-				gboolean savedialog,
-				GCallback ok_cb, GCallback cancel_cb,
-				PurpleAccount *account, const char *who, PurpleConversation *conv,
-				void *user_data)
+finch_request_file(const char *title, const char *filename, gboolean savedialog,
+	GCallback ok_cb, GCallback cancel_cb,
+	PurpleRequestCommonParameters *cpar, void *user_data)
 {
 	FinchFileRequest *data;
 	const char *path;
diff --git a/libpurple/ft.c b/libpurple/ft.c
--- a/libpurple/ft.c
+++ b/libpurple/ft.c
@@ -468,11 +468,11 @@ static int
 purple_xfer_choose_file(PurpleXfer *xfer)
 {
 	purple_request_file(xfer, NULL, purple_xfer_get_filename(xfer),
-					  (purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE),
-					  G_CALLBACK(purple_xfer_choose_file_ok_cb),
-					  G_CALLBACK(purple_xfer_choose_file_cancel_cb),
-					  purple_xfer_get_account(xfer), xfer->who, NULL,
-					  xfer);
+		(purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE),
+		G_CALLBACK(purple_xfer_choose_file_ok_cb),
+		G_CALLBACK(purple_xfer_choose_file_cancel_cb),
+		purple_request_cpar_from_account(purple_xfer_get_account(xfer)),
+		xfer);
 
 	return 0;
 }
diff --git a/libpurple/plugins/perl/common/Request.xs b/libpurple/plugins/perl/common/Request.xs
--- a/libpurple/plugins/perl/common/Request.xs
+++ b/libpurple/plugins/perl/common/Request.xs
@@ -167,7 +167,7 @@ CODE:
 	gpr->cancel_fun = purple_perl_sv_from_fun(handle, cancel_cb);
 	g_free(basename);
 
-	RETVAL = purple_request_file(handle, title, filename, savedialog, G_CALLBACK(purple_perl_request_ok_cb), G_CALLBACK(purple_perl_request_cancel_cb), NULL, NULL, NULL, gpr);
+	RETVAL = purple_request_file(handle, title, filename, savedialog, G_CALLBACK(purple_perl_request_ok_cb), G_CALLBACK(purple_perl_request_cancel_cb), NULL, gpr);
 OUTPUT:
 	RETVAL
 
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
@@ -152,9 +152,8 @@ static void ggp_action_buddylist_save(Pu
 	PurpleConnection *gc = (PurpleConnection *)action->context;
 
 	purple_request_file(action, _("Save buddylist..."), NULL, TRUE,
-			G_CALLBACK(ggp_callback_buddylist_save_ok), NULL,
-			purple_connection_get_account(gc), NULL, NULL,
-			gc);
+		G_CALLBACK(ggp_callback_buddylist_save_ok), NULL,
+		purple_request_cpar_from_connection(gc), gc);
 }
 
 static void ggp_action_buddylist_load(PurplePluginAction *action)
@@ -162,10 +161,8 @@ static void ggp_action_buddylist_load(Pu
 	PurpleConnection *gc = (PurpleConnection *)action->context;
 
 	purple_request_file(action, _("Load buddylist from file..."), NULL,
-			FALSE,
-			G_CALLBACK(ggp_callback_buddylist_load_ok), NULL,
-			purple_connection_get_account(gc), NULL, NULL,
-			gc);
+		FALSE, G_CALLBACK(ggp_callback_buddylist_load_ok), NULL,
+		purple_request_cpar_from_connection(gc), gc);
 }
 
 /* ----- CONFERENCES ---------------------------------------------------- */
diff --git a/libpurple/protocols/sametime/sametime.c b/libpurple/protocols/sametime/sametime.c
--- a/libpurple/protocols/sametime/sametime.c
+++ b/libpurple/protocols/sametime/sametime.c
@@ -5235,7 +5235,7 @@ static void st_import_action(PurplePlugi
 
   purple_request_file(gc, title, NULL, FALSE,
 		    G_CALLBACK(st_import_action_cb), NULL,
-		    account, NULL, NULL,
+		    purple_request_cpar_from_connection(gc),
 		    gc);
 
   g_free(title);
@@ -5275,7 +5275,7 @@ static void st_export_action(PurplePlugi
 
   purple_request_file(gc, title, NULL, TRUE,
 		    G_CALLBACK(st_export_action_cb), NULL,
-			account, NULL, NULL,
+		    purple_request_cpar_from_connection(gc),
 		    gc);
 
   g_free(title);
diff --git a/libpurple/protocols/silc/buddy.c b/libpurple/protocols/silc/buddy.c
--- a/libpurple/protocols/silc/buddy.c
+++ b/libpurple/protocols/silc/buddy.c
@@ -1067,7 +1067,7 @@ silcpurple_add_buddy_ask_pk_cb(SilcPurpl
 	purple_request_file(r->client->application, _("Open..."), NULL, FALSE,
 			    G_CALLBACK(silcpurple_add_buddy_ask_import),
 			    G_CALLBACK(silcpurple_add_buddy_ask_pk_cancel),
-			    purple_buddy_get_account(r->b), purple_buddy_get_name(r->b), NULL, r);
+			    purple_request_cpar_from_account(purple_buddy_get_account(r->b)), r);
 
 }
 
diff --git a/libpurple/protocols/silc/chat.c b/libpurple/protocols/silc/chat.c
--- a/libpurple/protocols/silc/chat.c
+++ b/libpurple/protocols/silc/chat.c
@@ -308,7 +308,7 @@ silcpurple_chat_chpk_cb(SilcPurpleChauth
 		purple_request_file(sg->gc, _("Open Public Key..."), NULL, FALSE,
 				    G_CALLBACK(silcpurple_chat_chpk_add),
 				    G_CALLBACK(silcpurple_chat_chpk_cancel),
-				    purple_connection_get_account(sg->gc), NULL, NULL, sgc);
+				    purple_request_cpar_from_connection(sg->gc), sgc);
 		return;
 	}
 
diff --git a/libpurple/request.c b/libpurple/request.c
--- a/libpurple/request.c
+++ b/libpurple/request.c
@@ -1897,10 +1897,8 @@ purple_request_fields(void *handle, cons
 
 void *
 purple_request_file(void *handle, const char *title, const char *filename,
-				  gboolean savedialog,
-				  GCallback ok_cb, GCallback cancel_cb,
-				  PurpleAccount *account, const char *who, PurpleConversation *conv,
-				  void *user_data)
+	gboolean savedialog, GCallback ok_cb, GCallback cancel_cb,
+	PurpleRequestCommonParameters *cpar, void *user_data)
 {
 	PurpleRequestUiOps *ops;
 
@@ -1913,12 +1911,14 @@ purple_request_file(void *handle, const 
 		info->type      = PURPLE_REQUEST_FILE;
 		info->handle    = handle;
 		info->ui_handle = ops->request_file(title, filename, savedialog,
-											ok_cb, cancel_cb,
-											account, who, conv, user_data);
+			ok_cb, cancel_cb, cpar, user_data);
 		handles = g_list_append(handles, info);
+
+		purple_request_cpar_unref(cpar);
 		return info->ui_handle;
 	}
 
+	purple_request_cpar_unref(cpar);
 	return NULL;
 }
 
diff --git a/libpurple/request.h b/libpurple/request.h
--- a/libpurple/request.h
+++ b/libpurple/request.h
@@ -95,42 +95,36 @@ typedef struct
 {
 	/** @see purple_request_input(). */
 	void *(*request_input)(const char *title, const char *primary,
-	                       const char *secondary, const char *default_value,
-	                       gboolean multiline, gboolean masked, gchar *hint,
-	                       const char *ok_text, GCallback ok_cb,
-	                       const char *cancel_text, GCallback cancel_cb,
-	                       PurpleRequestCommonParameters *cpar,
-	                       void *user_data);
+		const char *secondary, const char *default_value,
+		gboolean multiline, gboolean masked, gchar *hint,
+		const char *ok_text, GCallback ok_cb,
+		const char *cancel_text, GCallback cancel_cb,
+		PurpleRequestCommonParameters *cpar, void *user_data);
 
 	/** @see purple_request_choice_varg(). */
 	void *(*request_choice)(const char *title, const char *primary,
-	                        const char *secondary, int default_value,
-	                        const char *ok_text, GCallback ok_cb,
-	                        const char *cancel_text, GCallback cancel_cb,
-	                        PurpleRequestCommonParameters *cpar,
-	                        void *user_data, va_list choices);
+		const char *secondary, int default_value, const char *ok_text,
+		GCallback ok_cb, const char *cancel_text, GCallback cancel_cb,
+		PurpleRequestCommonParameters *cpar, void *user_data,
+		va_list choices);
 
 	/** @see purple_request_action_varg(). */
 	void *(*request_action)(const char *title, const char *primary,
-	                        const char *secondary, int default_action,
-	                        PurpleRequestCommonParameters *cpar,
-	                        void *user_data, size_t action_count,
-	                        va_list actions);
+		const char *secondary, int default_action,
+		PurpleRequestCommonParameters *cpar, void *user_data,
+		size_t action_count, va_list actions);
 
 	/** @see purple_request_fields(). */
 	void *(*request_fields)(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,
-	                        PurpleRequestCommonParameters *cpar,
-	                        void *user_data);
+		const char *secondary, PurpleRequestFields *fields,
+		const char *ok_text, GCallback ok_cb,
+		const char *cancel_text, GCallback cancel_cb,
+		PurpleRequestCommonParameters *cpar, void *user_data);
 
 	/** @see purple_request_file(). */
 	void *(*request_file)(const char *title, const char *filename,
-	                      gboolean savedialog, GCallback ok_cb,
-	                      GCallback cancel_cb, PurpleAccount *account,
-	                      const char *who, PurpleConversation *conv,
-	                      void *user_data);
+		gboolean savedialog, GCallback ok_cb, GCallback cancel_cb,
+		PurpleRequestCommonParameters *cpar, void *user_data);
 
 	void (*close_request)(PurpleRequestType type, void *ui_handle);
 
@@ -1700,20 +1694,16 @@ void purple_request_close_with_handle(vo
  *                    False if it is being used to open a file.
  * @param ok_cb       The callback for the @c OK button.
  * @param cancel_cb   The callback for the @c Cancel button, which may be @c NULL.
- * @param account     The #PurpleAccount associated with this request, or @c
- *                    NULL if none is
- * @param who         The username of the buddy associated with this request,
- *                    or @c NULL if none is
- * @param conv        The #PurpleConversation associated with this request, or
- *                    @c NULL if none is
+ * @param cpar        The #PurpleRequestCommonParameters object, which gets
+ *                    unref'ed after this call.
  * @param user_data   The data to pass to the callback.
  *
  * @return A UI-specific handle.
  */
-void *purple_request_file(void *handle, const char *title, const char *filename,
+void *
+purple_request_file(void *handle, const char *title, const char *filename,
 	gboolean savedialog, GCallback ok_cb, GCallback cancel_cb,
-	PurpleAccount *account, const char *who, PurpleConversation *conv,
-	void *user_data);
+	PurpleRequestCommonParameters *cpar, void *user_data);
 
 /**
  * Displays a folder select dialog. Returns the selected filename to
diff --git a/pidgin/gtkcertmgr.c b/pidgin/gtkcertmgr.c
--- a/pidgin/gtkcertmgr.c
+++ b/pidgin/gtkcertmgr.c
@@ -224,7 +224,7 @@ tls_peers_mgmt_import_cb(GtkWidget *butt
 			    FALSE, /* Not a save dialog */
 			    G_CALLBACK(tls_peers_mgmt_import_ok_cb),
 			    NULL,  /* Do nothing if cancelled */
-			    NULL, NULL, NULL, NULL );/* No account,conv,etc. */
+			    NULL, NULL); /* No extra parameters */
 }
 
 static void
@@ -298,7 +298,7 @@ tls_peers_mgmt_export_cb(GtkWidget *butt
 			    TRUE, /* Is a save dialog */
 			    G_CALLBACK(tls_peers_mgmt_export_ok_cb),
 			    G_CALLBACK(tls_peers_mgmt_export_cancel_cb),
-			    NULL, NULL, NULL, /* No account,conv,etc. */
+			    NULL, /* No extra parameters */
 			    crt); /* Pass the certificate on to the callback */
 }



More information about the Commits mailing list