diff options
author | Thomas Haller <thaller@redhat.com> | 2015-07-12 14:02:11 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-07-12 14:02:11 +0200 |
commit | 63413e1cc6b13095b8f799579b229cac9c91c8c1 (patch) | |
tree | 6ffdd43fe6b2d57916427c05e818f8b2979c3e29 | |
parent | 55c3f70ec8cc206b6f176e64864a47fbef2a7451 (diff) | |
parent | 4c48f66d3dd01e521453bd464639ac1d4db3da59 (diff) | |
download | NetworkManager-63413e1cc6b13095b8f799579b229cac9c91c8c1.tar.gz |
merge branch 'th/misc-bgo752087'
https://bugzilla.gnome.org/show_bug.cgi?id=752087
45 files changed, 480 insertions, 396 deletions
diff --git a/callouts/nm-dispatcher.c b/callouts/nm-dispatcher.c index 09eb0d3a36..d9fe147f4d 100644 --- a/callouts/nm-dispatcher.c +++ b/callouts/nm-dispatcher.c @@ -652,9 +652,7 @@ main (int argc, char **argv) g_option_context_free (opt_ctx); -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif + nm_g_type_init (); g_unix_signal_add (SIGTERM, signal_handler, GINT_TO_POINTER (SIGTERM)); g_unix_signal_add (SIGINT, signal_handler, GINT_TO_POINTER (SIGINT)); diff --git a/callouts/tests/test-dispatcher-envp.c b/callouts/tests/test-dispatcher-envp.c index ac2a9bd900..023c77a82d 100644 --- a/callouts/tests/test-dispatcher-envp.c +++ b/callouts/tests/test-dispatcher-envp.c @@ -30,6 +30,8 @@ #include "nm-dispatcher-utils.h" #include "nm-dispatcher-api.h" +#include "nm-test-utils.h" + /*******************************************/ static gboolean @@ -605,14 +607,12 @@ test_up_empty_vpn_iface (void) /*******************************************/ +NMTST_DEFINE (); + int main (int argc, char **argv) { - g_test_init (&argc, &argv, NULL); - -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif + nmtst_init (&argc, &argv, TRUE); g_test_add_func ("/dispatcher/up", test_up); g_test_add_func ("/dispatcher/down", test_down); diff --git a/clients/Makefile.am b/clients/Makefile.am index dea8f9e331..e30eb5d8eb 100644 --- a/clients/Makefile.am +++ b/clients/Makefile.am @@ -5,6 +5,7 @@ AM_CPPFLAGS = \ -I${top_builddir}/libnm-core \ -I${top_srcdir}/libnm \ -I${top_builddir}/libnm \ + -I${top_srcdir}/include \ $(GLIB_CFLAGS) \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ -DNMLOCALEDIR=\"$(datadir)/locale\" diff --git a/clients/cli/nmcli.c b/clients/cli/nmcli.c index 63c4b777a7..c27798c237 100644 --- a/clients/cli/nmcli.c +++ b/clients/cli/nmcli.c @@ -38,6 +38,7 @@ #include "polkit-agent.h" #include "nmcli.h" +#include "nm-glib-compat.h" #include "utils.h" #include "common.h" #include "connections.h" @@ -607,10 +608,8 @@ main (int argc, char *argv[]) textdomain (GETTEXT_PACKAGE); #endif -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif - + nm_g_type_init (); + /* Save terminal settings */ tcgetattr (STDIN_FILENO, &termios_orig); diff --git a/clients/nm-online.c b/clients/nm-online.c index bb0c970663..cd97e6cc16 100644 --- a/clients/nm-online.c +++ b/clients/nm-online.c @@ -41,6 +41,7 @@ #include <glib/gi18n.h> #include <NetworkManager.h> +#include "nm-glib-compat.h" #define PROGRESS_STEPS 15 #define WAIT_STARTUP_TAG "wait-startup" @@ -188,9 +189,7 @@ main (int argc, char *argv[]) } remaining_ms = t_secs * 1000; -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif + nm_g_type_init (); client = nm_client_new (NULL, &error); if (!client) { diff --git a/include/nm-glib-compat.h b/include/nm-glib-compat.h index dc39d2b934..5e36516f6e 100644 --- a/include/nm-glib-compat.h +++ b/include/nm-glib-compat.h @@ -106,6 +106,17 @@ __g_type_ensure (GType type) #endif + +#if GLIB_CHECK_VERSION (2, 35, 0) +/* For glib >= 2.36, g_type_init() is deprecated. + * But since 2.35.1 (7c42ab23b55c43ab96d0ac2124b550bf1f49c1ec) this function + * does nothing. Replace the call with empty statement. */ +#define nm_g_type_init() G_STMT_START { (void) 0; } G_STMT_END +#else +#define nm_g_type_init() G_STMT_START { g_type_init (); } G_STMT_END +#endif + + /* g_test_initialized() is only available since glib 2.36. */ #if !GLIB_CHECK_VERSION (2, 36, 0) #define g_test_initialized() (g_test_config_vars->test_initialized) diff --git a/include/nm-test-utils.h b/include/nm-test-utils.h index a2948b6aa1..14d4bb4514 100644 --- a/include/nm-test-utils.h +++ b/include/nm-test-utils.h @@ -302,9 +302,7 @@ __nmtst_init (int *argc, char ***argv, gboolean assert_logging, const char *log_ __nmtst_internal.assert_logging = !!assert_logging; -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif + nm_g_type_init (); is_debug = g_test_verbose (); @@ -634,6 +632,17 @@ __define_nmtst_static(03, 1024) memcpy(&x, __nmtst_swap_temp, sizeof(x)); \ } G_STMT_END +#define nmtst_assert_str_has_substr(str, substr) \ + G_STMT_START { \ + const char *__str = (str); \ + const char *__substr = (substr); \ + \ + g_assert (__str); \ + g_assert (__substr); \ + if (strstr (__str, __substr) == NULL) \ + g_error ("%s:%d: Expects \"%s\" but got \"%s\"", __FILE__, __LINE__, __substr, __str); \ + } G_STMT_END + inline static guint32 nmtst_inet4_from_string (const char *str) { diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c index acdc8b89c7..8f226582cd 100644 --- a/libnm-core/nm-connection.c +++ b/libnm-core/nm-connection.c @@ -1498,7 +1498,8 @@ nm_connection_get_uuid (NMConnection *connection) g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); s_con = nm_connection_get_setting_connection (connection); - g_return_val_if_fail (s_con != NULL, NULL); + if (!s_con) + return NULL; return nm_setting_connection_get_uuid (s_con); } diff --git a/libnm-core/nm-setting-private.h b/libnm-core/nm-setting-private.h index 2d34d509a5..dc8d7fac20 100644 --- a/libnm-core/nm-setting-private.h +++ b/libnm-core/nm-setting-private.h @@ -92,7 +92,7 @@ gboolean _nm_setting_clear_secrets_with_flags (NMSetting *setting, /* Ensure the setting's GType is registered at library load time */ #define NM_SETTING_REGISTER_TYPE(x) \ static void __attribute__((constructor)) register_setting (void) \ -{ g_type_init (); g_type_ensure (x); } +{ nm_g_type_init (); g_type_ensure (x); } GVariant *_nm_setting_get_deprecated_virtual_interface_name (NMSetting *setting, NMConnection *connection, diff --git a/libnm-core/nm-setting.c b/libnm-core/nm-setting.c index e1e81b5de2..b6af31a4c1 100644 --- a/libnm-core/nm-setting.c +++ b/libnm-core/nm-setting.c @@ -95,9 +95,7 @@ static void _ensure_registered (void) { if (G_UNLIKELY (registered_settings == NULL)) { -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif + nm_g_type_init (); registered_settings = g_hash_table_new (g_str_hash, g_str_equal); registered_settings_by_type = g_hash_table_new (_nm_gtype_hash, _nm_gtype_equal); } diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index 7ec67cffc5..3e1cf807e1 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -240,7 +240,7 @@ _nm_utils_init (void) bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - g_type_init (); + nm_g_type_init (); _nm_dbus_errors_init (); } diff --git a/libnm-core/tests/test-setting-dcb.c b/libnm-core/tests/test-setting-dcb.c index f7554e81a5..0369ca55f2 100644 --- a/libnm-core/tests/test-setting-dcb.c +++ b/libnm-core/tests/test-setting-dcb.c @@ -24,11 +24,11 @@ #include <glib.h> #include <string.h> #include <nm-utils.h> -#include <nm-glib-compat.h> #include "nm-setting-dcb.h" #include "nm-connection.h" #include "nm-errors.h" -#include "gsystem-local-alloc.h" + +#include "nm-test-utils.h" #define DCB_FLAGS_ALL (NM_SETTING_DCB_FLAG_ENABLE | \ NM_SETTING_DCB_FLAG_ADVERTISE | \ @@ -303,18 +303,12 @@ test_dcb_bandwidth_sums (void) #define TPATH "/libnm/settings/dcb/" +NMTST_DEFINE (); + int main (int argc, char **argv) { - g_test_init (&argc, &argv, NULL); - -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif - -#if !GLIB_CHECK_VERSION(2,34,0) - g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL); -#endif + nmtst_init (&argc, &argv, TRUE); g_test_add_func (TPATH "flags-valid", test_dcb_flags_valid); g_test_add_func (TPATH "flags-invalid", test_dcb_flags_invalid); diff --git a/libnm-glib/libnm-glib-test.c b/libnm-glib/libnm-glib-test.c index 7dc6823e20..da3bc5f6d9 100644 --- a/libnm-glib/libnm-glib-test.c +++ b/libnm-glib/libnm-glib-test.c @@ -38,6 +38,7 @@ #include "nm-active-connection.h" #include "nm-vpn-connection.h" #include "nm-setting-ip4-config.h" +#include "nm-glib-compat.h" static gboolean test_wireless_enabled (NMClient *client) @@ -392,9 +393,7 @@ main (int argc, char *argv[]) { NMClient *client; -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif + nm_g_type_init (); client = nm_client_new (); if (!client) { diff --git a/libnm-glib/libnm_glib.c b/libnm-glib/libnm_glib.c index fed8016066..7acfcc95a3 100644 --- a/libnm-glib/libnm_glib.c +++ b/libnm-glib/libnm_glib.c @@ -32,6 +32,8 @@ #include "NetworkManager.h" #include "libnm_glib.h" +#include "nm-glib-compat.h" + #define DBUS_NO_SERVICE_ERROR "org.freedesktop.DBus.Error.ServiceDoesNotExist" @@ -495,9 +497,7 @@ libnm_glib_init (void) { libnm_glib_ctx *ctx = NULL; -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif + nm_g_type_init (); if (!g_thread_supported ()) g_thread_init (NULL); diff --git a/libnm-glib/tests/test-nm-client.c b/libnm-glib/tests/test-nm-client.c index af3722eba4..0ec3924d99 100644 --- a/libnm-glib/tests/test-nm-client.c +++ b/libnm-glib/tests/test-nm-client.c @@ -33,7 +33,8 @@ #include "nm-device-wifi.h" #include "nm-device-ethernet.h" #include "nm-device-wimax.h" -#include "nm-glib-compat.h" + +#include "nm-test-utils.h" #include "common.h" @@ -880,14 +881,12 @@ test_client_manager_running (void) /*******************************************************************/ +NMTST_DEFINE (); + int main (int argc, char **argv) { -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif - - g_test_init (&argc, &argv, NULL); + nmtst_init (&argc, &argv, TRUE); loop = g_main_loop_new (NULL, FALSE); diff --git a/libnm-glib/tests/test-remote-settings-client.c b/libnm-glib/tests/test-remote-settings-client.c index a109f8df4a..afaa6fe117 100644 --- a/libnm-glib/tests/test-remote-settings-client.c +++ b/libnm-glib/tests/test-remote-settings-client.c @@ -36,7 +36,8 @@ #include "nm-remote-settings.h" #include "common.h" -#include "gsystem-local-alloc.h" + +#include "nm-test-utils.h" static NMTestServiceInfo *sinfo; static NMRemoteSettings *settings = NULL; @@ -422,17 +423,15 @@ test_service_running (void) /*******************************************************************/ +NMTST_DEFINE (); + int main (int argc, char **argv) { int ret; GError *error = NULL; -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif - - g_test_init (&argc, &argv, NULL); + nmtst_init (&argc, &argv, TRUE); bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error); g_assert_no_error (error); diff --git a/libnm-util/nm-param-spec-specialized.c b/libnm-util/nm-param-spec-specialized.c index acb8aec335..11f957499e 100644 --- a/libnm-util/nm-param-spec-specialized.c +++ b/libnm-util/nm-param-spec-specialized.c @@ -953,9 +953,7 @@ main (int argc, char *argv[]) { DBusGConnection *bus; -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif + nm_g_type_init (); bus = dbus_g_bus_get (DBUS_BUS_SESSION, NULL); diff --git a/libnm-util/nm-setting-private.h b/libnm-util/nm-setting-private.h index 1b271d0c76..5e1122e810 100644 --- a/libnm-util/nm-setting-private.h +++ b/libnm-util/nm-setting-private.h @@ -101,7 +101,7 @@ gboolean _nm_setting_clear_secrets_with_flags (NMSetting *setting, /* Ensure the setting's GType is registered at library load time */ #define NM_SETTING_REGISTER_TYPE(x) \ static void __attribute__((constructor)) register_setting (void) \ -{ g_type_init (); g_type_ensure (x); } +{ nm_g_type_init (); g_type_ensure (x); } NMSetting *nm_setting_find_in_list (GSList *settings_list, const char *setting_name); diff --git a/libnm-util/nm-setting.c b/libnm-util/nm-setting.c index 35ae01daf8..39c1d22207 100644 --- a/libnm-util/nm-setting.c +++ b/libnm-util/nm-setting.c @@ -103,9 +103,7 @@ static void _ensure_registered (void) { if (G_UNLIKELY (registered_settings == NULL)) { -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif + nm_g_type_init (); _nm_value_transforms_register (); registered_settings = g_hash_table_new (g_str_hash, g_str_equal); registered_settings_by_type = g_hash_table_new (_nm_gtype_hash, _nm_gtype_equal); diff --git a/libnm-util/tests/test-setting-dcb.c b/libnm-util/tests/test-setting-dcb.c index 36192cd33a..8f0af2e6c1 100644 --- a/libnm-util/tests/test-setting-dcb.c +++ b/libnm-util/tests/test-setting-dcb.c @@ -308,9 +308,7 @@ int main (int argc, char **argv) g_test_init (&argc, &argv, NULL); -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif + nm_g_type_init (); success = nm_utils_init (&error); g_assert_no_error (error); diff --git a/libnm/tests/test-nm-client.c b/libnm/tests/test-nm-client.c index 3541c741e1..1c9bc853a6 100644 --- a/libnm/tests/test-nm-client.c +++ b/libnm/tests/test-nm-client.c @@ -1170,10 +1170,6 @@ main (int argc, char **argv) { g_setenv ("LIBNM_USE_SESSION_BUS", "1", TRUE); -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif - nmtst_init (&argc, &argv, TRUE); loop = g_main_loop_new (NULL, FALSE); diff --git a/libnm/tests/test-remote-settings-client.c b/libnm/tests/test-remote-settings-client.c index 15590fac1a..d723f6ce7d 100644 --- a/libnm/tests/test-remote-settings-client.c +++ b/libnm/tests/test-remote-settings-client.c @@ -502,6 +502,8 @@ test_save_hostname (void) /*******************************************************************/ +NMTST_DEFINE (); + int main (int argc, char **argv) { @@ -510,11 +512,7 @@ main (int argc, char **argv) g_setenv ("LIBNM_USE_SESSION_BUS", "1", TRUE); -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif - - g_test_init (&argc, &argv, NULL); + nmtst_init (&argc, &argv, TRUE); bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); g_assert_no_error (error); diff --git a/libnm/tests/test-secret-agent.c b/libnm/tests/test-secret-agent.c index 037b5a8135..3f0095abc0 100644 --- a/libnm/tests/test-secret-agent.c +++ b/libnm/tests/test-secret-agent.c @@ -27,11 +27,11 @@ #include <NetworkManager.h> #include <nm-secret-agent-old.h> -#include "nm-glib-compat.h" -#include "nm-test-utils.h" #include "common.h" +#include "nm-test-utils.h" + /*******************************************************************/ enum { @@ -624,6 +624,8 @@ test_secret_agent_auto_register (void) /*******************************************************************/ +NMTST_DEFINE (); + int main (int argc, char **argv) { @@ -631,11 +633,7 @@ main (int argc, char **argv) g_setenv ("LIBNM_USE_SESSION_BUS", "1", TRUE); -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif - - g_test_init (&argc, &argv, NULL); + nmtst_init (&argc, &argv, TRUE); g_test_add ("/libnm/secret-agent/none", TestSecretAgentData, NULL, test_setup, test_secret_agent_none, test_cleanup); diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c index a9c72433ad..6292e80c76 100644 --- a/src/NetworkManagerUtils.c +++ b/src/NetworkManagerUtils.c @@ -2526,11 +2526,15 @@ nm_utils_log_connection_diff (NMConnection *connection, NMConnection *diff_base, if (print_header) { GError *err_verify = NULL; + const char *path = nm_connection_get_path (connection); - if (diff_base) - nm_log (level, domain, "%sconnection '%s' (%p/%s < %p/%s):", prefix, name, connection, G_OBJECT_TYPE_NAME (connection), diff_base, G_OBJECT_TYPE_NAME (diff_base)); - else - nm_log (level, domain, "%sconnection '%s' (%p/%s):", prefix, name, connection, G_OBJECT_TYPE_NAME (connection)); + if (diff_base) { + nm_log (level, domain, "%sconnection '%s' (%p/%s < %p/%s)%s%s%s:", prefix, name, connection, G_OBJECT_TYPE_NAME (connection), diff_base, G_OBJECT_TYPE_NAME (diff_base), + NM_PRINT_FMT_QUOTED (path, " [", path, "]", "")); + } else { + nm_log (level, domain, "%sconnection '%s' (%p/%s):%s%s%s", prefix, name, connection, G_OBJECT_TYPE_NAME (connection), + NM_PRINT_FMT_QUOTED (path, " [", path, "]", "")); + } print_header = FALSE; if (!nm_connection_verify (connection, &err_verify)) { diff --git a/src/devices/nm-device-factory.h b/src/devices/nm-device-factory.h index 34c056d20f..6ae865ae88 100644 --- a/src/devices/nm-device-factory.h +++ b/src/devices/nm-device-factory.h @@ -262,7 +262,7 @@ extern const char *_nm_device_factory_no_default_settings[]; static void __attribute__((constructor)) \ register_device_factory_internal_##lower (void) \ { \ - g_type_init (); \ + nm_g_type_init (); \ g_type_ensure (NM_TYPE_##upper##_FACTORY); \ } \ \ diff --git a/src/devices/wifi/tests/test-wifi-ap-utils.c b/src/devices/wifi/tests/test-wifi-ap-utils.c index 3c405e264f..b59b5376dd 100644 --- a/src/devices/wifi/tests/test-wifi-ap-utils.c +++ b/src/devices/wifi/tests/test-wifi-ap-utils.c @@ -27,6 +27,9 @@ #include "nm-dbus-glib-types.h" #include "nm-core-internal.h" +#include "nm-logging.h" + +#include "nm-test-utils.h" #define DEBUG 1 @@ -1336,16 +1339,14 @@ test_strength_wext (void) /*******************************************/ +NMTST_DEFINE (); + int main (int argc, char **argv) { gsize i; -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif - - g_test_init (&argc, &argv, NULL); + nmtst_init_assert_logging (&argc, &argv, "INFO", "DEFAULT"); g_test_add_func ("/wifi/lock_bssid", test_lock_bssid); diff --git a/src/dhcp-manager/nm-dhcp-dhclient.c b/src/dhcp-manager/nm-dhcp-dhclient.c index a951e3ea56..1d88da4463 100644 --- a/src/dhcp-manager/nm-dhcp-dhclient.c +++ b/src/dhcp-manager/nm-dhcp-dhclient.c @@ -44,6 +44,7 @@ #include "NetworkManagerUtils.h" #include "nm-dhcp-listener.h" #include "gsystem-local-alloc.h" +#include "nm-glib-compat.h" G_DEFINE_TYPE (NMDhcpDhclient, nm_dhcp_dhclient, NM_TYPE_DHCP_CLIENT) @@ -669,7 +670,7 @@ nm_dhcp_dhclient_class_init (NMDhcpDhclientClass *dhclient_class) static void __attribute__((constructor)) register_dhcp_dhclient (void) { - g_type_init (); + nm_g_type_init (); _nm_dhcp_client_register (NM_TYPE_DHCP_DHCLIENT, "dhclient", nm_dhcp_dhclient_get_path, diff --git a/src/dhcp-manager/nm-dhcp-dhcpcd.c b/src/dhcp-manager/nm-dhcp-dhcpcd.c index bea89dc981..acbc762096 100644 --- a/src/dhcp-manager/nm-dhcp-dhcpcd.c +++ b/src/dhcp-manager/nm-dhcp-dhcpcd.c @@ -39,6 +39,7 @@ #include "nm-logging.h" #include "NetworkManagerUtils.h" #include "nm-dhcp-listener.h" +#include "nm-glib-compat.h" G_DEFINE_TYPE (NMDhcpDhcpcd, nm_dhcp_dhcpcd, NM_TYPE_DHCP_CLIENT) @@ -213,7 +214,7 @@ nm_dhcp_dhcpcd_class_init (NMDhcpDhcpcdClass *dhcpcd_class) static void __attribute__((constructor)) register_dhcp_dhclient (void) { - g_type_init (); + nm_g_type_init (); _nm_dhcp_client_register (NM_TYPE_DHCP_DHCPCD, "dhcpcd", nm_dhcp_dhcpcd_get_path, diff --git a/src/dhcp-manager/nm-dhcp-systemd.c b/src/dhcp-manager/nm-dhcp-systemd.c index 05de2b340b..44a0d49e46 100644 --- a/src/dhcp-manager/nm-dhcp-systemd.c +++ b/src/dhcp-manager/nm-dhcp-systemd.c @@ -846,7 +846,7 @@ nm_dhcp_systemd_class_init (NMDhcpSystemdClass *sdhcp_class) static void __attribute__((constructor)) register_dhcp_dhclient (void) { - g_type_init (); + nm_g_type_init (); _nm_dhcp_client_register (NM_TYPE_DHCP_SYSTEMD, "internal", NULL, diff --git a/src/dnsmasq-manager/tests/test-dnsmasq-utils.c b/src/dnsmasq-manager/tests/test-dnsmasq-utils.c index f8120ffec3..fae4cae076 100644 --- a/src/dnsmasq-manager/tests/test-dnsmasq-utils.c +++ b/src/dnsmasq-manager/tests/test-dnsmasq-utils.c @@ -24,6 +24,9 @@ #include <arpa/inet.h> #include "nm-dnsmasq-utils.h" +#include "nm-logging.h" + +#include "nm-test-utils.h" static guint32 addr_to_num (const char *addr) @@ -101,14 +104,12 @@ test_address_ranges (void) /*******************************************/ +NMTST_DEFINE (); + int main (int argc, char **argv) { - g_test_init (&argc, &argv, NULL); - -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif + nmtst_init_assert_logging (&argc, &argv, "INFO", "DEFAULT"); g_test_add_func ("/dnsmasq-manager/address-ranges", test_address_ranges); diff --git a/src/main.c b/src/main.c index 4f906f5574..65ba7a61d7 100644 --- a/src/main.c +++ b/src/main.c @@ -273,9 +273,7 @@ main (int argc, char *argv[]) char *bad_domains = NULL; NMConfigCmdLineOptions *config_cli; -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif + nm_g_type_init (); _nm_utils_is_manager_process = TRUE; diff --git a/src/nm-iface-helper.c b/src/nm-iface-helper.c index ca7e654ce6..3cdd165965 100644 --- a/src/nm-iface-helper.c +++ b/src/nm-iface-helper.c @@ -307,10 +307,6 @@ do_early_setup (int *argc, char **argv[]) {NULL} }; -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif - if (!nm_main_utils_early_setup ("nm-iface-helper", argc, argv, @@ -340,9 +336,7 @@ main (int argc, char *argv[]) gconstpointer tmp; gs_free NMUtilsIPv6IfaceId *iid = NULL; -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif + nm_g_type_init (); setpgid (getpid (), getpid ()); diff --git a/src/platform/nm-platform-utils.c b/src/platform/nm-platform-utils.c index d3c62bddcd..2d064e1dd3 100644 --- a/src/platform/nm-platform-utils.c +++ b/src/platform/nm-platform-utils.c @@ -48,8 +48,11 @@ ethtool_get (const char *name, gpointer edata) if (!name || !*name) return FALSE; + if (strlen (name) >= IFNAMSIZ) + g_return_val_if_reached (FALSE); + memset (&ifr, 0, sizeof (ifr)); - strncpy (ifr.ifr_name, name, IFNAMSIZ); + strcpy (ifr.ifr_name, name); ifr.ifr_data = edata; fd = socket (PF_INET, SOCK_DGRAM, 0); diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index b534b273d2..d940cd7482 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -2521,20 +2521,39 @@ nm_platform_ip4_address_to_string (const NMPlatformIP4Address *address) void nm_platform_addr_flags2str (int flags, char *buf, size_t size) { - rtnl_addr_flags2str(flags, buf, size); - - /* There are two recent flags IFA_F_MANAGETEMPADDR and IFA_F_NOPREFIXROUTE. - * If libnl does not yet support them, add them by hand. - * These two flags were introduced together with the extended ifa_flags, - * so, check for that. - */ - if ((flags & IFA_F_MANAGETEMPADDR) && !nm_platform_check_support_libnl_extended_ifa_flags ()) { - strncat (buf, buf[0] ? "," IFA_F_MANAGETEMPADDR_STR : IFA_F_MANAGETEMPADDR_STR, - size - strlen (buf) - 1); - } - if ((flags & IFA_F_NOPREFIXROUTE) && !nm_platform_check_support_libnl_extended_ifa_flags ()) { - strncat (buf, buf[0] ? "," IFA_F_NOPREFIXROUTE_STR : IFA_F_NOPREFIXROUTE_STR, - size - strlen (buf) - 1); + if ( !NM_FLAGS_ANY (flags, IFA_F_MANAGETEMPADDR | IFA_F_NOPREFIXROUTE) + || nm_platform_check_support_libnl_extended_ifa_flags ()) + rtnl_addr_flags2str (flags, buf, size); + else { + /* There are two recent flags IFA_F_MANAGETEMPADDR and IFA_F_NOPREFIXROUTE. + * If libnl does not yet support them, add them by hand. + * These two flags were introduced together with the extended ifa_flags + * so check for nm_platform_check_support_libnl_extended_ifa_flags (). */ + gboolean has_other_unknown_flags = FALSE; + size_t len; + + /* if there are unknown flags to rtnl_addr_flags2str(), libnl appends ',' + * to indicate them. We want to keep this behavior, if there are other + * unknown flags present. */ + + rtnl_addr_flags2str (flags & ~(IFA_F_MANAGETEMPADDR | IFA_F_NOPREFIXROUTE), buf, size); + + len = strlen (buf); + if (len > 0) { + has_other_unknown_flags = (buf[len - 1] == ','); + if (!has_other_unknown_flags) + g_strlcat (buf, ",", size); + } + + if (NM_FLAGS_ALL (flags, IFA_F_MANAGETEMPADDR | IFA_F_NOPREFIXROUTE)) + g_strlcat (buf, IFA_F_MANAGETEMPADDR_STR","IFA_F_NOPREFIXROUTE_STR, size); + else if (NM_FLAGS_HAS (flags, IFA_F_MANAGETEMPADDR)) + g_strlcat (buf, IFA_F_MANAGETEMPADDR_STR, size); + else + g_strlcat (buf, IFA_F_NOPREFIXROUTE_STR, size); + + if (has_other_unknown_flags) + g_strlcat (buf, ",", size); } } @@ -2553,12 +2572,12 @@ nm_platform_addr_flags2str (int flags, char *buf, size_t size) const char * nm_platform_ip6_address_to_string (const NMPlatformIP6Address *address) { +#define S_FLAGS_PREFIX " flags " char s_flags[256]; char s_address[INET6_ADDRSTRLEN]; char s_peer[INET6_ADDRSTRLEN]; char str_lft[30], str_pref[30], str_time[50]; char str_dev[TO_STRING_DEV_BUF_SIZE]; - char *str_flags; char *str_peer = NULL; const char *str_lft_p, *str_pref_p, *str_time_p; gint32 now = nm_utils_get_monotonic_timestamp_s (); @@ -2574,9 +2593,11 @@ nm_platform_ip6_address_to_string (const NMPlatformIP6Address *address) _to_string_dev (NULL, address->ifindex, str_dev, sizeof (str_dev)); - nm_platform_addr_flags2str (address->flags, s_flags, sizeof (s_flags)); - - str_flags = s_flags[0] ? g_strconcat (" flags ", s_flags, NULL) : NULL; + nm_platform_addr_flags2str (address->flags, &s_flags[STRLEN (S_FLAGS_PREFIX)], sizeof (s_flags) - STRLEN (S_FLAGS_PREFIX)); + if (s_flags[STRLEN (S_FLAGS_PREFIX)] == '\0') + s_flags[0] = '\0'; + else + memcpy (s_flags, S_FLAGS_PREFIX, STRLEN (S_FLAGS_PREFIX)); str_lft_p = _lifetime_to_string (address->timestamp, address->lifetime ? address->lifetime : NM_PLATFORM_LIFETIME_PERMANENT, @@ -2592,9 +2613,8 @@ nm_platform_ip6_address_to_string (const NMPlatformIP6Address *address) s_address, address->plen, str_lft_p, str_pref_p, str_time_p, str_peer ? str_peer : "", str_dev, - str_flags ? str_flags : "", + s_flags, source_to_string (address->source)); - g_free (str_flags); g_free (str_peer); return _nm_platform_to_string_buffer; } diff --git a/src/platform/tests/dump.c b/src/platform/tests/dump.c index 54de1da70c..b1f8012350 100644 --- a/src/platform/tests/dump.c +++ b/src/platform/tests/dump.c @@ -123,9 +123,7 @@ dump_all (void) int main (int argc, char **argv) { -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif + nm_g_type_init (); g_assert (argc <= 2); if (argc > 1 && !g_strcmp0 (argv[1], "--fake")) diff --git a/src/platform/tests/monitor.c b/src/platform/tests/monitor.c index 9aff104763..a989e63e14 100644 --- a/src/platform/tests/monitor.c +++ b/src/platform/tests/monitor.c @@ -6,15 +6,14 @@ #include "nm-fake-platform.h" #include "nm-linux-platform.h" #include "nm-logging.h" +#include "nm-glib-compat.h" int main (int argc, char **argv) { GMainLoop *loop; -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif + nm_g_type_init (); loop = g_main_loop_new (NULL, FALSE); nm_logging_setup ("debug", NULL, NULL, NULL); diff --git a/src/platform/tests/platform.c b/src/platform/tests/platform.c index 60555414da..3e43ca57bd 100644 --- a/src/platform/tests/platform.c +++ b/src/platform/tests/platform.c @@ -866,9 +866,7 @@ main (int argc, char **argv) const command_t *command = NULL; gboolean status = TRUE; -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif + nm_g_type_init (); if (*argv && !g_strcmp0 (argv[1], "--fake")) { nm_fake_platform_setup (); diff --git a/src/platform/tests/test-general.c b/src/platform/tests/test-general.c index 0a397b3788..94d9650365 100644 --- a/src/platform/tests/test-general.c +++ b/src/platform/tests/test-general.c @@ -53,6 +53,37 @@ test_link_get_all (void) /******************************************************************/ +static void +test_nm_platform_ip6_address_to_string_flags (void) +{ + NMPlatformIP6Address addr = { 0 }; + + g_assert_cmpstr (strstr (nm_platform_ip6_address_to_string (&addr), " flags "), ==, NULL); + + addr.flags = IFA_F_MANAGETEMPADDR; + nmtst_assert_str_has_substr (nm_platform_ip6_address_to_string (&addr), " flags mngtmpaddr "); + + addr.flags = IFA_F_NOPREFIXROUTE; + nmtst_assert_str_has_substr (nm_platform_ip6_address_to_string (&addr), " flags noprefixroute "); + + addr.flags = IFA_F_MANAGETEMPADDR | IFA_F_NOPREFIXROUTE; + nmtst_assert_str_has_substr (nm_platform_ip6_address_to_string (&addr), " flags mngtmpaddr,noprefixroute "); + + addr.flags = IFA_F_TENTATIVE | IFA_F_NOPREFIXROUTE; + nmtst_assert_str_has_substr (nm_platform_ip6_address_to_string (&addr), " flags tentative,noprefixroute "); + + addr.flags = IFA_F_TENTATIVE | IFA_F_PERMANENT | IFA_F_MANAGETEMPADDR| IFA_F_NOPREFIXROUTE; + nmtst_assert_str_has_substr (nm_platform_ip6_address_to_string (&addr), " flags tentative,permanent,mngtmpaddr,noprefixroute "); + + addr.flags = IFA_F_TENTATIVE | IFA_F_PERMANENT | IFA_F_MANAGETEMPADDR| IFA_F_NOPREFIXROUTE | 0x8000; + nmtst_assert_str_has_substr (nm_platform_ip6_address_to_string (&addr), " flags tentative,permanent,mngtmpaddr,noprefixroute, "); + + addr.flags = IFA_F_TENTATIVE | IFA_F_PERMANENT | IFA_F_MANAGETEMPADDR| IFA_F_NOPREFIXROUTE | ((G_MAXUINT - (G_MAXUINT >> 1)) >> 1); + nmtst_assert_str_has_substr (nm_platform_ip6_address_to_string (&addr), " flags tentative,permanent,mngtmpaddr,noprefixroute, "); +} + +/******************************************************************/ + NMTST_DEFINE (); int @@ -62,6 +93,8 @@ main (int argc, char **argv) g_test_add_func ("/general/init_linux_platform", test_init_linux_platform); g_test_add_func ("/general/link_get_all", test_link_get_all); + g_test_add_func ("/general/nm_platform_ip6_address_to_string/flags", test_nm_platform_ip6_address_to_string_flags); return g_test_run (); } + diff --git a/src/ppp-manager/nm-pppd-plugin.c b/src/ppp-manager/nm-pppd-plugin.c index d5e8d70725..0a3bcca8d3 100644 --- a/src/ppp-manager/nm-pppd-plugin.c +++ b/src/ppp-manager/nm-pppd-plugin.c @@ -38,6 +38,7 @@ #include "nm-dbus-interface.h" #include "nm-pppd-plugin.h" #include "nm-ppp-status.h" +#include "nm-glib-compat.h" int plugin_init (void); @@ -372,9 +373,7 @@ plugin_init (void) GDBusConnection *bus; GError *err = NULL; -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif + nm_g_type_init (); g_message ("nm-ppp-plugin: (%s): initializing", __func__); diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c index fae0f025db..cc0a5b6b53 100644 --- a/src/settings/nm-settings-connection.c +++ b/src/settings/nm-settings-connection.c @@ -38,32 +38,75 @@ #include "nm-properties-changed-signal.h" #include "nm-core-internal.h" #include "nm-glib-compat.h" +#include "gsystem-local-alloc.h" #define SETTINGS_TIMESTAMPS_FILE NMSTATEDIR "/timestamps" #define SETTINGS_SEEN_BSSIDS_FILE NMSTATEDIR "/seen-bssids" -static void impl_settings_connection_get_settings (NMSettingsConnection *connection, + +#define _LOG_DOMAIN LOGD_SETTINGS +#define _LOG_PREFIX_NAME "settings-connection" + +#define _LOG(level, domain, self, ...) \ + G_STMT_START { \ + const NMLogLevel __level = (level); \ + const NMLogDomain __domain = (domain); \ + \ + if (nm_logging_enabled (__level, __domain)) { \ + char __prefix[128]; \ + const char *__p_prefix = _LOG_PREFIX_NAME; \ + const void *const __self = (self); \ + \ + if (__self) { \ + const char *__uuid = nm_connection_get_uuid ((NMConnection *) __self); \ + \ + g_snprintf (__prefix, sizeof (__prefix), "%s[%p%s%s]", _LOG_PREFIX_NAME, __self, __uuid ? "," : "", __uuid ? __uuid : ""); \ + __p_prefix = __prefix; \ + } \ + _nm_log (__level, __domain, 0, \ + "%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ + __p_prefix _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ + } \ + } G_STMT_END +#define _LOG_LEVEL_ENABLED(level, domain) \ + ( nm_logging_enabled ((level), (domain)) ) + +#ifdef NM_MORE_LOGGING +#define _LOGT_ENABLED() _LOG_LEVEL_ENABLED (LOGL_TRACE, _LOG_DOMAIN) +#define _LOGT(...) _LOG (LOGL_TRACE, _LOG_DOMAIN, self, __VA_ARGS__) +#else +#define _LOGT_ENABLED() FALSE +#define _LOGT(...) G_STMT_START { if (FALSE) { _LOG (LOGL_TRACE, _LOG_DOMAIN, self, __VA_ARGS__); } } G_STMT_END +#endif + +#define _LOGD(...) _LOG (LOGL_DEBUG, _LOG_DOMAIN, self, __VA_ARGS__) +#define _LOGI(...) _LOG (LOGL_INFO , _LOG_DOMAIN, self, __VA_ARGS__) +#define _LOGW(...) _LOG (LOGL_WARN , _LOG_DOMAIN, self, __VA_ARGS__) +#define _LOGE(...) _LOG (LOGL_ERR , _LOG_DOMAIN, self, __VA_ARGS__) + + +static void impl_settings_connection_get_settings (NMSettingsConnection *self, DBusGMethodInvocation *context); -static void impl_settings_connection_update (NMSettingsConnection *connection, +static void impl_settings_connection_update (NMSettingsConnection *self, GHashTable *new_settings, DBusGMethodInvocation *context); -static void impl_settings_connection_update_unsaved (NMSettingsConnection *connection, +static void impl_settings_connection_update_unsaved (NMSettingsConnection *self, GHashTable *new_settings, DBusGMethodInvocation *context); -static void impl_settings_connection_save (NMSettingsConnection *connection, +static void impl_settings_connection_save (NMSettingsConnection *self, DBusGMethodInvocation *context); -static void impl_settings_connection_delete (NMSettingsConnection *connection, +static void impl_settings_connection_delete (NMSettingsConnection *self, DBusGMethodInvocation *context); -static void impl_settings_connection_get_secrets (NMSettingsConnection *connection, +static void impl_settings_connection_get_secrets (NMSettingsConnection *self, const gchar *setting_name, DBusGMethodInvocation *context); -static void impl_settings_connection_clear_secrets (NMSettingsConnection *connection, +static void impl_settings_connection_clear_secrets (NMSettingsConnection *self, DBusGMethodInvocation *context); #include "nm-settings-connection-glue.h" @@ -145,7 +188,7 @@ typedef gboolean (*ForEachSecretFunc) (GHashTableIter *iter, gpointer user_data); static void -for_each_secret (NMConnection *connection, +for_each_secret (NMConnection *self, GHashTable *secrets, gboolean remove_non_secrets, ForEachSecretFunc callback, @@ -188,7 +231,7 @@ for_each_secret (NMConnection *connection, * from the connection data, since flags aren't secrets. What we're * iterating here is just the secrets, not a whole connection. */ - setting = nm_connection_get_setting_by_name (connection, setting_name); + setting = nm_connection_get_setting_by_name (self, setting_name); if (setting == NULL) continue; @@ -491,6 +534,9 @@ nm_settings_connection_replace_settings (NMSettingsConnection *self, nm_utils_log_connection_diff (new_connection, NM_CONNECTION (self), LOGL_DEBUG, LOGD_CORE, log_diff_name, "++ "); nm_connection_replace_settings_from_connection (NM_CONNECTION (self), new_connection); + + _LOGD ("replace settings from connection %p (%s)", new_connection, nm_connection_get_id (NM_CONNECTION (self))); + nm_settings_connection_set_flags (self, NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED | NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED_ASSUMED, FALSE); @@ -529,7 +575,7 @@ nm_settings_connection_replace_settings (NMSettingsConnection *self, } static void -ignore_cb (NMSettingsConnection *connection, +ignore_cb (NMSettingsConnection *self, GError *error, gpointer user_data) { @@ -586,49 +632,49 @@ commit_changes (NMSettingsConnection *self, } void -nm_settings_connection_commit_changes (NMSettingsConnection *connection, +nm_settings_connection_commit_changes (NMSettingsConnection *self, NMSettingsConnectionCommitFunc callback, gpointer user_data) { - g_return_if_fail (NM_IS_SETTINGS_CONNECTION (connection)); + g_return_if_fail (NM_IS_SETTINGS_CONNECTION (self)); - if (NM_SETTINGS_CONNECTION_GET_CLASS (connection)->commit_changes) { - NM_SETTINGS_CONNECTION_GET_CLASS (connection)->commit_changes (connection, - callback ? callback : ignore_cb, - user_data); + if (NM_SETTINGS_CONNECTION_GET_CLASS (self)->commit_changes) { + NM_SETTINGS_CONNECTION_GET_CLASS (self)->commit_changes (self, + callback ? callback : ignore_cb, + user_data); } else { GError *error = g_error_new (NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "%s: %s:%d commit_changes() unimplemented", __func__, __FILE__, __LINE__); if (callback) - callback (connection, error, user_data); + callback (self, error, user_data); g_error_free (error); } } void -nm_settings_connection_delete (NMSettingsConnection *connection, +nm_settings_connection_delete (NMSettingsConnection *self, NMSettingsConnectionDeleteFunc callback, gpointer user_data) { - g_return_if_fail (NM_IS_SETTINGS_CONNECTION (connection)); + g_return_if_fail (NM_IS_SETTINGS_CONNECTION (self)); - if (NM_SETTINGS_CONNECTION_GET_CLASS (connection)->delete) { - NM_SETTINGS_CONNECTION_GET_CLASS (connection)->delete (connection, - callback ? callback : ignore_cb, - user_data); + if (NM_SETTINGS_CONNECTION_GET_CLASS (self)->delete) { + NM_SETTINGS_CONNECTION_GET_CLASS (self)->delete (self, + callback ? callback : ignore_cb, + user_data); } else { GError *error = g_error_new (NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "%s: %s:%d delete() unimplemented", __func__, __FILE__, __LINE__); if (callback) - callback (connection, error, user_data); + callback (self, error, user_data); g_error_free (error); } } static void -remove_entry_from_db (NMSettingsConnection *connection, const char* db_name) +remove_entry_from_db (NMSettingsConnection *self, const char* db_name) { GKeyFile *key_file; const char *db_file; @@ -647,7 +693,7 @@ remove_entry_from_db (NMSettingsConnection *connection, const char* db_name) gsize len; GError *error = NULL; - connection_uuid = nm_connection_get_uuid (NM_CONNECTION (connection)); + connection_uuid = nm_connection_get_uuid (NM_CONNECTION (self)); g_key_file_remove_key (key_file, db_name, connection_uuid, NULL); data = g_key_file_to_data (key_file, &len, &error); @@ -656,7 +702,7 @@ remove_entry_from_db (NMSettingsConnection *connection, const char* db_name) g_free (data); } if (error) { - nm_log_warn (LOGD_SETTINGS, "error writing %s file '%s': %s", db_name, db_file, error->message); + _LOGW ("error writing %s file '%s': %s", db_name, db_file, error->message); g_error_free (error); } } @@ -664,39 +710,39 @@ remove_entry_from_db (NMSettingsConnection *connection, const char* db_name) } static void -do_delete (NMSettingsConnection *connection, +do_delete (NMSettingsConnection *self, NMSettingsConnectionDeleteFunc callback, gpointer user_data) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection); + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); NMConnection *for_agents; - g_object_ref (connection); - set_visible (connection, FALSE); + g_object_ref (self); + set_visible (self, FALSE); /* Tell agents to remove secrets for this connection */ - for_agents = nm_simple_connection_new_clone (NM_CONNECTION (connection)); + for_agents = nm_simple_connection_new_clone (NM_CONNECTION (self)); nm_connection_clear_secrets (for_agents); nm_agent_manager_delete_secrets (priv->agent_mgr, for_agents); g_object_unref (for_agents); /* Remove timestamp from timestamps database file */ - remove_entry_from_db (connection, "timestamps"); + remove_entry_from_db (self, "timestamps"); /* Remove connection from seen-bssids database file */ - remove_entry_from_db (connection, "seen-bssids"); + remove_entry_from_db (self, "seen-bssids"); - nm_settings_connection_signal_remove (connection); + nm_settings_connection_signal_remove (self); - callback (connection, NULL, user_data); + callback (self, NULL, user_data); - g_object_unref (connection); + g_object_unref (self); } /**************************************************************/ static gboolean -supports_secrets (NMSettingsConnection *connection, const char *setting_name) +supports_secrets (NMSettingsConnection *self, const char *setting_name) { /* All secrets supported */ return TRUE; @@ -737,13 +783,13 @@ has_system_owned_secrets (GHashTableIter *iter, } static void -new_secrets_commit_cb (NMSettingsConnection *connection, +new_secrets_commit_cb (NMSettingsConnection *self, GError *error, gpointer user_data) { if (error) { - nm_log_warn (LOGD_SETTINGS, "Error saving new secrets to backing storage: (%d) %s", - error->code, error->message ? error->message : "(unknown)"); + _LOGW ("Error saving new secrets to backing storage: (%d) %s", + error->code, error->message ? error->message : "(unknown)"); } } @@ -770,12 +816,11 @@ agent_secrets_done_cb (NMAgentManager *manager, gboolean agent_had_system = FALSE; if (error) { - nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) secrets request error: (%d) %s", - nm_connection_get_uuid (NM_CONNECTION (self)), - setting_name, - call_id, - error->code, - error->message ? error->message : "(unknown)"); + _LOGD ("(%s:%u) secrets request error: (%d) %s", + setting_name, + call_id, + error->code, + error->message ? error->message : "(unknown)"); callback (self, call_id, NULL, setting_name, error, callback_data); return; @@ -792,11 +837,10 @@ agent_secrets_done_cb (NMAgentManager *manager, g_assert (secrets); if (agent_dbus_owner) { - nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) secrets returned from agent %s", - nm_connection_get_uuid (NM_CONNECTION (self)), - setting_name, - call_id, - agent_dbus_owner); + _LOGD ("(%s:%u) secrets returned from agent %s", + setting_name, + call_id, + agent_dbus_owner); /* If the agent returned any system-owned secrets (initial connect and no * secrets given when the connection was created, or something like that) @@ -810,36 +854,32 @@ agent_secrets_done_cb (NMAgentManager *manager, /* No user interaction was allowed when requesting secrets; the * agent is being bad. Remove system-owned secrets. */ - nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) interaction forbidden but agent %s returned system secrets", - nm_connection_get_uuid (NM_CONNECTION (self)), - setting_name, - call_id, - agent_dbus_owner); + _LOGD ("(%s:%u) interaction forbidden but agent %s returned system secrets", + setting_name, + call_id, + agent_dbus_owner); for_each_secret (NM_CONNECTION (self), secrets, FALSE, clear_nonagent_secrets, NULL); } else if (agent_has_modify == FALSE) { /* Agent didn't successfully authenticate; clear system-owned secrets * from the secrets the agent returned. */ - nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) agent failed to authenticate but provided system secrets", - nm_connection_get_uuid (NM_CONNECTION (self)), - setting_name, - call_id); + _LOGD ("(%s:%u) agent failed to authenticate but provided system secrets", + setting_name, + call_id); for_each_secret (NM_CONNECTION (self), secrets, FALSE, clear_nonagent_secrets, NULL); } } } else { - nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) existing secrets returned", - nm_connection_get_uuid (NM_CONNECTION (self)), - setting_name, - call_id); + _LOGD ("(%s:%u) existing secrets returned", + setting_name, + call_id); } - nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) secrets request completed", - nm_connection_get_uuid (NM_CONNECTION (self)), - setting_name, - call_id); + _LOGD ("(%s:%u) secrets request completed", + setting_name, + call_id); /* If no user interaction was allowed, make sure that no "unsaved" secrets * came back. Unsaved secrets by definition require user interaction. @@ -872,34 +912,30 @@ agent_secrets_done_cb (NMAgentManager *manager, * nothing has changed, since agent-owned secrets don't get saved here. */ if (agent_had_system) { - nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) saving new secrets to backing storage", - nm_connection_get_uuid (NM_CONNECTION (self)), - setting_name, - call_id); + _LOGD ("(%s:%u) saving new secrets to backing storage", + setting_name, + call_id); nm_settings_connection_commit_changes (self, new_secrets_commit_cb, NULL); } else { - nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) new agent secrets processed", - nm_connection_get_uuid (NM_CONNECTION (self)), - setting_name, - call_id); + _LOGD ("(%s:%u) new agent secrets processed", + setting_name, + call_id); } } else { - nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) failed to update with agent secrets: (%d) %s", - nm_connection_get_uuid (NM_CONNECTION (self)), - setting_name, - call_id, - local ? local->code : -1, - (local && local->message) ? local->message : "(unknown)"); + _LOGD ("(%s:%u) failed to update with agent secrets: (%d) %s", + setting_name, + call_id, + local ? local->code : -1, + (local && local->message) ? local->message : "(unknown)"); } g_variant_unref (secrets_dict); } else { - nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) failed to update with existing secrets: (%d) %s", - nm_connection_get_uuid (NM_CONNECTION (self)), - setting_name, - call_id, - local ? local->code : -1, - (local && local->message) ? local->message : "(unknown)"); + _LOGD ("(%s:%u) failed to update with existing secrets: (%d) %s", + setting_name, + call_id, + local ? local->code : -1, + (local && local->message) ? local->message : "(unknown)"); } callback (self, call_id, agent_username, setting_name, local, callback_data); @@ -910,7 +946,7 @@ agent_secrets_done_cb (NMAgentManager *manager, /** * nm_settings_connection_get_secrets: - * @connection: the #NMSettingsConnection + * @self: the #NMSettingsConnection * @subject: the #NMAuthSubject originating the request * @setting_name: the setting to return secrets for * @flags: flags to modify the secrets request @@ -938,7 +974,7 @@ nm_settings_connection_get_secrets (NMSettingsConnection *self, GVariant *existing_secrets; GHashTable *existing_secrets_hash; guint32 call_id = 0; - char *joined_hints = NULL; + gs_free char *joined_hints = NULL; /* Use priv->secrets to work around the fact that nm_connection_clear_secrets() * will clear secrets on this object's settings. @@ -976,17 +1012,11 @@ nm_settings_connection_get_secrets (NMSettingsConnection *self, if (existing_secrets) g_variant_unref (existing_secrets); - if (nm_logging_enabled (LOGL_DEBUG, LOGD_SETTINGS)) { - if (hints) - joined_hints = g_strjoinv (",", (char **) hints); - nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) secrets requested flags 0x%X hints '%s'", - nm_connection_get_uuid (NM_CONNECTION (self)), - setting_name, - call_id, - flags, - joined_hints ? joined_hints : "(none)"); - g_free (joined_hints); - } + _LOGD ("(%s:%u) secrets requested flags 0x%X hints '%s'", + setting_name, + call_id, + flags, + (hints && hints[0]) ? (joined_hints = g_strjoinv (",", (char **) hints)) : "(none)"); return call_id; } @@ -997,9 +1027,8 @@ nm_settings_connection_cancel_secrets (NMSettingsConnection *self, { NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); - nm_log_dbg (LOGD_SETTINGS, "(%s:%u) secrets canceled", - nm_connection_get_uuid (NM_CONNECTION (self)), - call_id); + _LOGD ("(%u) secrets canceled", + call_id); priv->reqs = g_slist_remove (priv->reqs, GUINT_TO_POINTER (call_id)); nm_agent_manager_cancel_secrets (priv->agent_mgr, call_id); @@ -1007,7 +1036,7 @@ nm_settings_connection_cancel_secrets (NMSettingsConnection *self, /**** User authorization **************************************/ -typedef void (*AuthCallback) (NMSettingsConnection *connection, +typedef void (*AuthCallback) (NMSettingsConnection *self, DBusGMethodInvocation *context, NMAuthSubject *subject, GError *error, @@ -1138,13 +1167,13 @@ auth_start (NMSettingsConnection *self, /**** DBus method handlers ************************************/ static gboolean -check_writable (NMConnection *connection, GError **error) +check_writable (NMConnection *self, GError **error) { NMSettingConnection *s_con; - g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE); + g_return_val_if_fail (NM_IS_CONNECTION (self), FALSE); - s_con = nm_connection_get_setting_connection (connection); + s_con = nm_connection_get_setting_connection (self); if (!s_con) { g_set_error_literal (error, NM_SETTINGS_ERROR, @@ -1274,11 +1303,11 @@ has_some_secrets_cb (NMSetting *setting, } static gboolean -any_secrets_present (NMConnection *connection) +any_secrets_present (NMConnection *self) { gboolean has_secrets = FALSE; - nm_connection_for_each_setting_value (connection, has_some_secrets_cb, &has_secrets); + nm_connection_for_each_setting_value (self, has_some_secrets_cb, &has_secrets); return has_secrets; } @@ -1516,7 +1545,7 @@ impl_settings_connection_save (NMSettingsConnection *self, } static void -con_delete_cb (NMSettingsConnection *connection, +con_delete_cb (NMSettingsConnection *self, GError *error, gpointer user_data) { @@ -1529,7 +1558,7 @@ con_delete_cb (NMSettingsConnection *connection, } static void -delete_auth_cb (NMSettingsConnection *self, +delete_auth_cb (NMSettingsConnection *self, DBusGMethodInvocation *context, NMAuthSubject *subject, GError *error, @@ -1544,7 +1573,7 @@ delete_auth_cb (NMSettingsConnection *self, } static const char * -get_modify_permission_basic (NMSettingsConnection *connection) +get_modify_permission_basic (NMSettingsConnection *self) { NMSettingConnection *s_con; @@ -1552,7 +1581,7 @@ get_modify_permission_basic (NMSettingsConnection *connection) * we use the 'modify.own' permission instead of 'modify.system'. If the * request affects more than just the caller, require 'modify.system'. */ - s_con = nm_connection_get_setting_connection (NM_CONNECTION (connection)); + s_con = nm_connection_get_setting_connection (NM_CONNECTION (self)); g_assert (s_con); if (nm_setting_connection_get_num_permissions (s_con) == 1) return NM_AUTH_PERMISSION_SETTINGS_MODIFY_OWN; @@ -1693,7 +1722,7 @@ clear_secrets_cb (NMSettingsConnection *self, } static void -dbus_clear_secrets_auth_cb (NMSettingsConnection *self, +dbus_clear_secrets_auth_cb (NMSettingsConnection *self, DBusGMethodInvocation *context, NMAuthSubject *subject, GError *error, @@ -1816,7 +1845,7 @@ nm_settings_connection_set_flags_all (NMSettingsConnection *self, NMSettingsConn /** * nm_settings_connection_get_timestamp: - * @connection: the #NMSettingsConnection + * @self: the #NMSettingsConnection * @out_timestamp: the connection's timestamp * * Returns the time (in seconds since the Unix epoch) when the connection @@ -1825,19 +1854,19 @@ nm_settings_connection_set_flags_all (NMSettingsConnection *self, NMSettingsConn * Returns: %TRUE if the timestamp has ever been set, otherwise %FALSE. **/ gboolean -nm_settings_connection_get_timestamp (NMSettingsConnection *connection, +nm_settings_connection_get_timestamp (NMSettingsConnection *self, guint64 *out_timestamp) { - g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (connection), FALSE); + g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (self), FALSE); if (out_timestamp) - *out_timestamp = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection)->timestamp; - return NM_SETTINGS_CONNECTION_GET_PRIVATE (connection)->timestamp_set; + *out_timestamp = NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->timestamp; + return NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->timestamp_set; } /** * nm_settings_connection_update_timestamp: - * @connection: the #NMSettingsConnection + * @self: the #NMSettingsConnection * @timestamp: timestamp to set into the connection and to store into * the timestamps database * @flush_to_disk: if %TRUE, commit timestamp update to persistent storage @@ -1845,18 +1874,18 @@ nm_settings_connection_get_timestamp (NMSettingsConnection *connection, * Updates the connection and timestamps database with the provided timestamp. **/ void -nm_settings_connection_update_timestamp (NMSettingsConnection *connection, +nm_settings_connection_update_timestamp (NMSettingsConnection *self, guint64 timestamp, gboolean flush_to_disk) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection); + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); const char *connection_uuid; GKeyFile *timestamps_file; char *data, *tmp; gsize len; GError *error = NULL; - g_return_if_fail (NM_IS_SETTINGS_CONNECTION (connection)); + g_return_if_fail (NM_IS_SETTINGS_CONNECTION (self)); /* Update timestamp in private storage */ priv->timestamp = timestamp; @@ -1869,11 +1898,11 @@ nm_settings_connection_update_timestamp (NMSettingsConnection *connection, timestamps_file = g_key_file_new (); if (!g_key_file_load_from_file (timestamps_file, SETTINGS_TIMESTAMPS_FILE, G_KEY_FILE_KEEP_COMMENTS, &error)) { if (!(error->domain == G_FILE_ERROR && error->code == G_FILE_ERROR_NOENT)) - nm_log_warn (LOGD_SETTINGS, "error parsing timestamps file '%s': %s", SETTINGS_TIMESTAMPS_FILE, error->message); + _LOGW ("error parsing timestamps file '%s': %s", SETTINGS_TIMESTAMPS_FILE, error->message); g_clear_error (&error); } - connection_uuid = nm_connection_get_uuid (NM_CONNECTION (connection)); + connection_uuid = nm_connection_get_uuid (NM_CONNECTION (self)); tmp = g_strdup_printf ("%" G_GUINT64_FORMAT, timestamp); g_key_file_set_value (timestamps_file, "timestamps", connection_uuid, tmp); g_free (tmp); @@ -1884,7 +1913,7 @@ nm_settings_connection_update_timestamp (NMSettingsConnection *connection, g_free (data); } if (error) { - nm_log_warn (LOGD_SETTINGS, "error saving timestamp to file '%s': %s", SETTINGS_TIMESTAMPS_FILE, error->message); + _LOGW ("error saving timestamp to file '%s': %s", SETTINGS_TIMESTAMPS_FILE, error->message); g_error_free (error); } g_key_file_free (timestamps_file); @@ -1892,27 +1921,27 @@ nm_settings_connection_update_timestamp (NMSettingsConnection *connection, /** * nm_settings_connection_read_and_fill_timestamp: - * @connection: the #NMSettingsConnection + * @self: the #NMSettingsConnection * * Retrieves timestamp of the connection's last usage from database file and * stores it into the connection private data. **/ void -nm_settings_connection_read_and_fill_timestamp (NMSettingsConnection *connection) +nm_settings_connection_read_and_fill_timestamp (NMSettingsConnection *self) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection); + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); const char *connection_uuid; guint64 timestamp = 0; GKeyFile *timestamps_file; GError *err = NULL; char *tmp_str; - g_return_if_fail (NM_IS_SETTINGS_CONNECTION (connection)); + g_return_if_fail (NM_IS_SETTINGS_CONNECTION (self)); /* Get timestamp from database file */ timestamps_file = g_key_file_new (); g_key_file_load_from_file (timestamps_file, SETTINGS_TIMESTAMPS_FILE, G_KEY_FILE_KEEP_COMMENTS, NULL); - connection_uuid = nm_connection_get_uuid (NM_CONNECTION (connection)); + connection_uuid = nm_connection_get_uuid (NM_CONNECTION (self)); tmp_str = g_key_file_get_value (timestamps_file, "timestamps", connection_uuid, &err); if (tmp_str) { timestamp = g_ascii_strtoull (tmp_str, NULL, 10); @@ -1924,8 +1953,8 @@ nm_settings_connection_read_and_fill_timestamp (NMSettingsConnection *connection priv->timestamp = timestamp; priv->timestamp_set = TRUE; } else { - nm_log_dbg (LOGD_SETTINGS, "failed to read connection timestamp for '%s': (%d) %s", - connection_uuid, err->code, err->message); + _LOGD ("failed to read connection timestamp: (%d) %s", + err->code, err->message); g_clear_error (&err); } g_key_file_free (timestamps_file); @@ -1933,7 +1962,7 @@ nm_settings_connection_read_and_fill_timestamp (NMSettingsConnection *connection /** * nm_settings_connection_get_seen_bssids: - * @connection: the #NMSettingsConnection + * @self: the #NMSettingsConnection * * Returns current list of seen BSSIDs for the connection. * @@ -1941,14 +1970,14 @@ nm_settings_connection_read_and_fill_timestamp (NMSettingsConnection *connection * The caller is responsible for freeing the list, but not the content. **/ char ** -nm_settings_connection_get_seen_bssids (NMSettingsConnection *connection) +nm_settings_connection_get_seen_bssids (NMSettingsConnection *self) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection); + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); GHashTableIter iter; char **bssids, *bssid; int i; - g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (connection), NULL); + g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (self), NULL); bssids = g_new (char *, g_hash_table_size (priv->seen_bssids) + 1); @@ -1963,34 +1992,34 @@ nm_settings_connection_get_seen_bssids (NMSettingsConnection *connection) /** * nm_settings_connection_has_seen_bssid: - * @connection: the #NMSettingsConnection + * @self: the #NMSettingsConnection * @bssid: the BSSID to check the seen BSSID list for * * Returns: %TRUE if the given @bssid is in the seen BSSIDs list **/ gboolean -nm_settings_connection_has_seen_bssid (NMSettingsConnection *connection, +nm_settings_connection_has_seen_bssid (NMSettingsConnection *self, const char *bssid) { - g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (connection), FALSE); + g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (self), FALSE); g_return_val_if_fail (bssid != NULL, FALSE); - return !!g_hash_table_lookup (NM_SETTINGS_CONNECTION_GET_PRIVATE (connection)->seen_bssids, bssid); + return !!g_hash_table_lookup (NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->seen_bssids, bssid); } /** * nm_settings_connection_add_seen_bssid: - * @connection: the #NMSettingsConnection + * @self: the #NMSettingsConnection * @seen_bssid: BSSID to set into the connection and to store into * the seen-bssids database * * Updates the connection and seen-bssids database with the provided BSSID. **/ void -nm_settings_connection_add_seen_bssid (NMSettingsConnection *connection, +nm_settings_connection_add_seen_bssid (NMSettingsConnection *self, const char *seen_bssid) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection); + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); const char *connection_uuid; GKeyFile *seen_bssids_file; char *data, *bssid_str; @@ -2021,13 +2050,13 @@ nm_settings_connection_add_seen_bssid (NMSettingsConnection *connection, g_key_file_set_list_separator (seen_bssids_file, ','); if (!g_key_file_load_from_file (seen_bssids_file, SETTINGS_SEEN_BSSIDS_FILE, G_KEY_FILE_KEEP_COMMENTS, &error)) { if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT)) { - nm_log_warn (LOGD_SETTINGS, "error parsing seen-bssids file '%s': %s", - SETTINGS_SEEN_BSSIDS_FILE, error->message); + _LOGW ("error parsing seen-bssids file '%s': %s", + SETTINGS_SEEN_BSSIDS_FILE, error->message); } g_clear_error (&error); } - connection_uuid = nm_connection_get_uuid (NM_CONNECTION (connection)); + connection_uuid = nm_connection_get_uuid (NM_CONNECTION (self)); g_key_file_set_string_list (seen_bssids_file, "seen-bssids", connection_uuid, list, n); g_free (list); @@ -2039,23 +2068,23 @@ nm_settings_connection_add_seen_bssid (NMSettingsConnection *connection, g_key_file_free (seen_bssids_file); if (error) { - nm_log_warn (LOGD_SETTINGS, "error saving seen-bssids to file '%s': %s", - SETTINGS_SEEN_BSSIDS_FILE, error->message); + _LOGW ("error saving seen-bssids to file '%s': %s", + SETTINGS_SEEN_BSSIDS_FILE, error->message); g_error_free (error); } } /** * nm_settings_connection_read_and_fill_seen_bssids: - * @connection: the #NMSettingsConnection + * @self: the #NMSettingsConnection * * Retrieves seen BSSIDs of the connection from database file and stores then into the * connection private data. **/ void -nm_settings_connection_read_and_fill_seen_bssids (NMSettingsConnection *connection) +nm_settings_connection_read_and_fill_seen_bssids (NMSettingsConnection *self) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection); + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); const char *connection_uuid; GKeyFile *seen_bssids_file; char **tmp_strv = NULL; @@ -2066,7 +2095,7 @@ nm_settings_connection_read_and_fill_seen_bssids (NMSettingsConnection *connecti seen_bssids_file = g_key_file_new (); g_key_file_set_list_separator (seen_bssids_file, ','); if (g_key_file_load_from_file (seen_bssids_file, SETTINGS_SEEN_BSSIDS_FILE, G_KEY_FILE_KEEP_COMMENTS, NULL)) { - connection_uuid = nm_connection_get_uuid (NM_CONNECTION (connection)); + connection_uuid = nm_connection_get_uuid (NM_CONNECTION (self)); tmp_strv = g_key_file_get_string_list (seen_bssids_file, "seen-bssids", connection_uuid, &len, NULL); } g_key_file_free (seen_bssids_file); @@ -2083,7 +2112,7 @@ nm_settings_connection_read_and_fill_seen_bssids (NMSettingsConnection *connecti * seen-bssids list from the deprecated seen-bssids property of the * wifi setting. */ - s_wifi = nm_connection_get_setting_wireless (NM_CONNECTION (connection)); + s_wifi = nm_connection_get_setting_wireless (NM_CONNECTION (self)); if (s_wifi) { len = nm_setting_wireless_get_num_seen_bssids (s_wifi); for (i = 0; i < len; i++) { @@ -2099,16 +2128,16 @@ nm_settings_connection_read_and_fill_seen_bssids (NMSettingsConnection *connecti #define AUTOCONNECT_RESET_RETRIES_TIMER 300 int -nm_settings_connection_get_autoconnect_retries (NMSettingsConnection *connection) +nm_settings_connection_get_autoconnect_retries (NMSettingsConnection *self) { - return NM_SETTINGS_CONNECTION_GET_PRIVATE (connection)->autoconnect_retries; + return NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->autoconnect_retries; } void -nm_settings_connection_set_autoconnect_retries (NMSettingsConnection *connection, +nm_settings_connection_set_autoconnect_retries (NMSettingsConnection *self, int retries) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection); + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); priv->autoconnect_retries = retries; if (retries) @@ -2118,34 +2147,34 @@ nm_settings_connection_set_autoconnect_retries (NMSettingsConnection *connection } void -nm_settings_connection_reset_autoconnect_retries (NMSettingsConnection *connection) +nm_settings_connection_reset_autoconnect_retries (NMSettingsConnection *self) { - nm_settings_connection_set_autoconnect_retries (connection, AUTOCONNECT_RETRIES_DEFAULT); + nm_settings_connection_set_autoconnect_retries (self, AUTOCONNECT_RETRIES_DEFAULT); } gint32 -nm_settings_connection_get_autoconnect_retry_time (NMSettingsConnection *connection) +nm_settings_connection_get_autoconnect_retry_time (NMSettingsConnection *self) { - return NM_SETTINGS_CONNECTION_GET_PRIVATE (connection)->autoconnect_retry_time; + return NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->autoconnect_retry_time; } NMDeviceStateReason -nm_settings_connection_get_autoconnect_blocked_reason (NMSettingsConnection *connection) +nm_settings_connection_get_autoconnect_blocked_reason (NMSettingsConnection *self) { - return NM_SETTINGS_CONNECTION_GET_PRIVATE (connection)->autoconnect_blocked_reason; + return NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->autoconnect_blocked_reason; } void -nm_settings_connection_set_autoconnect_blocked_reason (NMSettingsConnection *connection, +nm_settings_connection_set_autoconnect_blocked_reason (NMSettingsConnection *self, NMDeviceStateReason reason) { - NM_SETTINGS_CONNECTION_GET_PRIVATE (connection)->autoconnect_blocked_reason = reason; + NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->autoconnect_blocked_reason = reason; } gboolean -nm_settings_connection_can_autoconnect (NMSettingsConnection *connection) +nm_settings_connection_can_autoconnect (NMSettingsConnection *self) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection); + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); NMSettingConnection *s_con; const char *permission; @@ -2154,13 +2183,13 @@ nm_settings_connection_can_autoconnect (NMSettingsConnection *connection) || priv->autoconnect_blocked_reason != NM_DEVICE_STATE_REASON_NONE) return FALSE; - s_con = nm_connection_get_setting_connection (NM_CONNECTION (connection)); + s_con = nm_connection_get_setting_connection (NM_CONNECTION (self)); if (!nm_setting_connection_get_autoconnect (s_con)) return FALSE; - permission = nm_utils_get_shared_wifi_permission (NM_CONNECTION (connection)); + permission = nm_utils_get_shared_wifi_permission (NM_CONNECTION (self)); if (permission) { - if (nm_settings_connection_check_permission (connection, permission) == FALSE) + if (nm_settings_connection_check_permission (self, permission) == FALSE) return FALSE; } @@ -2169,89 +2198,89 @@ nm_settings_connection_can_autoconnect (NMSettingsConnection *connection) /** * nm_settings_connection_get_nm_generated: - * @connection: an #NMSettingsConnection + * @self: an #NMSettingsConnection * - * Gets the "nm-generated" flag on @connection. + * Gets the "nm-generated" flag on @self. * * A connection is "nm-generated" if it was generated by * nm_device_generate_connection() and has not been modified or * saved by the user since then. */ gboolean -nm_settings_connection_get_nm_generated (NMSettingsConnection *connection) +nm_settings_connection_get_nm_generated (NMSettingsConnection *self) { - return NM_FLAGS_HAS (nm_settings_connection_get_flags (connection), NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED); + return NM_FLAGS_HAS (nm_settings_connection_get_flags (self), NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED); } /** * nm_settings_connection_get_nm_generated_assumed: - * @connection: an #NMSettingsConnection + * @self: an #NMSettingsConnection * - * Gets the "nm-generated-assumed" flag on @connection. + * Gets the "nm-generated-assumed" flag on @self. * * The connection is a generated connection especially * generated for connection assumption. */ gboolean -nm_settings_connection_get_nm_generated_assumed (NMSettingsConnection *connection) +nm_settings_connection_get_nm_generated_assumed (NMSettingsConnection *self) { - return NM_FLAGS_HAS (nm_settings_connection_get_flags (connection), NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED_ASSUMED); + return NM_FLAGS_HAS (nm_settings_connection_get_flags (self), NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED_ASSUMED); } gboolean -nm_settings_connection_get_ready (NMSettingsConnection *connection) +nm_settings_connection_get_ready (NMSettingsConnection *self) { - return NM_SETTINGS_CONNECTION_GET_PRIVATE (connection)->ready; + return NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->ready; } void -nm_settings_connection_set_ready (NMSettingsConnection *connection, +nm_settings_connection_set_ready (NMSettingsConnection *self, gboolean ready) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection); + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); ready = !!ready; if (priv->ready != ready) { priv->ready = ready; - g_object_notify (G_OBJECT (connection), NM_SETTINGS_CONNECTION_READY); + g_object_notify (G_OBJECT (self), NM_SETTINGS_CONNECTION_READY); } } /** * nm_settings_connection_set_filename: - * @connection: an #NMSettingsConnection - * @filename: @connection's filename + * @self: an #NMSettingsConnection + * @filename: @self's filename * - * Called by a backend to sets the filename that @connection is read + * Called by a backend to sets the filename that @self is read * from/written to. */ void -nm_settings_connection_set_filename (NMSettingsConnection *connection, +nm_settings_connection_set_filename (NMSettingsConnection *self, const char *filename) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection); + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); if (g_strcmp0 (filename, priv->filename) != 0) { g_free (priv->filename); priv->filename = g_strdup (filename); - g_object_notify (G_OBJECT (connection), NM_SETTINGS_CONNECTION_FILENAME); + g_object_notify (G_OBJECT (self), NM_SETTINGS_CONNECTION_FILENAME); } } /** * nm_settings_connection_get_filename: - * @connection: an #NMSettingsConnection + * @self: an #NMSettingsConnection * - * Gets the filename that @connection was read from/written to. This may be - * %NULL if @connection is unsaved, or if it is associated with a backend that + * Gets the filename that @self was read from/written to. This may be + * %NULL if @self is unsaved, or if it is associated with a backend that * does not store each connection in a separate file. * - * Returns: @connection's filename. + * Returns: @self's filename. */ const char * -nm_settings_connection_get_filename (NMSettingsConnection *connection) +nm_settings_connection_get_filename (NMSettingsConnection *self) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection); + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); return priv->filename; } @@ -2280,12 +2309,24 @@ nm_settings_connection_init (NMSettingsConnection *self) } static void +constructed (GObject *object) +{ + NMSettingsConnection *self = NM_SETTINGS_CONNECTION (object); + + _LOGD ("constructed (%s)", G_OBJECT_TYPE_NAME (self)); + + G_OBJECT_CLASS (nm_settings_connection_parent_class)->constructed (object); +} + +static void dispose (GObject *object) { NMSettingsConnection *self = NM_SETTINGS_CONNECTION (object); NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); GSList *iter; + _LOGD ("disposing"); + if (priv->updated_idle_id) { g_source_remove (priv->updated_idle_id); priv->updated_idle_id = 0; @@ -2386,6 +2427,7 @@ nm_settings_connection_class_init (NMSettingsConnectionClass *class) g_type_class_add_private (class, sizeof (NMSettingsConnectionPrivate)); /* Virtual methods */ + object_class->constructed = constructed; object_class->dispose = dispose; object_class->get_property = get_property; object_class->set_property = set_property; @@ -2436,7 +2478,7 @@ nm_settings_connection_class_init (NMSettingsConnectionClass *class) /* Signals */ /* Emitted when the connection is changed for any reason */ - signals[UPDATED] = + signals[UPDATED] = g_signal_new (NM_SETTINGS_CONNECTION_UPDATED, G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_FIRST, diff --git a/src/settings/nm-settings-connection.h b/src/settings/nm-settings-connection.h index 49661f38c6..512112f032 100644 --- a/src/settings/nm-settings-connection.h +++ b/src/settings/nm-settings-connection.h @@ -81,11 +81,11 @@ typedef enum typedef struct _NMSettingsConnectionClass NMSettingsConnectionClass; -typedef void (*NMSettingsConnectionCommitFunc) (NMSettingsConnection *connection, +typedef void (*NMSettingsConnectionCommitFunc) (NMSettingsConnection *self, GError *error, gpointer user_data); -typedef void (*NMSettingsConnectionDeleteFunc) (NMSettingsConnection *connection, +typedef void (*NMSettingsConnectionDeleteFunc) (NMSettingsConnection *self, GError *error, gpointer user_data); @@ -97,26 +97,26 @@ struct _NMSettingsConnectionClass { GObjectClass parent; /* virtual methods */ - void (*replace_and_commit) (NMSettingsConnection *connection, + void (*replace_and_commit) (NMSettingsConnection *self, NMConnection *new_connection, NMSettingsConnectionCommitFunc callback, gpointer user_data); - void (*commit_changes) (NMSettingsConnection *connection, + void (*commit_changes) (NMSettingsConnection *self, NMSettingsConnectionCommitFunc callback, gpointer user_data); - void (*delete) (NMSettingsConnection *connection, + void (*delete) (NMSettingsConnection *self, NMSettingsConnectionDeleteFunc callback, gpointer user_data); - gboolean (*supports_secrets) (NMSettingsConnection *connection, + gboolean (*supports_secrets) (NMSettingsConnection *self, const char *setting_name); }; GType nm_settings_connection_get_type (void); -void nm_settings_connection_commit_changes (NMSettingsConnection *connection, +void nm_settings_connection_commit_changes (NMSettingsConnection *self, NMSettingsConnectionCommitFunc callback, gpointer user_data); @@ -131,18 +131,18 @@ void nm_settings_connection_replace_and_commit (NMSettingsConnection *self, NMSettingsConnectionCommitFunc callback, gpointer user_data); -void nm_settings_connection_delete (NMSettingsConnection *connection, +void nm_settings_connection_delete (NMSettingsConnection *self, NMSettingsConnectionDeleteFunc callback, gpointer user_data); -typedef void (*NMSettingsConnectionSecretsFunc) (NMSettingsConnection *connection, +typedef void (*NMSettingsConnectionSecretsFunc) (NMSettingsConnection *self, guint32 call_id, const char *agent_username, const char *setting_name, GError *error, gpointer user_data); -guint32 nm_settings_connection_get_secrets (NMSettingsConnection *connection, +guint32 nm_settings_connection_get_secrets (NMSettingsConnection *self, NMAuthSubject *subject, const char *setting_name, NMSecretAgentGetSecretsFlags flags, @@ -151,7 +151,7 @@ guint32 nm_settings_connection_get_secrets (NMSettingsConnection *connection, gpointer callback_data, GError **error); -void nm_settings_connection_cancel_secrets (NMSettingsConnection *connection, +void nm_settings_connection_cancel_secrets (NMSettingsConnection *self, guint32 call_id); gboolean nm_settings_connection_is_visible (NMSettingsConnection *self); @@ -165,52 +165,52 @@ void nm_settings_connection_signal_remove (NMSettingsConnection *self); gboolean nm_settings_connection_get_unsaved (NMSettingsConnection *self); -NMSettingsConnectionFlags nm_settings_connection_get_flags (NMSettingsConnection *connection); -NMSettingsConnectionFlags nm_settings_connection_set_flags (NMSettingsConnection *connection, NMSettingsConnectionFlags flags, gboolean set); -NMSettingsConnectionFlags nm_settings_connection_set_flags_all (NMSettingsConnection *connection, NMSettingsConnectionFlags flags); +NMSettingsConnectionFlags nm_settings_connection_get_flags (NMSettingsConnection *self); +NMSettingsConnectionFlags nm_settings_connection_set_flags (NMSettingsConnection *self, NMSettingsConnectionFlags flags, gboolean set); +NMSettingsConnectionFlags nm_settings_connection_set_flags_all (NMSettingsConnection *self, NMSettingsConnectionFlags flags); -gboolean nm_settings_connection_get_timestamp (NMSettingsConnection *connection, +gboolean nm_settings_connection_get_timestamp (NMSettingsConnection *self, guint64 *out_timestamp); -void nm_settings_connection_update_timestamp (NMSettingsConnection *connection, +void nm_settings_connection_update_timestamp (NMSettingsConnection *self, guint64 timestamp, gboolean flush_to_disk); -void nm_settings_connection_read_and_fill_timestamp (NMSettingsConnection *connection); +void nm_settings_connection_read_and_fill_timestamp (NMSettingsConnection *self); -char **nm_settings_connection_get_seen_bssids (NMSettingsConnection *connection); +char **nm_settings_connection_get_seen_bssids (NMSettingsConnection *self); -gboolean nm_settings_connection_has_seen_bssid (NMSettingsConnection *connection, +gboolean nm_settings_connection_has_seen_bssid (NMSettingsConnection *self, const char *bssid); -void nm_settings_connection_add_seen_bssid (NMSettingsConnection *connection, +void nm_settings_connection_add_seen_bssid (NMSettingsConnection *self, const char *seen_bssid); -void nm_settings_connection_read_and_fill_seen_bssids (NMSettingsConnection *connection); +void nm_settings_connection_read_and_fill_seen_bssids (NMSettingsConnection *self); -int nm_settings_connection_get_autoconnect_retries (NMSettingsConnection *connection); -void nm_settings_connection_set_autoconnect_retries (NMSettingsConnection *connection, +int nm_settings_connection_get_autoconnect_retries (NMSettingsConnection *self); +void nm_settings_connection_set_autoconnect_retries (NMSettingsConnection *self, int retries); -void nm_settings_connection_reset_autoconnect_retries (NMSettingsConnection *connection); +void nm_settings_connection_reset_autoconnect_retries (NMSettingsConnection *self); -gint32 nm_settings_connection_get_autoconnect_retry_time (NMSettingsConnection *connection); +gint32 nm_settings_connection_get_autoconnect_retry_time (NMSettingsConnection *self); -NMDeviceStateReason nm_settings_connection_get_autoconnect_blocked_reason (NMSettingsConnection *connection); -void nm_settings_connection_set_autoconnect_blocked_reason (NMSettingsConnection *connection, +NMDeviceStateReason nm_settings_connection_get_autoconnect_blocked_reason (NMSettingsConnection *self); +void nm_settings_connection_set_autoconnect_blocked_reason (NMSettingsConnection *self, NMDeviceStateReason reason); -gboolean nm_settings_connection_can_autoconnect (NMSettingsConnection *connection); +gboolean nm_settings_connection_can_autoconnect (NMSettingsConnection *self); -gboolean nm_settings_connection_get_nm_generated (NMSettingsConnection *connection); -gboolean nm_settings_connection_get_nm_generated_assumed (NMSettingsConnection *connection); +gboolean nm_settings_connection_get_nm_generated (NMSettingsConnection *self); +gboolean nm_settings_connection_get_nm_generated_assumed (NMSettingsConnection *self); -gboolean nm_settings_connection_get_ready (NMSettingsConnection *connection); -void nm_settings_connection_set_ready (NMSettingsConnection *connection, +gboolean nm_settings_connection_get_ready (NMSettingsConnection *self); +void nm_settings_connection_set_ready (NMSettingsConnection *self, gboolean ready); -void nm_settings_connection_set_filename (NMSettingsConnection *connection, +void nm_settings_connection_set_filename (NMSettingsConnection *self, const char *filename); -const char *nm_settings_connection_get_filename (NMSettingsConnection *connection); +const char *nm_settings_connection_get_filename (NMSettingsConnection *self); G_END_DECLS diff --git a/src/settings/plugins/ifupdown/tests/test-ifupdown.c b/src/settings/plugins/ifupdown/tests/test-ifupdown.c index 1c100ac2e2..d285a464d7 100644 --- a/src/settings/plugins/ifupdown/tests/test-ifupdown.c +++ b/src/settings/plugins/ifupdown/tests/test-ifupdown.c @@ -27,6 +27,7 @@ #include "nm-logging.h" #include "interface_parser.h" #include "parser.h" +#include "nm-logging.h" #include "nm-test-utils.h" @@ -844,16 +845,12 @@ test20_source_stanza (const char *path) expected_free (e); } +NMTST_DEFINE (); + int main (int argc, char **argv) { -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif - - nm_logging_setup ("WARN", "DEFAULT", NULL, NULL); - - g_test_init (&argc, &argv, NULL); + nmtst_init_assert_logging (&argc, &argv, "WARN", "DEFAULT"); if (0) dump_blocks (); diff --git a/src/tests/test-dcb.c b/src/tests/test-dcb.c index dacb1f521f..2fef34ba09 100644 --- a/src/tests/test-dcb.c +++ b/src/tests/test-dcb.c @@ -24,6 +24,9 @@ #include <string.h> #include "nm-dcb.h" +#include "nm-logging.h" + +#include "nm-test-utils.h" typedef struct { guint num; @@ -335,14 +338,12 @@ test_fcoe_cleanup (void) /*******************************************/ +NMTST_DEFINE (); + int main (int argc, char **argv) { - g_test_init (&argc, &argv, NULL); - -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif + nmtst_init_assert_logging (&argc, &argv, "INFO", "DEFAULT"); g_test_add_func ("/dcb/fcoe", test_dcb_fcoe); g_test_add_func ("/dcb/iscsi", test_dcb_iscsi); diff --git a/src/tests/test-resolvconf-capture.c b/src/tests/test-resolvconf-capture.c index bf0fff0b1d..313c23f4d7 100644 --- a/src/tests/test-resolvconf-capture.c +++ b/src/tests/test-resolvconf-capture.c @@ -28,6 +28,9 @@ #include "nm-ip4-config.h" #include "nm-ip6-config.h" #include "nm-platform.h" +#include "nm-logging.h" + +#include "nm-test-utils.h" static void test_capture_empty (void) @@ -288,14 +291,12 @@ test_capture_dns_options_valid6 (void) } /*******************************************/ +NMTST_DEFINE (); + int main (int argc, char **argv) { - g_test_init (&argc, &argv, NULL); - -#if !GLIB_CHECK_VERSION (2,35,0) - g_type_init (); -#endif + nmtst_init_assert_logging (&argc, &argv, "INFO", "DEFAULT"); g_test_add_func ("/resolvconf-capture/empty", test_capture_empty); g_test_add_func ("/resolvconf-capture/basic4", test_capture_basic4); diff --git a/src/tests/test-wired-defname.c b/src/tests/test-wired-defname.c index b2933de0e3..7e626ec585 100644 --- a/src/tests/test-wired-defname.c +++ b/src/tests/test-wired-defname.c @@ -26,7 +26,9 @@ #include <nm-simple-connection.h> #include <nm-setting-connection.h> #include "nm-device-ethernet-utils.h" -#include "gsystem-local-alloc.h" +#include "nm-logging.h" + +#include "nm-test-utils.h" static NMConnection * _new_connection (const char *id) @@ -112,14 +114,12 @@ test_defname_multiple_conflicts (void) /*******************************************/ +NMTST_DEFINE (); + int main (int argc, char **argv) { -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif - - g_test_init (&argc, &argv, NULL); + nmtst_init_assert_logging (&argc, &argv, "INFO", "DEFAULT"); g_test_add_func ("/defname/no_connections", test_defname_no_connections); g_test_add_func ("/defname/no_conflict", test_defname_no_conflict); |