[gnome-packagekit] Don't show the gpk-install-x modal error box if the user cancelled the transaction
- From: Richard Hughes <rhughes src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-packagekit] Don't show the gpk-install-x modal error box if the user cancelled the transaction
- Date: Tue, 26 May 2009 07:24:43 -0400 (EDT)
commit c78ed22b4bfca8d100aa15f172b0b9f0b7a7dd64
Author: Richard Hughes <richard hughsie com>
Date: Tue May 26 09:35:51 2009 +0100
Don't show the gpk-install-x modal error box if the user cancelled the transaction
---
src/gpk-common.c | 31 +++++++++++++++++++++++++++++++
src/gpk-common.h | 1 +
src/gpk-install-catalog.c | 9 +++++----
src/gpk-install-local-file.c | 7 ++++---
src/gpk-install-mime-type.c | 7 ++++---
src/gpk-install-package-name.c | 7 ++++---
src/gpk-install-provide-file.c | 7 ++++---
7 files changed, 53 insertions(+), 16 deletions(-)
diff --git a/src/gpk-common.c b/src/gpk-common.c
index 1b34353..40004e6 100644
--- a/src/gpk-common.c
+++ b/src/gpk-common.c
@@ -657,6 +657,37 @@ gpk_package_entry_completion_new (void)
return completion;
}
+/**
+ * gpk_ignore_session_error:
+ *
+ * Returns true if the error is a remote exception where we cancelled
+ **/
+gboolean
+gpk_ignore_session_error (GError *error)
+{
+ gboolean ret = FALSE;
+ const gchar *name;
+
+ if (error == NULL)
+ goto out;
+ if (error->domain != DBUS_GERROR)
+ goto out;
+ if (error->code != DBUS_GERROR_REMOTE_EXCEPTION)
+ goto out;
+
+ /* use one of our local codes */
+ name = dbus_g_error_get_name (error);
+ if (name == NULL)
+ goto out;
+
+ if (g_str_has_prefix (name, "org.freedesktop.PackageKit.Modify.Cancelled")) {
+ ret = TRUE;
+ goto out;
+ }
+out:
+ return ret;
+}
+
/***************************************************************************
*** MAKE CHECK TESTS ***
***************************************************************************/
diff --git a/src/gpk-common.h b/src/gpk-common.h
index 88cd4d1..cc3c460 100644
--- a/src/gpk-common.h
+++ b/src/gpk-common.h
@@ -106,6 +106,7 @@ gboolean gpk_window_set_size_request (GtkWindow *window,
guint width,
guint height);
gboolean gpk_session_logout (void);
+gboolean gpk_ignore_session_error (GError *error);
G_END_DECLS
diff --git a/src/gpk-install-catalog.c b/src/gpk-install-catalog.c
index aca6e76..ca5c2dc 100644
--- a/src/gpk-install-catalog.c
+++ b/src/gpk-install-catalog.c
@@ -32,6 +32,7 @@
#include "gpk-common.h"
#include "gpk-error.h"
+#include "gpk-dbus.h"
/**
* main:
@@ -93,7 +94,6 @@ main (int argc, char *argv[])
connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
if (connection == NULL) {
egg_warning ("%s", error->message);
- g_error_free (error);
goto out;
}
@@ -117,17 +117,18 @@ main (int argc, char *argv[])
G_TYPE_STRING, "", /* interaction */
G_TYPE_INVALID,
G_TYPE_INVALID);
- if (!ret) {
+ if (!ret && !gpk_ignore_session_error (error)) {
/* TRANSLATORS: This is when the specified DBus method did not execute successfully */
gpk_error_dialog (_("The action could not be completed"),
/* TRANSLATORS: we don't have anything more useful to translate. sorry. */
_("The request failed. More details are available in the detailed report."),
error->message);
- egg_warning ("%s", error->message);
- g_error_free (error);
+ egg_warning ("%i: %s", error->code, error->message);
goto out;
}
out:
+ if (error != NULL)
+ g_error_free (error);
if (proxy != NULL)
g_object_unref (proxy);
g_strfreev (files);
diff --git a/src/gpk-install-local-file.c b/src/gpk-install-local-file.c
index 465ebbd..332cf5a 100644
--- a/src/gpk-install-local-file.c
+++ b/src/gpk-install-local-file.c
@@ -31,6 +31,7 @@
#include "gpk-common.h"
#include "gpk-error.h"
+#include "gpk-dbus.h"
/**
* main:
@@ -93,7 +94,6 @@ main (int argc, char *argv[])
connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
if (connection == NULL) {
egg_warning ("%s", error->message);
- g_error_free (error);
goto out;
}
@@ -117,17 +117,18 @@ main (int argc, char *argv[])
G_TYPE_STRING, "hide-finished", /* interaction */
G_TYPE_INVALID,
G_TYPE_INVALID);
- if (!ret) {
+ if (!ret && !gpk_ignore_session_error (error)) {
/* TRANSLATORS: This is when the specified DBus method did not execute successfully */
gpk_error_dialog (_("The action could not be completed"),
/* TRANSLATORS: we don't have anything more useful to translate. sorry. */
_("The request failed. More details are available in the detailed report."),
error->message);
egg_warning ("%s", error->message);
- g_error_free (error);
goto out;
}
out:
+ if (error != NULL)
+ g_error_free (error);
if (proxy != NULL)
g_object_unref (proxy);
g_strfreev (files);
diff --git a/src/gpk-install-mime-type.c b/src/gpk-install-mime-type.c
index 535fda6..d92cf14 100644
--- a/src/gpk-install-mime-type.c
+++ b/src/gpk-install-mime-type.c
@@ -31,6 +31,7 @@
#include "gpk-common.h"
#include "gpk-error.h"
+#include "gpk-dbus.h"
/**
* main:
@@ -93,7 +94,6 @@ main (int argc, char *argv[])
connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
if (connection == NULL) {
egg_warning ("%s", error->message);
- g_error_free (error);
goto out;
}
@@ -117,17 +117,18 @@ main (int argc, char *argv[])
G_TYPE_STRING, "", /* interaction */
G_TYPE_INVALID,
G_TYPE_INVALID);
- if (!ret) {
+ if (!ret && !gpk_ignore_session_error (error)) {
/* TRANSLATORS: This is when the specified DBus method did not execute successfully */
gpk_error_dialog (_("The action could not be completed"),
/* TRANSLATORS: we don't have anything more useful to translate. sorry. */
_("The request failed. More details are available in the detailed report."),
error->message);
egg_warning ("%s", error->message);
- g_error_free (error);
goto out;
}
out:
+ if (error != NULL)
+ g_error_free (error);
if (proxy != NULL)
g_object_unref (proxy);
g_strfreev (types);
diff --git a/src/gpk-install-package-name.c b/src/gpk-install-package-name.c
index 2a80303..976137f 100644
--- a/src/gpk-install-package-name.c
+++ b/src/gpk-install-package-name.c
@@ -31,6 +31,7 @@
#include "gpk-common.h"
#include "gpk-error.h"
+#include "gpk-dbus.h"
/**
* main:
@@ -92,7 +93,6 @@ main (int argc, char *argv[])
connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
if (connection == NULL) {
egg_warning ("%s", error->message);
- g_error_free (error);
goto out;
}
@@ -116,17 +116,18 @@ main (int argc, char *argv[])
G_TYPE_STRING, "", /* interaction */
G_TYPE_INVALID,
G_TYPE_INVALID);
- if (!ret) {
+ if (!ret && !gpk_ignore_session_error (error)) {
/* TRANSLATORS: This is when the specified DBus method did not execute successfully */
gpk_error_dialog (_("The action could not be completed"),
/* TRANSLATORS: we don't have anything more useful to translate. sorry. */
_("The request failed. More details are available in the detailed report."),
error->message);
egg_warning ("%s", error->message);
- g_error_free (error);
goto out;
}
out:
+ if (error != NULL)
+ g_error_free (error);
if (proxy != NULL)
g_object_unref (proxy);
g_strfreev (packages);
diff --git a/src/gpk-install-provide-file.c b/src/gpk-install-provide-file.c
index 98c62a1..a6a52d4 100644
--- a/src/gpk-install-provide-file.c
+++ b/src/gpk-install-provide-file.c
@@ -31,6 +31,7 @@
#include "gpk-common.h"
#include "gpk-error.h"
+#include "gpk-dbus.h"
/**
* main:
@@ -93,7 +94,6 @@ main (int argc, char *argv[])
connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
if (connection == NULL) {
egg_warning ("%s", error->message);
- g_error_free (error);
goto out;
}
@@ -117,17 +117,18 @@ main (int argc, char *argv[])
G_TYPE_STRING, "", /* interaction */
G_TYPE_INVALID,
G_TYPE_INVALID);
- if (!ret) {
+ if (!ret && !gpk_ignore_session_error (error)) {
/* TRANSLATORS: This is when the specified DBus method did not execute successfully */
gpk_error_dialog (_("The action could not be completed"),
/* TRANSLATORS: we don't have anything more useful to translate. sorry. */
_("The request failed. More details are available in the detailed report."),
error->message);
egg_warning ("%s", error->message);
- g_error_free (error);
goto out;
}
out:
+ if (error != NULL)
+ g_error_free (error);
if (proxy != NULL)
g_object_unref (proxy);
g_strfreev (files);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]