diff options
Diffstat (limited to 'libnm-glib')
| -rw-r--r-- | libnm-glib/Makefile.am | 5 | ||||
| -rw-r--r-- | libnm-glib/Makefile.in | 7 | ||||
| -rw-r--r-- | libnm-glib/nm-access-point.c | 1 | ||||
| -rw-r--r-- | libnm-glib/nm-client.c | 9 | ||||
| -rw-r--r-- | libnm-glib/nm-ip4-config.c | 6 | ||||
| -rw-r--r-- | libnm-glib/nm-object.c | 114 | ||||
| -rw-r--r-- | libnm-glib/nm-remote-connection.c | 6 | ||||
| -rw-r--r-- | libnm-glib/nm-remote-settings.c | 4 | ||||
| -rw-r--r-- | libnm-glib/tests/Makefile.am | 5 | ||||
| -rw-r--r-- | libnm-glib/tests/Makefile.in | 7 |
10 files changed, 92 insertions, 72 deletions
diff --git a/libnm-glib/Makefile.am b/libnm-glib/Makefile.am index c692a3ca..410848af 100644 --- a/libnm-glib/Makefile.am +++ b/libnm-glib/Makefile.am @@ -2,7 +2,7 @@ include $(GLIB_MAKEFILE) SUBDIRS = . tests -INCLUDES = \ +AM_CPPFLAGS = \ -I$(top_srcdir)/include \ -I$(top_builddir)/include \ -I$(top_srcdir)/libnm-util \ @@ -28,6 +28,7 @@ libdeprecated_nm_glib_la_SOURCES = \ libdeprecated_nm_glib_la_CPPFLAGS = \ $(DBUS_CFLAGS) \ $(GLIB_CFLAGS) \ + $(AM_CPPFLAGS) \ -Wno-deprecated-declarations \ -Wno-deprecated @@ -219,7 +220,7 @@ NMClient-1.0.gir: libnm-glib.la NMClient_1_0_gir_INCLUDES = Gio-2.0 DBusGLib-1.0 NMClient_1_0_gir_PACKAGES = gio-2.0 dbus-glib-1 gudev-1.0 NMClient_1_0_gir_EXPORT_PACKAGES = libnm-glib libnm-glib-vpn -NMClient_1_0_gir_CFLAGS = $(INCLUDES) -I$(top_srcdir)/libnm-glib -I$(top_srcdir)/libnm-util +NMClient_1_0_gir_CFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/libnm-glib -I$(top_srcdir)/libnm-util NMClient_1_0_gir_LIBS = libnm-glib.la $(top_builddir)/libnm-util/libnm-util.la NMClient_1_0_gir_FILES = $(introspection_sources) NMClient_1_0_gir_SCANNERFLAGS = --warn-all --identifier-prefix=NM --symbol-prefix=nm --include-uninstalled=$(top_builddir)/libnm-util/NetworkManager-1.0.gir diff --git a/libnm-glib/Makefile.in b/libnm-glib/Makefile.in index 4a94d03a..e726df56 100644 --- a/libnm-glib/Makefile.in +++ b/libnm-glib/Makefile.in @@ -388,6 +388,7 @@ DEPDIR = @DEPDIR@ DHCLIENT_PATH = @DHCLIENT_PATH@ DHCPCD_PATH = @DHCPCD_PATH@ DLLTOOL = @DLLTOOL@ +DNSMASQ_PATH = @DNSMASQ_PATH@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -410,6 +411,7 @@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ GTKDOC_MKPDF = @GTKDOC_MKPDF@ @@ -595,7 +597,7 @@ with_dhcpcd = @with_dhcpcd@ with_netconfig = @with_netconfig@ with_resolvconf = @with_resolvconf@ SUBDIRS = . tests -INCLUDES = \ +AM_CPPFLAGS = \ -I$(top_srcdir)/include \ -I$(top_builddir)/include \ -I$(top_srcdir)/libnm-util \ @@ -618,6 +620,7 @@ libdeprecated_nm_glib_la_SOURCES = \ libdeprecated_nm_glib_la_CPPFLAGS = \ $(DBUS_CFLAGS) \ $(GLIB_CFLAGS) \ + $(AM_CPPFLAGS) \ -Wno-deprecated-declarations \ -Wno-deprecated @@ -781,7 +784,7 @@ INTROSPECTION_COMPILER_ARGS = --includedir=$(top_builddir)/libnm-util @HAVE_INTROSPECTION_TRUE@NMClient_1_0_gir_INCLUDES = Gio-2.0 DBusGLib-1.0 @HAVE_INTROSPECTION_TRUE@NMClient_1_0_gir_PACKAGES = gio-2.0 dbus-glib-1 gudev-1.0 @HAVE_INTROSPECTION_TRUE@NMClient_1_0_gir_EXPORT_PACKAGES = libnm-glib libnm-glib-vpn -@HAVE_INTROSPECTION_TRUE@NMClient_1_0_gir_CFLAGS = $(INCLUDES) -I$(top_srcdir)/libnm-glib -I$(top_srcdir)/libnm-util +@HAVE_INTROSPECTION_TRUE@NMClient_1_0_gir_CFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/libnm-glib -I$(top_srcdir)/libnm-util @HAVE_INTROSPECTION_TRUE@NMClient_1_0_gir_LIBS = libnm-glib.la $(top_builddir)/libnm-util/libnm-util.la @HAVE_INTROSPECTION_TRUE@NMClient_1_0_gir_FILES = $(introspection_sources) @HAVE_INTROSPECTION_TRUE@NMClient_1_0_gir_SCANNERFLAGS = --warn-all --identifier-prefix=NM --symbol-prefix=nm --include-uninstalled=$(top_builddir)/libnm-util/NetworkManager-1.0.gir diff --git a/libnm-glib/nm-access-point.c b/libnm-glib/nm-access-point.c index 9326d3ab..d13a7d3c 100644 --- a/libnm-glib/nm-access-point.c +++ b/libnm-glib/nm-access-point.c @@ -354,7 +354,6 @@ nm_access_point_connection_valid (NMAccessPoint *ap, NMConnection *connection) /* Band and Channel/Frequency */ ap_freq = nm_access_point_get_frequency (ap); - g_warn_if_fail (ap_freq > 0); if (ap_freq) { setting_band = nm_setting_wireless_get_band (s_wifi); if (g_strcmp0 (setting_band, "a") == 0) { diff --git a/libnm-glib/nm-client.c b/libnm-glib/nm-client.c index 9226d350..658a3995 100644 --- a/libnm-glib/nm-client.c +++ b/libnm-glib/nm-client.c @@ -1404,9 +1404,11 @@ check_connectivity_cb (DBusGProxy *proxy, CheckConnectivityData *ccd = g_simple_async_result_get_op_res_gpointer (simple); GError *error = NULL; - if (!dbus_g_proxy_end_call (proxy, call, &error, - G_TYPE_UINT, &ccd->connectivity, - G_TYPE_INVALID)) + if (g_cancellable_set_error_if_cancelled (ccd->cancellable, &error)) + g_simple_async_result_take_error (simple, error); + else if (!dbus_g_proxy_end_call (proxy, call, &error, + G_TYPE_UINT, &ccd->connectivity, + G_TYPE_INVALID)) g_simple_async_result_take_error (simple, error); g_simple_async_result_complete (simple); @@ -1466,7 +1468,6 @@ nm_client_check_connectivity_async (NMClient *client, ccd->cancelled_id = g_signal_connect (cancellable, "cancelled", G_CALLBACK (check_connectivity_cancelled_cb), simple); - g_simple_async_result_set_check_cancellable (simple, cancellable); } ccd->call = dbus_g_proxy_begin_call (priv->client_proxy, "CheckConnectivity", diff --git a/libnm-glib/nm-ip4-config.c b/libnm-glib/nm-ip4-config.c index 862e7a01..80751c31 100644 --- a/libnm-glib/nm-ip4-config.c +++ b/libnm-glib/nm-ip4-config.c @@ -104,7 +104,7 @@ demarshal_ip4_routes_array (NMObject *object, GParamSpec *pspec, GValue *value, { NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object); - g_slist_foreach (priv->routes, (GFunc) g_free, NULL); + g_slist_foreach (priv->routes, (GFunc) nm_ip4_route_unref, NULL); g_slist_free (priv->routes); priv->routes = NULL; @@ -156,10 +156,10 @@ finalize (GObject *object) { NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object); - g_slist_foreach (priv->addresses, (GFunc) g_free, NULL); + g_slist_foreach (priv->addresses, (GFunc) nm_ip4_address_unref, NULL); g_slist_free (priv->addresses); - g_slist_foreach (priv->routes, (GFunc) g_free, NULL); + g_slist_foreach (priv->routes, (GFunc) nm_ip4_route_unref, NULL); g_slist_free (priv->routes); if (priv->nameservers) diff --git a/libnm-glib/nm-object.c b/libnm-glib/nm-object.c index 7696673b..93919d61 100644 --- a/libnm-glib/nm-object.c +++ b/libnm-glib/nm-object.c @@ -23,6 +23,7 @@ #include <string.h> #include <gio/gio.h> +#include <stdlib.h> #include <nm-utils.h> #include "NetworkManager.h" #include "nm-object.h" @@ -33,7 +34,8 @@ #include "nm-types.h" #include "nm-glib-marshal.h" -#define DEBUG 0 +static gboolean debug = FALSE; +#define dbgmsg(f,...) if (G_UNLIKELY (debug)) { g_message (f, ## __VA_ARGS__ ); } static void nm_object_initable_iface_init (GInitableIface *iface); static void nm_object_async_initable_iface_init (GAsyncInitableIface *iface); @@ -139,7 +141,7 @@ constructor (GType type, priv = NM_OBJECT_GET_PRIVATE (object); if (priv->connection == NULL || priv->path == NULL) { - g_warning ("%s: bus connection and path required.", __func__); + g_warn_if_reached (); g_object_unref (object); return NULL; } @@ -433,10 +435,13 @@ deferred_notify_cb (gpointer data) props = g_slist_reverse (priv->notify_props); priv->notify_props = NULL; + g_object_ref (object); for (iter = props; iter; iter = g_slist_next (iter)) { g_object_notify (G_OBJECT (object), (const char *) iter->data); g_free (iter->data); } + g_object_unref (object); + g_slist_free (props); return FALSE; } @@ -490,7 +495,7 @@ _nm_object_create (GType type, DBusGConnection *connection, const char *path) type = type_func (connection, path); if (type == G_TYPE_INVALID) { - g_warning ("Could not create object for %s: unknown object type", path); + dbgmsg ("Could not create object for %s: unknown object type", path); return NULL; } @@ -499,10 +504,9 @@ _nm_object_create (GType type, DBusGConnection *connection, const char *path) NM_OBJECT_DBUS_PATH, path, NULL); if (!g_initable_init (G_INITABLE (object), NULL, &error)) { - g_object_unref (object); - object = NULL; - g_warning ("Could not create object for %s: %s", path, error->message); + dbgmsg ("Could not create object for %s: %s", path, error->message); g_error_free (error); + g_clear_object (&object); } return object; @@ -544,11 +548,11 @@ async_inited (GObject *source, GAsyncResult *result, gpointer user_data) GError *error = NULL; if (!g_async_initable_init_finish (G_ASYNC_INITABLE (object), result, &error)) { - g_warning ("Could not create object for %s: %s", - nm_object_or_connection_get_path (object), error->message); + dbgmsg ("Could not create object for %s: %s", + nm_object_or_connection_get_path (object), + error->message); g_error_free (error); - g_object_unref (object); - object = NULL; + g_clear_object (&object); } create_async_complete (object, async_data); @@ -850,36 +854,33 @@ handle_property_changed (NMObject *self, const char *dbus_name, GValue *value, g } if (!found) { -#if DEBUG - g_warning ("Property '%s' unhandled.", prop_name); -#endif + dbgmsg ("Property '%s' unhandled.", prop_name); goto out; } pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (self)), prop_name); if (!pspec) { - g_warning ("%s: property '%s' changed but wasn't defined by object type %s.", - __func__, - prop_name, - G_OBJECT_TYPE_NAME (self)); + dbgmsg ("%s: property '%s' changed but wasn't defined by object type %s.", + __func__, + prop_name, + G_OBJECT_TYPE_NAME (self)); goto out; } -#if DEBUG - { + if (G_UNLIKELY (debug)) { char *s; s = g_strdup_value_contents (value); - g_message ("PC: %p (%s) prop (%s) '%s' value (%s) %s", - self, G_OBJECT_TYPE_NAME (self), - g_type_name (pspec->value_type), prop_name, - G_VALUE_TYPE_NAME (value), s); + dbgmsg ("PC: (%p) %s::%s => '%s' (%s%s%s)", + self, G_OBJECT_TYPE_NAME (self), + prop_name, + s, + G_VALUE_TYPE_NAME (value), + pi->object_type ? " / " : "", + pi->object_type ? g_type_name (pi->object_type) : ""); g_free (s); } -#endif + if (pi->object_type) { -#if DEBUG - g_message (" Value is object type %s", g_type_name (pi->object_type)); -#endif if (G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH)) success = handle_object_property (self, pspec->name, value, pi, synchronously); else if (G_VALUE_HOLDS (value, DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH)) @@ -892,10 +893,10 @@ handle_property_changed (NMObject *self, const char *dbus_name, GValue *value, g success = (*(pi->func)) (self, pspec, value, pi->field); if (!success) { - g_warning ("%s: failed to update property '%s' of object type %s.", - __func__, - prop_name, - G_OBJECT_TYPE_NAME (self)); + dbgmsg ("%s: failed to update property '%s' of object type %s.", + __func__, + prop_name, + G_OBJECT_TYPE_NAME (self)); } out: @@ -917,8 +918,8 @@ process_properties_changed (NMObject *self, GHashTable *properties, gboolean syn if (value) handle_property_changed (self, name, value, synchronously); else { - g_warning ("%s:%d %s(): object %s property '%s' value is unexpectedly NULL", - __FILE__, __LINE__, __func__, G_OBJECT_TYPE_NAME (self), (const char *) name); + dbgmsg ("%s:%d %s(): object %s property '%s' value is unexpectedly NULL", + __FILE__, __LINE__, __func__, G_OBJECT_TYPE_NAME (self), (const char *) name); } } } @@ -978,9 +979,11 @@ demarshal_generic (NMObject *object, HANDLE_TYPE(LONG, long, long) HANDLE_TYPE(ULONG, ulong, ulong) } else { - g_warning ("%s: %s/%s unhandled type %s.", - __func__, G_OBJECT_TYPE_NAME (object), pspec->name, - g_type_name (pspec->value_type)); + dbgmsg ("%s: %s/%s unhandled type %s.", + __func__, + G_OBJECT_TYPE_NAME (object), + pspec->name, + g_type_name (pspec->value_type)); success = FALSE; } @@ -988,9 +991,9 @@ done: if (success) { _nm_object_queue_notify (object, pspec->name); } else { - g_warning ("%s: %s/%s (type %s) couldn't be set with type %s.", - __func__, G_OBJECT_TYPE_NAME (object), pspec->name, - g_type_name (pspec->value_type), G_VALUE_TYPE_NAME (value)); + dbgmsg ("%s: %s/%s (type %s) couldn't be set with type %s.", + __func__, G_OBJECT_TYPE_NAME (object), pspec->name, + g_type_name (pspec->value_type), G_VALUE_TYPE_NAME (value)); } return success; } @@ -1001,6 +1004,8 @@ _nm_object_register_properties (NMObject *object, const NMPropertiesInfo *info) { NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object); + static gsize dval = 0; + const char *debugstr; NMPropertiesInfo *tmp; GHashTable *instance; @@ -1008,6 +1013,13 @@ _nm_object_register_properties (NMObject *object, g_return_if_fail (proxy != NULL); g_return_if_fail (info != NULL); + if (g_once_init_enter (&dval)) { + debugstr = getenv ("LIBNM_GLIB_DEBUG"); + if (debugstr && strstr (debugstr, "properties-changed")) + debug = TRUE; + g_once_init_leave (&dval, 1); + } + priv->property_interfaces = g_slist_prepend (priv->property_interfaces, g_strdup (dbus_g_proxy_get_interface (proxy))); @@ -1087,9 +1099,10 @@ _nm_object_ensure_inited (NMObject *object) if (!priv->inited) { if (!g_initable_init (G_INITABLE (object), NULL, &error)) { - g_warning ("Could not initialize %s %s: %s", - G_OBJECT_TYPE_NAME (object), priv->path, - error->message); + dbgmsg ("Could not initialize %s %s: %s", + G_OBJECT_TYPE_NAME (object), + priv->path, + error->message); g_error_free (error); /* Only warn once */ @@ -1117,17 +1130,12 @@ _nm_object_reload_property (NMObject *object, G_TYPE_INVALID, G_TYPE_VALUE, &value, G_TYPE_INVALID)) { - /* Don't warn about D-Bus no reply/timeout errors; it's mostly noise and - * happens for example when NM quits and the applet is still running. - */ - if (!g_error_matches (err, DBUS_GERROR, DBUS_GERROR_NO_REPLY)) { - g_warning ("%s: Error getting '%s' for %s: (%d) %s\n", - __func__, - prop_name, - nm_object_get_path (object), - err->code, - err->message); - } + dbgmsg ("%s: Error getting '%s' for %s: (%d) %s\n", + __func__, + prop_name, + nm_object_get_path (object), + err->code, + err->message); g_clear_error (&err); return; } diff --git a/libnm-glib/nm-remote-connection.c b/libnm-glib/nm-remote-connection.c index b5c2821f..9cadf2f7 100644 --- a/libnm-glib/nm-remote-connection.c +++ b/libnm-glib/nm-remote-connection.c @@ -102,6 +102,7 @@ update_cb (DBusGProxy *proxy, DBusGProxyCall *proxy_call, gpointer user_data) RemoteCall *call = user_data; NMRemoteConnectionCommitFunc func = (NMRemoteConnectionCommitFunc) call->callback; GError *error = NULL; + NMRemoteConnection *self = g_object_ref (call->self); dbus_g_proxy_end_call (proxy, proxy_call, &error, G_TYPE_INVALID); @@ -109,6 +110,7 @@ update_cb (DBusGProxy *proxy, DBusGProxyCall *proxy_call, gpointer user_data) (*func)(call->self, error, call->user_data); g_clear_error (&error); remote_call_complete (call->self, call); + g_object_unref (self); } /** @@ -206,13 +208,15 @@ get_secrets_cb (DBusGProxy *proxy, DBusGProxyCall *proxy_call, gpointer user_dat { RemoteCall *call = user_data; NMRemoteConnectionGetSecretsFunc func = (NMRemoteConnectionGetSecretsFunc) call->callback; - GHashTable *secrets; + GHashTable *secrets = NULL; GError *error = NULL; dbus_g_proxy_end_call (proxy, proxy_call, &error, DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, &secrets, G_TYPE_INVALID); (*func)(call->self, error ? NULL : secrets, error, call->user_data); + if (secrets) + g_hash_table_destroy (secrets); g_clear_error (&error); remote_call_complete (call->self, call); } diff --git a/libnm-glib/nm-remote-settings.c b/libnm-glib/nm-remote-settings.c index 989528cb..34817e2c 100644 --- a/libnm-glib/nm-remote-settings.c +++ b/libnm-glib/nm-remote-settings.c @@ -545,7 +545,7 @@ add_connection_done (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data * Requests that the remote settings service add the given settings to a new * connection. * - * Returns: TRUE if the request was successful, FALSE if it failed + * Returns: %TRUE if the request was successful, %FALSE if it failed **/ gboolean nm_remote_settings_add_connection (NMRemoteSettings *settings, @@ -652,7 +652,7 @@ save_hostname_cb (DBusGProxy *proxy, * Requests that the machine's persistent hostname be set to the specified value * or cleared. * - * Returns: TRUE if the request was successful, FALSE if it failed + * Returns: %TRUE if the request was successful, %FALSE if it failed **/ gboolean nm_remote_settings_save_hostname (NMRemoteSettings *settings, diff --git a/libnm-glib/tests/Makefile.am b/libnm-glib/tests/Makefile.am index 5fda5bd2..07994481 100644 --- a/libnm-glib/tests/Makefile.am +++ b/libnm-glib/tests/Makefile.am @@ -1,6 +1,6 @@ if ENABLE_TESTS -INCLUDES = \ +AM_CPPFLAGS = \ -I$(top_srcdir)/include \ -I$(top_builddir)/include \ -I$(top_srcdir)/libnm-util \ @@ -16,7 +16,8 @@ test_remote_settings_client_SOURCES = \ test_remote_settings_client_CPPFLAGS = \ $(GLIB_CFLAGS) \ - $(DBUS_CFLAGS) + $(DBUS_CFLAGS) \ + $(AM_CPPFLAGS) test_remote_settings_client_LDADD = \ $(top_builddir)/libnm-util/libnm-util.la \ diff --git a/libnm-glib/tests/Makefile.in b/libnm-glib/tests/Makefile.in index ef9fb9b9..e9ea17b1 100644 --- a/libnm-glib/tests/Makefile.in +++ b/libnm-glib/tests/Makefile.in @@ -210,6 +210,7 @@ DEPDIR = @DEPDIR@ DHCLIENT_PATH = @DHCLIENT_PATH@ DHCPCD_PATH = @DHCPCD_PATH@ DLLTOOL = @DLLTOOL@ +DNSMASQ_PATH = @DNSMASQ_PATH@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -232,6 +233,7 @@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ GTKDOC_MKPDF = @GTKDOC_MKPDF@ @@ -416,7 +418,7 @@ with_dhclient = @with_dhclient@ with_dhcpcd = @with_dhcpcd@ with_netconfig = @with_netconfig@ with_resolvconf = @with_resolvconf@ -@ENABLE_TESTS_TRUE@INCLUDES = \ +@ENABLE_TESTS_TRUE@AM_CPPFLAGS = \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/include \ @ENABLE_TESTS_TRUE@ -I$(top_builddir)/include \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/libnm-util \ @@ -430,7 +432,8 @@ with_resolvconf = @with_resolvconf@ @ENABLE_TESTS_TRUE@test_remote_settings_client_CPPFLAGS = \ @ENABLE_TESTS_TRUE@ $(GLIB_CFLAGS) \ -@ENABLE_TESTS_TRUE@ $(DBUS_CFLAGS) +@ENABLE_TESTS_TRUE@ $(DBUS_CFLAGS) \ +@ENABLE_TESTS_TRUE@ $(AM_CPPFLAGS) @ENABLE_TESTS_TRUE@test_remote_settings_client_LDADD = \ @ENABLE_TESTS_TRUE@ $(top_builddir)/libnm-util/libnm-util.la \ |