From 330026db90df99ffc394acc5c08c61e9a3de287a Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 18 Mar 2016 13:45:20 +0100 Subject: shared: add "nm-shared-utils" --- shared/nm-shared-utils.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 shared/nm-shared-utils.h (limited to 'shared/nm-shared-utils.h') diff --git a/shared/nm-shared-utils.h b/shared/nm-shared-utils.h new file mode 100644 index 0000000000..2619d04978 --- /dev/null +++ b/shared/nm-shared-utils.h @@ -0,0 +1,27 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * (C) Copyright 2016 Red Hat, Inc. + */ + +#ifndef __NM_SHARED_UTILS_H__ +#define __NM_SHARED_UTILS_H__ + +/******************************************************************************/ + +#endif /* __NM_SHARED_UTILS_H__ */ -- cgit v1.2.1 From fafc90526be534a9cc4acdbcd02df43424d8304b Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 20 Mar 2016 10:32:43 +0100 Subject: shared: move _nm_utils_ascii_str_to_int64() to "shared/nm-shared-utils.h" _nm_utils_ascii_str_to_int64() was declared in libnm-core's internal header "nm-core-internal.h" and thus available for libnm-core, libnm, NetworkManager and related. It also means, the function was not available in libnm-util, libnm-glib, clients or dispatcher. So, we either reimplemented it (nmc_string_to_int_base) or struggle with the awkward strtol* API. --- shared/nm-shared-utils.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'shared/nm-shared-utils.h') diff --git a/shared/nm-shared-utils.h b/shared/nm-shared-utils.h index 2619d04978..943e467d82 100644 --- a/shared/nm-shared-utils.h +++ b/shared/nm-shared-utils.h @@ -24,4 +24,8 @@ /******************************************************************************/ +gint64 _nm_utils_ascii_str_to_int64 (const char *str, guint base, gint64 min, gint64 max, gint64 fallback); + +/******************************************************************************/ + #endif /* __NM_SHARED_UTILS_H__ */ -- cgit v1.2.1 From 72216f73599760977a54bb8b96b1c8054f92ba6a Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 18 Mar 2016 13:59:57 +0100 Subject: shared: move NM_UTILS_ERROR to shared-utils NM_UTILS_ERROR is our way to say, that we don't care about the GError domain and code. nmcli sometimes passes domain "1" and code "0" to g_set_error(), which could be considered a bug. We usually don't care about the error but only about the error message, so let's have a universally available error quark around. --- shared/nm-shared-utils.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'shared/nm-shared-utils.h') diff --git a/shared/nm-shared-utils.h b/shared/nm-shared-utils.h index 943e467d82..2942fe9bb6 100644 --- a/shared/nm-shared-utils.h +++ b/shared/nm-shared-utils.h @@ -28,4 +28,29 @@ gint64 _nm_utils_ascii_str_to_int64 (const char *str, guint base, gint64 min, gi /******************************************************************************/ +/** + * NMUtilsError: + * @NM_UTILS_ERROR_UNKNOWN: unknown or unclassified error + * @NM_UTILS_ERROR_CANCELLED_DISPOSING: when disposing an object that has + * pending aynchronous operations, the operation is cancelled with this + * error reason. Depending on the usage, this might indicate a bug because + * usually the target object should stay alive as long as there are pending + * operations. + */ +typedef enum { + NM_UTILS_ERROR_UNKNOWN = 0, /*< nick=Unknown >*/ + NM_UTILS_ERROR_CANCELLED_DISPOSING, /*< nick=CancelledDisposing >*/ +} NMUtilsError; + +#define NM_UTILS_ERROR (nm_utils_error_quark ()) +GQuark nm_utils_error_quark (void); + +void nm_utils_error_set_cancelled (GError **error, + gboolean is_disposing, + const char *instance_name); +gboolean nm_utils_error_is_cancelled (GError *error, + gboolean consider_is_disposing); + +/******************************************************************************/ + #endif /* __NM_SHARED_UTILS_H__ */ -- cgit v1.2.1 From 88655999df765373a4808089e26e441d2bfcae14 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 18 Mar 2016 13:56:53 +0100 Subject: shared: add nm_g_object_set_property() --- shared/nm-shared-utils.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'shared/nm-shared-utils.h') diff --git a/shared/nm-shared-utils.h b/shared/nm-shared-utils.h index 2942fe9bb6..f80c850c69 100644 --- a/shared/nm-shared-utils.h +++ b/shared/nm-shared-utils.h @@ -53,4 +53,11 @@ gboolean nm_utils_error_is_cancelled (GError *error, /******************************************************************************/ +gboolean nm_g_object_set_property (GObject *object, + const gchar *property_name, + const GValue *value, + GError **error); + +/******************************************************************************/ + #endif /* __NM_SHARED_UTILS_H__ */ -- cgit v1.2.1