From a10ddb54737446188f3ea52af1b0b4b6c41ad398 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Mon, 24 Apr 2023 07:54:26 +0200 Subject: [PATCH 1/3] meson: Add version check --- src/meson.build | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/meson.build b/src/meson.build index b45e901d..e2bb1699 100644 --- a/src/meson.build +++ b/src/meson.build @@ -26,6 +26,13 @@ plug_files = files( switchboard_dep = dependency('switchboard-2.0') switchboard_plugsdir = switchboard_dep.get_pkgconfig_variable('plugsdir', define_variable: ['libdir', libdir]) +libnm_dep = dependency('libnm', version: '>=1.20.6') + +args = [] +if libnm_dep.version().version_compare('>=1.43.0') + args += '--define=HAS_NM_1_43' +endif + shared_module( meson.project_name(), plug_files, @@ -35,11 +42,12 @@ shared_module( dependency('gobject-2.0'), dependency('granite', version: '>=5.2.3'), dependency('gtk+-3.0'), - dependency('libnm', version: '>=1.20.6'), + libnm_dep, dependency('libnma'), meson.get_compiler('vala').find_library('posix'), switchboard_dep ], + vala_args: args, install: true, install_dir : join_paths(switchboard_plugsdir, 'network') ) From a09647c24bd66b643a7827d1bcf5b64e02030dc0 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Mon, 24 Apr 2023 07:54:39 +0200 Subject: [PATCH 2/3] Handle version --- src/Utils.vala | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Utils.vala b/src/Utils.vala index b2d03cd5..53f32e5a 100644 --- a/src/Utils.vala +++ b/src/Utils.vala @@ -24,10 +24,18 @@ namespace Network { public delegate void UpdateSecretCallback (); public static void update_secrets (NM.RemoteConnection connection, UpdateSecretCallback callback) { +#if HAS_NM_1_43 + connection.get_secrets_async.begin (NM.SettingWireless.SETTING_NAME, null, (obj, res) => { +#else connection.get_secrets_async.begin (NM.SettingWireless.SECURITY_SETTING_NAME, null, (obj, res) => { +#endif try { var secrets = connection.get_secrets_async.end (res); +#if HAS_NM_1_43 + connection.update_secrets (NM.SettingWireless.SETTING_NAME, secrets); +#else connection.update_secrets (NM.SettingWireless.SECURITY_SETTING_NAME, secrets); +#endif } catch (Error e) { warning ("%s\n", e.message); return; From d04652127e7bceea214ce200c9714deb3ea48dd5 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Mon, 24 Apr 2023 15:30:21 +0200 Subject: [PATCH 3/3] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Corentin Noël --- src/Utils.vala | 4 ++-- src/meson.build | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Utils.vala b/src/Utils.vala index 53f32e5a..c4d71eef 100644 --- a/src/Utils.vala +++ b/src/Utils.vala @@ -25,14 +25,14 @@ namespace Network { public static void update_secrets (NM.RemoteConnection connection, UpdateSecretCallback callback) { #if HAS_NM_1_43 - connection.get_secrets_async.begin (NM.SettingWireless.SETTING_NAME, null, (obj, res) => { + connection.get_secrets_async.begin (NM.SettingWirelessSecurity.SETTING_NAME, null, (obj, res) => { #else connection.get_secrets_async.begin (NM.SettingWireless.SECURITY_SETTING_NAME, null, (obj, res) => { #endif try { var secrets = connection.get_secrets_async.end (res); #if HAS_NM_1_43 - connection.update_secrets (NM.SettingWireless.SETTING_NAME, secrets); + connection.update_secrets (NM.SettingWirelessSecurity.SETTING_NAME, secrets); #else connection.update_secrets (NM.SettingWireless.SECURITY_SETTING_NAME, secrets); #endif diff --git a/src/meson.build b/src/meson.build index e2bb1699..905dc648 100644 --- a/src/meson.build +++ b/src/meson.build @@ -29,7 +29,7 @@ switchboard_plugsdir = switchboard_dep.get_pkgconfig_variable('plugsdir', define libnm_dep = dependency('libnm', version: '>=1.20.6') args = [] -if libnm_dep.version().version_compare('>=1.43.0') +if libnm_dep.version().version_compare('>=1.43.3') args += '--define=HAS_NM_1_43' endif