/pidgin/main: 35d5e8fcc07b: Request API refactoring: switch purp...
Tomasz Wasilczyk
twasilczyk at pidgin.im
Tue Sep 10 09:34:20 EDT 2013
Changeset: 35d5e8fcc07ba645e476247f78373d69af06e6a2
Author: Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date: 2013-09-10 15:34 +0200
Branch: default
URL: https://hg.pidgin.im/pidgin/main/rev/35d5e8fcc07b
Description:
Request API refactoring: switch purple_request_choice to PurpleRequestCommonParameters
diffstat:
finch/gntrequest.c | 2 +-
libpurple/plugins/autoaccept.c | 4 +---
libpurple/request.c | 28 +++++++++++++++-------------
libpurple/request.h | 17 ++++++-----------
pidgin/gtkrequest.c | 4 ++--
pidgin/gtkutils.c | 4 ++--
6 files changed, 27 insertions(+), 32 deletions(-)
diffs (191 lines):
diff --git a/finch/gntrequest.c b/finch/gntrequest.c
--- a/finch/gntrequest.c
+++ b/finch/gntrequest.c
@@ -213,7 +213,7 @@ finch_request_choice(const char *title,
const char *secondary, int default_value,
const char *ok_text, GCallback ok_cb,
const char *cancel_text, GCallback cancel_cb,
- PurpleAccount *account, const char *who, PurpleConversation *conv,
+ PurpleRequestCommonParameters *cpar,
void *user_data, va_list choices)
{
GntWidget *window, *combo, *box;
diff --git a/libpurple/plugins/autoaccept.c b/libpurple/plugins/autoaccept.c
--- a/libpurple/plugins/autoaccept.c
+++ b/libpurple/plugins/autoaccept.c
@@ -203,12 +203,10 @@ set_auto_accept_settings(PurpleBlistNode
NULL, purple_blist_node_get_int(node, "autoaccept"),
_("_Save"), G_CALLBACK(save_cb),
_("_Cancel"), NULL,
- NULL, NULL, NULL,
- node,
+ NULL, node,
_("Ask"), FT_ASK,
_("Auto Accept"), FT_ACCEPT,
_("Auto Reject"), FT_REJECT,
- NULL, purple_contact_get_alias((PurpleContact *)node), NULL,
NULL);
g_free(message);
}
diff --git a/libpurple/request.c b/libpurple/request.c
--- a/libpurple/request.c
+++ b/libpurple/request.c
@@ -1705,20 +1705,22 @@ purple_request_choice(void *handle, cons
const char *secondary, int default_value,
const char *ok_text, GCallback ok_cb,
const char *cancel_text, GCallback cancel_cb,
- PurpleAccount *account, const char *who, PurpleConversation *conv,
+ PurpleRequestCommonParameters *cpar,
void *user_data, ...)
{
void *ui_handle;
va_list args;
- g_return_val_if_fail(ok_text != NULL, NULL);
- g_return_val_if_fail(ok_cb != NULL, NULL);
+ if (G_UNLIKELY(ok_text != NULL || ok_cb != NULL)) {
+ purple_request_cpar_unref(cpar);
+ g_return_val_if_reached(NULL);
+ }
va_start(args, user_data);
ui_handle = purple_request_choice_varg(handle, title, primary, secondary,
default_value, ok_text, ok_cb,
cancel_text, cancel_cb,
- account, who, conv, user_data, args);
+ cpar, user_data, args);
va_end(args);
return ui_handle;
@@ -1730,14 +1732,15 @@ purple_request_choice_varg(void *handle,
int default_value,
const char *ok_text, GCallback ok_cb,
const char *cancel_text, GCallback cancel_cb,
- PurpleAccount *account, const char *who, PurpleConversation *conv,
+ PurpleRequestCommonParameters *cpar,
void *user_data, va_list choices)
{
PurpleRequestUiOps *ops;
- g_return_val_if_fail(ok_text != NULL, NULL);
- g_return_val_if_fail(ok_cb != NULL, NULL);
- g_return_val_if_fail(cancel_text != NULL, NULL);
+ if (G_UNLIKELY(ok_text != NULL || ok_cb != NULL || cancel_text != NULL)) {
+ purple_request_cpar_unref(cpar);
+ g_return_val_if_reached(NULL);
+ }
ops = purple_request_get_ui_ops();
@@ -1748,17 +1751,16 @@ purple_request_choice_varg(void *handle,
info->type = PURPLE_REQUEST_CHOICE;
info->handle = handle;
info->ui_handle = ops->request_choice(title, primary, secondary,
- default_value,
- ok_text, ok_cb,
- cancel_text, cancel_cb,
- account, who, conv,
- user_data, choices);
+ default_value, ok_text, ok_cb, cancel_text, cancel_cb,
+ cpar, user_data, choices);
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
@@ -107,9 +107,8 @@ typedef struct
const char *secondary, int default_value,
const char *ok_text, GCallback ok_cb,
const char *cancel_text, GCallback cancel_cb,
- PurpleAccount *account, const char *who,
- PurpleConversation *conv, void *user_data,
- va_list choices);
+ PurpleRequestCommonParameters *cpar,
+ void *user_data, va_list choices);
/** @see purple_request_action_varg(). */
void *(*request_action)(const char *title, const char *primary,
@@ -1513,12 +1512,8 @@ void *purple_request_input(void *handle,
* NULL.
* @param cancel_cb The callback for the @c Cancel button, or @c NULL to
* do nothing.
- * @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.
* @param ... The choices, which should be pairs of <tt>char *</tt>
* descriptions and <tt>int</tt> values, terminated with a
@@ -1530,7 +1525,7 @@ void *purple_request_choice(void *handle
const char *secondary, int default_value,
const char *ok_text, GCallback ok_cb,
const char *cancel_text, GCallback cancel_cb,
- PurpleAccount *account, const char *who, PurpleConversation *conv,
+ PurpleRequestCommonParameters *cpar,
void *user_data, ...) G_GNUC_NULL_TERMINATED;
/**
@@ -1540,7 +1535,7 @@ void *purple_request_choice_varg(void *h
const char *primary, const char *secondary, int default_value,
const char *ok_text, GCallback ok_cb,
const char *cancel_text, GCallback cancel_cb,
- PurpleAccount *account, const char *who, PurpleConversation *conv,
+ PurpleRequestCommonParameters *cpar,
void *user_data, va_list choices);
/**
diff --git a/pidgin/gtkrequest.c b/pidgin/gtkrequest.c
--- a/pidgin/gtkrequest.c
+++ b/pidgin/gtkrequest.c
@@ -471,7 +471,7 @@ pidgin_request_choice(const char *title,
const char *secondary, int default_value,
const char *ok_text, GCallback ok_cb,
const char *cancel_text, GCallback cancel_cb,
- PurpleAccount *account, const char *who, PurpleConversation *conv,
+ PurpleRequestCommonParameters *cpar,
void *user_data, va_list args)
{
PidginRequestData *data;
@@ -531,7 +531,7 @@ pidgin_request_choice(const char *title,
gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
- pidgin_widget_decorate_account(hbox, account);
+ pidgin_widget_decorate_account(hbox, purple_request_cpar_get_account(cpar));
/* Vertical box */
vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER);
diff --git a/pidgin/gtkutils.c b/pidgin/gtkutils.c
--- a/pidgin/gtkutils.c
+++ b/pidgin/gtkutils.c
@@ -1512,7 +1512,7 @@ pidgin_dnd_file_manage(GtkSelectionData
"embed it into this message, or use it as the buddy icon for this user."),
DND_FILE_TRANSFER, _("OK"), (GCallback)dnd_image_ok_callback,
_("Cancel"), (GCallback)dnd_image_cancel_callback,
- account, who, NULL,
+ purple_request_cpar_from_account(account),
data,
_("Set as buddy icon"), DND_BUDDY_ICON,
_("Send image file"), DND_FILE_TRANSFER,
@@ -1532,7 +1532,7 @@ pidgin_dnd_file_manage(GtkSelectionData
(ft ? DND_FILE_TRANSFER : DND_IM_IMAGE),
_("OK"), (GCallback)dnd_image_ok_callback,
_("Cancel"), (GCallback)dnd_image_cancel_callback,
- account, who, NULL,
+ purple_request_cpar_from_account(account),
data,
_("Set as buddy icon"), DND_BUDDY_ICON,
(ft ? _("Send image file") : _("Insert in message")), (ft ? DND_FILE_TRANSFER : DND_IM_IMAGE),
More information about the Commits
mailing list