pidgin/pidgin

Remove PurpleXfer UI data storage.

16 months ago, Elliott Sales de Andrade
263f9375fc8d
Parents e6692de3b4de
Children 7ba119b0f75c
Remove PurpleXfer UI data storage.

As a GObject, UIs can use g_object_[gs]et_data instead.
--- a/ChangeLog.API Sat Dec 21 21:51:21 2019 -0500
+++ b/ChangeLog.API Sun Dec 22 04:09:38 2019 -0500
@@ -473,6 +473,8 @@
* purple_util_get_image_checksum. Use
g_compute_checksum_for_data(G_CHECKSUM_SHA1, ...), instead.
* purple_uts35_to_str
+ * purple_xfer_get_ui_data and purple_xfer_set_ui_data. Use
+ GObject data functions instead.
* purple_xfer_update_progress
* PurpleCertificateVerificationStatus.PURPLE_CERTIFICATE_INVALID
* PurpleConnectionUiOps.report_disconnect_reason
--- a/finch/gntxfer.c Sat Dec 21 21:51:21 2019 -0500
+++ b/finch/gntxfer.c Sun Dec 22 04:09:38 2019 -0500
@@ -55,12 +55,12 @@
static PurpleGntXferDialog *xfer_dialog = NULL;
+#define UI_DATA "finch-ui-data"
typedef struct
{
gint64 last_updated_time;
gboolean in_list;
- char *name;
gboolean notified; /* Has the completion of the transfer been notified? */
} PurpleGntXferUiData;
@@ -256,7 +256,7 @@
for (iter = purple_xfers_get_all(); iter; iter = iter->next) {
PurpleXfer *xfer = (PurpleXfer *)iter->data;
- PurpleGntXferUiData *data = purple_xfer_get_ui_data(xfer);
+ PurpleGntXferUiData *data = g_object_get_data(G_OBJECT(xfer), UI_DATA);
if (data->in_list) {
finch_xfer_dialog_add_xfer(xfer);
finch_xfer_dialog_update_xfer(xfer);
@@ -296,7 +296,7 @@
g_object_ref(xfer);
- data = purple_xfer_get_ui_data(xfer);
+ data = g_object_get_data(G_OBJECT(xfer), UI_DATA);
data->in_list = TRUE;
finch_xfer_dialog_show();
@@ -334,7 +334,7 @@
g_return_if_fail(xfer_dialog != NULL);
g_return_if_fail(xfer != NULL);
- data = purple_xfer_get_ui_data(xfer);
+ data = g_object_get_data(G_OBJECT(xfer), UI_DATA);
if (data == NULL)
return;
@@ -364,7 +364,7 @@
g_return_if_fail(xfer_dialog != NULL);
g_return_if_fail(xfer != NULL);
- data = purple_xfer_get_ui_data(xfer);
+ data = g_object_get_data(G_OBJECT(xfer), UI_DATA);
if (data == NULL)
return;
@@ -414,11 +414,10 @@
g_return_if_fail(xfer_dialog != NULL);
g_return_if_fail(xfer != NULL);
- if ((data = purple_xfer_get_ui_data(xfer)) == NULL)
+ data = g_object_get_data(G_OBJECT(xfer), UI_DATA);
+ if (data == NULL || !data->in_list || data->notified) {
return;
-
- if (data->in_list == FALSE || data->notified)
- return;
+ }
current_time = g_get_monotonic_time();
if (((current_time - data->last_updated_time) < G_USEC_PER_SEC) &&
@@ -471,20 +470,7 @@
/* This is where we're setting xfer's "ui_data" for the first time. */
data = g_new0(PurpleGntXferUiData, 1);
- purple_xfer_set_ui_data(xfer, data);
-}
-
-static void
-finch_xfer_destroy(PurpleXfer *xfer)
-{
- PurpleGntXferUiData *data;
-
- data = purple_xfer_get_ui_data(xfer);
- if (data) {
- g_free(data->name);
- g_free(data);
- purple_xfer_set_ui_data(xfer, NULL);
- }
+ g_object_set_data_full(G_OBJECT(xfer), UI_DATA, data, g_free);
}
static void
@@ -525,7 +511,7 @@
static PurpleXferUiOps ops =
{
finch_xfer_new_xfer,
- finch_xfer_destroy,
+ NULL,
finch_xfer_add_xfer
};
--- a/libpurple/xfer.c Sat Dec 21 21:51:21 2019 -0500
+++ b/libpurple/xfer.c Sun Dec 22 04:09:38 2019 -0500
@@ -73,7 +73,6 @@
PurpleXferStatus status; /* File Transfer's status. */
- gpointer ui_data; /* UI-specific data */
PurpleXferUiOps *ui_ops; /* UI-specific operations. */
/*
@@ -116,7 +115,6 @@
PROP_END_TIME,
PROP_STATUS,
PROP_PROGRESS,
- PROP_UI_DATA,
PROP_LAST
};
@@ -1929,30 +1927,6 @@
g_signal_emit(xfer, signals[SIG_ADD_THUMBNAIL], 0, formats, NULL);
}
-void purple_xfer_set_ui_data(PurpleXfer *xfer, gpointer ui_data)
-{
- PurpleXferPrivate *priv = NULL;
-
- g_return_if_fail(PURPLE_IS_XFER(xfer));
-
- priv = purple_xfer_get_instance_private(xfer);
-
- priv->ui_data = ui_data;
-
- g_object_notify_by_pspec(G_OBJECT(xfer), properties[PROP_UI_DATA]);
-}
-
-gpointer purple_xfer_get_ui_data(PurpleXfer *xfer)
-{
- PurpleXferPrivate *priv = NULL;
-
- g_return_val_if_fail(PURPLE_IS_XFER(xfer), NULL);
-
- priv = purple_xfer_get_instance_private(xfer);
-
- return priv->ui_data;
-}
-
/**************************************************************************
* GObject code
**************************************************************************/
@@ -2000,9 +1974,6 @@
case PROP_STATUS:
purple_xfer_set_status(xfer, g_value_get_enum(value));
break;
- case PROP_UI_DATA:
- purple_xfer_set_ui_data(xfer, g_value_get_pointer(value));
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
break;
@@ -2067,9 +2038,6 @@
case PROP_PROGRESS:
g_value_set_double(value, purple_xfer_get_progress(xfer));
break;
- case PROP_UI_DATA:
- g_value_set_pointer(value, purple_xfer_get_ui_data(xfer));
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
break;
@@ -2249,10 +2217,6 @@
"The current progress of the file transfer.", -1.0, 1.0, -1.0,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
- properties[PROP_UI_DATA] = g_param_spec_pointer("ui-data", "UI Data",
- "The UI specific data for this xfer",
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
g_object_class_install_properties(obj_class, PROP_LAST, properties);
/* Signals */
--- a/libpurple/xfer.h Sat Dec 21 21:51:21 2019 -0500
+++ b/libpurple/xfer.h Sun Dec 22 04:09:38 2019 -0500
@@ -749,27 +749,6 @@
*/
void purple_xfer_prepare_thumbnail(PurpleXfer *xfer, const gchar *formats);
-/**
- * purple_xfer_set_ui_data:
- * @xfer: The file transfer.
- * @ui_data: A pointer to associate with this file transfer.
- *
- * Set the UI data associated with this file transfer.
- */
-void purple_xfer_set_ui_data(PurpleXfer *xfer, gpointer ui_data);
-
-/**
- * purple_xfer_get_ui_data:
- * @xfer: The file transfer.
- *
- * Get the UI data associated with this file transfer.
- *
- * Returns: The UI data associated with this file transfer. This is a
- * convenience field provided to the UIs--it is not
- * used by the libpurple core.
- */
-gpointer purple_xfer_get_ui_data(PurpleXfer *xfer);
-
/**************************************************************************/
/* File Transfer Subsystem API */
/**************************************************************************/
--- a/pidgin/gtkxfer.c Sat Dec 21 21:51:21 2019 -0500
+++ b/pidgin/gtkxfer.c Sun Dec 22 04:09:38 2019 -0500
@@ -46,8 +46,6 @@
GtkWidget *keep_open;
GtkWidget *auto_clear;
- gint num_transfers;
-
PurpleXfer *selected_xfer;
GtkWidget *tree;
@@ -78,14 +76,12 @@
G_DEFINE_TYPE(PidginXferDialog, pidgin_xfer_dialog, GTK_TYPE_DIALOG);
+#define UI_DATA "pidgin-ui-data"
typedef struct
{
GtkTreeIter iter;
gint64 last_updated_time;
gboolean in_list;
-
- char *name;
-
} PidginXferUiData;
static PidginXferDialog *xfer_dialog = NULL;
@@ -237,7 +233,7 @@
if (dialog == NULL || xfer == NULL)
return;
- data = purple_xfer_get_ui_data(xfer);
+ data = g_object_get_data(G_OBJECT(xfer), UI_DATA);
get_xfer_info_strings(xfer, &kbsec, &time_elapsed, &time_remaining);
@@ -695,7 +691,7 @@
g_object_ref(xfer);
- data = purple_xfer_get_ui_data(xfer);
+ data = g_object_get_data(G_OBJECT(xfer), UI_DATA);
data->in_list = TRUE;
pidgin_xfer_dialog_show(dialog);
@@ -729,8 +725,6 @@
g_free(size_str);
g_free(remaining_str);
- dialog->num_transfers++;
-
ensure_row_selected(dialog);
update_title_progress(dialog);
}
@@ -744,7 +738,7 @@
g_return_if_fail(dialog != NULL);
g_return_if_fail(xfer != NULL);
- data = purple_xfer_get_ui_data(xfer);
+ data = g_object_get_data(G_OBJECT(xfer), UI_DATA);
if (data == NULL)
return;
@@ -756,8 +750,6 @@
gtk_list_store_remove(GTK_LIST_STORE(dialog->model), &data->iter);
- dialog->num_transfers--;
-
ensure_row_selected(dialog);
update_title_progress(dialog);
@@ -774,7 +766,7 @@
g_return_if_fail(dialog != NULL);
g_return_if_fail(xfer != NULL);
- data = purple_xfer_get_ui_data(xfer);
+ data = g_object_get_data(G_OBJECT(xfer), UI_DATA);
if (data == NULL)
return;
@@ -789,7 +781,7 @@
return;
}
- data = purple_xfer_get_ui_data(xfer);
+ data = g_object_get_data(G_OBJECT(xfer), UI_DATA);
update_detailed_info(dialog, xfer);
update_title_progress(dialog);
@@ -820,11 +812,10 @@
g_return_if_fail(dialog != NULL);
g_return_if_fail(xfer != NULL);
- if ((data = purple_xfer_get_ui_data(xfer)) == NULL)
+ data = g_object_get_data(G_OBJECT(xfer), UI_DATA);
+ if (data == NULL || data->in_list == FALSE) {
return;
-
- if (data->in_list == FALSE)
- return;
+ }
current_time = g_get_monotonic_time();
if (((current_time - data->last_updated_time) < G_USEC_PER_SEC) &&
@@ -969,26 +960,13 @@
/* This is where we're setting xfer's "ui_data" for the first time. */
data = g_new0(PidginXferUiData, 1);
- purple_xfer_set_ui_data(xfer, data);
+ g_object_set_data_full(G_OBJECT(xfer), UI_DATA, data, g_free);
g_signal_connect(xfer, "add-thumbnail",
G_CALLBACK(pidgin_xfer_add_thumbnail), NULL);
}
static void
-pidgin_xfer_destroy(PurpleXfer *xfer)
-{
- PidginXferUiData *data;
-
- data = purple_xfer_get_ui_data(xfer);
- if (data) {
- g_free(data->name);
- g_free(data);
- purple_xfer_set_ui_data(xfer, NULL);
- }
-}
-
-static void
pidgin_xfer_progress_notify(PurpleXfer *xfer, G_GNUC_UNUSED GParamSpec *pspec,
G_GNUC_UNUSED gpointer data)
{
@@ -1024,7 +1002,7 @@
static PurpleXferUiOps ops =
{
pidgin_xfer_new_xfer,
- pidgin_xfer_destroy,
+ NULL,
pidgin_xfer_add_xfer
};