[gnome-bluetooth/gnome-2-28] Make the cancel button actually cancel the transfer
- From: Bastien Nocera <hadess src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-bluetooth/gnome-2-28] Make the cancel button actually cancel the transfer
- Date: Mon, 14 Dec 2009 16:29:21 +0000 (UTC)
commit 1c68aa03cffc8f86511c288e6ca9325fb207646d
Author: Bastien Nocera <hadess hadess net>
Date: Mon Dec 14 15:36:24 2009 +0000
Make the cancel button actually cancel the transfer
sendto/main.c | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/sendto/main.c b/sendto/main.c
index 0b4286b..b7d0274 100644
--- a/sendto/main.c
+++ b/sendto/main.c
@@ -43,6 +43,7 @@
#define AGENT_PATH "/org/bluez/agent/sendto"
static DBusGConnection *conn = NULL;
+static ObexAgent *agent = NULL;
static GtkWidget *dialog;
static GtkWidget *label_from;
@@ -54,6 +55,7 @@ static gchar *option_device = NULL;
static gchar *option_device_name = NULL;
static gchar **option_files = NULL;
+static DBusGProxy *current_transfer = NULL;
static guint64 current_size = 0;
static guint64 total_size = 0;
static guint64 total_sent = 0;
@@ -139,6 +141,12 @@ set_response_visible (GtkDialog *dialog,
static void response_callback(GtkWidget *dialog,
gint response, gpointer user_data)
{
+ if (current_transfer != NULL) {
+ obex_agent_set_error_func(agent, NULL, NULL);
+ dbus_g_proxy_call_no_reply (current_transfer, "Cancel", G_TYPE_INVALID);
+ g_object_unref (current_transfer);
+ current_transfer = NULL;
+ }
gtk_widget_destroy(dialog);
gtk_main_quit();
@@ -363,10 +371,14 @@ static void get_properties_callback (DBusGProxy *proxy,
static gboolean request_callback(DBusGMethodInvocation *context,
DBusGProxy *transfer, gpointer user_data)
{
+ g_assert (current_transfer == NULL);
+
dbus_g_proxy_begin_call(transfer, "GetProperties",
get_properties_callback, NULL, NULL,
G_TYPE_INVALID);
+ current_transfer = g_object_ref (transfer);
+
dbus_g_method_return(context, "");
return TRUE;
@@ -438,6 +450,10 @@ static gboolean complete_callback(DBusGMethodInvocation *context,
file_index++;
+ /* And we're done with the transfer */
+ g_object_unref (current_transfer);
+ current_transfer = NULL;
+
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress), 1.0);
dbus_g_method_return(context);
@@ -608,7 +624,6 @@ int main(int argc, char *argv[])
DBusGProxy *proxy;
GHashTable *hash = NULL;
GValue *value;
- ObexAgent *agent;
GError *error = NULL;
int i;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]