diff options
author | Benjamin Otte <otte@gnome.org> | 2009-06-10 11:36:22 +0200 |
---|---|---|
committer | Benjamin Otte <otte@gnome.org> | 2009-06-10 17:06:41 +0200 |
commit | df5339b873f1f1e9dd1c1d9fe113a16b52808213 (patch) | |
tree | aa608caef85ce21f3e67e59fa8b895706c982088 | |
parent | 060d792d9a47009e33ee01aac0706893deb80e9b (diff) |
signal the need for updates (changes wire protocol and internal API)
Send a boolean send_progress to the daemon in the case of push/pull jobs
that indicates if progress updates should be sent to the client.
Oftentimes the daemons can avoid quite a bit of work (like querying file
sizes or setting up and operating machinery required to send progress
updates) when it's not required.
Patch also includes fixes to daemons to ensure they don't call a NULL
progress_callback (previously, NULL was not a possible value).
-rw-r--r-- | client/gdaemonfile.c | 4 | ||||
-rw-r--r-- | daemon/gvfsbackendobexftp.c | 12 | ||||
-rw-r--r-- | daemon/gvfsjobpull.c | 12 | ||||
-rw-r--r-- | daemon/gvfsjobpull.h | 1 | ||||
-rw-r--r-- | daemon/gvfsjobpush.c | 12 | ||||
-rw-r--r-- | daemon/gvfsjobpush.h | 1 |
6 files changed, 27 insertions, 15 deletions
diff --git a/client/gdaemonfile.c b/client/gdaemonfile.c index 9e8eb637..0071a5bd 100644 --- a/client/gdaemonfile.c +++ b/client/gdaemonfile.c @@ -1958,10 +1958,12 @@ file_transfer (GFile *source, gboolean source_is_daemon; gboolean dest_is_daemon; gboolean native_transfer; + gboolean send_progress; native_transfer = FALSE; source_is_daemon = G_IS_DAEMON_FILE (source); dest_is_daemon = G_IS_DAEMON_FILE (destination); + send_progress = progress_callback != NULL; if (source_is_daemon && dest_is_daemon) native_transfer = TRUE; @@ -2028,6 +2030,7 @@ file_transfer (GFile *source, obj_path, progress_callback_message, &data, NULL, cancellable, error, G_DBUS_TYPE_CSTRING, &local_path, + DBUS_TYPE_BOOLEAN, &send_progress, DBUS_TYPE_UINT32, &flags_dbus, DBUS_TYPE_OBJECT_PATH, &dbus_obj_path, DBUS_TYPE_BOOLEAN, &dbus_remove_source, @@ -2040,6 +2043,7 @@ file_transfer (GFile *source, obj_path, progress_callback_message, &data, NULL, cancellable, error, G_DBUS_TYPE_CSTRING, &local_path, + DBUS_TYPE_BOOLEAN, &send_progress, DBUS_TYPE_UINT32, &flags_dbus, DBUS_TYPE_OBJECT_PATH, &dbus_obj_path, DBUS_TYPE_BOOLEAN, &dbus_remove_source, diff --git a/daemon/gvfsbackendobexftp.c b/daemon/gvfsbackendobexftp.c index f3b1517f..2a38177d 100644 --- a/daemon/gvfsbackendobexftp.c +++ b/daemon/gvfsbackendobexftp.c @@ -1528,8 +1528,9 @@ push_transfer_started_cb (DBusGProxy *proxy, op_backend->status = ASYNC_RUNNING; job_data->total_bytes = (goffset) total_bytes; - job_data->progress_callback (0, job_data->total_bytes, - job_data->progress_callback_data); + if (job_data->progress_callback) + job_data->progress_callback (0, job_data->total_bytes, + job_data->progress_callback_data); g_cond_signal (op_backend->cond); g_mutex_unlock (op_backend->mutex); @@ -1561,9 +1562,10 @@ push_transfer_progress_cb (DBusGProxy *proxy, g_message ("transfer progress"); - job_data->progress_callback ((goffset) bytes_transferred, - job_data->total_bytes, - job_data->progress_callback_data); + if (job_data->progress_callback) + job_data->progress_callback ((goffset) bytes_transferred, + job_data->total_bytes, + job_data->progress_callback_data); } static void diff --git a/daemon/gvfsjobpull.c b/daemon/gvfsjobpull.c index 58e67afb..b69d1a7e 100644 --- a/daemon/gvfsjobpull.c +++ b/daemon/gvfsjobpull.c @@ -87,7 +87,7 @@ g_vfs_job_pull_new (DBusConnection *connection, int path1_len, path2_len; const char *path1_data, *path2_data, *callback_obj_path; dbus_uint32_t flags; - dbus_bool_t remove_source; + dbus_bool_t remove_source, send_progress; dbus_error_init (&derror); if (!dbus_message_get_args (message, &derror, @@ -95,6 +95,7 @@ g_vfs_job_pull_new (DBusConnection *connection, &path1_data, &path1_len, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &path2_data, &path2_len, + DBUS_TYPE_BOOLEAN, &send_progress, DBUS_TYPE_UINT32, &flags, DBUS_TYPE_OBJECT_PATH, &callback_obj_path, DBUS_TYPE_BOOLEAN, &remove_source, @@ -118,6 +119,7 @@ g_vfs_job_pull_new (DBusConnection *connection, job->local_path = g_strndup (path2_data, path2_len); job->backend = backend; job->flags = flags; + job->send_progress = send_progress; job->remove_source = remove_source; g_debug ("Remove Source: %s\n", remove_source ? "true" : "false"); if (strcmp (callback_obj_path, "/org/gtk/vfs/void") != 0) @@ -180,8 +182,8 @@ run (GVfsJob *job) op_job->local_path, op_job->flags, op_job->remove_source, - progress_callback, - job); + op_job->send_progress ? progress_callback : NULL, + op_job->send_progress ? job : NULL); } static gboolean @@ -199,8 +201,8 @@ try (GVfsJob *job) op_job->local_path, op_job->flags, op_job->remove_source, - progress_callback, - job); + op_job->send_progress ? progress_callback : NULL, + op_job->send_progress ? job : NULL); } /* Might be called on an i/o thread */ diff --git a/daemon/gvfsjobpull.h b/daemon/gvfsjobpull.h index bb080878..c29f1c22 100644 --- a/daemon/gvfsjobpull.h +++ b/daemon/gvfsjobpull.h @@ -49,6 +49,7 @@ struct _GVfsJobPull GFileCopyFlags flags; char *callback_obj_path; gboolean remove_source; + gboolean send_progress; }; struct _GVfsJobPullClass diff --git a/daemon/gvfsjobpush.c b/daemon/gvfsjobpush.c index 0ab1efc5..ffb6cdb2 100644 --- a/daemon/gvfsjobpush.c +++ b/daemon/gvfsjobpush.c @@ -87,7 +87,7 @@ g_vfs_job_push_new (DBusConnection *connection, int path1_len, path2_len; const char *path1_data, *path2_data, *callback_obj_path; dbus_uint32_t flags; - dbus_bool_t remove_source; + dbus_bool_t remove_source, send_progress; dbus_error_init (&derror); if (!dbus_message_get_args (message, &derror, @@ -95,6 +95,7 @@ g_vfs_job_push_new (DBusConnection *connection, &path1_data, &path1_len, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &path2_data, &path2_len, + DBUS_TYPE_BOOLEAN, &send_progress, DBUS_TYPE_UINT32, &flags, DBUS_TYPE_OBJECT_PATH, &callback_obj_path, DBUS_TYPE_BOOLEAN, &remove_source, @@ -118,6 +119,7 @@ g_vfs_job_push_new (DBusConnection *connection, job->local_path = g_strndup (path2_data, path2_len); job->backend = backend; job->flags = flags; + job->send_progress = send_progress; job->remove_source = remove_source; g_debug ("Remove Source: %s\n", remove_source ? "true" : "false"); if (strcmp (callback_obj_path, "/org/gtk/vfs/void") != 0) @@ -180,8 +182,8 @@ run (GVfsJob *job) op_job->local_path, op_job->flags, op_job->remove_source, - progress_callback, - job); + op_job->send_progress ? progress_callback : NULL, + op_job->send_progress ? job : NULL); } static gboolean @@ -199,8 +201,8 @@ try (GVfsJob *job) op_job->local_path, op_job->flags, op_job->remove_source, - progress_callback, - job); + op_job->send_progress ? progress_callback : NULL, + op_job->send_progress ? job : NULL); } /* Might be called on an i/o thread */ diff --git a/daemon/gvfsjobpush.h b/daemon/gvfsjobpush.h index c7aabcba..291f7053 100644 --- a/daemon/gvfsjobpush.h +++ b/daemon/gvfsjobpush.h @@ -48,6 +48,7 @@ struct _GVfsJobPush char *local_path; GFileCopyFlags flags; char *callback_obj_path; + gboolean send_progress; gboolean remove_source; }; |