summaryrefslogtreecommitdiff
path: root/src/NetworkManagerUtils.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-09-24 12:44:20 +0200
committerThomas Haller <thaller@redhat.com>2015-09-25 10:34:02 +0200
commit44f3f18797cf3b0e0d45791939b2f9f023d51230 (patch)
tree1cc385b9fc62eaa41f94aaccc7aba6bdabcdeefa /src/NetworkManagerUtils.c
parenteecb4c46cc35c43c12e84e530b3be50374baa792 (diff)
core: add NM_UTILS_ERROR
Diffstat (limited to 'src/NetworkManagerUtils.c')
-rw-r--r--src/NetworkManagerUtils.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c
index d78313df5..d5bb6c87f 100644
--- a/src/NetworkManagerUtils.c
+++ b/src/NetworkManagerUtils.c
@@ -110,6 +110,39 @@ _nm_utils_set_testing (NMUtilsTestFlags flags)
/*****************************************************************************/
+G_DEFINE_QUARK (nm-utils-error-quark, nm_utils_error)
+
+void
+nm_utils_error_set_cancelled (GError **error,
+ gboolean is_disposing,
+ const char *instance_name)
+{
+ if (is_disposing) {
+ g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_CANCELLED_DISPOSING,
+ "Disposing %s instance",
+ instance_name && *instance_name ? instance_name : "source");
+ } else {
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_CANCELLED,
+ "Request cancelled");
+ }
+}
+
+gboolean
+nm_utils_error_is_cancelled (GError *error,
+ gboolean consider_is_disposing)
+{
+ if (error) {
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ return TRUE;
+ if ( consider_is_disposing
+ && g_error_matches (error, NM_UTILS_ERROR, NM_UTILS_ERROR_CANCELLED_DISPOSING))
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/*****************************************************************************/
+
static GSList *_singletons = NULL;
static gboolean _singletons_shutdown = FALSE;