diff options
author | Jan Tojnar <jtojnar@gmail.com> | 2018-08-06 22:35:52 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2018-08-07 06:45:20 +0000 |
commit | 1755a31202ee4d1e223e91c1c505a614114393d5 (patch) | |
tree | 864ee7e0dc499cf25cf1a44313ffa5b95e625e6f | |
parent | 5228e3e9c12763ef848b1758c746794818ba54ca (diff) | |
download | network-manager-applet-1755a31202ee4d1e223e91c1c505a614114393d5.tar.gz |
nma/mobile-providers: also use the data file locations from pc files
If a distribution lacks global datadir (e.g. NixOS), libnma would not
be able to find mobile-data-provider-info and isocodes without user
having to add them to XDG_DATA_DIRS manually.
This patch allows falling back to the paths provided by pkg-config
files of the data packages, making it work on more exotic platforms.
Closes: https://gitlab.gnome.org/GNOME/network-manager-applet/issues/14
-rw-r--r-- | .gitlab-ci.yml | 5 | ||||
-rw-r--r-- | config.h.meson | 3 | ||||
-rw-r--r-- | configure.ac | 23 | ||||
-rw-r--r-- | meson.build | 10 | ||||
-rw-r--r-- | meson_options.txt | 1 | ||||
-rw-r--r-- | src/libnma/nma-mobile-providers.c | 10 |
6 files changed, 52 insertions, 0 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f2eb6f7f..fb656eb9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -43,6 +43,7 @@ gobject-introspection-devel redhat-rpm-config gtk-doc iso-codes-devel + mobile-broadband-provider-info-devel jansson-devel ModemManager-glib-devel libselinux-devel @@ -66,6 +67,7 @@ -Dteam=false -Dgcr=false -Diso_codes=false + -Dmobile_broadband_provider_info=false -Dld_gc=false -Dgtk_doc=false -Dintrospection=false @@ -90,6 +92,7 @@ -Dteam=true -Dgcr=true -Diso_codes=true + -Dmobile_broadband_provider_info=true -Dld_gc=true -Dgtk_doc=true -Dintrospection=true @@ -114,6 +117,7 @@ --without-libnm-gtk --disable-nls --disable-iso-codes + --disable-mobile-broadband-provider-info --disable-gtk-doc --disable-introspection --disable-schemas-compile @@ -141,6 +145,7 @@ --without-libnm-gtk --enable-nls --enable-iso-codes + --enable-mobile-broadband-provider-info --enable-gtk-doc --enable-introspection --enable-schemas-compile diff --git a/config.h.meson b/config.h.meson index 8e566348..c3ca560e 100644 --- a/config.h.meson +++ b/config.h.meson @@ -7,6 +7,9 @@ /* ISO codes prefix */ #mesondefine ISO_CODES_PREFIX +/* Mobile Broadband Service Provider Information Database location */ +#mesondefine MOBILE_BROADBAND_PROVIDER_INFO_DATABASE + /* Define if more asserts are enabled */ #mesondefine NM_MORE_ASSERTS diff --git a/configure.ac b/configure.ac index 5f0f16e1..2c4aebe3 100644 --- a/configure.ac +++ b/configure.ac @@ -97,6 +97,29 @@ else AC_DEFINE_UNQUOTED([ISO_CODES_PREFIX],["$prefix"],[ISO codes prefix]) fi +# Check for mobile-broadband-provider-info for Mobile Broadband wizard +AC_MSG_CHECKING([whether to disable mobile-broadband-provider-info at build-time]) +AC_ARG_ENABLE([mobile-broadband-provider-info], + AS_HELP_STRING([--disable-mobile-broadband-provider-info],[do not check for mobile-broadband-provider-info at build-time]), + [],[disable_mobile_broadband_provider_info_check=no]) +if test x$disable_mobile_broadband_provider_info_check = xno ; then + AC_MSG_RESULT([no]) +else + AC_MSG_RESULT([yes]) +fi + +if test x$disable_mobile_broadband_provider_info_check = "xno" ; then + AC_DEFINE_UNQUOTED([MOBILE_BROADBAND_PROVIDER_INFO_DATABASE],["`$PKG_CONFIG --variable=database mobile-broadband-provider-info`"],[Mobile Broadband Service Provider Information Database location]) + PKG_CHECK_MODULES(MOBILE_BROADBAND_PROVIDER_INFO, [mobile-broadband-provider-info], + [], + [echo -e "\n$MOBILE_BROADBAND_PROVIDER_INFO_PKG_ERRORS.\n" + echo "Consider installing the package or adjusting the PKG_CONFIG_PATH environment variable." + echo "You can also disable build-time check for 'mobile-broadband-provider-info' via --disable-mobile-broadband-provider-info"; + exit 1;]) +else + AC_DEFINE_UNQUOTED([MOBILE_BROADBAND_PROVIDER_INFO_DATABASE],["$prefix/share/mobile-broadband-provider-info/serviceproviders.xml"],[Mobile Broadband Service Provider Information Database location]) +fi + dnl dnl API documentation dnl diff --git a/meson.build b/meson.build index c78b03b0..4096b06d 100644 --- a/meson.build +++ b/meson.build @@ -130,6 +130,16 @@ else config_h.set_quoted('ISO_CODES_PREFIX', nma_prefix) endif +# Check for mobile-broadband-provider-info for Mobile Broadband wizard +enable_mobile_broadband_provider_info = get_option('mobile_broadband_provider_info') +message('whether to enable mobile-broadband-provider-info at build-time: ' + enable_mobile_broadband_provider_info.to_string()) +if enable_mobile_broadband_provider_info + mobile_broadband_provider_info_dep = dependency('mobile-broadband-provider-info') + config_h.set_quoted('MOBILE_BROADBAND_PROVIDER_INFO_DATABASE', mobile_broadband_provider_info_dep.get_pkgconfig_variable('database')) +else + config_h.set_quoted('MOBILE_BROADBAND_PROVIDER_INFO_DATABASE', join_paths(nma_prefix, 'share', 'mobile-broadband-provider-info', 'serviceproviders.xml')) +endif + gio_dep = dependency('gio-2.0', version: '>= 2.38') gmodule_export_dep = dependency('gmodule-export-2.0') libsecret_dep = dependency('libsecret-1', version: '>= 0.18') diff --git a/meson_options.txt b/meson_options.txt index 0ea708cb..42240429 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -6,6 +6,7 @@ option('team', type: 'boolean', value: true, description: 'Enable team configura option('gcr', type: 'boolean', value: true, description: 'Enable advanced certificate chooser.') option('more_asserts', type: 'string', value: '0', description: 'Enable more assertions for debugging.') option('iso_codes', type: 'boolean', value: true, description: 'check for iso-codes at build-time') +option('mobile_broadband_provider_info', type: 'boolean', value: true, description: 'check for mobile-broadband-provider-info at build-time') option('ld_gc', type: 'boolean', value: true, description: 'Enable garbage collection of unused symbols on linking') option('gtk_doc', type: 'boolean', value: true, description: 'use gtk-doc to build documentation') option('introspection', type: 'boolean', value: true, description: 'Enable introspection for this build') diff --git a/src/libnma/nma-mobile-providers.c b/src/libnma/nma-mobile-providers.c index abe77c18..dffcdf61 100644 --- a/src/libnma/nma-mobile-providers.c +++ b/src/libnma/nma-mobile-providers.c @@ -1017,6 +1017,12 @@ mobile_providers_parse_sync (const gchar *country_codes, } if (!success) { + path = g_build_filename (ISO_CODES_PREFIX, "share", ISO_3166_COUNTRY_CODES, NULL); + success = read_country_codes (countries, path, cancellable, NULL); + g_free (path); + } + + if (!success) { g_warning ("Could not find the country codes file (%s): check your installation\n", ISO_3166_COUNTRY_CODES); } @@ -1041,6 +1047,10 @@ mobile_providers_parse_sync (const gchar *country_codes, } if (!success) { + success = read_service_providers (countries, MOBILE_BROADBAND_PROVIDER_INFO_DATABASE, cancellable, NULL); + } + + if (!success) { g_warning ("Could not find the provider data (%s): check your installation\n", MOBILE_BROADBAND_PROVIDER_INFO); } |