pidgin/pidgin

42922708e18e
Parents 09402b6a28cf
Children 39eb6d1b71ff
Replace PurpleXferUiOps.update_progress by PurpleXfer.progress.

Progress can be monitored by connecting to notify::progress on
PurpleXfer instances.
--- a/ChangeLog.API Sat Dec 21 20:14:34 2019 -0500
+++ b/ChangeLog.API Sat Dec 21 20:44:34 2019 -0500
@@ -473,6 +473,7 @@
* purple_util_get_image_checksum. Use
g_compute_checksum_for_data(G_CHECKSUM_SHA1, ...), instead.
* purple_uts35_to_str
+ * purple_xfer_update_progress
* PurpleCertificateVerificationStatus.PURPLE_CERTIFICATE_INVALID
* PurpleConnectionUiOps.report_disconnect_reason
* PurplePluginProtocolInfo.add_buddy_with_invite
@@ -483,6 +484,8 @@
instead.
* PurpleXferUiOps.ui_read. Use PurpleXfer::read-local instead.
* PurpleXferUiOps.ui_write. Use PurpleXfer::write-local instead.
+ * PurpleXferUiOps.update_progress. Use notify::progress on
+ #PurpleXfer objects instead.
* serv_got_attention
* serv_send_attention
* struct _PurpleAttentionType
--- a/finch/gntxfer.c Sat Dec 21 20:14:34 2019 -0500
+++ b/finch/gntxfer.c Sat Dec 21 20:44:34 2019 -0500
@@ -488,6 +488,15 @@
}
static void
+finch_xfer_progress_notify(PurpleXfer *xfer, G_GNUC_UNUSED GParamSpec *pspec,
+ G_GNUC_UNUSED gpointer data)
+{
+ if (xfer_dialog) {
+ finch_xfer_dialog_update_xfer(xfer);
+ }
+}
+
+static void
finch_xfer_add_xfer(PurpleXfer *xfer)
{
if (!xfer_dialog)
@@ -495,13 +504,9 @@
finch_xfer_dialog_add_xfer(xfer);
gnt_tree_set_selected(GNT_TREE(xfer_dialog->tree), xfer);
-}
-static void
-finch_xfer_update_progress(PurpleXfer *xfer, double percent)
-{
- if (xfer_dialog)
- finch_xfer_dialog_update_xfer(xfer);
+ g_signal_connect(xfer, "notify::progress",
+ G_CALLBACK(finch_xfer_progress_notify), NULL);
}
static void
@@ -523,7 +528,6 @@
finch_xfer_new_xfer,
finch_xfer_destroy,
finch_xfer_add_xfer,
- finch_xfer_update_progress,
finch_xfer_cancel_local,
finch_xfer_cancel_remote,
NULL /* add_thumbnail */
--- a/libpurple/protocols/jabber/oob.c Sat Dec 21 20:14:34 2019 -0500
+++ b/libpurple/protocols/jabber/oob.c Sat Dec 21 20:44:34 2019 -0500
@@ -87,7 +87,6 @@
total = soup_message_headers_get_content_length(msg->response_headers);
purple_xfer_set_size(xfer, total);
- purple_xfer_update_progress(xfer);
}
static void
--- a/libpurple/protocols/sametime/sametime.c Sat Dec 21 20:14:34 2019 -0500
+++ b/libpurple/protocols/sametime/sametime.c Sat Dec 21 20:44:34 2019 -0500
@@ -2174,8 +2174,6 @@
filesize = purple_xfer_get_size(xfer);
idb.user = remote_user;
- purple_xfer_update_progress(xfer);
-
/* test that we can actually send the file */
fp = g_fopen(filename, "rb");
if(! fp) {
@@ -2277,7 +2275,6 @@
/* calculate progress and display it */
purple_xfer_set_bytes_sent(xfer, purple_xfer_get_bytes_sent(xfer) + o.len);
- purple_xfer_update_progress(xfer);
mwFileTransfer_send(ft, &o);
@@ -2371,7 +2368,6 @@
/* update the progress */
purple_xfer_set_bytes_sent(xfer, purple_xfer_get_bytes_sent(xfer) + data->len);
- purple_xfer_update_progress(xfer);
/* let the other side know we got it, and to send some more */
mwFileTransfer_ack(ft);
--- a/libpurple/protocols/silc/ft.c Sat Dec 21 20:14:34 2019 -0500
+++ b/libpurple/protocols/silc/ft.c Sat Dec 21 20:44:34 2019 -0500
@@ -89,7 +89,6 @@
"during file transfer"), _("Remote disconnected"),
purple_request_cpar_from_connection(gc));
purple_xfer_set_status(xfer->xfer, PURPLE_XFER_STATUS_CANCEL_REMOTE);
- purple_xfer_update_progress(xfer->xfer);
silc_client_file_close(client, conn, session_id);
return;
}
@@ -131,7 +130,6 @@
purple_request_cpar_from_connection(gc));
}
purple_xfer_set_status(xfer->xfer, PURPLE_XFER_STATUS_CANCEL_REMOTE);
- purple_xfer_update_progress(xfer->xfer);
silc_client_file_close(client, conn, session_id);
return;
}
@@ -142,7 +140,6 @@
if (offset && filesize) {
purple_xfer_set_bytes_sent(xfer->xfer, offset);
}
- purple_xfer_update_progress(xfer->xfer);
if (status == SILC_CLIENT_FILE_MONITOR_SEND ||
status == SILC_CLIENT_FILE_MONITOR_RECEIVE) {
--- a/libpurple/xfer.c Sat Dec 21 20:14:34 2019 -0500
+++ b/libpurple/xfer.c Sat Dec 21 20:44:34 2019 -0500
@@ -115,6 +115,7 @@
PROP_START_TIME,
PROP_END_TIME,
PROP_STATUS,
+ PROP_PROGRESS,
PROP_UI_DATA,
PROP_LAST
};
@@ -913,7 +914,6 @@
purple_xfer_set_completed(PurpleXfer *xfer, gboolean completed)
{
PurpleXferPrivate *priv = NULL;
- PurpleXferUiOps *ui_ops;
g_return_if_fail(PURPLE_IS_XFER(xfer));
@@ -954,10 +954,7 @@
g_free(msg);
}
- ui_ops = purple_xfer_get_ui_ops(xfer);
-
- if (ui_ops != NULL && ui_ops->update_progress != NULL)
- ui_ops->update_progress(xfer, purple_xfer_get_progress(xfer));
+ g_object_notify_by_pspec(G_OBJECT(xfer), properties[PROP_PROGRESS]);
}
void
@@ -1033,6 +1030,7 @@
priv->size = size;
g_object_notify_by_pspec(G_OBJECT(xfer), properties[PROP_FILE_SIZE]);
+ g_object_notify_by_pspec(G_OBJECT(xfer), properties[PROP_PROGRESS]);
}
void
@@ -1059,6 +1057,7 @@
priv->bytes_sent = bytes_sent;
g_object_notify_by_pspec(G_OBJECT(xfer), properties[PROP_BYTES_SENT]);
+ g_object_notify_by_pspec(G_OBJECT(xfer), properties[PROP_PROGRESS]);
}
PurpleXferUiOps *
@@ -1300,12 +1299,9 @@
do_transfer(PurpleXfer *xfer)
{
PurpleXferPrivate *priv = purple_xfer_get_instance_private(xfer);
- PurpleXferUiOps *ui_ops;
guchar *buffer = NULL;
gssize r = 0;
- ui_ops = purple_xfer_get_ui_ops(xfer);
-
if (priv->type == PURPLE_XFER_TYPE_RECEIVE) {
r = purple_xfer_read(xfer, &buffer);
if (r > 0) {
@@ -1423,10 +1419,6 @@
if (klass && klass->ack)
klass->ack(xfer, buffer, r);
-
- if (ui_ops != NULL && ui_ops->update_progress != NULL)
- ui_ops->update_progress(xfer,
- purple_xfer_get_progress(xfer));
}
g_free(buffer);
@@ -1882,19 +1874,6 @@
g_free(title);
}
-void
-purple_xfer_update_progress(PurpleXfer *xfer)
-{
- PurpleXferUiOps *ui_ops;
-
- g_return_if_fail(PURPLE_IS_XFER(xfer));
-
- ui_ops = purple_xfer_get_ui_ops(xfer);
- if (ui_ops != NULL && ui_ops->update_progress != NULL) {
- ui_ops->update_progress(xfer, purple_xfer_get_progress(xfer));
- }
-}
-
gconstpointer
purple_xfer_get_thumbnail(PurpleXfer *xfer, gsize *len)
{
@@ -2102,6 +2081,9 @@
case PROP_STATUS:
g_value_set_enum(value, purple_xfer_get_status(xfer));
break;
+ 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;
@@ -2279,6 +2261,11 @@
PURPLE_TYPE_XFER_STATUS, PURPLE_XFER_STATUS_UNKNOWN,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+ properties[PROP_PROGRESS] = g_param_spec_double(
+ "progress", "Progress",
+ "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);
--- a/libpurple/xfer.h Sat Dec 21 20:14:34 2019 -0500
+++ b/libpurple/xfer.h Sat Dec 21 20:44:34 2019 -0500
@@ -101,8 +101,6 @@
* @new_xfer: UI op that's called after a new transfer is created.
* @destroy: UI op that's called when a transfer is being destroyed.
* @add_xfer: UI op that's called when a transfer should be added to the UI.
- * @update_progress: UI op that's called when a transfer's progress has been
- * updated.
* @cancel_local: UI op that's called when a transfer has been cancelled on the
* local end.
* @cancel_remote: UI op that's called when a transfer has been cancelled on
@@ -119,7 +117,6 @@
void (*new_xfer)(PurpleXfer *xfer);
void (*destroy)(PurpleXfer *xfer);
void (*add_xfer)(PurpleXfer *xfer);
- void (*update_progress)(PurpleXfer *xfer, double percent);
void (*cancel_local)(PurpleXfer *xfer);
void (*cancel_remote)(PurpleXfer *xfer);
void (*add_thumbnail)(PurpleXfer *xfer, const gchar *formats);
@@ -683,14 +680,6 @@
void purple_xfer_error(PurpleXferType type, PurpleAccount *account, const char *who, const char *msg);
/**
- * purple_xfer_update_progress:
- * @xfer: The file transfer.
- *
- * Updates file transfer progress.
- */
-void purple_xfer_update_progress(PurpleXfer *xfer);
-
-/**
* purple_xfer_conversation_write:
* @xfer: The file transfer to which this message relates.
* @message: The message to display.
--- a/pidgin/gtkxfer.c Sat Dec 21 20:14:34 2019 -0500
+++ b/pidgin/gtkxfer.c Sat Dec 21 20:44:34 2019 -0500
@@ -924,18 +924,22 @@
}
static void
+pidgin_xfer_progress_notify(PurpleXfer *xfer, G_GNUC_UNUSED GParamSpec *pspec,
+ G_GNUC_UNUSED gpointer data)
+{
+ pidgin_xfer_dialog_update_xfer(xfer_dialog, xfer);
+}
+
+static void
pidgin_xfer_add_xfer(PurpleXfer *xfer)
{
if (xfer_dialog == NULL)
xfer_dialog = pidgin_xfer_dialog_new();
pidgin_xfer_dialog_add_xfer(xfer_dialog, xfer);
-}
-static void
-pidgin_xfer_update_progress(PurpleXfer *xfer, double percent)
-{
- pidgin_xfer_dialog_update_xfer(xfer_dialog, xfer);
+ g_signal_connect(xfer, "notify::progress",
+ G_CALLBACK(pidgin_xfer_progress_notify), NULL);
}
static void
@@ -1018,7 +1022,6 @@
pidgin_xfer_new_xfer,
pidgin_xfer_destroy,
pidgin_xfer_add_xfer,
- pidgin_xfer_update_progress,
pidgin_xfer_cancel_local,
pidgin_xfer_cancel_remote,
pidgin_xfer_add_thumbnail