summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2019-10-14 09:01:03 +0200
committerLubomir Rintel <lkundrak@v3.sk>2019-11-04 13:42:52 +0100
commit4ab5039342249e04554c26da7d7ae935b5eff8f8 (patch)
treed101b3eee6f6999ec3ca6da797eb8149dbac86fa
parentf3e2fbc27f68c93a05c4449873903ce8b1a41bfe (diff)
downloadnetwork-manager-applet-lr/libnmicide.tar.gz
libnma: droplr/libnmicide
-rw-r--r--.gitlab-ci.yml63
-rw-r--r--Makefile.am612
-rwxr-xr-xautogen.sh1
-rw-r--r--configure.ac162
-rw-r--r--m4/introspection.m493
-rw-r--r--meson.build188
-rw-r--r--meson_options.txt6
-rw-r--r--po/POTFILES.in17
-rw-r--r--src/libnma/init.c23
-rw-r--r--src/libnma/libnma-gtk4.pc.in11
-rw-r--r--src/libnma/libnma.pc.in11
-rw-r--r--src/libnma/libnma.ver114
-rw-r--r--src/libnma/meson.build186
-rw-r--r--src/libnma/nma-bar-code-widget.c462
-rw-r--r--src/libnma/nma-bar-code-widget.h43
-rw-r--r--src/libnma/nma-bar-code-widget.ui45
-rw-r--r--src/libnma/nma-bar-code.c222
-rw-r--r--src/libnma/nma-bar-code.h54
-rw-r--r--src/libnma/nma-cert-chooser-button.c469
-rw-r--r--src/libnma/nma-cert-chooser-button.h59
-rw-r--r--src/libnma/nma-cert-chooser-private.h143
-rw-r--r--src/libnma/nma-cert-chooser.c788
-rw-r--r--src/libnma/nma-cert-chooser.h151
-rw-r--r--src/libnma/nma-file-cert-chooser.c399
-rw-r--r--src/libnma/nma-mobile-providers.c1600
-rw-r--r--src/libnma/nma-mobile-providers.h131
-rw-r--r--src/libnma/nma-mobile-wizard.c1560
-rw-r--r--src/libnma/nma-mobile-wizard.h65
-rw-r--r--src/libnma/nma-mobile-wizard.ui604
-rw-r--r--src/libnma/nma-pkcs11-cert-chooser-dialog.c643
-rw-r--r--src/libnma/nma-pkcs11-cert-chooser-dialog.h49
-rw-r--r--src/libnma/nma-pkcs11-cert-chooser-dialog.ui153
-rw-r--r--src/libnma/nma-pkcs11-cert-chooser.c559
-rw-r--r--src/libnma/nma-pkcs11-token-login-dialog.c236
-rw-r--r--src/libnma/nma-pkcs11-token-login-dialog.h43
-rw-r--r--src/libnma/nma-pkcs11-token-login-dialog.ui111
-rw-r--r--src/libnma/nma-private.h21
-rw-r--r--src/libnma/nma-ui-utils.c432
-rw-r--r--src/libnma/nma-ui-utils.h26
-rw-r--r--src/libnma/nma-version.h.in119
-rw-r--r--src/libnma/nma-vpn-password-dialog.c351
-rw-r--r--src/libnma/nma-vpn-password-dialog.h85
-rw-r--r--src/libnma/nma-vpn-password-dialog.ui222
-rw-r--r--src/libnma/nma-wifi-dialog.c1559
-rw-r--r--src/libnma/nma-wifi-dialog.h69
-rw-r--r--src/libnma/nma.gresource.xml11
-rw-r--r--src/libnma/qrcodegen.c1009
-rw-r--r--src/libnma/qrcodegen.h311
-rw-r--r--src/libnma/tests/bar-code.c178
-rw-r--r--src/libnma/tests/cert-chooser.c104
-rw-r--r--src/libnma/tests/meson.build31
-rw-r--r--src/libnma/tests/mobile-wizard.c33
-rw-r--r--src/libnma/tests/run-vpn.c87
-rw-r--r--src/libnma/tests/vpn-password-dialog.c36
-rw-r--r--src/libnma/tests/wifi-dialog-secrets.c100
-rw-r--r--src/libnma/tests/wifi-dialog.c60
-rw-r--r--src/libnma/wifi.ui215
-rw-r--r--src/meson.build16
-rw-r--r--src/wireless-security/meson.build22
59 files changed, 21 insertions, 15152 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 9ec72f18..ecbda96e 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -10,6 +10,7 @@
file
findutils
gcc
+ libtool
desktop-file-utils
gettext-devel
glib2-devel
@@ -30,6 +31,7 @@
file
findutils
gcc
+ libtool
desktop-file-utils
gettext-devel
glib2-devel
@@ -40,11 +42,7 @@
NetworkManager-libnm-devel
pkgconfig
/usr/bin/autopoint
- gcr-devel
- gobject-introspection-devel redhat-rpm-config
- gtk-doc
- iso-codes-devel
- mobile-broadband-provider-info-devel
+ redhat-rpm-config
jansson-devel
ModemManager-glib-devel
libselinux-devel
@@ -68,12 +66,7 @@
-Dwwan=false
-Dselinux=false
-Dteam=false
- -Dgcr=false
- -Diso_codes=false
- -Dmobile_broadband_provider_info=false
-Dld_gc=false
- -Dgtk_doc=false
- -Dintrospection=false
-Dappindicator=no
-Dmore_asserts=no
network-manager-applet-*/ build
@@ -92,12 +85,7 @@
-Dwwan=true
-Dselinux=true
-Dteam=true
- -Dgcr=true
- -Diso_codes=true
- -Dmobile_broadband_provider_info=true
-Dld_gc=true
- -Dgtk_doc=true
- -Dintrospection=true
-Dappindicator=no
-Dmore_asserts=yes
network-manager-applet-*/ build
@@ -117,17 +105,12 @@
--disable-silent-rules
--with-more-asserts=no
--disable-nls
- --disable-iso-codes
- --disable-mobile-broadband-provider-info
- --disable-gtk-doc
- --disable-introspection
--disable-schemas-compile
--disable-more-warnings
--without-appindicator
--without-wwan
--without-selinux
--without-team
- --without-gcr
- make -j$(nproc)
- make -j$(nproc) check
- make -j$(nproc) install
@@ -144,16 +127,11 @@
--disable-silent-rules
--with-more-asserts=yes
--enable-nls
- --enable-iso-codes
- --enable-mobile-broadband-provider-info
- --enable-gtk-doc
- --enable-introspection
--enable-schemas-compile
--enable-more-warnings
--with-wwan
--with-selinux
--with-team
- --with-gcr
- make -j$(nproc)
- make -j$(nproc) check
- make -j$(nproc) install
@@ -199,6 +177,7 @@ fedora_autotools_full:
# file
# findutils
# gcc
+# libtool
# desktop-file-utils
# gettext-devel
# glib2-devel
@@ -210,11 +189,7 @@ fedora_autotools_full:
# NetworkManager-libnm-devel
# pkgconfig
# /usr/bin/autopoint
-# gcr-devel
-# gobject-introspection-devel redhat-rpm-config
-# gtk-doc
-# iso-codes-devel
-# mobile-broadband-provider-info-devel
+# redhat-rpm-config
# jansson-devel
# ModemManager-glib-devel
# libselinux-devel
@@ -226,42 +201,14 @@ fedora_autotools_full:
# --disable-silent-rules
# --with-more-asserts=yes
# --enable-nls
-# --enable-iso-codes
-# --enable-mobile-broadband-provider-info
-# --enable-gtk-doc
-# --enable-introspection
# --enable-schemas-compile
# --enable-more-warnings
# --with-wwan
# --with-selinux
# --with-team
-# --with-gcr
# - make -j$(nproc)
# - make -j$(nproc) check
# - make -j$(nproc) install
# - make -j$(nproc) uninstall
# image: centos:7
# stage: test
-
-# https://network-manager-applet.pages.gitlab.gnome.org/libnma/
-pages:
- <<: *fedora_full
- <<: *dist
- image: fedora:latest
- stage: deploy
- script:
- - dnf -y install make
- - tar xJf network-manager-applet-*.tar.xz
- - cd network-manager-applet-*/
- - ./configure
- --disable-silent-rules
- --enable-gtk-doc
- - make -j$(nproc)
- - cd ..
- - mkdir -p public
- - mv network-manager-applet-*/html public/libnma
- artifacts:
- paths:
- - public
- only:
- - master
diff --git a/Makefile.am b/Makefile.am
index e5876460..8da267b7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,4 @@
include $(GLIB_MAKEFILE)
--include $(INTROSPECTION_MAKEFILE)
-include $(top_srcdir)/gtk-doc.make
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
@@ -26,16 +24,17 @@ check_local =
TESTS =
+EXTRA_DIST =
+
+CLEANFILES =
+
DISTCLEANFILES =
DISTCHECK_CONFIGURE_FLAGS = \
--disable-dependency-tracking \
- --enable-gtk-doc \
- --enable-introspection \
--enable-more-warnings=error \
--with-wwan \
- --with-team \
- --with-gcr
+ --with-team
man_MANS =
@@ -44,16 +43,6 @@ pkgconfig_DATA =
pkgconfigdir = $(libdir)/pkgconfig
-girdir = $(datadir)/gir-1.0
-gir_DATA = $(INTROSPECTION_GIRS)
-BUILT_SOURCES += $(gir_DATA)
-
-typelibdir = $(libdir)/girepository-1.0
-typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
-BUILT_SOURCES += $(typelib_DATA)
-
-INTROSPECTION_GIRS =
-
SUBDIRS = \
. \
po
@@ -190,26 +179,6 @@ src_utils_libutils_libnm_la_LIBADD = \
$(GTK3_LIBS) \
$(LIBNM_LIBS)
-if WITH_LIBNMA_GTK4
-
-noinst_LTLIBRARIES += src/utils/libutils-libnm-gtk4.la
-
-src_utils_libutils_libnm_gtk4_la_CPPFLAGS = \
- "-I$(srcdir)/shared" \
- $(GTK4_CFLAGS) \
- $(LIBNM_CFLAGS)
-
-src_utils_libutils_libnm_gtk4_la_SOURCES = \
- $(shared_files) \
- src/utils/utils.c \
- src/utils/utils.h
-
-src_utils_libutils_libnm_gtk4_la_LIBADD = \
- $(GTK4_LIBS) \
- $(LIBNM_LIBS)
-
-endif
-
check_programs += src/utils/tests/test-utils
src_utils_tests_test_utils_SOURCES = src/utils/tests/test-utils.c
@@ -291,9 +260,8 @@ src_wireless_security_libwireless_security_libnm_la_CPPFLAGS = \
$(dflt_cppflags) \
"-I$(srcdir)/shared" \
"-I$(srcdir)/src/utils" \
- "-I$(srcdir)/src/libnma" \
- -Isrc/libnma \
$(GTK3_CFLAGS) \
+ $(LIBNMA_CFLAGS) \
$(LIBNM_CFLAGS)
src_wireless_security_libwireless_security_libnm_la_LIBADD = \
@@ -303,33 +271,6 @@ src_wireless_security_libwireless_security_libnm_la_LIBADD = \
$(src_wireless_security_libwireless_security_libnm_la_OBJECTS): $(wireless_security_h_gen)
-if WITH_LIBNMA_GTK4
-
-noinst_LTLIBRARIES += src/wireless-security/libwireless-security-libnm-gtk4.la
-
-src_wireless_security_libwireless_security_libnm_gtk4_la_SOURCES = \
- $(wireless_security_c_real)
-
-nodist_src_wireless_security_libwireless_security_libnm_gtk4_la_SOURCES = \
- $(wireless_security_c_gen)
-
-src_wireless_security_libwireless_security_libnm_gtk4_la_CPPFLAGS = \
- "-I$(srcdir)/shared" \
- "-I$(srcdir)/src/utils" \
- "-I$(srcdir)/src/libnma" \
- -Isrc/libnma \
- $(GTK4_CFLAGS) \
- $(LIBNM_CFLAGS)
-
-src_wireless_security_libwireless_security_libnm_gtk4_la_LIBADD = \
- src/utils/libutils-libnm-gtk4.la \
- $(GTK4_LIBS) \
- $(LIBNM_LIBS)
-
-$(src_wireless_security_libwireless_security_libnm_gtk4_la_OBJECTS): $(wireless_security_h_gen)
-
-endif
-
EXTRA_DIST += \
src/wireless-security/eap-method-fast.ui \
src/wireless-security/eap-method-leap.ui \
@@ -348,499 +289,6 @@ EXTRA_DIST += \
###############################################################################
-src/libnma/nma-resources.h: src/libnma/nma.gresource.xml
- $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $< --target=$@ --sourcedir=$(srcdir)/src/libnma --generate-header --internal
-
-src/libnma/nma-resources.c: src/libnma/nma.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir)/src/libnma --generate-dependencies $(srcdir)/src/libnma/nma.gresource.xml)
- $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $< --target=$@ --sourcedir=$(srcdir)/src/libnma --generate-source --internal
-
-src/libnma-gtk4/nma-resources.c: src/libnma/nma.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies $(srcdir)/src/libnma/nma.gresource.xml |sed "s,^,$(builddir)/src/libnma-gtk4/,")
- @mkdir -p $(builddir)/src/libnma-gtk4
- $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $< --target=$@ --sourcedir=$(builddir)/src/libnma-gtk4 --generate-source --internal
-
-
-src/libnma-gtk4/%.ui: src/libnma/%.ui
- @mkdir -p $(builddir)/src/libnma-gtk4
- gtk4-builder-tool simplify --3to4 $< >$@
-
-CLEANFILES += \
- $(libnma_h_priv_gen) \
- $(libnma_c_gen) \
- $(libnma_gtk4_c_gen)
-
-libnma_h_priv_gen = \
- src/libnma/nma-resources.h
-
-libnma_c_gen = \
- src/libnma/nma-resources.c
-
-libnma_gtk4_c_gen = \
- src/libnma-gtk4/nma-resources.c
-
-libnma_h_pub = \
- src/libnma/nma-version.h \
- src/libnma/nma-wifi-dialog.h \
- src/libnma/nma-mobile-wizard.h \
- src/libnma/nma-mobile-providers.h \
- src/libnma/nma-vpn-password-dialog.h \
- src/libnma/nma-ui-utils.h \
- src/libnma/nma-cert-chooser.h \
- src/libnma/nma-bar-code-widget.h \
- src/libnma/nma-bar-code.h
-
-libnma_c_real = \
- src/libnma/nma-wifi-dialog.c \
- src/libnma/nma-mobile-wizard.c \
- src/libnma/nma-mobile-providers.c \
- src/libnma/nma-vpn-password-dialog.c \
- src/libnma/nma-ui-utils.c \
- src/libnma/init.c \
- src/libnma/nma-cert-chooser.c \
- src/libnma/nma-file-cert-chooser.c \
- src/libnma/nma-bar-code-widget.c \
- src/libnma/nma-bar-code.c
-
-EXTRA_DIST += \
- src/libnma/qrcodegen.c \
- src/libnma/qrcodegen.h
-
-libnma_h_priv_real = \
- src/libnma/nma-cert-chooser-private.h \
- src/libnma/nma-private.h
-
-libnma_h_priv_gcr = \
- src/libnma/nma-pkcs11-token-login-dialog.h \
- src/libnma/nma-pkcs11-cert-chooser-dialog.h \
- src/libnma/nma-cert-chooser-button.h
-
-libnma_c_gcr = \
- src/libnma/nma-pkcs11-token-login-dialog.c \
- src/libnma/nma-pkcs11-cert-chooser-dialog.c \
- src/libnma/nma-cert-chooser-button.c \
- src/libnma/nma-pkcs11-cert-chooser.c
-
-src_libnma_libnmadir = $(includedir)/libnma
-
-src_libnma_libnma_HEADERS = \
- $(libnma_h_pub)
-
-lib_LTLIBRARIES += src/libnma/libnma.la
-
-src_libnma_libnma_la_SOURCES = \
- $(libnma_h_priv_real) \
- $(libnma_c_real)
-
-if WITH_GCR
-src_libnma_libnma_la_SOURCES += \
- $(libnma_h_priv_gcr) \
- $(libnma_c_gcr)
-endif
-
-nodist_src_libnma_libnma_la_SOURCES = \
- $(libnma_h_priv_gen) \
- $(libnma_c_gen)
-
-src_libnma_libnma_la_CFLAGS = \
- $(dflt_cppflags) \
- -DICONDIR=\""$(datadir)/icons"\" \
- -DBINDIR=\""$(bindir)"\" \
- -DSYSCONFDIR=\""$(sysconfdir)"\" \
- -DLIBEXECDIR=\""$(libexecdir)"\" \
- -DDATADIR=\""$(datadir)"\" \
- -DAUTOSTARTDIR=\""$(sysconfdir)/xdg/autostart"\" \
- -DNMALOCALEDIR=\"$(datadir)/locale\" \
- -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB \
- "-I$(srcdir)/shared" \
- "-I$(srcdir)/src/utils" \
- "-I$(srcdir)/src/wireless-security" \
- "-I$(srcdir)/src/libnma" \
- -Isrc/libnma \
- $(GTK3_CFLAGS) \
- $(LIBNM_CFLAGS) \
- $(GUDEV_CFLAGS) \
- $(GCR_CFLAGS)
-
-src_libnma_libnma_la_LIBADD = \
- src/wireless-security/libwireless-security-libnm.la \
- $(GTK3_LIBS) \
- $(LIBNM_LIBS) \
- $(GUDEV_LIBS) \
- $(GCR_LIBS)
-
-EXTRA_src_libnma_libnma_la_DEPENDENCIES = src/libnma/libnma.ver
-
-src_libnma_libnma_la_LDFLAGS = \
- -Wl,-no-undefined \
- -Wl,--version-script=$(srcdir)/src/libnma/libnma.ver
-
-
-pkgconfig_DATA += src/libnma/libnma.pc
-
-if HAVE_INTROSPECTION
-src/libnma/NMA-1.0.gir: src/libnma/libnma.la
-src_libnma_NMA_1_0_gir_INCLUDES = NM-1.0 Gtk-3.0
-src_libnma_NMA_1_0_gir_EXPORT_PACKAGES = libnma
-src_libnma_NMA_1_0_gir_CFLAGS = $(src_libnma_libnma_la_CFLAGS)
-src_libnma_NMA_1_0_gir_LIBS = src/libnma/libnma.la
-src_libnma_NMA_1_0_gir_FILES = \
- $(libnma_h_pub) \
- $(libnma_c_real)
-if WITH_GCR
-src_libnma_NMA_1_0_gir_FILES += \
- $(libnma_c_gcr)
-endif
-src_libnma_NMA_1_0_gir_SCANNERFLAGS = --warn-all --identifier-prefix=NMA --symbol-prefix=nma
-INTROSPECTION_GIRS += src/libnma/NMA-1.0.gir
-endif
-
-check_PROGRAMS_norun += src/libnma/tests/mobile-wizard
-
-src_libnma_tests_mobile_wizard_CPPFLAGS = \
- $(dflt_cppflags) \
- $(GLIB_CFLAGS) \
- $(GTK3_CFLAGS) \
- $(LIBNM_CFLAGS) \
- "-I$(srcdir)/shared/" \
- "-I$(srcdir)/src/libnma" \
- -Isrc/libnma
-
-src_libnma_tests_mobile_wizard_LDADD = \
- $(GLIB_LIBS) \
- $(GTK3_LIBS) \
- $(LIBNM_LIBS) \
- src/libnma/libnma.la
-
-check_PROGRAMS_norun += src/libnma/tests/vpn-password-dialog
-
-src_libnma_tests_vpn_password_dialog_CPPFLAGS = \
- $(dflt_cppflags) \
- $(GLIB_CFLAGS) \
- $(GTK3_CFLAGS) \
- $(LIBNM_CFLAGS) \
- "-I$(srcdir)/shared/" \
- "-I$(srcdir)/src/libnma" \
- -Isrc/libnma
-
-src_libnma_tests_vpn_password_dialog_LDADD = \
- $(GLIB_LIBS) \
- $(GTK3_LIBS) \
- $(LIBNM_LIBS) \
- src/libnma/libnma.la
-
-check_PROGRAMS_norun += src/libnma/tests/wifi-dialog
-
-src_libnma_tests_wifi_dialog_CPPFLAGS = \
- $(dflt_cppflags) \
- $(GLIB_CFLAGS) \
- $(GTK3_CFLAGS) \
- $(LIBNM_CFLAGS) \
- "-I$(srcdir)/shared/" \
- "-I$(srcdir)/src/libnma" \
- -Isrc/libnma
-
-src_libnma_tests_wifi_dialog_LDADD = \
- $(GLIB_LIBS) \
- $(GTK3_LIBS) \
- $(LIBNM_LIBS) \
- src/libnma/libnma.la
-
-check_PROGRAMS_norun += src/libnma/tests/wifi-dialog-secrets
-
-src_libnma_tests_wifi_dialog_secrets_CPPFLAGS = \
- $(dflt_cppflags) \
- $(GLIB_CFLAGS) \
- $(GTK3_CFLAGS) \
- $(LIBNM_CFLAGS) \
- "-I$(srcdir)/shared/" \
- "-I$(srcdir)/src/libnma" \
- -Isrc/libnma
-
-src_libnma_tests_wifi_dialog_secrets_LDADD = \
- $(GLIB_LIBS) \
- $(GTK3_LIBS) \
- $(LIBNM_LIBS) \
- src/libnma/libnma.la
-
-check_PROGRAMS_norun += src/libnma/tests/run-vpn
-
-src_libnma_tests_run_vpn_CPPFLAGS = \
- $(dflt_cppflags) \
- $(GLIB_CFLAGS) \
- $(GTK3_CFLAGS) \
- $(LIBNM_CFLAGS) \
- "-I$(srcdir)/shared/" \
- "-I$(srcdir)/src/libnma" \
- -Isrc/libnma
-
-src_libnma_tests_run_vpn_LDADD = \
- $(GLIB_LIBS) \
- $(GTK3_LIBS) \
- $(LIBNM_LIBS) \
- src/libnma/libnma.la
-
-check_PROGRAMS_norun += src/libnma/tests/cert-chooser
-
-src_libnma_tests_cert_chooser_CPPFLAGS = \
- $(dflt_cppflags) \
- $(GLIB_CFLAGS) \
- $(GTK3_CFLAGS) \
- $(LIBNM_CFLAGS) \
- "-I$(srcdir)/shared/" \
- "-I$(srcdir)/src/libnma" \
- -Isrc/libnma
-
-src_libnma_tests_cert_chooser_LDADD = \
- $(GLIB_LIBS) \
- $(GTK3_LIBS) \
- $(LIBNM_LIBS) \
- src/libnma/libnma.la
-
-check_PROGRAMS_norun += src/libnma/tests/bar-code
-
-src_libnma_tests_bar_code_CPPFLAGS = \
- $(dflt_cppflags) \
- $(GLIB_CFLAGS) \
- $(GTK3_CFLAGS) \
- $(LIBNM_CFLAGS) \
- "-I$(srcdir)/shared/" \
- "-I$(srcdir)/src/libnma" \
- -Isrc/libnma
-
-src_libnma_tests_bar_code_LDADD = \
- $(GLIB_LIBS) \
- $(GTK3_LIBS) \
- $(LIBNM_LIBS) \
- src/libnma/libnma.la
-
-if WITH_LIBNMA_GTK4
-
-lib_LTLIBRARIES += src/libnma/libnma-gtk4.la
-
-src_libnma_libnma_gtk4_la_SOURCES = \
- $(libnma_h_priv_real) \
- $(libnma_c_real)
-
-if WITH_GCR_GTK4
-src_libnma_libnma_gtk4_la_SOURCES += \
- $(libnma_h_priv_gcr) \
- $(libnma_c_gcr)
-endif
-
-nodist_src_libnma_libnma_gtk4_la_SOURCES = \
- $(libnma_h_priv_gen) \
- $(libnma_gtk4_c_gen)
-
-src_libnma_libnma_gtk4_la_CFLAGS = \
- -DICONDIR=\""$(datadir)/icons"\" \
- -DBINDIR=\""$(bindir)"\" \
- -DSYSCONFDIR=\""$(sysconfdir)"\" \
- -DLIBEXECDIR=\""$(libexecdir)"\" \
- -DDATADIR=\""$(datadir)"\" \
- -DAUTOSTARTDIR=\""$(sysconfdir)/xdg/autostart"\" \
- -DNMALOCALEDIR=\"$(datadir)/locale\" \
- -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB \
- "-I$(srcdir)/shared" \
- "-I$(srcdir)/src/utils" \
- "-I$(srcdir)/src/wireless-security" \
- "-I$(srcdir)/src/libnma" \
- -Isrc/libnma \
- $(GTK4_CFLAGS) \
- $(LIBNM_CFLAGS) \
- $(GUDEV_CFLAGS) \
- $(GCR_GCR4_CFLAGS)
-
-src_libnma_libnma_gtk4_la_LIBADD = \
- src/wireless-security/libwireless-security-libnm-gtk4.la \
- $(GTK4_LIBS) \
- $(LIBNM_LIBS) \
- $(GUDEV_LIBS) \
- $(GCR_GCR4_LIBS)
-
-EXTRA_src_libnma_libnma_gtk4_la_DEPENDENCIES = src/libnma/libnma.ver
-
-src_libnma_libnma_gtk4_la_LDFLAGS = \
- -Wl,-no-undefined \
- -Wl,--version-script=$(srcdir)/src/libnma/libnma.ver
-
-
-pkgconfig_DATA += src/libnma/libnma-gtk4.pc
-
-if HAVE_INTROSPECTION
-src/libnma/NMA4-1.0.gir: src/libnma/libnma-gtk4.la
-src_libnma_NMA4_1_0_gir_INCLUDES = NM-1.0 Gtk-4.0
-src_libnma_NMA4_1_0_gir_EXPORT_PACKAGES = libnma-gtk4
-src_libnma_NMA4_1_0_gir_CFLAGS = $(src_libnma_libnma_gtk4_la_CFLAGS)
-src_libnma_NMA4_1_0_gir_LIBS = src/libnma/libnma-gtk4.la
-src_libnma_NMA4_1_0_gir_FILES = \
- $(libnma_h_pub) \
- $(libnma_c_real)
-if WITH_GCR_GTK4
-src_libnma_NMA4_1_0_gir_FILES += \
- $(libnma_c_gcr)
-endif
-src_libnma_NMA4_1_0_gir_SCANNERFLAGS = --warn-all --identifier-prefix=NMA --symbol-prefix=nma
-INTROSPECTION_GIRS += src/libnma/NMA4-1.0.gir
-endif
-
-check_PROGRAMS_norun += src/libnma/tests/mobile-wizard-gtk4
-
-src_libnma_tests_mobile_wizard_gtk4_SOURCES = \
- src/libnma/tests/mobile-wizard.c
-
-src_libnma_tests_mobile_wizard_gtk4_CPPFLAGS = \
- $(dflt_cppflags) \
- $(GLIB_CFLAGS) \
- $(GTK4_CFLAGS) \
- $(LIBNM_CFLAGS) \
- "-I$(srcdir)/shared/" \
- "-I$(srcdir)/src/libnma" \
- -Isrc/libnma
-
-src_libnma_tests_mobile_wizard_gtk4_LDADD = \
- $(GLIB_LIBS) \
- $(GTK4_LIBS) \
- $(LIBNM_LIBS) \
- src/libnma/libnma-gtk4.la
-
-check_PROGRAMS_norun += src/libnma/tests/vpn-password-dialog-gtk4
-
-src_libnma_tests_vpn_password_dialog_gtk4_SOURCES = \
- src/libnma/tests/vpn-password-dialog.c
-
-src_libnma_tests_vpn_password_dialog_gtk4_CPPFLAGS = \
- $(dflt_cppflags) \
- $(GLIB_CFLAGS) \
- $(GTK4_CFLAGS) \
- $(LIBNM_CFLAGS) \
- "-I$(srcdir)/shared/" \
- "-I$(srcdir)/src/libnma" \
- -Isrc/libnma
-
-src_libnma_tests_vpn_password_dialog_gtk4_LDADD = \
- $(GLIB_LIBS) \
- $(GTK4_LIBS) \
- $(LIBNM_LIBS) \
- src/libnma/libnma-gtk4.la
-
-check_PROGRAMS_norun += src/libnma/tests/wifi-dialog-gtk4
-
-src_libnma_tests_wifi_dialog_gtk4_SOURCES = \
- src/libnma/tests/wifi-dialog.c
-
-src_libnma_tests_wifi_dialog_gtk4_CPPFLAGS = \
- $(dflt_cppflags) \
- $(GLIB_CFLAGS) \
- $(GTK4_CFLAGS) \
- $(LIBNM_CFLAGS) \
- "-I$(srcdir)/shared/" \
- "-I$(srcdir)/src/libnma" \
- -Isrc/libnma
-
-src_libnma_tests_wifi_dialog_gtk4_LDADD = \
- $(GLIB_LIBS) \
- $(GTK4_LIBS) \
- $(LIBNM_LIBS) \
- src/libnma/libnma-gtk4.la
-
-check_PROGRAMS_norun += src/libnma/tests/wifi-dialog-secrets-gtk4
-
-src_libnma_tests_wifi_dialog_secrets_gtk4_SOURCES = \
- src/libnma/tests/wifi-dialog-secrets.c
-
-src_libnma_tests_wifi_dialog_secrets_gtk4_CPPFLAGS = \
- $(dflt_cppflags) \
- $(GLIB_CFLAGS) \
- $(GTK4_CFLAGS) \
- $(LIBNM_CFLAGS) \
- "-I$(srcdir)/shared/" \
- "-I$(srcdir)/src/libnma" \
- -Isrc/libnma
-
-src_libnma_tests_wifi_dialog_secrets_gtk4_LDADD = \
- $(GLIB_LIBS) \
- $(GTK4_LIBS) \
- $(LIBNM_LIBS) \
- src/libnma/libnma-gtk4.la
-
-check_PROGRAMS_norun += src/libnma/tests/run-vpn-gtk4
-
-src_libnma_tests_run_vpn_gtk4_SOURCES = \
- src/libnma/tests/run-vpn.c
-
-src_libnma_tests_run_vpn_gtk4_CPPFLAGS = \
- $(dflt_cppflags) \
- $(GLIB_CFLAGS) \
- $(GTK4_CFLAGS) \
- $(LIBNM_CFLAGS) \
- "-I$(srcdir)/shared/" \
- "-I$(srcdir)/src/libnma" \
- -Isrc/libnma
-
-src_libnma_tests_run_vpn_gtk4_LDADD = \
- $(GLIB_LIBS) \
- $(GTK4_LIBS) \
- $(LIBNM_LIBS) \
- src/libnma/libnma-gtk4.la
-
-check_PROGRAMS_norun += src/libnma/tests/cert-chooser-gtk4
-
-src_libnma_tests_cert_chooser_gtk4_SOURCES = \
- src/libnma/tests/cert-chooser.c
-
-src_libnma_tests_cert_chooser_gtk4_CPPFLAGS = \
- $(dflt_cppflags) \
- $(GLIB_CFLAGS) \
- $(GTK4_CFLAGS) \
- $(LIBNM_CFLAGS) \
- "-I$(srcdir)/shared/" \
- "-I$(srcdir)/src/libnma" \
- -Isrc/libnma
-
-src_libnma_tests_cert_chooser_gtk4_LDADD = \
- $(GLIB_LIBS) \
- $(GTK4_LIBS) \
- $(LIBNM_LIBS) \
- src/libnma/libnma-gtk4.la
-
-check_PROGRAMS_norun += src/libnma/tests/bar-code-gtk4
-
-src_libnma_tests_bar_code_gtk4_SOURCES = \
- src/libnma/tests/bar-code.c
-
-src_libnma_tests_bar_code_gtk4_CPPFLAGS = \
- $(dflt_cppflags) \
- $(GLIB_CFLAGS) \
- $(GTK4_CFLAGS) \
- $(LIBNM_CFLAGS) \
- "-I$(srcdir)/shared/" \
- "-I$(srcdir)/src/libnma" \
- -Isrc/libnma
-
-src_libnma_tests_bar_code_gtk4_LDADD = \
- $(GLIB_LIBS) \
- $(GTK4_LIBS) \
- $(LIBNM_LIBS) \
- src/libnma/libnma-gtk4.la
-
-endif
-
-EXTRA_DIST += \
- src/libnma/nma-version.h.in \
- src/libnma/libnma.pc.in \
- src/libnma/libnma-gtk4.pc.in \
- src/libnma/libnma.ver \
- src/libnma/wifi.ui \
- src/libnma/nma-mobile-wizard.ui \
- src/libnma/nma-bar-code-widget.ui \
- src/libnma/nma-pkcs11-token-login-dialog.ui \
- src/libnma/nma-pkcs11-cert-chooser-dialog.ui \
- src/libnma/nma-vpn-password-dialog.ui \
- src/libnma/nma.gresource.xml \
- src/libnma/meson.build \
- src/libnma/tests/meson.build
-
-###############################################################################
-
src/connection-editor/ce-resources.h: src/connection-editor/ce.gresource.xml
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $< --target=$@ --sourcedir=$(srcdir)/src/connection-editor --generate-header --internal
@@ -949,18 +397,17 @@ src_connection_editor_nm_connection_editor_CPPFLAGS = \
"-I$(srcdir)/shared" \
"-I$(srcdir)/src/utils" \
"-I$(srcdir)/src/wireless-security" \
- "-I$(srcdir)/src/libnma" \
- -Isrc/libnma \
$(GTK3_CFLAGS) \
+ $(LIBNMA_CFLAGS) \
$(LIBNM_CFLAGS) \
$(JANSSON_CFLAGS) \
$(SELINUX_CFLAGS)
src_connection_editor_nm_connection_editor_LDADD = \
src/wireless-security/libwireless-security-libnm.la \
- src/libnma/libnma.la \
$(GTK3_LIBS) \
$(LIBNM_LIBS) \
+ $(LIBNMA_LIBS) \
$(JANSSON_LIBS) \
$(SELINUX_LIBS) \
-lm
@@ -1076,9 +523,8 @@ src_nm_applet_CPPFLAGS = \
"-I$(srcdir)/shared" \
"-I$(srcdir)/src/utils" \
"-I$(srcdir)/src/wireless-security" \
- "-I$(srcdir)/src/libnma" \
- -Isrc/libnma \
$(GTK3_CFLAGS) \
+ $(LIBNMA_CFLAGS) \
$(LIBNM_CFLAGS) \
$(LIBSECRET_CFLAGS) \
$(NOTIFY_CFLAGS) \
@@ -1087,9 +533,9 @@ src_nm_applet_CPPFLAGS = \
src_nm_applet_LDADD = \
src/wireless-security/libwireless-security-libnm.la \
- src/libnma/libnma.la \
$(GTK3_LIBS) \
$(LIBNM_LIBS) \
+ $(LIBNMA_LIBS) \
$(LIBSECRET_LIBS) \
$(NOTIFY_LIBS) \
$(MM_GLIB_LIBS) \
@@ -1138,43 +584,6 @@ EXTRA_DIST += man/meson.build
###############################################################################
-DOC_MODULE = libnma
-
-DOC_SOURCE_DIR = $(top_srcdir)/src/libnma
-
-SCAN_OPTIONS=--rebuild-types --rebuild-sections
-
-DOC_MAIN_SGML_FILE = libnma-docs.xml
-
-GTKDOC_LIBS = src/libnma/libnma.la
-
-scan-build.stamp: $(GTKDOC_LIBS)
-
-HFILE_GLOB = $(top_srcdir)/src/libnma/*.h
-
-CFILE_GLOB = $(top_srcdir)/src/libnma/*.c
-
-IGNORE_HFILES = \
- nma-resources.h \
- nma-version.h \
- nma-cert-chooser-private.h \
- nma-private.h \
- nma-pkcs11-token-login-dialog.h \
- nma-pkcs11-cert-chooser-dialog.h \
- nma-cert-chooser-button.h
-
-mkdb_ignore_c_files = \
- nma-resources.c \
- nma-file-cert-chooser.c \
- nma-pkcs11-token-login-dialog.c \
- nma-pkcs11-cert-chooser-dialog.c \
- nma-cert-chooser-button.c \
- nma-pkcs11-cert-chooser.c
-
-MKDB_OPTIONS = --ignore-files "$(IGNORE_HFILES) $(mkdb_ignore_c_files)"
-
-###############################################################################
-
check_PROGRAMS += $(check_programs)
check-local: $(check_local)
@@ -1232,7 +641,6 @@ EXTRA_DIST += \
$(desktop_in_files)
CLEANFILES += \
- $(INTROSPECTION_GIRS) \
$(typelib_DATA) \
\
$(autostart_DATA) \
diff --git a/autogen.sh b/autogen.sh
index cbdc5c44..37363e75 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -14,7 +14,6 @@ PKG_NAME=nm-applet
}
(cd $srcdir;
- gtkdocize &&
autoreconf --force --install --symlink
)
diff --git a/configure.ac b/configure.ac
index 727fed30..5a46cde3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -68,69 +68,14 @@ GETTEXT_PACKAGE=nm-applet
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package])
-# Check for iso-codes for country names translation
-AC_MSG_CHECKING([whether to disable iso-codes at build-time])
-AC_ARG_ENABLE([iso-codes],
- AS_HELP_STRING([--disable-iso-codes],[do not check for iso-codes at build-time]),
- [],[disable_iso_codes_check=no])
-if test x$disable_iso_codes_check = xno ; then
- AC_MSG_RESULT([no])
-else
- AC_MSG_RESULT([yes])
-fi
-
-if test x$disable_iso_codes_check = "xno" ; then
- AC_MSG_CHECKING([whether iso-codes has iso_3166 domain])
- if $PKG_CONFIG --variable=domains iso-codes | grep iso_3166 >/dev/null ; then
- AC_MSG_RESULT([yes])
- else
- AC_MSG_RESULT([no])
- fi
- AC_DEFINE_UNQUOTED([ISO_CODES_PREFIX],["`$PKG_CONFIG --variable=prefix iso-codes`"],[ISO codes prefix])
- PKG_CHECK_MODULES(ISO_CODES, [iso-codes],
- [],
- [echo -e "\n$ISO_CODES_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 'iso-codes' via --disable-iso-codes";
- exit 1;])
-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
-GTK_DOC_CHECK(1.0)
-
PKG_CHECK_MODULES(LIBNM, [libnm >= 1.7 gio-2.0 >= 2.38 gmodule-export-2.0])
LIBNM_CFLAGS="$LIBNM_CFLAGS -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_38"
LIBNM_CFLAGS="$LIBNM_CFLAGS -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_38"
LIBNM_CFLAGS="$LIBNM_CFLAGS -DNM_VERSION_MIN_REQUIRED=NM_VERSION_1_8"
LIBNM_CFLAGS="$LIBNM_CFLAGS -DNM_VERSION_MAX_ALLOWED=NM_VERSION_1_8"
+PKG_CHECK_MODULES(LIBNMA, libnma)
+
PKG_CHECK_MODULES(LIBSECRET, [libsecret-1 >= 0.18])
# Check for libnotify >= 0.7
@@ -143,20 +88,6 @@ PKG_CHECK_MODULES(NOTIFY, [libnotify >= 0.4.3])
PKG_CHECK_MODULES(GTK3, gtk+-3.0 >= 3.10)
GTK3_CFLAGS="$GTK3_CFLAGS -DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_10 -DGDK_VERSION_MAX_ALLOWED=GDK_VERSION_3_10"
-AC_ARG_WITH(libnma-gtk4, AS_HELP_STRING([--with-libnma-gtk4], [build EXPERIMENTAL libnma-gtk4 library for use with GTK4]))
-if test "$with_libnma_gtk4" == yes; then
- PKG_CHECK_MODULES(GTK4, gtk4 >= 3.94)
- GTK4_CFLAGS="$GTK4_CFLAGS -DGTK_VERSION_MIN_REQUIRED=GTK_VERSION_3_96 -DGTK_VERSION_MAX_ALLOWED=GTK_VERSION_3_96"
-else
- with_libnma_gtk4=no
-fi
-AM_CONDITIONAL(WITH_LIBNMA_GTK4, test "$with_libnma_gtk4" != "no")
-
-# No such thing yet, just same lame duck placeholders.
-# it may actually end up being called differently.
-AC_DEFINE(WITH_GCR_GTK4, 0, [Define if GTK4 Gcr is available])
-AM_CONDITIONAL(WITH_GCR_GTK4, false)
-
AC_ARG_WITH([appindicator],
AS_HELP_STRING([--with-appindicator=no|yes|auto|ayatana|ubuntu], [Build with lib(ayatana-)appindicator support in addition to xembed systray support.]),
[], [with_appindicator=no])
@@ -188,8 +119,6 @@ if test "$with_appindicator" != "no"; then
fi
fi
-AM_CONDITIONAL(HAVE_GBT, test x"$have_gbt" = "xyes")
-
dnl ModemManager1 with libmm-glib for WWAN support
AC_ARG_WITH(wwan, AS_HELP_STRING([--with-wwan], [Enable WWAN support (default: yes)]))
if (test "${with_wwan}" == "no"); then
@@ -229,79 +158,6 @@ else
fi
AM_CONDITIONAL(WITH_JANSSON, test "${with_team}" != "no")
-dnl GCR for PKCS#11 enabled certificate chooser
-AC_ARG_WITH(gcr, AS_HELP_STRING([--with-gcr], [Enable advanced certificate chooser (default: auto)]))
-if (test "${with_gcr}" == "no"); then
- have_gcr=no
-else
- PKG_CHECK_MODULES(GCR,
- [gcr-3 >= 3.14, gck-1 >= 3.14],
- dnl GCR API is declared subject to change, do an extensive check of the prototypes
- GCR_CFLAGS="$GCR_CFLAGS -DGCR_API_SUBJECT_TO_CHANGE -DGCK_API_SUBJECT_TO_CHANGE"
- CFLAGS_SAVED="$CFLAGS"
- CFLAGS="$CFLAGS $GCR_CFLAGS"
- AC_MSG_CHECKING([for GCR usefulness])
- AC_COMPILE_IFELSE([AC_LANG_SOURCE([
- #include <gcr/gcr.h>
- #include <gck/gck.h>
-
- const GckAttribute *gck_attributes_find (GckAttributes *attrs, gulong attr_type);
- gboolean gck_attributes_find_string (GckAttributes *attrs, gulong attr_type, gchar **value);
- gboolean gck_attributes_find_ulong (GckAttributes *attrs, gulong attr_type, gulong *value);
- GckAttributes *gck_attributes_new_empty (gulong first_type, ...);
- void gck_attributes_unref (gpointer attrs);
- void gck_builder_add_all (GckBuilder *builder, GckAttributes *attrs);
- void gck_builder_add_only (GckBuilder *builder, GckAttributes *attrs, gulong only_type, ...);
- GckAttributes *gck_builder_end (GckBuilder *builder);
- GckBuilder *gck_builder_new (GckBuilderFlags flags);
- void gck_enumerator_next_async (GckEnumerator *self, gint max_objects, GCancellable *cancellable,
- GAsyncReadyCallback callback, gpointer user_data);
- GList *gck_enumerator_next_finish (GckEnumerator *self, GAsyncResult *result, GError **error);
- void gck_list_unref_free (GList *reflist);
- GList *gck_modules_get_slots (GList *modules, gboolean token_present);
- void gck_modules_initialize_registered_async (GCancellable *cancellable, GAsyncReadyCallback callback,
- gpointer user_data);
- GList *gck_modules_initialize_registered_finish (GAsyncResult *result, GError **error);
- void gck_object_get_async (GckObject *self, const gulong *attr_types, guint n_attr_types,
- GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data);
- GckAttributes *gck_object_get_finish (GckObject *self, GAsyncResult *result, GError **error);
- void gck_session_login_async (GckSession *self, gulong user_type, const guchar *pin,
- gsize n_pin, GCancellable *cancellable,
- GAsyncReadyCallback callback, gpointer user_data);
- gboolean gck_session_login_finish (GckSession *self, GAsyncResult *result, GError **error);
- GckSlotInfo *gck_slot_get_info (GckSlot *self);
- GckTokenInfo *gck_slot_get_token_info (GckSlot *self);
- void gck_slot_open_session_async (GckSlot *self, GckSessionOptions options, GCancellable *cancellable,
- GAsyncReadyCallback callback, gpointer user_data);
- GckSession *gck_slot_open_session_finish (GckSlot *self, GAsyncResult *result, GError **error);
- void gck_token_info_free (GckTokenInfo *token_info);
- gchar *gck_uri_build (GckUriData *uri_data, GckUriFlags flags);
- void gck_uri_data_free (GckUriData *uri_data);
- GckUriData *gck_uri_parse (const gchar *string, GckUriFlags flags, GError **error);
- gchar *gcr_certificate_get_issuer_name (GcrCertificate *self);
- gchar *gcr_certificate_get_subject_name (GcrCertificate *self);
- GcrCertificate *gcr_simple_certificate_new (const guchar *data, gsize n_data);
- ])],
- have_gcr=yes,
- have_gcr=no)
- AC_MSG_RESULT(${have_gcr})
- CFLAGS="$CFLAGS_SAVED",
- have_gcr=no);
-fi
-
-if (test "${have_gcr}" == "yes"); then
- AC_DEFINE(WITH_GCR, 1, [Define if Gcr is available])
-else
- if (test "${with_gcr}" == "yes"); then
- AC_MSG_ERROR([gcr support was requested, but the gcr library is not available.])
- fi
- AC_DEFINE(WITH_GCR, 0, [Define if Gcr is available])
-fi
-AM_CONDITIONAL(WITH_GCR, test "${have_gcr}" == "yes")
-
-dnl Check for gobject introspection
-GOBJECT_INTROSPECTION_CHECK([0.9.6])
-
GLIB_CONFIG_NMA
GLIB_GSETTINGS
AC_PATH_PROG(GLIB_COMPILE_RESOURCES, glib-compile-resources)
@@ -310,15 +166,6 @@ NM_COMPILER_WARNINGS(CFLAGS, [yes])
NM_LTO
NM_LD_GC
-# Disable extra compiler warning until GTK4 doesn't trigger it via graphene
-# https://github.com/ebassi/graphene/issues/134
-if test "$with_libnma_gtk4" == yes; then
- _CFLAGS_SAVED="$CFLAGS"
- CFLAGS="$CFLAGS $GTK4_CFLAGS"
- NM_COMPILER_WARNING([_CFLAGS], [float-equal], [#include <gtk/gtk.h>])
- CFLAGS="$_CFLAGS_SAVED $_CFLAGS"
-fi
-
AC_ARG_WITH(more-asserts,
AS_HELP_STRING([--with-more-asserts=level], [Enable more assertions for debugging (default: 0)]),
[more_asserts=${with_more_asserts}],
@@ -335,19 +182,14 @@ AC_DEFINE_UNQUOTED(NM_MORE_ASSERTS, $more_asserts, [Define if more asserts are e
AC_CONFIG_FILES([
Makefile
-src/libnma/libnma.pc
-src/libnma/libnma-gtk4.pc
po/Makefile.in
man/nm-applet.1
man/nm-connection-editor.1
org.gnome.nm-applet.gschema.xml
-src/libnma/nma-version.h
])
AC_OUTPUT
echo ""
-echo " Build EXPERIMENTAL libnma-gtk4 library for use with GTK4: --with-libnma-gtk4=${with_libnma_gtk4}"
-echo " GCR: --with-gcr=$have_gcr"
echo " LTO: --enable-lto=$enable_lto"
echo " Linker garbage collection: --enable-ld-gc=$enable_ld_gc"
echo " appindicator: $with_appindicator"
diff --git a/m4/introspection.m4 b/m4/introspection.m4
deleted file mode 100644
index f3bda0e7..00000000
--- a/m4/introspection.m4
+++ /dev/null
@@ -1,93 +0,0 @@
-dnl -*- mode: autoconf -*-
-dnl Copyright 2009 Johan Dahlin
-dnl
-dnl This file is free software; the author(s) gives unlimited
-dnl permission to copy and/or distribute it, with or without
-dnl modifications, as long as this notice is preserved.
-dnl
-
-# serial 1
-
-m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL],
-[
- AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first
- AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first
- AC_BEFORE([LT_INIT],[$0])dnl setup libtool first
-
- dnl enable/disable introspection
- m4_if([$2], [require],
- [dnl
- enable_introspection=yes
- ],[dnl
- AC_ARG_ENABLE(introspection,
- AS_HELP_STRING([--enable-introspection[=@<:@no/auto/yes@:>@]],
- [Enable introspection for this build]),,
- [enable_introspection=auto])
- ])dnl
-
- INTROSPECTION_SCANNER=
- INTROSPECTION_COMPILER=
- INTROSPECTION_GENERATE=
- INTROSPECTION_GIRDIR=
- INTROSPECTION_TYPELIBDIR=
-
- if test "x$enable_introspection" == "xno"; then
- found_introspection="no"
- else
- PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], [
- INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0`
- INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0`
- INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0`
- INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0`
- INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)"
- INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0`
- INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0`
- INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection
-
- AC_MSG_CHECKING([if $INTROSPECTION_SCANNER works])
- if CFLAGS="${CFLAGS} -Wno-error" "$INTROSPECTION_SCANNER" --namespace=test --library=c /dev/null --output /dev/null >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
- found_introspection=yes
- else
- found_introspection="no (compiler failure -- check config.log)"
- fi
- AC_MSG_RESULT([$found_introspection])
- ], [found_introspection="no (not installed)"])
-
- if test "x$enable_introspection" == "xyes"; then
- if test "x$found_introspection" != "xyes"; then
- AC_MSG_ERROR([introspection enabled but can't be used])
- fi
- elif test "x$enable_introspection" != "xauto"; then
- AC_MSG_ERROR([invalid argument passed to --enable-introspection, should be one of @<:@no/auto/yes@:>@])
- fi
- fi
-
- AC_SUBST(INTROSPECTION_SCANNER, 'CFLAGS="${CFLAGS} -Wno-error" '"$INTROSPECTION_SCANNER")
- AC_SUBST(INTROSPECTION_COMPILER)
- AC_SUBST(INTROSPECTION_GENERATE)
- AC_SUBST(INTROSPECTION_GIRDIR)
- AC_SUBST(INTROSPECTION_TYPELIBDIR)
- AC_SUBST(INTROSPECTION_CFLAGS)
- AC_SUBST(INTROSPECTION_LIBS)
- AC_SUBST(INTROSPECTION_MAKEFILE)
-
- AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes")
-])
-
-
-dnl Usage:
-dnl GOBJECT_INTROSPECTION_CHECK([minimum-g-i-version])
-
-AC_DEFUN([GOBJECT_INTROSPECTION_CHECK],
-[
- _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1])
-])
-
-dnl Usage:
-dnl GOBJECT_INTROSPECTION_REQUIRE([minimum-g-i-version])
-
-
-AC_DEFUN([GOBJECT_INTROSPECTION_REQUIRE],
-[
- _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1], [require])
-])
diff --git a/meson.build b/meson.build
index 31def378..fc3eacdc 100644
--- a/meson.build
+++ b/meson.build
@@ -74,18 +74,6 @@ if enable_ld_gc
common_ldflags += test_ldflags
endif
-enable_libnma_gtk4 = get_option('libnma_gtk4')
-if enable_libnma_gtk4
- gtk4_ext_dep = dependency('gtk4', version: '>= 3.96')
- gtk4_dep = declare_dependency(
- dependencies: gtk4_ext_dep,
- compile_args: [
- '-DGTK_VERSION_MIN_REQUIRED=GTK_VERSION_3_96',
- '-DGTK_VERSION_MAX_ALLOWED=GTK_VERSION_3_96'
- ]
- )
-endif
-
if nma_debug
test_cflags = [
'-Wdeclaration-after-statement',
@@ -108,12 +96,6 @@ if nma_debug
'-Wvla',
]
- # Disable extra compiler warning until GTK4 doesn't trigger it via graphene
- # https://github.com/ebassi/graphene/issues/134
- if not enable_libnma_gtk4 or cc.compiles('#include <gtk/gtk.h>', dependencies: gtk4_ext_dep, args: ['-Werror=float-equal'])
- test_cflags += '-Wfloat-equal'
- endif
-
common_flags += cc.get_supported_arguments(test_cflags)
endif
@@ -122,37 +104,10 @@ add_project_link_arguments(common_ldflags, language: 'c')
linker_script_ver = join_paths(meson.source_root(), 'linker-script-binary.ver')
-# Check for iso-codes for country names translation
-enable_iso_codes = get_option('iso_codes')
-message('whether to disable iso-codes at build-time: ' + enable_iso_codes.to_string())
-if enable_iso_codes
- iso_codes_dep = dependency('iso-codes')
-
- str = 'Consider installing the package or adjusting the PKG_CONFIG_PATH environment variable.\n'
- str += 'You can also disable build-time check for \'iso-codes\' via -Diso_codes=false'
- assert(iso_codes_dep.found(), str)
-
- iso_3166 = iso_codes_dep.get_pkgconfig_variable('domains').contains('iso_3166')
- message('whether iso-codes has iso_3166 domain: ' + iso_3166.to_string())
-
- config_h.set_quoted('ISO_CODES_PREFIX', iso_codes_dep.get_pkgconfig_variable('prefix'))
-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_datadir, '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')
+libnma_dep = dependency('libnma')
m_dep = cc.find_library('m')
@@ -258,85 +213,6 @@ if enable_team
endif
config_h.set10('WITH_JANSSON', enable_team)
-# GCR for PKCS#11 enabled certificate chooser
-enable_gcr = get_option('gcr')
-if enable_gcr
- deps = [
- dependency('gcr-3', version: '>= 3.14'),
- dependency('gck-1', version: '>= 3.14')
- ]
-
- cflags = [
- '-DGCR_API_SUBJECT_TO_CHANGE',
- '-DGCK_API_SUBJECT_TO_CHANGE'
- ]
-
- # GCR API is declared subject to change, do an extensive check of the prototypes
- gcr_src = '''
- #ifndef GCR_API_SUBJECT_TO_CHANGE
- # define GCR_API_SUBJECT_TO_CHANGE
- #endif
- #ifndef GCK_API_SUBJECT_TO_CHANGE
- # define GCK_API_SUBJECT_TO_CHANGE
- #endif
-
- #include <gcr/gcr.h>
- #include <gck/gck.h>
-
- const GckAttribute *gck_attributes_find (GckAttributes *attrs, gulong attr_type);
- gboolean gck_attributes_find_string (GckAttributes *attrs, gulong attr_type, gchar **value);
- gboolean gck_attributes_find_ulong (GckAttributes *attrs, gulong attr_type, gulong *value);
- GckAttributes *gck_attributes_new_empty (gulong first_type, ...);
- void gck_attributes_unref (gpointer attrs);
- void gck_builder_add_all (GckBuilder *builder, GckAttributes *attrs);
- void gck_builder_add_only (GckBuilder *builder, GckAttributes *attrs, gulong only_type, ...);
- GckAttributes *gck_builder_end (GckBuilder *builder);
- GckBuilder *gck_builder_new (GckBuilderFlags flags);
- void gck_enumerator_next_async (GckEnumerator *self, gint max_objects, GCancellable *cancellable,
- GAsyncReadyCallback callback, gpointer user_data);
- GList *gck_enumerator_next_finish (GckEnumerator *self, GAsyncResult *result, GError **error);
- void gck_list_unref_free (GList *reflist);
- GList *gck_modules_get_slots (GList *modules, gboolean token_present);
- void gck_modules_initialize_registered_async (GCancellable *cancellable, GAsyncReadyCallback callback,
- gpointer user_data);
- GList *gck_modules_initialize_registered_finish (GAsyncResult *result, GError **error);
- void gck_object_get_async (GckObject *self, const gulong *attr_types, guint n_attr_types,
- GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data);
- GckAttributes *gck_object_get_finish (GckObject *self, GAsyncResult *result, GError **error);
- void gck_session_login_async (GckSession *self, gulong user_type, const guchar *pin,
- gsize n_pin, GCancellable *cancellable,
- GAsyncReadyCallback callback, gpointer user_data);
- gboolean gck_session_login_finish (GckSession *self, GAsyncResult *result, GError **error);
- GckSlotInfo *gck_slot_get_info (GckSlot *self);
- GckTokenInfo *gck_slot_get_token_info (GckSlot *self);
- void gck_slot_open_session_async (GckSlot *self, GckSessionOptions options, GCancellable *cancellable,
- GAsyncReadyCallback callback, gpointer user_data);
- GckSession *gck_slot_open_session_finish (GckSlot *self, GAsyncResult *result, GError **error);
- void gck_token_info_free (GckTokenInfo *token_info);
- gchar *gck_uri_build (GckUriData *uri_data, GckUriFlags flags);
- void gck_uri_data_free (GckUriData *uri_data);
- GckUriData *gck_uri_parse (const gchar *string, GckUriFlags flags, GError **error);
- gchar *gcr_certificate_get_issuer_name (GcrCertificate *self);
- gchar *gcr_certificate_get_subject_name (GcrCertificate *self);
- GcrCertificate *gcr_simple_certificate_new (const guchar *data, gsize n_data);
- '''
-
- assert(cc.compiles(gcr_src, dependencies: deps), 'gcr support was requested, but the gcr library is not available. Use -Dgcr=false to build without it.')
-
- gcr_dep = declare_dependency(
- dependencies: deps,
- compile_args: cflags
- )
-endif
-config_h.set10('WITH_GCR', enable_gcr)
-
-# introspection support
-enable_introspection = get_option('introspection')
-if enable_introspection
- gir_dep = dependency('gobject-introspection-1.0', version: '>= 0.9.6', required: false)
- assert(gir_dep.found(), 'introspection support was requested, but the gobject-introspection library is not available. Use -Dintrospection=false to build without it.')
-endif
-
more_asserts = get_option('more_asserts')
if more_asserts == 'no'
more_asserts = 0
@@ -430,66 +306,6 @@ install_data(
install_dir: join_paths(nma_datadir, 'GConf', 'gsettings')
)
-# documentation
-enable_gtk_doc = get_option('gtk_doc')
-if enable_gtk_doc
- mod_name = 'libnma'
-
- private_headers = [
- 'nma-cert-chooser-button.h',
- 'nma-cert-chooser-private.h',
- 'nma-pkcs11-cert-chooser-dialog.h',
- 'nma-pkcs11-token-login-dialog.h',
- 'nma-resources.h',
- 'nma-private.h',
- 'nma-version.h',
- ]
-
- private_sources = [
- 'nma-cert-chooser-button.c',
- 'nma-file-cert-chooser.c',
- 'nma-pkcs11-cert-chooser-dialog.c',
- 'nma-pkcs11-cert-chooser.c',
- 'nma-pkcs11-token-login-dialog.c',
- 'nma-resources.c'
- ]
-
- ent_conf = configuration_data()
- ent_conf.set_quoted('PACKAGE', meson.project_name())
- ent_conf.set_quoted('PACKAGE_BUGREPORT', 'https://gitlab.gnome.org/GNOME/network-manager-applet/issues')
- ent_conf.set_quoted('PACKAGE_NAME', nma_name)
- ent_conf.set_quoted('PACKAGE_STRING', '@0@ @1@'.format(nma_name, nma_version))
- ent_conf.set_quoted('PACKAGE_TARNAME', meson.project_name())
- ent_conf.set_quoted('PACKAGE_URL', '')
- ent_conf.set_quoted('PACKAGE_VERSION', nma_version)
-
- ent = 'gtkdocentities.ent'
-
- configure_file(
- input: ent + '.in',
- output: ent,
- configuration: ent_conf
- )
-
- doc_path = join_paths(nma_datadir, 'gtk-doc', 'html', mod_name)
-
- gnome.gtkdoc(
- mod_name,
- main_xml: mod_name + '-docs.xml',
- src_dir: libnma_inc,
- dependencies: libnma_dep,
- scan_args: [
- '--rebuild-types',
- '--rebuild-sections',
- '--ignore-headers=' + ' '.join(private_headers)
- ],
- mkdb_args: '--ignore-files=' + ' '.join(private_headers + private_sources),
- gobject_typesfile: mod_name + '.types',
- install: true,
- install_dir: doc_path
- )
-endif
-
config = 'config.h'
configure_file(
@@ -505,8 +321,6 @@ meson.add_install_script(
)
output = '\n'
-output += ' Build EXPERIMENTAL library libnm-gtk4 for use with GTK4: ' + enable_libnma_gtk4.to_string() + '\n'
-output += ' GCR: ' + enable_gcr.to_string() + '\n'
output += ' LTO: ' + get_option('b_lto').to_string() + '\n'
output += ' Linker garbage collection: ' + enable_ld_gc.to_string() + '\n'
output += ' libappindicator: ' + enable_appindicator
diff --git a/meson_options.txt b/meson_options.txt
index 01ee5aec..15f96450 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,12 +1,6 @@
-option('libnma_gtk4', type: 'boolean', value: false, description: 'build EXPERIMENTAL library libnma-gtk4 for use with GTK4')
option('appindicator', type: 'string', value: 'no', description: 'Build with lib(ayatana-)appindicator support in addition to xembed systray support (no|yes|auto|ayatana|ubuntu). Default is "no", "yes" is an alias for "auto".')
option('wwan', type: 'boolean', value: true, description: 'Enable WWAN support.')
option('selinux', type: 'boolean', value: true, description: 'Enable support for adjusting SELinux labels in configuration editor.')
option('team', type: 'boolean', value: true, description: 'Enable team configuration editor.')
-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/po/POTFILES.in b/po/POTFILES.in
index 78b18609..3803b199 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -80,23 +80,6 @@ src/connection-editor/vpn-helpers.c
src/ethernet-dialog.c
src/gsm-unlock.ui
src/info.ui
-src/libnma/nma-bar-code-widget.c
-src/libnma/nma-bar-code-widget.ui
-src/libnma/nma-file-cert-chooser.c
-src/libnma/nma-mobile-providers.c
-src/libnma/nma-mobile-wizard.c
-src/libnma/nma-mobile-wizard.ui
-src/libnma/nma-cert-chooser-button.c
-src/libnma/nma-pkcs11-cert-chooser.c
-src/libnma/nma-pkcs11-cert-chooser-dialog.c
-src/libnma/nma-pkcs11-cert-chooser-dialog.ui
-src/libnma/nma-pkcs11-token-login-dialog.c
-src/libnma/nma-pkcs11-token-login-dialog.ui
-src/libnma/nma-ui-utils.c
-src/libnma/nma-vpn-password-dialog.c
-src/libnma/nma-vpn-password-dialog.ui
-src/libnma/nma-wifi-dialog.c
-src/libnma/wifi.ui
src/main.c
src/mb-menu-item.c
src/mobile-helpers.c
diff --git a/src/libnma/init.c b/src/libnma/init.c
deleted file mode 100644
index 26828592..00000000
--- a/src/libnma/init.c
+++ /dev/null
@@ -1,23 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-
-/*
- * Copyright 2014 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <libintl.h>
-
-static void __attribute__((constructor))
-_libnma_init (void)
-{
- static gboolean initialized = FALSE;
-
- if (initialized)
- return;
- initialized = TRUE;
-
- bindtextdomain (GETTEXT_PACKAGE, NMALOCALEDIR);
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-}
-
diff --git a/src/libnma/libnma-gtk4.pc.in b/src/libnma/libnma-gtk4.pc.in
deleted file mode 100644
index a2cf2b49..00000000
--- a/src/libnma/libnma-gtk4.pc.in
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-includedir=@includedir@
-libdir=@libdir@
-
-Name: libnma
-Description: NetworkManager UI utilities (gtk4 version)
-Version: @PACKAGE_VERSION@
-Requires: libnm
-Cflags: -I${includedir}/libnma
-Libs: -L${libdir} -lnma-gtk4
diff --git a/src/libnma/libnma.pc.in b/src/libnma/libnma.pc.in
deleted file mode 100644
index 9e6f905d..00000000
--- a/src/libnma/libnma.pc.in
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-includedir=@includedir@
-libdir=@libdir@
-
-Name: libnma
-Description: NetworkManager UI utilities (libnm version)
-Version: @PACKAGE_VERSION@
-Requires: libnm
-Cflags: -I${includedir}/libnma
-Libs: -L${libdir} -lnma
diff --git a/src/libnma/libnma.ver b/src/libnma/libnma.ver
deleted file mode 100644
index 9b263d9c..00000000
--- a/src/libnma/libnma.ver
+++ /dev/null
@@ -1,114 +0,0 @@
-libnma_1_2_0 {
-global:
- nma_country_info_get_country_code;
- nma_country_info_get_country_name;
- nma_country_info_get_providers;
- nma_country_info_get_type;
- nma_country_info_ref;
- nma_country_info_unref;
- nma_mobile_access_method_get_3gpp_apn;
- nma_mobile_access_method_get_dns;
- nma_mobile_access_method_get_family;
- nma_mobile_access_method_get_gateway;
- nma_mobile_access_method_get_name;
- nma_mobile_access_method_get_password;
- nma_mobile_access_method_get_type;
- nma_mobile_access_method_get_username;
- nma_mobile_access_method_ref;
- nma_mobile_access_method_unref;
- nma_mobile_provider_get_3gpp_mcc_mnc;
- nma_mobile_provider_get_cdma_sid;
- nma_mobile_provider_get_methods;
- nma_mobile_provider_get_name;
- nma_mobile_provider_get_type;
- nma_mobile_provider_ref;
- nma_mobile_providers_database_dump;
- nma_mobile_providers_database_get_countries;
- nma_mobile_providers_database_get_type;
- nma_mobile_providers_database_lookup_3gpp_mcc_mnc;
- nma_mobile_providers_database_lookup_cdma_sid;
- nma_mobile_providers_database_lookup_country;
- nma_mobile_providers_database_new;
- nma_mobile_providers_database_new_finish;
- nma_mobile_providers_database_new_sync;
- nma_mobile_providers_split_3gpp_mcc_mnc;
- nma_mobile_provider_unref;
- nma_mobile_wizard_destroy;
- nma_mobile_wizard_new;
- nma_mobile_wizard_present;
- nma_utils_menu_to_secret_flags;
- nma_utils_setup_password_storage;
- nma_utils_update_password_storage;
- nma_vpn_password_dialog_focus_password;
- nma_vpn_password_dialog_focus_password_secondary;
- nma_vpn_password_dialog_focus_password_ternary;
- nma_vpn_password_dialog_get_password;
- nma_vpn_password_dialog_get_password_secondary;
- nma_vpn_password_dialog_get_password_ternary;
- nma_vpn_password_dialog_get_type;
- nma_vpn_password_dialog_new;
- nma_vpn_password_dialog_run_and_block;
- nma_vpn_password_dialog_set_password;
- nma_vpn_password_dialog_set_password_label;
- nma_vpn_password_dialog_set_password_secondary;
- nma_vpn_password_dialog_set_password_secondary_label;
- nma_vpn_password_dialog_set_password_ternary;
- nma_vpn_password_dialog_set_password_ternary_label;
- nma_vpn_password_dialog_set_show_password;
- nma_vpn_password_dialog_set_show_password_secondary;
- nma_vpn_password_dialog_set_show_password_ternary;
- nma_wifi_dialog_get_connection;
- nma_wifi_dialog_get_nag_ignored;
- nma_wifi_dialog_get_type;
- nma_wifi_dialog_nag_user;
- nma_wifi_dialog_new;
- nma_wifi_dialog_new_for_create;
- nma_wifi_dialog_new_for_hidden;
- nma_wifi_dialog_new_for_other;
- nma_wifi_dialog_set_nag_ignored;
-local:
- *;
-};
-
-libnma_1_8_0 {
-global:
- nma_cert_chooser_add_to_size_group;
- nma_cert_chooser_get_cert;
- nma_cert_chooser_get_cert_password;
- nma_cert_chooser_get_cert_password_flags;
- nma_cert_chooser_get_cert_uri;
- nma_cert_chooser_get_key;
- nma_cert_chooser_get_key_password;
- nma_cert_chooser_get_key_password_flags;
- nma_cert_chooser_get_key_uri;
- nma_cert_chooser_get_type;
- nma_cert_chooser_new;
- nma_cert_chooser_set_cert;
- nma_cert_chooser_set_cert_password;
- nma_cert_chooser_set_cert_uri;
- nma_cert_chooser_set_key;
- nma_cert_chooser_set_key_password;
- nma_cert_chooser_set_key_uri;
- nma_cert_chooser_setup_cert_password_storage;
- nma_cert_chooser_setup_key_password_storage;
- nma_cert_chooser_update_cert_password_storage;
- nma_cert_chooser_update_key_password_storage;
- nma_cert_chooser_validate;
-} libnma_1_2_0;
-
-libnma_1_8_12 {
- nma_mobile_wizard_get_type;
-} libnma_1_8_0;
-
-libnma_1_8_20 {
- nma_wifi_dialog_new_for_secrets;
-} libnma_1_8_12;
-
-libnma_1_8_22 {
- nma_bar_code_draw;
- nma_bar_code_get_size;
- nma_bar_code_get_type;
- nma_bar_code_new;
- nma_bar_code_widget_get_type;
- nma_bar_code_widget_new;
-} libnma_1_8_12;
diff --git a/src/libnma/meson.build b/src/libnma/meson.build
deleted file mode 100644
index 2432be93..00000000
--- a/src/libnma/meson.build
+++ /dev/null
@@ -1,186 +0,0 @@
-cert_chooser_headers = files('nma-cert-chooser.h')
-
-cert_chooser_sources = files(
- 'nma-cert-chooser.c',
- 'nma-file-cert-chooser.c'
-)
-
-resource_data = files(
- 'nma-pkcs11-cert-chooser-dialog.ui',
- 'nma-pkcs11-token-login-dialog.ui',
- 'wifi.ui'
-)
-
-built_sources = gnome.compile_resources(
- 'nma-resources',
- 'nma.gresource.xml',
- dependencies: resource_data
-)
-
-gir_headers = cert_chooser_headers + files(
- 'nma-bar-code-widget.h',
- 'nma-bar-code.h',
- 'nma-mobile-providers.h',
- 'nma-mobile-wizard.h',
- 'nma-ui-utils.h',
- 'nma-vpn-password-dialog.h',
- 'nma-wifi-dialog.h'
-)
-
-install_headers(
- gir_headers,
- subdir: 'libnma'
-)
-
-gir_sources = [version_header] + cert_chooser_sources + files(
- 'init.c',
- 'nma-bar-code-widget.c',
- 'nma-bar-code.c',
- 'nma-mobile-providers.c',
- 'nma-mobile-wizard.c',
- 'nma-ui-utils.c',
- 'nma-vpn-password-dialog.c',
- 'nma-wifi-dialog.c'
-)
-
-incs = [
- top_inc,
- shared_inc,
- src_inc,
- libnma_inc,
- wireless_security_inc
-]
-
-deps = [
- gudev_dep,
- libnm_dep,
- libutils_libnm_dep,
-]
-
-cflags = [
- '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB',
- '-DBINDIR="@0@"'.format(nma_bindir),
- '-DDATADIR="@0@"'.format(nma_datadir),
- '-DLIBEXECDIR="@0@"'.format(nma_libexecdir),
- '-DNMALOCALEDIR="@0@"'.format(nma_localedir),
- '-DSYSCONFDIR="@0@"'.format(nma_sysconfdir),
- '-DAUTOSTARTDIR="@0@"'.format(nma_autostartdir),
- '-DICONDIR="@0@"'.format(nma_icondir)
-]
-
-symbol_map = join_paths(meson.current_source_dir(), 'libnma.ver')
-
-nma_deps = [ deps, gtk_dep ]
-nma_sources = [ gir_sources, built_sources ]
-if enable_gcr
- nma_sources += files(
- 'nma-cert-chooser-button.c',
- 'nma-pkcs11-cert-chooser.c',
- 'nma-pkcs11-cert-chooser-dialog.c',
- 'nma-pkcs11-token-login-dialog.c'
- )
- nma_deps += gcr_dep
-endif
-
-libnma = shared_library(
- 'nma',
- sources: nma_sources,
- version: libversion,
- include_directories: incs,
- dependencies: nma_deps,
- c_args: cflags,
- link_args: '-Wl,--version-script,' + symbol_map,
- link_depends: symbol_map,
- link_whole: libwireless_security_libnm,
- install: true,
- install_dir: nma_libdir
-)
-
-libnma_dep = declare_dependency(
- link_with: libnma,
- include_directories: libnma_inc
-)
-
-if enable_libnma_gtk4
- libnma_gtk4 = shared_library(
- 'nma-gtk4',
- sources: gir_sources + built_sources,
- version: libversion,
- include_directories: incs,
- dependencies: [ deps, gtk4_dep ],
- c_args: cflags,
- link_args: '-Wl,--version-script,' + symbol_map,
- link_depends: symbol_map,
- link_whole: libwireless_security_libnma_gtk4,
- install: true,
- install_dir: nma_libdir
- )
-
- libnma_gtk4_dep = declare_dependency(
- link_with: libnma_gtk4,
- include_directories: libnma_inc
- )
-endif
-
-subdir('tests')
-
-pkg.generate(
- libraries: libnma,
- version: nma_version,
- name: 'libnma',
- description: 'NetworkManager UI utilities (libnm version)',
- filebase: 'libnma',
- subdirs: 'libnma',
- requires: 'libnm',
- variables: 'exec_prefix=' + nma_prefix,
- install_dir: join_paths(nma_libdir, 'pkgconfig')
-)
-
-if enable_libnma_gtk4
- pkg.generate(
- libraries: libnma_gtk4,
- version: nma_version,
- name: 'libnma-gtk4',
- description: 'NetworkManager UI utilities (gtk4 version)',
- filebase: 'libnma-gtk4',
- subdirs: 'libnma',
- requires: 'libnm',
- variables: 'exec_prefix=' + nma_prefix,
- install_dir: join_paths(nma_libdir, 'pkgconfig')
- )
-endif
-
-if enable_introspection
- gir_dir = join_paths(nma_datadir, 'gir-' + nma_gir_version)
- typelib_dir = join_paths(nma_libdir, 'girepository-' + nma_gir_version)
-
- gnome.generate_gir(
- libnma,
- sources: gir_sources + gir_headers,
- nsversion: nma_gir_version,
- namespace: 'NMA',
- includes: [ 'Gtk-3.0', 'NM-1.0' ],
- identifier_prefix: nma_gir_prefix,
- symbol_prefix: nma_gir_prefix.to_lower(),
- export_packages: 'libnma',
- install: true,
- install_dir_gir: gir_dir,
- install_dir_typelib: typelib_dir
- )
-
- if enable_libnma_gtk4
- gnome.generate_gir(
- libnma,
- sources: gir_sources + gir_headers,
- nsversion: nma_gir_version,
- namespace: 'NMA4',
- includes: [ 'Gtk-4.0', 'NM-1.0' ],
- identifier_prefix: nma_gir_prefix,
- symbol_prefix: nma_gir_prefix.to_lower(),
- export_packages: 'libnma',
- install: true,
- install_dir_gir: gir_dir,
- install_dir_typelib: typelib_dir
- )
- endif
-endif
diff --git a/src/libnma/nma-bar-code-widget.c b/src/libnma/nma-bar-code-widget.c
deleted file mode 100644
index 0d547f2a..00000000
--- a/src/libnma/nma-bar-code-widget.c
+++ /dev/null
@@ -1,462 +0,0 @@
-/* nma-bar-code-widget.h - Renderer of a "QR" code
- *
- * Lubomir Rintel <lkundrak@v3.sk>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License as
- * published by the ree Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * Copyright 2018, 2019 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <stdint.h>
-
-#include "nma-bar-code.h"
-#include "nma-bar-code-widget.h"
-
-#define CARD_WIDTH_PT 252
-#define CARD_HEIGHT_PT 144
-
-struct _NMABarCodeWidget {
- GtkBox parent;
-};
-
-struct _NMABarCodeWidgetClass {
- GtkBoxClass parent_class;
-};
-
-typedef struct {
- NMConnection *connection;
- GtkWidget *qr_code;
- NMABarCode *qr;
-} NMABarCodeWidgetPrivate;
-
-/**
- * SECTION:nma-bar-code-widget
- * @title: NMABarCodeWidget
- *
- * This is a widget that displays a QR code for a connection suitable for
- * optical recognition, e.g. scanning on a phone to connect to a hotspot.
- */
-
-G_DEFINE_TYPE_WITH_CODE (NMABarCodeWidget, nma_bar_code_widget, GTK_TYPE_BOX,
- G_ADD_PRIVATE (NMABarCodeWidget))
-
-enum {
- PROP_0,
- PROP_CONNECTION,
-
- LAST_PROP
-};
-
-#define NMA_BAR_CODE_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
- NMA_TYPE_BAR_CODE_WIDGET, \
- NMABarCodeWidgetPrivate))
-
-static void
-do_qr_code_draw (GtkDrawingArea *area, cairo_t *cr, int width, int height,
- gpointer user_data)
-{
- NMABarCodeWidgetPrivate *priv = NMA_BAR_CODE_WIDGET_GET_PRIVATE (user_data);
- int size = nma_bar_code_get_size (priv->qr);
-
- gtk_widget_set_size_request (priv->qr_code, (size + 2) * 3, (size + 2) * 3);
-
- cairo_set_source_rgba (cr, 1, 1, 1, 1);
- cairo_fill (cr);
- cairo_paint (cr);
- cairo_set_source_rgba (cr, 0, 0, 0, 1);
- cairo_scale (cr, (float)width / (size + 2), (float)height / (size + 2));
- cairo_translate (cr, 1, 1);
- cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
- nma_bar_code_draw (priv->qr, cr);
-}
-
-static gboolean
-qr_code_draw (GtkWidget *widget, cairo_t *cr, gpointer user_data)
-{
- do_qr_code_draw (GTK_DRAWING_AREA (widget), cr,
- gtk_widget_get_allocated_width (widget),
- gtk_widget_get_allocated_height (widget),
- user_data);
-
- return TRUE;
-}
-
-static char *
-shell_escape (const char *to_escape)
-{
- GString *string = g_string_sized_new (32);
- gboolean quote = *to_escape == '\0';
- const char *c;
-
- for (c = to_escape; *c; c++) {
- if (strchr ("$\\\"", *c))
- g_string_append_c (string, '\\');
- else if (!g_ascii_isalnum(*c) && !strchr ("@%^+-_[]:", *c))
- quote = TRUE;
- g_string_append_c (string, *c);
- }
- if (quote) {
- g_string_append_c (string, '"');
- g_string_prepend_c (string, '"');
- }
- return g_string_free (string, FALSE);
-}
-
-static void
-draw_one (NMABarCodeWidget *self, cairo_t *cr,
- const char *psk, const char *ssid,
- const char *nmcli_line1, const char *nmcli_line2)
-{
- NMABarCodeWidgetPrivate *priv = NMA_BAR_CODE_WIDGET_GET_PRIVATE (self);
- int size = nma_bar_code_get_size (priv->qr);
-
- cairo_save (cr);
-
- cairo_set_line_width (cr, 0.01);
- cairo_rectangle (cr, 0, 0, CARD_WIDTH_PT, CARD_HEIGHT_PT);
- cairo_stroke (cr);
- cairo_translate (cr, 12, 12);
-
- cairo_save (cr);
- cairo_scale (cr, (float)84/(float)size, (float)84/(float)size);
- cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
- nma_bar_code_draw (priv->qr, cr);
- cairo_restore (cr);
-
- cairo_select_font_face(cr, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
-
- cairo_move_to (cr, 96, 12);
- cairo_set_font_size (cr, 12);
- cairo_show_text(cr, _("Network"));
-
- cairo_move_to (cr, 96, 30);
- cairo_set_font_size (cr, 16);
- cairo_show_text(cr, ssid);
-
- cairo_select_font_face(cr, "Monospace", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
-
- cairo_move_to (cr, 0, 108);
- cairo_set_font_size (cr, 10);
- cairo_show_text(cr, nmcli_line1);
-
- if (psk) {
- cairo_select_font_face(cr, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
-
- cairo_move_to (cr, 96, 60);
- cairo_set_font_size (cr, 12);
- cairo_show_text(cr, _("Password"));
-
- cairo_move_to (cr, 96, 78);
- cairo_set_font_size (cr, 16);
- cairo_show_text(cr, psk);
-
- cairo_select_font_face(cr, "Monospace", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
-
- cairo_move_to (cr, 24, 120);
- cairo_set_font_size (cr, 10);
- cairo_show_text(cr, nmcli_line2);
- }
-
- cairo_restore (cr);
-}
-
-static void
-draw_page (GtkPrintOperation *operation, GtkPrintContext *context, int page_nr, gpointer user_data)
-{
- NMABarCodeWidget *self = NMA_BAR_CODE_WIDGET (user_data);
- NMABarCodeWidgetPrivate *priv = NMA_BAR_CODE_WIDGET_GET_PRIVATE (self);
- cairo_t *cr = gtk_print_context_get_cairo_context (context);
- double width = gtk_print_context_get_width (context);
- double height = gtk_print_context_get_height (context);
- int count_x = width / CARD_WIDTH_PT;
- int count_y = height / CARD_HEIGHT_PT;
- double spacing_x = (width - (count_x * CARD_WIDTH_PT)) / (count_x + 1);
- double spacing_y = (height - (count_y * CARD_HEIGHT_PT)) / (count_y + 1);
- NMSettingWireless *s_wireless;
- NMSettingWirelessSecurity *s_wsec;
- gs_free char *nmcli_line1 = NULL;
- gs_free char *nmcli_line2 = NULL;
- const char *psk = NULL;
- GBytes *ssid_bytes;
- char *ssid;
- char *tmp;
- int x, y;
-
- s_wireless = nm_connection_get_setting_wireless (priv->connection);
- if (!s_wireless) {
- nma_bar_code_set_text (priv->qr, NULL);
- gtk_widget_queue_draw (priv->qr_code);
- return;
- }
-
- ssid_bytes = nm_setting_wireless_get_ssid (s_wireless);
- g_return_if_fail (ssid_bytes);
- ssid = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid_bytes, NULL),
- g_bytes_get_size (ssid_bytes));
- g_return_if_fail (ssid);
-
- s_wsec = nm_connection_get_setting_wireless_security (priv->connection);
- if (s_wsec)
- psk = nm_setting_wireless_security_get_psk (s_wsec);
-
- tmp = shell_escape (ssid);
- nmcli_line1 = g_strdup_printf ("$ nmcli d wifi con %s%s", tmp, psk ? " \\" : "");
- g_free (tmp);
-
- if (psk) {
- tmp = shell_escape (psk);
- nmcli_line2 = g_strdup_printf ("password %s", tmp);
- g_free (tmp);
- }
-
- for (y = 0; y < count_y; y++) {
- cairo_save (cr);
-
- cairo_translate (cr, spacing_x, spacing_y);
-
- for (x = 0; x < count_x; x++) {
- draw_one (self, cr, psk, ssid, nmcli_line1, nmcli_line2);
- cairo_translate (cr, CARD_WIDTH_PT + spacing_x, 0);
- }
-
- cairo_restore (cr);
- cairo_translate (cr, 0, CARD_HEIGHT_PT + spacing_y);
- }
-}
-
-static gboolean
-link_activated (GtkLabel *label, char *uri, gpointer user_data)
-{
- NMABarCodeWidget *self = NMA_BAR_CODE_WIDGET (user_data);
- GtkPrintOperation *print = gtk_print_operation_new ();
- GtkWidget *window;
- GError *error = NULL;
-
- g_return_val_if_fail (strcmp (uri, "nma:print") == 0, FALSE);
-
- window = gtk_widget_get_ancestor (GTK_WIDGET (self), GTK_TYPE_WINDOW);
-
- gtk_print_operation_set_n_pages (print, 1);
- gtk_print_operation_set_use_full_page (print, TRUE);
- gtk_print_operation_set_unit (print, GTK_UNIT_POINTS);
- g_signal_connect (print, "draw_page", G_CALLBACK (draw_page), self);
-
- if (!gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
- window ? GTK_WINDOW (window) : NULL, &error)) {
- g_printerr ("%s", error->message);
- g_error_free (error);
- }
-
- g_object_unref (print);
-
- return FALSE;
-}
-
-static void
-string_append_mecard (GString *string, const char *tag, const char *text)
-{
- const char *p;
- bool is_hex = TRUE;
- int start;
-
- if (!text)
- return;
-
- g_string_append (string, tag);
- start = string->len;
-
- for (p = text; *p; p++) {
- if (!g_ascii_isxdigit (*p))
- is_hex = FALSE;
- if (strchr ("\\\":;,", *p))
- g_string_append_c (string, '\\');
- g_string_append_c (string, *p);
- }
-
- if (is_hex) {
- g_string_insert_c (string, start, '\"');
- g_string_append_c (string, '\"');
- }
- g_string_append_c (string, ';');
-}
-
-static void
-update_qr_code (NMABarCodeWidget *self)
-{
- NMABarCodeWidgetPrivate *priv = NMA_BAR_CODE_WIDGET_GET_PRIVATE (self);
- NMSettingWireless *s_wireless;
- NMSettingWirelessSecurity *s_wsec;
- const char *key_mgmt = NULL;
- const char *psk = NULL;
- const char *type = NULL;
- GBytes *ssid_bytes;
- char *ssid;
- GString *string;
-
- if (!priv->qr)
- return;
-
- s_wireless = nm_connection_get_setting_wireless (priv->connection);
- if (!s_wireless) {
- nma_bar_code_set_text (priv->qr, NULL);
- gtk_widget_queue_draw (priv->qr_code);
- return;
- }
-
- ssid_bytes = nm_setting_wireless_get_ssid (s_wireless);
- g_return_if_fail (ssid_bytes);
- ssid = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid_bytes, NULL),
- g_bytes_get_size (ssid_bytes));
- g_return_if_fail (ssid);
-
- string = g_string_sized_new (64);
- g_string_append (string, "WIFI:");
-
- s_wsec = nm_connection_get_setting_wireless_security (priv->connection);
- if (s_wsec) {
- key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wsec);
- psk = nm_setting_wireless_security_get_psk (s_wsec);
- }
-
- if (key_mgmt == NULL) {
- type = "nopass";
- } else if ( strcmp (key_mgmt, "none") == 0
- || strcmp (key_mgmt, "ieee8021x") == 0) {
- type = "WEP";
- } else if ( strcmp (key_mgmt, "wpa-none") == 0
- || strcmp (key_mgmt, "wpa-psk") == 0) {
- type = "WPA";
- }
-
- string_append_mecard(string, "T:", type);
- string_append_mecard(string, "S:", ssid);
- string_append_mecard(string, "P:", psk);
-
- if (nm_setting_wireless_get_hidden (s_wireless))
- g_string_append (string, "H:true;");
-
- g_string_append_c (string, ';');
- nma_bar_code_set_text (priv->qr, string->str);
- gtk_widget_queue_draw (priv->qr_code);
- g_string_free (string, TRUE);
-}
-
-static void
-set_connection (NMABarCodeWidget *self, NMConnection *connection)
-{
- NMABarCodeWidgetPrivate *priv = NMA_BAR_CODE_WIDGET_GET_PRIVATE (self);
-
- if (priv->connection) {
- g_signal_handlers_disconnect_by_data (priv->connection, self);
- g_clear_object (&priv->connection);
- }
-
- if (connection) {
- priv->connection = connection;
- g_signal_connect_swapped (connection, "changed", G_CALLBACK (update_qr_code), self);
- g_signal_connect_swapped (connection, "secrets-updated", G_CALLBACK (update_qr_code), self);
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
-{
- NMABarCodeWidgetPrivate *priv = NMA_BAR_CODE_WIDGET_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_CONNECTION:
- g_value_set_object (value, priv->connection);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
-{
- NMABarCodeWidget *self = NMA_BAR_CODE_WIDGET (object);
-
- switch (prop_id) {
- case PROP_CONNECTION:
- set_connection (self, g_value_dup_object (value));
- update_qr_code (self);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nma_bar_code_widget_init (NMABarCodeWidget *self)
-{
- NMABarCodeWidgetPrivate *priv = NMA_BAR_CODE_WIDGET_GET_PRIVATE (self);
-
- gtk_widget_init_template (GTK_WIDGET (self));
-
- priv->qr = nma_bar_code_new (NULL);
- g_signal_connect (priv->qr_code, "draw", G_CALLBACK (qr_code_draw), self);
-}
-
-/**
- * nma_bar_code_widget_new:
- * @connection: connection to get network details from
- *
- * Returns: (transfer full): the bar code widget instance
- *
- * Since: 1.8.22
- */
-GtkWidget *
-nma_bar_code_widget_new (NMConnection *connection)
-{
- return g_object_new (NMA_TYPE_BAR_CODE_WIDGET,
- NMA_BAR_CODE_WIDGET_CONNECTION, connection,
- NULL);
-}
-
-static void
-finalize (GObject *object)
-{
- NMABarCodeWidget *self = NMA_BAR_CODE_WIDGET (object);
- NMABarCodeWidgetPrivate *priv = NMA_BAR_CODE_WIDGET_GET_PRIVATE (self);
-
- g_clear_object (&priv->qr);
- set_connection (self, NULL);
-
- G_OBJECT_CLASS (nma_bar_code_widget_parent_class)->finalize (object);
-}
-
-static void
-nma_bar_code_widget_class_init (NMABarCodeWidgetClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
- object_class->get_property = get_property;
- object_class->set_property = set_property;
- object_class->finalize = finalize;
-
- g_object_class_install_property
- (object_class, PROP_CONNECTION,
- g_param_spec_object (NMA_BAR_CODE_WIDGET_CONNECTION, "", "",
- NM_TYPE_CONNECTION,
- G_PARAM_READABLE | G_PARAM_WRITABLE));
-
- gtk_widget_class_set_template_from_resource (widget_class,
- "/org/freedesktop/network-manager-applet/nma-bar-code-widget.ui");
-
- gtk_widget_class_bind_template_child_private (widget_class, NMABarCodeWidget, qr_code);
- gtk_widget_class_bind_template_callback (widget_class, link_activated);
-}
diff --git a/src/libnma/nma-bar-code-widget.h b/src/libnma/nma-bar-code-widget.h
deleted file mode 100644
index d12782e5..00000000
--- a/src/libnma/nma-bar-code-widget.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* nma-bar-code.h - Widget that renders a "QR" code
- *
- * Lubomir Rintel <lkundrak@v3.sk>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License as
- * published by the ree Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * Copyright (C) 2018, 2019 Red Hat, Inc.
- */
-
-#ifndef __NMA_BAR_CODE_WIDGET_H__
-#define __NMA_BAR_CODE_WIDGET_H__
-
-#include <glib-object.h>
-
-#include "nma-version.h"
-
-#define NMA_TYPE_BAR_CODE_WIDGET (nma_bar_code_widget_get_type ())
-#define NMA_BAR_CODE_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMA_TYPE_BAR_CODE_WIDGET, NMABarCodeWidget))
-#define NMA_BAR_CODE_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMA_TYPE_BAR_CODE_WIDGET, NMABarCodeWidgetClass))
-#define NMA_IS_BAR_CODE_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMA_TYPE_BAR_CODE_WIDGET))
-#define NMA_IS_BAR_CODE_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMA_TYPE_BAR_CODE_WIDGET))
-#define NMA_BAR_CODE_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMA_TYPE_BAR_CODE_WIDGET, NMABarCodeWidgetClass))
-
-#define NMA_BAR_CODE_WIDGET_CONNECTION "connection"
-
-typedef struct _NMABarCodeWidget NMABarCodeWidget;
-typedef struct _NMABarCodeWidgetClass NMABarCodeWidgetClass;
-
-NMA_AVAILABLE_IN_1_8_22
-GType nma_bar_code_widget_get_type (void) G_GNUC_CONST;
-
-NMA_AVAILABLE_IN_1_8_22
-GtkWidget *nma_bar_code_widget_new (NMConnection *connection);
-
-#endif /* __NMA_BAR_CODE_WIDGET_H__ */
diff --git a/src/libnma/nma-bar-code-widget.ui b/src/libnma/nma-bar-code-widget.ui
deleted file mode 100644
index d88f17c6..00000000
--- a/src/libnma/nma-bar-code-widget.ui
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.22.1 -->
-<interface domain="nm-applet">
- <requires lib="gtk+" version="3.20"/>
- <template class="NMABarCodeWidget" parent="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_start">6</property>
- <property name="margin_end">6</property>
- <property name="margin_top">6</property>
- <property name="margin_bottom">6</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkAspectFrame">
- <property name="expand">True</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label_xalign">0.5</property>
- <child>
- <object class="GtkDrawingArea" id="qr_code">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="expand">False</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Scan with your phone or &lt;a href="nma:print"&gt;Print&lt;/a&gt;</property>
- <property name="use_markup">True</property>
- <signal name="activate-link" handler="link_activated" swapped="no"/>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </template>
-</interface>
diff --git a/src/libnma/nma-bar-code.c b/src/libnma/nma-bar-code.c
deleted file mode 100644
index 0efa9f12..00000000
--- a/src/libnma/nma-bar-code.c
+++ /dev/null
@@ -1,222 +0,0 @@
-/* nma-bar-code.h - Renderer of a "QR" code
- *
- * Lubomir Rintel <lkundrak@v3.sk>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License as
- * published by the ree Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * Copyright 2018, 2019 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <stdint.h>
-
-#include "nma-bar-code.h"
-
-/*
- * The aim of this class is to provide a GObject-y QR code generator based
- * on qrcodegen library [1]. We purposefully include it directly instead
- * of compiling it separately, while providing a much less flexible (and
- * more straightforward) API. This way we the compiler does a good job at
- * slimming things down (chopping off half of the library) while allowing
- * us to leave the original source unmodified for easier maintenance.
- *
- * [1] https://github.com/nayuki/QR-Code-generator
- */
-
-#pragma GCC visibility push(hidden)
-NM_PRAGMA_WARNING_DISABLE("-Wdeclaration-after-statement")
-#define NDEBUG
-#include "qrcodegen.c"
-NM_PRAGMA_WARNING_REENABLE
-#pragma GCC visibility pop
-
-struct _NMABarCode {
- GObject parent;
-};
-
-struct _NMABarCodeClass {
- GObjectClass parent_class;
-};
-
-typedef struct {
- uint8_t qrcode[qrcodegen_BUFFER_LEN_FOR_VERSION (qrcodegen_VERSION_MAX)];
-} NMABarCodePrivate;
-
-/**
- * SECTION:nma-bar-code
- * @title: NMABarCode
- *
- * A Bar Code object provides the means of drawing a QR code onto a cairo
- * context. Useful for rendering Wi-Fi network credential in a form that
- * can be optically scanned with a phone camera.
- */
-
-G_DEFINE_TYPE_WITH_CODE (NMABarCode, nma_bar_code, G_TYPE_OBJECT,
- G_ADD_PRIVATE (NMABarCode))
-
-enum {
- PROP_0,
- PROP_TEXT,
- PROP_SIZE,
-
- LAST_PROP
-};
-
-#define NMA_BAR_CODE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NMA_TYPE_BAR_CODE, NMABarCodePrivate))
-
-/**
- * nma_bar_code_set_text:
- * @self: bar code instance
- * @text: new bar code text
- *
- * Regenerates the QR code for a different text.
- *
- * Since: 1.8.22
- */
-
-void
-nma_bar_code_set_text (NMABarCode *self, const char *text)
-{
- g_object_set (self, NMA_BAR_CODE_TEXT, text, NULL);
-}
-
-/**
- * nma_bar_code_get_size:
- * @self: bar code instance
- *
- * Returns: the side of a QR code square.
- *
- * Since: 1.8.22
- */
-
-int
-nma_bar_code_get_size (NMABarCode *self)
-{
- int size;
-
- g_object_get (self, NMA_BAR_CODE_SIZE, &size, NULL);
- return size;
-}
-
-/**
- * nma_bar_code_draw:
- * @self: bar code instance
- * @cr: cairo context
- *
- * Draws the QR code onto the given context.
- *
- * Since: 1.8.22
- */
-
-void
-nma_bar_code_draw (NMABarCode *self, cairo_t *cr)
-{
- NMABarCodePrivate *priv = NMA_BAR_CODE_GET_PRIVATE (self);
- int x, y, size;
-
- size = qrcodegen_getSize (priv->qrcode);
- cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
-
- for (y = 0; y < size; y++) {
- for (x = 0; x < size; x++) {
- if (qrcodegen_getModule (priv->qrcode, x, y)) {
- cairo_rectangle (cr, x, y, 1, 1);
- cairo_fill (cr);
- }
- }
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
-{
- NMABarCodePrivate *priv = NMA_BAR_CODE_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_SIZE:
- g_value_set_int (value, qrcodegen_getSize (priv->qrcode));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
-{
- NMABarCodePrivate *priv = NMA_BAR_CODE_GET_PRIVATE (object);
- uint8_t tempBuffer[qrcodegen_BUFFER_LEN_FOR_VERSION (qrcodegen_VERSION_MAX)];
- const char *text;
- bool success = FALSE;
-
- switch (prop_id) {
- case PROP_TEXT:
- text = g_value_get_string (value);
- if (text) {
- success = qrcodegen_encodeText(g_value_get_string (value),
- tempBuffer,
- priv->qrcode,
- qrcodegen_Ecc_LOW,
- qrcodegen_VERSION_MIN,
- qrcodegen_VERSION_MAX,
- qrcodegen_Mask_AUTO,
- FALSE);
- }
- if (!success)
- bzero (priv->qrcode, sizeof (priv->qrcode));
- g_object_notify (object, NMA_BAR_CODE_SIZE);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nma_bar_code_init (NMABarCode *self)
-{
-}
-
-/**
- * nma_bar_code_new:
- * @text: set the bar code text
- *
- * Returns: (transfer full): the bar code instance
- *
- * Since: 1.8.22
- */
-
-NMABarCode *
-nma_bar_code_new (const char *text)
-{
- return g_object_new (NMA_TYPE_BAR_CODE, NMA_BAR_CODE_TEXT, text, NULL);
-}
-
-static void
-nma_bar_code_class_init (NMABarCodeClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->get_property = get_property;
- object_class->set_property = set_property;
-
- g_object_class_install_property
- (object_class, PROP_TEXT,
- g_param_spec_string (NMA_BAR_CODE_TEXT, "", "",
- "", G_PARAM_WRITABLE));
-
- g_object_class_install_property
- (object_class, PROP_SIZE,
- g_param_spec_int (NMA_BAR_CODE_SIZE, "", "",
- G_MININT, G_MAXINT, 0, G_PARAM_READABLE));
-}
diff --git a/src/libnma/nma-bar-code.h b/src/libnma/nma-bar-code.h
deleted file mode 100644
index 143f2f8a..00000000
--- a/src/libnma/nma-bar-code.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* nma-bar-code.h - Widget that renders a "QR" code
- *
- * Lubomir Rintel <lkundrak@v3.sk>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License as
- * published by the ree Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * Copyright (C) 2018, 2019 Red Hat, Inc.
- */
-
-#ifndef __NMA_BAR_CODE_H__
-#define __NMA_BAR_CODE_H__
-
-#include <glib-object.h>
-#include <cairo.h>
-
-#include "nma-version.h"
-
-#define NMA_TYPE_BAR_CODE (nma_bar_code_get_type ())
-#define NMA_BAR_CODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMA_TYPE_BAR_CODE, NMABarCode))
-#define NMA_BAR_CODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMA_TYPE_BAR_CODE, NMABarCodeClass))
-#define NMA_IS_BAR_CODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMA_TYPE_BAR_CODE))
-#define NMA_IS_BAR_CODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMA_TYPE_BAR_CODE))
-#define NMA_BAR_CODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMA_TYPE_BAR_CODE, NMABarCodeClass))
-
-#define NMA_BAR_CODE_TEXT "text"
-#define NMA_BAR_CODE_SIZE "size"
-
-typedef struct _NMABarCode NMABarCode;
-typedef struct _NMABarCodeClass NMABarCodeClass;
-
-NMA_AVAILABLE_IN_1_8_22
-GType nma_bar_code_get_type (void) G_GNUC_CONST;
-
-NMA_AVAILABLE_IN_1_8_22
-NMABarCode *nma_bar_code_new (const char *text);
-
-NMA_AVAILABLE_IN_1_8_22
-void nma_bar_code_set_text (NMABarCode *self, const char *text);
-
-NMA_AVAILABLE_IN_1_8_22
-int nma_bar_code_get_size (NMABarCode *self);
-
-NMA_AVAILABLE_IN_1_8_22
-void nma_bar_code_draw (NMABarCode *self, cairo_t *cr);
-
-#endif /* __NMA_BAR_CODE_H__ */
diff --git a/src/libnma/nma-cert-chooser-button.c b/src/libnma/nma-cert-chooser-button.c
deleted file mode 100644
index 9d5287f5..00000000
--- a/src/libnma/nma-cert-chooser-button.c
+++ /dev/null
@@ -1,469 +0,0 @@
-// SPDX-License-Identifier: LGPL-2.1+
-/* NetworkManager Applet -- allow user control over networking
- *
- * Lubomir Rintel <lkundrak@v3.sk>
- *
- * Copyright (C) 2016,2017 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-#include "nma-cert-chooser-button.h"
-#include "nma-pkcs11-cert-chooser-dialog.h"
-#include "utils.h"
-
-#include <gck/gck.h>
-
-/**
- * SECTION:nma-cert-chooser-button
- * @title: NMACertChooserButton
- * @short_description: The PKCS\#11 or file certificate chooser button
- *
- * #NMACertChooserButton is a button that provides a dropdown of
- * PKCS\#11 slots present in the system and allows choosing a certificate
- * from either of them or a file.
- */
-
-enum {
- COLUMN_LABEL,
- COLUMN_SLOT,
- N_COLUMNS
-};
-
-typedef struct {
- gchar *title;
- gchar *uri;
- gchar *pin;
- gboolean remember_pin;
- NMACertChooserButtonFlags flags;
-} NMACertChooserButtonPrivate;
-
-G_DEFINE_TYPE (NMACertChooserButton, nma_cert_chooser_button, GTK_TYPE_COMBO_BOX);
-
-#define NMA_CERT_CHOOSER_BUTTON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
- NMA_TYPE_CERT_CHOOSER_BUTTON, \
- NMACertChooserButtonPrivate))
-
-static gboolean
-is_this_a_slot_nobody_loves (GckSlot *slot)
-{
- GckSlotInfo *slot_info;
- gboolean ret_value = FALSE;
-
- slot_info = gck_slot_get_info (slot);
- if (!slot_info)
- return TRUE;
-
- /* The p11-kit CA trusts do use their filesystem paths for description. */
- if (g_str_has_prefix (slot_info->slot_description, "/"))
- ret_value = TRUE;
- else if (NM_IN_STRSET (slot_info->slot_description,
- "SSH Keys",
- "Secret Store",
- "User Key Storage"))
- ret_value = TRUE;
-
- gck_slot_info_free (slot_info);
-
- return ret_value;
-}
-
-static void
-modules_initialized (GObject *object, GAsyncResult *res, gpointer user_data)
-{
- NMACertChooserButton *self = NMA_CERT_CHOOSER_BUTTON (user_data);
- GList *slots;
- GList *list_iter;
- GError *error = NULL;
- GList *modules;
- GtkTreeIter iter;
- GtkListStore *model;
- GckTokenInfo *info;
- gchar *label;
-
- modules = gck_modules_initialize_registered_finish (res, &error);
- if (error) {
- /* The Front Fell Off. */
- g_warning ("Error getting registered modules: %s", error->message);
- g_clear_error (&error);
- }
-
- model = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (self)));
-
- /* A separator. */
- gtk_list_store_insert_with_values (model, &iter, 2,
- COLUMN_LABEL, NULL,
- COLUMN_SLOT, NULL, -1);
-
- slots = gck_modules_get_slots (modules, FALSE);
- for (list_iter = slots; list_iter; list_iter = list_iter->next) {
- GckSlot *slot = GCK_SLOT (list_iter->data);
-
- if (is_this_a_slot_nobody_loves (slot))
- continue;
-
- info = gck_slot_get_token_info (slot);
- if (!info) {
- /* This happens when the slot has no token inserted.
- * Don't add this one to the list. The other widgets
- * assume gck_slot_get_token_info() don't fail and a slot
- * for which it does is essentially useless as it can't be
- * used for crafting an URI. */
- continue;
- }
-
- if ((info->flags & CKF_TOKEN_INITIALIZED) == 0)
- continue;
-
- if (info->label && *info->label) {
- label = g_strdup_printf ("%s\342\200\246", info->label);
- } else if (info->model && *info->model) {
- g_warning ("The token doesn't have a valid label");
- label = g_strdup_printf ("%s\342\200\246", info->model);
- } else {
- g_warning ("The token has neither valid label nor model");
- label = g_strdup ("(Unknown)\342\200\246");
- }
- gtk_list_store_insert_with_values (model, &iter, 2,
- COLUMN_LABEL, label,
- COLUMN_SLOT, slot, -1);
- g_free (label);
- gck_token_info_free (info);
- }
-
- gck_list_unref_free (slots);
- gck_list_unref_free (modules);
-}
-
-static void
-update_title (NMACertChooserButton *button)
-{
- NMACertChooserButtonPrivate *priv = NMA_CERT_CHOOSER_BUTTON_GET_PRIVATE (button);
- GckUriData *data;
- GtkTreeIter iter;
- GtkTreeModel *model;
- gs_free char *label = NULL;
- GError *error = NULL;
-
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (button));
-
- if (!gtk_tree_model_get_iter_first (model, &iter))
- g_return_if_reached ();
-
- if (!priv->uri) {
- label = g_strdup (_("(None)"));
- } else if (g_str_has_prefix (priv->uri, "pkcs11:")) {
- data = gck_uri_parse (priv->uri, GCK_URI_FOR_ANY, &error);
- if (data) {
- if (!gck_attributes_find_string (data->attributes, CKA_LABEL, &label)) {
- if (data->token_info) {
- g_free (label);
- label = g_strdup_printf ( priv->flags & NMA_CERT_CHOOSER_BUTTON_FLAG_KEY
- ? _("Key in %s")
- : _("Certificate in %s"),
- data->token_info->label);
- }
- }
- gck_uri_data_free (data);
- } else {
- g_warning ("Bad URI '%s': %s\n", priv->uri, error->message);
- g_error_free (error);
- }
- } else {
- label = priv->uri;
- if (g_str_has_prefix (label, "file://"))
- label += 7;
- if (g_strrstr (label, "/"))
- label = g_strrstr (label, "/") + 1;
- label = g_strdup (label);
- }
-
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- COLUMN_LABEL, label ?: _("(Unknown)"),
- -1);
-}
-
-static void
-select_from_token (NMACertChooserButton *button, GckSlot *slot)
-{
- NMACertChooserButtonPrivate *priv = NMA_CERT_CHOOSER_BUTTON_GET_PRIVATE (button);
- GtkWidget *toplevel;
- GtkWidget *dialog;
-
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (button));
- if (!gtk_widget_is_toplevel (toplevel) || !GTK_IS_WINDOW (toplevel))
- toplevel = NULL;
-
- dialog = nma_pkcs11_cert_chooser_dialog_new (slot,
- priv->flags & NMA_CERT_CHOOSER_BUTTON_FLAG_KEY
- ? CKO_PRIVATE_KEY
- : CKO_CERTIFICATE,
- priv->title,
- GTK_WINDOW (toplevel),
- GTK_FILE_CHOOSER_ACTION_OPEN | GTK_DIALOG_USE_HEADER_BAR,
- _("Select"), GTK_RESPONSE_ACCEPT,
- _("Cancel"), GTK_RESPONSE_CANCEL,
- NULL);
- if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
- if (priv->uri)
- g_free (priv->uri);
- priv->uri = nma_pkcs11_cert_chooser_dialog_get_uri (NMA_PKCS11_CERT_CHOOSER_DIALOG (dialog));
- if (priv->pin)
- g_free (priv->pin);
- priv->pin = nma_pkcs11_cert_chooser_dialog_get_pin (NMA_PKCS11_CERT_CHOOSER_DIALOG (dialog));
- priv->remember_pin = nma_pkcs11_cert_chooser_dialog_get_remember_pin (NMA_PKCS11_CERT_CHOOSER_DIALOG (dialog));
- update_title (button);
- }
- gtk_widget_destroy (dialog);
-}
-
-static void
-select_from_file (NMACertChooserButton *button)
-{
- NMACertChooserButtonPrivate *priv = NMA_CERT_CHOOSER_BUTTON_GET_PRIVATE (button);
- GtkWidget *toplevel;
- GtkWidget *dialog;
-
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (button));
- if (!gtk_widget_is_toplevel (toplevel) || !GTK_IS_WINDOW (toplevel))
- toplevel = NULL;
-
- dialog = gtk_file_chooser_dialog_new (priv->title,
- GTK_WINDOW (toplevel),
- GTK_FILE_CHOOSER_ACTION_OPEN,
- _("Select"), GTK_RESPONSE_ACCEPT,
- _("Cancel"), GTK_RESPONSE_CANCEL,
- NULL);
-
- if (priv->flags & NMA_CERT_CHOOSER_BUTTON_FLAG_KEY)
- gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), utils_key_filter ());
- else
- gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), utils_cert_filter ());
-
- if (priv->uri)
- gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (dialog), priv->uri);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
- if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
- if (priv->uri)
- g_free (priv->uri);
- priv->uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
- if (priv->pin) {
- g_free (priv->pin);
- priv->pin = NULL;
- }
- priv->remember_pin = FALSE;
- update_title (button);
- }
- gtk_widget_destroy (dialog);
-}
-
-static void
-dispose (GObject *object)
-{
- NMACertChooserButtonPrivate *priv = NMA_CERT_CHOOSER_BUTTON_GET_PRIVATE (object);
-
- nm_clear_g_free (&priv->title);
- nm_clear_g_free (&priv->uri);
- nm_clear_g_free (&priv->pin);
-}
-
-static void
-changed (GtkComboBox *combo_box)
-{
- GtkTreeIter iter;
- GtkTreeModel *model;
- gchar *label;
- GckSlot *slot;
-
- if (gtk_combo_box_get_active (combo_box) == 0)
- return;
-
- g_signal_stop_emission_by_name (combo_box, "changed");
- gtk_combo_box_get_active_iter (combo_box, &iter);
-
- model = gtk_combo_box_get_model (combo_box);
- gtk_tree_model_get (model, &iter,
- COLUMN_LABEL, &label,
- COLUMN_SLOT, &slot, -1);
- if (slot)
- select_from_token (NMA_CERT_CHOOSER_BUTTON (combo_box), slot);
- else
- select_from_file (NMA_CERT_CHOOSER_BUTTON (combo_box));
-
- g_free (label);
- g_clear_object (&slot);
- gtk_combo_box_set_active (combo_box, 0);
-}
-
-static void
-nma_cert_chooser_button_class_init (NMACertChooserButtonClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkComboBoxClass *combo_box_class = GTK_COMBO_BOX_CLASS (klass);
-
- g_type_class_add_private (object_class, sizeof (NMACertChooserButtonPrivate));
-
- object_class->dispose = dispose;
- combo_box_class->changed = changed;
-}
-
-static void
-nma_cert_chooser_button_init (NMACertChooserButton *self)
-{
- gck_modules_initialize_registered_async (NULL, modules_initialized, self);
-}
-
-static gboolean
-row_separator (GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
-{
- gchar *label;
- GckSlot *slot;
-
- gtk_tree_model_get (model, iter, 0, &label, 1, &slot, -1);
- if (label == NULL && slot == NULL)
- return TRUE;
- g_free (label);
- g_clear_object (&slot);
-
- return FALSE;
-}
-
-/**
- * nma_cert_chooser_button_set_title:
- * @button: the #NMACertChooserButton instance
- * @title: the title of the token or file chooser dialogs
- *
- * Set the title of file or PKCS\#11 object chooser dialogs.
- */
-void
-nma_cert_chooser_button_set_title (NMACertChooserButton *button, const gchar *title)
-{
- NMACertChooserButtonPrivate *priv = NMA_CERT_CHOOSER_BUTTON_GET_PRIVATE (button);
-
- if (priv->title)
- g_free (priv->title);
- priv->title = g_strdup (title);
-}
-
-/**
- * nma_cert_chooser_button_get_uri:
- * @button: the #NMACertChooserButton instance
- *
- * Obtain the URI of the selected obejct -- either of
- * "pkcs11" or "file" scheme.
- *
- * Returns: the URI or %NULL if none was selected.
- */
-const gchar *
-nma_cert_chooser_button_get_uri (NMACertChooserButton *button)
-{
- NMACertChooserButtonPrivate *priv = NMA_CERT_CHOOSER_BUTTON_GET_PRIVATE (button);
-
- return priv->uri;
-}
-
-/**
- * nma_cert_chooser_button_set_uri:
- * @button: the #NMACertChooserButton instance
- * @uri: the URI
- *
- * Set the chosen URI to given string.
- */
-void
-nma_cert_chooser_button_set_uri (NMACertChooserButton *button, const gchar *uri)
-{
- NMACertChooserButtonPrivate *priv = NMA_CERT_CHOOSER_BUTTON_GET_PRIVATE (button);
-
- if (priv->uri)
- g_free (priv->uri);
- priv->uri = g_strdup (uri);
- update_title (button);
-}
-
-/**
- * nma_cert_chooser_button_get_pin:
- * @button: the #NMACertChooserButton instance
- *
- * Obtain the PIN that was used to unlock the token.
- *
- * Returns: the PIN, %NULL if the token was not logged into or an emtpy
- * string ("") if the protected authentication path was used.
- */
-gchar *
-nma_cert_chooser_button_get_pin (NMACertChooserButton *button)
-{
- NMACertChooserButtonPrivate *priv = NMA_CERT_CHOOSER_BUTTON_GET_PRIVATE (button);
-
- return g_strdup (priv->pin);
-}
-
-/**
- * nma_cert_chooser_button_get_remember_pin:
- * @button: the #NMACertChooserButton instance
- *
- * Obtain the value of the "Remember PIN" checkbox during the token login.
- *
- * Returns: TRUE if the user chose to remember the PIN, FALSE
- * if not or if the tokin was not logged into at all.
- */
-gboolean
-nma_cert_chooser_button_get_remember_pin (NMACertChooserButton *button)
-{
- NMACertChooserButtonPrivate *priv = NMA_CERT_CHOOSER_BUTTON_GET_PRIVATE (button);
-
- return priv->remember_pin;
-}
-
-/**
- * nma_cert_chooser_button_new:
- * @flags: the flags configuring the behavior of the chooser dialogs
- *
- * Creates the new button that can select certificates from
- * files or PKCS\#11 tokens.
- *
- * Returns: the newly created #NMACertChooserButton
- */
-GtkWidget *
-nma_cert_chooser_button_new (NMACertChooserButtonFlags flags)
-{
- GtkWidget *self;
- GtkListStore *model;
- GtkTreeIter iter;
- GtkCellRenderer *cell;
- NMACertChooserButtonPrivate *priv;
-
- model = gtk_list_store_new (2, G_TYPE_STRING, GCK_TYPE_SLOT);
- self = g_object_new (NMA_TYPE_CERT_CHOOSER_BUTTON,
- "model", model,
- "popup-fixed-width", TRUE,
- NULL);
- g_object_unref (model);
-
- priv = NMA_CERT_CHOOSER_BUTTON_GET_PRIVATE (self);
- priv->flags = flags;
-
- gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (self),
- row_separator,
- NULL,
- NULL);
-
- /* The first entry with current object name. */
- gtk_list_store_insert_with_values (model, &iter, 0,
- COLUMN_LABEL, NULL,
- COLUMN_SLOT, NULL, -1);
- update_title (NMA_CERT_CHOOSER_BUTTON (self));
-
- /* The separator and the last entry. The tokens will be added in between. */
- gtk_list_store_insert_with_values (model, &iter, 1,
- COLUMN_LABEL, NULL,
- COLUMN_SLOT, NULL, -1);
- gtk_list_store_insert_with_values (model, &iter, 2,
- COLUMN_LABEL, _("Select from file\342\200\246"),
- COLUMN_SLOT, NULL, -1);
-
- cell = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (self), cell, FALSE);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (self), cell, "text", 0);
- gtk_combo_box_set_active (GTK_COMBO_BOX (self), 0);
-
- return self;
-}
diff --git a/src/libnma/nma-cert-chooser-button.h b/src/libnma/nma-cert-chooser-button.h
deleted file mode 100644
index fcc54680..00000000
--- a/src/libnma/nma-cert-chooser-button.h
+++ /dev/null
@@ -1,59 +0,0 @@
-// SPDX-License-Identifier: LGPL-2.1+
-/* NetworkManager Applet -- allow user control over networking
- *
- * Lubomir Rintel <lkundrak@v3.sk>
- *
- * Copyright (C) 2016,2017 Red Hat, Inc.
- */
-
-#ifndef __NMA_CERT_CHOOSER_BUTTON_H__
-#define __NMA_CERT_CHOOSER_BUTTON_H__
-
-#include <gtk/gtk.h>
-
-/**
- * NMACertChooserButtonFlags:
- * @NMA_CERT_CHOOSER_BUTTON_FLAG_NONE: defaults
- * @NMA_CERT_CHOOSER_BUTTON_FLAG_KEY: only allow choosing a key
- *
- * Unless NMA_CERT_CHOOSER_BUTTON_FLAG_KEY is chosen, the
- * choosers allow picking a certificate or a certificate with
- * key in a single object (PKCS\#11 URI or a PKCS\#12 archive).
- */
-typedef enum {
- NMA_CERT_CHOOSER_BUTTON_FLAG_NONE = 0,
- NMA_CERT_CHOOSER_BUTTON_FLAG_KEY = 1,
-} NMACertChooserButtonFlags;
-
-typedef struct {
- GtkComboBox parent;
-} NMACertChooserButton;
-
-typedef struct {
- GtkComboBoxClass parent;
-} NMACertChooserButtonClass;
-
-#define NMA_TYPE_CERT_CHOOSER_BUTTON (nma_cert_chooser_button_get_type ())
-#define NMA_CERT_CHOOSER_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMA_TYPE_CERT_CHOOSER_BUTTON, NMACertChooserButton))
-#define NMA_CERT_CHOOSER_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMA_TYPE_CERT_CHOOSER_BUTTON, NMACertChooserButtonClass))
-#define NMA_IS_CERT_CHOOSER_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMA_TYPE_CERT_CHOOSER_BUTTON))
-#define NMA_IS_CERT_CHOOSER_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMA_TYPE_CERT_CHOOSER_BUTTON))
-#define NMA_CERT_CHOOSER_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMA_TYPE_CERT_CHOOSER_BUTTON, NMACertChooserButtonClass))
-
-GType nma_cert_chooser_button_get_type (void);
-
-void nma_cert_chooser_button_set_title (NMACertChooserButton *button,
- const gchar *title);
-
-const gchar *nma_cert_chooser_button_get_uri (NMACertChooserButton *button);
-
-void nma_cert_chooser_button_set_uri (NMACertChooserButton *button,
- const gchar *uri);
-
-gchar *nma_cert_chooser_button_get_pin (NMACertChooserButton *button);
-
-gboolean nma_cert_chooser_button_get_remember_pin (NMACertChooserButton *button);
-
-GtkWidget *nma_cert_chooser_button_new (NMACertChooserButtonFlags flags);
-
-#endif /* __NMA_CERT_CHOOSER_BUTTON_H__ */
diff --git a/src/libnma/nma-cert-chooser-private.h b/src/libnma/nma-cert-chooser-private.h
deleted file mode 100644
index dcfc8ccc..00000000
--- a/src/libnma/nma-cert-chooser-private.h
+++ /dev/null
@@ -1,143 +0,0 @@
-// SPDX-License-Identifier: LGPL-2.1+
-/* NetworkManager Applet -- allow user control over networking
- *
- * Lubomir Rintel <lkundrak@v3.sk>
- *
- * Copyright (C) 2015,2017 Red Hat, Inc.
- */
-
-#ifndef NMA_CERT_CHOOSER_PRIVATE_H
-#define NMA_CERT_CHOOSER_PRIVATE_H
-
-#include "nma-cert-chooser.h"
-
-typedef struct _NMACertChooserVtable NMACertChooserVtable;
-
-typedef struct {
- GtkWidget *key_button_label;
- GtkWidget *key_password_label;
- GtkWidget *cert_button_label;
- GtkWidget *key_button;
- GtkWidget *key_password;
- GtkWidget *cert_button;
- GtkWidget *show_password;
-} NMAFileCertChooserPrivate;
-
-typedef struct {
- GtkWidget *key_button_label;
- GtkWidget *key_password_label;
- GtkWidget *cert_button_label;
- GtkWidget *cert_password_label;
- GtkWidget *key_button;
- GtkWidget *key_password;
- GtkWidget *cert_button;
- GtkWidget *cert_password;
- GtkWidget *show_password;
-} NMAPkcs11CertChooserPrivate;
-
-typedef struct {
- const NMACertChooserVtable *vtable;
-
- struct {
- union {
- NMAFileCertChooserPrivate file;
- NMAPkcs11CertChooserPrivate pkcs11;
- };
- } _sub;
-} NMACertChooserPrivate;
-
-struct _NMACertChooser {
- GtkGrid parent;
- NMACertChooserPrivate _priv;
-};
-
-struct _NMACertChooserClass {
- GtkGridClass parent_class;
-};
-
-/**
- * NMACertChooserVtable:
- * @init: called early to initialize the type.
- * @set_cert_uri: Set the certificate location for the chooser button.
- * @get_cert_uri: Get the real certificate location from the chooser button along
- * with the scheme.
- * @set_cert_password: Set the password or a PIN that might be required to
- * access the certificate.
- * @get_cert_password: Obtain the password or a PIN that was be required to
- * access the certificate.
- * @set_key_uri: Set the key location for the chooser button.
- * @get_key_uri: Get the real key location from the chooser button along with the
- * scheme.
- * @set_key_password: Set the password or a PIN that might be required to
- * access the key.
- * @get_key_password: Obtain the password or a PIN that was be required to
- * access the key.
- * @add_to_size_group: Add the labels to the specified size group so that they
- * are aligned.
- * @validate: Validate whether the chosen values make sense.
- * @setup_cert_password_storage: Set up certificate password storage.
- * @update_cert_password_storage: Update certificate password storage.
- * @get_cert_password_flags: Return secret flags corresponding to the
- * certificate password if one is present.
- * @setup_key_password_storage: Set up key password storage.
- * @update_key_password_storage: Update key password storage.
- * @get_key_password_flags: Returns secret flags corresponding to the key
- * password if one is present.
- * @set_title: Setup the title property
- * @set_flags: Setup the flags property
- */
-struct _NMACertChooserVtable {
- void (*init) (NMACertChooser *cert_chooser);
- void (*set_cert_uri) (NMACertChooser *cert_chooser,
- const gchar *uri);
- gchar *(*get_cert_uri) (NMACertChooser *cert_chooser);
- void (*set_cert_password) (NMACertChooser *cert_chooser,
- const gchar *password);
- const gchar *(*get_cert_password) (NMACertChooser *cert_chooser);
- void (*set_key_uri) (NMACertChooser *cert_chooser,
- const gchar *uri);
- gchar *(*get_key_uri) (NMACertChooser *cert_chooser);
- void (*set_key_password) (NMACertChooser *cert_chooser,
- const gchar *password);
- const gchar *(*get_key_password) (NMACertChooser *cert_chooser);
-
- void (*add_to_size_group) (NMACertChooser *cert_chooser,
- GtkSizeGroup *group);
- gboolean (*validate) (NMACertChooser *cert_chooser,
- GError **error);
-
- void (*setup_cert_password_storage) (NMACertChooser *cert_chooser,
- NMSettingSecretFlags initial_flags,
- NMSetting *setting,
- const char *password_flags_name,
- gboolean with_not_required,
- gboolean ask_mode);
- void (*update_cert_password_storage) (NMACertChooser *cert_chooser,
- NMSettingSecretFlags secret_flags,
- NMSetting *setting,
- const char *password_flags_name);
- NMSettingSecretFlags (*get_cert_password_flags) (NMACertChooser *cert_chooser);
- void (*setup_key_password_storage) (NMACertChooser *cert_chooser,
- NMSettingSecretFlags initial_flags,
- NMSetting *setting,
- const char *password_flags_name,
- gboolean with_not_required,
- gboolean ask_mode);
- void (*update_key_password_storage) (NMACertChooser *cert_chooser,
- NMSettingSecretFlags secret_flags,
- NMSetting *setting,
- const char *password_flags_name);
- NMSettingSecretFlags (*get_key_password_flags) (NMACertChooser *cert_chooser);
-
- void (*set_title) (NMACertChooser *cert_chooser,
- const gchar *title);
- void (*set_flags) (NMACertChooser *cert_chooser,
- NMACertChooserFlags flags);
-};
-
-extern const NMACertChooserVtable nma_cert_chooser_vtable_file;
-#if LIBNM_BUILD && WITH_GCR
-extern const NMACertChooserVtable nma_cert_chooser_vtable_pkcs11;
-#endif
-
-#endif /* NMA_CERT_CHOOSER_PRIVATE_H */
diff --git a/src/libnma/nma-cert-chooser.c b/src/libnma/nma-cert-chooser.c
deleted file mode 100644
index 82d0e00b..00000000
--- a/src/libnma/nma-cert-chooser.c
+++ /dev/null
@@ -1,788 +0,0 @@
-// SPDX-License-Identifier: LGPL-2.1+
-/* NetworkManager Applet -- allow user control over networking
- *
- * Lubomir Rintel <lkundrak@v3.sk>
- *
- * Copyright (C) 2017 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-#include "nma-cert-chooser.h"
-
-#include "nma-cert-chooser-private.h"
-
-#if !LIBNM_BUILD
-#define NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH "file://"
-#endif
-
-/**
- * SECTION:nma-cert-chooser
- * @title: NMACertChooser
- *
- * Certificate chooser allows for selection of a certificate or
- * various schemes optionally accompanied with a key and passwords
- * or PIN.
- *
- * The widgets that implement this interface may allow selecting
- * the certificates from various sources such as files or cryptographic
- * tokens.
- */
-
-enum {
- PROP_0,
- PROP_TITLE,
- PROP_FLAGS,
- LAST_PROP,
-};
-
-static GParamSpec *properties[LAST_PROP];
-
-enum {
- CERT_VALIDATE,
- CERT_PASSWORD_VALIDATE,
- KEY_VALIDATE,
- KEY_PASSWORD_VALIDATE,
- CHANGED,
- LAST_SIGNAL,
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE (NMACertChooser, nma_cert_chooser, GTK_TYPE_GRID)
-
-#define NMA_CERT_CHOOSER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMACertChooser, NMA_IS_CERT_CHOOSER)
-#define NMA_CERT_CHOOSER_GET_VTABLE(o) (NMA_CERT_CHOOSER_GET_PRIVATE (o)->vtable)
-
-static gboolean
-accu_validation_error (GSignalInvocationHint *ihint,
- GValue *return_accu,
- const GValue *handler_return,
- gpointer data)
-{
- if (g_value_get_boxed (handler_return)) {
- g_value_copy (handler_return, return_accu);
- return FALSE;
- }
-
- return TRUE;
-}
-
-static gchar *
-value_with_scheme_to_uri (const gchar *value, NMSetting8021xCKScheme scheme)
-{
- switch (scheme) {
- case NM_SETTING_802_1X_CK_SCHEME_PATH:
- return g_strdup_printf (NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH "%s", value);
-#if LIBNM_BUILD
- case NM_SETTING_802_1X_CK_SCHEME_PKCS11:
- return g_strdup (value);
-#endif
- default:
- g_return_val_if_reached (NULL);
- }
-}
-
-static gchar *
-uri_to_value_with_scheme (const gchar *uri, NMSetting8021xCKScheme *scheme)
-{
- if (!uri) {
- NM_SET_OUT (scheme, NM_SETTING_802_1X_CK_SCHEME_UNKNOWN);
- return NULL;
- }
-
- if (g_str_has_prefix (uri, NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH)) {
- NM_SET_OUT (scheme, NM_SETTING_802_1X_CK_SCHEME_PATH);
- return g_uri_unescape_string (uri + NM_STRLEN (NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH), NULL);
- }
-
-#if LIBNM_BUILD
- if (g_str_has_prefix (uri, NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PKCS11)) {
- NM_SET_OUT (scheme, NM_SETTING_802_1X_CK_SCHEME_PKCS11);
- return g_strdup (uri);
- }
-#endif
-
- g_return_val_if_reached (NULL);
-}
-
-/**
- * nma_cert_chooser_set_cert_uri:
- * @cert_chooser: certificate chooser button instance
- * @uri: the path or URI of a certificate
- *
- * Sets the certificate URI for the chooser button.
- *
- * Since: 1.8.0
- */
-void
-nma_cert_chooser_set_cert_uri (NMACertChooser *cert_chooser,
- const gchar *uri)
-{
- g_return_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser));
-
- NMA_CERT_CHOOSER_GET_VTABLE (cert_chooser)->set_cert_uri (cert_chooser, uri);
-}
-
-/**
- * nma_cert_chooser_set_cert:
- * @cert_chooser: certificate chooser button instance
- * @value: the path or URI of a certificate
- * @scheme: the scheme of the certificate path
- *
- * Sets the certificate location for the chooser button.
- *
- * Since: 1.8.0
- */
-void
-nma_cert_chooser_set_cert (NMACertChooser *cert_chooser,
- const gchar *value,
- NMSetting8021xCKScheme scheme)
-{
- gs_free gchar *uri = NULL;
-
- g_return_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser));
-
- if (!value)
- return;
-
- uri = value_with_scheme_to_uri (value, scheme);
- nma_cert_chooser_set_cert_uri (cert_chooser, uri);
-}
-
-/**
- * nma_cert_chooser_get_cert_uri:
- * @cert_chooser: certificate chooser button instance
- *
- * Gets the real certificate URI from the chooser button along with the scheme.
- *
- * Returns: (transfer full) (nullable): the certificate URI
- *
- * Since: 1.8.0
- */
-gchar *
-nma_cert_chooser_get_cert_uri (NMACertChooser *cert_chooser)
-{
- g_return_val_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser), NULL);
-
- return NMA_CERT_CHOOSER_GET_VTABLE (cert_chooser)->get_cert_uri (cert_chooser);
-}
-
-/**
- * nma_cert_chooser_get_cert:
- * @cert_chooser: certificate chooser button instance
- * @scheme: (out): the scheme of the returned certificate path
- *
- * Gets the real certificate location from the chooser button along with the scheme.
- *
- * Returns: (transfer full) (nullable): the certificate path
- *
- * Since: 1.8.0
- */
-gchar *
-nma_cert_chooser_get_cert (NMACertChooser *cert_chooser, NMSetting8021xCKScheme *scheme)
-{
- gs_free gchar *uri = NULL;
-
- g_return_val_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser), NULL);
-
- uri = nma_cert_chooser_get_cert_uri (cert_chooser);
- return uri_to_value_with_scheme (uri, scheme);
-}
-
-/**
- * nma_cert_chooser_set_cert_password:
- * @cert_chooser: certificate chooser button instance
- * @password: the certificate PIN or password
- *
- * Sets the password or a PIN that might be required to access the certificate.
- *
- * Since: 1.8.0
- */
-void
-nma_cert_chooser_set_cert_password (NMACertChooser *cert_chooser, const gchar *password)
-{
- const NMACertChooserVtable *vtable;
-
- g_return_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser));
- g_return_if_fail (password);
-
- vtable = NMA_CERT_CHOOSER_GET_VTABLE (cert_chooser);
- if (vtable->set_cert_password)
- vtable->set_cert_password (cert_chooser, password);
- else
- g_warning ("Can't set certificate password");
-}
-
-/**
- * nma_cert_chooser_get_cert_password:
- * @cert_chooser: certificate chooser button instance
- *
- * Obtains the password or a PIN that was be required to access the certificate.
- *
- * Returns: the certificate PIN or password
- *
- * Since: 1.8.0
- */
-const gchar *
-nma_cert_chooser_get_cert_password (NMACertChooser *cert_chooser)
-{
- const NMACertChooserVtable *vtable;
-
- g_return_val_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser), NULL);
-
- vtable = NMA_CERT_CHOOSER_GET_VTABLE (cert_chooser);
- if (!vtable->get_cert_password)
- return NULL;
- return vtable->get_cert_password (cert_chooser);
-}
-
-/**
- * nma_cert_chooser_set_key_uri:
- * @cert_chooser: certificate chooser button instance
- * @uri: the URI of a key
- *
- * Sets the key URI for the chooser button.
- *
- * Since: 1.8.0
- */
-void
-nma_cert_chooser_set_key_uri (NMACertChooser *cert_chooser,
- const gchar *uri)
-{
- g_return_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser));
-
- return NMA_CERT_CHOOSER_GET_VTABLE (cert_chooser)->set_key_uri (cert_chooser, uri);
-}
-
-/**
- * nma_cert_chooser_set_key:
- * @cert_chooser: certificate chooser button instance
- * @value: the path or URI of a key
- * @scheme: the scheme of the key path
- *
- * Sets the key location for the chooser button.
- *
- * Since: 1.8.0
- */
-void
-nma_cert_chooser_set_key (NMACertChooser *cert_chooser,
- const gchar *value,
- NMSetting8021xCKScheme scheme)
-{
- gs_free gchar *uri = NULL;
-
- g_return_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser));
-
- if (!value)
- return;
-
- uri = value_with_scheme_to_uri (value, scheme);
- nma_cert_chooser_set_key_uri (cert_chooser, uri);
-}
-
-/**
- * nma_cert_chooser_get_key:
- * @cert_chooser: certificate chooser button instance
- * @scheme: (out): the scheme of the returned key path
- *
- * Gets the real key location from the chooser button along with the scheme.
- *
- * Returns: (transfer full) (nullable): the key path
- *
- * Since: 1.8.0
- */
-gchar *
-nma_cert_chooser_get_key (NMACertChooser *cert_chooser, NMSetting8021xCKScheme *scheme)
-{
- gs_free gchar *uri = NULL;
-
- g_return_val_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser), NULL);
-
- uri = nma_cert_chooser_get_key_uri (cert_chooser);
- return uri_to_value_with_scheme (uri, scheme);
-}
-
-/**
- * nma_cert_chooser_get_key_uri:
- * @cert_chooser: certificate chooser button instance
- *
- * Gets the real key URI from the chooser button along with the scheme.
- *
- * Returns: (transfer full) (nullable): the key URI
- *
- * Since: 1.8.0
- */
-gchar *
-nma_cert_chooser_get_key_uri (NMACertChooser *cert_chooser)
-{
- g_return_val_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser), NULL);
-
- return NMA_CERT_CHOOSER_GET_VTABLE (cert_chooser)->get_key_uri (cert_chooser);
-}
-
-/**
- * nma_cert_chooser_set_key_password:
- * @cert_chooser: certificate chooser button instance
- * @password: the key PIN or password
- *
- * Sets the password or a PIN that might be required to access the key.
- *
- * Since: 1.8.0
- */
-void
-nma_cert_chooser_set_key_password (NMACertChooser *cert_chooser, const gchar *password)
-{
- g_return_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser));
- g_return_if_fail (password);
-
- NMA_CERT_CHOOSER_GET_VTABLE (cert_chooser)->set_key_password (cert_chooser, password);
-}
-
-/**
- * nma_cert_chooser_get_key_password:
- * @cert_chooser: certificate chooser button instance
- *
- * Obtains the password or a PIN that was be required to access the key.
- *
- * Returns: the key PIN or password
- *
- * Since: 1.8.0
- */
-const gchar *
-nma_cert_chooser_get_key_password (NMACertChooser *cert_chooser)
-{
- g_return_val_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser), NULL);
-
- return NMA_CERT_CHOOSER_GET_VTABLE (cert_chooser)->get_key_password (cert_chooser);
-}
-
-/**
- * nma_cert_chooser_add_to_size_group:
- * @cert_chooser: certificate chooser button instance
- * @group: a size group
- *
- * Adds the labels to the specified size group so that they are aligned
- * nicely with other entries in a form.
- *
- * It is expected that the NMACertChooser is a GtkGrid with two columns
- * with the labels in the first one.
- *
- * Since: 1.8.0
- */
-void
-nma_cert_chooser_add_to_size_group (NMACertChooser *cert_chooser, GtkSizeGroup *group)
-{
- g_return_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser));
-
- NMA_CERT_CHOOSER_GET_VTABLE (cert_chooser)->add_to_size_group (cert_chooser, group);
-}
-
-/**
- * nma_cert_chooser_validate:
- * @cert_chooser: certificate chooser button instance
- * @error: error return location
- *
- * Validates whether the chosen values make sense. The users can do further
- * validation by subscribing to the "*-changed" signals and returning an
- * error themselves.
- *
- * Returns: %TRUE if validation passes, %FALSE otherwise
- *
- * Since: 1.8.0
- */
-gboolean
-nma_cert_chooser_validate (NMACertChooser *cert_chooser, GError **error)
-{
- g_return_val_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser), TRUE);
-
- return NMA_CERT_CHOOSER_GET_VTABLE (cert_chooser)->validate (cert_chooser, error);
-}
-
-/**
- * nma_cert_chooser_setup_cert_password_storage:
- * @cert_chooser: certificate chooser button instance
- * @initial_flags: initial secret flags to setup password menu from
- * @setting: #NMSetting containing the password, or NULL
- * @password_flags_name: name of the secret flags (like psk-flags), or NULL
- * @with_not_required: whether to include "Not required" menu item
- * @ask_mode: %TRUE if the entry is shown in ASK mode
- *
- * This method basically calls nma_utils_setup_password_storage()
- * on the certificate password entry, in case one is present.
- *
- * Since: 1.8.0
- */
-void
-nma_cert_chooser_setup_cert_password_storage (NMACertChooser *cert_chooser,
- NMSettingSecretFlags initial_flags,
- NMSetting *setting,
- const char *password_flags_name,
- gboolean with_not_required,
- gboolean ask_mode)
-{
- const NMACertChooserVtable *vtable;
-
- g_return_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser));
-
- vtable = NMA_CERT_CHOOSER_GET_VTABLE (cert_chooser);
- if (vtable->setup_cert_password_storage) {
- vtable->setup_cert_password_storage (cert_chooser,
- initial_flags,
- setting,
- password_flags_name,
- with_not_required,
- ask_mode);
- }
-}
-
-/**
- * nma_cert_chooser_update_cert_password_storage:
- * @cert_chooser: certificate chooser button instance
- * @secret_flags: secret flags to set
- * @setting: #NMSetting containing the password, or NULL
- * @password_flags_name: name of the secret flags (like psk-flags), or NULL
- *
- * This method basically calls nma_utils_update_password_storage()
- * on the certificate password entry, in case one is present.
- *
- * Since: 1.8.0
- */
-void
-nma_cert_chooser_update_cert_password_storage (NMACertChooser *cert_chooser,
- NMSettingSecretFlags secret_flags,
- NMSetting *setting,
- const char *password_flags_name)
-{
- const NMACertChooserVtable *vtable;
-
- g_return_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser));
-
- vtable = NMA_CERT_CHOOSER_GET_VTABLE (cert_chooser);
- if (vtable->update_cert_password_storage) {
- vtable->update_cert_password_storage (cert_chooser,
- secret_flags,
- setting,
- password_flags_name);
- }
-}
-
-/**
- * nma_cert_chooser_get_cert_password_flags:
- * @cert_chooser: certificate chooser button instance
- *
- * Returns secret flags corresponding to the certificate password
- * if one is present. The chooser would typically call into
- * nma_utils_menu_to_secret_flags() for the certificate password
- * entry.
- *
- * Returns: secret flags corresponding to the certificate password
- *
- * Since: 1.8.0
- */
-NMSettingSecretFlags
-nma_cert_chooser_get_cert_password_flags (NMACertChooser *cert_chooser)
-{
- const NMACertChooserVtable *vtable;
-
- g_return_val_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser),
- NM_SETTING_SECRET_FLAG_NONE);
-
- vtable = NMA_CERT_CHOOSER_GET_VTABLE (cert_chooser);
- if (!vtable->get_cert_password_flags)
- return NM_SETTING_SECRET_FLAG_NONE;
- return vtable->get_cert_password_flags (cert_chooser);
-}
-
-
-/**
- * nma_cert_chooser_setup_key_password_storage:
- * @cert_chooser: certificate chooser button instance
- * @initial_flags: initial secret flags to setup password menu from
- * @setting: #NMSetting containing the password, or NULL
- * @password_flags_name: name of the secret flags (like psk-flags), or NULL
- * @with_not_required: whether to include "Not required" menu item
- * @ask_mode: %TRUE if the entry is shown in ASK mode
- *
- * This method basically calls nma_utils_setup_password_storage()
- * on the key password entry, in case one is present.
- *
- * Since: 1.8.0
- */
-void
-nma_cert_chooser_setup_key_password_storage (NMACertChooser *cert_chooser,
- NMSettingSecretFlags initial_flags,
- NMSetting *setting,
- const char *password_flags_name,
- gboolean with_not_required,
- gboolean ask_mode)
-{
- g_return_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser));
-
- NMA_CERT_CHOOSER_GET_VTABLE (cert_chooser)->setup_key_password_storage (cert_chooser,
- initial_flags,
- setting,
- password_flags_name,
- with_not_required,
- ask_mode);
-}
-
-/**
- * nma_cert_chooser_update_key_password_storage:
- * @cert_chooser: certificate chooser button instance
- * @secret_flags: secret flags to set
- * @setting: #NMSetting containing the password, or NULL
- * @password_flags_name: name of the secret flags (like psk-flags), or NULL
- *
- * This method basically calls nma_utils_update_password_storage()
- * on the key password entry, in case one is present.
- *
- * Since: 1.8.0
- */
-void
-nma_cert_chooser_update_key_password_storage (NMACertChooser *cert_chooser,
- NMSettingSecretFlags secret_flags,
- NMSetting *setting,
- const char *password_flags_name)
-{
- g_return_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser));
-
- NMA_CERT_CHOOSER_GET_VTABLE (cert_chooser)->update_key_password_storage (cert_chooser,
- secret_flags,
- setting,
- password_flags_name);
-}
-
-/**
- * nma_cert_chooser_get_key_password_flags:
- * @cert_chooser: certificate chooser button instance
- *
- * Returns secret flags corresponding to the key password
- * if one is present. The chooser would typically call into
- * nma_utils_menu_to_secret_flags() for the key password
- * entry.
- *
- * Returns: secret flags corresponding to the key password
- *
- * Since: 1.8.0
- */
-NMSettingSecretFlags
-nma_cert_chooser_get_key_password_flags (NMACertChooser *cert_chooser)
-{
- g_return_val_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser),
- NM_SETTING_SECRET_FLAG_NONE);
-
- return NMA_CERT_CHOOSER_GET_VTABLE (cert_chooser)->get_key_password_flags (cert_chooser);
-}
-
-static GObject *
-constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_properties)
-{
- GObject *object;
- NMACertChooser *cert_chooser;
- NMACertChooserFlags flags = NMA_CERT_CHOOSER_FLAG_NONE;
- NMACertChooserPrivate *priv;
- int i;
- const gchar *title = NULL;
-
- object = G_OBJECT_CLASS (nma_cert_chooser_parent_class)->constructor (type,
- n_construct_properties,
- construct_properties);
- cert_chooser = NMA_CERT_CHOOSER (object);
- priv = NMA_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
-
- for (i = 0; i < n_construct_properties; i++) {
- if (strcmp (construct_properties[i].pspec->name, "title") == 0)
- title = g_value_get_string (construct_properties[i].value);
- if (strcmp (construct_properties[i].pspec->name, "flags") == 0)
- flags |= g_value_get_uint (construct_properties[i].value);
- }
- priv->vtable = &nma_cert_chooser_vtable_file;
-#if LIBNM_BUILD && (GTK_CHECK_VERSION(3,90,0) ? WITH_GCR_GTK4 : WITH_GCR)
- if ((flags & NMA_CERT_CHOOSER_FLAG_PEM) == 0)
- priv->vtable = &nma_cert_chooser_vtable_pkcs11;
-#endif
-
- /* Initialize the vtable and construct-time properties */
- priv->vtable->init (cert_chooser);
- priv->vtable->set_flags (cert_chooser, flags);
- priv->vtable->set_title (cert_chooser, title);
-
- return object;
-}
-
-static void
-set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
-{
- NMACertChooser *cert_chooser = NMA_CERT_CHOOSER (object);
-
- g_return_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser));
-
- switch (property_id) {
- case PROP_TITLE:
- case PROP_FLAGS:
- /* Just ignore these, should be set at construct time */
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-nma_cert_chooser_class_init (NMACertChooserClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (object_class, sizeof (NMACertChooserPrivate));
-
- object_class->constructor = constructor;
- object_class->set_property = set_property;
-
- /**
- * NMACertChooser::title:
- *
- * Name of the certificate or certificate/key pair to be chosen.
- * Used in labels and chooser dialog titles.
- *
- * Since: 1.8.0
- */
- properties[PROP_TITLE] = g_param_spec_string ("title",
- "Title",
- "Certificate Chooser Title",
- NULL,
- G_PARAM_WRITABLE
- | G_PARAM_CONSTRUCT_ONLY
- | G_PARAM_STATIC_STRINGS);
-
- /**
- * NMACertChooser::flags:
- *
- * The #NMACertChooserFlags flags that influnce which chooser
- * implementation is used and configure its behavior.
- *
- * Since: 1.8.0
- */
- properties[PROP_FLAGS] = g_param_spec_uint ("flags",
- "Flags",
- "Certificate Chooser Flags",
- NMA_CERT_CHOOSER_FLAG_NONE,
- NMA_CERT_CHOOSER_FLAG_CERT
- | NMA_CERT_CHOOSER_FLAG_PASSWORDS
- | NMA_CERT_CHOOSER_FLAG_PEM,
- NMA_CERT_CHOOSER_FLAG_NONE,
- G_PARAM_WRITABLE
- | G_PARAM_CONSTRUCT_ONLY
- | G_PARAM_STATIC_STRINGS);
-
- g_object_class_install_properties (object_class, LAST_PROP, properties);
-
- /**
- * NMACertChooser::cert-validate:
- *
- * Emitted when the certificate needs validation. The handlers can indicate that
- * the certificate is invalid by returning an error, which blocks further
- * signal processing and causes a call to nma_cert_chooser_validate()
- * to fail.
- *
- * Since: 1.8.0
- */
- signals[CERT_VALIDATE] = g_signal_new ("cert-validate",
- NMA_TYPE_CERT_CHOOSER,
- G_SIGNAL_RUN_LAST,
- 0,
- accu_validation_error, NULL, NULL,
- G_TYPE_ERROR, 0);
-
- /**
- * NMACertChooser::cert-password-validate:
- *
- * Emitted when the certificate password needs validation. The handlers
- * can indicate that the password is invalid by returning an error, which blocks further
- * signal processing and causes a call to nma_cert_chooser_validate()
- * to fail.
- *
- * Since: 1.8.0
- */
- signals[CERT_PASSWORD_VALIDATE] = g_signal_new ("cert-password-validate",
- NMA_TYPE_CERT_CHOOSER,
- G_SIGNAL_RUN_LAST,
- 0,
- accu_validation_error, NULL, NULL,
- G_TYPE_ERROR, 0);
-
- /**
- * NMACertChooser::key-validate:
- *
- * Emitted when the key needs validation. The handlers can indicate that
- * the key is invalid by returning an error, which blocks further
- * signal processing and causes a call to nma_cert_chooser_validate()
- * to fail.
- *
- * Since: 1.8.0
- */
- signals[KEY_VALIDATE] = g_signal_new ("key-validate",
- NMA_TYPE_CERT_CHOOSER,
- G_SIGNAL_RUN_LAST,
- 0,
- accu_validation_error, NULL, NULL,
- G_TYPE_ERROR, 0);
-
- /**
- * NMACertChooser::key-password-validate:
- *
- * Emitted when the key password needs validation. The handlers can indicate
- * that the password is invalid by returning an error, which blocks further
- * signal processing and causes a call to nma_cert_chooser_validate()
- * to fail.
- *
- * Since: 1.8.0
- */
- signals[KEY_PASSWORD_VALIDATE] = g_signal_new ("key-password-validate",
- NMA_TYPE_CERT_CHOOSER,
- G_SIGNAL_RUN_LAST,
- 0,
- accu_validation_error, NULL, NULL,
- G_TYPE_ERROR, 0);
-
- /**
- * NMACertChooser::changed:
- *
- * Emitted when anything changes in the certificate chooser, be it a certificate,
- * a key or associated passwords.
- *
- * Since: 1.8.0
- */
- signals[CHANGED] = g_signal_new ("changed",
- NMA_TYPE_CERT_CHOOSER,
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
- 0,
- NULL, NULL, NULL,
- G_TYPE_NONE, 0);
-
-}
-
-static void
-nma_cert_chooser_init (NMACertChooser *file_cert_chooser)
-{
-}
-
-/**
- * nma_cert_chooser_new:
- * @title: title of the certificate chooser dialog
- * @flags: the flags that configure the capabilities of the button
- *
- * Constructs the button that is capable of selecting a certificate
- * and a key.
- *
- * Returns: (transfer full): the certificate chooser button instance
- *
- * Since: 1.8.0
- */
-GtkWidget *
-nma_cert_chooser_new (const gchar *title, NMACertChooserFlags flags)
-{
- return g_object_new (NMA_TYPE_CERT_CHOOSER,
- "title", title,
- "flags", flags,
- NULL);
-}
diff --git a/src/libnma/nma-cert-chooser.h b/src/libnma/nma-cert-chooser.h
deleted file mode 100644
index c4c0ad54..00000000
--- a/src/libnma/nma-cert-chooser.h
+++ /dev/null
@@ -1,151 +0,0 @@
-// SPDX-License-Identifier: LGPL-2.1+
-/* NetworkManager Applet -- allow user control over networking
- *
- * Lubomir Rintel <lkundrak@v3.sk>
- *
- * Copyright (C) 2015,2017 Red Hat, Inc.
- */
-
-#ifndef NMA_CERT_CHOOSER_H
-#define NMA_CERT_CHOOSER_H
-
-#include <gtk/gtk.h>
-#include <NetworkManager.h>
-
-#include "nma-version.h"
-
-G_BEGIN_DECLS
-
-/**
- * NMACertChooserFlags:
- * @NMA_CERT_CHOOSER_FLAG_NONE: No flags
- * @NMA_CERT_CHOOSER_FLAG_CERT: Only pick a certificate, not a key
- * @NMA_CERT_CHOOSER_FLAG_PASSWORDS: Hide all controls but the secrets entries
- * @NMA_CERT_CHOOSER_FLAG_PEM: Ensure the chooser only selects regular PEM files
- *
- * Flags that controls what is the certificate chooser button able to pick.
- * Currently only local files are supported, but might be extended to use URIs,
- * such as PKCS\#11 certificate URIs in future as well.
- *
- * Since: 1.8.0
- */
-NMA_AVAILABLE_IN_1_8
-typedef enum {
- NMA_CERT_CHOOSER_FLAG_NONE = 0x0,
- NMA_CERT_CHOOSER_FLAG_CERT = 0x1,
- NMA_CERT_CHOOSER_FLAG_PASSWORDS = 0x2,
- NMA_CERT_CHOOSER_FLAG_PEM = 0x4,
-} NMACertChooserFlags;
-
-#define NMA_TYPE_CERT_CHOOSER (nma_cert_chooser_get_type ())
-#define NMA_CERT_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMA_TYPE_CERT_CHOOSER, NMACertChooser))
-#define NMA_CERT_CHOOSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMA_TYPE_CERT_CHOOSER, NMACertChooserClass))
-#define NMA_IS_CERT_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMA_TYPE_CERT_CHOOSER))
-#define NMA_IS_CERT_CHOOSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMA_TYPE_CERT_CHOOSER))
-#define NMA_CERT_CHOOSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMA_TYPE_CERT_CHOOSER, NMACertChooserClass))
-
-NMA_AVAILABLE_IN_1_8
-typedef struct _NMACertChooser NMACertChooser;
-
-NMA_AVAILABLE_IN_1_8
-typedef struct _NMACertChooserClass NMACertChooserClass;
-
-NMA_AVAILABLE_IN_1_8
-GType nma_cert_chooser_get_type (void);
-
-NMA_AVAILABLE_IN_1_8
-void nma_cert_chooser_set_cert (NMACertChooser *cert_chooser,
- const gchar *value,
- NMSetting8021xCKScheme scheme);
-
-NMA_AVAILABLE_IN_1_8
-void nma_cert_chooser_set_cert_uri (NMACertChooser *cert_chooser,
- const gchar *uri);
-
-NMA_AVAILABLE_IN_1_8
-gchar *nma_cert_chooser_get_cert (NMACertChooser *cert_chooser,
- NMSetting8021xCKScheme *scheme);
-
-NMA_AVAILABLE_IN_1_8
-gchar *nma_cert_chooser_get_cert_uri (NMACertChooser *cert_chooser);
-
-NMA_AVAILABLE_IN_1_8
-void nma_cert_chooser_set_cert_password (NMACertChooser *cert_chooser,
- const gchar *password);
-
-NMA_AVAILABLE_IN_1_8
-const gchar *nma_cert_chooser_get_cert_password (NMACertChooser *cert_chooser);
-
-NMA_AVAILABLE_IN_1_8
-void nma_cert_chooser_set_key (NMACertChooser *cert_chooser,
- const gchar *value,
- NMSetting8021xCKScheme scheme);
-
-NMA_AVAILABLE_IN_1_8
-void nma_cert_chooser_set_key_uri (NMACertChooser *cert_chooser,
- const gchar *uri);
-
-NMA_AVAILABLE_IN_1_8
-gchar *nma_cert_chooser_get_key (NMACertChooser *cert_chooser,
- NMSetting8021xCKScheme *scheme);
-
-NMA_AVAILABLE_IN_1_8
-gchar *nma_cert_chooser_get_key_uri (NMACertChooser *cert_chooser);
-
-NMA_AVAILABLE_IN_1_8
-void nma_cert_chooser_set_key_password (NMACertChooser *cert_chooser,
- const gchar *password);
-
-NMA_AVAILABLE_IN_1_8
-const gchar *nma_cert_chooser_get_key_password (NMACertChooser *cert_chooser);
-
-NMA_AVAILABLE_IN_1_8
-GtkWidget *nma_cert_chooser_new (const gchar *title,
- NMACertChooserFlags flags);
-
-
-NMA_AVAILABLE_IN_1_8
-void nma_cert_chooser_add_to_size_group (NMACertChooser *cert_chooser,
- GtkSizeGroup *group);
-
-NMA_AVAILABLE_IN_1_8
-gboolean nma_cert_chooser_validate (NMACertChooser *cert_chooser,
- GError **error);
-
-NMA_AVAILABLE_IN_1_8
-void nma_cert_chooser_setup_cert_password_storage (NMACertChooser *cert_chooser,
- NMSettingSecretFlags initial_flags,
- NMSetting *setting,
- const char *password_flags_name,
- gboolean with_not_required,
- gboolean ask_mode);
-
-NMA_AVAILABLE_IN_1_8
-void nma_cert_chooser_update_cert_password_storage (NMACertChooser *cert_chooser,
- NMSettingSecretFlags secret_flags,
- NMSetting *setting,
- const char *password_flags_name);
-
-NMA_AVAILABLE_IN_1_8
-NMSettingSecretFlags nma_cert_chooser_get_cert_password_flags (NMACertChooser *cert_chooser);
-
-NMA_AVAILABLE_IN_1_8
-void nma_cert_chooser_setup_key_password_storage (NMACertChooser *cert_chooser,
- NMSettingSecretFlags initial_flags,
- NMSetting *setting,
- const char *password_flags_name,
- gboolean with_not_required,
- gboolean ask_mode);
-
-NMA_AVAILABLE_IN_1_8
-void nma_cert_chooser_update_key_password_storage (NMACertChooser *cert_chooser,
- NMSettingSecretFlags secret_flags,
- NMSetting *setting,
- const char *password_flags_name);
-
-NMA_AVAILABLE_IN_1_8
-NMSettingSecretFlags nma_cert_chooser_get_key_password_flags (NMACertChooser *cert_chooser);
-
-G_END_DECLS
-
-#endif /* NMA_CERT_CHOOSER_H */
diff --git a/src/libnma/nma-file-cert-chooser.c b/src/libnma/nma-file-cert-chooser.c
deleted file mode 100644
index 8f24c826..00000000
--- a/src/libnma/nma-file-cert-chooser.c
+++ /dev/null
@@ -1,399 +0,0 @@
-// SPDX-License-Identifier: LGPL-2.1+
-/* NetworkManager Applet -- allow user control over networking
- *
- * Dan Williams <dcbw@redhat.com>
- * Lubomir Rintel <lkundrak@v3.sk>
- *
- * Copyright (C) 2015,2017 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-#include "nma-private.h"
-#include "nma-cert-chooser-private.h"
-#include "utils.h"
-#ifdef LIBNM_BUILD
-#include "nma-ui-utils.h"
-#else
-#include "nm-ui-utils.h"
-#endif
-
-#define NMA_FILE_CERT_CHOOSER_GET_PRIVATE(self) (&(_NM_GET_PRIVATE (self, NMACertChooser, NMA_IS_CERT_CHOOSER)->_sub.file))
-
-#if GTK_CHECK_VERSION(3,90,0)
-#define gtk3_widget_set_no_show_all(widget, show)
-#else
-#define gtk3_widget_set_no_show_all(widget, show) gtk_widget_set_no_show_all (widget, show);
-#endif
-
-static void
-set_key_password (NMACertChooser *cert_chooser, const gchar *password)
-{
- NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
-
- g_return_if_fail (priv->key_password != NULL);
- gtk_editable_set_text (GTK_EDITABLE (priv->key_password), password);
-}
-
-static const gchar *
-get_key_password (NMACertChooser *cert_chooser)
-{
- NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
-
- g_return_val_if_fail (priv->key_password != NULL, NULL);
- return gtk_editable_get_text (GTK_EDITABLE (priv->key_password));
-}
-
-static void
-set_key_uri (NMACertChooser *cert_chooser, const gchar *uri)
-{
- NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
-
- if (uri)
- gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (priv->key_button), uri);
-}
-
-static gchar *
-get_key_uri (NMACertChooser *cert_chooser)
-{
- NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
-
- return gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (priv->key_button));
-}
-
-static void
-set_cert_uri (NMACertChooser *cert_chooser, const gchar *uri)
-{
- NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
-
- if (uri)
- gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (priv->cert_button), uri);
-}
-
-static gchar *
-get_cert_uri (NMACertChooser *cert_chooser)
-{
- NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
-
- return gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (priv->cert_button));
-}
-
-static void
-add_to_size_group (NMACertChooser *cert_chooser, GtkSizeGroup *group)
-{
- NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
-
- gtk_size_group_add_widget (group, priv->cert_button_label);
- gtk_size_group_add_widget (group, priv->key_button_label);
- gtk_size_group_add_widget (group, priv->key_password_label);
-}
-
-static gboolean
-validate (NMACertChooser *cert_chooser, GError **error)
-{
- NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
- GError *local = NULL;
- char *tmp;
-
- tmp = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (priv->cert_button));
- if (tmp) {
- g_free (tmp);
- } else {
- g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("No certificate set"));
- return FALSE;
- }
-
- g_signal_emit_by_name (cert_chooser, "cert-validate", &local);
- if (local) {
- widget_set_error (priv->cert_button);
- g_propagate_error (error, local);
- return FALSE;
- } else {
- widget_unset_error (priv->cert_button);
- }
-
- if (gtk_widget_get_visible (priv->key_button)) {
- tmp = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (priv->key_button));
- if (tmp) {
- g_free (tmp);
- } else {
- g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("No key set"));
- return FALSE;
- }
-
- g_signal_emit_by_name (cert_chooser, "key-validate", &local);
- if (local) {
- widget_set_error (priv->key_button);
- g_propagate_error (error, local);
- return FALSE;
- } else {
- widget_unset_error (priv->key_button);
- }
-
- g_signal_emit_by_name (cert_chooser, "key-password-validate", &local);
- if (local) {
- widget_set_error (priv->key_password);
- g_propagate_error (error, local);
- return FALSE;
- } else {
- widget_unset_error (priv->key_password);
- }
- }
-
- return TRUE;
-}
-
-static void
-setup_key_password_storage (NMACertChooser *cert_chooser,
- NMSettingSecretFlags initial_flags,
- NMSetting *setting,
- const char *password_flags_name,
- gboolean with_not_required,
- gboolean ask_mode)
-{
- NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
-
- nma_utils_setup_password_storage (priv->key_password,
- initial_flags,
- setting,
- password_flags_name,
- with_not_required,
- ask_mode);
-}
-
-static void
-update_key_password_storage (NMACertChooser *cert_chooser,
- NMSettingSecretFlags secret_flags,
- NMSetting *setting,
- const char *password_flags_name)
-{
- NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
-
- nma_utils_update_password_storage (priv->key_password,
- secret_flags,
- setting,
- password_flags_name);
-}
-
-
-static NMSettingSecretFlags
-get_key_password_flags (NMACertChooser *cert_chooser)
-{
- NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
-
- return nma_utils_menu_to_secret_flags (priv->key_password);
-}
-
-static void
-reset_filter (GtkWidget *widget, GParamSpec *spec, gpointer user_data)
-{
- if (!gtk_file_chooser_get_filter (GTK_FILE_CHOOSER (widget))) {
- g_signal_handlers_block_by_func (widget, reset_filter, user_data);
- gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (widget), GTK_FILE_FILTER (user_data));
- g_signal_handlers_unblock_by_func (widget, reset_filter, user_data);
- }
-}
-
-static void
-cert_changed_cb (GtkFileChooserButton *file_chooser_button, gpointer user_data)
-{
- NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (NMA_CERT_CHOOSER (user_data));
-
- if (gtk_widget_get_visible (priv->key_button)) {
- gtk_widget_set_sensitive (priv->key_button, TRUE);
- gtk_widget_set_sensitive (priv->key_button_label, TRUE);
- }
- g_signal_emit_by_name (user_data, "changed");
-}
-
-static void
-key_changed_cb (GtkFileChooserButton *file_chooser_button, gpointer user_data)
-{
- NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (NMA_CERT_CHOOSER (user_data));
-
- gtk_widget_set_sensitive (priv->key_password, TRUE);
- gtk_widget_set_sensitive (priv->key_password_label, TRUE);
- g_signal_emit_by_name (user_data, "changed");
-}
-
-static void
-key_password_changed_cb (GtkEntry *entry, gpointer user_data)
-{
- g_signal_emit_by_name (user_data, "changed");
-}
-
-static void
-show_toggled_cb (GtkCheckButton *button, gpointer user_data)
-{
- NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (NMA_CERT_CHOOSER (user_data));
-
- gtk_entry_set_visibility (GTK_ENTRY (priv->key_password),
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)));
-}
-
-static void
-set_title (NMACertChooser *cert_chooser, const gchar *title)
-{
- NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
- gchar *text;
-
- text = g_strdup_printf (_("Choose a key for %s Certificate"), title);
- gtk_file_chooser_button_set_title (GTK_FILE_CHOOSER_BUTTON (priv->key_button), text);
- g_free (text);
-
- text = g_strdup_printf (_("%s private _key"), title);
- gtk_label_set_text_with_mnemonic (GTK_LABEL (priv->key_button_label), text);
- g_free (text);
-
- text = g_strdup_printf (_("%s key _password"), title);
- gtk_label_set_text_with_mnemonic (GTK_LABEL (priv->key_password_label), text);
- g_free (text);
-
- text = g_strdup_printf (_("Choose %s Certificate"), title);
- gtk_file_chooser_button_set_title (GTK_FILE_CHOOSER_BUTTON (priv->cert_button), text);
- g_free (text);
-
- text = g_strdup_printf (_("%s _certificate"), title);
- gtk_label_set_text_with_mnemonic (GTK_LABEL (priv->cert_button_label), text);
- g_free (text);
-}
-
-static void
-set_flags (NMACertChooser *cert_chooser, NMACertChooserFlags flags)
-{
- NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
-
- if (flags & NMA_CERT_CHOOSER_FLAG_CERT) {
- gtk_widget_hide (priv->key_button);
- gtk_widget_hide (priv->key_button_label);
- gtk_widget_hide (priv->key_password);
- gtk_widget_hide (priv->key_password_label);
- gtk_widget_hide (priv->show_password);
- }
-
- if (flags & NMA_CERT_CHOOSER_FLAG_PASSWORDS) {
- gtk_widget_hide (priv->cert_button);
- gtk_widget_hide (priv->cert_button_label);
- gtk_widget_hide (priv->key_button);
- gtk_widget_hide (priv->key_button_label);
- }
-}
-
-static void
-init (NMACertChooser *cert_chooser)
-{
- NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
- GtkFileFilter *filter;
-
- gtk_grid_insert_column (GTK_GRID (cert_chooser), 2);
- gtk_grid_set_row_spacing (GTK_GRID (cert_chooser), 6);
- gtk_grid_set_column_spacing (GTK_GRID (cert_chooser), 6);
-
- /* The key chooser */
- gtk_grid_insert_row (GTK_GRID (cert_chooser), 0);
-
- priv->key_button = g_object_new (GTK_TYPE_FILE_CHOOSER_BUTTON,
- "action", GTK_FILE_CHOOSER_ACTION_OPEN,
- "filter", utils_key_filter (),
- "local-only", TRUE,
- NULL);
- gtk_grid_attach (GTK_GRID (cert_chooser), priv->key_button, 1, 0, 1, 1);
- gtk_widget_set_hexpand (priv->key_button, TRUE);
- gtk_widget_set_sensitive (priv->key_button, FALSE);
- gtk_widget_show (priv->key_button);
- gtk3_widget_set_no_show_all (priv->key_button, TRUE);
-
- g_signal_connect (priv->key_button, "selection-changed",
- G_CALLBACK (key_changed_cb), cert_chooser);
-
- priv->key_button_label = gtk_label_new (NULL);
- g_object_set (priv->key_button_label, "xalign", (gfloat) 1, NULL);
- gtk_label_set_mnemonic_widget (GTK_LABEL (priv->key_button_label), priv->key_button);
- gtk_grid_attach (GTK_GRID (cert_chooser), priv->key_button_label, 0, 0, 1, 1);
- gtk_widget_set_sensitive (priv->key_button_label, FALSE);
- gtk_widget_show (priv->key_button_label);
- gtk3_widget_set_no_show_all (priv->key_button_label, TRUE);
-
- /* The key password entry */
- gtk_grid_insert_row (GTK_GRID (cert_chooser), 1);
-
- priv->key_password = gtk_entry_new ();
- gtk_entry_set_visibility (GTK_ENTRY (priv->key_password), FALSE);
- gtk_grid_attach (GTK_GRID (cert_chooser), priv->key_password, 1, 1, 1, 1);
- gtk_widget_set_hexpand (priv->key_password, TRUE);
- gtk_widget_set_sensitive (priv->key_password, FALSE);
- gtk_widget_show (priv->key_password);
- gtk3_widget_set_no_show_all (priv->key_password, TRUE);
-
- g_signal_connect (priv->key_password, "changed",
- G_CALLBACK (key_password_changed_cb), cert_chooser);
-
- priv->key_password_label = gtk_label_new (NULL);
- g_object_set (priv->key_password_label, "xalign", (gfloat) 1, NULL);
- gtk_label_set_mnemonic_widget (GTK_LABEL (priv->key_password_label), priv->key_password);
- gtk_grid_attach (GTK_GRID (cert_chooser), priv->key_password_label, 0, 1, 1, 1);
- gtk_widget_set_sensitive (priv->key_password_label, FALSE);
- gtk_widget_show (priv->key_password_label);
- gtk3_widget_set_no_show_all (priv->key_password_label, TRUE);
-
- /* Show password */
- gtk_grid_insert_row (GTK_GRID (cert_chooser), 2);
- priv->show_password = gtk_check_button_new_with_mnemonic _("Sho_w password");
- gtk_grid_attach (GTK_GRID (cert_chooser), priv->show_password, 1, 2, 1, 1);
- gtk_widget_show (priv->show_password);
- gtk3_widget_set_no_show_all (priv->show_password, TRUE);
- g_signal_connect (priv->show_password, "toggled",
- G_CALLBACK (show_toggled_cb), cert_chooser);
-
- /* The certificate chooser */
- gtk_grid_insert_row (GTK_GRID (cert_chooser), 0);
-
- filter = utils_cert_filter ();
- priv->cert_button = g_object_new (GTK_TYPE_FILE_CHOOSER_BUTTON,
- "action", GTK_FILE_CHOOSER_ACTION_OPEN,
- "filter", filter,
- "local-only", TRUE,
- NULL);
- gtk_grid_attach (GTK_GRID (cert_chooser), priv->cert_button, 1, 0, 1, 1);
- gtk_widget_set_hexpand (priv->cert_button, TRUE);
- gtk_widget_show (priv->cert_button);
- gtk3_widget_set_no_show_all (priv->cert_button, TRUE);
-
- /* For some reason, GTK+ calls set_current_filter (..., NULL) from
- * gtkfilechooserdefault.c::show_and_select_files_finished_loading() on our
- * dialog; so force-reset the filter to what we want it to be whenever
- * it gets cleared.
- */
- g_signal_connect (priv->cert_button, "notify::filter",
- G_CALLBACK (reset_filter), filter);
-
- g_signal_connect (priv->cert_button, "selection-changed",
- G_CALLBACK (cert_changed_cb), cert_chooser);
-
- priv->cert_button_label = gtk_label_new (NULL);
- g_object_set (priv->cert_button_label, "xalign", (gfloat) 1, NULL);
- gtk_label_set_mnemonic_widget (GTK_LABEL (priv->cert_button_label), priv->cert_button);
- gtk_grid_attach (GTK_GRID (cert_chooser), priv->cert_button_label, 0, 0, 1, 1);
- gtk_widget_show (priv->cert_button_label);
- gtk3_widget_set_no_show_all (priv->cert_button_label, TRUE);
-}
-
-const NMACertChooserVtable nma_cert_chooser_vtable_file = {
- .init = init,
-
- .set_title = set_title,
- .set_flags = set_flags,
-
- .set_cert_uri = set_cert_uri,
- .get_cert_uri = get_cert_uri,
- .set_key_uri = set_key_uri,
- .get_key_uri = get_key_uri,
- .set_key_password = set_key_password,
- .get_key_password = get_key_password,
-
- .add_to_size_group = add_to_size_group,
- .validate = validate,
-
- .setup_key_password_storage = setup_key_password_storage,
- .update_key_password_storage = update_key_password_storage,
- .get_key_password_flags = get_key_password_flags,
-};
diff --git a/src/libnma/nma-mobile-providers.c b/src/libnma/nma-mobile-providers.c
deleted file mode 100644
index e69378b3..00000000
--- a/src/libnma/nma-mobile-providers.c
+++ /dev/null
@@ -1,1600 +0,0 @@
-// SPDX-License-Identifier: LGPL-2.1+
-/*
- * Copyright (C) 2009 Novell, Inc.
- * Author: Tambet Ingo (tambet@gmail.com).
- *
- * Copyright (C) 2009 - 2012 Red Hat, Inc.
- * Copyright (C) 2012 Lanedo GmbH
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <errno.h>
-#include <stdlib.h>
-
-#include "nma-mobile-providers.h"
-
-#define MOBILE_BROADBAND_PROVIDER_INFO "/mobile-broadband-provider-info/serviceproviders.xml"
-#define ISO_3166_COUNTRY_CODES "/xml/iso-codes/iso_3166.xml"
-
-/******************************************************************************/
-/* Access method type */
-
-G_DEFINE_BOXED_TYPE (NMAMobileAccessMethod,
- nma_mobile_access_method,
- nma_mobile_access_method_ref,
- nma_mobile_access_method_unref)
-
-struct _NMAMobileAccessMethod {
- volatile gint refs;
-
- char *name;
- /* maps lang (char *) -> name (char *) */
- GHashTable *lcl_names;
-
- char *username;
- char *password;
- char *gateway;
- GPtrArray *dns; /* GPtrArray of 'char *' */
-
- /* Only used with 3GPP family type providers */
- char *apn;
-
- NMAMobileFamily family;
-};
-
-static NMAMobileAccessMethod *
-access_method_new (void)
-{
- NMAMobileAccessMethod *method;
-
- method = g_slice_new0 (NMAMobileAccessMethod);
- method->refs = 1;
- method->lcl_names = g_hash_table_new_full (g_str_hash, g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) g_free);
-
- return method;
-}
-
-NMAMobileAccessMethod *
-nma_mobile_access_method_ref (NMAMobileAccessMethod *method)
-{
- g_return_val_if_fail (method != NULL, NULL);
- g_return_val_if_fail (method->refs > 0, NULL);
-
- g_atomic_int_inc (&method->refs);
-
- return method;
-}
-
-void
-nma_mobile_access_method_unref (NMAMobileAccessMethod *method)
-{
- g_return_if_fail (method != NULL);
- g_return_if_fail (method->refs > 0);
-
- if (g_atomic_int_dec_and_test (&method->refs)) {
- g_free (method->name);
- g_hash_table_destroy (method->lcl_names);
- g_free (method->username);
- g_free (method->password);
- g_free (method->gateway);
- g_free (method->apn);
-
- if (method->dns)
- g_ptr_array_unref (method->dns);
-
- g_slice_free (NMAMobileAccessMethod, method);
- }
-}
-
-/**
- * nma_mobile_access_method_get_name:
- * @method: a #NMAMobileAccessMethod
- *
- * Returns: (transfer none): the name of the method.
- */
-const gchar *
-nma_mobile_access_method_get_name (NMAMobileAccessMethod *method)
-{
- g_return_val_if_fail (method != NULL, NULL);
-
- return method->name;
-}
-
-/**
- * nma_mobile_access_method_get_username:
- * @method: a #NMAMobileAccessMethod
- *
- * Returns: (transfer none): the username.
- */
-const gchar *
-nma_mobile_access_method_get_username (NMAMobileAccessMethod *method)
-{
- g_return_val_if_fail (method != NULL, NULL);
-
- return method->username;
-}
-
-/**
- * nma_mobile_access_method_get_password:
- * @method: a #NMAMobileAccessMethod
- *
- * Returns: (transfer none): the password.
- */
-const gchar *
-nma_mobile_access_method_get_password (NMAMobileAccessMethod *method)
-{
- g_return_val_if_fail (method != NULL, NULL);
-
- return method->password;
-}
-
-/**
- * nma_mobile_access_method_get_gateway:
- * @method: a #NMAMobileAccessMethod
- *
- * Returns: (transfer none): the gateway.
- */
-const gchar *
-nma_mobile_access_method_get_gateway (NMAMobileAccessMethod *method)
-{
- g_return_val_if_fail (method != NULL, NULL);
-
- return method->gateway;
-}
-
-/**
- * nma_mobile_access_method_get_dns:
- * @method: a #NMAMobileAccessMethod
- *
- * Returns: (transfer none) (array zero-terminated=1) (element-type utf8): the list of DNS.
- */
-const gchar **
-nma_mobile_access_method_get_dns (NMAMobileAccessMethod *method)
-{
- g_return_val_if_fail (method != NULL, NULL);
-
- return method->dns ? (const gchar **)method->dns->pdata : NULL;
-}
-
-/**
- * nma_mobile_access_method_get_3gpp_apn:
- * @method: a #NMAMobileAccessMethod
- *
- * Returns: (transfer none): the 3GPP APN.
- */
-const gchar *
-nma_mobile_access_method_get_3gpp_apn (NMAMobileAccessMethod *method)
-{
- g_return_val_if_fail (method != NULL, NULL);
-
- return method->apn;
-}
-
-/**
- * nma_mobile_access_method_get_family:
- * @method: a #NMAMobileAccessMethod
- *
- * Returns: a #NMAMobileFamily.
- */
-NMAMobileFamily
-nma_mobile_access_method_get_family (NMAMobileAccessMethod *method)
-{
- g_return_val_if_fail (method != NULL, NMA_MOBILE_FAMILY_UNKNOWN);
-
- return method->family;
-}
-
-/******************************************************************************/
-/* Mobile provider type */
-
-G_DEFINE_BOXED_TYPE (NMAMobileProvider,
- nma_mobile_provider,
- nma_mobile_provider_ref,
- nma_mobile_provider_unref)
-
-struct _NMAMobileProvider {
- volatile gint refs;
-
- char *name;
- /* maps lang (char *) -> name (char *) */
- GHashTable *lcl_names;
-
- GSList *methods; /* GSList of NmaMobileAccessMethod */
-
- GPtrArray *mcc_mnc; /* GPtrArray of strings */
- GArray *cdma_sid; /* GArray of guint32 */
-};
-
-static NMAMobileProvider *
-provider_new (void)
-{
- NMAMobileProvider *provider;
-
- provider = g_slice_new0 (NMAMobileProvider);
- provider->refs = 1;
- provider->lcl_names = g_hash_table_new_full (g_str_hash, g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) g_free);
-
- return provider;
-}
-
-NMAMobileProvider *
-nma_mobile_provider_ref (NMAMobileProvider *provider)
-{
- g_return_val_if_fail (provider != NULL, NULL);
- g_return_val_if_fail (provider->refs > 0, NULL);
-
- g_atomic_int_inc (&provider->refs);
-
- return provider;
-}
-
-void
-nma_mobile_provider_unref (NMAMobileProvider *provider)
-{
- if (g_atomic_int_dec_and_test (&provider->refs)) {
- g_free (provider->name);
- g_hash_table_destroy (provider->lcl_names);
-
- g_slist_free_full (provider->methods, (GDestroyNotify) nma_mobile_access_method_unref);
-
- if (provider->mcc_mnc)
- g_ptr_array_unref (provider->mcc_mnc);
-
- if (provider->cdma_sid)
- g_array_unref (provider->cdma_sid);
-
- g_slice_free (NMAMobileProvider, provider);
- }
-}
-
-/**
- * nma_mobile_provider_get_name:
- * @provider: a #NMAMobileProvider
- *
- * Returns: (transfer none): the name of the provider.
- */
-const gchar *
-nma_mobile_provider_get_name (NMAMobileProvider *provider)
-{
- g_return_val_if_fail (provider != NULL, NULL);
-
- return provider->name;
-}
-
-/**
- * nma_mobile_provider_get_methods:
- * @provider: a #NMAMobileProvider
- *
- * Returns: (element-type NMAMobileAccessMethod) (transfer none): the
- * list of #NMAMobileAccessMethod this provider exposes.
- */
-GSList *
-nma_mobile_provider_get_methods (NMAMobileProvider *provider)
-{
- g_return_val_if_fail (provider != NULL, NULL);
-
- return provider->methods;
-}
-
-/**
- * nma_mobile_provider_get_3gpp_mcc_mnc:
- * @provider: a #NMAMobileProvider
- *
- * Returns: (transfer none) (array zero-terminated=1) (element-type utf8): a
- * list of strings with the MCC and MNC codes this provider exposes.
- */
-const gchar **
-nma_mobile_provider_get_3gpp_mcc_mnc (NMAMobileProvider *provider)
-{
- g_return_val_if_fail (provider != NULL, NULL);
-
- return provider->mcc_mnc ? (const gchar **)provider->mcc_mnc->pdata : NULL;
-}
-
-/**
- * nma_mobile_provider_get_cdma_sid:
- * @provider: a #NMAMobileProvider
- *
- * Returns: (transfer none) (array zero-terminated=1) (element-type guint32): the
- * list of CDMA SIDs this provider exposes
- */
-const guint32 *
-nma_mobile_provider_get_cdma_sid (NMAMobileProvider *provider)
-{
- g_return_val_if_fail (provider != NULL, NULL);
-
- return provider->cdma_sid ? (const guint32 *)provider->cdma_sid->data : NULL;
-}
-
-/******************************************************************************/
-/* Country Info type */
-
-G_DEFINE_BOXED_TYPE (NMACountryInfo,
- nma_country_info,
- nma_country_info_ref,
- nma_country_info_unref)
-
-struct _NMACountryInfo {
- volatile gint refs;
-
- char *country_code;
- char *country_name;
- GSList *providers;
-};
-
-static NMACountryInfo *
-country_info_new (const char *country_code,
- const gchar *country_name)
-{
- NMACountryInfo *country_info;
-
- country_info = g_slice_new0 (NMACountryInfo);
- country_info->refs = 1;
- country_info->country_code = g_strdup (country_code);
- country_info->country_name = g_strdup (country_name);
- return country_info;
-}
-
-NMACountryInfo *
-nma_country_info_ref (NMACountryInfo *country_info)
-{
- g_return_val_if_fail (country_info != NULL, NULL);
- g_return_val_if_fail (country_info->refs > 0, NULL);
-
- g_atomic_int_inc (&country_info->refs);
-
- return country_info;
-}
-
-void
-nma_country_info_unref (NMACountryInfo *country_info)
-{
- if (g_atomic_int_dec_and_test (&country_info->refs)) {
- g_free (country_info->country_code);
- g_free (country_info->country_name);
- g_slist_free_full (country_info->providers,
- (GDestroyNotify) nma_mobile_provider_unref);
- g_slice_free (NMACountryInfo, country_info);
- }
-}
-
-/**
- * nma_country_info_get_country_code:
- * @country_info: a #NMACountryInfo
- *
- * Returns: (transfer none): the code of the country or %NULL for "Unknown".
- */
-const gchar *
-nma_country_info_get_country_code (NMACountryInfo *country_info)
-{
- g_return_val_if_fail (country_info != NULL, NULL);
-
- if (country_info->country_code[0] == '\0')
- return NULL;
-
- return country_info->country_code;
-}
-
-/**
- * nma_country_info_get_country_name:
- * @country_info: a #NMACountryInfo
- *
- * Returns: (transfer none): the name of the country.
- */
-const gchar *
-nma_country_info_get_country_name (NMACountryInfo *country_info)
-{
- g_return_val_if_fail (country_info != NULL, NULL);
-
- return country_info->country_name;
-}
-
-/**
- * nma_country_info_get_providers:
- * @country_info: a #NMACountryInfo
- *
- * Returns: (element-type NMAMobileProvider) (transfer none): the
- * list of #NMAMobileProvider this country exposes.
- */
-GSList *
-nma_country_info_get_providers (NMACountryInfo *country_info)
-{
- g_return_val_if_fail (country_info != NULL, NULL);
-
- return country_info->providers;
-}
-
-/******************************************************************************/
-/* XML Parser for iso_3166.xml */
-
-static void
-iso_3166_parser_start_element (GMarkupParseContext *context,
- const gchar *element_name,
- const gchar **attribute_names,
- const gchar **attribute_values,
- gpointer data,
- GError **error)
-{
- int i;
- const char *country_code = NULL;
- const char *common_name = NULL;
- const char *name = NULL;
- GHashTable *table = (GHashTable *) data;
-
- if (!strcmp (element_name, "iso_3166_entry")) {
- NMACountryInfo *country_info;
-
- for (i = 0; attribute_names && attribute_names[i]; i++) {
- if (!strcmp (attribute_names[i], "alpha_2_code"))
- country_code = attribute_values[i];
- else if (!strcmp (attribute_names[i], "common_name"))
- common_name = attribute_values[i];
- else if (!strcmp (attribute_names[i], "name"))
- name = attribute_values[i];
- }
- if (!country_code) {
- g_warning ("%s: missing mandatory 'alpha_2_code' atribute in '%s'"
- " element.", __func__, element_name);
- return;
- }
- if (!name) {
- g_warning ("%s: missing mandatory 'name' atribute in '%s'"
- " element.", __func__, element_name);
- return;
- }
-
- country_info = country_info_new (country_code,
- dgettext ("iso_3166", common_name ? common_name : name));
-
- g_hash_table_insert (table, g_strdup (country_code), country_info);
- }
-}
-
-static const GMarkupParser iso_3166_parser = {
- iso_3166_parser_start_element,
- NULL, /* end element */
- NULL, /* text */
- NULL, /* passthrough */
- NULL /* error */
-};
-
-static gboolean
-read_country_codes (GHashTable *table,
- const gchar *country_codes_file,
- GCancellable *cancellable,
- GError **error)
-{
- GMarkupParseContext *ctx;
- char *buf;
- gsize buf_len;
-
- /* Set domain to iso_3166 for country name translation */
- bindtextdomain ("iso_3166", ISO_CODES_PREFIX "/locale");
- bind_textdomain_codeset ("iso_3166", "UTF-8");
-
- if (!g_file_get_contents (country_codes_file, &buf, &buf_len, error)) {
- g_prefix_error (error,
- "Failed to load '%s' from 'iso-codes': ",
- country_codes_file);
- return FALSE;
- }
-
- ctx = g_markup_parse_context_new (&iso_3166_parser, 0, table, NULL);
- if (!g_markup_parse_context_parse (ctx, buf, buf_len, error)) {
- g_prefix_error (error,
- "Failed to parse '%s' from 'iso-codes': ",
- country_codes_file);
- return FALSE;
- }
-
- g_markup_parse_context_free (ctx);
- g_free (buf);
- return TRUE;
-}
-
-/******************************************************************************/
-/* XML Parser for serviceproviders.xml */
-
-typedef enum {
- PARSER_TOPLEVEL = 0,
- PARSER_COUNTRY,
- PARSER_PROVIDER,
- PARSER_METHOD_GSM,
- PARSER_METHOD_GSM_APN,
- PARSER_METHOD_CDMA,
- PARSER_ERROR
-} MobileContextState;
-
-typedef struct {
- GHashTable *table;
-
- NMACountryInfo *current_country;
- char *country_code;
- NMAMobileProvider *current_provider;
- NMAMobileAccessMethod *current_method;
-
- char *text_buffer;
- MobileContextState state;
-} MobileParser;
-
-static NMACountryInfo *
-lookup_country (GHashTable *table, const char *country_code)
-{
- NMACountryInfo *country_info;
-
- country_info = g_hash_table_lookup (table, country_code);
- if (!country_info) {
- g_warning ("%s: adding providers for unknown country '%s'", __func__, country_code);
- country_info = g_hash_table_lookup (table, "");
- }
-
- return country_info;
-}
-
-static void
-parser_toplevel_start (MobileParser *parser,
- const char *name,
- const char **attribute_names,
- const char **attribute_values)
-{
- int i;
-
- if (!strcmp (name, "serviceproviders")) {
- for (i = 0; attribute_names && attribute_names[i]; i++) {
- if (!strcmp (attribute_names[i], "format")) {
- if (strcmp (attribute_values[i], "2.0")) {
- g_warning ("%s: mobile broadband provider database format '%s'"
- " not supported.", __func__, attribute_values[i]);
- parser->state = PARSER_ERROR;
- break;
- }
- }
- }
- } else if (!strcmp (name, "country")) {
- for (i = 0; attribute_names && attribute_names[i]; i++) {
- if (!strcmp (attribute_names[i], "code")) {
- g_free (parser->country_code);
- parser->country_code = g_ascii_strup (attribute_values[i], -1);
- parser->current_country = lookup_country (parser->table, parser->country_code);
- parser->state = PARSER_COUNTRY;
- break;
- }
- }
- }
-}
-
-static void
-parser_country_start (MobileParser *parser,
- const char *name,
- const char **attribute_names,
- const char **attribute_values)
-{
- if (!strcmp (name, "provider")) {
- parser->state = PARSER_PROVIDER;
- parser->current_provider = provider_new ();
- }
-}
-
-static void
-parser_provider_start (MobileParser *parser,
- const char *name,
- const char **attribute_names,
- const char **attribute_values)
-{
- if (!strcmp (name, "gsm"))
- parser->state = PARSER_METHOD_GSM;
- else if (!strcmp (name, "cdma")) {
- parser->state = PARSER_METHOD_CDMA;
- parser->current_method = access_method_new ();
- }
-}
-
-static void
-parser_gsm_start (MobileParser *parser,
- const char *name,
- const char **attribute_names,
- const char **attribute_values)
-{
- if (!strcmp (name, "network-id")) {
- const char *mcc = NULL, *mnc = NULL;
- int i;
-
- for (i = 0; attribute_names && attribute_names[i]; i++) {
- if (!strcmp (attribute_names[i], "mcc"))
- mcc = attribute_values[i];
- else if (!strcmp (attribute_names[i], "mnc"))
- mnc = attribute_values[i];
-
- if (mcc && strlen (mcc) && mnc && strlen (mnc)) {
- gchar *mccmnc;
-
- if (!parser->current_provider->mcc_mnc)
- parser->current_provider->mcc_mnc = g_ptr_array_new_full (2, g_free);
-
- mccmnc = g_strdup_printf ("%s%s", mcc, mnc);
- g_ptr_array_add (parser->current_provider->mcc_mnc, mccmnc);
- break;
- }
- }
- } else if (!strcmp (name, "apn")) {
- int i;
-
- for (i = 0; attribute_names && attribute_names[i]; i++) {
- if (!strcmp (attribute_names[i], "value")) {
-
- parser->state = PARSER_METHOD_GSM_APN;
- parser->current_method = access_method_new ();
- parser->current_method->apn = g_strstrip (g_strdup (attribute_values[i]));
- break;
- }
- }
- }
-}
-
-static void
-parser_cdma_start (MobileParser *parser,
- const char *name,
- const char **attribute_names,
- const char **attribute_values)
-{
- if (!strcmp (name, "sid")) {
- int i;
-
- for (i = 0; attribute_names && attribute_names[i]; i++) {
- if (!strcmp (attribute_names[i], "value")) {
- guint32 tmp;
-
- errno = 0;
- tmp = (guint32) strtoul (attribute_values[i], NULL, 10);
- if (errno == 0 && tmp > 0) {
- if (!parser->current_provider->cdma_sid)
- parser->current_provider->cdma_sid = g_array_sized_new (TRUE, FALSE, sizeof (guint32), 2);
- g_array_append_val (parser->current_provider->cdma_sid, tmp);
- }
- break;
- }
- }
- }
-}
-
-static void
-mobile_parser_start_element (GMarkupParseContext *context,
- const gchar *element_name,
- const gchar **attribute_names,
- const gchar **attribute_values,
- gpointer data,
- GError **error)
-{
- MobileParser *parser = (MobileParser *) data;
-
- if (parser->text_buffer) {
- g_free (parser->text_buffer);
- parser->text_buffer = NULL;
- }
-
- switch (parser->state) {
- case PARSER_TOPLEVEL:
- parser_toplevel_start (parser, element_name, attribute_names, attribute_values);
- break;
- case PARSER_COUNTRY:
- parser_country_start (parser, element_name, attribute_names, attribute_values);
- break;
- case PARSER_PROVIDER:
- parser_provider_start (parser, element_name, attribute_names, attribute_values);
- break;
- case PARSER_METHOD_GSM:
- parser_gsm_start (parser, element_name, attribute_names, attribute_values);
- break;
- case PARSER_METHOD_CDMA:
- parser_cdma_start (parser, element_name, attribute_names, attribute_values);
- break;
- default:
- break;
- }
-}
-
-static void
-parser_country_end (MobileParser *parser,
- const char *name)
-{
- if (!strcmp (name, "country")) {
- parser->current_country = NULL;
- g_free (parser->country_code);
- parser->country_code = NULL;
- g_free (parser->text_buffer);
- parser->text_buffer = NULL;
- parser->state = PARSER_TOPLEVEL;
- }
-}
-
-static void
-parser_provider_end (MobileParser *parser,
- const char *name)
-{
- if (!strcmp (name, "name")) {
- if (!parser->current_provider->name) {
- /* Use the first one. */
- if (nma_country_info_get_country_code (parser->current_country)) {
- parser->current_provider->name = parser->text_buffer;
- } else {
- parser->current_provider->name = g_strdup_printf ("%s (%s)",
- parser->text_buffer,
- parser->country_code);
- g_free (parser->text_buffer);
- }
- parser->text_buffer = NULL;
- }
- } else if (!strcmp (name, "provider")) {
- if (parser->current_provider->mcc_mnc)
- g_ptr_array_add (parser->current_provider->mcc_mnc, NULL);
-
- parser->current_provider->methods = g_slist_reverse (parser->current_provider->methods);
-
- parser->current_country->providers = g_slist_prepend (parser->current_country->providers,
- parser->current_provider);
- parser->current_provider = NULL;
- g_free (parser->text_buffer);
- parser->text_buffer = NULL;
- parser->state = PARSER_COUNTRY;
- }
-}
-
-static void
-parser_gsm_end (MobileParser *parser,
- const char *name)
-{
- if (!strcmp (name, "gsm")) {
- g_free (parser->text_buffer);
- parser->text_buffer = NULL;
- parser->state = PARSER_PROVIDER;
- }
-}
-
-static void
-parser_gsm_apn_end (MobileParser *parser,
- const char *name)
-{
- if (!strcmp (name, "name")) {
- if (!parser->current_method->name) {
- /* Use the first one. */
- parser->current_method->name = parser->text_buffer;
- parser->text_buffer = NULL;
- }
- } else if (!strcmp (name, "username")) {
- parser->current_method->username = parser->text_buffer;
- parser->text_buffer = NULL;
- } else if (!strcmp (name, "password")) {
- parser->current_method->password = parser->text_buffer;
- parser->text_buffer = NULL;
- } else if (!strcmp (name, "dns")) {
- if (!parser->current_method->dns)
- parser->current_method->dns = g_ptr_array_new_full (2, g_free);
- g_ptr_array_add (parser->current_method->dns, parser->text_buffer);
- parser->text_buffer = NULL;
- } else if (!strcmp (name, "gateway")) {
- parser->current_method->gateway = parser->text_buffer;
- parser->text_buffer = NULL;
- } else if (!strcmp (name, "apn")) {
- parser->current_method->family = NMA_MOBILE_FAMILY_3GPP;
-
- if (!parser->current_method->name)
- parser->current_method->name = g_strdup (_("Default"));
-
- if (parser->current_method->dns)
- g_ptr_array_add (parser->current_method->dns, NULL);
-
- parser->current_provider->methods = g_slist_prepend (parser->current_provider->methods,
- parser->current_method);
- parser->current_method = NULL;
- g_free (parser->text_buffer);
- parser->text_buffer = NULL;
- parser->state = PARSER_METHOD_GSM;
- }
-}
-
-static void
-parser_cdma_end (MobileParser *parser,
- const char *name)
-{
- if (!strcmp (name, "username")) {
- parser->current_method->username = parser->text_buffer;
- parser->text_buffer = NULL;
- } else if (!strcmp (name, "password")) {
- parser->current_method->password = parser->text_buffer;
- parser->text_buffer = NULL;
- } else if (!strcmp (name, "dns")) {
- if (!parser->current_method->dns)
- parser->current_method->dns = g_ptr_array_new_full (2, g_free);
- g_ptr_array_add (parser->current_method->dns, parser->text_buffer);
- parser->text_buffer = NULL;
- } else if (!strcmp (name, "gateway")) {
- parser->current_method->gateway = parser->text_buffer;
- parser->text_buffer = NULL;
- } else if (!strcmp (name, "cdma")) {
- parser->current_method->family = NMA_MOBILE_FAMILY_CDMA;
-
- if (!parser->current_method->name)
- parser->current_method->name = g_strdup (parser->current_provider->name);
-
- if (parser->current_method->dns)
- g_ptr_array_add (parser->current_method->dns, NULL);
-
- parser->current_provider->methods = g_slist_prepend (parser->current_provider->methods,
- parser->current_method);
- parser->current_method = NULL;
- g_free (parser->text_buffer);
- parser->text_buffer = NULL;
- parser->state = PARSER_PROVIDER;
- }
-}
-
-static void
-mobile_parser_end_element (GMarkupParseContext *context,
- const gchar *element_name,
- gpointer data,
- GError **error)
-{
- MobileParser *parser = (MobileParser *) data;
-
- switch (parser->state) {
- case PARSER_COUNTRY:
- parser_country_end (parser, element_name);
- break;
- case PARSER_PROVIDER:
- parser_provider_end (parser, element_name);
- break;
- case PARSER_METHOD_GSM:
- parser_gsm_end (parser, element_name);
- break;
- case PARSER_METHOD_GSM_APN:
- parser_gsm_apn_end (parser, element_name);
- break;
- case PARSER_METHOD_CDMA:
- parser_cdma_end (parser, element_name);
- break;
- default:
- break;
- }
-}
-
-static void
-mobile_parser_characters (GMarkupParseContext *context,
- const gchar *text,
- gsize text_len,
- gpointer data,
- GError **error)
-{
- MobileParser *parser = (MobileParser *) data;
-
- g_free (parser->text_buffer);
- parser->text_buffer = g_strdup (text);
-}
-
-static const GMarkupParser mobile_parser = {
- mobile_parser_start_element,
- mobile_parser_end_element,
- mobile_parser_characters,
- NULL, /* passthrough */
- NULL /* error */
-};
-
-static gboolean
-read_service_providers (GHashTable *countries,
- const gchar *service_providers,
- GCancellable *cancellable,
- GError **error)
-{
- GMarkupParseContext *ctx;
- GIOChannel *channel;
- MobileParser parser;
- char buffer[4096];
- GIOStatus status;
- gsize len = 0;
-
- memset (&parser, 0, sizeof (MobileParser));
- parser.table = countries;
-
- channel = g_io_channel_new_file (service_providers, "r", error);
- if (!channel) {
- g_prefix_error (error,
- "Could not read '%s': ",
- service_providers);
- return FALSE;
- }
-
- parser.state = PARSER_TOPLEVEL;
-
- ctx = g_markup_parse_context_new (&mobile_parser, 0, &parser, NULL);
-
- status = G_IO_STATUS_NORMAL;
- while (status == G_IO_STATUS_NORMAL) {
- status = g_io_channel_read_chars (channel, buffer, sizeof (buffer), &len, error);
-
- switch (status) {
- case G_IO_STATUS_NORMAL:
- if (!g_markup_parse_context_parse (ctx, buffer, len, error)) {
- status = G_IO_STATUS_ERROR;
- g_prefix_error (error,
- "Error while parsing XML at '%s': ",
- service_providers);
- }
- break;
- case G_IO_STATUS_EOF:
- break;
- case G_IO_STATUS_ERROR:
- g_prefix_error (error,
- "Error while reading '%s': ",
- service_providers);
- break;
- case G_IO_STATUS_AGAIN:
- /* FIXME: Try again a few times, but really, it never happens, right? */
- break;
- }
-
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- status = G_IO_STATUS_ERROR;
- }
-
- g_io_channel_unref (channel);
- g_markup_parse_context_free (ctx);
-
- if (parser.current_provider) {
- g_warning ("pending current provider");
- nma_mobile_provider_unref (parser.current_provider);
- }
-
- g_free (parser.text_buffer);
-
- return (status == G_IO_STATUS_EOF);
-}
-
-static GHashTable *
-mobile_providers_parse_sync (const gchar *country_codes,
- const gchar *service_providers,
- GCancellable *cancellable,
- GError **error)
-{
- GHashTable *countries;
- char *path;
- const gchar * const *dirs;
- int i;
- gboolean success;
-
- dirs = g_get_system_data_dirs ();
- countries = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free,
- (GDestroyNotify)nma_country_info_unref);
-
- g_hash_table_insert (countries, g_strdup (""),
- country_info_new ("", _("My country is not listed")));
-
- /* Use default paths if none given */
- if (country_codes) {
- if (!read_country_codes (countries, country_codes, cancellable, error)) {
- g_hash_table_unref (countries);
- return FALSE;
- }
- } else {
- /* First try the user override file. */
- path = g_build_filename (g_get_user_data_dir (), ISO_3166_COUNTRY_CODES, NULL);
- success = read_country_codes (countries, path, cancellable, NULL);
- g_free (path);
-
- /* Look in system locations. */
- for (i = 0; dirs[i] && !success; i++) {
- path = g_build_filename (dirs[i], ISO_3166_COUNTRY_CODES, NULL);
- success = read_country_codes (countries, path, cancellable, NULL);
- g_free (path);
- }
-
- 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);
- }
- }
-
- if (service_providers) {
- if (!read_service_providers (countries, service_providers, cancellable, error)) {
- g_hash_table_unref (countries);
- return FALSE;
- }
- } else {
- /* First try the user override file. */
- path = g_build_filename (g_get_user_data_dir (), MOBILE_BROADBAND_PROVIDER_INFO, NULL);
- success = read_service_providers (countries, path, cancellable, NULL);
- g_free (path);
-
- /* Look in system locations. */
- for (i = 0; dirs[i] && !success; i++) {
- path = g_build_filename (dirs[i], MOBILE_BROADBAND_PROVIDER_INFO, NULL);
- success = read_service_providers (countries, path, cancellable, NULL);
- g_free (path);
- }
-
- 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);
- }
- }
-
- return countries;
-}
-
-/******************************************************************************/
-/* Dump to stdout contents */
-
-static void
-dump_generic (NMAMobileAccessMethod *method)
-{
- g_print (" username: %s\n", method->username ? method->username : "");
- g_print (" password: %s\n", method->password ? method->password : "");
-
- if (method->dns) {
- guint i;
- const gchar **dns;
- GString *dns_str;
-
- dns = nma_mobile_access_method_get_dns (method);
- dns_str = g_string_new (NULL);
- for (i = 0; dns[i]; i++)
- g_string_append_printf (dns_str, "%s%s", i == 0 ? "" : ", ", dns[i]);
- g_print (" dns : %s\n", dns_str->str);
- g_string_free (dns_str, TRUE);
- }
-
- g_print (" gateway : %s\n", method->gateway ? method->gateway : "");
-}
-
-static void
-dump_cdma (NMAMobileAccessMethod *method)
-{
- g_print (" CDMA: %s\n", method->name);
-
- dump_generic (method);
-}
-
-static void
-dump_3gpp (NMAMobileAccessMethod *method)
-{
- g_print (" APN: %s (%s)\n", method->name, method->apn);
-
- dump_generic (method);
-}
-
-static void
-dump_country (gpointer key, gpointer value, gpointer user_data)
-{
- GSList *miter, *citer;
- NMACountryInfo *country_info = value;
-
- g_print ("Country: %s (%s)\n",
- country_info->country_code,
- country_info->country_name);
-
- for (citer = country_info->providers; citer; citer = g_slist_next (citer)) {
- NMAMobileProvider *provider = citer->data;
- const gchar **mcc_mnc;
- const guint *sid;
- guint n;
-
- g_print (" Provider: %s (%s)\n", provider->name, (const char *) key);
-
- mcc_mnc = nma_mobile_provider_get_3gpp_mcc_mnc (provider);
- if (mcc_mnc) {
- for (n = 0; mcc_mnc[n]; n++)
- g_print (" MCC/MNC: %s\n", mcc_mnc[n]);
- }
-
- sid = nma_mobile_provider_get_cdma_sid (provider);
- if (sid) {
- for (n = 0; sid[n]; n++)
- g_print (" SID: %u\n", sid[n]);
- }
-
- for (miter = provider->methods; miter; miter = g_slist_next (miter)) {
- NMAMobileAccessMethod *method = miter->data;
-
- switch (method->family) {
- case NMA_MOBILE_FAMILY_CDMA:
- dump_cdma (method);
- break;
- case NMA_MOBILE_FAMILY_3GPP:
- dump_3gpp (method);
- break;
- default:
- break;
- }
- g_print ("\n");
- }
- }
-}
-
-/******************************************************************************/
-/* Mobile providers database type */
-
-static void initable_iface_init (GInitableIface *iface);
-static void async_initable_iface_init (GAsyncInitableIface *iface);
-
-G_DEFINE_TYPE_EXTENDED (NMAMobileProvidersDatabase, nma_mobile_providers_database, G_TYPE_OBJECT, 0,
- G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, initable_iface_init)
- G_IMPLEMENT_INTERFACE (G_TYPE_ASYNC_INITABLE, async_initable_iface_init))
-
-enum {
- PROP_0,
- PROP_COUNTRY_CODES_PATH,
- PROP_SERVICE_PROVIDERS_PATH,
- PROP_LAST
-};
-
-static GParamSpec *properties[PROP_LAST];
-
-struct _NMAMobileProvidersDatabasePrivate {
- /* Paths to input files */
- gchar *country_codes_path;
- gchar *service_providers_path;
-
- /* The HT with country code as key and NMACountryInfo as value. */
- GHashTable *countries;
-};
-
-/**********************************/
-
-/**
- * nma_mobile_providers_database_get_countries:
- * @self: a #NMAMobileProvidersDatabase.
- *
- * Returns: (element-type utf8 NMACountryInfo) (transfer none): a
- * hash table where keys are country names #gchar and values are #NMACountryInfo.
- */
-GHashTable *
-nma_mobile_providers_database_get_countries (NMAMobileProvidersDatabase *self)
-{
- g_return_val_if_fail (NMA_IS_MOBILE_PROVIDERS_DATABASE (self), NULL);
-
- /* Warn if the object hasn't been initialized */
- g_return_val_if_fail (self->priv->countries != NULL, NULL);
-
- return self->priv->countries;
-}
-
-/**
- * nma_mobile_providers_database_dump:
- * @self: a #NMAMobileProvidersDatabase.
- *
- */
-void
-nma_mobile_providers_database_dump (NMAMobileProvidersDatabase *self)
-{
- g_return_if_fail (NMA_IS_MOBILE_PROVIDERS_DATABASE (self));
-
- /* Warn if the object hasn't been initialized */
- g_return_if_fail (self->priv->countries != NULL);
-
- g_hash_table_foreach (self->priv->countries, dump_country, NULL);
-}
-
-/**
- * nma_mobile_providers_database_lookup_country:
- * @self: a #NMAMobileProvidersDatabase.
- * @country_code: the country code string to look for.
- *
- * Returns: (transfer none): a #NMACountryInfo or %NULL if not found.
- */
-NMACountryInfo *
-nma_mobile_providers_database_lookup_country (NMAMobileProvidersDatabase *self,
- const gchar *country_code)
-{
- g_return_val_if_fail (NMA_IS_MOBILE_PROVIDERS_DATABASE (self), NULL);
-
- /* Warn if the object hasn't been initialized */
- g_return_val_if_fail (self->priv->countries != NULL, NULL);
-
- return (NMACountryInfo *) g_hash_table_lookup (self->priv->countries, country_code);
-}
-
-/**
- * nma_mobile_providers_database_lookup_3gpp_mcc_mnc:
- * @self: a #NMAMobileProvidersDatabase.
- * @mccmnc: the MCC/MNC string to look for.
- *
- * Returns: (transfer none): a #NMAMobileProvider or %NULL if not found.
- */
-NMAMobileProvider *
-nma_mobile_providers_database_lookup_3gpp_mcc_mnc (NMAMobileProvidersDatabase *self,
- const gchar *mccmnc)
-{
- GHashTableIter iter;
- gpointer value;
- GSList *piter;
- NMAMobileProvider *provider_match_2mnc = NULL;
- guint mccmnc_len;
-
- g_return_val_if_fail (NMA_IS_MOBILE_PROVIDERS_DATABASE (self), NULL);
- g_return_val_if_fail (mccmnc != NULL, NULL);
- /* Warn if the object hasn't been initialized */
- g_return_val_if_fail (self->priv->countries != NULL, NULL);
-
- /* Expect only 5 or 6 digit MCCMNC strings */
- mccmnc_len = strlen (mccmnc);
- if (mccmnc_len != 5 && mccmnc_len != 6)
- return NULL;
-
- g_hash_table_iter_init (&iter, self->priv->countries);
- /* Search through each country */
- while (g_hash_table_iter_next (&iter, NULL, &value)) {
- NMACountryInfo *country_info = value;
-
- /* Search through each country's providers */
- for (piter = nma_country_info_get_providers (country_info);
- piter;
- piter = g_slist_next (piter)) {
- NMAMobileProvider *provider = piter->data;
- const gchar **mccmnc_list;
- guint i;
-
- /* Search through MCC/MNC list */
- mccmnc_list = nma_mobile_provider_get_3gpp_mcc_mnc (provider);
- if (!mccmnc_list)
- continue;
-
- for (i = 0; mccmnc_list[i]; i++) {
- const gchar *mccmnc_iter;
- guint mccmnc_iter_len;
-
- mccmnc_iter = mccmnc_list[i];
- mccmnc_iter_len = strlen (mccmnc_iter);
-
- /* Match both 2-digit and 3-digit MNC; prefer a
- * 3-digit match if found, otherwise a 2-digit one.
- */
-
- if (strncmp (mccmnc_iter, mccmnc, 3))
- /* MCC was wrong */
- continue;
-
- /* Now we have the following match cases, examples given:
- * a) input: 123/456 --> iter: 123/456 (3-digit match)
- * b) input: 123/45 --> iter: 123/045 (3-digit match)
- * c) input: 123/045 --> iter: 123/45 (2-digit match)
- * d) input: 123/45 --> iter: 123/45 (2-digit match)
- */
-
- if (mccmnc_iter_len == 6) {
- /* Covers cases a) and b) */
- if ( (mccmnc_len == 6 && !strncmp (mccmnc + 3, mccmnc_iter + 3, 3))
- || (mccmnc_len == 5 && mccmnc_iter[3] == '0' && !strncmp (mccmnc + 3, mccmnc_iter + 4, 2)))
- /* 3-digit MNC match! */
- return provider;
-
- /* MNC was wrong */
- continue;
- }
-
- if ( !provider_match_2mnc
- && mccmnc_iter_len == 5) {
- if ( (mccmnc_len == 5 && !strncmp (mccmnc + 3, mccmnc_iter + 3, 2))
- || (mccmnc_len == 6 && mccmnc[3] == '0' && !strncmp (mccmnc + 4, mccmnc_iter + 3, 2))) {
- /* Store the 2-digit MNC match, but keep looking,
- * we may have a 3-digit MNC match */
- provider_match_2mnc = provider;
- continue;
- }
-
- /* MNC was wrong */
- continue;
- }
- }
- }
- }
-
- return provider_match_2mnc;
-}
-
-/**
- * nma_mobile_providers_database_lookup_cdma_sid:
- * @self: a #NMAMobileProvidersDatabase.
- * @sid: the SID to look for.
- *
- * Returns: (transfer none): a #NMAMobileProvider, or %NULL if not found.
- */
-NMAMobileProvider *
-nma_mobile_providers_database_lookup_cdma_sid (NMAMobileProvidersDatabase *self,
- guint32 sid)
-{
- GHashTableIter iter;
- gpointer value;
- GSList *piter;
-
- g_return_val_if_fail (NMA_IS_MOBILE_PROVIDERS_DATABASE (self), NULL);
- g_return_val_if_fail (sid > 0, NULL);
- /* Warn if the object hasn't been initialized */
- g_return_val_if_fail (self->priv->countries != NULL, NULL);
-
- g_hash_table_iter_init (&iter, self->priv->countries);
- /* Search through each country */
- while (g_hash_table_iter_next (&iter, NULL, &value)) {
- NMACountryInfo *country_info = value;
-
- /* Search through each country's providers */
- for (piter = nma_country_info_get_providers (country_info);
- piter;
- piter = g_slist_next (piter)) {
- NMAMobileProvider *provider = piter->data;
- const guint32 *sid_list;
- guint i;
-
- /* Search through CDMA SID list */
- sid_list = nma_mobile_provider_get_cdma_sid (provider);
- if (!sid_list)
- continue;
-
- for (i = 0; sid_list[i]; i++) {
- if (sid == sid_list[i])
- return provider;
- }
- }
- }
-
- return NULL;
-}
-
-/**********************************/
-
-static gboolean
-initable_init_sync (GInitable *initable,
- GCancellable *cancellable,
- GError **error)
-{
- NMAMobileProvidersDatabase *self = NMA_MOBILE_PROVIDERS_DATABASE (initable);
-
- /* Parse the files */
- self->priv->countries = mobile_providers_parse_sync (self->priv->country_codes_path,
- self->priv->service_providers_path,
- cancellable,
- error);
- if (!self->priv->countries)
- return FALSE;
-
- /* All good */
- return TRUE;
-}
-
-/**********************************/
-
-/**
- * nma_mobile_providers_database_new:
- * @country_codes: (allow-none): Path to the country codes file.
- * @service_providers: (allow-none): Path to the service providers file.
- * @cancellable: (allow-none): A #GCancellable or %NULL.
- * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
- * @user_data: User data to pass to @callback.
- *
- */
-void
-nma_mobile_providers_database_new (const gchar *country_codes,
- const gchar *service_providers,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- g_async_initable_new_async (NMA_TYPE_MOBILE_PROVIDERS_DATABASE,
- G_PRIORITY_DEFAULT,
- cancellable,
- callback,
- user_data,
- "country-codes", country_codes,
- "service-providers", service_providers,
- NULL);
-}
-
-/**
- * nma_mobile_providers_database_new_finish:
- * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to nma_mobile_providers_database_new().
- * @error: Return location for error or %NULL.
- *
- * Returns: (transfer full) (type NMAMobileProvidersDatabase): The constructed object or %NULL if @error is set.
- */
-NMAMobileProvidersDatabase *
-nma_mobile_providers_database_new_finish (GAsyncResult *res,
- GError **error)
-{
- GObject *initable;
- GObject *out;
-
- initable = g_async_result_get_source_object (res);
- out = g_async_initable_new_finish (G_ASYNC_INITABLE (initable), res, error);
- g_object_unref (initable);
-
- return out ? NMA_MOBILE_PROVIDERS_DATABASE (out) : NULL;
-}
-
-/**
- * nma_mobile_providers_database_new_sync:
- * @country_codes: (allow-none): Path to the country codes file.
- * @service_providers: (allow-none): Path to the service providers file.
- * @cancellable: (allow-none): A #GCancellable or %NULL.
- * @error: Return location for error or %NULL.
- *
- * Returns: (transfer full) (type NMAMobileProvidersDatabase): The constructed object or %NULL if @error is set.
- */
-NMAMobileProvidersDatabase *
-nma_mobile_providers_database_new_sync (const gchar *country_codes,
- const gchar *service_providers,
- GCancellable *cancellable,
- GError **error)
-{
- GObject *out;
-
- out = g_initable_new (NMA_TYPE_MOBILE_PROVIDERS_DATABASE,
- cancellable,
- error,
- "country-codes", country_codes,
- "service-providers", service_providers,
- NULL);
-
- return out ? NMA_MOBILE_PROVIDERS_DATABASE (out) : NULL;
-}
-
-/**********************************/
-
-static void
-set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- NMAMobileProvidersDatabase *self = NMA_MOBILE_PROVIDERS_DATABASE (object);
-
- switch (prop_id) {
- case PROP_COUNTRY_CODES_PATH:
- self->priv->country_codes_path = g_value_dup_string (value);
- break;
- case PROP_SERVICE_PROVIDERS_PATH:
- self->priv->service_providers_path = g_value_dup_string (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- NMAMobileProvidersDatabase *self = NMA_MOBILE_PROVIDERS_DATABASE (object);
-
- switch (prop_id) {
- case PROP_COUNTRY_CODES_PATH:
- g_value_set_string (value, self->priv->country_codes_path);
- break;
- case PROP_SERVICE_PROVIDERS_PATH:
- g_value_set_string (value, self->priv->service_providers_path);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nma_mobile_providers_database_init (NMAMobileProvidersDatabase *self)
-{
- /* Setup private data */
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
- NMA_TYPE_MOBILE_PROVIDERS_DATABASE,
- NMAMobileProvidersDatabasePrivate);
-}
-
-static void
-finalize (GObject *object)
-{
- NMAMobileProvidersDatabase *self = NMA_MOBILE_PROVIDERS_DATABASE (object);
-
- g_free (self->priv->country_codes_path);
- g_free (self->priv->service_providers_path);
-
- if (self->priv->countries)
- g_hash_table_unref (self->priv->countries);
-
- G_OBJECT_CLASS (nma_mobile_providers_database_parent_class)->finalize (object);
-}
-
-static void
-initable_iface_init (GInitableIface *iface)
-{
- iface->init = initable_init_sync;
-}
-
-static void
-async_initable_iface_init (GAsyncInitableIface *iface)
-{
- /* Just use defaults (run sync init() in a thread) */
-}
-
-static void
-nma_mobile_providers_database_class_init (NMAMobileProvidersDatabaseClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (object_class, sizeof (NMAMobileProvidersDatabasePrivate));
-
- /* Virtual methods */
- object_class->get_property = get_property;
- object_class->set_property = set_property;
- object_class->finalize = finalize;
-
- properties[PROP_COUNTRY_CODES_PATH] =
- g_param_spec_string ("country-codes",
- "Country Codes",
- "Path to the country codes file",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
- g_object_class_install_property (object_class, PROP_COUNTRY_CODES_PATH, properties[PROP_COUNTRY_CODES_PATH]);
-
- properties[PROP_SERVICE_PROVIDERS_PATH] =
- g_param_spec_string ("service-providers",
- "Service Providers",
- "Path to the service providers file",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
- g_object_class_install_property (object_class, PROP_SERVICE_PROVIDERS_PATH, properties[PROP_SERVICE_PROVIDERS_PATH]);
-}
-
-/******************************************************************************/
-/* Utils */
-
-/**
- * nma_mobile_providers_split_3gpp_mcc_mnc:
- * @mccmnc: input MCCMNC string.
- * @mcc: (out) (transfer full): the MCC.
- * @mnc: (out) (transfer full): the MNC.
- *
- * Splits the input MCCMNC string into separate MCC and MNC strings.
- *
- * Returns: %TRUE if correctly split and @mcc and @mnc are set; %FALSE otherwise.
- */
-gboolean
-nma_mobile_providers_split_3gpp_mcc_mnc (const gchar *mccmnc,
- gchar **mcc,
- gchar **mnc)
-{
- gint len;
-
- g_return_val_if_fail (mccmnc != NULL, FALSE);
- g_return_val_if_fail (mcc != NULL, FALSE);
- g_return_val_if_fail (mnc != NULL, FALSE);
-
- len = strlen (mccmnc);
- if (len != 5 && len != 6)
- return FALSE;
-
- /* MCCMNC is all digits */
- while (len > 0) {
- if (!g_ascii_isdigit (mccmnc[--len]))
- return FALSE;
- }
-
- *mcc = g_strndup (mccmnc, 3);
- *mnc = g_strdup (mccmnc + 3);
- return TRUE;
-}
diff --git a/src/libnma/nma-mobile-providers.h b/src/libnma/nma-mobile-providers.h
deleted file mode 100644
index 913aada8..00000000
--- a/src/libnma/nma-mobile-providers.h
+++ /dev/null
@@ -1,131 +0,0 @@
-// SPDX-License-Identifier: LGPL-2.1+
-/*
- * Copyright (C) 2009 Novell, Inc.
- * Author: Tambet Ingo (tambet@gmail.com).
- *
- * Copyright (C) 2009 - 2012 Red Hat, Inc.
- * Copyright (C) 2012 Lanedo GmbH.
- */
-
-#ifndef NM_MOBILE_PROVIDERS_H
-#define NM_MOBILE_PROVIDERS_H
-
-#include <glib.h>
-#include <glib-object.h>
-#include <gio/gio.h>
-
-/******************************************************************************/
-/* Access method type */
-
-/**
- * NMAMobileFamily:
- * @NMA_MOBILE_FAMILY_UNKNOWN: Unknown or invalid network access method
- * @NMA_MOBILE_FAMILY_3GPP: 3rd Generation Partnership Project (3GPP) network
- * @NMA_MOBILE_FAMILY_CDMA: A CDMA network
- */
-typedef enum {
- NMA_MOBILE_FAMILY_UNKNOWN = 0,
- NMA_MOBILE_FAMILY_3GPP,
- NMA_MOBILE_FAMILY_CDMA
-} NMAMobileFamily;
-
-#define NMA_TYPE_MOBILE_ACCESS_METHOD (nma_mobile_access_method_get_type ())
-
-typedef struct _NMAMobileAccessMethod NMAMobileAccessMethod;
-
-GType nma_mobile_access_method_get_type (void);
-NMAMobileAccessMethod *nma_mobile_access_method_ref (NMAMobileAccessMethod *method);
-void nma_mobile_access_method_unref (NMAMobileAccessMethod *method);
-const gchar *nma_mobile_access_method_get_name (NMAMobileAccessMethod *method);
-const gchar *nma_mobile_access_method_get_username (NMAMobileAccessMethod *method);
-const gchar *nma_mobile_access_method_get_password (NMAMobileAccessMethod *method);
-const gchar *nma_mobile_access_method_get_gateway (NMAMobileAccessMethod *method);
-const gchar **nma_mobile_access_method_get_dns (NMAMobileAccessMethod *method);
-const gchar *nma_mobile_access_method_get_3gpp_apn (NMAMobileAccessMethod *method);
-NMAMobileFamily nma_mobile_access_method_get_family (NMAMobileAccessMethod *method);
-
-/******************************************************************************/
-/* Mobile provider type */
-
-#define NMA_TYPE_MOBILE_PROVIDER (nma_mobile_provider_get_type ())
-
-typedef struct _NMAMobileProvider NMAMobileProvider;
-
-GType nma_mobile_provider_get_type (void);
-NMAMobileProvider *nma_mobile_provider_ref (NMAMobileProvider *provider);
-void nma_mobile_provider_unref (NMAMobileProvider *provider);
-const gchar *nma_mobile_provider_get_name (NMAMobileProvider *provider);
-GSList *nma_mobile_provider_get_methods (NMAMobileProvider *provider);
-const gchar **nma_mobile_provider_get_3gpp_mcc_mnc (NMAMobileProvider *provider);
-const guint32 *nma_mobile_provider_get_cdma_sid (NMAMobileProvider *provider);
-
-/******************************************************************************/
-/* Country Info type */
-
-#define NMA_TYPE_COUNTRY_INFO (nma_country_info_get_type ())
-
-typedef struct _NMACountryInfo NMACountryInfo;
-
-GType nma_country_info_get_type (void);
-NMACountryInfo *nma_country_info_ref (NMACountryInfo *country_info);
-void nma_country_info_unref (NMACountryInfo *country_info);
-const gchar *nma_country_info_get_country_code (NMACountryInfo *country_info);
-const gchar *nma_country_info_get_country_name (NMACountryInfo *country_info);
-GSList *nma_country_info_get_providers (NMACountryInfo *country_info);
-
-/******************************************************************************/
-/* Mobile providers database type */
-
-#define NMA_TYPE_MOBILE_PROVIDERS_DATABASE (nma_mobile_providers_database_get_type ())
-#define NMA_MOBILE_PROVIDERS_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMA_TYPE_MOBILE_PROVIDERS_DATABASE, NMAMobileProvidersDatabase))
-#define NMA_MOBILE_PROVIDERS_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMA_TYPE_MOBILE_PROVIDERS_DATABASE, NMAMobileProvidersDatabaseClass))
-#define NMA_IS_MOBILE_PROVIDERS_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMA_TYPE_MOBILE_PROVIDERS_DATABASE))
-#define NMA_IS_MOBILE_PROVIDERS_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMA_TYPE_MOBILE_PROVIDERS_DATABASE))
-#define NMA_MOBILE_PROVIDERS_DATABASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMA_TYPE_MOBILE_PROVIDERS_DATABASE, NMAMobileProvidersDatabaseClass))
-
-typedef struct _NMAMobileProvidersDatabase NMAMobileProvidersDatabase;
-typedef struct _NMAMobileProvidersDatabaseClass NMAMobileProvidersDatabaseClass;
-typedef struct _NMAMobileProvidersDatabasePrivate NMAMobileProvidersDatabasePrivate;
-
-struct _NMAMobileProvidersDatabase {
- GObject parent;
- NMAMobileProvidersDatabasePrivate *priv;
-};
-
-struct _NMAMobileProvidersDatabaseClass {
- GObjectClass parent;
-};
-
-GType nma_mobile_providers_database_get_type (void);
-
-void nma_mobile_providers_database_new (const gchar *country_codes,
- const gchar *service_providers,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-NMAMobileProvidersDatabase *nma_mobile_providers_database_new_finish (GAsyncResult *res,
- GError **error);
-NMAMobileProvidersDatabase *nma_mobile_providers_database_new_sync (const gchar *country_codes,
- const gchar *service_providers,
- GCancellable *cancellable,
- GError **error);
-
-GHashTable *nma_mobile_providers_database_get_countries (NMAMobileProvidersDatabase *self);
-
-void nma_mobile_providers_database_dump (NMAMobileProvidersDatabase *self);
-
-NMACountryInfo *nma_mobile_providers_database_lookup_country (NMAMobileProvidersDatabase *self,
- const gchar *country_code);
-NMAMobileProvider *nma_mobile_providers_database_lookup_3gpp_mcc_mnc (NMAMobileProvidersDatabase *self,
- const gchar *mccmnc);
-NMAMobileProvider *nma_mobile_providers_database_lookup_cdma_sid (NMAMobileProvidersDatabase *self,
- guint32 sid);
-
-/******************************************************************************/
-/* Utils */
-
-gboolean nma_mobile_providers_split_3gpp_mcc_mnc (const gchar *mccmnc,
- gchar **mcc,
- gchar **mnc);
-
-#endif /* NM_MOBILE_PROVIDERS_H */
diff --git a/src/libnma/nma-mobile-wizard.c b/src/libnma/nma-mobile-wizard.c
deleted file mode 100644
index 9a4e753b..00000000
--- a/src/libnma/nma-mobile-wizard.c
+++ /dev/null
@@ -1,1560 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/* NetworkManager Connection editor -- Connection editor for NetworkManager
- *
- * Dan Williams <dcbw@redhat.com>
- * Lubomir Rintel <lkundrak@v3.sk>
- *
- * (C) Copyright 2008 - 2018 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-#include "nma-private.h"
-
-#include <stdlib.h>
-
-#if GTK_CHECK_VERSION(3,90,0)
-#include <gdk/x11/gdkx.h>
-#else
-#include <gdk/gdkx.h>
-#endif
-
-#include <NetworkManager.h>
-#include <nm-setting-gsm.h>
-#include <nm-setting-cdma.h>
-#include <nm-client.h>
-#include <nm-device-modem.h>
-
-#include "nma-mobile-wizard.h"
-#include "nma-mobile-providers.h"
-#include "utils.h"
-
-#define DEVICE_TAG "device"
-#define TYPE_TAG "setting-type"
-
-#define INTRO_PAGE_IDX 0
-#define COUNTRY_PAGE_IDX 1
-#define PROVIDERS_PAGE_IDX 2
-#define PLAN_PAGE_IDX 3
-#define CONFIRM_PAGE_IDX 4
-
-static NMACountryInfo *get_selected_country (NMAMobileWizard *self);
-static NMAMobileProvider *get_selected_provider (NMAMobileWizard *self);
-static NMAMobileFamily get_provider_unlisted_type (NMAMobileWizard *self);
-static NMAMobileAccessMethod *get_selected_method (NMAMobileWizard *self, gboolean *manual);
-
-#include "nm-default.h"
-
-struct _NMAMobileWizard {
- GtkAssistant parent;
-};
-
-struct _NMAMobileWizardClass {
- GtkAssistantClass parent;
-};
-
-typedef struct {
- NMAMobileWizardCallback callback;
- gpointer user_data;
- NMAMobileProvidersDatabase *mobile_providers_database;
- NMAMobileFamily family;
- gboolean initial_family;
- gboolean will_connect_after;
-
- /* Intro page */
- GtkLabel *dev_combo_label;
- GtkComboBox *dev_combo;
- GtkLabel *provider_name_label;
- GtkLabel *plan_name_label;
- GtkLabel *apn_label;
- GtkTreeStore *dev_store;
- char *dev_desc;
- NMClient *client;
-
- /* Country page */
- NMACountryInfo *country;
- GtkWidget *country_page;
- GtkTreeView *country_view;
- GtkTreeStore *country_store;
- GtkTreeModelSort *country_sort;
- guint32 country_focus_id;
-
- /* Providers page */
- GtkWidget *providers_page;
- GtkTreeView *providers_view;
- GtkTreeStore *providers_store;
- GtkTreeModel *providers_sort;
- guint32 providers_focus_id;
- GtkToggleButton *providers_view_radio;
-
- GtkToggleButton *provider_unlisted_radio;
- GtkComboBox *provider_unlisted_type_combo;
-
- gboolean provider_only_cdma;
-
- /* Plan page */
- GtkWidget *plan_page;
- GtkComboBox *plan_combo;
- GtkTreeStore *plan_store;
- guint32 plan_focus_id;
-
- GtkEditable *plan_apn_entry;
-
- /* Confirm page */
- GtkWidget *confirm_page;
- GtkLabel *confirm_provider;
- GtkLabel *confirm_plan;
- GtkLabel *confirm_apn;
- GtkLabel *confirm_plan_label;
- GtkLabel *confirm_device;
- GtkLabel *confirm_device_label;
- GtkWidget *confirm_connect_after_label;
-} NMAMobileWizardPrivate;
-
-#define NMA_MOBILE_WIZARD_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
- NMA_TYPE_MOBILE_WIZARD, \
- NMAMobileWizardPrivate))
-
-G_DEFINE_TYPE_WITH_CODE (NMAMobileWizard, nma_mobile_wizard, GTK_TYPE_ASSISTANT,
- G_ADD_PRIVATE (NMAMobileWizard))
-
-static void
-assistant_closed (GtkButton *button, gpointer user_data)
-{
- NMAMobileWizard *self = NMA_MOBILE_WIZARD (user_data);
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
- NMAMobileProvider *provider;
- NMAMobileAccessMethod *method;
- NMAMobileWizardAccessMethod *wiz_method;
- NMAMobileFamily family = priv->family;
-
- wiz_method = g_malloc0 (sizeof (NMAMobileWizardAccessMethod));
-
- provider = get_selected_provider (self);
- if (!provider) {
- if (family == NMA_MOBILE_FAMILY_UNKNOWN)
- family = get_provider_unlisted_type (self);
-
- switch (family) {
- case NMA_MOBILE_FAMILY_3GPP:
- wiz_method->provider_name = g_strdup (_("GSM"));
- break;
- case NMA_MOBILE_FAMILY_CDMA:
- wiz_method->provider_name = g_strdup (_("CDMA"));
- break;
- case NMA_MOBILE_FAMILY_UNKNOWN:
- g_return_if_reached ();
- break;
- }
- } else {
- gboolean manual = FALSE;
-
- wiz_method->provider_name = g_strdup (nma_mobile_provider_get_name (provider));
- method = get_selected_method (self, &manual);
- if (method) {
- family = nma_mobile_access_method_get_family (method);
- wiz_method->plan_name = g_strdup (nma_mobile_access_method_get_name (method));
- wiz_method->username = g_strdup (nma_mobile_access_method_get_username (method));
- wiz_method->password = g_strdup (nma_mobile_access_method_get_password (method));
- if (family == NMA_MOBILE_FAMILY_3GPP)
- wiz_method->gsm_apn = g_strdup (nma_mobile_access_method_get_3gpp_apn (method));
- } else {
- if (priv->provider_only_cdma) {
- GSList *methods;
-
- family = NMA_MOBILE_FAMILY_CDMA;
-
- methods = nma_mobile_provider_get_methods (provider);
- /* Take username and password from the first (only) method for CDMA only provider */
- if (methods) {
- method = methods->data;
- wiz_method->username = g_strdup (nma_mobile_access_method_get_username (method));
- wiz_method->password = g_strdup (nma_mobile_access_method_get_password (method));
- }
- } else {
- family = NMA_MOBILE_FAMILY_3GPP;
- wiz_method->gsm_apn = g_strdup (gtk_editable_get_text (priv->plan_apn_entry));
- }
- }
- }
-
- switch (family) {
- case NMA_MOBILE_FAMILY_3GPP:
- wiz_method->devtype = NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS;
- break;
- case NMA_MOBILE_FAMILY_CDMA:
- wiz_method->devtype = NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO;
- break;
- default:
- g_return_if_reached ();
- break;
- }
-
- (*(priv->callback)) (self, FALSE, wiz_method, priv->user_data);
-
- if (provider)
- nma_mobile_provider_unref (provider);
- g_free (wiz_method->provider_name);
- g_free (wiz_method->plan_name);
- g_free (wiz_method->username);
- g_free (wiz_method->password);
- g_free (wiz_method->gsm_apn);
- g_free (wiz_method);
-}
-
-static void
-assistant_cancel (GtkButton *button, gpointer user_data)
-{
- NMAMobileWizard *self = user_data;
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
-
- (*(priv->callback)) (self, TRUE, NULL, priv->user_data);
-}
-
-/**********************************************************/
-/* Confirm page */
-/**********************************************************/
-
-static void
-confirm_setup (NMAMobileWizard *self)
-{
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
-
- if (priv->will_connect_after)
- gtk_widget_show (priv->confirm_connect_after_label);
-}
-
-static void
-confirm_prepare (NMAMobileWizard *self)
-{
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
- NMAMobileProvider *provider = NULL;
- NMAMobileAccessMethod *method = NULL;
- const char *apn = NULL;
- NMACountryInfo *country_info;
- gboolean manual = FALSE;
- GString *str;
-
- provider = get_selected_provider (self);
- if (provider)
- method = get_selected_method (self, &manual);
-
- /* Provider */
- str = g_string_new (NULL);
- if (provider) {
- g_string_append (str, nma_mobile_provider_get_name (provider));
- nma_mobile_provider_unref (provider);
- } else {
- g_string_append (str, _("Unlisted"));
- }
-
- country_info = get_selected_country (self);
- if (nma_country_info_get_country_code (country_info))
- g_string_append_printf (str, ", %s", nma_country_info_get_country_name (country_info));
- nma_country_info_unref (country_info);
-
- gtk_label_set_text (priv->confirm_provider, str->str);
- gtk_widget_show (GTK_WIDGET (priv->confirm_provider));
- g_string_free (str, TRUE);
-
- if (priv->dev_desc) {
- gtk_label_set_text (priv->confirm_device, priv->dev_desc);
- gtk_widget_show (GTK_WIDGET (priv->confirm_device_label));
- gtk_widget_show (GTK_WIDGET (priv->confirm_device));
- } else {
- gtk_widget_hide (GTK_WIDGET (priv->confirm_device_label));
- gtk_widget_hide (GTK_WIDGET (priv->confirm_device));
- }
-
- if (priv->provider_only_cdma) {
- gtk_widget_hide (GTK_WIDGET (priv->confirm_plan_label));
- gtk_widget_hide (GTK_WIDGET (priv->confirm_plan));
- } else {
- /* Plan */
- gtk_widget_show (GTK_WIDGET (priv->confirm_plan_label));
- gtk_widget_show (GTK_WIDGET (priv->confirm_plan));
-
- if (method)
- gtk_label_set_text (priv->confirm_plan, nma_mobile_access_method_get_name (method));
- else
- gtk_label_set_text (priv->confirm_plan, _("Unlisted"));
-
- apn = gtk_editable_get_text (priv->plan_apn_entry);
- }
-
- if (apn) {
- str = g_string_new (NULL);
- g_string_append_printf (str, "<span color=\"#999999\">APN: %s</span>", apn);
- gtk_label_set_markup (priv->confirm_apn, str->str);
- g_string_free (str, TRUE);
- gtk_widget_show (GTK_WIDGET (priv->confirm_apn));
- } else {
- gtk_widget_hide (GTK_WIDGET (priv->confirm_apn));
- }
-}
-
-/**********************************************************/
-/* Plan page */
-/**********************************************************/
-
-#define PLAN_COL_NAME 0
-#define PLAN_COL_METHOD 1
-#define PLAN_COL_MANUAL 2
-
-static NMAMobileAccessMethod *
-get_selected_method (NMAMobileWizard *self, gboolean *manual)
-{
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
- GtkTreeModel *model;
- NMAMobileAccessMethod *method = NULL;
- GtkTreeIter iter;
- gboolean is_manual = FALSE;
-
- if (!gtk_combo_box_get_active_iter (priv->plan_combo, &iter))
- return NULL;
-
- model = gtk_combo_box_get_model (priv->plan_combo);
- if (!model)
- return NULL;
-
- gtk_tree_model_get (model, &iter,
- PLAN_COL_METHOD, &method,
- PLAN_COL_MANUAL, &is_manual,
- -1);
- if (is_manual) {
- if (manual)
- *manual = is_manual;
- if (method)
- nma_mobile_access_method_unref (method);
- method = NULL;
- }
-
- return method;
-}
-
-static void
-plan_update_complete (NMAMobileWizard *self)
-{
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
- GtkAssistant *assistant = GTK_ASSISTANT (self);
- gboolean is_manual = FALSE;
- NMAMobileAccessMethod *method;
-
- method = get_selected_method (self, &is_manual);
- if (method) {
- gtk_assistant_set_page_complete (assistant, priv->plan_page, TRUE);
- nma_mobile_access_method_unref (method);
- } else {
- const char *manual_apn;
-
- manual_apn = gtk_editable_get_text (priv->plan_apn_entry);
- gtk_assistant_set_page_complete (assistant, priv->plan_page,
- (manual_apn && strlen (manual_apn)));
- }
-}
-
-static void
-plan_combo_changed (NMAMobileWizard *self)
-{
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
- NMAMobileAccessMethod *method = NULL;
- gboolean is_manual = FALSE;
-
- method = get_selected_method (self, &is_manual);
- if (method) {
- gtk_editable_set_text (priv->plan_apn_entry, nma_mobile_access_method_get_3gpp_apn (method));
- gtk_widget_set_sensitive (GTK_WIDGET (priv->plan_apn_entry), FALSE);
- } else {
- gtk_editable_set_text (priv->plan_apn_entry, "");
- gtk_widget_set_sensitive (GTK_WIDGET (priv->plan_apn_entry), TRUE);
- gtk_widget_grab_focus (GTK_WIDGET (priv->plan_apn_entry));
- }
-
- if (method)
- nma_mobile_access_method_unref (method);
-
- plan_update_complete (self);
-}
-
-static gboolean
-plan_row_separator_func (GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
-{
- NMAMobileAccessMethod *method = NULL;
- gboolean is_manual = FALSE;
- gboolean draw_separator = FALSE;
-
- gtk_tree_model_get (model, iter,
- PLAN_COL_METHOD, &method,
- PLAN_COL_MANUAL, &is_manual,
- -1);
- if (!method && !is_manual)
- draw_separator = TRUE;
- if (method)
- nma_mobile_access_method_unref (method);
- return draw_separator;
-}
-
-static void
-apn_filter_cb (GtkEditable *editable,
- gchar *text,
- gint length,
- gint *position,
- gpointer user_data)
-{
- utils_filter_editable_on_insert_text (editable,
- text, length, position, user_data,
- utils_char_is_ascii_apn,
- apn_filter_cb);
-}
-
-static void
-plan_setup (NMAMobileWizard *self)
-{
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
- GtkCellRenderer *renderer;
-
- gtk_combo_box_set_row_separator_func (priv->plan_combo,
- plan_row_separator_func,
- NULL,
- NULL);
-
- renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (priv->plan_combo), renderer, TRUE);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (priv->plan_combo), renderer, "text", PLAN_COL_NAME);
-}
-
-static gboolean
-focus_plan_apn_entry (gpointer user_data)
-{
- NMAMobileWizard *self = user_data;
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
-
- priv->plan_focus_id = 0;
- gtk_widget_grab_focus (GTK_WIDGET (priv->plan_apn_entry));
- return FALSE;
-}
-
-static void
-plan_prepare (NMAMobileWizard *self)
-{
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
- NMAMobileProvider *provider;
- GtkTreeIter method_iter;
- guint32 count = 0;
-
- gtk_tree_store_clear (priv->plan_store);
-
- provider = get_selected_provider (self);
- if (provider) {
- GSList *iter;
-
- for (iter = nma_mobile_provider_get_methods (provider); iter; iter = g_slist_next (iter)) {
- NMAMobileAccessMethod *method = iter->data;
-
- if ( (priv->family != NMA_MOBILE_FAMILY_UNKNOWN)
- && (nma_mobile_access_method_get_family (method) != priv->family))
- continue;
-
- gtk_tree_store_append (priv->plan_store, &method_iter, NULL);
- gtk_tree_store_set (priv->plan_store,
- &method_iter,
- PLAN_COL_NAME,
- nma_mobile_access_method_get_name (method),
- PLAN_COL_METHOD,
- method,
- -1);
- count++;
- }
- nma_mobile_provider_unref (provider);
-
- /* Draw the separator */
- if (count)
- gtk_tree_store_append (priv->plan_store, &method_iter, NULL);
- }
-
- /* Add the "My plan is not listed..." item */
- gtk_tree_store_append (priv->plan_store, &method_iter, NULL);
- gtk_tree_store_set (priv->plan_store,
- &method_iter,
- PLAN_COL_NAME,
- _("My plan is not listed…"),
- PLAN_COL_MANUAL,
- TRUE,
- -1);
- /* Select the first item by default if nothing is yet selected */
- if (gtk_combo_box_get_active (priv->plan_combo) < 0)
- gtk_combo_box_set_active (priv->plan_combo, 0);
-
- gtk_widget_set_sensitive (GTK_WIDGET (priv->plan_combo), count > 0);
- if (count == 0) {
- if (!priv->plan_focus_id)
- priv->plan_focus_id = g_idle_add (focus_plan_apn_entry, self);
- }
-
- plan_combo_changed (self);
-}
-
-/**********************************************************/
-/* Providers page */
-/**********************************************************/
-
-#define PROVIDER_COL_NAME 0
-#define PROVIDER_COL_PROVIDER 1
-
-static gboolean
-providers_search_func (GtkTreeModel *model,
- gint column,
- const char *key,
- GtkTreeIter *iter,
- gpointer search_data)
-{
- gboolean unmatched = TRUE;
- char *provider = NULL;
-
- if (!key)
- return TRUE;
-
- gtk_tree_model_get (model, iter, column, &provider, -1);
- if (!provider)
- return TRUE;
-
- unmatched = !!g_ascii_strncasecmp (provider, key, strlen (key));
- g_free (provider);
- return unmatched;
-}
-
-static NMAMobileProvider *
-get_selected_provider (NMAMobileWizard *self)
-{
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
- GtkTreeSelection *selection;
- GtkTreeModel *model = NULL;
- GtkTreeIter iter;
- NMAMobileProvider *provider = NULL;
-
- if (!gtk_toggle_button_get_active (priv->providers_view_radio))
- return NULL;
-
- selection = gtk_tree_view_get_selection (priv->providers_view);
- g_assert (selection);
-
- if (!gtk_tree_selection_get_selected (GTK_TREE_SELECTION (selection), &model, &iter))
- return NULL;
-
- gtk_tree_model_get (model, &iter, PROVIDER_COL_PROVIDER, &provider, -1);
- return provider;
-}
-
-static void
-providers_update_complete (NMAMobileWizard *self)
-{
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
- GtkAssistant *assistant = GTK_ASSISTANT (self);
- gboolean use_view;
-
- use_view = gtk_toggle_button_get_active (priv->providers_view_radio);
- if (use_view) {
- NMAMobileProvider *provider;
-
- provider = get_selected_provider (self);
- gtk_assistant_set_page_complete (assistant, priv->providers_page, !!provider);
- if (provider)
- nma_mobile_provider_unref (provider);
- } else {
- gtk_assistant_set_page_complete (assistant, priv->providers_page, TRUE);
- }
-}
-
-static void
-providers_update_continue (NMAMobileWizard *self)
-{
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
-
- gtk_assistant_set_page_complete (GTK_ASSISTANT (self),
- priv->providers_page,
- TRUE);
-
- gtk_assistant_next_page (GTK_ASSISTANT (self));
-}
-
-static gboolean
-focus_providers_view (gpointer user_data)
-{
- NMAMobileWizard *self = user_data;
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
-
- priv->providers_focus_id = 0;
- gtk_widget_grab_focus (GTK_WIDGET (priv->providers_view));
- return FALSE;
-}
-
-static gboolean
-focus_provider_unlisted_type_combo (gpointer user_data)
-{
- NMAMobileWizard *self = user_data;
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
-
- priv->providers_focus_id = 0;
- gtk_widget_grab_focus (GTK_WIDGET (priv->provider_unlisted_type_combo));
- return FALSE;
-}
-
-static void
-providers_radio_toggled (GtkToggleButton *button, gpointer user_data)
-{
- NMAMobileWizard *self = user_data;
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
- gboolean use_view;
-
- use_view = gtk_toggle_button_get_active (priv->providers_view_radio);
- if (use_view) {
- if (!priv->providers_focus_id)
- priv->providers_focus_id = g_idle_add (focus_providers_view, self);
- gtk_widget_set_sensitive (GTK_WIDGET (priv->providers_view), TRUE);
- gtk_widget_set_sensitive (GTK_WIDGET (priv->provider_unlisted_type_combo), FALSE);
- } else if (priv->family == NMA_MOBILE_FAMILY_UNKNOWN) {
- if (!priv->providers_focus_id)
- priv->providers_focus_id = g_idle_add (focus_provider_unlisted_type_combo, self);
- gtk_widget_set_sensitive (GTK_WIDGET (priv->providers_view), FALSE);
- gtk_widget_set_sensitive (GTK_WIDGET (priv->provider_unlisted_type_combo), TRUE);
- }
-
- providers_update_complete (self);
-}
-
-static NMAMobileFamily
-get_provider_unlisted_type (NMAMobileWizard *self)
-{
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
-
- switch (gtk_combo_box_get_active (priv->provider_unlisted_type_combo)) {
- case 0:
- return NMA_MOBILE_FAMILY_3GPP;
- case 1:
- return NMA_MOBILE_FAMILY_CDMA;
- default:
- g_return_val_if_reached (NMA_MOBILE_FAMILY_UNKNOWN);
- }
-}
-
-static void
-providers_setup (NMAMobileWizard *self)
-{
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
- GtkTreeSelection *selection;
-
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (priv->providers_sort),
- PROVIDER_COL_NAME, GTK_SORT_ASCENDING);
-
- renderer = gtk_cell_renderer_text_new ();
- column = gtk_tree_view_column_new_with_attributes (_("Provider"),
- renderer,
- "text", PROVIDER_COL_NAME,
- NULL);
- gtk_tree_view_append_column (priv->providers_view, column);
- gtk_tree_view_column_set_clickable (column, TRUE);
-
- selection = gtk_tree_view_get_selection (priv->providers_view);
- g_assert (selection);
-
- switch (priv->family) {
- case NMA_MOBILE_FAMILY_3GPP:
- gtk_combo_box_set_active (priv->provider_unlisted_type_combo, 0);
- gtk_widget_set_sensitive (GTK_WIDGET (priv->provider_unlisted_type_combo), FALSE);
- break;
- case NMA_MOBILE_FAMILY_CDMA:
- gtk_combo_box_set_active (priv->provider_unlisted_type_combo, 1);
- gtk_widget_set_sensitive (GTK_WIDGET (priv->provider_unlisted_type_combo), FALSE);
- break;
- case NMA_MOBILE_FAMILY_UNKNOWN:
- gtk_widget_set_sensitive (GTK_WIDGET (priv->provider_unlisted_type_combo), TRUE);
- break;
- }
-}
-
-static void
-providers_prepare (NMAMobileWizard *self)
-{
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
- GtkTreeSelection *selection;
- NMACountryInfo *country_info;
- GSList *piter;
-
- gtk_tree_store_clear (priv->providers_store);
-
- country_info = get_selected_country (self);
- for (piter = nma_country_info_get_providers (country_info);
- piter;
- piter = g_slist_next (piter)) {
- NMAMobileProvider *provider = piter->data;
- GtkTreeIter provider_iter;
-
- /* Ignore providers that don't match the current device type */
- if (priv->family != NMA_MOBILE_FAMILY_UNKNOWN) {
- GSList *miter;
- guint32 count = 0;
-
- for (miter = nma_mobile_provider_get_methods (provider); miter; miter = g_slist_next (miter)) {
- NMAMobileAccessMethod *method = miter->data;
-
- if (priv->family == nma_mobile_access_method_get_family (method))
- count++;
- }
-
- if (!count)
- continue;
- }
-
- gtk_tree_store_append (priv->providers_store, &provider_iter, NULL);
- gtk_tree_store_set (priv->providers_store,
- &provider_iter,
- PROVIDER_COL_NAME,
- nma_mobile_provider_get_name (provider),
- PROVIDER_COL_PROVIDER,
- provider,
- -1);
- }
- nma_country_info_unref (country_info);
-
- gtk_tree_view_set_search_column (priv->providers_view, PROVIDER_COL_NAME);
- gtk_tree_view_set_search_equal_func (priv->providers_view,
- providers_search_func, self, NULL);
-
- /* If no row has focus yet, focus the first row so that the user can start
- * incremental search without clicking.
- */
- selection = gtk_tree_view_get_selection (priv->providers_view);
- g_assert (selection);
- if (!gtk_tree_selection_count_selected_rows (selection)) {
- GtkTreeIter first_iter;
- GtkTreePath *first_path;
-
- if (gtk_tree_model_get_iter_first (priv->providers_sort, &first_iter)) {
- first_path = gtk_tree_model_get_path (priv->providers_sort, &first_iter);
- if (first_path) {
- gtk_tree_selection_select_path (selection, first_path);
- gtk_tree_path_free (first_path);
- }
- }
- }
-
- if (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (priv->providers_store), NULL) == 0) {
- /* No providers to choose from. */
- gtk_toggle_button_set_active (priv->provider_unlisted_radio, TRUE);
- gtk_widget_set_sensitive (GTK_WIDGET (priv->providers_view_radio), FALSE);
- } else {
- gtk_toggle_button_set_active (priv->providers_view_radio, TRUE);
- gtk_widget_set_sensitive (GTK_WIDGET (priv->providers_view_radio), TRUE);
- }
-
- providers_radio_toggled (NULL, self);
-
- /* Initial completeness state */
- providers_update_complete (self);
-}
-
-/**********************************************************/
-/* Country page */
-/**********************************************************/
-
-#define COUNTRIES_COL_NAME 0
-#define COUNTRIES_COL_INFO 1
-
-static gboolean
-country_search_func (GtkTreeModel *model,
- gint column,
- const char *key,
- GtkTreeIter *iter,
- gpointer search_data)
-{
- gboolean unmatched = TRUE;
- char *country = NULL;
-
- if (!key)
- return TRUE;
-
- gtk_tree_model_get (model, iter, column, &country, -1);
- if (!country)
- return TRUE;
-
- unmatched = !!g_ascii_strncasecmp (country, key, strlen (key));
- g_free (country);
- return unmatched;
-}
-
-static void
-add_one_country (gpointer key, gpointer value, gpointer user_data)
-{
- NMAMobileWizard *self = user_data;
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
- NMACountryInfo *country_info = value;
- GtkTreeIter country_iter;
- GtkTreePath *country_path, *country_view_path;
-
- g_assert (key);
-
- if ( nma_country_info_get_country_code (country_info)
- && !nma_country_info_get_providers (country_info))
- return;
-
- gtk_tree_store_append (priv->country_store, &country_iter, NULL);
- gtk_tree_store_set (priv->country_store,
- &country_iter,
- COUNTRIES_COL_NAME,
- nma_country_info_get_country_name (country_info),
- COUNTRIES_COL_INFO,
- country_info,
- -1);
-
- /* If this country is the same country as the user's current locale,
- * select it by default.
- */
- if (priv->country != country_info)
- return;
-
- country_path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->country_store), &country_iter);
- if (!country_path)
- return;
-
- country_view_path = gtk_tree_model_sort_convert_child_path_to_path (priv->country_sort, country_path);
- if (country_view_path) {
- GtkTreeSelection *selection;
-
- gtk_tree_view_expand_row (priv->country_view, country_view_path, TRUE);
-
- selection = gtk_tree_view_get_selection (priv->country_view);
- g_assert (selection);
- gtk_tree_selection_select_path (selection, country_view_path);
- gtk_tree_view_scroll_to_cell (priv->country_view,
- country_view_path, NULL, TRUE, 0, 0);
- gtk_tree_path_free (country_view_path);
- }
- gtk_tree_path_free (country_path);
-}
-
-static NMACountryInfo *
-get_selected_country (NMAMobileWizard *self)
-{
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
- GtkTreeSelection *selection;
- GtkTreeModel *model = NULL;
- GtkTreeIter iter;
- NMACountryInfo *country_info = NULL;
-
- selection = gtk_tree_view_get_selection (priv->country_view);
- g_assert (selection);
-
- if (!gtk_tree_selection_get_selected (GTK_TREE_SELECTION (selection), &model, &iter))
- return NULL;
-
- gtk_tree_model_get (model, &iter, COUNTRIES_COL_INFO, &country_info, -1);
- return country_info;
-}
-
-static void
-country_update_complete (NMAMobileWizard *self)
-{
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
- GtkTreeSelection *selection;
-
- selection = gtk_tree_view_get_selection (priv->country_view);
- g_assert (selection);
-
- gtk_assistant_set_page_complete (GTK_ASSISTANT (self),
- priv->country_page,
- gtk_tree_selection_get_selected (selection, NULL, NULL));
-}
-
-static void
-country_update_continue (NMAMobileWizard *self)
-{
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
-
- gtk_assistant_set_page_complete (GTK_ASSISTANT (self),
- priv->country_page,
- TRUE);
-
- gtk_assistant_next_page (GTK_ASSISTANT (self));
-}
-
-static gint
-country_sort_func (GtkTreeModel *model,
- GtkTreeIter *a,
- GtkTreeIter *b,
- gpointer user_data)
-{
- char *a_str = NULL, *b_str = NULL;
- NMACountryInfo *a_country_info = NULL, *b_country_info = NULL;
- gint ret = 0;
-
- gtk_tree_model_get (model, a, COUNTRIES_COL_NAME, &a_str, COUNTRIES_COL_INFO, &a_country_info, -1);
- gtk_tree_model_get (model, b, COUNTRIES_COL_NAME, &b_str, COUNTRIES_COL_INFO, &b_country_info, -1);
-
- if (!a_country_info || !nma_country_info_get_country_code (a_country_info)) {
- ret = -1;
- goto out;
- } else if (!b_country_info || !nma_country_info_get_country_code (b_country_info)) {
- ret = 1;
- goto out;
- }
-
- if (a_str && !b_str)
- ret = -1;
- else if (!a_str && b_str)
- ret = 1;
- else if (!a_str && !b_str)
- ret = 0;
- else
- ret = g_utf8_collate (a_str, b_str);
-
-out:
- if (a_country_info)
- nma_country_info_unref (a_country_info);
- if (b_country_info)
- nma_country_info_unref (b_country_info);
- g_free (a_str);
- g_free (b_str);
- return ret;
-}
-
-static void
-country_setup (NMAMobileWizard *self)
-{
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
- GtkTreeSelection *selection;
-
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (priv->country_sort),
- COUNTRIES_COL_NAME, GTK_SORT_ASCENDING);
-
- gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (priv->country_sort),
- COUNTRIES_COL_NAME,
- country_sort_func,
- NULL,
- NULL);
-
- renderer = gtk_cell_renderer_text_new ();
- column = gtk_tree_view_column_new_with_attributes (NULL,
- renderer,
- "text", COUNTRIES_COL_NAME,
- NULL);
- gtk_tree_view_append_column (priv->country_view, column);
- gtk_tree_view_column_set_clickable (column, TRUE);
-
- /* Add the rest of the providers */
- if (priv->mobile_providers_database) {
- GHashTable *countries;
-
- countries = nma_mobile_providers_database_get_countries (priv->mobile_providers_database);
- g_hash_table_foreach (countries, add_one_country, self);
- }
-
- /* If no row has focus yet, focus the first row so that the user can start
- * incremental search without clicking.
- */
- selection = gtk_tree_view_get_selection (priv->country_view);
- g_assert (selection);
- if (!gtk_tree_selection_count_selected_rows (selection)) {
- GtkTreeIter first_iter;
- GtkTreePath *first_path;
-
- if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->country_sort), &first_iter)) {
- first_path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->country_sort), &first_iter);
- if (first_path) {
- gtk_tree_selection_select_path (selection, first_path);
- gtk_tree_path_free (first_path);
- }
- }
- }
-
- /* Initial completeness state */
- country_update_complete (self);
-}
-
-static gboolean
-focus_country_view (gpointer user_data)
-{
- NMAMobileWizard *self = user_data;
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
-
- priv->country_focus_id = 0;
- gtk_widget_grab_focus (GTK_WIDGET (priv->country_view));
- return FALSE;
-}
-
-static void
-country_prepare (NMAMobileWizard *self)
-{
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
-
- gtk_tree_view_set_search_column (priv->country_view, COUNTRIES_COL_NAME);
- gtk_tree_view_set_search_equal_func (priv->country_view, country_search_func, self, NULL);
-
- if (!priv->country_focus_id)
- priv->country_focus_id = g_idle_add (focus_country_view, self);
-
- country_update_complete (self);
-}
-
-/**********************************************************/
-/* Intro page */
-/**********************************************************/
-
-#define INTRO_COL_NAME 0
-#define INTRO_COL_DEVICE 1
-#define INTRO_COL_SEPARATOR 2
-
-static gboolean
-__intro_device_added (NMAMobileWizard *self, NMDevice *device, gboolean select_it)
-{
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
- GtkTreeIter iter;
- const char *desc = nm_device_get_description (device);
- NMDeviceModemCapabilities caps;
-
- if (!NM_IS_DEVICE_MODEM (device))
- return FALSE;
-
- caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device));
- if (caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) {
- if (!desc)
- desc = _("Installed GSM device");
- } else if (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO) {
- if (!desc)
- desc = _("Installed CDMA device");
- } else
- return FALSE;
-
- gtk_tree_store_append (priv->dev_store, &iter, NULL);
- gtk_tree_store_set (priv->dev_store,
- &iter,
- INTRO_COL_NAME, desc,
- INTRO_COL_DEVICE, device,
- -1);
-
- /* Select the device just added */
- if (select_it)
- gtk_combo_box_set_active_iter (priv->dev_combo, &iter);
-
- gtk_widget_set_sensitive (GTK_WIDGET (priv->dev_combo), TRUE);
- return TRUE;
-}
-
-static void
-intro_device_added_cb (NMClient *client, NMDevice *device, NMAMobileWizard *self)
-{
- __intro_device_added (self, device, TRUE);
-}
-
-static void
-intro_device_removed_cb (NMClient *client, NMDevice *device, NMAMobileWizard *self)
-{
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
- GtkTreeIter iter;
- gboolean have_device = FALSE, removed = FALSE;
-
- if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->dev_store), &iter))
- return;
-
- do {
- NMDevice *candidate = NULL;
-
- gtk_tree_model_get (GTK_TREE_MODEL (priv->dev_store), &iter,
- INTRO_COL_DEVICE, &candidate, -1);
- if (candidate) {
- if (candidate == device) {
- gtk_tree_store_remove (priv->dev_store, &iter);
- removed = TRUE;
- }
- g_object_unref (candidate);
- }
- } while (!removed && gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->dev_store), &iter));
-
- /* There's already a selected device item; nothing more to do */
- if (gtk_combo_box_get_active (priv->dev_combo) > 1)
- return;
-
- /* If there are no more devices, select the "Any" item and disable the
- * combo box. If there is no selected item and there is at least one device
- * item, select the first one.
- */
- if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->dev_store), &iter))
- return;
-
- do {
- NMDevice *candidate = NULL;
-
- gtk_tree_model_get (GTK_TREE_MODEL (priv->dev_store), &iter,
- INTRO_COL_DEVICE, &candidate, -1);
- if (candidate) {
- have_device = TRUE;
- g_object_unref (candidate);
- }
- } while (!have_device && gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->dev_store), &iter));
-
- if (have_device) {
- /* Iter should point to the last device item in the combo */
- gtk_combo_box_set_active_iter (priv->dev_combo, &iter);
- } else {
- gtk_combo_box_set_active (priv->dev_combo, 0);
- gtk_widget_set_sensitive (GTK_WIDGET (priv->dev_combo), FALSE);
- }
-}
-
-static void
-intro_add_initial_devices (NMAMobileWizard *self)
-{
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
- const GPtrArray *devices;
- gboolean selected_first = FALSE;
- int i;
-
- devices = priv->client ? nm_client_get_devices (priv->client) : NULL;
- for (i = 0; devices && (i < devices->len); i++) {
- if (__intro_device_added (self, g_ptr_array_index (devices, i), !selected_first)) {
- if (selected_first == FALSE)
- selected_first = TRUE;
- }
- }
-
- /* Otherwise the "Any device" item */
- if (!selected_first) {
- /* Select the first device item by default */
- gtk_combo_box_set_active (priv->dev_combo, 0);
- gtk_widget_set_sensitive (GTK_WIDGET (priv->dev_combo), FALSE);
- }
-}
-
-static void
-intro_remove_all_devices (NMAMobileWizard *self)
-{
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
-
- gtk_tree_store_clear (priv->dev_store);
-
- /* Select the "Any device" item */
- gtk_combo_box_set_active (priv->dev_combo, 0);
-}
-
-static void
-intro_manager_running_cb (NMClient *client, GParamSpec *pspec, NMAMobileWizard *self)
-{
- if (nm_client_get_nm_running (client))
- intro_add_initial_devices (self);
- else
- intro_remove_all_devices (self);
-}
-
-static gboolean
-intro_row_separator_func (GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
-{
- gboolean separator = FALSE;
- gtk_tree_model_get (model, iter, INTRO_COL_SEPARATOR, &separator, -1);
- return separator;
-}
-
-static void
-intro_combo_changed (NMAMobileWizard *self)
-{
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
- GtkTreeIter iter;
- NMDevice *selected = NULL;
- NMDeviceModemCapabilities caps;
-
- g_free (priv->dev_desc);
- priv->dev_desc = NULL;
-
- if (!gtk_combo_box_get_active_iter (priv->dev_combo, &iter))
- return;
-
- gtk_tree_model_get (GTK_TREE_MODEL (priv->dev_store), &iter,
- INTRO_COL_DEVICE, &selected, -1);
- if (selected) {
- priv->dev_desc = g_strdup (nm_device_get_description (selected));
- caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (selected));
- if (caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS)
- priv->family = NMA_MOBILE_FAMILY_3GPP;
- else if (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)
- priv->family = NMA_MOBILE_FAMILY_CDMA;
- else
- g_warning ("%s: unknown modem capabilities 0x%X", __func__, caps);
-
- g_object_unref (selected);
- }
-}
-
-static void
-intro_setup (NMAMobileWizard *self)
-{
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
- GtkCellRenderer *renderer;
- char *s;
-
- s = g_strdup_printf ("• %s", gtk_label_get_text (priv->provider_name_label));
- gtk_label_set_text (priv->provider_name_label, s);
- g_free (s);
-
- s = g_strdup_printf ("• %s", gtk_label_get_text (priv->plan_name_label));
- gtk_label_set_text (priv->plan_name_label, s);
- g_free (s);
-
- s = g_strdup_printf ("• %s", gtk_label_get_text (priv->apn_label));
- gtk_label_set_text (priv->apn_label, s);
- g_free (s);
-
- /* Device combo; only built if the wizard's caller didn't pass one in */
- if (!priv->initial_family) {
- GtkTreeIter iter;
-
- priv->client = nm_client_new (NULL, NULL);
- if (priv->client) {
- g_signal_connect (priv->client, "device-added",
- G_CALLBACK (intro_device_added_cb), self);
- g_signal_connect (priv->client, "device-removed",
- G_CALLBACK (intro_device_removed_cb), self);
- g_signal_connect (priv->client, "notify::manager-running",
- G_CALLBACK (intro_manager_running_cb), self);
- }
-
- gtk_combo_box_set_row_separator_func (priv->dev_combo,
- intro_row_separator_func, NULL, NULL);
-
- renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (priv->dev_combo), renderer, TRUE);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (priv->dev_combo), renderer, "text", INTRO_COL_NAME);
-
- /* Any device */
- gtk_tree_store_append (priv->dev_store, &iter, NULL);
- gtk_tree_store_set (priv->dev_store, &iter,
- INTRO_COL_NAME, _("Any device"), -1);
-
- /* Separator */
- gtk_tree_store_append (priv->dev_store, &iter, NULL);
- gtk_tree_store_set (priv->dev_store, &iter,
- INTRO_COL_SEPARATOR, TRUE, -1);
-
- intro_add_initial_devices (self);
- }
-}
-
-/**********************************************************/
-/* General assistant stuff */
-/**********************************************************/
-
-static void
-remove_plan_focus_idle (NMAMobileWizard *self)
-{
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
-
- if (priv->plan_focus_id) {
- g_source_remove (priv->plan_focus_id);
- priv->plan_focus_id = 0;
- }
-}
-
-static void
-remove_provider_focus_idle (NMAMobileWizard *self)
-{
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
-
- if (priv->providers_focus_id) {
- g_source_remove (priv->providers_focus_id);
- priv->providers_focus_id = 0;
- }
-}
-
-static void
-remove_country_focus_idle (NMAMobileWizard *self)
-{
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
-
- if (priv->country_focus_id) {
- g_source_remove (priv->country_focus_id);
- priv->country_focus_id = 0;
- }
-}
-
-static void
-assistant_prepare (GtkAssistant *assistant, GtkWidget *page, gpointer user_data)
-{
- NMAMobileWizard *self = user_data;
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
-
- if (page != priv->plan_page)
- remove_plan_focus_idle (self);
- if (page != priv->providers_page)
- remove_provider_focus_idle (self);
- if (page != priv->country_page)
- remove_country_focus_idle (self);
-
- if (page == priv->country_page)
- country_prepare (self);
- else if (page == priv->providers_page)
- providers_prepare (self);
- else if (page == priv->plan_page)
- plan_prepare (self);
- else if (page == priv->confirm_page)
- confirm_prepare (self);
-}
-
-static gint
-forward_func (gint current_page, gpointer user_data)
-{
- NMAMobileWizard *self = user_data;
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
-
- if (current_page == PROVIDERS_PAGE_IDX) {
- NMAMobileFamily family = priv->family;
-
- /* If the provider is unlisted, we can skip ahead of the user's
- * access technology is CDMA.
- */
- if (gtk_toggle_button_get_active (priv->provider_unlisted_radio)) {
- if (family == NMA_MOBILE_FAMILY_UNKNOWN)
- family = get_provider_unlisted_type (self);
- } else {
- /* Or, if the provider is only CDMA, then we can also skip ahead */
- NMAMobileProvider *provider;
- GSList *iter;
- gboolean gsm = FALSE, cdma = FALSE;
-
- provider = get_selected_provider (self);
- if (provider) {
- for (iter = nma_mobile_provider_get_methods (provider); iter; iter = g_slist_next (iter)) {
- NMAMobileAccessMethod *method = iter->data;
-
- if (nma_mobile_access_method_get_family (method) == NMA_MOBILE_FAMILY_CDMA)
- cdma = TRUE;
- else if (nma_mobile_access_method_get_family (method) == NMA_MOBILE_FAMILY_3GPP)
- gsm = TRUE;
- }
- nma_mobile_provider_unref (provider);
-
- if (cdma && !gsm)
- family = NMA_MOBILE_FAMILY_CDMA;
- }
- }
-
- /* Skip to the confirm page if we know its CDMA */
- if (family == NMA_MOBILE_FAMILY_CDMA) {
- priv->provider_only_cdma = TRUE;
- return CONFIRM_PAGE_IDX;
- } else
- priv->provider_only_cdma = FALSE;
- }
-
- return current_page + 1;
-}
-
-static char *
-get_country_from_locale (void)
-{
- char *p, *m, *cc, *lang;
-
- lang = getenv ("LC_ALL");
- if (!lang)
- lang = getenv ("LANG");
- if (!lang)
- return NULL;
-
- p = strchr (lang, '_');
- if (!p || !strlen (p)) {
- g_free (p);
- return NULL;
- }
-
- p = cc = g_strdup (++p);
- m = strchr (cc, '.');
- if (m)
- *m = '\0';
-
- while (*p) {
- *p = g_ascii_toupper (*p);
- p++;
- }
-
- return cc;
-}
-
-static void
-finalize (GObject *object)
-{
- NMAMobileWizard *self = NMA_MOBILE_WIZARD (object);
- NMAMobileWizardPrivate *priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
-
- g_clear_pointer (&priv->dev_desc, g_free);
- g_clear_object (&priv->client);
-
- remove_plan_focus_idle (self);
- remove_provider_focus_idle (self);
- remove_country_focus_idle (self);
-
- g_clear_object (&priv->mobile_providers_database);
-
- G_OBJECT_CLASS (nma_mobile_wizard_parent_class)->finalize (object);
-}
-
-static void
-nma_mobile_wizard_class_init (NMAMobileWizardClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
- object_class->finalize = finalize;
-
- g_type_ensure (NM_TYPE_DEVICE);
- gtk_widget_class_set_template_from_resource (widget_class,
- "/org/freedesktop/network-manager-applet/nma-mobile-wizard.ui");
-
-
- gtk_widget_class_bind_template_child_private (widget_class, NMAMobileWizard, dev_combo);
- gtk_widget_class_bind_template_child_private (widget_class, NMAMobileWizard, dev_combo_label);
- gtk_widget_class_bind_template_child_private (widget_class, NMAMobileWizard, country_page);
- gtk_widget_class_bind_template_child_private (widget_class, NMAMobileWizard, country_view);
- gtk_widget_class_bind_template_child_private (widget_class, NMAMobileWizard, providers_page);
- gtk_widget_class_bind_template_child_private (widget_class, NMAMobileWizard, providers_view_radio);
- gtk_widget_class_bind_template_child_private (widget_class, NMAMobileWizard, providers_view);
- gtk_widget_class_bind_template_child_private (widget_class, NMAMobileWizard, provider_unlisted_radio);
- gtk_widget_class_bind_template_child_private (widget_class, NMAMobileWizard, provider_unlisted_type_combo);
- gtk_widget_class_bind_template_child_private (widget_class, NMAMobileWizard, plan_page);
- gtk_widget_class_bind_template_child_private (widget_class, NMAMobileWizard, plan_combo);
- gtk_widget_class_bind_template_child_private (widget_class, NMAMobileWizard, plan_apn_entry);
- gtk_widget_class_bind_template_child_private (widget_class, NMAMobileWizard, confirm_page);
- gtk_widget_class_bind_template_child_private (widget_class, NMAMobileWizard, confirm_provider);
- gtk_widget_class_bind_template_child_private (widget_class, NMAMobileWizard, confirm_plan_label);
- gtk_widget_class_bind_template_child_private (widget_class, NMAMobileWizard, confirm_apn);
- gtk_widget_class_bind_template_child_private (widget_class, NMAMobileWizard, confirm_plan);
- gtk_widget_class_bind_template_child_private (widget_class, NMAMobileWizard, confirm_device_label);
- gtk_widget_class_bind_template_child_private (widget_class, NMAMobileWizard, confirm_connect_after_label);
- gtk_widget_class_bind_template_child_private (widget_class, NMAMobileWizard, confirm_device);
- gtk_widget_class_bind_template_child_private (widget_class, NMAMobileWizard, provider_name_label);
- gtk_widget_class_bind_template_child_private (widget_class, NMAMobileWizard, plan_name_label);
- gtk_widget_class_bind_template_child_private (widget_class, NMAMobileWizard, apn_label);
-
- gtk_widget_class_bind_template_child_private (widget_class, NMAMobileWizard, dev_store);
- gtk_widget_class_bind_template_child_private (widget_class, NMAMobileWizard, country_store);
- gtk_widget_class_bind_template_child_private (widget_class, NMAMobileWizard, country_sort);
- gtk_widget_class_bind_template_child_private (widget_class, NMAMobileWizard, providers_store);
- gtk_widget_class_bind_template_child_private (widget_class, NMAMobileWizard, providers_sort);
- gtk_widget_class_bind_template_child_private (widget_class, NMAMobileWizard, plan_store);
-
- gtk_widget_class_bind_template_callback (widget_class, assistant_closed);
- gtk_widget_class_bind_template_callback (widget_class, assistant_cancel);
- gtk_widget_class_bind_template_callback (widget_class, assistant_prepare);
- gtk_widget_class_bind_template_callback (widget_class, intro_combo_changed);
- gtk_widget_class_bind_template_callback (widget_class, country_update_continue);
- gtk_widget_class_bind_template_callback (widget_class, providers_radio_toggled);
- gtk_widget_class_bind_template_callback (widget_class, providers_update_complete);
- gtk_widget_class_bind_template_callback (widget_class, providers_update_continue);
- gtk_widget_class_bind_template_callback (widget_class, plan_combo_changed);
- gtk_widget_class_bind_template_callback (widget_class, plan_update_complete);
- gtk_widget_class_bind_template_callback (widget_class, apn_filter_cb);
-}
-
-static void
-nma_mobile_wizard_init (NMAMobileWizard *self)
-{
- gtk_widget_init_template (GTK_WIDGET (self));
- gtk_widget_realize (GTK_WIDGET (self));
-
- if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (self)))) {
-#if GTK_CHECK_VERSION(3,90,0)
- GdkSurface *surface = gtk_widget_get_surface (GTK_WIDGET (self));
- gdk_x11_surface_set_skip_taskbar_hint (surface, TRUE);
-#else
- GdkWindow *gdk_window = gtk_widget_get_window (GTK_WIDGET (self));
- gdk_window_set_skip_taskbar_hint (gdk_window, TRUE);
-#endif
- }
-}
-
-/**
- * nma_mobile_wizard_new: (skip)
- * @parent:
- * @window_group:
- * @modem_caps:
- * @will_connect_after:
- * @cb: (scope async):
- * @user_data:
- *
- * Returns: the newly created #NMAMobileWizard
- */
-NMAMobileWizard *
-nma_mobile_wizard_new (GtkWindow *parent,
- GtkWindowGroup *window_group,
- NMDeviceModemCapabilities modem_caps,
- gboolean will_connect_after,
- NMAMobileWizardCallback cb,
- gpointer user_data)
-{
- NMAMobileWizard *self;
- NMAMobileWizardPrivate *priv;
- char *cc;
- GError *error = NULL;
-
- self = g_object_new (NMA_TYPE_MOBILE_WIZARD, NULL);
- priv = NMA_MOBILE_WIZARD_GET_PRIVATE (self);
-
- priv->mobile_providers_database = nma_mobile_providers_database_new_sync (NULL, NULL, NULL, &error);
- if (!priv->mobile_providers_database) {
- g_warning ("Cannot create mobile providers database: %s",
- error->message);
- g_error_free (error);
- nma_mobile_wizard_destroy (self);
- return NULL;
- }
-
- cc = get_country_from_locale ();
- if (cc) {
- priv->country = nma_mobile_providers_database_lookup_country (priv->mobile_providers_database, cc);
- g_free (cc);
- }
-
- priv->will_connect_after = will_connect_after;
- priv->callback = cb;
- priv->user_data = user_data;
- if (modem_caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS)
- priv->family = NMA_MOBILE_FAMILY_3GPP;
- else if (modem_caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)
- priv->family = NMA_MOBILE_FAMILY_CDMA;
- if (priv->family) {
- priv->initial_family = TRUE; /* Skip device selection */
- } else {
- gtk_widget_show (GTK_WIDGET (priv->dev_combo_label));
- gtk_widget_show (GTK_WIDGET (priv->dev_combo));
- }
-
- gtk_assistant_set_forward_page_func (GTK_ASSISTANT (self),
- forward_func, self, NULL);
-
- intro_setup (self);
- country_setup (self);
- providers_setup (self);
- plan_setup (self);
- confirm_setup (self);
-
- if (parent)
- gtk_window_set_transient_for (GTK_WINDOW (self), parent);
- if (window_group)
- gtk_window_group_add_window (window_group, GTK_WINDOW (self));
-
- return self;
-}
-
-void
-nma_mobile_wizard_present (NMAMobileWizard *self)
-{
- g_return_if_fail (self != NULL);
-
- gtk_window_present (GTK_WINDOW (self));
-}
-
-void
-nma_mobile_wizard_destroy (NMAMobileWizard *self)
-{
- g_return_if_fail (self != NULL);
-
- gtk_widget_destroy (GTK_WIDGET (self));
-}
diff --git a/src/libnma/nma-mobile-wizard.h b/src/libnma/nma-mobile-wizard.h
deleted file mode 100644
index 85239387..00000000
--- a/src/libnma/nma-mobile-wizard.h
+++ /dev/null
@@ -1,65 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/* NetworkManager Connection editor -- Connection editor for NetworkManager
- *
- * Dan Williams <dcbw@redhat.com>
- * Lubomir Rintel <lkundrak@v3.sk>
- *
- * (C) Copyright 2008 - 2018 Red Hat, Inc.
- */
-
-#ifndef MOBILE_WIZARD_H
-#define MOBILE_WIZARD_H
-
-#include <glib.h>
-#include <NetworkManager.h>
-#include <nm-device.h>
-
-typedef struct _NMAMobileWizard NMAMobileWizard;
-typedef struct _NMAMobileWizardClass NMAMobileWizardClass;
-
-/**
- * NMAMobileWizardAccessMethod:
- * @provider_name: The mobile network provider name
- * @plan_name: The provided network access billing plan
- * @devtype: Required NetworkManager device capabilities
- * @username: User login
- * @password: User secret
- * @gsm_apn: The GSM Access Point Name
- *
- * Network access method details.
- */
-typedef struct {
- char *provider_name;
- char *plan_name;
- NMDeviceModemCapabilities devtype;
- char *username;
- char *password;
- char *gsm_apn;
-} NMAMobileWizardAccessMethod;
-
-typedef void (*NMAMobileWizardCallback) (NMAMobileWizard *self,
- gboolean canceled,
- NMAMobileWizardAccessMethod *method,
- gpointer user_data);
-
-#define NMA_TYPE_MOBILE_WIZARD (nma_mobile_wizard_get_type ())
-#define NMA_MOBILE_WIZARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMA_TYPE_MOBILE_WIZARD, NMAMobileWizard))
-#define NMA_MOBILE_WIZARD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMA_TYPE_MOBILE_WIZARD, NMAMobileWizardClass))
-#define NMA_IS_MOBILE_WIZARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMA_TYPE_MOBILE_WIZARD))
-#define NMA_IS_MOBILE_WIZARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMA_TYPE_MOBILE_WIZARD))
-#define NMA_MOBILE_WIZARD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMA_TYPE_MOBILE_WIZARD, NMAMobileWizardClass))
-
-GType nma_mobile_wizard_get_type (void);
-
-NMAMobileWizard *nma_mobile_wizard_new (GtkWindow *parent,
- GtkWindowGroup *window_group,
- NMDeviceModemCapabilities modem_caps,
- gboolean will_connect_after,
- NMAMobileWizardCallback cb,
- gpointer user_data);
-
-void nma_mobile_wizard_present (NMAMobileWizard *wizard);
-
-void nma_mobile_wizard_destroy (NMAMobileWizard *self);
-
-#endif /* MOBILE_WIZARD_H */
diff --git a/src/libnma/nma-mobile-wizard.ui b/src/libnma/nma-mobile-wizard.ui
deleted file mode 100644
index e120e962..00000000
--- a/src/libnma/nma-mobile-wizard.ui
+++ /dev/null
@@ -1,604 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.2 -->
-<interface domain="nm-applet">
- <requires lib="gtk+" version="3.20"/>
- <object class="GtkTreeStore" id="country_store">
- <columns>
- <!-- column-name name -->
- <column type="gchararray"/>
- <!-- column-name info -->
- <column type="NMACountryInfo"/>
- </columns>
- </object>
- <object class="GtkTreeModelSort" id="country_sort">
- <property name="model">country_store</property>
- </object>
- <object class="GtkTreeStore" id="dev_store">
- <columns>
- <!-- column-name name -->
- <column type="gchararray"/>
- <!-- column-name device -->
- <column type="NMDevice"/>
- <!-- column-name sparator -->
- <column type="gboolean"/>
- </columns>
- </object>
- <object class="GtkTreeStore" id="plan_store">
- <columns>
- <!-- column-name name -->
- <column type="gchararray"/>
- <!-- column-name method -->
- <column type="NMAMobileAccessMethod"/>
- <!-- column-name manual -->
- <column type="gboolean"/>
- </columns>
- </object>
- <object class="GtkTreeStore" id="providers_store">
- <columns>
- <!-- column-name name -->
- <column type="gchararray"/>
- <!-- column-name provider -->
- <column type="NMAMobileProvider"/>
- </columns>
- </object>
- <object class="GtkTreeModelSort" id="providers_sort">
- <property name="model">providers_store</property>
- </object>
- <template class="NMAMobileWizard" parent="GtkAssistant">
- <property name="can_focus">False</property>
- <property name="title" translatable="yes">New Mobile Broadband Connection</property>
- <property name="modal">True</property>
- <property name="window_position">center-always</property>
- <property name="type_hint">dialog</property>
- <property name="use_header_bar">1</property>
- <signal name="cancel" handler="assistant_cancel" swapped="no"/>
- <signal name="close" handler="assistant_closed" swapped="no"/>
- <signal name="prepare" handler="assistant_prepare" swapped="no"/>
- <child>
- <object class="GtkBox" id="intro_page">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_start">12</property>
- <property name="margin_end">12</property>
- <property name="margin_top">12</property>
- <property name="margin_bottom">12</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">This assistant helps you easily set up a mobile broadband connection to a cellular (3G) network.</property>
- <property name="wrap">True</property>
- <property name="max_width_chars">60</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">5</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">You will need the following information:</property>
- <property name="wrap">True</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">6</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="provider_name_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_start">25</property>
- <property name="label" translatable="yes">Your broadband provider’s name</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">7</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="plan_name_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_start">25</property>
- <property name="label" translatable="yes">Your broadband billing plan name</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">8</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="apn_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_start">25</property>
- <property name="label" translatable="yes">(in some cases) Your broadband billing plan APN (Access Point Name)</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">9</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="dev_combo_label">
- <property name="can_focus">False</property>
- <property name="valign">end</property>
- <property name="vexpand">True</property>
- <property name="label" translatable="yes">Create a connection for _this mobile broadband device:</property>
- <property name="use_underline">True</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">10</property>
- </packing>
- </child>
- <child>
- <object class="GtkComboBox" id="dev_combo">
- <property name="sensitive">False</property>
- <property name="can_focus">False</property>
- <property name="model">dev_store</property>
- <property name="active">0</property>
- <signal name="changed" handler="intro_combo_changed" swapped="yes"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">11</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="page_type">intro</property>
- <property name="title" translatable="yes">Set up a Mobile Broadband Connection</property>
- <property name="complete">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="country_page">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_start">12</property>
- <property name="margin_end">12</property>
- <property name="margin_top">12</property>
- <property name="margin_bottom">12</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Country or region:</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkScrolledWindow">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="vexpand">True</property>
- <property name="hscrollbar_policy">never</property>
- <property name="shadow_type">in</property>
- <child>
- <object class="GtkTreeView" id="country_view">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="model">country_sort</property>
- <property name="headers_visible">False</property>
- <property name="search_column">0</property>
- <signal name="row-activated" handler="country_update_continue" swapped="yes"/>
- <child internal-child="selection">
- <object class="GtkTreeSelection"/>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="title" translatable="yes">Choose your Provider’s Country or Region</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="providers_page">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_start">12</property>
- <property name="margin_end">12</property>
- <property name="margin_top">12</property>
- <property name="margin_bottom">12</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkRadioButton" id="providers_view_radio">
- <property name="label" translatable="yes">Select your provider from a _list:</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="active">True</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="providers_radio_toggled" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkScrolledWindow">
- <property name="height_request">140</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="margin_start">25</property>
- <property name="vexpand">True</property>
- <property name="hscrollbar_policy">never</property>
- <property name="shadow_type">in</property>
- <child>
- <object class="GtkTreeView" id="providers_view">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="model">providers_sort</property>
- <property name="search_column">0</property>
- <signal name="row-activated" handler="providers_update_continue" swapped="yes"/>
- <child internal-child="selection">
- <object class="GtkTreeSelection"/>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkRadioButton" id="provider_unlisted_radio">
- <property name="label" translatable="yes">I can’t find my provider and I wish to set up the connection _manually:</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <property name="group">providers_view_radio</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkComboBoxText" id="provider_unlisted_type_combo">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_start">25</property>
- <property name="active">0</property>
- <items>
- <item id="0" translatable="yes">My provider uses GSM technology (GPRS, EDGE, UMTS, HSPA)</item>
- <item id="1" translatable="yes">My provider uses CDMA technology (1xRTT, EVDO)</item>
- </items>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">3</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="title" translatable="yes">Choose your Provider</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="plan_page">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_start">12</property>
- <property name="margin_end">12</property>
- <property name="margin_top">12</property>
- <property name="margin_bottom">12</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">_Select your plan:</property>
- <property name="use_underline">True</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkComboBox" id="plan_combo">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="model">plan_store</property>
- <signal name="changed" handler="plan_combo_changed" swapped="yes"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Selected plan _APN (Access Point Name):</property>
- <property name="use_underline">True</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="plan_apn_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="max_length">64</property>
- <signal name="changed" handler="plan_update_complete" swapped="yes"/>
- <signal name="insert-text" handler="apn_filter_cb" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="valign">end</property>
- <property name="vexpand">True</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkImage">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="valign">start</property>
- <property name="icon_name">dialog-warning</property>
- <property name="icon_size">6</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="width_request">500</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Warning: Selecting an incorrect plan may result in billing issues for your broadband account or may prevent connectivity.
-
-If you are unsure of your plan please ask your provider for your plan’s APN.</property>
- <property name="wrap">True</property>
- <property name="max_width_chars">60</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">5</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">4</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="title" translatable="yes">Choose your Billing Plan</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="confirm_page">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_start">12</property>
- <property name="margin_end">12</property>
- <property name="margin_top">12</property>
- <property name="margin_bottom">12</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel">
- <property name="width_request">500</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Your mobile broadband connection is configured with the following settings:</property>
- <property name="wrap">True</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="confirm_device_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Your Device:</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="confirm_device">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_start">25</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Your Provider:</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="confirm_provider">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_start">25</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">4</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="confirm_plan_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Your Plan:</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">5</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel" id="confirm_plan">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_start">25</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="confirm_apn">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_start">25</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">6</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="confirm_connect_after_label">
- <property name="visible">False</property>
- <property name="width_request">500</property>
- <property name="can_focus">False</property>
- <property name="valign">end</property>
- <property name="vexpand">True</property>
- <property name="label" translatable="yes">A connection will now be made to your mobile broadband provider using the settings you selected. If the connection fails or you cannot access network resources, double-check your settings. To modify your mobile broadband connection settings, choose “Network Connections” from the System → Preferences menu.</property>
- <property name="wrap">True</property>
- <property name="max_width_chars">60</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">7</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="page_type">confirm</property>
- <property name="title" translatable="yes">Confirm Mobile Broadband Settings</property>
- <property name="complete">True</property>
- </packing>
- </child>
- <child>
- <placeholder/>
- </child>
- <child internal-child="action_area">
- <object class="GtkBox">
- <property name="can_focus">False</property>
- </object>
- <packing>
- </packing>
- </child>
- </template>
-</interface>
diff --git a/src/libnma/nma-pkcs11-cert-chooser-dialog.c b/src/libnma/nma-pkcs11-cert-chooser-dialog.c
deleted file mode 100644
index f8feb056..00000000
--- a/src/libnma/nma-pkcs11-cert-chooser-dialog.c
+++ /dev/null
@@ -1,643 +0,0 @@
-// SPDX-License-Identifier: LGPL-2.1+
-/* NetworkManager Applet -- allow user control over networking
- *
- * Lubomir Rintel <lkundrak@v3.sk>
- *
- * Copyright (C) 2016,2017 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-#include "nma-pkcs11-cert-chooser-dialog.h"
-#include "nma-pkcs11-token-login-dialog.h"
-
-#include <string.h>
-#include <gck/gck.h>
-#include <gcr/gcr.h>
-
-/**
- * SECTION:nma-pkcs11-cert-chooser-dialog
- * @title: NMAPkcs11CertChooserDialog
- * @short_description: The PKCS\#11 Object Chooser Dialog
- *
- * #NMAPkcs11CertChooserDialog selects an object from a PKCS\#11 token,
- * optionally allowing the user to specify the PIN and log in.
- */
-
-enum {
- COLUMN_LABEL,
- COLUMN_ISSUER,
- COLUMN_HAS_KEY,
- COLUMN_ATTRIBUTES,
- N_COLUMNS
-};
-
-struct _NMAPkcs11CertChooserDialogPrivate {
- GckSlot *slot;
- GtkListStore *cert_store;
- GtkListStore *key_store;
- GtkWidget *login_button;
-
- guchar *pin_value;
- gulong pin_length;
- gboolean remember_pin;
-
- GtkRevealer *error_revealer;
- GtkLabel *error_label;
- GtkTreeView *objects_view;
- GtkTreeViewColumn *list_name_column;
- GtkCellRenderer *list_name_renderer;
- GtkTreeViewColumn *list_issued_by_column;
- GtkCellRenderer *list_issued_by_renderer;
-};
-
-#define NMA_PKCS11_CERT_CHOOSER_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
- NMA_TYPE_PKCS11_CERT_CHOOSER_DIALOG, \
- NMAPkcs11CertChooserDialogPrivate))
-
-G_DEFINE_TYPE_WITH_CODE (NMAPkcs11CertChooserDialog, nma_pkcs11_cert_chooser_dialog, GTK_TYPE_DIALOG,
- G_ADD_PRIVATE (NMAPkcs11CertChooserDialog))
-
-#define NMA_RESPONSE_LOGIN 1
-
-enum {
- PROP_0,
- PROP_SLOT,
-};
-
-typedef struct {
- GckAttributes *attrs;
- gboolean has_key;
-} IdMatchData;
-
-static gboolean
-id_match (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer user_data)
-{
- IdMatchData *data = user_data;
- GckAttributes *attrs = NULL;
- const GckAttribute *attr1, *attr2;
-
- attr1 = gck_attributes_find (data->attrs, CKA_ID);
- if (!attr1 || !attr1->value || !attr1->length)
- goto out;
-
- gtk_tree_model_get (model, iter, COLUMN_ATTRIBUTES, &attrs, -1);
- attr2 = gck_attributes_find (attrs, CKA_ID);
- if (!attr2 || !attr2->value || !attr2->length)
- goto out;
-
- if (attr1->length != attr2->length)
- goto out;
-
- if (memcmp (attr1->value, attr2->value, attr1->length))
- goto out;
-
- data->has_key = TRUE;
- gtk_list_store_set (GTK_LIST_STORE (model), iter,
- COLUMN_HAS_KEY, TRUE, -1);
-
- if (attrs)
- gck_attributes_unref (attrs);
-out:
- return data->has_key;
-}
-
-static void
-object_details (GObject *source_object, GAsyncResult *res, gpointer user_data)
-{
- GckObject *object = GCK_OBJECT (source_object);
- NMAPkcs11CertChooserDialog *self = NMA_PKCS11_CERT_CHOOSER_DIALOG (user_data);
- NMAPkcs11CertChooserDialogPrivate *priv = NMA_PKCS11_CERT_CHOOSER_DIALOG_GET_PRIVATE (self);
- GckAttributes *attrs;
- GtkTreeIter iter;
- CK_OBJECT_CLASS cka_class;
- const GckAttribute *attr;
- GcrCertificate *cert;
- gchar *label, *issuer;
- GError *error = NULL;
- GtkListStore *store1, *store2;
- IdMatchData data;
-
- attrs = gck_object_get_finish (object, res, &error);
- if (!attrs) {
- /* No better idea than to just ignore the object. */
- g_warning ("Error getting attributes: %s\n", error->message);
- g_error_free (error);
- goto out;
- }
-
- if (!gck_attributes_find_ulong (attrs, CKA_CLASS, &cka_class)) {
- g_warning ("An object without CKA_CLASS\n");
- goto out;
- }
-
- switch (cka_class) {
- case CKO_CERTIFICATE:
- store1 = priv->cert_store;
- store2 = priv->key_store;
- break;
- case CKO_PRIVATE_KEY:
- store1 = priv->key_store;
- store2 = priv->cert_store;
- break;
- default:
- goto out;
- }
-
- /* See if there's a matching object in another store. */
- data.attrs = attrs;
- data.has_key = FALSE;
- gtk_tree_model_foreach (GTK_TREE_MODEL (store2),
- id_match,
- &data);
-
- attr = gck_attributes_find (attrs, CKA_VALUE);
- if (attr && attr->value && attr->length) {
- cert = gcr_simple_certificate_new (attr->value, attr->length);
- label = gcr_certificate_get_subject_name (cert);
- issuer = gcr_certificate_get_issuer_name (cert);
- g_object_unref (cert);
- } else {
- attr = gck_attributes_find (attrs, CKA_LABEL);
- if (attr && attr->value && attr->length) {
- label = g_malloc (attr->length + 1);
- memcpy (label, attr->value, attr->length);
- label[attr->length] = '\0';
- } else {
- label = g_strdup (_("(Unknown)"));
- }
- issuer = g_memdup ("", 1);
- }
-
- gtk_list_store_append (store1, &iter);
- gtk_list_store_set (store1, &iter,
- COLUMN_LABEL, label,
- COLUMN_ISSUER, issuer,
- COLUMN_HAS_KEY, data.has_key,
- COLUMN_ATTRIBUTES, attrs,
- -1);
-
- g_free (label);
- g_free (issuer);
-
-out:
- if (attrs)
- gck_attributes_unref (attrs);
-}
-
-static void
-next_object (GObject *obj, GAsyncResult *res, gpointer user_data)
-{
- NMAPkcs11CertChooserDialog *self = NMA_PKCS11_CERT_CHOOSER_DIALOG (user_data);
- GckEnumerator *enm = GCK_ENUMERATOR (obj);
- GList *objects;
- GList *iter;
- GError *error = NULL;
-
- objects = gck_enumerator_next_finish (enm, res, &error);
- if (error) {
- /* No better idea than to just ignore the object. */
- g_warning ("Error getting object: %s", error->message);
- g_error_free (error);
- return;
- }
-
- for (iter = objects; iter; iter = iter->next) {
- GckObject *object = GCK_OBJECT (iter->data);
- const gulong attr_types[] = { CKA_ID, CKA_LABEL, CKA_ISSUER,
- CKA_VALUE, CKA_CLASS };
-
- gck_object_get_async (object, attr_types,
- sizeof(attr_types) / sizeof(attr_types[0]),
- NULL, object_details, self);
- }
-
- gck_list_unref_free (objects);
-}
-
-static void
-reload_slot (NMAPkcs11CertChooserDialog *self, GckSession *session)
-{
- NMAPkcs11CertChooserDialogPrivate *priv = NMA_PKCS11_CERT_CHOOSER_DIALOG_GET_PRIVATE (self);
- GckEnumerator *enm;
-
- gtk_list_store_clear (priv->key_store);
- gtk_list_store_clear (priv->cert_store);
- enm = gck_session_enumerate_objects (session, gck_attributes_new_empty (GCK_INVALID));
- gck_enumerator_next_async (enm, -1, NULL, next_object, self);
-}
-
-static void
-logged_in (GObject *obj, GAsyncResult *res, gpointer user_data)
-{
- NMAPkcs11CertChooserDialog *self = NMA_PKCS11_CERT_CHOOSER_DIALOG (user_data);
- NMAPkcs11CertChooserDialogPrivate *priv = NMA_PKCS11_CERT_CHOOSER_DIALOG_GET_PRIVATE (self);
- GckSession *session = GCK_SESSION (obj);
- GError *error = NULL;
-
- if (!gck_session_login_finish (session, res, &error)) {
- g_prefix_error (&error, _("Error logging in: "));
- gtk_label_set_label (priv->error_label, error->message);
- gtk_revealer_set_reveal_child (priv->error_revealer, TRUE);
- g_error_free (error);
- } else {
- gtk_revealer_set_reveal_child (priv->error_revealer, FALSE);
- gtk_widget_set_sensitive (priv->login_button, FALSE);
- reload_slot (self, session);
- g_clear_object (&session);
- }
-}
-
-static void
-session_opened (GObject *obj, GAsyncResult *res, gpointer user_data)
-{
- NMAPkcs11CertChooserDialog *self = NMA_PKCS11_CERT_CHOOSER_DIALOG (user_data);
- NMAPkcs11CertChooserDialogPrivate *priv = NMA_PKCS11_CERT_CHOOSER_DIALOG_GET_PRIVATE (self);
- GckSession *session;
- GError *error = NULL;
-
- session = gck_slot_open_session_finish (priv->slot, res, &error);
- if (error) {
- g_prefix_error (&error, _("Error opening a session: "));
- gtk_label_set_label (priv->error_label, error->message);
- gtk_revealer_set_reveal_child (priv->error_revealer, TRUE);
- g_error_free (error);
- return;
- }
-
- if (priv->pin_value) {
- gck_session_login_async (session, CKU_USER,
- priv->pin_value, priv->pin_length,
- NULL, logged_in, self);
- } else {
- reload_slot (self, session);
- g_clear_object (&session);
- }
-}
-
-static void
-row_activated (GtkTreeView *tree_view, GtkTreePath *path,
- GtkTreeViewColumn *column, gpointer user_data)
-{
- if (gtk_window_activate_default (GTK_WINDOW (user_data)))
- return;
-}
-
-static void
-cursor_changed (GtkTreeView *tree_view, gpointer user_data)
-{
- NMAPkcs11CertChooserDialog *self = NMA_PKCS11_CERT_CHOOSER_DIALOG (user_data);
- gchar *uri;
-
- uri = nma_pkcs11_cert_chooser_dialog_get_uri (self);
- gtk_dialog_set_response_sensitive (GTK_DIALOG (self), GTK_RESPONSE_ACCEPT, uri != NULL);
- g_free (uri);
-}
-
-static void
-error_close (GtkInfoBar *bar, gint response_id, gpointer user_data)
-{
- NMAPkcs11CertChooserDialog *self = user_data;
- NMAPkcs11CertChooserDialogPrivate *priv = self->priv;
-
- gtk_revealer_set_reveal_child (priv->error_revealer, FALSE);
-}
-
-static void
-login_clicked (GtkButton *button, gpointer user_data)
-{
- NMAPkcs11CertChooserDialog *self = NMA_PKCS11_CERT_CHOOSER_DIALOG (user_data);
- NMAPkcs11CertChooserDialogPrivate *priv = NMA_PKCS11_CERT_CHOOSER_DIALOG_GET_PRIVATE (self);
- GtkWidget *dialog;
- GckTokenInfo *token_info;
- gboolean has_pin_pad = FALSE;
-
- /* See if the token has a PIN pad. */
- token_info = gck_slot_get_token_info (priv->slot);
- g_return_if_fail (token_info);
- if (token_info->flags & CKF_PROTECTED_AUTHENTICATION_PATH)
- has_pin_pad = TRUE;
- gck_token_info_free (token_info);
-
- if (priv->pin_value)
- g_free (priv->pin_value);
-
- if (has_pin_pad) {
- /* Login with empty credentials makes the token
- * log in on its PIN pad. */
- priv->pin_length = 0;
- priv->pin_value = g_memdup ("", 1);
- priv->remember_pin = TRUE;
- gck_slot_open_session_async (priv->slot, GCK_SESSION_READ_ONLY, NULL, session_opened, self);
- return;
- }
-
- /* The token doesn't have a PIN pad. Ask for PIN. */
- dialog = nma_pkcs11_token_login_dialog_new (priv->slot);
- gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (self));
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
-
- if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
- priv->pin_length = nma_pkcs11_token_login_dialog_get_pin_length (NMA_PKCS11_TOKEN_LOGIN_DIALOG (dialog));
- priv->pin_value = g_memdup (nma_pkcs11_token_login_dialog_get_pin_value (NMA_PKCS11_TOKEN_LOGIN_DIALOG (dialog)),
- priv->pin_length + 1);
- priv->remember_pin = nma_pkcs11_token_login_dialog_get_remember_pin (NMA_PKCS11_TOKEN_LOGIN_DIALOG (dialog));
- gck_slot_open_session_async (priv->slot, GCK_SESSION_READ_ONLY, NULL, session_opened, self);
- }
-
- gtk_widget_destroy (dialog);
-}
-
-static void
-get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
-{
- NMAPkcs11CertChooserDialog *self = NMA_PKCS11_CERT_CHOOSER_DIALOG (object);
- NMAPkcs11CertChooserDialogPrivate *priv = NMA_PKCS11_CERT_CHOOSER_DIALOG_GET_PRIVATE (self);
-
- switch (prop_id) {
- case PROP_SLOT:
- if (priv->slot)
- g_value_set_object (value, priv->slot);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
-}
-
-static void
-set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
-{
- NMAPkcs11CertChooserDialog *self = NMA_PKCS11_CERT_CHOOSER_DIALOG (object);
- NMAPkcs11CertChooserDialogPrivate *priv = NMA_PKCS11_CERT_CHOOSER_DIALOG_GET_PRIVATE (self);
- GckTokenInfo *token_info;
-
- switch (prop_id) {
- case PROP_SLOT:
- priv->slot = g_value_dup_object (value);
- token_info = gck_slot_get_token_info (priv->slot);
- g_return_if_fail (token_info);
- if ((token_info->flags & CKF_LOGIN_REQUIRED) == 0)
- gtk_widget_set_sensitive (priv->login_button, FALSE);
- gck_token_info_free (token_info);
- gck_slot_open_session_async (priv->slot, GCK_SESSION_READ_ONLY, NULL, session_opened, self);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
-}
-
-static void
-finalize (GObject *object)
-{
- NMAPkcs11CertChooserDialog *self = NMA_PKCS11_CERT_CHOOSER_DIALOG (object);
- NMAPkcs11CertChooserDialogPrivate *priv = NMA_PKCS11_CERT_CHOOSER_DIALOG_GET_PRIVATE (self);
-
- g_clear_object (&priv->cert_store);
- g_clear_object (&priv->key_store);
- g_clear_object (&priv->slot);
-
- if (priv->pin_value) {
- g_free (priv->pin_value);
- priv->pin_value = NULL;
- }
-
- G_OBJECT_CLASS (nma_pkcs11_cert_chooser_dialog_parent_class)->finalize (object);
-}
-
-static void
-nma_pkcs11_cert_chooser_dialog_class_init (NMAPkcs11CertChooserDialogClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
- object_class->get_property = get_property;
- object_class->set_property = set_property;
- object_class->finalize = finalize;
-
- g_object_class_install_property (object_class, PROP_SLOT,
- g_param_spec_object ("slot", "PKCS#11 Slot", "PKCS#11 Slot",
- GCK_TYPE_SLOT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- gtk_widget_class_set_template_from_resource (widget_class,
- "/org/freedesktop/network-manager-applet/nma-pkcs11-cert-chooser-dialog.ui");
-
- gtk_widget_class_bind_template_child_private (widget_class, NMAPkcs11CertChooserDialog, objects_view);
- gtk_widget_class_bind_template_child_private (widget_class, NMAPkcs11CertChooserDialog, list_name_column);
- gtk_widget_class_bind_template_child_private (widget_class, NMAPkcs11CertChooserDialog, list_name_renderer);
- gtk_widget_class_bind_template_child_private (widget_class, NMAPkcs11CertChooserDialog, list_issued_by_column);
- gtk_widget_class_bind_template_child_private (widget_class, NMAPkcs11CertChooserDialog, list_issued_by_renderer);
- gtk_widget_class_bind_template_child_private (widget_class, NMAPkcs11CertChooserDialog, error_revealer);
- gtk_widget_class_bind_template_child_private (widget_class, NMAPkcs11CertChooserDialog, error_label);
- gtk_widget_class_bind_template_child_private (widget_class, NMAPkcs11CertChooserDialog, login_button);
-
- gtk_widget_class_bind_template_callback (widget_class, row_activated);
- gtk_widget_class_bind_template_callback (widget_class, cursor_changed);
- gtk_widget_class_bind_template_callback (widget_class, error_close);
- gtk_widget_class_bind_template_callback (widget_class, login_clicked);
-}
-
-static void
-nma_pkcs11_cert_chooser_dialog_init (NMAPkcs11CertChooserDialog *self)
-{
- NMAPkcs11CertChooserDialogPrivate *priv;
-
- self->priv = nma_pkcs11_cert_chooser_dialog_get_instance_private (self);
- priv = NMA_PKCS11_CERT_CHOOSER_DIALOG_GET_PRIVATE (self);
-
- gtk_widget_init_template (GTK_WIDGET (self));
-
- gtk_tree_view_column_set_attributes (priv->list_name_column,
- priv->list_name_renderer,
- "text", 0, NULL);
- gtk_tree_view_column_set_attributes (priv->list_issued_by_column,
- priv->list_issued_by_renderer,
- "text", 1, NULL);
-
- priv->cert_store = gtk_list_store_new (N_COLUMNS,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_BOOLEAN,
- GCK_TYPE_ATTRIBUTES);
- priv->key_store = gtk_list_store_new (N_COLUMNS,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_BOOLEAN,
- GCK_TYPE_ATTRIBUTES);
-}
-
-static GtkWidget *
-nma_pkcs11_cert_chooser_dialog_new_valist (GckSlot *slot,
- CK_OBJECT_CLASS object_class,
- const gchar *title, GtkWindow *parent,
- GtkDialogFlags flags,
- const gchar *first_button_text,
- va_list varargs)
-{
- NMAPkcs11CertChooserDialogPrivate *priv;
- GtkWidget *self;
- const char *button_text = first_button_text;
- gint response_id;
-
- self = g_object_new (NMA_TYPE_PKCS11_CERT_CHOOSER_DIALOG,
- "use-header-bar", !!(flags & GTK_DIALOG_USE_HEADER_BAR),
- "title", title,
- "slot", slot,
- NULL);
-
- priv = NMA_PKCS11_CERT_CHOOSER_DIALOG_GET_PRIVATE (self);
- switch (object_class) {
- case CKO_CERTIFICATE:
- gtk_tree_view_set_model (GTK_TREE_VIEW (priv->objects_view),
- GTK_TREE_MODEL (priv->cert_store));
- break;
- case CKO_PRIVATE_KEY:
- gtk_tree_view_set_model (GTK_TREE_VIEW (priv->objects_view),
- GTK_TREE_MODEL (priv->key_store));
- break;
- default:
- g_warn_if_reached ();
- }
-
- if (parent)
- gtk_window_set_transient_for (GTK_WINDOW (self), parent);
-
- while (button_text) {
- response_id = va_arg (varargs, gint);
- gtk_dialog_add_button (GTK_DIALOG (self), button_text, response_id);
- button_text = va_arg (varargs, const gchar *);
- }
-
- gtk_dialog_set_default_response (GTK_DIALOG (self), GTK_RESPONSE_ACCEPT);
- gtk_dialog_set_response_sensitive (GTK_DIALOG (self), GTK_RESPONSE_ACCEPT, FALSE);
-
- return self;
-}
-
-/**
- * nma_pkcs11_cert_chooser_dialog_get_uri:
- * @dialog: the #NMAPkcs11CertChooserDialog instance
- *
- * Obtain the URI of the selected obejct.
- *
- * Returns: the URI or %NULL if none was selected.
- */
-gchar *
-nma_pkcs11_cert_chooser_dialog_get_uri (NMAPkcs11CertChooserDialog *dialog)
-{
- NMAPkcs11CertChooserDialogPrivate *priv = NMA_PKCS11_CERT_CHOOSER_DIALOG_GET_PRIVATE (dialog);
- GtkTreeModel *model;
- GtkTreePath *path;
- GtkTreeIter iter;
- GckAttributes *attrs;
- gboolean has_key;
- GckBuilder *builder;
- GckUriData uri_data = { 0, };
- gchar *uri;
-
- gtk_tree_view_get_cursor (priv->objects_view, &path, NULL);
- if (path == NULL)
- return NULL;
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->objects_view));
- if (!gtk_tree_model_get_iter (model, &iter, path))
- g_return_val_if_reached (NULL);
-
- gtk_tree_model_get (model, &iter,
- COLUMN_HAS_KEY, &has_key,
- COLUMN_ATTRIBUTES, &attrs, -1);
-
- builder = gck_builder_new (GCK_BUILDER_NONE);
- if (has_key) {
- /* We do have a object with matching id in the other store (a key)
- * but its other properties (label) may be unset or missing.
- * Still, we want an URI that matches both. */
- gck_builder_add_only (builder, attrs, CKA_ID, GCK_INVALID);
- } else {
- gck_builder_add_all (builder, attrs);
- }
-
- uri_data.attributes = gck_builder_end (builder);
- uri_data.token_info = gck_slot_get_token_info (priv->slot);
- uri = gck_uri_build (&uri_data, GCK_URI_FOR_OBJECT_ON_TOKEN);
-
- gck_attributes_unref (uri_data.attributes);
- gck_attributes_unref (attrs);
-
- return uri;
-}
-
-/**
- * nma_pkcs11_cert_chooser_dialog_get_pin:
- * @dialog: the #NMAPkcs11CertChooserDialog instance
- *
- * Obtain the PIN that was used to unlock the token.
- *
- * Returns: the PIN, %NULL if the token was not logged into or an emtpy
- * string ("") if the protected authentication path was used.
- */
-gchar *
-nma_pkcs11_cert_chooser_dialog_get_pin (NMAPkcs11CertChooserDialog *dialog)
-{
- NMAPkcs11CertChooserDialogPrivate *priv = NMA_PKCS11_CERT_CHOOSER_DIALOG_GET_PRIVATE (dialog);
-
- return g_strdup ((gchar *) priv->pin_value);
-}
-
-/**
- * nma_pkcs11_cert_chooser_dialog_get_remember_pin:
- * @dialog: the #NMAPkcs11CertChooserDialog instance
- *
- * Obtain the value of the "Remember PIN" checkbox during the token login.
- *
- * Returns: TRUE if the user chose to remember the PIN, FALSE
- * if not or if the tokin was not logged into at all.
- */
-gboolean
-nma_pkcs11_cert_chooser_dialog_get_remember_pin (NMAPkcs11CertChooserDialog *dialog)
-{
- NMAPkcs11CertChooserDialogPrivate *priv = NMA_PKCS11_CERT_CHOOSER_DIALOG_GET_PRIVATE (dialog);
-
- return priv->remember_pin;
-}
-
-/**
- * nma_pkcs11_cert_chooser_dialog_new:
- * @slot: the PKCS\#11 slot the token is in
- * @object_class: CKA_CLASS of object to be selected
- * @title: The dialog window title
- * @parent: (allow-none): The parent window or %NULL
- * @flags: The dialog flags
- * @first_button_text: (allow-none): The text of the first button
- * @...: response ID for the first button, texts and response ids for other buttons, terminated with %NULL
- *
- * Creates the new #NMAPkcs11CertChooserDialog.
- *
- * Returns: newly created #NMAPkcs11CertChooserDialog
- */
-
-GtkWidget *
-nma_pkcs11_cert_chooser_dialog_new (GckSlot *slot,
- CK_OBJECT_CLASS object_class,
- const gchar *title,
- GtkWindow *parent,
- GtkDialogFlags flags,
- const gchar *first_button_text,
- ...)
-{
- GtkWidget *result;
- va_list varargs;
-
- va_start (varargs, first_button_text);
- result = nma_pkcs11_cert_chooser_dialog_new_valist (slot,
- object_class,
- title,
- parent,
- flags,
- first_button_text,
- varargs);
- va_end (varargs);
-
- return result;
-}
diff --git a/src/libnma/nma-pkcs11-cert-chooser-dialog.h b/src/libnma/nma-pkcs11-cert-chooser-dialog.h
deleted file mode 100644
index ced388ab..00000000
--- a/src/libnma/nma-pkcs11-cert-chooser-dialog.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// SPDX-License-Identifier: LGPL-2.1+
-/* NetworkManager Applet -- allow user control over networking
- *
- * Lubomir Rintel <lkundrak@v3.sk>
- *
- * Copyright (C) 2016,2017 Red Hat, Inc.
- */
-
-#ifndef __NMA_PKCS11_CERT_CHOOSER_DIALOG_H__
-#define __NMA_PKCS11_CERT_CHOOSER_DIALOG_H__
-
-#include <gtk/gtk.h>
-#include <gck/gck.h>
-
-typedef struct _NMAPkcs11CertChooserDialogPrivate NMAPkcs11CertChooserDialogPrivate;
-
-typedef struct {
- GtkDialog parent;
- NMAPkcs11CertChooserDialogPrivate *priv;
-} NMAPkcs11CertChooserDialog;
-
-typedef struct {
- GtkDialogClass parent;
-} NMAPkcs11CertChooserDialogClass;
-
-#define NMA_TYPE_PKCS11_CERT_CHOOSER_DIALOG (nma_pkcs11_cert_chooser_dialog_get_type ())
-#define NMA_PKCS11_CERT_CHOOSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMA_TYPE_PKCS11_CERT_CHOOSER_DIALOG, NMAPkcs11CertChooserDialog))
-#define NMA_PKCS11_CERT_CHOOSER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMA_TYPE_PKCS11_CERT_CHOOSER_DIALOG, NMAPkcs11CertChooserDialogClass))
-#define NMA_IS_PKCS11_CERT_CHOOSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMA_TYPE_PKCS11_CERT_CHOOSER_DIALOG))
-#define NMA_IS_PKCS11_CERT_CHOOSER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMA_TYPE_PKCS11_CERT_CHOOSER_DIALOG))
-#define NMA_PKCS11_CERT_CHOOSER_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMA_TYPE_PKCS11_CERT_CHOOSER_DIALOG, NMAPkcs11CertChooserDialogClass))
-
-GType nma_pkcs11_cert_chooser_dialog_get_type (void);
-
-GtkWidget *nma_pkcs11_cert_chooser_dialog_new (GckSlot *slot,
- CK_OBJECT_CLASS object_class,
- const gchar *title,
- GtkWindow *parent,
- GtkDialogFlags flags,
- const gchar *first_button_text,
- ...);
-
-gchar *nma_pkcs11_cert_chooser_dialog_get_uri (NMAPkcs11CertChooserDialog *dialog);
-
-gchar *nma_pkcs11_cert_chooser_dialog_get_pin (NMAPkcs11CertChooserDialog *dialog);
-
-gboolean nma_pkcs11_cert_chooser_dialog_get_remember_pin (NMAPkcs11CertChooserDialog *dialog);
-
-#endif /* __NMA_PKCS11_CERT_CHOOSER_DIALOG_H__ */
diff --git a/src/libnma/nma-pkcs11-cert-chooser-dialog.ui b/src/libnma/nma-pkcs11-cert-chooser-dialog.ui
deleted file mode 100644
index 3141dba8..00000000
--- a/src/libnma/nma-pkcs11-cert-chooser-dialog.ui
+++ /dev/null
@@ -1,153 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
-<interface domain="gtk30">
- <requires lib="gtk+" version="3.10"/>
- <template class="NMAPkcs11CertChooserDialog" parent="GtkDialog">
- <property name="can_focus">False</property>
- <property name="role">NMAPkcs11CertChooserDialog</property>
- <property name="type_hint">dialog</property>
- <child internal-child="vbox">
- <object class="GtkBox" id="dialog-vbox1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <child internal-child="action_area">
- <object class="GtkButtonBox" id="dialog-action_area1">
- <property name="can_focus">False</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="login_button">
- <property name="label" translatable="yes">_Unlock token</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_underline">True</property>
- <signal name="clicked" handler="login_clicked" swapped="no"/>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="pack_type">end</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkRevealer" id="error_revealer">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkInfoBar" id="error_bar">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="message_type">error</property>
- <property name="show_close_button">True</property>
- <signal name="response" handler="error_close" swapped="no"/>
- <child internal-child="action_area">
- <object class="GtkButtonBox">
- <property name="can_focus">False</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child internal-child="content_area">
- <object class="GtkBox">
- <property name="can_focus">False</property>
- <child>
- <object class="GtkLabel" id="error_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkScrolledWindow">
- <property name="width_request">300</property>
- <property name="height_request">200</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hscrollbar_policy">never</property>
- <child>
- <object class="GtkTreeView" id="objects_view">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="enable_search">False</property>
- <signal name="cursor-changed" handler="cursor_changed" swapped="no"/>
- <signal name="row-activated" handler="row_activated" swapped="no"/>
- <child internal-child="selection">
- <object class="GtkTreeSelection" id="objects_view_selection"/>
- </child>
- <child>
- <object class="GtkTreeViewColumn" id="list_name_column">
- <property name="title" translatable="yes">Name</property>
- <child>
- <object class="GtkCellRendererText" id="list_name_renderer">
- <property name="xpad">6</property>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkTreeViewColumn" id="list_issued_by_column">
- <property name="title" translatable="yes">Issued By</property>
- <child>
- <object class="GtkCellRendererText" id="list_issued_by_renderer">
- <property name="xpad">6</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- </template>
-</interface>
diff --git a/src/libnma/nma-pkcs11-cert-chooser.c b/src/libnma/nma-pkcs11-cert-chooser.c
deleted file mode 100644
index 8e45138e..00000000
--- a/src/libnma/nma-pkcs11-cert-chooser.c
+++ /dev/null
@@ -1,559 +0,0 @@
-// SPDX-License-Identifier: LGPL-2.1+
-/* NetworkManager Applet -- allow user control over networking
- *
- * Lubomir Rintel <lkundrak@v3.sk>
- *
- * Copyright (C) 2017,2018 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-#include "nma-private.h"
-#include "nma-cert-chooser-private.h"
-#include "nma-cert-chooser-button.h"
-#include "nma-ui-utils.h"
-#include "utils.h"
-
-#include <glib/gstdio.h>
-#include <gck/gck.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#define NMA_PKCS11_CERT_CHOOSER_GET_PRIVATE(self) (&(_NM_GET_PRIVATE (self, NMACertChooser, NMA_IS_CERT_CHOOSER)->_sub.pkcs11))
-
-static void
-set_key_password (NMACertChooser *cert_chooser, const gchar *password)
-{
- NMAPkcs11CertChooserPrivate *priv = NMA_PKCS11_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
-
- g_return_if_fail (priv->key_password != NULL);
- if (password)
- gtk_editable_set_text (GTK_EDITABLE (priv->key_password), password);
-}
-
-static const gchar *
-get_key_password (NMACertChooser *cert_chooser)
-{
- NMAPkcs11CertChooserPrivate *priv = NMA_PKCS11_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
- const gchar *text;
-
- g_return_val_if_fail (priv->key_password != NULL, NULL);
- text = gtk_editable_get_text (GTK_EDITABLE (priv->key_password));
-
- return text && text[0] ? text : NULL;
-}
-
-static void
-set_key_uri (NMACertChooser *cert_chooser, const gchar *uri)
-{
- NMAPkcs11CertChooserPrivate *priv = NMA_PKCS11_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
-
- gtk_widget_set_sensitive (priv->key_button, TRUE);
- gtk_widget_set_sensitive (priv->key_button_label, TRUE);
- gtk_widget_set_sensitive (priv->key_password, TRUE);
- gtk_widget_set_sensitive (priv->key_password_label, TRUE);
- gtk_widget_show (priv->key_password);
- gtk_widget_show (priv->key_password_label);
- gtk_widget_show (priv->show_password);
- nma_cert_chooser_button_set_uri (NMA_CERT_CHOOSER_BUTTON (priv->key_button), uri);
-}
-
-static gchar *
-get_key_uri (NMACertChooser *cert_chooser)
-{
- NMAPkcs11CertChooserPrivate *priv = NMA_PKCS11_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
-
- return g_strdup (nma_cert_chooser_button_get_uri (NMA_CERT_CHOOSER_BUTTON (priv->key_button)));
-}
-
-static void
-set_cert_password (NMACertChooser *cert_chooser, const gchar *password)
-{
- NMAPkcs11CertChooserPrivate *priv = NMA_PKCS11_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
-
- g_return_if_fail (priv->cert_password != NULL);
- if (password)
- gtk_editable_set_text (GTK_EDITABLE (priv->cert_password), password);
-}
-
-static const gchar *
-get_cert_password (NMACertChooser *cert_chooser)
-{
- NMAPkcs11CertChooserPrivate *priv = NMA_PKCS11_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
- const gchar *text;
-
- g_return_val_if_fail (priv->cert_password != NULL, NULL);
- text = gtk_editable_get_text (GTK_EDITABLE (priv->cert_password));
-
- return text && text[0] ? text : NULL;
-}
-
-static void
-set_cert_uri (NMACertChooser *cert_chooser, const gchar *uri)
-{
- NMAPkcs11CertChooserPrivate *priv = NMA_PKCS11_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
-
- if (g_str_has_prefix (uri, NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH)) {
- gtk_widget_set_sensitive (priv->cert_password, FALSE);
- gtk_widget_set_sensitive (priv->cert_password_label, FALSE);
- } else if (g_str_has_prefix (uri, NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PKCS11)) {
- gtk_widget_set_sensitive (priv->cert_password, TRUE);
- gtk_widget_set_sensitive (priv->cert_password_label, TRUE);
- gtk_widget_show (priv->cert_password);
- gtk_widget_show (priv->cert_password_label);
- gtk_widget_show (priv->show_password);
- } else {
- g_warning ("The certificate '%s' uses an unknown scheme\n", uri);
- return;
- }
-
- nma_cert_chooser_button_set_uri (NMA_CERT_CHOOSER_BUTTON (priv->cert_button), uri);
-}
-
-static gchar *
-get_cert_uri (NMACertChooser *cert_chooser)
-{
- NMAPkcs11CertChooserPrivate *priv = NMA_PKCS11_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
-
- return g_strdup (nma_cert_chooser_button_get_uri (NMA_CERT_CHOOSER_BUTTON (priv->cert_button)));
-}
-
-static void
-add_to_size_group (NMACertChooser *cert_chooser, GtkSizeGroup *group)
-{
- NMAPkcs11CertChooserPrivate *priv = NMA_PKCS11_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
-
- gtk_size_group_add_widget (group, priv->cert_button_label);
- gtk_size_group_add_widget (group, priv->cert_password_label);
- gtk_size_group_add_widget (group, priv->key_button_label);
- gtk_size_group_add_widget (group, priv->key_password_label);
-}
-
-static gboolean
-validate (NMACertChooser *cert_chooser, GError **error)
-{
- NMAPkcs11CertChooserPrivate *priv = NMA_PKCS11_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
- GError *local = NULL;
-
- if (!nma_cert_chooser_button_get_uri (NMA_CERT_CHOOSER_BUTTON (priv->cert_button))) {
- g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("No certificate set"));
- return FALSE;
- }
-
- g_signal_emit_by_name (cert_chooser, "cert-validate", &local);
- if (local) {
- widget_set_error (priv->cert_button);
- g_propagate_error (error, local);
- return FALSE;
- } else {
- widget_unset_error (priv->cert_button);
- }
-
- g_signal_emit_by_name (cert_chooser, "cert-password-validate", &local);
- if (local) {
- widget_set_error (priv->cert_password);
- g_propagate_error (error, local);
- return FALSE;
- } else {
- widget_unset_error (priv->cert_password);
- }
-
- if (gtk_widget_get_visible (priv->key_button)) {
- if (!nma_cert_chooser_button_get_uri (NMA_CERT_CHOOSER_BUTTON (priv->cert_button))) {
- g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("No key set"));
- return FALSE;
- }
-
- g_signal_emit_by_name (cert_chooser, "key-validate", &local);
- if (local) {
- widget_set_error (priv->key_button);
- g_propagate_error (error, local);
- return FALSE;
- } else {
- widget_unset_error (priv->key_button);
- }
-
- g_signal_emit_by_name (cert_chooser, "key-password-validate", &local);
- if (local) {
- widget_set_error (priv->key_password);
- g_propagate_error (error, local);
- return FALSE;
- } else {
- widget_unset_error (priv->key_password);
- }
- }
-
- return TRUE;
-}
-
-static void
-setup_key_password_storage (NMACertChooser *cert_chooser,
- NMSettingSecretFlags initial_flags,
- NMSetting *setting,
- const char *password_flags_name,
- gboolean with_not_required,
- gboolean ask_mode)
-{
- NMAPkcs11CertChooserPrivate *priv = NMA_PKCS11_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
-
- nma_utils_setup_password_storage (priv->key_password,
- initial_flags,
- setting,
- password_flags_name,
- with_not_required,
- ask_mode);
-}
-
-static void
-update_key_password_storage (NMACertChooser *cert_chooser,
- NMSettingSecretFlags secret_flags,
- NMSetting *setting,
- const char *password_flags_name)
-{
- NMAPkcs11CertChooserPrivate *priv = NMA_PKCS11_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
-
- nma_utils_update_password_storage (priv->key_password,
- secret_flags,
- setting,
- password_flags_name);
-}
-
-static NMSettingSecretFlags
-get_key_password_flags (NMACertChooser *cert_chooser)
-{
- NMAPkcs11CertChooserPrivate *priv = NMA_PKCS11_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
-
- return nma_utils_menu_to_secret_flags (priv->key_password);
-}
-
-static void
-setup_cert_password_storage (NMACertChooser *cert_chooser,
- NMSettingSecretFlags initial_flags,
- NMSetting *setting,
- const char *password_flags_name,
- gboolean with_not_required,
- gboolean ask_mode)
-{
- NMAPkcs11CertChooserPrivate *priv = NMA_PKCS11_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
-
- nma_utils_setup_password_storage (priv->cert_password,
- initial_flags,
- setting,
- password_flags_name,
- with_not_required,
- ask_mode);
-}
-
-static void
-update_cert_password_storage (NMACertChooser *cert_chooser,
- NMSettingSecretFlags secret_flags,
- NMSetting *setting,
- const char *password_flags_name)
-{
- NMAPkcs11CertChooserPrivate *priv = NMA_PKCS11_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
-
- nma_utils_update_password_storage (priv->cert_password,
- secret_flags,
- setting,
- password_flags_name);
-}
-
-static NMSettingSecretFlags
-get_cert_password_flags (NMACertChooser *cert_chooser)
-{
- NMAPkcs11CertChooserPrivate *priv = NMA_PKCS11_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
-
- return nma_utils_menu_to_secret_flags (priv->cert_password);
-}
-
-static void
-cert_changed_cb (NMACertChooserButton *button, gpointer user_data)
-{
- NMAPkcs11CertChooserPrivate *priv = NMA_PKCS11_CERT_CHOOSER_GET_PRIVATE (NMA_CERT_CHOOSER (user_data));
- GckUriData *uri_data;
- gchar *pin = NULL;
- const gchar *uri;
-
- uri = nma_cert_chooser_button_get_uri (button);
- if (!uri)
- return;
- uri_data = gck_uri_parse (uri, GCK_URI_FOR_OBJECT, NULL);
-
- if (nma_cert_chooser_button_get_remember_pin (button))
- pin = nma_cert_chooser_button_get_pin (button);
- if (pin)
- gtk_editable_set_text (GTK_EDITABLE (priv->cert_password), pin);
-
- gtk_widget_set_sensitive (priv->cert_password, uri_data != NULL);
- gtk_widget_set_sensitive (priv->cert_password_label, uri_data != NULL);
-
- if (!gtk_widget_get_sensitive (priv->key_button)) {
- gtk_widget_set_sensitive (priv->key_button, TRUE);
- gtk_widget_set_sensitive (priv->key_button_label, TRUE);
-
- if (uri_data) {
- /* URI that is good both for a certificate and for a key. */
- if (!gck_attributes_find (uri_data->attributes, CKA_CLASS)) {
- nma_cert_chooser_button_set_uri (NMA_CERT_CHOOSER_BUTTON (priv->key_button), uri);
- gtk_widget_set_sensitive (priv->key_password, TRUE);
- gtk_widget_set_sensitive (priv->key_password_label, TRUE);
- if (pin)
- gtk_editable_set_text (GTK_EDITABLE (priv->key_password), pin);
- }
- }
- }
-
- if (uri_data)
- gck_uri_data_free (uri_data);
- if (pin)
- g_free (pin);
-
- g_signal_emit_by_name (user_data, "changed");
-}
-
-static void
-key_changed_cb (NMACertChooserButton *button, gpointer user_data)
-{
- NMAPkcs11CertChooserPrivate *priv = NMA_PKCS11_CERT_CHOOSER_GET_PRIVATE (NMA_CERT_CHOOSER (user_data));
- gchar *pin = NULL;
-
- if (nma_cert_chooser_button_get_remember_pin (button))
- pin = nma_cert_chooser_button_get_pin (button);
- if (pin) {
- gtk_editable_set_text (GTK_EDITABLE (priv->key_password), pin);
- g_free (pin);
- }
-
- gtk_widget_set_sensitive (priv->key_password, TRUE);
- gtk_widget_set_sensitive (priv->key_password_label, TRUE);
- g_signal_emit_by_name (user_data, "changed");
-}
-
-static void
-key_password_changed_cb (GtkEntry *entry, gpointer user_data)
-{
- g_signal_emit_by_name (user_data, "changed");
-}
-
-static void
-cert_password_changed_cb (GtkEntry *entry, gpointer user_data)
-{
- g_signal_emit_by_name (user_data, "changed");
-}
-
-
-static void
-show_toggled_cb (GtkCheckButton *button, gpointer user_data)
-{
- NMAPkcs11CertChooserPrivate *priv = NMA_PKCS11_CERT_CHOOSER_GET_PRIVATE (NMA_CERT_CHOOSER (user_data));
- gboolean active;
-
- active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
- gtk_entry_set_visibility (GTK_ENTRY (priv->cert_password), active);
- if (priv->key_password)
- gtk_entry_set_visibility (GTK_ENTRY (priv->key_password), active);
-}
-
-static void
-set_title (NMACertChooser *cert_chooser, const gchar *title)
-{
- NMAPkcs11CertChooserPrivate *priv = NMA_PKCS11_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
- gs_free gchar *mnemonic_escaped = NULL;
- gchar *text;
- char **split;
-
- split = g_strsplit (title, "_", -1);
- mnemonic_escaped = g_strjoinv("__", split);
- g_strfreev (split);
-
- text = g_strdup_printf (_("Choose a key for %s Certificate"), title);
- nma_cert_chooser_button_set_title (NMA_CERT_CHOOSER_BUTTON (priv->key_button), text);
- g_free (text);
-
- text = g_strdup_printf (_("%s private _key"), mnemonic_escaped);
- gtk_label_set_text_with_mnemonic (GTK_LABEL (priv->key_button_label), text);
- g_free (text);
-
- text = g_strdup_printf (_("%s key _password"), mnemonic_escaped);
- gtk_label_set_text_with_mnemonic (GTK_LABEL (priv->key_password_label), text);
- g_free (text);
-
- text = g_strdup_printf (_("Choose a %s Certificate"), title);
- nma_cert_chooser_button_set_title (NMA_CERT_CHOOSER_BUTTON (priv->cert_button), text);
- g_free (text);
-
- text = g_strdup_printf (_("%s _certificate"), mnemonic_escaped);
- gtk_label_set_text_with_mnemonic (GTK_LABEL (priv->cert_button_label), text);
- g_free (text);
-
- text = g_strdup_printf (_("%s certificate _password"), mnemonic_escaped);
- gtk_label_set_text_with_mnemonic (GTK_LABEL (priv->cert_password_label), text);
- g_free (text);
-}
-
-static void
-set_flags (NMACertChooser *cert_chooser, NMACertChooserFlags flags)
-{
- NMAPkcs11CertChooserPrivate *priv = NMA_PKCS11_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
-
- if (flags & NMA_CERT_CHOOSER_FLAG_CERT) {
- gtk_widget_hide (priv->key_button);
- gtk_widget_hide (priv->key_button_label);
- gtk_widget_hide (priv->key_password);
- gtk_widget_hide (priv->key_password_label);
- }
-
- if (flags & NMA_CERT_CHOOSER_FLAG_PASSWORDS) {
- gtk_widget_hide (priv->cert_button);
- gtk_widget_hide (priv->cert_button_label);
- gtk_widget_hide (priv->key_button);
- gtk_widget_hide (priv->key_button_label);
-
- /* With FLAG_PASSWORDS the user can't pick a different key or a
- * certificate, so there's no point in showing inactive password
- * inputs. */
- if (!gtk_widget_get_sensitive (priv->cert_password)) {
- gtk_widget_hide (priv->cert_password);
- gtk_widget_hide (priv->cert_password_label);
- }
- if (!gtk_widget_get_sensitive (priv->key_password)) {
- gtk_widget_hide (priv->key_password);
- gtk_widget_hide (priv->key_password_label);
- }
- if ( !gtk_widget_get_visible (priv->cert_password)
- && !gtk_widget_get_visible (priv->key_password)) {
- gtk_widget_hide (priv->show_password);
- }
- }
-}
-
-static void
-init (NMACertChooser *cert_chooser)
-{
- NMAPkcs11CertChooserPrivate *priv = NMA_PKCS11_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
-
- gtk_grid_insert_column (GTK_GRID (cert_chooser), 2);
- gtk_grid_set_row_spacing (GTK_GRID (cert_chooser), 6);
- gtk_grid_set_column_spacing (GTK_GRID (cert_chooser), 6);
-
- /* Show password */
- gtk_grid_insert_row (GTK_GRID (cert_chooser), 0);
- priv->show_password = gtk_check_button_new_with_mnemonic _("Sho_w passwords");
- gtk_grid_attach (GTK_GRID (cert_chooser), priv->show_password, 1, 2, 1, 1);
- gtk_widget_show (priv->show_password);
- gtk_widget_set_no_show_all (priv->show_password, TRUE);
- g_signal_connect (priv->show_password, "toggled",
- G_CALLBACK (show_toggled_cb), cert_chooser);
-
- /* The key chooser */
- gtk_grid_insert_row (GTK_GRID (cert_chooser), 0);
-
- priv->key_button = nma_cert_chooser_button_new (NMA_CERT_CHOOSER_BUTTON_FLAG_KEY);
-
- gtk_grid_attach (GTK_GRID (cert_chooser), priv->key_button, 1, 0, 1, 1);
- gtk_widget_set_hexpand (priv->key_button, TRUE);
- gtk_widget_set_sensitive (priv->key_button, FALSE);
- gtk_widget_show (priv->key_button);
- gtk_widget_set_no_show_all (priv->key_button, TRUE);
-
- g_signal_connect (priv->key_button, "changed",
- G_CALLBACK (key_changed_cb), cert_chooser);
-
- priv->key_button_label = gtk_label_new (NULL);
- g_object_set (priv->key_button_label, "xalign", (gfloat) 1, NULL);
- gtk_label_set_mnemonic_widget (GTK_LABEL (priv->key_button_label), priv->key_button);
- gtk_grid_attach (GTK_GRID (cert_chooser), priv->key_button_label, 0, 0, 1, 1);
- gtk_widget_set_sensitive (priv->key_button_label, FALSE);
- gtk_widget_show (priv->key_button_label);
- gtk_widget_set_no_show_all (priv->key_button_label, TRUE);
-
- /* The key password entry */
- gtk_grid_insert_row (GTK_GRID (cert_chooser), 1);
-
- priv->key_password = gtk_entry_new ();
- gtk_entry_set_visibility (GTK_ENTRY (priv->key_password), FALSE);
- gtk_grid_attach (GTK_GRID (cert_chooser), priv->key_password, 1, 1, 1, 1);
- gtk_widget_set_hexpand (priv->key_password, TRUE);
- gtk_widget_set_sensitive (priv->key_password, FALSE);
- gtk_widget_show (priv->key_password);
- gtk_widget_set_no_show_all (priv->key_password, TRUE);
-
- g_signal_connect (priv->key_password, "changed",
- G_CALLBACK (key_password_changed_cb), cert_chooser);
-
- priv->key_password_label = gtk_label_new (NULL);
- g_object_set (priv->key_password_label, "xalign", (gfloat) 1, NULL);
- gtk_label_set_mnemonic_widget (GTK_LABEL (priv->key_password_label), priv->key_password);
- gtk_grid_attach (GTK_GRID (cert_chooser), priv->key_password_label, 0, 1, 1, 1);
- gtk_widget_set_sensitive (priv->key_password_label, FALSE);
- gtk_widget_show (priv->key_password_label);
- gtk_widget_set_no_show_all (priv->key_password_label, TRUE);
-
- /* The certificate chooser */
- gtk_grid_insert_row (GTK_GRID (cert_chooser), 0);
-
- priv->cert_button = nma_cert_chooser_button_new (NMA_CERT_CHOOSER_BUTTON_FLAG_NONE);
-
- gtk_grid_attach (GTK_GRID (cert_chooser), priv->cert_button, 1, 0, 1, 1);
- gtk_widget_set_hexpand (priv->cert_button, TRUE);
- gtk_widget_show (priv->cert_button);
- gtk_widget_set_no_show_all (priv->cert_button, TRUE);
-
- g_signal_connect (priv->cert_button, "changed",
- G_CALLBACK (cert_changed_cb), cert_chooser);
-
- priv->cert_button_label = gtk_label_new (NULL);
- g_object_set (priv->cert_button_label, "xalign", (gfloat) 1, NULL);
- gtk_label_set_mnemonic_widget (GTK_LABEL (priv->cert_button_label), priv->cert_button);
- gtk_grid_attach (GTK_GRID (cert_chooser), priv->cert_button_label, 0, 0, 1, 1);
- gtk_widget_show (priv->cert_button_label);
- gtk_widget_set_no_show_all (priv->cert_button_label, TRUE);
-
- /* The cert password entry */
- gtk_grid_insert_row (GTK_GRID (cert_chooser), 1);
-
- priv->cert_password = gtk_entry_new ();
- gtk_entry_set_visibility (GTK_ENTRY (priv->cert_password), FALSE);
- gtk_grid_attach (GTK_GRID (cert_chooser), priv->cert_password, 1, 1, 1, 1);
- gtk_widget_set_hexpand (priv->cert_password, TRUE);
- gtk_widget_set_sensitive (priv->cert_password, FALSE);
- gtk_widget_show (priv->cert_password);
- gtk_widget_set_no_show_all (priv->cert_password, TRUE);
-
- g_signal_connect (priv->cert_password, "changed",
- G_CALLBACK (cert_password_changed_cb), cert_chooser);
-
- priv->cert_password_label = gtk_label_new (NULL);
- g_object_set (priv->cert_password_label, "xalign", (gfloat) 1, NULL);
- gtk_label_set_mnemonic_widget (GTK_LABEL (priv->cert_password_label), priv->cert_password);
- gtk_grid_attach (GTK_GRID (cert_chooser), priv->cert_password_label, 0, 1, 1, 1);
- gtk_widget_set_sensitive (priv->cert_password_label, FALSE);
- gtk_widget_show (priv->cert_password_label);
- gtk_widget_set_no_show_all (priv->cert_password_label, TRUE);
-}
-
-const NMACertChooserVtable nma_cert_chooser_vtable_pkcs11 = {
- .init = init,
-
- .set_title = set_title,
- .set_flags = set_flags,
- .set_cert_uri = set_cert_uri,
- .get_cert_uri = get_cert_uri,
-
- .set_cert_password = set_cert_password,
- .get_cert_password = get_cert_password,
- .set_key_uri = set_key_uri,
- .get_key_uri = get_key_uri,
- .set_key_password = set_key_password,
- .get_key_password = get_key_password,
-
- .add_to_size_group = add_to_size_group,
- .validate = validate,
-
- .setup_key_password_storage = setup_key_password_storage,
- .update_key_password_storage = update_key_password_storage,
- .get_key_password_flags = get_key_password_flags,
- .setup_cert_password_storage = setup_cert_password_storage,
- .update_cert_password_storage = update_cert_password_storage,
- .get_cert_password_flags = get_cert_password_flags,
-};
diff --git a/src/libnma/nma-pkcs11-token-login-dialog.c b/src/libnma/nma-pkcs11-token-login-dialog.c
deleted file mode 100644
index f141ce74..00000000
--- a/src/libnma/nma-pkcs11-token-login-dialog.c
+++ /dev/null
@@ -1,236 +0,0 @@
-// SPDX-License-Identifier: LGPL-2.1+
-/* NetworkManager Applet -- allow user control over networking
- *
- * Lubomir Rintel <lkundrak@v3.sk>
- *
- * Copyright (C) 2016,2017 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-#include "nma-pkcs11-token-login-dialog.h"
-
-#include <gck/gck.h>
-
-/**
- * SECTION:nma-pkcs11-token-login-dialog
- * @title: NMAPkcs11TokenLoginDialog
- * @short_description: The PKCS\#11 PIN Dialog
- * @see_also: #GcrObjectChooserDialog
- *
- * #NMAPkcs11TokenLoginDialog asks for the PKCS\#11 login PIN.
- * It enforces the PIN constrains (maximum & minimum length).
- *
- * Used by the #GcrObjectChooserDialog when the #GcrTokensSidebar indicates
- * that the user requested the token to be logged in.
- */
-
-struct _NMAPkcs11TokenLoginDialogPrivate
-{
- GckSlot *slot;
- GckTokenInfo *info;
-
- GtkEntry *pin_entry;
- GtkCheckButton *remember;
-};
-
-G_DEFINE_TYPE_WITH_CODE (NMAPkcs11TokenLoginDialog, nma_pkcs11_token_login_dialog, GTK_TYPE_DIALOG,
- G_ADD_PRIVATE (NMAPkcs11TokenLoginDialog));
-
-enum
-{
- PROP_0,
- PROP_TOKEN_SLOT,
-};
-
-/**
- * nma_pkcs11_token_login_dialog_get_pin_value:
- * @self: The #NMAPkcs11TokenLoginDialog
- *
- * Returns: the entered PIN
- */
-
-const guchar *
-nma_pkcs11_token_login_dialog_get_pin_value (NMAPkcs11TokenLoginDialog *self)
-{
- NMAPkcs11TokenLoginDialogPrivate *priv = self->priv;
- GtkEntryBuffer *buffer = gtk_entry_get_buffer (priv->pin_entry);
-
- return (guchar *) gtk_entry_buffer_get_text (buffer);
-}
-
-/**
- * nma_pkcs11_token_login_dialog_get_pin_length:
- * @self: The #NMAPkcs11TokenLoginDialog
- *
- * Returns: the PIN length
- */
-
-gulong
-nma_pkcs11_token_login_dialog_get_pin_length (NMAPkcs11TokenLoginDialog *self)
-{
- NMAPkcs11TokenLoginDialogPrivate *priv = self->priv;
- GtkEntryBuffer *buffer = gtk_entry_get_buffer (priv->pin_entry);
-
- return gtk_entry_buffer_get_bytes (buffer);
-}
-
-/**
- * nma_pkcs11_token_login_dialog_get_remember_pin:
- * @self: The #NMAPkcs11TokenLoginDialog
- *
- * Returns: %TRUE if the "Remember PIN" checkbox was checked
- */
-
-gboolean
-nma_pkcs11_token_login_dialog_get_remember_pin (NMAPkcs11TokenLoginDialog *self)
-{
- NMAPkcs11TokenLoginDialogPrivate *priv = self->priv;
-
- return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->remember));
-}
-
-static void
-get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
-{
- NMAPkcs11TokenLoginDialog *self = NMA_PKCS11_TOKEN_LOGIN_DIALOG (object);
- NMAPkcs11TokenLoginDialogPrivate *priv = self->priv;
-
- switch (prop_id) {
- case PROP_TOKEN_SLOT:
- if (priv->slot)
- g_value_set_object (value, priv->slot);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
-}
-
-static gboolean
-can_activate (NMAPkcs11TokenLoginDialog *self)
-{
- NMAPkcs11TokenLoginDialogPrivate *priv = self->priv;
- GtkEntryBuffer *buffer = gtk_entry_get_buffer (priv->pin_entry);
- guint len = gtk_entry_buffer_get_length (buffer);
-
- return len <= priv->info->max_pin_len && len >= priv->info->min_pin_len;
-}
-
-static void
-set_slot (NMAPkcs11TokenLoginDialog *self, GckSlot *slot)
-{
- NMAPkcs11TokenLoginDialogPrivate *priv = self->priv;
- gchar *title;
-
- g_clear_object (&priv->slot);
- if (priv->info)
- gck_token_info_free (priv->info);
-
- priv->slot = slot;
- priv->info = gck_slot_get_token_info (slot);
- g_return_if_fail (priv->info);
-
- title = g_strdup_printf (_("Enter %s PIN"), priv->info->label);
- gtk_window_set_title (GTK_WINDOW (self), title);
- g_free (title);
-
- gtk_entry_set_max_length (priv->pin_entry, priv->info->max_pin_len);
- gtk_dialog_set_response_sensitive (GTK_DIALOG (self), GTK_RESPONSE_ACCEPT,
- can_activate (self));
-}
-
-
-static void
-set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
-{
- NMAPkcs11TokenLoginDialog *self = NMA_PKCS11_TOKEN_LOGIN_DIALOG (object);
-
- switch (prop_id) {
- case PROP_TOKEN_SLOT:
- set_slot (self, g_value_dup_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
-}
-
-static void
-finalize (GObject *object)
-{
- NMAPkcs11TokenLoginDialog *self = NMA_PKCS11_TOKEN_LOGIN_DIALOG (object);
- NMAPkcs11TokenLoginDialogPrivate *priv = self->priv;
-
- g_clear_object (&priv->slot);
- if (priv->info) {
- gck_token_info_free (priv->info);
- priv->info = NULL;
- }
-
- G_OBJECT_CLASS (nma_pkcs11_token_login_dialog_parent_class)->finalize (object);
-}
-
-static void
-pin_changed (GtkEditable *editable, gpointer user_data)
-{
- gtk_dialog_set_response_sensitive (GTK_DIALOG (user_data), GTK_RESPONSE_ACCEPT,
- can_activate (NMA_PKCS11_TOKEN_LOGIN_DIALOG (user_data)));
-}
-
-
-static void
-pin_activate (GtkEditable *editable, gpointer user_data)
-{
- if (can_activate (NMA_PKCS11_TOKEN_LOGIN_DIALOG (user_data)))
- gtk_dialog_response (GTK_DIALOG (user_data), GTK_RESPONSE_ACCEPT);
-}
-
-static void
-nma_pkcs11_token_login_dialog_class_init (NMAPkcs11TokenLoginDialogClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
- object_class->get_property = get_property;
- object_class->set_property = set_property;
- object_class->finalize = finalize;
-
- /**
- * NMAPkcs11TokenLoginDialog::token-slot:
- *
- * Slot that contains the pin for which the dialog requests
- * the PIN.
- */
- g_object_class_install_property (object_class, PROP_TOKEN_SLOT,
- g_param_spec_object ("token-slot", "Slot", "Slot containing the Token",
- GCK_TYPE_SLOT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- gtk_widget_class_set_template_from_resource (widget_class, "/org/freedesktop/network-manager-applet/nma-pkcs11-token-login-dialog.ui");
- gtk_widget_class_bind_template_child_private (widget_class, NMAPkcs11TokenLoginDialog, pin_entry);
- gtk_widget_class_bind_template_child_private (widget_class, NMAPkcs11TokenLoginDialog, remember);
- gtk_widget_class_bind_template_callback (widget_class, pin_changed);
- gtk_widget_class_bind_template_callback (widget_class, pin_activate);
-}
-
-static void
-nma_pkcs11_token_login_dialog_init (NMAPkcs11TokenLoginDialog *self)
-{
- self->priv = nma_pkcs11_token_login_dialog_get_instance_private (self);
-
- gtk_widget_init_template (GTK_WIDGET (self));
-}
-
-/**
- * nma_pkcs11_token_login_dialog_new:
- * @slot: Slot that contains the pin for which the dialog requests the PIN
- *
- * Creates the new PKCS\#11 login dialog.
- *
- * Returns: the newly created #NMAPkcs11TokenLoginDialog
- */
-GtkWidget *
-nma_pkcs11_token_login_dialog_new (GckSlot *slot)
-{
- return GTK_WIDGET (g_object_new (NMA_TYPE_PKCS11_TOKEN_LOGIN_DIALOG,
- "use-header-bar", TRUE,
- "token-slot", slot,
- NULL));
-}
diff --git a/src/libnma/nma-pkcs11-token-login-dialog.h b/src/libnma/nma-pkcs11-token-login-dialog.h
deleted file mode 100644
index fd8e602c..00000000
--- a/src/libnma/nma-pkcs11-token-login-dialog.h
+++ /dev/null
@@ -1,43 +0,0 @@
-// SPDX-License-Identifier: LGPL-2.1+
-/* NetworkManager Applet -- allow user control over networking
- *
- * Lubomir Rintel <lkundrak@v3.sk>
- *
- * Copyright (C) 2017 Red Hat, Inc.
- */
-
-#ifndef __NMA_PKCS11_TOKEN_LOGIN_DIALOG_H__
-#define __NMA_PKCS11_TOKEN_LOGIN_DIALOG_H__
-
-#include <gtk/gtk.h>
-#include <gck/gck.h>
-
-typedef struct _NMAPkcs11TokenLoginDialogPrivate NMAPkcs11TokenLoginDialogPrivate;
-
-typedef struct {
- GtkDialog parent;
- NMAPkcs11TokenLoginDialogPrivate *priv;
-} NMAPkcs11TokenLoginDialog;
-
-typedef struct {
- GtkDialog parent;
-} NMAPkcs11TokenLoginDialogClass;
-
-#define NMA_TYPE_PKCS11_TOKEN_LOGIN_DIALOG (nma_pkcs11_token_login_dialog_get_type ())
-#define NMA_PKCS11_TOKEN_LOGIN_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMA_TYPE_PKCS11_TOKEN_LOGIN_DIALOG, NMAPkcs11TokenLoginDialog))
-#define NMA_PKCS11_TOKEN_LOGIN_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMA_TYPE_PKCS11_TOKEN_LOGIN_DIALOG, NMAPkcs11TokenLoginDialogClass))
-#define NMA_IS_PKCS11_TOKEN_LOGIN_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMA_TYPE_PKCS11_TOKEN_LOGIN_DIALOG))
-#define NMA_IS_PKCS11_TOKEN_LOGIN_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMA_TYPE_PKCS11_TOKEN_LOGIN_DIALOG))
-#define NMA_PKCS11_TOKEN_LOGIN_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMA_TYPE_PKCS11_TOKEN_LOGIN_DIALOG, NMAPkcs11TokenLoginDialogClass))
-
-GType nma_pkcs11_token_login_dialog_get_type (void);
-
-GtkWidget *nma_pkcs11_token_login_dialog_new (GckSlot *slot);
-
-const guchar *nma_pkcs11_token_login_dialog_get_pin_value (NMAPkcs11TokenLoginDialog *self);
-
-gulong nma_pkcs11_token_login_dialog_get_pin_length (NMAPkcs11TokenLoginDialog *self);
-
-gboolean nma_pkcs11_token_login_dialog_get_remember_pin (NMAPkcs11TokenLoginDialog *self);
-
-#endif /* __NMA_PKCS11_TOKEN_LOGIN_DIALOG_H__ */
diff --git a/src/libnma/nma-pkcs11-token-login-dialog.ui b/src/libnma/nma-pkcs11-token-login-dialog.ui
deleted file mode 100644
index 147596b1..00000000
--- a/src/libnma/nma-pkcs11-token-login-dialog.ui
+++ /dev/null
@@ -1,111 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
-<interface domain="nm-applet">
- <requires lib="gtk+" version="3.10"/>
- <template class="NMAPkcs11TokenLoginDialog" parent="GtkDialog">
- <property name="can_focus">False</property>
- <property name="type_hint">dialog</property>
- <child internal-child="vbox">
- <object class="GtkBox">
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">2</property>
- <child internal-child="action_area">
- <object class="GtkButtonBox">
- <property name="can_focus">False</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="cancel">
- <property name="label" translatable="yes">_Cancel</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="pack_type">end</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="login">
- <property name="label" translatable="yes">_Login</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_start">12</property>
- <property name="margin_end">12</property>
- <property name="margin_top">12</property>
- <property name="margin_bottom">12</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkEntry" id="pin_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="visibility">False</property>
- <property name="input_purpose">password</property>
- <signal name="activate" handler="pin_activate" swapped="no"/>
- <signal name="changed" handler="pin_changed" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="padding">6</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="remember">
- <property name="label" translatable="yes">_Remember PIN</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="halign">start</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="padding">6</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- <action-widgets>
- <action-widget response="-6">cancel</action-widget>
- <action-widget response="-3">login</action-widget>
- </action-widgets>
- </template>
-</interface>
diff --git a/src/libnma/nma-private.h b/src/libnma/nma-private.h
deleted file mode 100644
index 8470fbf3..00000000
--- a/src/libnma/nma-private.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/* NetworkManager Applet -- allow user control over networking
- *
- * Lubomir Rintel <lkundrak@v3.sk>
- *
- * Copyright (C) 2019 Red Hat, Inc.
- */
-
-#ifndef NMA_PRIVATE_H
-
-#if !GTK_CHECK_VERSION(3,96,0)
-#define gtk_editable_set_text(editable,text) gtk_entry_set_text(GTK_ENTRY(editable), (text))
-#define gtk_editable_get_text(editable) gtk_entry_get_text(GTK_ENTRY(editable))
-#define gtk_editable_set_width_chars(editable, n_chars) gtk_entry_set_width_chars(GTK_ENTRY(editable), (n_chars))
-#endif
-
-void nma_gtk_widget_activate_default (GtkWidget *widget);
-
-#define NMA_PRIVATE_H
-
-#endif /* NMA_PRIVATE_H */
diff --git a/src/libnma/nma-ui-utils.c b/src/libnma/nma-ui-utils.c
deleted file mode 100644
index d36638ad..00000000
--- a/src/libnma/nma-ui-utils.c
+++ /dev/null
@@ -1,432 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright 2015 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-#include "nma-private.h"
-
-#include <string.h>
-
-#include "nma-ui-utils.h"
-
-/*---------------------------------------------------------------------------*/
-/* Password storage icon */
-
-#define PASSWORD_STORAGE_MENU_TAG "password-storage-menu"
-#define MENU_WITH_NOT_REQUIRED_TAG "menu-with-not-required"
-#define ASK_MODE_TAG "ask-mode"
-
-typedef enum {
- ITEM_STORAGE_USER = 0,
- ITEM_STORAGE_SYSTEM = 1,
- ITEM_STORAGE_ASK = 2,
- ITEM_STORAGE_UNUSED = 3,
- __ITEM_STORAGE_MAX,
- ITEM_STORAGE_MAX = __ITEM_STORAGE_MAX - 1,
-} MenuItem;
-
-static const char *icon_name_table[ITEM_STORAGE_MAX + 1] = {
- [ITEM_STORAGE_USER] = "user-info-symbolic",
- [ITEM_STORAGE_SYSTEM] = "system-users-symbolic",
- [ITEM_STORAGE_ASK] = "dialog-question-symbolic",
- [ITEM_STORAGE_UNUSED] = "edit-clear-all-symbolic",
-};
-static const char *icon_desc_table[ITEM_STORAGE_MAX + 1] = {
- [ITEM_STORAGE_USER] = N_("Store the password only for this user"),
- [ITEM_STORAGE_SYSTEM] = N_("Store the password for all users"),
- [ITEM_STORAGE_ASK] = N_("Ask for this password every time"),
- [ITEM_STORAGE_UNUSED] = N_("The password is not required"),
-};
-
-static void
-g_free_str0 (gpointer mem)
-{
- /* g_free a char pointer and set it to 0 before (for passwords). */
- if (mem) {
- char *p = mem;
- memset (p, 0, strlen (p));
- g_free (p);
- }
-}
-
-static void
-change_password_storage_icon (GtkWidget *passwd_entry, MenuItem item)
-{
- const char *old_pwd;
- gboolean ask_mode;
-
- g_return_if_fail (item >= 0 && item <= ITEM_STORAGE_MAX);
-
- gtk_entry_set_icon_from_icon_name (GTK_ENTRY (passwd_entry),
- GTK_ENTRY_ICON_SECONDARY,
- icon_name_table[item]);
- gtk_entry_set_icon_tooltip_text (GTK_ENTRY (passwd_entry),
- GTK_ENTRY_ICON_SECONDARY,
- _(icon_desc_table[item]));
-
- /* We want to make entry insensitive when ITEM_STORAGE_ASK is selected
- * Unfortunately, making GtkEntry insensitive will also make the icon
- * insensitive, which prevents user from reverting the action.
- * Let's workaround that by disabling focus for entry instead of
- * sensitivity change.
- */
- ask_mode = !!g_object_get_data (G_OBJECT (passwd_entry), ASK_MODE_TAG);
- if ( (item == ITEM_STORAGE_ASK && !ask_mode)
- || item == ITEM_STORAGE_UNUSED) {
- /* Store the old password */
- old_pwd = gtk_editable_get_text (GTK_EDITABLE (passwd_entry));
- if (old_pwd && *old_pwd)
- g_object_set_data_full (G_OBJECT (passwd_entry), "password-old",
- g_strdup (old_pwd), g_free_str0);
- gtk_editable_set_text (GTK_EDITABLE (passwd_entry), "");
-
- if (gtk_widget_is_focus (passwd_entry))
- gtk_widget_child_focus ((gtk_widget_get_toplevel (passwd_entry)), GTK_DIR_TAB_BACKWARD);
- gtk_widget_set_can_focus (passwd_entry, FALSE);
- } else {
- /* Set the old password to the entry */
- old_pwd = g_object_get_data (G_OBJECT (passwd_entry), "password-old");
- if (old_pwd && *old_pwd)
- gtk_editable_set_text (GTK_EDITABLE (passwd_entry), old_pwd);
- g_object_set_data (G_OBJECT (passwd_entry), "password-old", NULL);
-
- if (!gtk_widget_get_can_focus (passwd_entry)) {
- gtk_widget_set_can_focus (passwd_entry, TRUE);
- gtk_widget_grab_focus (passwd_entry);
- }
- }
-}
-
-static MenuItem
-secret_flags_to_menu_item (NMSettingSecretFlags flags, gboolean with_not_required)
-{
- MenuItem idx;
-
- if (flags & NM_SETTING_SECRET_FLAG_NOT_SAVED)
- idx = ITEM_STORAGE_ASK;
- else if (with_not_required && (flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED))
- idx = ITEM_STORAGE_UNUSED;
- else if (flags & NM_SETTING_SECRET_FLAG_AGENT_OWNED)
- idx = ITEM_STORAGE_USER;
- else
- idx = ITEM_STORAGE_SYSTEM;
-
- return idx;
-}
-
-static NMSettingSecretFlags
-menu_item_to_secret_flags (MenuItem item)
-{
- NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE;
-
- switch (item) {
- case ITEM_STORAGE_USER:
- flags |= NM_SETTING_SECRET_FLAG_AGENT_OWNED;
- break;
- case ITEM_STORAGE_ASK:
- flags |= NM_SETTING_SECRET_FLAG_NOT_SAVED;
- break;
- case ITEM_STORAGE_UNUSED:
- flags |= NM_SETTING_SECRET_FLAG_NOT_REQUIRED;
- break;
- case ITEM_STORAGE_SYSTEM:
- default:
- break;
- }
- return flags;
-}
-
-typedef struct {
- NMSetting *setting;
- char *password_flags_name;
- MenuItem item_number;
- GtkWidget *passwd_entry;
-} PopupMenuItemInfo;
-
-static void
-popup_menu_item_info_destroy (gpointer data, GClosure *closure)
-{
- PopupMenuItemInfo *info = (PopupMenuItemInfo *) data;
-
- if (info->setting)
- g_object_unref (info->setting);
- g_clear_pointer (&info->password_flags_name, g_free);
- if (info->passwd_entry)
- g_object_remove_weak_pointer (G_OBJECT (info->passwd_entry), (gpointer *) &info->passwd_entry);
- g_slice_free (PopupMenuItemInfo, info);
-}
-
-static void
-activate_menu_item_cb (GtkMenuItem *menuitem, gpointer user_data)
-{
- PopupMenuItemInfo *info = (PopupMenuItemInfo *) user_data;
- NMSettingSecretFlags flags;
-
- /* Update password flags according to the password-storage popup menu */
- if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (menuitem))) {
- flags = menu_item_to_secret_flags (info->item_number);
-
- /* Update the secret flags in the setting */
- if (info->setting)
- nm_setting_set_secret_flags (info->setting, info->password_flags_name,
- flags, NULL);
-
- /* Change icon */
- if (info->passwd_entry) {
- change_password_storage_icon (info->passwd_entry, info->item_number);
-
- /* Emit "changed" signal on the entry */
- g_signal_emit_by_name (G_OBJECT (info->passwd_entry), "changed");
- }
- }
-}
-
-static void
-popup_menu_item_info_register (GtkWidget *item,
- NMSetting *setting,
- const char *password_flags_name,
- MenuItem item_number,
- GtkWidget *passwd_entry)
-{
- PopupMenuItemInfo *info;
-
- info = g_slice_new0 (PopupMenuItemInfo);
- info->setting = setting ? g_object_ref (setting) : NULL;
- info->password_flags_name = g_strdup (password_flags_name);
- info->item_number = item_number;
- info->passwd_entry = passwd_entry;
-
- if (info->passwd_entry)
- g_object_add_weak_pointer (G_OBJECT (info->passwd_entry), (gpointer *) &info->passwd_entry);
-
- g_signal_connect_data (item, "activate",
- G_CALLBACK (activate_menu_item_cb),
- info,
- (GClosureNotify) popup_menu_item_info_destroy, 0);
-}
-
-void
-nma_gtk_widget_activate_default (GtkWidget *widget)
-{
-#if GTK_CHECK_VERSION(3,90,0)
- gtk_widget_activate_default (widget);
-#else
- gtk_window_activate_default (GTK_WINDOW (widget));
-#endif
-}
-
-static void
-icon_release_cb (GtkEntry *entry,
- GtkEntryIconPosition position,
-#if !GTK_CHECK_VERSION(3,90,0)
- GdkEventButton *event,
-#endif
- gpointer data)
-{
- GtkMenu *menu = GTK_MENU (data);
-#if GTK_CHECK_VERSION(3,90,0)
- GdkRectangle icon_area;
-#endif
-
- if (position == GTK_ENTRY_ICON_SECONDARY) {
-#if GTK_CHECK_VERSION(3,90,0)
- gtk_widget_show (GTK_WIDGET (data));
- gtk_entry_get_icon_area (entry,
- GTK_ENTRY_ICON_SECONDARY,
- &icon_area);
- gtk_menu_popup_at_rect (menu,
- gtk_widget_get_surface (GTK_WIDGET (entry)),
- &icon_area,
- GDK_GRAVITY_CENTER,
- GDK_GRAVITY_CENTER,
- NULL);
-#else
- gtk_widget_show_all (GTK_WIDGET (data));
- gtk_menu_popup (menu, NULL, NULL, NULL, NULL,
- event->button, event->time);
-#endif
- }
-}
-
-/**
- * nma_utils_setup_password_storage:
- * @passwd_entry: password #GtkEntry which the icon is attached to
- * @initial_flags: initial secret flags to setup password menu from
- * @setting: #NMSetting containing the password, or NULL
- * @password_flags_name: name of the secret flags (like psk-flags), or NULL
- * @with_not_required: whether to include "Not required" menu item
- * @ask_mode: %TRUE if the entry is shown in ASK mode. That means,
- * while prompting for a password, contrary to being inside the
- * editor mode.
- * If %TRUE, the entry should be sensivive on selected "always-ask"
- * icon (this is e.f. for nm-applet asking for password), otherwise
- * not.
- * If %TRUE, it shall not be possible to select a different storage,
- * because we only prompt for a password, we cannot change the password
- * location.
- *
- * Adds a secondary icon and creates a popup menu for password entry.
- * The active menu item is set up according to initial_flags, or
- * from @setting/@password_flags_name (if they are not NULL).
- * If the @setting/@password_flags_name are not NULL, secret flags will
- * be automatically updated in the setting when menu is changed.
- */
-void
-nma_utils_setup_password_storage (GtkWidget *passwd_entry,
- NMSettingSecretFlags initial_flags,
- NMSetting *setting,
- const char *password_flags_name,
- gboolean with_not_required,
- gboolean ask_mode)
-{
- GtkWidget *popup_menu;
- GtkWidget *item[4];
- GSList *group;
- MenuItem idx;
- NMSettingSecretFlags secret_flags;
-
- /* Whether entry should be sensitive if "always-ask" is active " */
- g_object_set_data (G_OBJECT (passwd_entry), ASK_MODE_TAG, GUINT_TO_POINTER (ask_mode));
-
- popup_menu = gtk_menu_new ();
- g_object_set_data (G_OBJECT (popup_menu), PASSWORD_STORAGE_MENU_TAG, GUINT_TO_POINTER (TRUE));
- g_object_set_data (G_OBJECT (popup_menu), MENU_WITH_NOT_REQUIRED_TAG, GUINT_TO_POINTER (with_not_required));
- group = NULL;
- item[0] = gtk_radio_menu_item_new_with_label (group, _(icon_desc_table[0]));
- group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (item[0]));
- item[1] = gtk_radio_menu_item_new_with_label (group, _(icon_desc_table[1]));
- item[2] = gtk_radio_menu_item_new_with_label (group, _(icon_desc_table[2]));
- if (with_not_required)
- item[3] = gtk_radio_menu_item_new_with_label (group, _(icon_desc_table[3]));
-
- gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), item[0]);
- gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), item[1]);
- gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), item[2]);
- if (with_not_required)
- gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), item[3]);
-
- popup_menu_item_info_register (item[0], setting, password_flags_name, ITEM_STORAGE_USER, passwd_entry);
- popup_menu_item_info_register (item[1], setting, password_flags_name, ITEM_STORAGE_SYSTEM, passwd_entry);
- popup_menu_item_info_register (item[2], setting, password_flags_name, ITEM_STORAGE_ASK, passwd_entry);
- if (with_not_required)
- popup_menu_item_info_register (item[3], setting, password_flags_name, ITEM_STORAGE_UNUSED, passwd_entry);
-
- g_signal_connect (passwd_entry, "icon-release", G_CALLBACK (icon_release_cb), popup_menu);
- gtk_entry_set_icon_activatable (GTK_ENTRY (passwd_entry), GTK_ENTRY_ICON_SECONDARY,
- !ask_mode);
- gtk_menu_attach_to_widget (GTK_MENU (popup_menu), passwd_entry, NULL);
-
- /* Initialize active item for password-storage popup menu */
- if (setting && password_flags_name)
- nm_setting_get_secret_flags (setting, password_flags_name, &secret_flags, NULL);
- else
- secret_flags = initial_flags;
-
- idx = secret_flags_to_menu_item (secret_flags, with_not_required);
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item[idx]), TRUE);
- change_password_storage_icon (passwd_entry, idx);
-}
-
-/**
- * nma_utils_menu_to_secret_flags:
- * @passwd_entry: password #GtkEntry which the password icon/menu is attached to
- *
- * Returns secret flags corresponding to the selected password storage menu
- * in the attached icon
- *
- * Returns: secret flags corresponding to the active item in password menu
- */
-NMSettingSecretFlags
-nma_utils_menu_to_secret_flags (GtkWidget *passwd_entry)
-{
- GList *menu_list, *iter;
- GtkWidget *menu = NULL;
- NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE;
-
- menu_list = gtk_menu_get_for_attach_widget (passwd_entry);
- for (iter = menu_list; iter; iter = g_list_next (iter)) {
- if (g_object_get_data (G_OBJECT (iter->data), PASSWORD_STORAGE_MENU_TAG)) {
- menu = iter->data;
- break;
- }
- }
-
- /* Translate password popup menu to secret flags */
- if (menu) {
- MenuItem idx = 0;
- gs_free_list GList *list = NULL;
- int i, length;
-
- list = gtk_container_get_children (GTK_CONTAINER (menu));
- iter = list;
- length = g_list_length (list);
- for (i = 0; i < length; i++) {
- if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (iter->data))) {
- idx = (MenuItem) i;
- break;
- }
- iter = g_list_next (iter);
- }
-
- flags = menu_item_to_secret_flags (idx);
- }
- return flags;
-}
-
-/**
- * nma_utils_update_password_storage:
- * @passwd_entry: #GtkEntry with the password
- * @secret_flags: secret flags to set
- * @setting: #NMSetting containing the password, or NULL
- * @password_flags_name: name of the secret flags (like psk-flags), or NULL
- *
- * Updates secret flags in the password storage popup menu and also
- * in the @setting (if @setting and @password_flags_name are not NULL).
- *
- */
-void
-nma_utils_update_password_storage (GtkWidget *passwd_entry,
- NMSettingSecretFlags secret_flags,
- NMSetting *setting,
- const char *password_flags_name)
-{
- GList *menu_list, *iter;
- GtkWidget *menu = NULL;
-
- /* Update secret flags (WEP_KEY_FLAGS, PSK_FLAGS, ...) in the security setting */
- if (setting && password_flags_name)
- nm_setting_set_secret_flags (setting, password_flags_name, secret_flags, NULL);
-
- /* Update password-storage popup menu to reflect secret flags */
- menu_list = gtk_menu_get_for_attach_widget (passwd_entry);
- for (iter = menu_list; iter; iter = g_list_next (iter)) {
- if (g_object_get_data (G_OBJECT (iter->data), PASSWORD_STORAGE_MENU_TAG)) {
- menu = iter->data;
- break;
- }
- }
-
- if (menu) {
- GtkRadioMenuItem *item;
- MenuItem idx;
- GSList *group;
- gboolean with_not_required;
- int i, last;
-
- /* radio menu group list contains the menu items in reverse order */
- item = (GtkRadioMenuItem *) gtk_menu_get_active (GTK_MENU (menu));
- group = gtk_radio_menu_item_get_group (item);
- with_not_required = !!g_object_get_data (G_OBJECT (menu), MENU_WITH_NOT_REQUIRED_TAG);
-
- idx = secret_flags_to_menu_item (secret_flags, with_not_required);
- last = g_slist_length (group) - idx - 1;
- for (i = 0; i < last; i++)
- group = g_slist_next (group);
-
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (group->data), TRUE);
- change_password_storage_icon (passwd_entry, idx);
- }
-}
-/*---------------------------------------------------------------------------*/
-
diff --git a/src/libnma/nma-ui-utils.h b/src/libnma/nma-ui-utils.h
deleted file mode 100644
index bde5f487..00000000
--- a/src/libnma/nma-ui-utils.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright 2015 Red Hat, Inc.
- */
-
-#ifndef NMA_UI_UTILS_H
-#define NMA_UI_UTILS_H
-
-#include <glib.h>
-#include <gtk/gtk.h>
-#include <NetworkManager.h>
-
-void nma_utils_setup_password_storage (GtkWidget *passwd_entry,
- NMSettingSecretFlags initial_flags,
- NMSetting *setting,
- const char *password_flags_name,
- gboolean with_not_required,
- gboolean ask_mode);
-NMSettingSecretFlags nma_utils_menu_to_secret_flags (GtkWidget *passwd_entry);
-void nma_utils_update_password_storage (GtkWidget *passwd_entry,
- NMSettingSecretFlags secret_flags,
- NMSetting *setting,
- const char *password_flags_name);
-
-#endif /* NMA_UI_UTILS_H */
-
diff --git a/src/libnma/nma-version.h.in b/src/libnma/nma-version.h.in
deleted file mode 100644
index 78e0f206..00000000
--- a/src/libnma/nma-version.h.in
+++ /dev/null
@@ -1,119 +0,0 @@
-// SPDX-License-Identifier: LGPL-2.1+
-/* NetworkManager Applet -- allow user control over networking
- *
- * Copyright (C) 2011-2017 Red Hat, Inc.
- */
-
-#ifndef NMA_VERSION_H
-#define NMA_VERSION_H
-
-#include <glib.h>
-
-/**
- * NMA_MAJOR_VERSION:
- *
- * Evaluates to the major version number of NetworkManager which this source
- * is compiled against.
- */
-#define NMA_MAJOR_VERSION (@NMA_MAJOR_VERSION@)
-
-/**
- * NMA_MINOR_VERSION:
- *
- * Evaluates to the minor version number of NetworkManager which this source
- * is compiled against.
- */
-#define NMA_MINOR_VERSION (@NMA_MINOR_VERSION@)
-
-/**
- * NMA_MICRO_VERSION:
- *
- * Evaluates to the micro version number of NetworkManager which this source
- * compiled against.
- */
-#define NMA_MICRO_VERSION (@NMA_MICRO_VERSION@)
-
-/**
- * NMA_CHECK_VERSION:
- * @major: major version (e.g. 1 for version 1.2.5)
- * @minor: minor version (e.g. 2 for version 1.2.5)
- * @micro: micro version (e.g. 5 for version 1.2.5)
- *
- * Returns: %TRUE if the version of the NetworkManager header files
- * is the same as or newer than the passed-in version.
- */
-#define NMA_CHECK_VERSION(major,minor,micro) \
- (NMA_MAJOR_VERSION > (major) || \
- (NMA_MAJOR_VERSION == (major) && NMA_MINOR_VERSION > (minor)) || \
- (NMA_MAJOR_VERSION == (major) && NMA_MINOR_VERSION == (minor) && NMA_MICRO_VERSION >= (micro)))
-
-#define NMA_ENCODE_VERSION(major,minor,micro) ((major) << 16 | (minor) << 8 | (micro))
-
-#define NMA_VERSION_1_2 (NMA_ENCODE_VERSION (1, 2, 0))
-#define NMA_VERSION_1_4 (NMA_ENCODE_VERSION (1, 4, 0))
-#define NMA_VERSION_1_8 (NMA_ENCODE_VERSION (1, 8, 0))
-#define NMA_VERSION_1_8_2 (NMA_ENCODE_VERSION (1, 8, 2))
-#define NMA_VERSION_1_8_4 (NMA_ENCODE_VERSION (1, 8, 4))
-#define NMA_VERSION_1_8_6 (NMA_ENCODE_VERSION (1, 8, 6))
-#define NMA_VERSION_1_8_8 (NMA_ENCODE_VERSION (1, 8, 8))
-#define NMA_VERSION_1_8_10 (NMA_ENCODE_VERSION (1, 8, 10))
-#define NMA_VERSION_1_8_12 (NMA_ENCODE_VERSION (1, 8, 12))
-#define NMA_VERSION_1_8_22 (NMA_ENCODE_VERSION (1, 8, 22))
-
-#define NMA_VERSION_CUR_STABLE NMA_VERSION_1_8_10
-#define NMA_VERSION_NEXT_STABLE NMA_VERSION_1_8_22
-
-#define NMA_VERSION NMA_ENCODE_VERSION (NMA_MAJOR_VERSION, NMA_MINOR_VERSION, NMA_MICRO_VERSION)
-
-/* Deprecation / Availability macros */
-
-#if !defined (NMA_VERSION_MIN_REQUIRED) || (NMA_VERSION_MIN_REQUIRED == 0)
-# undef NMA_VERSION_MIN_REQUIRED
-# define NMA_VERSION_MIN_REQUIRED (NMA_VERSION_CUR_STABLE)
-#endif
-
-#if !defined (NMA_VERSION_MAX_ALLOWED) || (NMA_VERSION_MAX_ALLOWED == 0)
-# undef NMA_VERSION_MAX_ALLOWED
-# define NMA_VERSION_MAX_ALLOWED (NMA_VERSION_NEXT_STABLE)
-#endif
-
-/* sanity checks */
-#if NMA_VERSION_MIN_REQUIRED > NMA_VERSION_NEXT_STABLE
-#error "NMA_VERSION_MIN_REQUIRED must be <= NMA_VERSION_NEXT_STABLE"
-#endif
-#if NMA_VERSION_MAX_ALLOWED < NMA_VERSION_MIN_REQUIRED
-#error "NMA_VERSION_MAX_ALLOWED must be >= NMA_VERSION_MIN_REQUIRED"
-#endif
-#if NMA_VERSION_MIN_REQUIRED < NMA_VERSION_1_2
-#error "NMA_VERSION_MIN_REQUIRED must be >= NMA_VERSION_1_2"
-#endif
-
-#if NMA_VERSION_MIN_REQUIRED >= NMA_VERSION_1_2
-# define NMA_DEPRECATED_IN_1_2 G_DEPRECATED
-# define NMA_DEPRECATED_IN_1_2_FOR(f) G_DEPRECATED_FOR(f)
-#else
-# define NMA_DEPRECATED_IN_1_2
-# define NMA_DEPRECATED_IN_1_2_FOR(f)
-#endif
-
-#if NMA_VERSION_MIN_REQUIRED >= NMA_VERSION_1_8
-# define NMA_DEPRECATED_IN_1_8 G_DEPRECATED
-# define NMA_DEPRECATED_IN_1_8_FOR(f) G_DEPRECATED_FOR(f)
-#else
-# define NMA_DEPRECATED_IN_1_8
-# define NMA_DEPRECATED_IN_1_8_FOR(f)
-#endif
-
-#if NMA_VERSION_MAX_ALLOWED < NMA_VERSION_1_8
-# define NMA_AVAILABLE_IN_1_8 G_UNAVAILABLE(1,8)
-#else
-# define NMA_AVAILABLE_IN_1_8
-#endif
-
-#if NMA_VERSION_MAX_ALLOWED < NMA_VERSION_1_8_22
-# define NMA_AVAILABLE_IN_1_8_22 G_UNAVAILABLE(1.8,22)
-#else
-# define NMA_AVAILABLE_IN_1_8_22
-#endif
-
-#endif /* NMA_VERSION_H */
diff --git a/src/libnma/nma-vpn-password-dialog.c b/src/libnma/nma-vpn-password-dialog.c
deleted file mode 100644
index adc67971..00000000
--- a/src/libnma/nma-vpn-password-dialog.c
+++ /dev/null
@@ -1,351 +0,0 @@
-/* nma-vpn-password-dialog.c - A password prompting dialog widget.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License as
- * published by the ree Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * Copyright (C) 1999, 2000 Eazel, Inc.
- * Copyright (C) 2011 - 2018 Red Hat, Inc.
- *
- * Authors: Ramiro Estrugo <ramiro@eazel.com>
- * Dan Williams <dcbw@redhat.com>
- * Lubomir Rintel <lkundrak@v3.sk>
- */
-
-#include "nm-default.h"
-#include "nma-private.h"
-#include "nma-vpn-password-dialog.h"
-
-typedef struct {
- GtkWidget *message_label;
- GtkWidget *password_label;
- GtkWidget *password_label_secondary;
- GtkWidget *password_label_tertiary;
- GtkWidget *password_entry;
- GtkWidget *password_entry_secondary;
- GtkWidget *password_entry_tertiary;
- GtkWidget *show_passwords_checkbox;
-} NMAVpnPasswordDialogPrivate;
-
-G_DEFINE_TYPE_WITH_CODE (NMAVpnPasswordDialog, nma_vpn_password_dialog, GTK_TYPE_DIALOG,
- G_ADD_PRIVATE (NMAVpnPasswordDialog))
-
-
-#define NMA_VPN_PASSWORD_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
- NMA_VPN_TYPE_PASSWORD_DIALOG, \
- NMAVpnPasswordDialogPrivate))
-
-/* NMAVpnPasswordDialogClass methods */
-static void nma_vpn_password_dialog_class_init (NMAVpnPasswordDialogClass *password_dialog_class);
-static void nma_vpn_password_dialog_init (NMAVpnPasswordDialog *password_dialog);
-
-/* GtkDialog callbacks */
-static void dialog_show_callback (GtkWidget *widget, gpointer callback_data);
-static void dialog_close_callback (GtkWidget *widget, gpointer callback_data);
-
-static void
-show_passwords_toggled_cb (GtkWidget *widget, gpointer user_data)
-{
- NMAVpnPasswordDialog *dialog = NMA_VPN_PASSWORD_DIALOG (user_data);
- NMAVpnPasswordDialogPrivate *priv = NMA_VPN_PASSWORD_DIALOG_GET_PRIVATE (dialog);
- gboolean visible;
-
- visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
-
- gtk_entry_set_visibility (GTK_ENTRY (priv->password_entry), visible);
- gtk_entry_set_visibility (GTK_ENTRY (priv->password_entry_secondary), visible);
- gtk_entry_set_visibility (GTK_ENTRY (priv->password_entry_tertiary), visible);
-}
-
-static void
-nma_vpn_password_dialog_class_init (NMAVpnPasswordDialogClass *klass)
-{
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
- g_type_ensure (NM_TYPE_DEVICE);
- gtk_widget_class_set_template_from_resource (widget_class,
- "/org/freedesktop/network-manager-applet/nma-vpn-password-dialog.ui");
-
- gtk_widget_class_bind_template_child_private (widget_class, NMAVpnPasswordDialog, message_label);
- gtk_widget_class_bind_template_child_private (widget_class, NMAVpnPasswordDialog, password_label);
- gtk_widget_class_bind_template_child_private (widget_class, NMAVpnPasswordDialog, password_label_secondary);
- gtk_widget_class_bind_template_child_private (widget_class, NMAVpnPasswordDialog, password_label_tertiary);
- gtk_widget_class_bind_template_child_private (widget_class, NMAVpnPasswordDialog, password_entry);
- gtk_widget_class_bind_template_child_private (widget_class, NMAVpnPasswordDialog, password_entry_secondary);
- gtk_widget_class_bind_template_child_private (widget_class, NMAVpnPasswordDialog, password_entry_tertiary);
- gtk_widget_class_bind_template_child_private (widget_class, NMAVpnPasswordDialog, show_passwords_checkbox);
-
- gtk_widget_class_bind_template_callback (widget_class, dialog_close_callback);
- gtk_widget_class_bind_template_callback (widget_class, dialog_show_callback);
- gtk_widget_class_bind_template_callback (widget_class, nma_gtk_widget_activate_default);
- gtk_widget_class_bind_template_callback (widget_class, show_passwords_toggled_cb);
-}
-
-static void
-nma_vpn_password_dialog_init (NMAVpnPasswordDialog *dialog)
-{
- gtk_widget_init_template (GTK_WIDGET (dialog));
-}
-
-/* GtkDialog callbacks */
-static void
-dialog_show_callback (GtkWidget *widget, gpointer callback_data)
-{
- NMAVpnPasswordDialog *dialog = NMA_VPN_PASSWORD_DIALOG (callback_data);
- NMAVpnPasswordDialogPrivate *priv = NMA_VPN_PASSWORD_DIALOG_GET_PRIVATE (dialog);
- GtkWidget *to_focus = NULL;
-
-
- if ( gtk_widget_get_visible (priv->password_entry)
- && gtk_entry_get_text_length (GTK_ENTRY (priv->password_entry)) == 0)
- to_focus = priv->password_entry;
- else if ( gtk_widget_get_visible (priv->password_entry_secondary)
- && gtk_entry_get_text_length (GTK_ENTRY (priv->password_entry_secondary)) == 0)
- to_focus = priv->password_entry_secondary;
- else if ( gtk_widget_get_visible (priv->password_entry_tertiary)
- && gtk_entry_get_text_length (GTK_ENTRY (priv->password_entry_tertiary)) == 0)
- to_focus = priv->password_entry_tertiary;
-
- gtk_widget_grab_focus (to_focus ?: priv->password_entry);
-}
-
-static void
-dialog_close_callback (GtkWidget *widget, gpointer callback_data)
-{
- gtk_widget_hide (widget);
-}
-
-/* Public NMAVpnPasswordDialog methods */
-GtkWidget *
-nma_vpn_password_dialog_new (const char *title,
- const char *message,
- const char *password)
-{
- GtkWidget *dialog;
- NMAVpnPasswordDialogPrivate *priv;
-
- dialog = gtk_widget_new (NMA_VPN_TYPE_PASSWORD_DIALOG, "title", title, NULL);
- if (!dialog)
- return NULL;
- priv = NMA_VPN_PASSWORD_DIALOG_GET_PRIVATE (dialog);
-
- if (message) {
- gtk_label_set_text (GTK_LABEL (priv->message_label), message);
- gtk_widget_show (priv->message_label);
- }
-
- nma_vpn_password_dialog_set_password (NMA_VPN_PASSWORD_DIALOG (dialog), password);
-
- return GTK_WIDGET (dialog);
-}
-
-gboolean
-nma_vpn_password_dialog_run_and_block (NMAVpnPasswordDialog *dialog)
-{
- gint button_clicked;
-
- g_return_val_if_fail (dialog != NULL, FALSE);
- g_return_val_if_fail (NMA_VPN_IS_PASSWORD_DIALOG (dialog), FALSE);
-
- button_clicked = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_hide (GTK_WIDGET (dialog));
-
- return button_clicked == GTK_RESPONSE_OK;
-}
-
-void
-nma_vpn_password_dialog_set_password (NMAVpnPasswordDialog *dialog,
- const char *password)
-{
- NMAVpnPasswordDialogPrivate *priv;
-
- g_return_if_fail (NMA_VPN_IS_PASSWORD_DIALOG (dialog));
-
- priv = NMA_VPN_PASSWORD_DIALOG_GET_PRIVATE (dialog);
- gtk_editable_set_text (GTK_EDITABLE (priv->password_entry), password ? password : "");
-}
-
-void
-nma_vpn_password_dialog_set_password_secondary (NMAVpnPasswordDialog *dialog,
- const char *password_secondary)
-{
- NMAVpnPasswordDialogPrivate *priv;
-
- g_return_if_fail (NMA_VPN_IS_PASSWORD_DIALOG (dialog));
-
- priv = NMA_VPN_PASSWORD_DIALOG_GET_PRIVATE (dialog);
- gtk_editable_set_text (GTK_EDITABLE (priv->password_entry_secondary),
- password_secondary ? password_secondary : "");
-}
-
-void
-nma_vpn_password_dialog_set_password_ternary (NMAVpnPasswordDialog *dialog,
- const char *password_tertiary)
-{
- NMAVpnPasswordDialogPrivate *priv;
-
- g_return_if_fail (NMA_VPN_IS_PASSWORD_DIALOG (dialog));
-
- priv = NMA_VPN_PASSWORD_DIALOG_GET_PRIVATE (dialog);
- gtk_editable_set_text (GTK_EDITABLE (priv->password_entry_tertiary),
- password_tertiary ? password_tertiary : "");
-}
-
-void
-nma_vpn_password_dialog_set_show_password (NMAVpnPasswordDialog *dialog, gboolean show)
-{
- NMAVpnPasswordDialogPrivate *priv;
-
- g_return_if_fail (dialog != NULL);
- g_return_if_fail (NMA_VPN_IS_PASSWORD_DIALOG (dialog));
-
- priv = NMA_VPN_PASSWORD_DIALOG_GET_PRIVATE (dialog);
- gtk_widget_set_visible (priv->password_label, show);
- gtk_widget_set_visible (priv->password_entry, show);
-}
-
-void
-nma_vpn_password_dialog_set_show_password_secondary (NMAVpnPasswordDialog *dialog,
- gboolean show)
-{
- NMAVpnPasswordDialogPrivate *priv;
-
- g_return_if_fail (dialog != NULL);
- g_return_if_fail (NMA_VPN_IS_PASSWORD_DIALOG (dialog));
-
- priv = NMA_VPN_PASSWORD_DIALOG_GET_PRIVATE (dialog);
- gtk_widget_set_visible (priv->password_label_secondary, show);
- gtk_widget_set_visible (priv->password_entry_secondary, show);
-}
-
-void
-nma_vpn_password_dialog_set_show_password_ternary (NMAVpnPasswordDialog *dialog,
- gboolean show)
-{
- NMAVpnPasswordDialogPrivate *priv;
-
- g_return_if_fail (dialog != NULL);
- g_return_if_fail (NMA_VPN_IS_PASSWORD_DIALOG (dialog));
-
- priv = NMA_VPN_PASSWORD_DIALOG_GET_PRIVATE (dialog);
- gtk_widget_set_visible (priv->password_label_tertiary, show);
- gtk_widget_set_visible (priv->password_entry_tertiary, show);
-}
-
-void
-nma_vpn_password_dialog_focus_password (NMAVpnPasswordDialog *dialog)
-{
- NMAVpnPasswordDialogPrivate *priv;
-
- g_return_if_fail (dialog != NULL);
- g_return_if_fail (NMA_VPN_IS_PASSWORD_DIALOG (dialog));
-
- priv = NMA_VPN_PASSWORD_DIALOG_GET_PRIVATE (dialog);
- if (gtk_widget_get_visible (priv->password_entry))
- gtk_widget_grab_focus (priv->password_entry);
-}
-
-void
-nma_vpn_password_dialog_focus_password_secondary (NMAVpnPasswordDialog *dialog)
-{
- NMAVpnPasswordDialogPrivate *priv;
-
- g_return_if_fail (dialog != NULL);
- g_return_if_fail (NMA_VPN_IS_PASSWORD_DIALOG (dialog));
-
- priv = NMA_VPN_PASSWORD_DIALOG_GET_PRIVATE (dialog);
- if (gtk_widget_get_visible (priv->password_entry_secondary))
- gtk_widget_grab_focus (priv->password_entry_secondary);
-}
-
-void
-nma_vpn_password_dialog_focus_password_ternary (NMAVpnPasswordDialog *dialog)
-{
- NMAVpnPasswordDialogPrivate *priv;
-
- g_return_if_fail (dialog != NULL);
- g_return_if_fail (NMA_VPN_IS_PASSWORD_DIALOG (dialog));
-
- priv = NMA_VPN_PASSWORD_DIALOG_GET_PRIVATE (dialog);
- if (gtk_widget_get_visible (priv->password_entry_tertiary))
- gtk_widget_grab_focus (priv->password_entry_tertiary);
-}
-
-const char *
-nma_vpn_password_dialog_get_password (NMAVpnPasswordDialog *dialog)
-{
- NMAVpnPasswordDialogPrivate *priv;
-
- g_return_val_if_fail (NMA_VPN_IS_PASSWORD_DIALOG (dialog), NULL);
-
- priv = NMA_VPN_PASSWORD_DIALOG_GET_PRIVATE (dialog);
- return gtk_editable_get_text (GTK_EDITABLE (priv->password_entry));
-}
-
-const char *
-nma_vpn_password_dialog_get_password_secondary (NMAVpnPasswordDialog *dialog)
-{
- NMAVpnPasswordDialogPrivate *priv;
-
- g_return_val_if_fail (NMA_VPN_IS_PASSWORD_DIALOG (dialog), NULL);
-
- priv = NMA_VPN_PASSWORD_DIALOG_GET_PRIVATE (dialog);
- return gtk_editable_get_text (GTK_EDITABLE (priv->password_entry_secondary));
-}
-
-const char *
-nma_vpn_password_dialog_get_password_ternary (NMAVpnPasswordDialog *dialog)
-{
- NMAVpnPasswordDialogPrivate *priv;
-
- g_return_val_if_fail (NMA_VPN_IS_PASSWORD_DIALOG (dialog), NULL);
-
- priv = NMA_VPN_PASSWORD_DIALOG_GET_PRIVATE (dialog);
- return gtk_editable_get_text (GTK_EDITABLE (priv->password_entry_tertiary));
-}
-
-void nma_vpn_password_dialog_set_password_label (NMAVpnPasswordDialog *dialog,
- const char *label)
-{
- NMAVpnPasswordDialogPrivate *priv;
-
- g_return_if_fail (dialog != NULL);
- g_return_if_fail (NMA_VPN_IS_PASSWORD_DIALOG (dialog));
-
- priv = NMA_VPN_PASSWORD_DIALOG_GET_PRIVATE (dialog);
-
- gtk_label_set_text_with_mnemonic (GTK_LABEL (priv->password_label), label);
-}
-
-void nma_vpn_password_dialog_set_password_secondary_label (NMAVpnPasswordDialog *dialog,
- const char *label)
-{
- NMAVpnPasswordDialogPrivate *priv;
-
- g_return_if_fail (dialog != NULL);
- g_return_if_fail (NMA_VPN_IS_PASSWORD_DIALOG (dialog));
-
- priv = NMA_VPN_PASSWORD_DIALOG_GET_PRIVATE (dialog);
-
- gtk_label_set_text_with_mnemonic (GTK_LABEL (priv->password_label_secondary), label);
-}
-
-void
-nma_vpn_password_dialog_set_password_ternary_label (NMAVpnPasswordDialog *dialog,
- const char *label)
-{
- NMAVpnPasswordDialogPrivate *priv;
-
- g_return_if_fail (dialog != NULL);
- g_return_if_fail (NMA_VPN_IS_PASSWORD_DIALOG (dialog));
-
- priv = NMA_VPN_PASSWORD_DIALOG_GET_PRIVATE (dialog);
-
- gtk_label_set_text_with_mnemonic (GTK_LABEL (priv->password_label_tertiary), label);
-}
diff --git a/src/libnma/nma-vpn-password-dialog.h b/src/libnma/nma-vpn-password-dialog.h
deleted file mode 100644
index 5e274222..00000000
--- a/src/libnma/nma-vpn-password-dialog.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* vpn-password-dialog.c - A use password prompting dialog widget.
- *
- * The Gnome Library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License as
- * published by the ree Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * The Gnome Library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * Copyright (C) 1999, 2000 Eazel, Inc.
- * Copyright (C) 2011, 2013 Red Hat, Inc.
- *
- * Authors: Ramiro Estrugo <ramiro@eazel.com>
- * Dan Williams <dcbw@redhat.com>
- */
-
-#ifndef NMA_VPN_PASSWORD_DIALOG_H
-#define NMA_VPN_PASSWORD_DIALOG_H
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-#define NMA_VPN_TYPE_PASSWORD_DIALOG (nma_vpn_password_dialog_get_type ())
-#define NMA_VPN_PASSWORD_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMA_VPN_TYPE_PASSWORD_DIALOG, NMAVpnPasswordDialog))
-#define NMA_VPN_PASSWORD_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMA_VPN_TYPE_PASSWORD_DIALOG, NMAVpnPasswordDialogClass))
-#define NMA_VPN_IS_PASSWORD_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMA_VPN_TYPE_PASSWORD_DIALOG))
-#define NMA_VPN_IS_PASSWORD_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMA_VPN_TYPE_PASSWORD_DIALOG))
-
-typedef struct NMAVpnPasswordDialog NMAVpnPasswordDialog;
-typedef struct NMAVpnPasswordDialogClass NMAVpnPasswordDialogClass;
-
-struct NMAVpnPasswordDialog {
- GtkDialog parent;
-};
-
-struct NMAVpnPasswordDialogClass {
- GtkDialogClass parent_class;
-};
-
-GType nma_vpn_password_dialog_get_type (void);
-GtkWidget* nma_vpn_password_dialog_new (const char *title,
- const char *message,
- const char *password);
-
-gboolean nma_vpn_password_dialog_run_and_block (NMAVpnPasswordDialog *dialog);
-
-/* Attribute mutators */
-void nma_vpn_password_dialog_set_show_password (NMAVpnPasswordDialog *dialog,
- gboolean show);
-void nma_vpn_password_dialog_focus_password (NMAVpnPasswordDialog *dialog);
-void nma_vpn_password_dialog_set_password (NMAVpnPasswordDialog *dialog,
- const char *password);
-void nma_vpn_password_dialog_set_password_label (NMAVpnPasswordDialog *dialog,
- const char *label);
-
-void nma_vpn_password_dialog_set_show_password_secondary (NMAVpnPasswordDialog *dialog,
- gboolean show);
-void nma_vpn_password_dialog_focus_password_secondary (NMAVpnPasswordDialog *dialog);
-void nma_vpn_password_dialog_set_password_secondary (NMAVpnPasswordDialog *dialog,
- const char *password_secondary);
-void nma_vpn_password_dialog_set_password_secondary_label (NMAVpnPasswordDialog *dialog,
- const char *label);
-
-void nma_vpn_password_dialog_set_show_password_ternary (NMAVpnPasswordDialog *dialog,
- gboolean show);
-void nma_vpn_password_dialog_focus_password_ternary (NMAVpnPasswordDialog *dialog);
-void nma_vpn_password_dialog_set_password_ternary (NMAVpnPasswordDialog *dialog,
- const char *password_ternary);
-void nma_vpn_password_dialog_set_password_ternary_label (NMAVpnPasswordDialog *dialog,
- const char *label);
-
-/* Attribute accessors */
-const char *nma_vpn_password_dialog_get_password (NMAVpnPasswordDialog *dialog);
-
-const char *nma_vpn_password_dialog_get_password_secondary (NMAVpnPasswordDialog *dialog);
-
-const char *nma_vpn_password_dialog_get_password_ternary (NMAVpnPasswordDialog *dialog);
-
-G_END_DECLS
-
-#endif /* NMA_VPN_PASSWORD_DIALOG_H */
diff --git a/src/libnma/nma-vpn-password-dialog.ui b/src/libnma/nma-vpn-password-dialog.ui
deleted file mode 100644
index 4774d2e4..00000000
--- a/src/libnma/nma-vpn-password-dialog.ui
+++ /dev/null
@@ -1,222 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.2 -->
-<interface domain="nm-applet">
- <requires lib="gtk+" version="3.20"/>
- <template class="NMAVpnPasswordDialog" parent="GtkDialog">
- <property name="can_focus">False</property>
- <property name="resizable">False</property>
- <property name="modal">True</property>
- <property name="window_position">center</property>
- <property name="type_hint">dialog</property>
- <signal name="close" handler="dialog_close_callback" swapped="no"/>
- <signal name="show" handler="dialog_show_callback" swapped="no"/>
- <child internal-child="vbox">
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <child internal-child="action_area">
- <object class="GtkButtonBox">
- <property name="can_focus">False</property>
- <child>
- <object class="GtkButton" id="cancel_button">
- <property name="label" translatable="yes">_Cancel</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">True</property>
- <property name="valign">baseline</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="ok_button">
- <property name="label" translatable="yes">_OK</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="receives_default">True</property>
- <property name="valign">baseline</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkGrid">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_start">12</property>
- <property name="margin_end">12</property>
- <property name="margin_top">12</property>
- <property name="margin_bottom">12</property>
- <property name="row_spacing">6</property>
- <property name="column_spacing">12</property>
- <child>
- <object class="GtkCheckButton" id="show_passwords_checkbox">
- <property name="label" translatable="yes">Sh_ow passwords</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="halign">start</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="show_passwords_toggled_cb" swapped="no"/>
- </object>
- <packing>
- <property name="left_attach">2</property>
- <property name="top_attach">4</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="password_entry_tertiary">
- <property name="visible">False</property>
- <property name="can_focus">True</property>
- <property name="visibility">False</property>
- <property name="width_chars">20</property>
- <signal name="activate" handler="nma_gtk_widget_activate_default" swapped="yes"/>
- </object>
- <packing>
- <property name="left_attach">2</property>
- <property name="top_attach">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="password_entry_secondary">
- <property name="visible">False</property>
- <property name="can_focus">True</property>
- <property name="visibility">False</property>
- <property name="width_chars">20</property>
- <signal name="activate" handler="nma_gtk_widget_activate_default" swapped="yes"/>
- </object>
- <packing>
- <property name="left_attach">2</property>
- <property name="top_attach">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="password_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="visibility">False</property>
- <property name="width_chars">20</property>
- <signal name="activate" handler="nma_gtk_widget_activate_default" swapped="yes"/>
- </object>
- <packing>
- <property name="left_attach">2</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="password_label_tertiary">
- <property name="visible">False</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">_Tertiary Password:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">password_entry_tertiary</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="password_label_secondary">
- <property name="visible">False</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">_Secondary Password:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">password_entry_secondary</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="password_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">_Password:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">password_entry</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="message_label">
- <property name="visible">False</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="margin_bottom">12</property>
- <property name="hexpand">True</property>
- <property name="wrap">True</property>
- <property name="max_width_chars">35</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- <property name="width">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkImage">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_start">6</property>
- <property name="margin_end">12</property>
- <property name="margin_top">6</property>
- <property name="margin_bottom">6</property>
- <property name="valign">start</property>
- <property name="icon_name">dialog-password</property>
- <property name="icon_size">6</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- <property name="height">5</property>
- </packing>
- </child>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- </child>
- <action-widgets>
- <action-widget response="-6">cancel_button</action-widget>
- <action-widget response="-5">ok_button</action-widget>
- </action-widgets>
- <child>
- <placeholder/>
- </child>
- </template>
-</interface>
diff --git a/src/libnma/nma-wifi-dialog.c b/src/libnma/nma-wifi-dialog.c
deleted file mode 100644
index 2a572ccf..00000000
--- a/src/libnma/nma-wifi-dialog.c
+++ /dev/null
@@ -1,1559 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/* NetworkManager Applet -- allow user control over networking
- *
- * Dan Williams <dcbw@redhat.com>
- *
- * Copyright 2007 - 2017 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-#include "nma-private.h"
-
-#include <string.h>
-#include <netinet/ether.h>
-
-#include <NetworkManager.h>
-
-#include "nma-wifi-dialog.h"
-#include "wireless-security.h"
-#include "eap-method.h"
-
-G_DEFINE_TYPE (NMAWifiDialog, nma_wifi_dialog, GTK_TYPE_DIALOG)
-
-#define NMA_WIFI_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
- NMA_TYPE_WIFI_DIALOG, \
- NMAWifiDialogPrivate))
-
-typedef struct {
- NMAWifiDialog *self;
- NMConnection *connection;
- gboolean canceled;
-} GetSecretsInfo;
-
-typedef struct {
- NMClient *client;
-
- GtkBuilder *builder;
-
- NMConnection *specific_connection;
- NMConnection *connection;
- NMDevice *device;
- NMAccessPoint *ap;
- guint operation;
-
- GtkTreeModel *device_model;
- GtkTreeModel *connection_model;
- GtkSizeGroup *group;
- GtkWidget *sec_combo;
- GtkWidget *ok_response_button;
-
- gboolean network_name_focus;
-
- gboolean secrets_only;
-
- guint revalidate_id;
-
- GetSecretsInfo *secrets_info;
-} NMAWifiDialogPrivate;
-
-enum {
- OP_NONE = 0,
- OP_CREATE_ADHOC,
- OP_CONNECT_HIDDEN,
-};
-
-#define D_NAME_COLUMN 0
-#define D_DEV_COLUMN 1
-
-#define S_NAME_COLUMN 0
-#define S_SEC_COLUMN 1
-
-#define C_NAME_COLUMN 0
-#define C_CON_COLUMN 1
-#define C_SEP_COLUMN 2
-#define C_NEW_COLUMN 3
-
-static gboolean security_combo_init (NMAWifiDialog *self, gboolean secrets_only,
- const char *secrets_setting_name,
- const char *const*secrets_hints);
-static void ssid_entry_changed (GtkWidget *entry, gpointer user_data);
-
-void
-nma_wifi_dialog_set_nag_ignored (NMAWifiDialog *self, gboolean ignored)
-{
-}
-
-gboolean
-nma_wifi_dialog_get_nag_ignored (NMAWifiDialog *self)
-{
- return TRUE;
-}
-
-static void
-size_group_clear (GtkSizeGroup *group)
-{
- GSList *iter;
-
- g_return_if_fail (group != NULL);
-
- iter = gtk_size_group_get_widgets (group);
- while (iter) {
- gtk_size_group_remove_widget (group, GTK_WIDGET (iter->data));
- iter = gtk_size_group_get_widgets (group);
- }
-}
-
-static void
-_set_ok_sensitive (NMAWifiDialog *self, gboolean is_sensitive, const char *error_tooltip)
-{
- NMAWifiDialogPrivate *priv = NMA_WIFI_DIALOG_GET_PRIVATE (self);
- gtk_dialog_set_response_sensitive (GTK_DIALOG (self), GTK_RESPONSE_OK, is_sensitive);
-
- if (priv->ok_response_button) {
- gtk_widget_set_tooltip_text (priv->ok_response_button,
- is_sensitive ? _("Click to connect") : error_tooltip);
- }
-}
-
-static void
-size_group_add_permanent (GtkSizeGroup *group,
- GtkBuilder *builder)
-{
- GtkWidget *widget;
-
- g_return_if_fail (group != NULL);
- g_return_if_fail (builder != NULL);
-
- widget = GTK_WIDGET (gtk_builder_get_object (builder, "network_name_label"));
- gtk_size_group_add_widget (group, widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (builder, "security_combo_label"));
- gtk_size_group_add_widget (group, widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (builder, "device_label"));
- gtk_size_group_add_widget (group, widget);
-}
-
-static void
-security_combo_changed (GtkWidget *combo,
- gpointer user_data)
-{
- NMAWifiDialog *self = NMA_WIFI_DIALOG (user_data);
- NMAWifiDialogPrivate *priv = NMA_WIFI_DIALOG_GET_PRIVATE (self);
- GtkWidget *vbox, *sec_widget, *def_widget;
- GList *elt, *children;
- GtkTreeIter iter;
- GtkTreeModel *model;
- WirelessSecurity *sec = NULL;
-
- vbox = GTK_WIDGET (gtk_builder_get_object (priv->builder, "security_vbox"));
- g_assert (vbox);
-
- size_group_clear (priv->group);
-
- /* Remove any previous wireless security widgets */
- children = gtk_container_get_children (GTK_CONTAINER (vbox));
- for (elt = children; elt; elt = g_list_next (elt))
- gtk_container_remove (GTK_CONTAINER (vbox), GTK_WIDGET (elt->data));
- g_list_free (children);
-
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
- if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter)) {
- g_warning ("%s: no active security combo box item.", __func__);
- return;
- }
-
- gtk_tree_model_get (model, &iter, S_SEC_COLUMN, &sec, -1);
- if (!sec) {
- /* Revalidate dialog if the user picked "None" so the OK button
- * gets enabled if there's already a valid SSID.
- */
- ssid_entry_changed (NULL, self);
- return;
- }
-
- sec_widget = wireless_security_get_widget (sec);
- g_assert (sec_widget);
- gtk_widget_unparent (sec_widget);
-
- size_group_add_permanent (priv->group, priv->builder);
- wireless_security_add_to_size_group (sec, priv->group);
-
- gtk_container_add (GTK_CONTAINER (vbox), sec_widget);
-
- /* Re-validate */
- wireless_security_changed_cb (NULL, sec);
-
- /* Set focus to the security method's default widget, but only if the
- * network name entry should not be focused.
- */
- if (!priv->network_name_focus && sec->default_field) {
- def_widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, sec->default_field));
- if (def_widget)
- gtk_widget_grab_focus (def_widget);
- }
-
- wireless_security_unref (sec);
-}
-
-static void
-security_combo_changed_manually (GtkWidget *combo,
- gpointer user_data)
-{
- NMAWifiDialog *self = NMA_WIFI_DIALOG (user_data);
- NMAWifiDialogPrivate *priv = NMA_WIFI_DIALOG_GET_PRIVATE (self);
-
- /* Flag that the combo was changed manually to allow focus to move
- * to the security method's default widget instead of the network name.
- */
- priv->network_name_focus = FALSE;
- security_combo_changed (combo, user_data);
-}
-
-static GBytes *
-validate_dialog_ssid (NMAWifiDialog *self)
-{
- NMAWifiDialogPrivate *priv = NMA_WIFI_DIALOG_GET_PRIVATE (self);
- GtkWidget *widget;
- const char *ssid;
- GBytes *ssid_bytes;
-
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "network_name_entry"));
-
- ssid = gtk_editable_get_text (GTK_EDITABLE (widget));
-
- if (!ssid || strlen (ssid) == 0 || strlen (ssid) > 32)
- return NULL;
-
- ssid_bytes = g_bytes_new (ssid, strlen (ssid));
- return ssid_bytes;
-}
-
-static void
-stuff_changed_cb (WirelessSecurity *sec, gpointer user_data)
-{
- NMAWifiDialog *self = NMA_WIFI_DIALOG (user_data);
- NMAWifiDialogPrivate *priv = NMA_WIFI_DIALOG_GET_PRIVATE (self);
- GBytes *ssid = NULL;
- gboolean free_ssid = TRUE;
- gboolean valid = FALSE;
- GtkTreeModel *model;
- GtkTreeIter iter;
- WirelessSecurity *sel_sec = NULL;
- gs_free_error GError *error = NULL;
-
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->sec_combo));
- if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->sec_combo), &iter))
- gtk_tree_model_get (model, &iter, S_SEC_COLUMN, &sel_sec, -1);
-
- if (sel_sec)
- wireless_security_unref (sel_sec);
-
- if (sel_sec != sec)
- return;
-
- if (priv->connection) {
- NMSettingWireless *s_wireless;
- s_wireless = nm_connection_get_setting_wireless (priv->connection);
- g_assert (s_wireless);
- ssid = nm_setting_wireless_get_ssid (s_wireless);
- free_ssid = FALSE;
- } else {
- ssid = validate_dialog_ssid (self);
- }
-
- if (ssid) {
- valid = wireless_security_validate (sec, &error);
- if (free_ssid)
- g_bytes_unref (ssid);
- }
-
- /* But if there's an in-progress secrets call (which might require authorization)
- * then we don't want to enable the OK button because we don't have all the
- * connection details yet.
- */
- if (priv->secrets_info)
- valid = FALSE;
-
- _set_ok_sensitive (self, valid, error ? error->message : NULL);
-}
-
-static void
-ssid_entry_changed (GtkWidget *entry, gpointer user_data)
-{
- NMAWifiDialog *self = NMA_WIFI_DIALOG (user_data);
- NMAWifiDialogPrivate *priv = NMA_WIFI_DIALOG_GET_PRIVATE (self);
- GtkTreeIter iter;
- WirelessSecurity *sec = NULL;
- GtkTreeModel *model;
- gboolean valid = FALSE;
- GBytes *ssid;
- gs_free_error GError *error = NULL;
-
- /* If the network name entry was touched at all, allow focus to go to
- * the default widget of the security method now.
- */
- priv->network_name_focus = FALSE;
-
- ssid = validate_dialog_ssid (self);
- if (!ssid)
- goto out;
-
- g_bytes_unref (ssid);
-
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->sec_combo));
- if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->sec_combo), &iter))
- gtk_tree_model_get (model, &iter, S_SEC_COLUMN, &sec, -1);
-
- if (sec) {
- valid = wireless_security_validate (sec, &error);
- wireless_security_unref (sec);
- } else {
- valid = TRUE;
- }
-
-out:
- /* But if there's an in-progress secrets call (which might require authorization)
- * then we don't want to enable the OK button because we don't have all the
- * connection details yet.
- */
- if (priv->secrets_info)
- valid = FALSE;
-
- _set_ok_sensitive (self, valid, error ? error->message : NULL);
-}
-
-static void
-connection_combo_changed (GtkWidget *combo,
- gpointer user_data)
-{
- NMAWifiDialog *self = NMA_WIFI_DIALOG (user_data);
- NMAWifiDialogPrivate *priv = NMA_WIFI_DIALOG_GET_PRIVATE (self);
- GtkTreeIter iter;
- GtkTreeModel *model;
- gboolean is_new = FALSE;
- NMSettingWireless *s_wireless;
- char *utf8_ssid;
- GtkWidget *widget;
-
- if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter)) {
- g_warning ("%s: no active connection combo box item.", __func__);
- return;
- }
-
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
-
- if (priv->connection)
- g_object_unref (priv->connection);
-
- gtk_tree_model_get (model, &iter,
- C_CON_COLUMN, &priv->connection,
- C_NEW_COLUMN, &is_new, -1);
-
- if (priv->connection)
- eap_method_ca_cert_ignore_load (priv->connection);
-
- if (!security_combo_init (self, priv->secrets_only, NULL, NULL)) {
- g_warning ("Couldn't change Wi-Fi security combo box.");
- return;
- }
- security_combo_changed (priv->sec_combo, self);
-
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "network_name_entry"));
- if (priv->connection) {
- GBytes *ssid;
-
- s_wireless = nm_connection_get_setting_wireless (priv->connection);
- ssid = nm_setting_wireless_get_ssid (s_wireless);
- utf8_ssid = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid));
- gtk_editable_set_text (GTK_EDITABLE (widget), utf8_ssid);
- g_free (utf8_ssid);
- } else {
- gtk_editable_set_text (GTK_EDITABLE (widget), "");
- }
-
- gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (priv->builder, "network_name_entry")), is_new);
- gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (priv->builder, "network_name_label")), is_new);
- gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (priv->builder, "security_combo")), is_new);
- gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (priv->builder, "security_combo_label")), is_new);
- gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (priv->builder, "security_vbox")), is_new);
-}
-
-static gboolean
-connection_combo_separator_cb (GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
-{
- gboolean is_separator = FALSE;
-
- gtk_tree_model_get (model, iter, C_SEP_COLUMN, &is_separator, -1);
- return is_separator;
-}
-
-static gint
-alphabetize_connections (NMConnection *a, NMConnection *b)
-{
- NMSettingConnection *asc, *bsc;
-
- asc = nm_connection_get_setting_connection (a);
- bsc = nm_connection_get_setting_connection (b);
-
- return strcmp (nm_setting_connection_get_id (asc),
- nm_setting_connection_get_id (bsc));
-}
-
-static gboolean
-connection_combo_init (NMAWifiDialog *self)
-{
- NMAWifiDialogPrivate *priv = NMA_WIFI_DIALOG_GET_PRIVATE (self);
- GtkListStore *store;
- int num_added = 0;
- GtkTreeIter tree_iter;
- GtkWidget *widget;
- NMSettingConnection *s_con;
- GtkCellRenderer *renderer;
- const char *id;
-
- g_clear_object (&priv->connection_model);
- g_clear_object (&priv->connection);
-
- /* New model */
- store = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_OBJECT, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
- priv->connection_model = GTK_TREE_MODEL (store);
-
- if (priv->specific_connection) {
- s_con = nm_connection_get_setting_connection (priv->specific_connection);
- g_assert (s_con);
- id = nm_setting_connection_get_id (s_con);
- if (id == NULL) {
- /* New connections which will be completed by NM won't have an ID
- * yet, but that doesn't matter because we don't show the connection
- * combo anyway when there's a predefined connection.
- */
- id = "blahblah";
- }
-
- gtk_list_store_append (store, &tree_iter);
- gtk_list_store_set (store, &tree_iter,
- C_NAME_COLUMN, id,
- C_CON_COLUMN, priv->specific_connection, -1);
- } else {
- GSList *to_add = NULL, *iter;
- const GPtrArray *connections;
- int i;
-
- gtk_list_store_append (store, &tree_iter);
- gtk_list_store_set (store, &tree_iter,
- C_NAME_COLUMN, _("New…"),
- C_NEW_COLUMN, TRUE, -1);
-
- gtk_list_store_append (store, &tree_iter);
- gtk_list_store_set (store, &tree_iter, C_SEP_COLUMN, TRUE, -1);
-
- connections = nm_client_get_connections (priv->client);
- for (i = 0; i < connections->len; i++) {
- NMConnection *candidate = NM_CONNECTION (connections->pdata[i]);
- NMSettingWireless *s_wireless;
- const char *connection_type;
- const char *mode;
- const char *setting_mac, *hw_addr;
-
- s_con = nm_connection_get_setting_connection (candidate);
- connection_type = s_con ? nm_setting_connection_get_connection_type (s_con) : NULL;
- if (!connection_type)
- continue;
-
- if (strcmp (connection_type, NM_SETTING_WIRELESS_SETTING_NAME))
- continue;
-
- s_wireless = nm_connection_get_setting_wireless (candidate);
- if (!s_wireless)
- continue;
-
- /* If creating a new Ad-Hoc network, only show shared network connections */
- if (priv->operation == OP_CREATE_ADHOC) {
- NMSettingIPConfig *s_ip4;
- const char *method = NULL;
-
- s_ip4 = nm_connection_get_setting_ip4_config (candidate);
- if (s_ip4)
- method = nm_setting_ip_config_get_method (s_ip4);
-
- if (!s_ip4 || strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED))
- continue;
-
- /* Ignore non-Ad-Hoc connections too */
- mode = nm_setting_wireless_get_mode (s_wireless);
- if (!mode || (strcmp (mode, "adhoc") && strcmp (mode, "ap")))
- continue;
- }
-
- /* Ignore connections that don't apply to the selected device */
- setting_mac = nm_setting_wireless_get_mac_address (s_wireless);
- hw_addr = nm_device_wifi_get_hw_address (NM_DEVICE_WIFI (priv->device));
- if ( setting_mac
- && hw_addr
- && !nm_utils_hwaddr_matches (setting_mac, -1, hw_addr, -1))
- continue;
-
- to_add = g_slist_append (to_add, candidate);
- }
-
- /* Alphabetize the list then add the connections */
- to_add = g_slist_sort (to_add, (GCompareFunc) alphabetize_connections);
- for (iter = to_add; iter; iter = g_slist_next (iter)) {
- NMConnection *candidate = NM_CONNECTION (iter->data);
-
- s_con = nm_connection_get_setting_connection (candidate);
- gtk_list_store_append (store, &tree_iter);
- gtk_list_store_set (store, &tree_iter,
- C_NAME_COLUMN, nm_setting_connection_get_id (s_con),
- C_CON_COLUMN, candidate, -1);
- num_added++;
- }
- g_slist_free (to_add);
- }
-
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "connection_combo"));
-
- gtk_cell_layout_clear (GTK_CELL_LAYOUT (widget));
- renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (widget), renderer, TRUE);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (widget), renderer,
- "text", C_NAME_COLUMN);
-#if !GTK_CHECK_VERSION(3,96,0)
- gtk_combo_box_set_wrap_width (GTK_COMBO_BOX (widget), 1);
-#endif
-
- gtk_combo_box_set_model (GTK_COMBO_BOX (widget), priv->connection_model);
-
- gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (widget),
- connection_combo_separator_cb,
- NULL,
- NULL);
-
- gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
-
- g_signal_handlers_disconnect_by_func (widget, connection_combo_changed, self);
- if (priv->specific_connection || !num_added) {
- gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->builder, "connection_label")));
- gtk_widget_hide (widget);
- } else {
- g_signal_connect (widget, "changed",
- G_CALLBACK (connection_combo_changed), self);
- }
- if (gtk_tree_model_get_iter_first (priv->connection_model, &tree_iter))
- gtk_tree_model_get (priv->connection_model, &tree_iter, C_CON_COLUMN, &priv->connection, -1);
-
- return TRUE;
-}
-
-static void
-device_combo_changed (GtkWidget *combo,
- gpointer user_data)
-{
- NMAWifiDialog *self = NMA_WIFI_DIALOG (user_data);
- NMAWifiDialogPrivate *priv = NMA_WIFI_DIALOG_GET_PRIVATE (self);
- GtkTreeIter iter;
- GtkTreeModel *model;
-
- if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter)) {
- g_warning ("%s: no active device combo box item.", __func__);
- return;
- }
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
-
- g_object_unref (priv->device);
- gtk_tree_model_get (model, &iter, D_DEV_COLUMN, &priv->device, -1);
-
- if (!connection_combo_init (self)) {
- g_warning ("Couldn't change connection combo box.");
- return;
- }
-
- if (!security_combo_init (self, priv->secrets_only, NULL, NULL)) {
- g_warning ("Couldn't change Wi-Fi security combo box.");
- return;
- }
-
- security_combo_changed (priv->sec_combo, self);
-}
-
-static void
-add_device_to_model (GtkListStore *model, NMDevice *device)
-{
- GtkTreeIter iter;
- const char *desc;
-
- desc = nm_device_get_description (device);
- gtk_list_store_append (model, &iter);
- gtk_list_store_set (model, &iter, D_NAME_COLUMN, desc, D_DEV_COLUMN, device, -1);
-}
-
-static gboolean
-can_use_device (NMDevice *device)
-{
- /* Ignore unsupported devices */
- if (!(nm_device_get_capabilities (device) & NM_DEVICE_CAP_NM_SUPPORTED))
- return FALSE;
-
- if (!NM_IS_DEVICE_WIFI (device))
- return FALSE;
-
- if (nm_device_get_state (device) < NM_DEVICE_STATE_DISCONNECTED)
- return FALSE;
-
- return TRUE;
-}
-
-static gboolean
-device_combo_init (NMAWifiDialog *self, NMDevice *device)
-{
- NMAWifiDialogPrivate *priv = NMA_WIFI_DIALOG_GET_PRIVATE (self);
- const GPtrArray *devices;
- GtkListStore *store;
- int i, num_added = 0;
-
- g_return_val_if_fail (priv->device == NULL, FALSE);
-
- store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_OBJECT);
- priv->device_model = GTK_TREE_MODEL (store);
-
- if (device) {
- if (!can_use_device (device))
- return FALSE;
- add_device_to_model (store, device);
- num_added++;
- } else {
- devices = nm_client_get_devices (priv->client);
- if (!devices)
- return FALSE;
-
- for (i = 0; devices && (i < devices->len); i++) {
- device = NM_DEVICE (g_ptr_array_index (devices, i));
- if (can_use_device (device)) {
- add_device_to_model (store, device);
- num_added++;
- }
- }
- }
-
- if (num_added > 0) {
- GtkWidget *widget;
- GtkTreeIter iter;
-
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "device_combo"));
- gtk_combo_box_set_model (GTK_COMBO_BOX (widget), priv->device_model);
- gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
- g_signal_connect (G_OBJECT (widget), "changed",
- G_CALLBACK (device_combo_changed), self);
- if (num_added == 1) {
- gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->builder, "device_label")));
- gtk_widget_hide (widget);
- }
- if (gtk_tree_model_get_iter_first (priv->device_model, &iter))
- gtk_tree_model_get (priv->device_model, &iter, D_DEV_COLUMN, &priv->device, -1);
- }
-
- return num_added > 0 ? TRUE : FALSE;
-}
-
-static gboolean
-find_proto (NMSettingWirelessSecurity *sec, const char *item)
-{
- guint32 i;
-
- for (i = 0; i < nm_setting_wireless_security_get_num_protos (sec); i++) {
- if (!strcmp (item, nm_setting_wireless_security_get_proto (sec, i)))
- return TRUE;
- }
- return FALSE;
-}
-
-static NMUtilsSecurityType
-get_default_type_for_security (NMSettingWirelessSecurity *sec,
- gboolean have_ap,
- guint32 ap_flags,
- guint32 dev_caps)
-{
- const char *key_mgmt, *auth_alg;
-
- g_return_val_if_fail (sec != NULL, NMU_SEC_NONE);
-
- key_mgmt = nm_setting_wireless_security_get_key_mgmt (sec);
- auth_alg = nm_setting_wireless_security_get_auth_alg (sec);
-
- /* No IEEE 802.1x */
- if (!strcmp (key_mgmt, "none"))
- return NMU_SEC_STATIC_WEP;
-
- if ( !strcmp (key_mgmt, "ieee8021x")
- && (!have_ap || (ap_flags & NM_802_11_AP_FLAGS_PRIVACY))) {
- if (auth_alg && !strcmp (auth_alg, "leap"))
- return NMU_SEC_LEAP;
- return NMU_SEC_DYNAMIC_WEP;
- }
-
- if (!strcmp (key_mgmt, "sae"))
- return NMU_SEC_SAE;
-
- if ( !strcmp (key_mgmt, "wpa-none")
- || !strcmp (key_mgmt, "wpa-psk")) {
- if (!have_ap || (ap_flags & NM_802_11_AP_FLAGS_PRIVACY)) {
- if (find_proto (sec, "rsn"))
- return NMU_SEC_WPA2_PSK;
- else if (find_proto (sec, "wpa"))
- return NMU_SEC_WPA_PSK;
- else
- return NMU_SEC_WPA_PSK;
- }
- }
-
- if ( !strcmp (key_mgmt, "wpa-eap")
- && (!have_ap || (ap_flags & NM_802_11_AP_FLAGS_PRIVACY))) {
- if (find_proto (sec, "rsn"))
- return NMU_SEC_WPA2_ENTERPRISE;
- else if (find_proto (sec, "wpa"))
- return NMU_SEC_WPA_ENTERPRISE;
- else
- return NMU_SEC_WPA_ENTERPRISE;
- }
-
- return NMU_SEC_INVALID;
-}
-
-static void
-add_security_item (NMAWifiDialog *self,
- WirelessSecurity *sec,
- GtkListStore *model,
- GtkTreeIter *iter,
- const char *text)
-{
- wireless_security_set_changed_notify (sec, stuff_changed_cb, self);
- gtk_list_store_append (model, iter);
- gtk_list_store_set (model, iter, S_NAME_COLUMN, text, S_SEC_COLUMN, sec, -1);
- wireless_security_unref (sec);
-}
-
-static void
-get_secrets_cb (GObject *object,
- GAsyncResult *result,
- gpointer user_data)
-{
- GetSecretsInfo *info = user_data;
- NMRemoteConnection *connection = NM_REMOTE_CONNECTION (object);
- NMAWifiDialogPrivate *priv;
- GVariant *secrets;
- GVariantIter variant_iter;
- const char *setting_name;
- GVariant *setting_dict;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GError *error = NULL;
- gboolean current_secrets = FALSE;
-
- if (info->canceled)
- goto out;
-
- priv = NMA_WIFI_DIALOG_GET_PRIVATE (info->self);
- if (priv->secrets_info == info) {
- priv->secrets_info = NULL;
-
- /* Buttons should only be re-enabled if this secrets response is the
- * in-progress one.
- */
- gtk_dialog_set_response_sensitive (GTK_DIALOG (info->self), GTK_RESPONSE_CANCEL, TRUE);
- current_secrets = TRUE;
- }
-
- secrets = nm_remote_connection_get_secrets_finish (connection, result, &error);
- if (error) {
- g_warning ("%s: error getting connection secrets: (%d) %s",
- __func__,
- error ? error->code : -1,
- error && error->message ? error->message : "(unknown)");
- goto out;
- }
-
- if (current_secrets)
- _set_ok_sensitive (info->self, TRUE, NULL);
-
- /* User might have changed the connection while the secrets call was in
- * progress, so don't try to update the wrong connection with the secrets
- * we just received.
- */
- if ( (priv->connection != info->connection)
- || !secrets)
- goto out;
-
- /* Try to update the connection's secrets; log errors but we don't care */
- g_variant_iter_init (&variant_iter, secrets);
- while (g_variant_iter_next (&variant_iter, "{&s@a{sv}}", &setting_name, &setting_dict)) {
- GError *update_error = NULL;
-
- if (!nm_connection_update_secrets (priv->connection,
- setting_name,
- setting_dict,
- &update_error)) {
- g_warning ("%s: error updating connection secrets: (%d) %s",
- __func__,
- update_error ? update_error->code : -1,
- update_error && update_error->message ? update_error->message : "(unknown)");
- g_clear_error (&update_error);
- }
- g_variant_unref (setting_dict);
- }
-
- /* Update each security method's UI elements with the new secrets */
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->sec_combo));
- if (gtk_tree_model_get_iter_first (model, &iter)) {
- do {
- WirelessSecurity *sec = NULL;
-
- gtk_tree_model_get (model, &iter, S_SEC_COLUMN, &sec, -1);
- if (sec) {
- wireless_security_update_secrets (sec, priv->connection);
- wireless_security_unref (sec);
- }
- } while (gtk_tree_model_iter_next (model, &iter));
- }
-
-out:
- g_object_unref (info->connection);
- g_free (info);
-}
-
-static gboolean
-security_valid (NMUtilsSecurityType sectype,
- NM80211Mode mode,
- NMDeviceWifiCapabilities wifi_caps,
- gboolean have_ap,
- NM80211ApFlags ap_flags,
- NM80211ApSecurityFlags ap_wpa,
- NM80211ApSecurityFlags ap_rsn)
-{
- switch (mode) {
- case NM_802_11_MODE_AP:
- if (sectype == NMU_SEC_SAE)
- return TRUE;
- return nm_utils_ap_mode_security_valid (sectype, wifi_caps);
- case NM_802_11_MODE_ADHOC:
- case NM_802_11_MODE_INFRA:
- default:
- return nm_utils_security_valid (sectype,
- wifi_caps,
- have_ap,
- (mode == NM_802_11_MODE_ADHOC),
- ap_flags, ap_wpa, ap_rsn);
- }
- g_assert_not_reached ();
-}
-
-static gboolean
-security_combo_init (NMAWifiDialog *self, gboolean secrets_only,
- const char *secrets_setting_name, const char *const*secrets_hints)
-{
- NMAWifiDialogPrivate *priv;
- GtkListStore *sec_model;
- GtkTreeIter iter;
- guint32 ap_flags = 0;
- guint32 ap_wpa = 0;
- guint32 ap_rsn = 0;
- guint32 dev_caps;
- NMSettingWirelessSecurity *wsec = NULL;
- NMUtilsSecurityType default_type = NMU_SEC_NONE;
- NMWepKeyType wep_type = NM_WEP_KEY_TYPE_KEY;
- int active = -1;
- int item = 0;
- NMSettingWireless *s_wireless = NULL;
- NM80211Mode mode;
- const char *setting_name;
-
- g_return_val_if_fail (self != NULL, FALSE);
-
- priv = NMA_WIFI_DIALOG_GET_PRIVATE (self);
- g_return_val_if_fail (priv->device != NULL, FALSE);
- g_return_val_if_fail (priv->sec_combo != NULL, FALSE);
-
- mode = (priv->operation == OP_CREATE_ADHOC) ? NM_802_11_MODE_ADHOC : NM_802_11_MODE_INFRA;
-
- /* The security options displayed are filtered based on device
- * capabilities, and if provided, additionally by access point capabilities.
- * If a connection is given, that connection's options should be selected
- * by default. If hints is non-empty only filter based on the setting
- * keys on the hints list.
- */
- dev_caps = nm_device_wifi_get_capabilities (NM_DEVICE_WIFI (priv->device));
- if (priv->ap != NULL) {
- ap_flags = nm_access_point_get_flags (priv->ap);
- ap_wpa = nm_access_point_get_wpa_flags (priv->ap);
- ap_rsn = nm_access_point_get_rsn_flags (priv->ap);
- }
-
- if (priv->connection) {
- const char *mode_str;
-
- s_wireless = nm_connection_get_setting_wireless (priv->connection);
-
- mode_str = nm_setting_wireless_get_mode (s_wireless);
- if (mode_str && !strcmp (mode_str, "adhoc"))
- mode = NM_802_11_MODE_ADHOC;
- else if (mode_str && !strcmp (mode_str, "ap"))
- mode = NM_802_11_MODE_AP;
- else
- mode = NM_802_11_MODE_INFRA;
-
- wsec = nm_connection_get_setting_wireless_security (priv->connection);
-
- if (wsec) {
- default_type = get_default_type_for_security (wsec, !!priv->ap, ap_flags, dev_caps);
- if (default_type == NMU_SEC_STATIC_WEP)
- wep_type = nm_setting_wireless_security_get_wep_key_type (wsec);
- if (wep_type == NM_WEP_KEY_TYPE_UNKNOWN)
- wep_type = NM_WEP_KEY_TYPE_KEY;
- }
- } else if (mode == NM_802_11_MODE_ADHOC) {
- default_type = NMU_SEC_STATIC_WEP;
- wep_type = NM_WEP_KEY_TYPE_PASSPHRASE;
- }
-
- sec_model = gtk_list_store_new (2, G_TYPE_STRING, WIRELESS_TYPE_SECURITY);
-
- if (security_valid (NMU_SEC_NONE, mode, dev_caps, !!priv->ap, ap_flags, ap_wpa, ap_rsn)) {
- gtk_list_store_append (sec_model, &iter);
- gtk_list_store_set (sec_model, &iter,
- S_NAME_COLUMN, C_("Wifi/wired security", "None"),
- -1);
- if (default_type == NMU_SEC_NONE)
- active = item;
- item++;
- }
-
- /* Don't show Static WEP if both the AP and the device are capable of WPA,
- * even though technically it's possible to have this configuration.
- */
- if ( security_valid (NMU_SEC_STATIC_WEP, mode, dev_caps, !!priv->ap, ap_flags, ap_wpa, ap_rsn)
- && ((!ap_wpa && !ap_rsn) || !(dev_caps & (NM_WIFI_DEVICE_CAP_WPA | NM_WIFI_DEVICE_CAP_RSN)))) {
- WirelessSecurityWEPKey *ws_wep;
-
- ws_wep = ws_wep_key_new (priv->connection, NM_WEP_KEY_TYPE_KEY, mode == NM_802_11_MODE_ADHOC, secrets_only);
- if (ws_wep) {
- add_security_item (self, WIRELESS_SECURITY (ws_wep), sec_model,
- &iter, _("WEP 40/128-bit Key (Hex or ASCII)"));
- if ((active < 0) && (default_type == NMU_SEC_STATIC_WEP) && (wep_type == NM_WEP_KEY_TYPE_KEY))
- active = item;
- item++;
- }
-
- ws_wep = ws_wep_key_new (priv->connection, NM_WEP_KEY_TYPE_PASSPHRASE, mode == NM_802_11_MODE_ADHOC, secrets_only);
- if (ws_wep) {
- add_security_item (self, WIRELESS_SECURITY (ws_wep), sec_model,
- &iter, _("WEP 128-bit Passphrase"));
- if ((active < 0) && (default_type == NMU_SEC_STATIC_WEP) && (wep_type == NM_WEP_KEY_TYPE_PASSPHRASE))
- active = item;
- item++;
- }
- }
-
- /* Don't show LEAP if both the AP and the device are capable of WPA,
- * even though technically it's possible to have this configuration.
- */
- if ( security_valid (NMU_SEC_LEAP, mode, dev_caps, !!priv->ap, ap_flags, ap_wpa, ap_rsn)
- && ((!ap_wpa && !ap_rsn) || !(dev_caps & (NM_WIFI_DEVICE_CAP_WPA | NM_WIFI_DEVICE_CAP_RSN)))) {
- WirelessSecurityLEAP *ws_leap;
-
- ws_leap = ws_leap_new (priv->connection, secrets_only);
- if (ws_leap) {
- add_security_item (self, WIRELESS_SECURITY (ws_leap), sec_model,
- &iter, _("LEAP"));
- if ((active < 0) && (default_type == NMU_SEC_LEAP))
- active = item;
- item++;
- }
- }
-
- if (security_valid (NMU_SEC_DYNAMIC_WEP, mode, dev_caps, !!priv->ap, ap_flags, ap_wpa, ap_rsn)) {
- WirelessSecurityDynamicWEP *ws_dynamic_wep;
-
- ws_dynamic_wep = ws_dynamic_wep_new (priv->connection, FALSE, secrets_only);
- if (ws_dynamic_wep) {
- add_security_item (self, WIRELESS_SECURITY (ws_dynamic_wep), sec_model,
- &iter, _("Dynamic WEP (802.1x)"));
- if ((active < 0) && (default_type == NMU_SEC_DYNAMIC_WEP))
- active = item;
- item++;
- }
- }
-
- if ( security_valid (NMU_SEC_WPA_PSK, mode, dev_caps, !!priv->ap, ap_flags, ap_wpa, ap_rsn)
- || security_valid (NMU_SEC_WPA2_PSK, mode, dev_caps, !!priv->ap, ap_flags, ap_wpa, ap_rsn)) {
- WirelessSecurityWPAPSK *ws_wpa_psk;
-
- ws_wpa_psk = ws_wpa_psk_new (priv->connection, secrets_only);
- if (ws_wpa_psk) {
- add_security_item (self, WIRELESS_SECURITY (ws_wpa_psk), sec_model,
- &iter, _("WPA & WPA2 Personal"));
- if ((active < 0) && ((default_type == NMU_SEC_WPA_PSK) || (default_type == NMU_SEC_WPA2_PSK)))
- active = item;
- item++;
- }
- }
-
- if ( security_valid (NMU_SEC_WPA_ENTERPRISE, mode, dev_caps, !!priv->ap, ap_flags, ap_wpa, ap_rsn)
- || security_valid (NMU_SEC_WPA2_ENTERPRISE, mode, dev_caps, !!priv->ap, ap_flags, ap_wpa, ap_rsn)) {
- WirelessSecurityWPAEAP *ws_wpa_eap;
- const char *const*hints = NULL;
-
- if (secrets_setting_name && !strcmp (secrets_setting_name, NM_SETTING_802_1X_SETTING_NAME))
- hints = secrets_hints;
-
- ws_wpa_eap = ws_wpa_eap_new (priv->connection, FALSE, secrets_only, hints);
- if (ws_wpa_eap) {
- add_security_item (self, WIRELESS_SECURITY (ws_wpa_eap), sec_model,
- &iter, _("WPA & WPA2 Enterprise"));
- if ((active < 0) && ((default_type == NMU_SEC_WPA_ENTERPRISE) || (default_type == NMU_SEC_WPA2_ENTERPRISE)))
- active = item;
- item++;
- }
- }
-
- if (security_valid (NMU_SEC_SAE, mode, dev_caps, !!priv->ap, ap_flags, ap_wpa, ap_rsn)) {
- WirelessSecuritySAE *ws_sae;
-
- ws_sae = ws_sae_new (priv->connection, secrets_only);
- if (ws_sae) {
- add_security_item (self, WIRELESS_SECURITY (ws_sae), sec_model,
- &iter, _("WPA3 Personal"));
- if (active < 0 && default_type == NMU_SEC_SAE)
- active = item;
- item++;
- }
- }
-
- gtk_combo_box_set_model (GTK_COMBO_BOX (priv->sec_combo), GTK_TREE_MODEL (sec_model));
- gtk_combo_box_set_active (GTK_COMBO_BOX (priv->sec_combo), active < 0 ? 0 : (guint32) active);
- g_object_unref (G_OBJECT (sec_model));
-
- /* If the dialog was given a connection when it was created, that connection
- * will already be populated with secrets. If no connection was given,
- * then we need to get any existing secrets to populate the dialog with.
- */
- if (priv->connection) {
- if (secrets_setting_name)
- setting_name = secrets_setting_name;
- else
- setting_name = nm_connection_need_secrets (priv->connection, NULL);
- } else
- setting_name = NULL;
-
- if (setting_name && NM_IS_REMOTE_CONNECTION (priv->connection)) {
- GetSecretsInfo *info;
-
- /* Desensitize the dialog's buttons while we wait for the secrets
- * operation to complete.
- */
- _set_ok_sensitive (self, FALSE, NULL);
- gtk_dialog_set_response_sensitive (GTK_DIALOG (self), GTK_RESPONSE_CANCEL, FALSE);
-
- info = g_malloc0 (sizeof (GetSecretsInfo));
- info->self = self;
- info->connection = g_object_ref (priv->connection);
- priv->secrets_info = info;
-
- nm_remote_connection_get_secrets_async (NM_REMOTE_CONNECTION (priv->connection),
- setting_name, NULL, get_secrets_cb, info);
- }
-
- return TRUE;
-}
-
-static gboolean
-revalidate (gpointer user_data)
-{
- NMAWifiDialog *self = NMA_WIFI_DIALOG (user_data);
- NMAWifiDialogPrivate *priv = NMA_WIFI_DIALOG_GET_PRIVATE (self);
-
- priv->revalidate_id = 0;
- security_combo_changed (priv->sec_combo, self);
- return FALSE;
-}
-
-static gboolean
-internal_init (NMAWifiDialog *self,
- NMConnection *specific_connection,
- NMDevice *specific_device,
- gboolean secrets_only,
- const char *secrets_setting_name,
- const char *const*secrets_hints)
-{
- NMAWifiDialogPrivate *priv = NMA_WIFI_DIALOG_GET_PRIVATE (self);
- GtkWidget *widget;
- char *label, *icon_name = "network-wireless";
- gboolean security_combo_focus = FALSE;
-
- gtk_window_set_position (GTK_WINDOW (self), GTK_WIN_POS_CENTER_ALWAYS);
- gtk_window_set_default_size (GTK_WINDOW (self), 488, -1);
- gtk_window_set_resizable (GTK_WINDOW (self), FALSE);
-
- priv->secrets_only = secrets_only;
- if (secrets_only)
- icon_name = "dialog-password";
- else
- icon_name = "network-wireless";
-
- if (specific_connection)
- priv->specific_connection = g_object_ref (specific_connection);
-
- gtk_window_set_icon_name (GTK_WINDOW (self), icon_name);
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "image1"));
-#if GTK_CHECK_VERSION(3,90,0)
- gtk_image_set_from_icon_name (GTK_IMAGE (widget), icon_name);
-#else
- gtk_image_set_from_icon_name (GTK_IMAGE (widget), icon_name, GTK_ICON_SIZE_DIALOG);
-#endif
-
- gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))), 2);
-
- widget = gtk_dialog_add_button (GTK_DIALOG (self), _("_Cancel"), GTK_RESPONSE_CANCEL);
-
- /* Connect/Create button */
- if (priv->operation == OP_CREATE_ADHOC) {
- widget = gtk_dialog_add_button (GTK_DIALOG (self), _("C_reate"), GTK_RESPONSE_OK);
- } else {
- widget = gtk_dialog_add_button (GTK_DIALOG (self), _("C_onnect"), GTK_RESPONSE_OK);
- priv->ok_response_button = widget;
- }
-
-#if !GTK_CHECK_VERSION(3,96,0)
- g_object_set (G_OBJECT (widget), "can-default", TRUE, NULL);
- gtk_widget_grab_default (widget);
-#endif
-
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "wifi_dialog"));
- if (!widget) {
- g_warning ("Couldn't find Wi-Fi_dialog widget.");
- return FALSE;
- }
-
- gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (self))), widget);
-
- /* If given a valid connection, hide the SSID bits and connection combo */
- if (specific_connection) {
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "network_name_label"));
- gtk_widget_hide (widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "network_name_entry"));
- gtk_widget_hide (widget);
-
- security_combo_focus = TRUE;
- priv->network_name_focus = FALSE;
- } else {
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "network_name_entry"));
- g_signal_connect (G_OBJECT (widget), "changed", (GCallback) ssid_entry_changed, self);
- priv->network_name_focus = TRUE;
- }
-
- _set_ok_sensitive (self, FALSE, NULL);
-
- if (!device_combo_init (self, specific_device)) {
- g_warning ("No Wi-Fi devices available.");
- return FALSE;
- }
-
- if (!connection_combo_init (self)) {
- g_warning ("Couldn't set up connection combo box.");
- return FALSE;
- }
-
- if (!security_combo_init (self, priv->secrets_only, secrets_setting_name, secrets_hints)) {
- g_warning ("Couldn't set up Wi-Fi security combo box.");
- return FALSE;
- }
-
- security_combo_changed (priv->sec_combo, self);
- g_signal_connect (G_OBJECT (priv->sec_combo), "changed",
- G_CALLBACK (security_combo_changed_manually), self);
-
- if (secrets_only) {
- gtk_widget_hide (priv->sec_combo);
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "security_combo_label"));
- gtk_widget_hide (widget);
- }
-
- if (security_combo_focus && !secrets_only)
- gtk_widget_grab_focus (priv->sec_combo);
- else if (priv->network_name_focus) {
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "network_name_entry"));
- gtk_widget_grab_focus (widget);
- }
-
- if (priv->connection) {
- char *tmp;
- char *esc_ssid = NULL;
- NMSettingWireless *s_wireless;
- GBytes *ssid;
-
- s_wireless = nm_connection_get_setting_wireless (priv->connection);
- ssid = s_wireless ? nm_setting_wireless_get_ssid (s_wireless) : NULL;
- if (ssid)
- esc_ssid = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid));
-
- tmp = g_strdup_printf (_("Passwords or encryption keys are required to access the Wi-Fi network “%s”."),
- esc_ssid ? esc_ssid : "<unknown>");
- gtk_window_set_title (GTK_WINDOW (self), _("Wi-Fi Network Authentication Required"));
- label = g_markup_printf_escaped ("<span size=\"larger\" weight=\"bold\">%s</span>\n\n%s",
- _("Authentication required by Wi-Fi network"),
- tmp);
- g_free (esc_ssid);
- g_free (tmp);
- } else if (priv->operation == OP_CREATE_ADHOC) {
- gtk_window_set_title (GTK_WINDOW (self), _("Create New Wi-Fi Network"));
- label = g_strdup_printf ("<span size=\"larger\" weight=\"bold\">%s</span>\n\n%s",
- _("New Wi-Fi network"),
- _("Enter a name for the Wi-Fi network you wish to create."));
- } else if (priv->operation == OP_CONNECT_HIDDEN) {
- gtk_window_set_title (GTK_WINDOW (self), _("Connect to Hidden Wi-Fi Network"));
- label = g_strdup_printf ("<span size=\"larger\" weight=\"bold\">%s</span>\n\n%s",
- _("Hidden Wi-Fi network"),
- _("Enter the name and security details of the hidden Wi-Fi network you wish to connect to."));
- } else
- g_assert_not_reached ();
-
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "caption_label"));
- gtk_label_set_markup (GTK_LABEL (widget), label);
- g_free (label);
-
- /* Re-validate from an idle handler so that widgets like file choosers
- * have had time to find their files.
- */
- priv->revalidate_id = g_idle_add (revalidate, self);
-
- return TRUE;
-}
-
-/**
- * nma_wifi_dialog_get_connection:
- * @self: an #NMAWifiDialog
- * @device: (out):
- * @ap: (out):
- *
- * Returns: (transfer full):
- */
-NMConnection *
-nma_wifi_dialog_get_connection (NMAWifiDialog *self,
- NMDevice **device,
- NMAccessPoint **ap)
-{
- NMAWifiDialogPrivate *priv;
- GtkWidget *combo;
- GtkTreeModel *model;
- WirelessSecurity *sec = NULL;
- GtkTreeIter iter;
- NMConnection *connection;
- NMSettingWireless *s_wireless;
-
- g_return_val_if_fail (self != NULL, NULL);
-
- priv = NMA_WIFI_DIALOG_GET_PRIVATE (self);
-
- if (!priv->connection) {
- NMSettingConnection *s_con;
- char *uuid;
- GBytes *ssid;
-
- connection = nm_simple_connection_new ();
-
- s_con = (NMSettingConnection *) nm_setting_connection_new ();
- uuid = nm_utils_uuid_generate ();
- g_object_set (s_con,
- NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME,
- NM_SETTING_CONNECTION_UUID, uuid,
- NULL);
- g_free (uuid);
- nm_connection_add_setting (connection, (NMSetting *) s_con);
-
- s_wireless = (NMSettingWireless *) nm_setting_wireless_new ();
- ssid = validate_dialog_ssid (self);
- g_object_set (s_wireless, NM_SETTING_WIRELESS_SSID, ssid, NULL);
- g_bytes_unref (ssid);
-
- if (priv->operation == OP_CREATE_ADHOC) {
- NMSetting *s_ip4;
-
- g_object_set (s_wireless, NM_SETTING_WIRELESS_MODE, "adhoc", NULL);
-
- s_ip4 = nm_setting_ip4_config_new ();
- g_object_set (s_ip4,
- NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_SHARED,
- NULL);
- nm_connection_add_setting (connection, s_ip4);
- } else if (priv->operation == OP_CONNECT_HIDDEN) {
- /* Mark as a hidden SSID network */
- g_object_set (s_wireless, NM_SETTING_WIRELESS_HIDDEN, TRUE, NULL);
- } else
- g_assert_not_reached ();
-
- nm_connection_add_setting (connection, (NMSetting *) s_wireless);
- } else
- connection = g_object_ref (priv->connection);
-
- /* Fill security */
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->sec_combo));
- if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->sec_combo), &iter))
- gtk_tree_model_get (model, &iter, S_SEC_COLUMN, &sec, -1);
- if (sec) {
- wireless_security_fill_connection (sec, connection);
- wireless_security_unref (sec);
- }
-
- /* Save new CA cert ignore values to GSettings */
- eap_method_ca_cert_ignore_save (connection);
-
- /* Fill device */
- if (device) {
- combo = GTK_WIDGET (gtk_builder_get_object (priv->builder, "device_combo"));
- gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter);
- gtk_tree_model_get (priv->device_model, &iter, D_DEV_COLUMN, device, -1);
- g_object_unref (*device);
- }
-
- if (ap)
- *ap = priv->ap;
-
- return connection;
-}
-
-static GtkWidget *
-internal_new_dialog (NMClient *client,
- NMConnection *connection,
- NMDevice *device,
- NMAccessPoint *ap,
- gboolean secrets_only,
- const char *secrets_setting_name,
- const char *const*secrets_hints)
-{
- NMAWifiDialog *self;
- NMAWifiDialogPrivate *priv;
-
- g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- self = NMA_WIFI_DIALOG (g_object_new (NMA_TYPE_WIFI_DIALOG, NULL));
- if (self) {
- priv = NMA_WIFI_DIALOG_GET_PRIVATE (self);
-
- priv->client = g_object_ref (client);
- if (ap)
- priv->ap = g_object_ref (ap);
-
- priv->sec_combo = GTK_WIDGET (gtk_builder_get_object (priv->builder, "security_combo"));
- priv->group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
-
- /* Handle CA cert ignore stuff */
- eap_method_ca_cert_ignore_load (connection);
-
- if (!internal_init (self, connection, device, secrets_only, secrets_setting_name, secrets_hints)) {
- g_warning ("Couldn't create Wi-Fi security dialog.");
- gtk_widget_destroy (GTK_WIDGET (self));
- self = NULL;
- }
- }
-
- return GTK_WIDGET (self);
-}
-
-/**
- * nma_wifi_dialog_new:
- * @client: client to retrieve list of devices or connections from
- * @connection: connection to be shown/edited or %NULL
- * @device: device to check connection compatibility against
- * @ap: AP to check connection compatibility against
- * @secrets_only: whether to only ask for secrets for given connection
- *
- * Creates a wifi connection dialog and populates it with settings from
- * @connection if given. If @device is not given a device selection combo box
- * will be included. If @connection is not given a connection selection combo
- * box will be included. If @secrets_only is %FALSE a complete connection
- * creator/editor dialog is returned, otherwise only wifi security secrets
- * relevant to the security settings in @connection are going to be shown and
- * will be editable.
- *
- * Returns: the dialog widget or %NULL in case of error
- */
-GtkWidget *
-nma_wifi_dialog_new (NMClient *client,
- NMConnection *connection,
- NMDevice *device,
- NMAccessPoint *ap,
- gboolean secrets_only)
-{
- guint32 dev_caps;
-
- /* Ensure device validity */
- if (device) {
- dev_caps = nm_device_get_capabilities (device);
- g_return_val_if_fail (dev_caps & NM_DEVICE_CAP_NM_SUPPORTED, NULL);
- g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL);
- }
-
- return internal_new_dialog (client,
- connection,
- device,
- ap,
- secrets_only,
- NULL,
- NULL);
-}
-
-/**
- * nma_wifi_dialog_new_for_secrets:
- * @client: client to retrieve list of devices or connections from
- * @connection: connection for which secrets are requested
- * @secrets_setting_name: setting name whose secrets are requested
- * or %NULL
- * @secrets_hints: array of setting key names within the setting given in
- * @secrets_setting_name which are requested or %NULL
- *
- * Creates a wifi secrets dialog and populates it with setting values from
- * @connection. If @secrets_setting_name and @secrets_hints are not given
- * this function creates an identical dialog as nma_wifi_dialog_new() would
- * create with the @secrets_only parameter %TRUE. Otherwise
- * @secrets_setting_name and @secrets_hints determine the list of specific
- * secrets that are being requested from the user and no editable entries
- * are shown for any other settings.
- *
- * Note: only a subset of all settings and setting keys is supported as
- * @secrets_setting_name and @secrets_hints.
- *
- * Returns: the dialog widget or %NULL in case of error
- */
-GtkWidget *
-nma_wifi_dialog_new_for_secrets (NMClient *client,
- NMConnection *connection,
- const char *secrets_setting_name,
- const char *const*secrets_hints)
-{
- return internal_new_dialog (client,
- connection,
- NULL,
- NULL,
- TRUE,
- secrets_setting_name,
- secrets_hints);
-}
-
-static GtkWidget *
-internal_new_operation (NMClient *client,
- guint operation)
-{
- NMAWifiDialog *self;
- NMAWifiDialogPrivate *priv;
-
- g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
-
- self = NMA_WIFI_DIALOG (g_object_new (NMA_TYPE_WIFI_DIALOG, NULL));
- if (!self)
- return NULL;
-
- priv = NMA_WIFI_DIALOG_GET_PRIVATE (self);
-
- priv->client = g_object_ref (client);
- priv->sec_combo = GTK_WIDGET (gtk_builder_get_object (priv->builder, "security_combo"));
- priv->group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
- priv->operation = operation;
-
- if (!internal_init (self, NULL, NULL, FALSE, NULL, NULL)) {
- g_warning ("Couldn't create Wi-Fi security dialog.");
- gtk_widget_destroy (GTK_WIDGET (self));
- return NULL;
- }
-
- return GTK_WIDGET (self);
-}
-
-GtkWidget *
-nma_wifi_dialog_new_for_hidden (NMClient *client)
-{
- return internal_new_operation (client, OP_CONNECT_HIDDEN);
-}
-
-GtkWidget *
-nma_wifi_dialog_new_for_other (NMClient *client)
-{
- return internal_new_operation (client, OP_CONNECT_HIDDEN);
-}
-
-GtkWidget *
-nma_wifi_dialog_new_for_create (NMClient *client)
-{
- return internal_new_operation (client, OP_CREATE_ADHOC);
-}
-
-/**
- * nma_wifi_dialog_nag_user:
- * @self:
- *
- * Returns: (transfer full):
- */
-GtkWidget *
-nma_wifi_dialog_nag_user (NMAWifiDialog *self)
-{
- return NULL;
-}
-
-static void
-nma_wifi_dialog_init (NMAWifiDialog *self)
-{
- NMAWifiDialogPrivate *priv = NMA_WIFI_DIALOG_GET_PRIVATE (self);
- GError *error = NULL;
-
- priv->builder = gtk_builder_new ();
-
- if (!gtk_builder_add_from_resource (priv->builder, "/org/freedesktop/network-manager-applet/wifi.ui", &error)) {
- g_warning ("Couldn't load builder resource: %s", error->message);
- g_error_free (error);
- }
-}
-
-static void
-dispose (GObject *object)
-{
- NMAWifiDialogPrivate *priv = NMA_WIFI_DIALOG_GET_PRIVATE (object);
-
-
- if (priv->secrets_info) {
- priv->secrets_info->canceled = TRUE;
- priv->secrets_info = NULL;
- }
-
- g_clear_object (&priv->client);
- g_clear_object (&priv->builder);
-
- g_clear_object (&priv->device_model);
- g_clear_object (&priv->connection_model);
-
- g_clear_object (&priv->group);
-
- g_clear_object (&priv->specific_connection);
- g_clear_object (&priv->connection);
-
- g_clear_object (&priv->device);
-
- g_clear_object (&priv->ap);
-
- if (priv->revalidate_id) {
- g_source_remove (priv->revalidate_id);
- priv->revalidate_id = 0;
- }
-
- G_OBJECT_CLASS (nma_wifi_dialog_parent_class)->dispose (object);
-}
-
-static void
-nma_wifi_dialog_class_init (NMAWifiDialogClass *nmad_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (nmad_class);
-
- g_type_class_add_private (nmad_class, sizeof (NMAWifiDialogPrivate));
-
- /* virtual methods */
- object_class->dispose = dispose;
-}
diff --git a/src/libnma/nma-wifi-dialog.h b/src/libnma/nma-wifi-dialog.h
deleted file mode 100644
index 18c43b0a..00000000
--- a/src/libnma/nma-wifi-dialog.h
+++ /dev/null
@@ -1,69 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
- *
- * Dan Williams <dcbw@redhat.com>
- *
- * Copyright 2007 - 2014 Red Hat, Inc.
- */
-
-#ifndef NMA_WIFI_DIALOG_H
-#define NMA_WIFI_DIALOG_H
-
-#include <gtk/gtk.h>
-#include <glib.h>
-#include <glib-object.h>
-
-#include <NetworkManager.h>
-
-#include "nma-version.h"
-
-#define NMA_TYPE_WIFI_DIALOG (nma_wifi_dialog_get_type ())
-#define NMA_WIFI_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMA_TYPE_WIFI_DIALOG, NMAWifiDialog))
-#define NMA_WIFI_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMA_TYPE_WIFI_DIALOG, NMAWifiDialogClass))
-#define NMA_IS_WIFI_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMA_TYPE_WIFI_DIALOG))
-#define NMA_IS_WIFI_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMA_TYPE_WIFI_DIALOG))
-#define NMA_WIFI_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMA_TYPE_WIFI_DIALOG, NMAWifiDialogClass))
-
-typedef struct {
- GtkDialog parent;
-} NMAWifiDialog;
-
-typedef struct {
- GtkDialogClass parent;
-} NMAWifiDialogClass;
-
-GType nma_wifi_dialog_get_type (void);
-
-GtkWidget *nma_wifi_dialog_new (NMClient *client,
- NMConnection *connection,
- NMDevice *device,
- NMAccessPoint *ap,
- gboolean secrets_only);
-
-GtkWidget *nma_wifi_dialog_new_for_secrets (NMClient *client,
- NMConnection *connection,
- const char *secrets_setting_name,
- const char *const*secrets_hints);
-
-GtkWidget *nma_wifi_dialog_new_for_hidden (NMClient *client);
-
-GtkWidget *nma_wifi_dialog_new_for_create (NMClient *client);
-
-NMConnection * nma_wifi_dialog_get_connection (NMAWifiDialog *self,
- NMDevice **device,
- NMAccessPoint **ap);
-
-NMA_DEPRECATED_IN_1_2
-GtkWidget * nma_wifi_dialog_nag_user (NMAWifiDialog *self);
-
-NMA_DEPRECATED_IN_1_2
-void nma_wifi_dialog_set_nag_ignored (NMAWifiDialog *self, gboolean ignored);
-
-NMA_DEPRECATED_IN_1_2
-gboolean nma_wifi_dialog_get_nag_ignored (NMAWifiDialog *self);
-
-NMA_DEPRECATED_IN_1_2_FOR(nma_wifi_dialog_new_for_hidden)
-GtkWidget *nma_wifi_dialog_new_for_other (NMClient *client);
-
-#endif /* NMA_WIFI_DIALOG_H */
-
diff --git a/src/libnma/nma.gresource.xml b/src/libnma/nma.gresource.xml
deleted file mode 100644
index ee1fcb20..00000000
--- a/src/libnma/nma.gresource.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<gresources>
- <gresource prefix="/org/freedesktop/network-manager-applet">
- <file preprocess="xml-stripblanks">wifi.ui</file>
- <file preprocess="xml-stripblanks">nma-pkcs11-token-login-dialog.ui</file>
- <file preprocess="xml-stripblanks">nma-pkcs11-cert-chooser-dialog.ui</file>
- <file preprocess="xml-stripblanks">nma-mobile-wizard.ui</file>
- <file preprocess="xml-stripblanks">nma-vpn-password-dialog.ui</file>
- <file preprocess="xml-stripblanks">nma-bar-code-widget.ui</file>
- </gresource>
-</gresources>
diff --git a/src/libnma/qrcodegen.c b/src/libnma/qrcodegen.c
deleted file mode 100644
index 7cda9659..00000000
--- a/src/libnma/qrcodegen.c
+++ /dev/null
@@ -1,1009 +0,0 @@
-/*
- * QR Code generator library (C)
- *
- * Copyright (c) Project Nayuki. (MIT License)
- * https://www.nayuki.io/page/qr-code-generator-library
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and associated documentation files (the "Software"), to deal in
- * the Software without restriction, including without limitation the rights to
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
- * the Software, and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- * - The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- * - The Software is provided "as is", without warranty of any kind, express or
- * implied, including but not limited to the warranties of merchantability,
- * fitness for a particular purpose and noninfringement. In no event shall the
- * authors or copyright holders be liable for any claim, damages or other
- * liability, whether in an action of contract, tort or otherwise, arising from,
- * out of or in connection with the Software or the use or other dealings in the
- * Software.
- */
-
-#include <assert.h>
-#include <limits.h>
-#include <stdlib.h>
-#include <string.h>
-#include "qrcodegen.h"
-
-#ifndef QRCODEGEN_TEST
- #define testable static // Keep functions private
-#else
- #define testable // Expose private functions
-#endif
-
-
-/*---- Forward declarations for private functions ----*/
-
-// Regarding all public and private functions defined in this source file:
-// - They require all pointer/array arguments to be not null unless the array length is zero.
-// - They only read input scalar/array arguments, write to output pointer/array
-// arguments, and return scalar values; they are "pure" functions.
-// - They don't read mutable global variables or write to any global variables.
-// - They don't perform I/O, read the clock, print to console, etc.
-// - They allocate a small and constant amount of stack memory.
-// - They don't allocate or free any memory on the heap.
-// - They don't recurse or mutually recurse. All the code
-// could be inlined into the top-level public functions.
-// - They run in at most quadratic time with respect to input arguments.
-// Most functions run in linear time, and some in constant time.
-// There are no unbounded loops or non-obvious termination conditions.
-// - They are completely thread-safe if the caller does not give the
-// same writable buffer to concurrent calls to these functions.
-
-testable void appendBitsToBuffer(unsigned int val, int numBits, uint8_t buffer[], int *bitLen);
-
-testable void addEccAndInterleave(uint8_t data[], int version, enum qrcodegen_Ecc ecl, uint8_t result[]);
-testable int getNumDataCodewords(int version, enum qrcodegen_Ecc ecl);
-testable int getNumRawDataModules(int ver);
-
-testable void calcReedSolomonGenerator(int degree, uint8_t result[]);
-testable void calcReedSolomonRemainder(const uint8_t data[], int dataLen,
- const uint8_t generator[], int degree, uint8_t result[]);
-testable uint8_t finiteFieldMultiply(uint8_t x, uint8_t y);
-
-testable void initializeFunctionModules(int version, uint8_t qrcode[]);
-static void drawWhiteFunctionModules(uint8_t qrcode[], int version);
-static void drawFormatBits(enum qrcodegen_Ecc ecl, enum qrcodegen_Mask mask, uint8_t qrcode[]);
-testable int getAlignmentPatternPositions(int version, uint8_t result[7]);
-static void fillRectangle(int left, int top, int width, int height, uint8_t qrcode[]);
-
-static void drawCodewords(const uint8_t data[], int dataLen, uint8_t qrcode[]);
-static void applyMask(const uint8_t functionModules[], uint8_t qrcode[], enum qrcodegen_Mask mask);
-static long getPenaltyScore(const uint8_t qrcode[]);
-static void addRunToHistory(unsigned char run, unsigned char history[7]);
-static bool hasFinderLikePattern(unsigned char runHistory[7]);
-
-testable bool getModule(const uint8_t qrcode[], int x, int y);
-testable void setModule(uint8_t qrcode[], int x, int y, bool isBlack);
-testable void setModuleBounded(uint8_t qrcode[], int x, int y, bool isBlack);
-static bool getBit(int x, int i);
-
-testable int calcSegmentBitLength(enum qrcodegen_Mode mode, size_t numChars);
-testable int getTotalBits(const struct qrcodegen_Segment segs[], size_t len, int version);
-static int numCharCountBits(enum qrcodegen_Mode mode, int version);
-
-
-
-/*---- Private tables of constants ----*/
-
-// The set of all legal characters in alphanumeric mode, where each character
-// value maps to the index in the string. For checking text and encoding segments.
-static const char *ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
-
-// For generating error correction codes.
-testable const int8_t ECC_CODEWORDS_PER_BLOCK[4][41] = {
- // Version: (note that index 0 is for padding, and is set to an illegal value)
- //0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
- {-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30}, // Low
- {-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28}, // Medium
- {-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30}, // Quartile
- {-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30}, // High
-};
-
-#define qrcodegen_REED_SOLOMON_DEGREE_MAX 30 // Based on the table above
-
-// For generating error correction codes.
-testable const int8_t NUM_ERROR_CORRECTION_BLOCKS[4][41] = {
- // Version: (note that index 0 is for padding, and is set to an illegal value)
- //0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
- {-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25}, // Low
- {-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49}, // Medium
- {-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68}, // Quartile
- {-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81}, // High
-};
-
-// For automatic mask pattern selection.
-static const int PENALTY_N1 = 3;
-static const int PENALTY_N2 = 3;
-static const int PENALTY_N3 = 40;
-static const int PENALTY_N4 = 10;
-
-
-
-/*---- High-level QR Code encoding functions ----*/
-
-// Public function - see documentation comment in header file.
-bool qrcodegen_encodeText(const char *text, uint8_t tempBuffer[], uint8_t qrcode[],
- enum qrcodegen_Ecc ecl, int minVersion, int maxVersion, enum qrcodegen_Mask mask, bool boostEcl) {
-
- size_t textLen = strlen(text);
- if (textLen == 0)
- return qrcodegen_encodeSegmentsAdvanced(NULL, 0, ecl, minVersion, maxVersion, mask, boostEcl, tempBuffer, qrcode);
- size_t bufLen = qrcodegen_BUFFER_LEN_FOR_VERSION(maxVersion);
-
- struct qrcodegen_Segment seg;
- if (qrcodegen_isNumeric(text)) {
- if (qrcodegen_calcSegmentBufferSize(qrcodegen_Mode_NUMERIC, textLen) > bufLen)
- goto fail;
- seg = qrcodegen_makeNumeric(text, tempBuffer);
- } else if (qrcodegen_isAlphanumeric(text)) {
- if (qrcodegen_calcSegmentBufferSize(qrcodegen_Mode_ALPHANUMERIC, textLen) > bufLen)
- goto fail;
- seg = qrcodegen_makeAlphanumeric(text, tempBuffer);
- } else {
- if (textLen > bufLen)
- goto fail;
- for (size_t i = 0; i < textLen; i++)
- tempBuffer[i] = (uint8_t)text[i];
- seg.mode = qrcodegen_Mode_BYTE;
- seg.bitLength = calcSegmentBitLength(seg.mode, textLen);
- if (seg.bitLength == -1)
- goto fail;
- seg.numChars = (int)textLen;
- seg.data = tempBuffer;
- }
- return qrcodegen_encodeSegmentsAdvanced(&seg, 1, ecl, minVersion, maxVersion, mask, boostEcl, tempBuffer, qrcode);
-
-fail:
- qrcode[0] = 0; // Set size to invalid value for safety
- return false;
-}
-
-
-// Public function - see documentation comment in header file.
-bool qrcodegen_encodeBinary(uint8_t dataAndTemp[], size_t dataLen, uint8_t qrcode[],
- enum qrcodegen_Ecc ecl, int minVersion, int maxVersion, enum qrcodegen_Mask mask, bool boostEcl) {
-
- struct qrcodegen_Segment seg;
- seg.mode = qrcodegen_Mode_BYTE;
- seg.bitLength = calcSegmentBitLength(seg.mode, dataLen);
- if (seg.bitLength == -1) {
- qrcode[0] = 0; // Set size to invalid value for safety
- return false;
- }
- seg.numChars = (int)dataLen;
- seg.data = dataAndTemp;
- return qrcodegen_encodeSegmentsAdvanced(&seg, 1, ecl, minVersion, maxVersion, mask, boostEcl, dataAndTemp, qrcode);
-}
-
-
-// Appends the given number of low-order bits of the given value to the given byte-based
-// bit buffer, increasing the bit length. Requires 0 <= numBits <= 16 and val < 2^numBits.
-testable void appendBitsToBuffer(unsigned int val, int numBits, uint8_t buffer[], int *bitLen) {
- assert(0 <= numBits && numBits <= 16 && (unsigned long)val >> numBits == 0);
- for (int i = numBits - 1; i >= 0; i--, (*bitLen)++)
- buffer[*bitLen >> 3] |= ((val >> i) & 1) << (7 - (*bitLen & 7));
-}
-
-
-
-/*---- Low-level QR Code encoding functions ----*/
-
-// Public function - see documentation comment in header file.
-bool qrcodegen_encodeSegments(const struct qrcodegen_Segment segs[], size_t len,
- enum qrcodegen_Ecc ecl, uint8_t tempBuffer[], uint8_t qrcode[]) {
- return qrcodegen_encodeSegmentsAdvanced(segs, len, ecl,
- qrcodegen_VERSION_MIN, qrcodegen_VERSION_MAX, -1, true, tempBuffer, qrcode);
-}
-
-
-// Public function - see documentation comment in header file.
-bool qrcodegen_encodeSegmentsAdvanced(const struct qrcodegen_Segment segs[], size_t len, enum qrcodegen_Ecc ecl,
- int minVersion, int maxVersion, int mask, bool boostEcl, uint8_t tempBuffer[], uint8_t qrcode[]) {
- assert(segs != NULL || len == 0);
- assert(qrcodegen_VERSION_MIN <= minVersion && minVersion <= maxVersion && maxVersion <= qrcodegen_VERSION_MAX);
- assert(0 <= (int)ecl && (int)ecl <= 3 && -1 <= (int)mask && (int)mask <= 7);
-
- // Find the minimal version number to use
- int version, dataUsedBits;
- for (version = minVersion; ; version++) {
- int dataCapacityBits = getNumDataCodewords(version, ecl) * 8; // Number of data bits available
- dataUsedBits = getTotalBits(segs, len, version);
- if (dataUsedBits != -1 && dataUsedBits <= dataCapacityBits)
- break; // This version number is found to be suitable
- if (version >= maxVersion) { // All versions in the range could not fit the given data
- qrcode[0] = 0; // Set size to invalid value for safety
- return false;
- }
- }
- assert(dataUsedBits != -1);
-
- // Increase the error correction level while the data still fits in the current version number
- for (int i = (int)qrcodegen_Ecc_MEDIUM; i <= (int)qrcodegen_Ecc_HIGH; i++) { // From low to high
- if (boostEcl && dataUsedBits <= getNumDataCodewords(version, (enum qrcodegen_Ecc)i) * 8)
- ecl = (enum qrcodegen_Ecc)i;
- }
-
- // Concatenate all segments to create the data bit string
- memset(qrcode, 0, qrcodegen_BUFFER_LEN_FOR_VERSION(version) * sizeof(qrcode[0]));
- int bitLen = 0;
- for (size_t i = 0; i < len; i++) {
- const struct qrcodegen_Segment *seg = &segs[i];
- appendBitsToBuffer((int)seg->mode, 4, qrcode, &bitLen);
- appendBitsToBuffer(seg->numChars, numCharCountBits(seg->mode, version), qrcode, &bitLen);
- for (int j = 0; j < seg->bitLength; j++)
- appendBitsToBuffer((seg->data[j >> 3] >> (7 - (j & 7))) & 1, 1, qrcode, &bitLen);
- }
- assert(bitLen == dataUsedBits);
-
- // Add terminator and pad up to a byte if applicable
- int dataCapacityBits = getNumDataCodewords(version, ecl) * 8;
- assert(bitLen <= dataCapacityBits);
- int terminatorBits = dataCapacityBits - bitLen;
- if (terminatorBits > 4)
- terminatorBits = 4;
- appendBitsToBuffer(0, terminatorBits, qrcode, &bitLen);
- appendBitsToBuffer(0, (8 - bitLen % 8) % 8, qrcode, &bitLen);
- assert(bitLen % 8 == 0);
-
- // Pad with alternating bytes until data capacity is reached
- for (uint8_t padByte = 0xEC; bitLen < dataCapacityBits; padByte ^= 0xEC ^ 0x11)
- appendBitsToBuffer(padByte, 8, qrcode, &bitLen);
-
- // Draw function and data codeword modules
- addEccAndInterleave(qrcode, version, ecl, tempBuffer);
- initializeFunctionModules(version, qrcode);
- drawCodewords(tempBuffer, getNumRawDataModules(version) / 8, qrcode);
- drawWhiteFunctionModules(qrcode, version);
- initializeFunctionModules(version, tempBuffer);
-
- // Handle masking
- if (mask == qrcodegen_Mask_AUTO) { // Automatically choose best mask
- long minPenalty = LONG_MAX;
- for (int i = 0; i < 8; i++) {
- enum qrcodegen_Mask msk = (enum qrcodegen_Mask)i;
- drawFormatBits(ecl, msk, qrcode);
- applyMask(tempBuffer, qrcode, msk);
- long penalty = getPenaltyScore(qrcode);
- if (penalty < minPenalty) {
- mask = msk;
- minPenalty = penalty;
- }
- applyMask(tempBuffer, qrcode, msk); // Undoes the mask due to XOR
- }
- }
- assert(0 <= (int)mask && (int)mask <= 7);
- drawFormatBits(ecl, mask, qrcode);
- applyMask(tempBuffer, qrcode, mask);
- return true;
-}
-
-
-
-/*---- Error correction code generation functions ----*/
-
-// Appends error correction bytes to each block of the given data array, then interleaves
-// bytes from the blocks and stores them in the result array. data[0 : dataLen] contains
-// the input data. data[dataLen : rawCodewords] is used as a temporary work area and will
-// be clobbered by this function. The final answer is stored in result[0 : rawCodewords].
-testable void addEccAndInterleave(uint8_t data[], int version, enum qrcodegen_Ecc ecl, uint8_t result[]) {
- // Calculate parameter numbers
- assert(0 <= (int)ecl && (int)ecl < 4 && qrcodegen_VERSION_MIN <= version && version <= qrcodegen_VERSION_MAX);
- int numBlocks = NUM_ERROR_CORRECTION_BLOCKS[(int)ecl][version];
- int blockEccLen = ECC_CODEWORDS_PER_BLOCK [(int)ecl][version];
- int rawCodewords = getNumRawDataModules(version) / 8;
- int dataLen = getNumDataCodewords(version, ecl);
- int numShortBlocks = numBlocks - rawCodewords % numBlocks;
- int shortBlockDataLen = rawCodewords / numBlocks - blockEccLen;
-
- // Split data into blocks, calculate ECC, and interleave
- // (not concatenate) the bytes into a single sequence
- uint8_t generator[qrcodegen_REED_SOLOMON_DEGREE_MAX];
- calcReedSolomonGenerator(blockEccLen, generator);
- const uint8_t *dat = data;
- for (int i = 0; i < numBlocks; i++) {
- int datLen = shortBlockDataLen + (i < numShortBlocks ? 0 : 1);
- uint8_t *ecc = &data[dataLen]; // Temporary storage
- calcReedSolomonRemainder(dat, datLen, generator, blockEccLen, ecc);
- for (int j = 0, k = i; j < datLen; j++, k += numBlocks) { // Copy data
- if (j == shortBlockDataLen)
- k -= numShortBlocks;
- result[k] = dat[j];
- }
- for (int j = 0, k = dataLen + i; j < blockEccLen; j++, k += numBlocks) // Copy ECC
- result[k] = ecc[j];
- dat += datLen;
- }
-}
-
-
-// Returns the number of 8-bit codewords that can be used for storing data (not ECC),
-// for the given version number and error correction level. The result is in the range [9, 2956].
-testable int getNumDataCodewords(int version, enum qrcodegen_Ecc ecl) {
- int v = version, e = (int)ecl;
- assert(0 <= e && e < 4);
- return getNumRawDataModules(v) / 8
- - ECC_CODEWORDS_PER_BLOCK [e][v]
- * NUM_ERROR_CORRECTION_BLOCKS[e][v];
-}
-
-
-// Returns the number of data bits that can be stored in a QR Code of the given version number, after
-// all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8.
-// The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table.
-testable int getNumRawDataModules(int ver) {
- assert(qrcodegen_VERSION_MIN <= ver && ver <= qrcodegen_VERSION_MAX);
- int result = (16 * ver + 128) * ver + 64;
- if (ver >= 2) {
- int numAlign = ver / 7 + 2;
- result -= (25 * numAlign - 10) * numAlign - 55;
- if (ver >= 7)
- result -= 36;
- }
- return result;
-}
-
-
-
-/*---- Reed-Solomon ECC generator functions ----*/
-
-// Calculates the Reed-Solomon generator polynomial of the given degree, storing in result[0 : degree].
-testable void calcReedSolomonGenerator(int degree, uint8_t result[]) {
- // Start with the monomial x^0
- assert(1 <= degree && degree <= qrcodegen_REED_SOLOMON_DEGREE_MAX);
- memset(result, 0, degree * sizeof(result[0]));
- result[degree - 1] = 1;
-
- // Compute the product polynomial (x - r^0) * (x - r^1) * (x - r^2) * ... * (x - r^{degree-1}),
- // drop the highest term, and store the rest of the coefficients in order of descending powers.
- // Note that r = 0x02, which is a generator element of this field GF(2^8/0x11D).
- uint8_t root = 1;
- for (int i = 0; i < degree; i++) {
- // Multiply the current product by (x - r^i)
- for (int j = 0; j < degree; j++) {
- result[j] = finiteFieldMultiply(result[j], root);
- if (j + 1 < degree)
- result[j] ^= result[j + 1];
- }
- root = finiteFieldMultiply(root, 0x02);
- }
-}
-
-
-// Calculates the remainder of the polynomial data[0 : dataLen] when divided by the generator[0 : degree], where all
-// polynomials are in big endian and the generator has an implicit leading 1 term, storing the result in result[0 : degree].
-testable void calcReedSolomonRemainder(const uint8_t data[], int dataLen,
- const uint8_t generator[], int degree, uint8_t result[]) {
-
- // Perform polynomial division
- assert(1 <= degree && degree <= qrcodegen_REED_SOLOMON_DEGREE_MAX);
- memset(result, 0, degree * sizeof(result[0]));
- for (int i = 0; i < dataLen; i++) {
- uint8_t factor = data[i] ^ result[0];
- memmove(&result[0], &result[1], (degree - 1) * sizeof(result[0]));
- result[degree - 1] = 0;
- for (int j = 0; j < degree; j++)
- result[j] ^= finiteFieldMultiply(generator[j], factor);
- }
-}
-
-#undef qrcodegen_REED_SOLOMON_DEGREE_MAX
-
-
-// Returns the product of the two given field elements modulo GF(2^8/0x11D).
-// All inputs are valid. This could be implemented as a 256*256 lookup table.
-testable uint8_t finiteFieldMultiply(uint8_t x, uint8_t y) {
- // Russian peasant multiplication
- uint8_t z = 0;
- for (int i = 7; i >= 0; i--) {
- z = (z << 1) ^ ((z >> 7) * 0x11D);
- z ^= ((y >> i) & 1) * x;
- }
- return z;
-}
-
-
-
-/*---- Drawing function modules ----*/
-
-// Clears the given QR Code grid with white modules for the given
-// version's size, then marks every function module as black.
-testable void initializeFunctionModules(int version, uint8_t qrcode[]) {
- // Initialize QR Code
- int qrsize = version * 4 + 17;
- memset(qrcode, 0, ((qrsize * qrsize + 7) / 8 + 1) * sizeof(qrcode[0]));
- qrcode[0] = (uint8_t)qrsize;
-
- // Fill horizontal and vertical timing patterns
- fillRectangle(6, 0, 1, qrsize, qrcode);
- fillRectangle(0, 6, qrsize, 1, qrcode);
-
- // Fill 3 finder patterns (all corners except bottom right) and format bits
- fillRectangle(0, 0, 9, 9, qrcode);
- fillRectangle(qrsize - 8, 0, 8, 9, qrcode);
- fillRectangle(0, qrsize - 8, 9, 8, qrcode);
-
- // Fill numerous alignment patterns
- uint8_t alignPatPos[7];
- int numAlign = getAlignmentPatternPositions(version, alignPatPos);
- for (int i = 0; i < numAlign; i++) {
- for (int j = 0; j < numAlign; j++) {
- // Don't draw on the three finder corners
- if (!((i == 0 && j == 0) || (i == 0 && j == numAlign - 1) || (i == numAlign - 1 && j == 0)))
- fillRectangle(alignPatPos[i] - 2, alignPatPos[j] - 2, 5, 5, qrcode);
- }
- }
-
- // Fill version blocks
- if (version >= 7) {
- fillRectangle(qrsize - 11, 0, 3, 6, qrcode);
- fillRectangle(0, qrsize - 11, 6, 3, qrcode);
- }
-}
-
-
-// Draws white function modules and possibly some black modules onto the given QR Code, without changing
-// non-function modules. This does not draw the format bits. This requires all function modules to be previously
-// marked black (namely by initializeFunctionModules()), because this may skip redrawing black function modules.
-static void drawWhiteFunctionModules(uint8_t qrcode[], int version) {
- // Draw horizontal and vertical timing patterns
- int qrsize = qrcodegen_getSize(qrcode);
- for (int i = 7; i < qrsize - 7; i += 2) {
- setModule(qrcode, 6, i, false);
- setModule(qrcode, i, 6, false);
- }
-
- // Draw 3 finder patterns (all corners except bottom right; overwrites some timing modules)
- for (int dy = -4; dy <= 4; dy++) {
- for (int dx = -4; dx <= 4; dx++) {
- int dist = abs(dx);
- if (abs(dy) > dist)
- dist = abs(dy);
- if (dist == 2 || dist == 4) {
- setModuleBounded(qrcode, 3 + dx, 3 + dy, false);
- setModuleBounded(qrcode, qrsize - 4 + dx, 3 + dy, false);
- setModuleBounded(qrcode, 3 + dx, qrsize - 4 + dy, false);
- }
- }
- }
-
- // Draw numerous alignment patterns
- uint8_t alignPatPos[7];
- int numAlign = getAlignmentPatternPositions(version, alignPatPos);
- for (int i = 0; i < numAlign; i++) {
- for (int j = 0; j < numAlign; j++) {
- if ((i == 0 && j == 0) || (i == 0 && j == numAlign - 1) || (i == numAlign - 1 && j == 0))
- continue; // Don't draw on the three finder corners
- for (int dy = -1; dy <= 1; dy++) {
- for (int dx = -1; dx <= 1; dx++)
- setModule(qrcode, alignPatPos[i] + dx, alignPatPos[j] + dy, dx == 0 && dy == 0);
- }
- }
- }
-
- // Draw version blocks
- if (version >= 7) {
- // Calculate error correction code and pack bits
- int rem = version; // version is uint6, in the range [7, 40]
- for (int i = 0; i < 12; i++)
- rem = (rem << 1) ^ ((rem >> 11) * 0x1F25);
- long bits = (long)version << 12 | rem; // uint18
- assert(bits >> 18 == 0);
-
- // Draw two copies
- for (int i = 0; i < 6; i++) {
- for (int j = 0; j < 3; j++) {
- int k = qrsize - 11 + j;
- setModule(qrcode, k, i, (bits & 1) != 0);
- setModule(qrcode, i, k, (bits & 1) != 0);
- bits >>= 1;
- }
- }
- }
-}
-
-
-// Draws two copies of the format bits (with its own error correction code) based
-// on the given mask and error correction level. This always draws all modules of
-// the format bits, unlike drawWhiteFunctionModules() which might skip black modules.
-static void drawFormatBits(enum qrcodegen_Ecc ecl, enum qrcodegen_Mask mask, uint8_t qrcode[]) {
- // Calculate error correction code and pack bits
- assert(0 <= (int)mask && (int)mask <= 7);
- static const int table[] = {1, 0, 3, 2};
- int data = table[(int)ecl] << 3 | (int)mask; // errCorrLvl is uint2, mask is uint3
- int rem = data;
- for (int i = 0; i < 10; i++)
- rem = (rem << 1) ^ ((rem >> 9) * 0x537);
- int bits = (data << 10 | rem) ^ 0x5412; // uint15
- assert(bits >> 15 == 0);
-
- // Draw first copy
- for (int i = 0; i <= 5; i++)
- setModule(qrcode, 8, i, getBit(bits, i));
- setModule(qrcode, 8, 7, getBit(bits, 6));
- setModule(qrcode, 8, 8, getBit(bits, 7));
- setModule(qrcode, 7, 8, getBit(bits, 8));
- for (int i = 9; i < 15; i++)
- setModule(qrcode, 14 - i, 8, getBit(bits, i));
-
- // Draw second copy
- int qrsize = qrcodegen_getSize(qrcode);
- for (int i = 0; i < 8; i++)
- setModule(qrcode, qrsize - 1 - i, 8, getBit(bits, i));
- for (int i = 8; i < 15; i++)
- setModule(qrcode, 8, qrsize - 15 + i, getBit(bits, i));
- setModule(qrcode, 8, qrsize - 8, true); // Always black
-}
-
-
-// Calculates and stores an ascending list of positions of alignment patterns
-// for this version number, returning the length of the list (in the range [0,7]).
-// Each position is in the range [0,177), and are used on both the x and y axes.
-// This could be implemented as lookup table of 40 variable-length lists of unsigned bytes.
-testable int getAlignmentPatternPositions(int version, uint8_t result[7]) {
- if (version == 1)
- return 0;
- int numAlign = version / 7 + 2;
- int step = (version == 32) ? 26 :
- (version*4 + numAlign*2 + 1) / (numAlign*2 - 2) * 2;
- for (int i = numAlign - 1, pos = version * 4 + 10; i >= 1; i--, pos -= step)
- result[i] = pos;
- result[0] = 6;
- return numAlign;
-}
-
-
-// Sets every pixel in the range [left : left + width] * [top : top + height] to black.
-static void fillRectangle(int left, int top, int width, int height, uint8_t qrcode[]) {
- for (int dy = 0; dy < height; dy++) {
- for (int dx = 0; dx < width; dx++)
- setModule(qrcode, left + dx, top + dy, true);
- }
-}
-
-
-
-/*---- Drawing data modules and masking ----*/
-
-// Draws the raw codewords (including data and ECC) onto the given QR Code. This requires the initial state of
-// the QR Code to be black at function modules and white at codeword modules (including unused remainder bits).
-static void drawCodewords(const uint8_t data[], int dataLen, uint8_t qrcode[]) {
- int qrsize = qrcodegen_getSize(qrcode);
- int i = 0; // Bit index into the data
- // Do the funny zigzag scan
- for (int right = qrsize - 1; right >= 1; right -= 2) { // Index of right column in each column pair
- if (right == 6)
- right = 5;
- for (int vert = 0; vert < qrsize; vert++) { // Vertical counter
- for (int j = 0; j < 2; j++) {
- int x = right - j; // Actual x coordinate
- bool upward = ((right + 1) & 2) == 0;
- int y = upward ? qrsize - 1 - vert : vert; // Actual y coordinate
- if (!getModule(qrcode, x, y) && i < dataLen * 8) {
- bool black = getBit(data[i >> 3], 7 - (i & 7));
- setModule(qrcode, x, y, black);
- i++;
- }
- // If this QR Code has any remainder bits (0 to 7), they were assigned as
- // 0/false/white by the constructor and are left unchanged by this method
- }
- }
- }
- assert(i == dataLen * 8);
-}
-
-
-// XORs the codeword modules in this QR Code with the given mask pattern.
-// The function modules must be marked and the codeword bits must be drawn
-// before masking. Due to the arithmetic of XOR, calling applyMask() with
-// the same mask value a second time will undo the mask. A final well-formed
-// QR Code needs exactly one (not zero, two, etc.) mask applied.
-static void applyMask(const uint8_t functionModules[], uint8_t qrcode[], enum qrcodegen_Mask mask) {
- assert(0 <= (int)mask && (int)mask <= 7); // Disallows qrcodegen_Mask_AUTO
- int qrsize = qrcodegen_getSize(qrcode);
- for (int y = 0; y < qrsize; y++) {
- for (int x = 0; x < qrsize; x++) {
- if (getModule(functionModules, x, y))
- continue;
- bool invert;
- switch ((int)mask) {
- case 0: invert = (x + y) % 2 == 0; break;
- case 1: invert = y % 2 == 0; break;
- case 2: invert = x % 3 == 0; break;
- case 3: invert = (x + y) % 3 == 0; break;
- case 4: invert = (x / 3 + y / 2) % 2 == 0; break;
- case 5: invert = x * y % 2 + x * y % 3 == 0; break;
- case 6: invert = (x * y % 2 + x * y % 3) % 2 == 0; break;
- case 7: invert = ((x + y) % 2 + x * y % 3) % 2 == 0; break;
- default: assert(false); return;
- }
- bool val = getModule(qrcode, x, y);
- setModule(qrcode, x, y, val ^ invert);
- }
- }
-}
-
-
-// Calculates and returns the penalty score based on state of the given QR Code's current modules.
-// This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score.
-static long getPenaltyScore(const uint8_t qrcode[]) {
- int qrsize = qrcodegen_getSize(qrcode);
- long result = 0;
-
- // Adjacent modules in row having same color, and finder-like patterns
- for (int y = 0; y < qrsize; y++) {
- unsigned char runHistory[7] = {0};
- bool color = false;
- unsigned char runX = 0;
- for (int x = 0; x < qrsize; x++) {
- if (getModule(qrcode, x, y) == color) {
- runX++;
- if (runX == 5)
- result += PENALTY_N1;
- else if (runX > 5)
- result++;
- } else {
- addRunToHistory(runX, runHistory);
- if (!color && hasFinderLikePattern(runHistory))
- result += PENALTY_N3;
- color = getModule(qrcode, x, y);
- runX = 1;
- }
- }
- addRunToHistory(runX, runHistory);
- if (color)
- addRunToHistory(0, runHistory); // Dummy run of white
- if (hasFinderLikePattern(runHistory))
- result += PENALTY_N3;
- }
- // Adjacent modules in column having same color, and finder-like patterns
- for (int x = 0; x < qrsize; x++) {
- unsigned char runHistory[7] = {0};
- bool color = false;
- unsigned char runY = 0;
- for (int y = 0; y < qrsize; y++) {
- if (getModule(qrcode, x, y) == color) {
- runY++;
- if (runY == 5)
- result += PENALTY_N1;
- else if (runY > 5)
- result++;
- } else {
- addRunToHistory(runY, runHistory);
- if (!color && hasFinderLikePattern(runHistory))
- result += PENALTY_N3;
- color = getModule(qrcode, x, y);
- runY = 1;
- }
- }
- addRunToHistory(runY, runHistory);
- if (color)
- addRunToHistory(0, runHistory); // Dummy run of white
- if (hasFinderLikePattern(runHistory))
- result += PENALTY_N3;
- }
-
- // 2*2 blocks of modules having same color
- for (int y = 0; y < qrsize - 1; y++) {
- for (int x = 0; x < qrsize - 1; x++) {
- bool color = getModule(qrcode, x, y);
- if ( color == getModule(qrcode, x + 1, y) &&
- color == getModule(qrcode, x, y + 1) &&
- color == getModule(qrcode, x + 1, y + 1))
- result += PENALTY_N2;
- }
- }
-
- // Balance of black and white modules
- int black = 0;
- for (int y = 0; y < qrsize; y++) {
- for (int x = 0; x < qrsize; x++) {
- if (getModule(qrcode, x, y))
- black++;
- }
- }
- int total = qrsize * qrsize; // Note that size is odd, so black/total != 1/2
- // Compute the smallest integer k >= 0 such that (45-5k)% <= black/total <= (55+5k)%
- int k = (int)((labs(black * 20L - total * 10L) + total - 1) / total) - 1;
- result += k * PENALTY_N4;
- return result;
-}
-
-
-// Inserts the given value to the front of the given array, which shifts over the
-// existing values and deletes the last value. A helper function for getPenaltyScore().
-static void addRunToHistory(unsigned char run, unsigned char history[7]) {
- memmove(&history[1], &history[0], 6 * sizeof(history[0]));
- history[0] = run;
-}
-
-
-// Tests whether the given run history has the pattern of ratio 1:1:3:1:1 in the middle, and
-// surrounded by at least 4 on either or both ends. A helper function for getPenaltyScore().
-// Must only be called immediately after a run of white modules has ended.
-static bool hasFinderLikePattern(unsigned char runHistory[7]) {
- unsigned char n = runHistory[1];
- // The maximum QR Code size is 177, hence the run length n <= 177.
- // Arithmetic is promoted to int, so n*4 will not overflow.
- return n > 0 && runHistory[2] == n && runHistory[4] == n && runHistory[5] == n
- && runHistory[3] == n * 3 && (runHistory[0] >= n * 4 || runHistory[6] >= n * 4);
-}
-
-
-
-/*---- Basic QR Code information ----*/
-
-// Public function - see documentation comment in header file.
-int qrcodegen_getSize(const uint8_t qrcode[]) {
- assert(qrcode != NULL);
- int result = qrcode[0];
- assert((qrcodegen_VERSION_MIN * 4 + 17) <= result
- && result <= (qrcodegen_VERSION_MAX * 4 + 17));
- return result;
-}
-
-
-// Public function - see documentation comment in header file.
-bool qrcodegen_getModule(const uint8_t qrcode[], int x, int y) {
- assert(qrcode != NULL);
- int qrsize = qrcode[0];
- return (0 <= x && x < qrsize && 0 <= y && y < qrsize) && getModule(qrcode, x, y);
-}
-
-
-// Gets the module at the given coordinates, which must be in bounds.
-testable bool getModule(const uint8_t qrcode[], int x, int y) {
- int qrsize = qrcode[0];
- assert(21 <= qrsize && qrsize <= 177 && 0 <= x && x < qrsize && 0 <= y && y < qrsize);
- int index = y * qrsize + x;
- return getBit(qrcode[(index >> 3) + 1], index & 7);
-}
-
-
-// Sets the module at the given coordinates, which must be in bounds.
-testable void setModule(uint8_t qrcode[], int x, int y, bool isBlack) {
- int qrsize = qrcode[0];
- assert(21 <= qrsize && qrsize <= 177 && 0 <= x && x < qrsize && 0 <= y && y < qrsize);
- int index = y * qrsize + x;
- int bitIndex = index & 7;
- int byteIndex = (index >> 3) + 1;
- if (isBlack)
- qrcode[byteIndex] |= 1 << bitIndex;
- else
- qrcode[byteIndex] &= (1 << bitIndex) ^ 0xFF;
-}
-
-
-// Sets the module at the given coordinates, doing nothing if out of bounds.
-testable void setModuleBounded(uint8_t qrcode[], int x, int y, bool isBlack) {
- int qrsize = qrcode[0];
- if (0 <= x && x < qrsize && 0 <= y && y < qrsize)
- setModule(qrcode, x, y, isBlack);
-}
-
-
-// Returns true iff the i'th bit of x is set to 1. Requires x >= 0 and 0 <= i <= 14.
-static bool getBit(int x, int i) {
- return ((x >> i) & 1) != 0;
-}
-
-
-
-/*---- Segment handling ----*/
-
-// Public function - see documentation comment in header file.
-bool qrcodegen_isAlphanumeric(const char *text) {
- assert(text != NULL);
- for (; *text != '\0'; text++) {
- if (strchr(ALPHANUMERIC_CHARSET, *text) == NULL)
- return false;
- }
- return true;
-}
-
-
-// Public function - see documentation comment in header file.
-bool qrcodegen_isNumeric(const char *text) {
- assert(text != NULL);
- for (; *text != '\0'; text++) {
- if (*text < '0' || *text > '9')
- return false;
- }
- return true;
-}
-
-
-// Public function - see documentation comment in header file.
-size_t qrcodegen_calcSegmentBufferSize(enum qrcodegen_Mode mode, size_t numChars) {
- int temp = calcSegmentBitLength(mode, numChars);
- if (temp == -1)
- return SIZE_MAX;
- assert(0 <= temp && temp <= INT16_MAX);
- return ((size_t)temp + 7) / 8;
-}
-
-
-// Returns the number of data bits needed to represent a segment
-// containing the given number of characters using the given mode. Notes:
-// - Returns -1 on failure, i.e. numChars > INT16_MAX or
-// the number of needed bits exceeds INT16_MAX (i.e. 32767).
-// - Otherwise, all valid results are in the range [0, INT16_MAX].
-// - For byte mode, numChars measures the number of bytes, not Unicode code points.
-// - For ECI mode, numChars must be 0, and the worst-case number of bits is returned.
-// An actual ECI segment can have shorter data. For non-ECI modes, the result is exact.
-testable int calcSegmentBitLength(enum qrcodegen_Mode mode, size_t numChars) {
- // All calculations are designed to avoid overflow on all platforms
- if (numChars > (unsigned int)INT16_MAX)
- return -1;
- long result = (long)numChars;
- if (mode == qrcodegen_Mode_NUMERIC)
- result = (result * 10 + 2) / 3; // ceil(10/3 * n)
- else if (mode == qrcodegen_Mode_ALPHANUMERIC)
- result = (result * 11 + 1) / 2; // ceil(11/2 * n)
- else if (mode == qrcodegen_Mode_BYTE)
- result *= 8;
- else if (mode == qrcodegen_Mode_KANJI)
- result *= 13;
- else if (mode == qrcodegen_Mode_ECI && numChars == 0)
- result = 3 * 8;
- else { // Invalid argument
- assert(false);
- return -1;
- }
- assert(result >= 0);
- if (result > (unsigned int)INT16_MAX)
- return -1;
- return (int)result;
-}
-
-
-// Public function - see documentation comment in header file.
-struct qrcodegen_Segment qrcodegen_makeBytes(const uint8_t data[], size_t len, uint8_t buf[]) {
- assert(data != NULL || len == 0);
- struct qrcodegen_Segment result;
- result.mode = qrcodegen_Mode_BYTE;
- result.bitLength = calcSegmentBitLength(result.mode, len);
- assert(result.bitLength != -1);
- result.numChars = (int)len;
- if (len > 0)
- memcpy(buf, data, len * sizeof(buf[0]));
- result.data = buf;
- return result;
-}
-
-
-// Public function - see documentation comment in header file.
-struct qrcodegen_Segment qrcodegen_makeNumeric(const char *digits, uint8_t buf[]) {
- assert(digits != NULL);
- struct qrcodegen_Segment result;
- size_t len = strlen(digits);
- result.mode = qrcodegen_Mode_NUMERIC;
- int bitLen = calcSegmentBitLength(result.mode, len);
- assert(bitLen != -1);
- result.numChars = (int)len;
- if (bitLen > 0)
- memset(buf, 0, ((size_t)bitLen + 7) / 8 * sizeof(buf[0]));
- result.bitLength = 0;
-
- unsigned int accumData = 0;
- int accumCount = 0;
- for (; *digits != '\0'; digits++) {
- char c = *digits;
- assert('0' <= c && c <= '9');
- accumData = accumData * 10 + (unsigned int)(c - '0');
- accumCount++;
- if (accumCount == 3) {
- appendBitsToBuffer(accumData, 10, buf, &result.bitLength);
- accumData = 0;
- accumCount = 0;
- }
- }
- if (accumCount > 0) // 1 or 2 digits remaining
- appendBitsToBuffer(accumData, accumCount * 3 + 1, buf, &result.bitLength);
- assert(result.bitLength == bitLen);
- result.data = buf;
- return result;
-}
-
-
-// Public function - see documentation comment in header file.
-struct qrcodegen_Segment qrcodegen_makeAlphanumeric(const char *text, uint8_t buf[]) {
- assert(text != NULL);
- struct qrcodegen_Segment result;
- size_t len = strlen(text);
- result.mode = qrcodegen_Mode_ALPHANUMERIC;
- int bitLen = calcSegmentBitLength(result.mode, len);
- assert(bitLen != -1);
- result.numChars = (int)len;
- if (bitLen > 0)
- memset(buf, 0, ((size_t)bitLen + 7) / 8 * sizeof(buf[0]));
- result.bitLength = 0;
-
- unsigned int accumData = 0;
- int accumCount = 0;
- for (; *text != '\0'; text++) {
- const char *temp = strchr(ALPHANUMERIC_CHARSET, *text);
- assert(temp != NULL);
- accumData = accumData * 45 + (unsigned int)(temp - ALPHANUMERIC_CHARSET);
- accumCount++;
- if (accumCount == 2) {
- appendBitsToBuffer(accumData, 11, buf, &result.bitLength);
- accumData = 0;
- accumCount = 0;
- }
- }
- if (accumCount > 0) // 1 character remaining
- appendBitsToBuffer(accumData, 6, buf, &result.bitLength);
- assert(result.bitLength == bitLen);
- result.data = buf;
- return result;
-}
-
-
-// Public function - see documentation comment in header file.
-struct qrcodegen_Segment qrcodegen_makeEci(long assignVal, uint8_t buf[]) {
- struct qrcodegen_Segment result;
- result.mode = qrcodegen_Mode_ECI;
- result.numChars = 0;
- result.bitLength = 0;
- if (assignVal < 0)
- assert(false);
- else if (assignVal < (1 << 7)) {
- memset(buf, 0, 1 * sizeof(buf[0]));
- appendBitsToBuffer(assignVal, 8, buf, &result.bitLength);
- } else if (assignVal < (1 << 14)) {
- memset(buf, 0, 2 * sizeof(buf[0]));
- appendBitsToBuffer(2, 2, buf, &result.bitLength);
- appendBitsToBuffer(assignVal, 14, buf, &result.bitLength);
- } else if (assignVal < 1000000L) {
- memset(buf, 0, 3 * sizeof(buf[0]));
- appendBitsToBuffer(6, 3, buf, &result.bitLength);
- appendBitsToBuffer(assignVal >> 10, 11, buf, &result.bitLength);
- appendBitsToBuffer(assignVal & 0x3FF, 10, buf, &result.bitLength);
- } else
- assert(false);
- result.data = buf;
- return result;
-}
-
-
-// Calculates the number of bits needed to encode the given segments at the given version.
-// Returns a non-negative number if successful. Otherwise returns -1 if a segment has too
-// many characters to fit its length field, or the total bits exceeds INT16_MAX.
-testable int getTotalBits(const struct qrcodegen_Segment segs[], size_t len, int version) {
- assert(segs != NULL || len == 0);
- long result = 0;
- for (size_t i = 0; i < len; i++) {
- int numChars = segs[i].numChars;
- int bitLength = segs[i].bitLength;
- assert(0 <= numChars && numChars <= INT16_MAX);
- assert(0 <= bitLength && bitLength <= INT16_MAX);
- int ccbits = numCharCountBits(segs[i].mode, version);
- assert(0 <= ccbits && ccbits <= 16);
- if (numChars >= (1L << ccbits))
- return -1; // The segment's length doesn't fit the field's bit width
- result += 4L + ccbits + bitLength;
- if (result > INT16_MAX)
- return -1; // The sum might overflow an int type
- }
- assert(0 <= result && result <= INT16_MAX);
- return (int)result;
-}
-
-
-// Returns the bit width of the character count field for a segment in the given mode
-// in a QR Code at the given version number. The result is in the range [0, 16].
-static int numCharCountBits(enum qrcodegen_Mode mode, int version) {
- assert(qrcodegen_VERSION_MIN <= version && version <= qrcodegen_VERSION_MAX);
- int i = (version + 7) / 17;
- switch (mode) {
- case qrcodegen_Mode_NUMERIC : { static const int temp[] = {10, 12, 14}; return temp[i]; }
- case qrcodegen_Mode_ALPHANUMERIC: { static const int temp[] = { 9, 11, 13}; return temp[i]; }
- case qrcodegen_Mode_BYTE : { static const int temp[] = { 8, 16, 16}; return temp[i]; }
- case qrcodegen_Mode_KANJI : { static const int temp[] = { 8, 10, 12}; return temp[i]; }
- case qrcodegen_Mode_ECI : return 0;
- default: assert(false); return -1; // Dummy value
- }
-}
diff --git a/src/libnma/qrcodegen.h b/src/libnma/qrcodegen.h
deleted file mode 100644
index 55e2bfec..00000000
--- a/src/libnma/qrcodegen.h
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * QR Code generator library (C)
- *
- * Copyright (c) Project Nayuki. (MIT License)
- * https://www.nayuki.io/page/qr-code-generator-library
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and associated documentation files (the "Software"), to deal in
- * the Software without restriction, including without limitation the rights to
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
- * the Software, and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- * - The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- * - The Software is provided "as is", without warranty of any kind, express or
- * implied, including but not limited to the warranties of merchantability,
- * fitness for a particular purpose and noninfringement. In no event shall the
- * authors or copyright holders be liable for any claim, damages or other
- * liability, whether in an action of contract, tort or otherwise, arising from,
- * out of or in connection with the Software or the use or other dealings in the
- * Software.
- */
-
-#pragma once
-
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/*
- * This library creates QR Code symbols, which is a type of two-dimension barcode.
- * Invented by Denso Wave and described in the ISO/IEC 18004 standard.
- * A QR Code structure is an immutable square grid of black and white cells.
- * The library provides functions to create a QR Code from text or binary data.
- * The library covers the QR Code Model 2 specification, supporting all versions (sizes)
- * from 1 to 40, all 4 error correction levels, and 4 character encoding modes.
- *
- * Ways to create a QR Code object:
- * - High level: Take the payload data and call qrcodegen_encodeText() or qrcodegen_encodeBinary().
- * - Low level: Custom-make the list of segments and call
- * qrcodegen_encodeSegments() or qrcodegen_encodeSegmentsAdvanced().
- * (Note that all ways require supplying the desired error correction level and various byte buffers.)
- */
-
-
-/*---- Enum and struct types----*/
-
-/*
- * The error correction level in a QR Code symbol.
- */
-enum qrcodegen_Ecc {
- // Must be declared in ascending order of error protection
- // so that an internal qrcodegen function works properly
- qrcodegen_Ecc_LOW = 0 , // The QR Code can tolerate about 7% erroneous codewords
- qrcodegen_Ecc_MEDIUM , // The QR Code can tolerate about 15% erroneous codewords
- qrcodegen_Ecc_QUARTILE, // The QR Code can tolerate about 25% erroneous codewords
- qrcodegen_Ecc_HIGH , // The QR Code can tolerate about 30% erroneous codewords
-};
-
-
-/*
- * The mask pattern used in a QR Code symbol.
- */
-enum qrcodegen_Mask {
- // A special value to tell the QR Code encoder to
- // automatically select an appropriate mask pattern
- qrcodegen_Mask_AUTO = -1,
- // The eight actual mask patterns
- qrcodegen_Mask_0 = 0,
- qrcodegen_Mask_1,
- qrcodegen_Mask_2,
- qrcodegen_Mask_3,
- qrcodegen_Mask_4,
- qrcodegen_Mask_5,
- qrcodegen_Mask_6,
- qrcodegen_Mask_7,
-};
-
-
-/*
- * Describes how a segment's data bits are interpreted.
- */
-enum qrcodegen_Mode {
- qrcodegen_Mode_NUMERIC = 0x1,
- qrcodegen_Mode_ALPHANUMERIC = 0x2,
- qrcodegen_Mode_BYTE = 0x4,
- qrcodegen_Mode_KANJI = 0x8,
- qrcodegen_Mode_ECI = 0x7,
-};
-
-
-/*
- * A segment of character/binary/control data in a QR Code symbol.
- * The mid-level way to create a segment is to take the payload data
- * and call a factory function such as qrcodegen_makeNumeric().
- * The low-level way to create a segment is to custom-make the bit buffer
- * and initialize a qrcodegen_Segment struct with appropriate values.
- * Even in the most favorable conditions, a QR Code can only hold 7089 characters of data.
- * Any segment longer than this is meaningless for the purpose of generating QR Codes.
- * Moreover, the maximum allowed bit length is 32767 because
- * the largest QR Code (version 40) has 31329 modules.
- */
-struct qrcodegen_Segment {
- // The mode indicator of this segment.
- enum qrcodegen_Mode mode;
-
- // The length of this segment's unencoded data. Measured in characters for
- // numeric/alphanumeric/kanji mode, bytes for byte mode, and 0 for ECI mode.
- // Always zero or positive. Not the same as the data's bit length.
- int numChars;
-
- // The data bits of this segment, packed in bitwise big endian.
- // Can be null if the bit length is zero.
- uint8_t *data;
-
- // The number of valid data bits used in the buffer. Requires
- // 0 <= bitLength <= 32767, and bitLength <= (capacity of data array) * 8.
- // The character count (numChars) must agree with the mode and the bit buffer length.
- int bitLength;
-};
-
-
-
-/*---- Macro constants and functions ----*/
-
-#define qrcodegen_VERSION_MIN 1 // The minimum version number supported in the QR Code Model 2 standard
-#define qrcodegen_VERSION_MAX 40 // The maximum version number supported in the QR Code Model 2 standard
-
-// Calculates the number of bytes needed to store any QR Code up to and including the given version number,
-// as a compile-time constant. For example, 'uint8_t buffer[qrcodegen_BUFFER_LEN_FOR_VERSION(25)];'
-// can store any single QR Code from version 1 to 25 (inclusive). The result fits in an int (or int16).
-// Requires qrcodegen_VERSION_MIN <= n <= qrcodegen_VERSION_MAX.
-#define qrcodegen_BUFFER_LEN_FOR_VERSION(n) ((((n) * 4 + 17) * ((n) * 4 + 17) + 7) / 8 + 1)
-
-// The worst-case number of bytes needed to store one QR Code, up to and including
-// version 40. This value equals 3918, which is just under 4 kilobytes.
-// Use this more convenient value to avoid calculating tighter memory bounds for buffers.
-#define qrcodegen_BUFFER_LEN_MAX qrcodegen_BUFFER_LEN_FOR_VERSION(qrcodegen_VERSION_MAX)
-
-
-
-/*---- Functions (high level) to generate QR Codes ----*/
-
-/*
- * Encodes the given text string to a QR Code, returning true if encoding succeeded.
- * If the data is too long to fit in any version in the given range
- * at the given ECC level, then false is returned.
- * - The input text must be encoded in UTF-8 and contain no NULs.
- * - The variables ecl and mask must correspond to enum constant values.
- * - Requires 1 <= minVersion <= maxVersion <= 40.
- * - The arrays tempBuffer and qrcode must each have a length
- * of at least qrcodegen_BUFFER_LEN_FOR_VERSION(maxVersion).
- * - After the function returns, tempBuffer contains no useful data.
- * - If successful, the resulting QR Code may use numeric,
- * alphanumeric, or byte mode to encode the text.
- * - In the most optimistic case, a QR Code at version 40 with low ECC
- * can hold any UTF-8 string up to 2953 bytes, or any alphanumeric string
- * up to 4296 characters, or any digit string up to 7089 characters.
- * These numbers represent the hard upper limit of the QR Code standard.
- * - Please consult the QR Code specification for information on
- * data capacities per version, ECC level, and text encoding mode.
- */
-bool qrcodegen_encodeText(const char *text, uint8_t tempBuffer[], uint8_t qrcode[],
- enum qrcodegen_Ecc ecl, int minVersion, int maxVersion, enum qrcodegen_Mask mask, bool boostEcl);
-
-
-/*
- * Encodes the given binary data to a QR Code, returning true if encoding succeeded.
- * If the data is too long to fit in any version in the given range
- * at the given ECC level, then false is returned.
- * - The input array range dataAndTemp[0 : dataLen] should normally be
- * valid UTF-8 text, but is not required by the QR Code standard.
- * - The variables ecl and mask must correspond to enum constant values.
- * - Requires 1 <= minVersion <= maxVersion <= 40.
- * - The arrays dataAndTemp and qrcode must each have a length
- * of at least qrcodegen_BUFFER_LEN_FOR_VERSION(maxVersion).
- * - After the function returns, the contents of dataAndTemp may have changed,
- * and does not represent useful data anymore.
- * - If successful, the resulting QR Code will use byte mode to encode the data.
- * - In the most optimistic case, a QR Code at version 40 with low ECC can hold any byte
- * sequence up to length 2953. This is the hard upper limit of the QR Code standard.
- * - Please consult the QR Code specification for information on
- * data capacities per version, ECC level, and text encoding mode.
- */
-bool qrcodegen_encodeBinary(uint8_t dataAndTemp[], size_t dataLen, uint8_t qrcode[],
- enum qrcodegen_Ecc ecl, int minVersion, int maxVersion, enum qrcodegen_Mask mask, bool boostEcl);
-
-
-/*---- Functions (low level) to generate QR Codes ----*/
-
-/*
- * Renders a QR Code representing the given segments at the given error correction level.
- * The smallest possible QR Code version is automatically chosen for the output. Returns true if
- * QR Code creation succeeded, or false if the data is too long to fit in any version. The ECC level
- * of the result may be higher than the ecl argument if it can be done without increasing the version.
- * This function allows the user to create a custom sequence of segments that switches
- * between modes (such as alphanumeric and byte) to encode text in less space.
- * This is a low-level API; the high-level API is qrcodegen_encodeText() and qrcodegen_encodeBinary().
- * To save memory, the segments' data buffers can alias/overlap tempBuffer, and will
- * result in them being clobbered, but the QR Code output will still be correct.
- * But the qrcode array must not overlap tempBuffer or any segment's data buffer.
- */
-bool qrcodegen_encodeSegments(const struct qrcodegen_Segment segs[], size_t len,
- enum qrcodegen_Ecc ecl, uint8_t tempBuffer[], uint8_t qrcode[]);
-
-
-/*
- * Renders a QR Code representing the given segments with the given encoding parameters.
- * Returns true if QR Code creation succeeded, or false if the data is too long to fit in the range of versions.
- * The smallest possible QR Code version within the given range is automatically
- * chosen for the output. Iff boostEcl is true, then the ECC level of the result
- * may be higher than the ecl argument if it can be done without increasing the
- * version. The mask number is either between 0 to 7 (inclusive) to force that
- * mask, or -1 to automatically choose an appropriate mask (which may be slow).
- * This function allows the user to create a custom sequence of segments that switches
- * between modes (such as alphanumeric and byte) to encode text in less space.
- * This is a low-level API; the high-level API is qrcodegen_encodeText() and qrcodegen_encodeBinary().
- * To save memory, the segments' data buffers can alias/overlap tempBuffer, and will
- * result in them being clobbered, but the QR Code output will still be correct.
- * But the qrcode array must not overlap tempBuffer or any segment's data buffer.
- */
-bool qrcodegen_encodeSegmentsAdvanced(const struct qrcodegen_Segment segs[], size_t len, enum qrcodegen_Ecc ecl,
- int minVersion, int maxVersion, int mask, bool boostEcl, uint8_t tempBuffer[], uint8_t qrcode[]);
-
-
-/*
- * Tests whether the given string can be encoded as a segment in alphanumeric mode.
- * A string is encodable iff each character is in the following set: 0 to 9, A to Z
- * (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.
- */
-bool qrcodegen_isAlphanumeric(const char *text);
-
-
-/*
- * Tests whether the given string can be encoded as a segment in numeric mode.
- * A string is encodable iff each character is in the range 0 to 9.
- */
-bool qrcodegen_isNumeric(const char *text);
-
-
-/*
- * Returns the number of bytes (uint8_t) needed for the data buffer of a segment
- * containing the given number of characters using the given mode. Notes:
- * - Returns SIZE_MAX on failure, i.e. numChars > INT16_MAX or
- * the number of needed bits exceeds INT16_MAX (i.e. 32767).
- * - Otherwise, all valid results are in the range [0, ceil(INT16_MAX / 8)], i.e. at most 4096.
- * - It is okay for the user to allocate more bytes for the buffer than needed.
- * - For byte mode, numChars measures the number of bytes, not Unicode code points.
- * - For ECI mode, numChars must be 0, and the worst-case number of bytes is returned.
- * An actual ECI segment can have shorter data. For non-ECI modes, the result is exact.
- */
-size_t qrcodegen_calcSegmentBufferSize(enum qrcodegen_Mode mode, size_t numChars);
-
-
-/*
- * Returns a segment representing the given binary data encoded in
- * byte mode. All input byte arrays are acceptable. Any text string
- * can be converted to UTF-8 bytes and encoded as a byte mode segment.
- */
-struct qrcodegen_Segment qrcodegen_makeBytes(const uint8_t data[], size_t len, uint8_t buf[]);
-
-
-/*
- * Returns a segment representing the given string of decimal digits encoded in numeric mode.
- */
-struct qrcodegen_Segment qrcodegen_makeNumeric(const char *digits, uint8_t buf[]);
-
-
-/*
- * Returns a segment representing the given text string encoded in alphanumeric mode.
- * The characters allowed are: 0 to 9, A to Z (uppercase only), space,
- * dollar, percent, asterisk, plus, hyphen, period, slash, colon.
- */
-struct qrcodegen_Segment qrcodegen_makeAlphanumeric(const char *text, uint8_t buf[]);
-
-
-/*
- * Returns a segment representing an Extended Channel Interpretation
- * (ECI) designator with the given assignment value.
- */
-struct qrcodegen_Segment qrcodegen_makeEci(long assignVal, uint8_t buf[]);
-
-
-/*---- Functions to extract raw data from QR Codes ----*/
-
-/*
- * Returns the side length of the given QR Code, assuming that encoding succeeded.
- * The result is in the range [21, 177]. Note that the length of the array buffer
- * is related to the side length - every 'uint8_t qrcode[]' must have length at least
- * qrcodegen_BUFFER_LEN_FOR_VERSION(version), which equals ceil(size^2 / 8 + 1).
- */
-int qrcodegen_getSize(const uint8_t qrcode[]);
-
-
-/*
- * Returns the color of the module (pixel) at the given coordinates, which is false
- * for white or true for black. The top left corner has the coordinates (x=0, y=0).
- * If the given coordinates are out of bounds, then false (white) is returned.
- */
-bool qrcodegen_getModule(const uint8_t qrcode[], int x, int y);
-
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/src/libnma/tests/bar-code.c b/src/libnma/tests/bar-code.c
deleted file mode 100644
index f85a0cfa..00000000
--- a/src/libnma/tests/bar-code.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License as
- * published by the ree Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * Copyright 2018, 2019 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-#include "nma-private.h"
-
-#include <stdio.h>
-#include <string.h>
-
-#include <gtk/gtk.h>
-
-#include "nma-bar-code-widget.h"
-
-static gboolean
-delete (GtkWidget *widget, GdkEvent *event, gpointer user_data)
-{
- gtk_main_quit ();
-
- return FALSE;
-}
-
-static void
-ssid_changed (GtkEditable *editable, gpointer user_data)
-{
- NMConnection *connection = NM_CONNECTION (user_data);
- NMSettingWireless *s_wireless = nm_connection_get_setting_wireless (connection);
- gs_unref_bytes GBytes *ssid = NULL;
- GtkEntryBuffer *buffer;
-
- g_return_if_fail (s_wireless);
-
- buffer = gtk_entry_get_buffer (GTK_ENTRY (editable));
- ssid = g_bytes_new_static (gtk_entry_buffer_get_text (buffer),
- gtk_entry_buffer_get_bytes (buffer));
-
- g_object_set (s_wireless,
- NM_SETTING_WIRELESS_SSID, ssid,
- NULL);
-}
-
-static void
-password_changed (GtkEditable *editable, gpointer user_data)
-{
- NMConnection *connection = NM_CONNECTION (user_data);
- NMSettingWirelessSecurity *s_wsec = nm_connection_get_setting_wireless_security (connection);
-
- if (!s_wsec)
- return;
-
- g_object_set (s_wsec,
- NM_SETTING_WIRELESS_SECURITY_PSK,
- gtk_editable_get_text (editable),
- NULL);
-}
-
-static void
-key_mgmt_changed (GtkComboBox *combo_box, gpointer user_data)
-{
- NMConnection *connection = NM_CONNECTION (user_data);
- const char *key_mgmt = gtk_combo_box_get_active_id (combo_box);
- NMSettingWirelessSecurity *s_wsec = nm_connection_get_setting_wireless_security (connection);
- GtkWidget *pass = g_object_get_data (G_OBJECT (combo_box), "pass");
-
- if (!key_mgmt) {
- nm_connection_remove_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY);
- gtk_widget_set_sensitive (pass, FALSE);
- return;
- }
-
- if (!s_wsec) {
- s_wsec = NM_SETTING_WIRELESS_SECURITY (nm_setting_wireless_security_new ());
- nm_connection_add_setting (connection, NM_SETTING (s_wsec));
- gtk_widget_set_sensitive (pass, TRUE);
- password_changed (GTK_EDITABLE (pass), connection);
- }
-
- g_object_set (s_wsec,
- NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, key_mgmt,
- NULL);
-}
-
-int
-main (int argc, char *argv[])
-{
- GtkWidget *w, *pass;
- GtkWidget *grid;
- NMConnection *connection = NULL;
- gs_unref_bytes GBytes *ssid = g_bytes_new_static ("\"ab:cd\"", 13);
-
- connection = nm_simple_connection_new ();
- nm_connection_add_setting (connection,
- g_object_new (NM_TYPE_SETTING_CONNECTION,
- NM_SETTING_CONNECTION_ID, "fifik",
- NULL));
- nm_connection_add_setting (connection,
- nm_setting_wireless_new ());
-
-#if GTK_CHECK_VERSION(3,90,0)
- gtk_init ();
-#else
- gtk_init (&argc, &argv);
-#endif
-
- w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_widget_show (w);
- gtk_window_set_default_size (GTK_WINDOW (w), 800, 680);
- g_signal_connect (w, "delete-event", G_CALLBACK (delete), NULL);
-
- grid = gtk_grid_new ();
- gtk_widget_show (grid);
- gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
- gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
- g_object_set (grid,
- "margin_start", 6,
- "margin_end", 6,
- "margin_top", 6,
- "margin_bottom", 6,
- NULL);
- gtk_container_add (GTK_CONTAINER (w), grid);
-
- w = gtk_label_new ("SSID");
- gtk_widget_show (w);
- g_object_set (w, "xalign", 1.0, NULL);
- gtk_grid_attach (GTK_GRID (grid), w, 0, 0, 1, 1);
-
- w = gtk_entry_new ();
- g_signal_connect (w, "changed", G_CALLBACK (ssid_changed), connection);
- gtk_editable_set_text (GTK_EDITABLE (w), "\"ab:cd\"");
- gtk_widget_show (w);
- gtk_grid_attach (GTK_GRID (grid), w, 1, 0, 1, 1);
-
- w = gtk_label_new ("Password");
- gtk_widget_show (w);
- g_object_set (w, "xalign", 1.0, NULL);
- gtk_grid_attach (GTK_GRID (grid), w, 0, 1, 1, 1);
-
- pass = gtk_entry_new ();
- g_signal_connect (pass, "changed", G_CALLBACK (password_changed), connection);
- gtk_editable_set_text (GTK_EDITABLE (pass), "lolofon");
- gtk_widget_show (pass);
- gtk_grid_attach (GTK_GRID (grid), pass, 1, 1, 1, 1);
-
- w = gtk_label_new ("Key Management");
- gtk_widget_show (w);
- g_object_set (w, "xalign", 1.0, NULL);
- gtk_grid_attach (GTK_GRID (grid), w, 0, 2, 1, 1);
-
- w = gtk_combo_box_text_new ();
- gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (w), NULL, "No Password");
- gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (w), "none", "WEP: none");
- gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (w), "ieee8021x", "WEP: ieee8021x");
- gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (w), "wpa-none", "WPA: wpa-none");
- gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (w), "wpa-psk", "WPA: wpa-psk");
- g_object_set_data (G_OBJECT (w), "pass", pass);
- g_signal_connect (w, "changed", G_CALLBACK (key_mgmt_changed), connection);
- gtk_combo_box_set_active_id (GTK_COMBO_BOX (w), "wpa-psk");
- gtk_widget_show (w);
- gtk_grid_attach (GTK_GRID (grid), w, 1, 2, 1, 1);
-
- w = nma_bar_code_widget_new (connection);
- gtk_widget_show (w);
- gtk_widget_set_vexpand (w, TRUE);
- gtk_widget_set_hexpand (w, TRUE);
- gtk_grid_attach (GTK_GRID (grid), w, 0, 3, 2, 1);
-
- gtk_main ();
-}
diff --git a/src/libnma/tests/cert-chooser.c b/src/libnma/tests/cert-chooser.c
deleted file mode 100644
index 99808d12..00000000
--- a/src/libnma/tests/cert-chooser.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License as
- * published by the ree Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * Copyright 2019 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <gtk/gtk.h>
-#include "nma-cert-chooser.h"
-
-int
-main (int argc, char *argv[])
-{
- GtkWidget *dialog;
- GtkBox *content;
- GtkWidget *widget;
-
-#if GTK_CHECK_VERSION(3,90,0)
- gtk_init ();
-#else
- gtk_init (&argc, &argv);
-#endif
-
- dialog = gtk_dialog_new_with_buttons ("NMACertChooser test",
- NULL, GTK_DIALOG_MODAL,
- "Dismiss", GTK_RESPONSE_DELETE_EVENT,
- NULL);
- content = GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog)));
-#if GTK_CHECK_VERSION(3,90,0)
- gtk_box_set_spacing (content, 6);
-#endif
-
- widget = nma_cert_chooser_new ("Any", 0);
- gtk_widget_show (widget);
-#if GTK_CHECK_VERSION(3,90,0)
- gtk_container_add (GTK_CONTAINER (content), widget);
-#else
- gtk_box_pack_start (content, widget, TRUE, TRUE, 6);
-#endif
-
- widget = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
- gtk_widget_show (widget);
-#if GTK_CHECK_VERSION(3,90,0)
- gtk_container_add (GTK_CONTAINER (content), widget);
-#else
- gtk_box_pack_start (content, widget, TRUE, TRUE, 6);
-#endif
-
- widget = nma_cert_chooser_new ("FLAG_PASSWORDS", NMA_CERT_CHOOSER_FLAG_PASSWORDS);
- nma_cert_chooser_set_cert (NMA_CERT_CHOOSER (widget),
- "pkcs11:object=praise;type=satan",
- NM_SETTING_802_1X_CK_SCHEME_PKCS11);
- nma_cert_chooser_set_key_uri (NMA_CERT_CHOOSER (widget),
- "pkcs11:object=worship;type=doom");
- gtk_widget_show (widget);
-#if GTK_CHECK_VERSION(3,90,0)
- gtk_container_add (GTK_CONTAINER (content), widget);
-#else
- gtk_box_pack_start (content, widget, TRUE, TRUE, 6);
-#endif
-
- widget = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
- gtk_widget_show (widget);
-#if GTK_CHECK_VERSION(3,90,0)
- gtk_container_add (GTK_CONTAINER (content), widget);
-#else
- gtk_box_pack_start (content, widget, TRUE, TRUE, 6);
-#endif
-
- widget = nma_cert_chooser_new ("FLAG_CERT", NMA_CERT_CHOOSER_FLAG_CERT);
- gtk_widget_show (widget);
-#if GTK_CHECK_VERSION(3,90,0)
- gtk_container_add (GTK_CONTAINER (content), widget);
-#else
- gtk_box_pack_start (content, widget, TRUE, TRUE, 6);
-#endif
-
- widget = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
- gtk_widget_show (widget);
-#if GTK_CHECK_VERSION(3,90,0)
- gtk_container_add (GTK_CONTAINER (content), widget);
-#else
- gtk_box_pack_start (content, widget, TRUE, TRUE, 6);
-#endif
-
- widget = nma_cert_chooser_new ("FLAG_PEM", NMA_CERT_CHOOSER_FLAG_PEM);
- gtk_widget_show (widget);
-#if GTK_CHECK_VERSION(3,90,0)
- gtk_container_add (GTK_CONTAINER (content), widget);
-#else
- gtk_box_pack_start (content, widget, TRUE, TRUE, 6);
-#endif
-
- gtk_dialog_run (GTK_DIALOG (dialog));
-}
diff --git a/src/libnma/tests/meson.build b/src/libnma/tests/meson.build
deleted file mode 100644
index 253de9e7..00000000
--- a/src/libnma/tests/meson.build
+++ /dev/null
@@ -1,31 +0,0 @@
-tests = [
- 'bar-code',
- 'cert-chooser',
- 'mobile-wizard',
- 'run-vpn',
- 'vpn-password-dialog',
- 'wifi-dialog',
- 'wifi-dialog-secrets',
-]
-
-foreach tst : tests
- executable(
- tst,
- tst + '.c',
- include_directories: incs,
- dependencies: [ gtk_dep, libnm_dep, libnma_dep ],
- c_args: cflags,
- install: false
- )
-
- if enable_libnma_gtk4
- executable(
- tst + '-gtk4',
- tst + '.c',
- include_directories: incs,
- dependencies: [ gtk4_dep, libnm_dep, libnma_gtk4_dep ],
- c_args: cflags,
- install: false
- )
- endif
-endforeach
diff --git a/src/libnma/tests/mobile-wizard.c b/src/libnma/tests/mobile-wizard.c
deleted file mode 100644
index 1e21868f..00000000
--- a/src/libnma/tests/mobile-wizard.c
+++ /dev/null
@@ -1,33 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright 2018 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <gtk/gtk.h>
-#include "nma-mobile-wizard.h"
-
-static void
-wizard_cb (NMAMobileWizard *self, gboolean canceled, NMAMobileWizardAccessMethod *method, gpointer user_data)
-{
- gtk_main_quit ();
-}
-
-int
-main (int argc, char *argv[])
-{
- NMAMobileWizard *wizard;
-
-#if GTK_CHECK_VERSION(3,90,0)
- gtk_init ();
-#else
- gtk_init (&argc, &argv);
-#endif
-
- wizard = nma_mobile_wizard_new (NULL, NULL, NM_DEVICE_MODEM_CAPABILITY_NONE, TRUE, wizard_cb, NULL);
-
- nma_mobile_wizard_present (wizard);
- gtk_main ();
- nma_mobile_wizard_destroy (wizard);
-}
diff --git a/src/libnma/tests/run-vpn.c b/src/libnma/tests/run-vpn.c
deleted file mode 100644
index b0e39d9d..00000000
--- a/src/libnma/tests/run-vpn.c
+++ /dev/null
@@ -1,87 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * run-vpn - VPN plugin runner for testing
- *
- * (C) Copyright 2018 Lubomir Rintel
- */
-
-#include "nm-default.h"
-
-#include <NetworkManager.h>
-#include <gtk/gtk.h>
-#include <stdlib.h>
-
-static gboolean
-window_deleted (GtkWidget *widget,
- GdkEvent *event,
- gpointer user_data)
-{
- GMainLoop *main_loop = user_data;
- g_main_loop_quit (main_loop);
- return TRUE;
-}
-
-int
-main (int argc, char *argv[])
-{
- gs_unref_object NMVpnEditorPlugin *plugin = NULL;
- gs_unref_object NMVpnEditor *editor = NULL;
- gs_unref_object NMConnection *connection = NULL;
- gs_free char *service_type = NULL;
- GMainLoop *main_loop;
- GtkWidget *window;
- GtkWidget *widget;
- gs_free_error GError *error = NULL;
-
-#if GTK_CHECK_VERSION(3,90,0)
- gtk_init ();
-#else
- gtk_init (&argc, &argv);
-#endif
-
- if (argc != 2) {
- g_printerr ("Usage: %s libnm-vpn-plugin-<name>.so\n", argv[0]);
- return EXIT_FAILURE;
- }
-
- plugin = nm_vpn_editor_plugin_load (argv[1], NULL, &error);
- if (!plugin) {
- g_printerr ("Error: %s\n", error->message);
- return EXIT_FAILURE;
- }
-
- g_object_get (G_OBJECT (plugin), "service", &service_type, NULL);
- g_return_val_if_fail (service_type, EXIT_FAILURE);
-
- connection = nm_simple_connection_new ();
- nm_connection_add_setting (connection,
- g_object_new (NM_TYPE_SETTING_VPN,
- "service-type", service_type,
- NULL));
-
- editor = nm_vpn_editor_plugin_get_editor (plugin, connection, &error);
- if (!editor) {
- g_printerr ("Error: %s\n", error->message);
- return EXIT_FAILURE;
- }
-
- main_loop = g_main_loop_new (NULL, FALSE);
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_widget_show (window);
- g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK (window_deleted), main_loop);
-
- widget = GTK_WIDGET (nm_vpn_editor_get_widget (editor));
- gtk_widget_show (widget);
- gtk_container_add (GTK_CONTAINER (window), widget);
- g_main_loop_run (main_loop);
-
- if (!nm_vpn_editor_update_connection (editor, connection, &error)) {
- g_printerr ("Error: %s\n", error->message);
- return EXIT_FAILURE;
- }
-
- gtk_widget_destroy (widget);
- nm_connection_dump (connection);
-
- return EXIT_SUCCESS;
-}
diff --git a/src/libnma/tests/vpn-password-dialog.c b/src/libnma/tests/vpn-password-dialog.c
deleted file mode 100644
index 2a65b432..00000000
--- a/src/libnma/tests/vpn-password-dialog.c
+++ /dev/null
@@ -1,36 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright 2018 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <gtk/gtk.h>
-#include "nma-vpn-password-dialog.h"
-
-int
-main (int argc, char *argv[])
-{
- GtkWidget *widget;
-
-#if GTK_CHECK_VERSION(3,90,0)
- gtk_init ();
-#else
- gtk_init (&argc, &argv);
-#endif
-
- widget = nma_vpn_password_dialog_new ("Title", "Message", "Password");
-
- nma_vpn_password_dialog_set_password (NMA_VPN_PASSWORD_DIALOG (widget), "Password One");
- nma_vpn_password_dialog_set_password_label (NMA_VPN_PASSWORD_DIALOG (widget), "First _Label");
-
- nma_vpn_password_dialog_set_password_secondary (NMA_VPN_PASSWORD_DIALOG (widget), "");
- nma_vpn_password_dialog_set_password_secondary_label (NMA_VPN_PASSWORD_DIALOG (widget), "_Second Label");
- nma_vpn_password_dialog_set_show_password_secondary (NMA_VPN_PASSWORD_DIALOG (widget), TRUE);
-
- nma_vpn_password_dialog_set_password_ternary_label (NMA_VPN_PASSWORD_DIALOG (widget), "_Third Label");
- nma_vpn_password_dialog_set_show_password_ternary (NMA_VPN_PASSWORD_DIALOG (widget), TRUE);
-
- nma_vpn_password_dialog_run_and_block (NMA_VPN_PASSWORD_DIALOG (widget));
- gtk_widget_destroy (widget);
-}
diff --git a/src/libnma/tests/wifi-dialog-secrets.c b/src/libnma/tests/wifi-dialog-secrets.c
deleted file mode 100644
index f6d9ef95..00000000
--- a/src/libnma/tests/wifi-dialog-secrets.c
+++ /dev/null
@@ -1,100 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright 2018 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <gtk/gtk.h>
-#include <NetworkManager.h>
-#include "nma-wifi-dialog.h"
-
-static void
-response_cb (GtkDialog *obj, gint response, gpointer user_data)
-{
- NMAWifiDialog *dialog = NMA_WIFI_DIALOG (obj);
-
- g_print ("response %i\n", response);
-
- if (response == GTK_RESPONSE_OK) {
- GHashTable *diff = NULL, *setting_diff;
- GHashTableIter iter, setting_iter;
- const char *setting, *key;
- NMConnection *connection = nma_wifi_dialog_get_connection (dialog, NULL, NULL);
- NMConnection *orig = user_data;
-
- g_print ("settings changed:\n");
- nm_connection_diff (connection, orig, NM_SETTING_COMPARE_FLAG_EXACT, &diff);
- if (!diff)
- return;
-
- g_hash_table_iter_init (&iter, diff);
- while (g_hash_table_iter_next (&iter, (gpointer) &setting, (gpointer) &setting_diff)) {
- g_hash_table_iter_init (&setting_iter, setting_diff);
- while (g_hash_table_iter_next (&setting_iter, (gpointer) &key, NULL))
- g_print (" %s.%s\n", setting, key);
- }
-
- g_hash_table_destroy (diff);
- }
-}
-
-int
-main (int argc, char *argv[])
-{
- GtkWidget *dialog;
- NMClient *client = NULL;
- NMConnection *connection = NULL;
- GError *error = NULL;
- gs_unref_bytes GBytes *ssid = g_bytes_new_static ("<Maj Vaj Faj>", 13);
- const char *hints[] = {
- NM_SETTING_802_1X_IDENTITY,
- NM_SETTING_802_1X_PASSWORD,
- NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD,
- NULL
- };
-
-#if GTK_CHECK_VERSION(3,90,0)
- gtk_init ();
-#else
- gtk_init (&argc, &argv);
-#endif
-
- client = nm_client_new (NULL, NULL);
- connection = nm_simple_connection_new ();
- nm_connection_add_setting (connection,
- g_object_new (NM_TYPE_SETTING_CONNECTION,
- NM_SETTING_CONNECTION_ID, "<Maj Vaj Faj>",
- NULL));
- nm_connection_add_setting (connection,
- g_object_new (NM_TYPE_SETTING_WIRELESS,
- NM_SETTING_WIRELESS_SSID, ssid,
- NULL));
- nm_connection_add_setting (connection,
- g_object_new (NM_TYPE_SETTING_WIRELESS_SECURITY,
- NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-eap",
- NULL));
- nm_connection_add_setting (connection,
- g_object_new (NM_TYPE_SETTING_802_1X,
- NM_SETTING_802_1X_EAP, (const char * const []){ "peap", NULL },
- NM_SETTING_802_1X_IDENTITY, "budulinek",
- NM_SETTING_802_1X_PHASE2_AUTH, "gtc",
- NULL));
-
- if (!nm_connection_normalize (connection, NULL, NULL, &error)) {
- nm_connection_dump (connection);
- g_printerr ("Error: %s\n", error->message);
- g_error_free (error);
- return 1;
- }
-
- dialog = nma_wifi_dialog_new_for_secrets (client,
- nm_simple_connection_new_clone (connection),
- NM_SETTING_802_1X_SETTING_NAME,
- hints);
- g_signal_connect (dialog, "response", G_CALLBACK (response_cb), connection);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-
- g_object_unref (connection);
-}
diff --git a/src/libnma/tests/wifi-dialog.c b/src/libnma/tests/wifi-dialog.c
deleted file mode 100644
index 1f8219ae..00000000
--- a/src/libnma/tests/wifi-dialog.c
+++ /dev/null
@@ -1,60 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright 2018 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <gtk/gtk.h>
-#include "nma-wifi-dialog.h"
-
-int
-main (int argc, char *argv[])
-{
- GtkWidget *dialog;
- NMClient *client = NULL;
- NMConnection *connection = NULL;
- NMDevice *device = NULL;
- NMAccessPoint *ap = NULL;
- gboolean secrets_only = FALSE;
- GError *error = NULL;
- gs_unref_bytes GBytes *ssid = g_bytes_new_static ("<Maj Vaj Faj>", 13);
-
-#if GTK_CHECK_VERSION(3,90,0)
- gtk_init ();
-#else
- gtk_init (&argc, &argv);
-#endif
-
- client = nm_client_new (NULL, NULL);
- connection = nm_simple_connection_new ();
- nm_connection_add_setting (connection,
- g_object_new (NM_TYPE_SETTING_CONNECTION,
- NM_SETTING_CONNECTION_ID, "<Maj Vaj Faj>",
- NULL));
- nm_connection_add_setting (connection,
- g_object_new (NM_TYPE_SETTING_WIRELESS,
- NM_SETTING_WIRELESS_SSID, ssid,
- NULL));
- nm_connection_add_setting (connection,
- g_object_new (NM_TYPE_SETTING_WIRELESS_SECURITY,
- NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-eap",
- NULL));
- nm_connection_add_setting (connection,
- g_object_new (NM_TYPE_SETTING_802_1X,
- NM_SETTING_802_1X_EAP, (const char * const []){ "peap", NULL },
- NM_SETTING_802_1X_IDENTITY, "budulinek",
- NM_SETTING_802_1X_PHASE2_AUTH, "gtc",
- NULL));
-
- if (!nm_connection_normalize (connection, NULL, NULL, &error)) {
- nm_connection_dump (connection);
- g_printerr ("Error: %s\n", error->message);
- g_error_free (error);
- return 1;
- }
-
- dialog = nma_wifi_dialog_new (client, connection, device, ap, secrets_only);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-}
diff --git a/src/libnma/wifi.ui b/src/libnma/wifi.ui
deleted file mode 100644
index 9e212057..00000000
--- a/src/libnma/wifi.ui
+++ /dev/null
@@ -1,215 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
-<interface domain="nm-applet">
- <requires lib="gtk+" version="3.10"/>
- <object class="GtkListStore" id="model1">
- <columns>
- <!-- column-name gchararray -->
- <column type="gchararray"/>
- </columns>
- <data>
- <row>
- <col id="0"> </col>
- </row>
- </data>
- </object>
- <object class="GtkListStore" id="model2">
- <columns>
- <!-- column-name gchararray -->
- <column type="gchararray"/>
- </columns>
- <data>
- <row>
- <col id="0"> </col>
- </row>
- </data>
- </object>
- <object class="GtkGrid" id="wifi_dialog">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_start">12</property>
- <property name="margin_end">12</property>
- <property name="margin_top">12</property>
- <property name="margin_bottom">12</property>
- <property name="row_spacing">12</property>
- <property name="column_spacing">12</property>
- <child>
- <object class="GtkImage" id="image1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="valign">start</property>
- <property name="margin_start">12</property>
- <property name="margin_end">12</property>
- <property name="margin_top">12</property>
- <property name="margin_bottom">12</property>
- <property name="icon_name">network-wireless</property>
- <property name="icon_size">6</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="caption_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_start">12</property>
- <property name="margin_end">12</property>
- <property name="margin_top">12</property>
- <property name="margin_bottom">12</property>
- <property name="use_markup">True</property>
- <property name="wrap">True</property>
- <property name="max_width_chars">50</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkGrid" id="table1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="row_spacing">6</property>
- <property name="column_spacing">6</property>
- <child>
- <object class="GtkBox" id="security_vbox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="orientation">vertical</property>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">4</property>
- <property name="width">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="security_combo_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Wi-Fi _security</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">security_combo</property>
- <property name="xalign">1</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkComboBox" id="security_combo">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="model">model1</property>
- <child>
- <object class="GtkCellRendererText" id="renderer1"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="network_name_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">_Network name</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">network_name_entry</property>
- <property name="xalign">1</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="network_name_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="activates_default">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="connection_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">C_onnection</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">connection_combo</property>
- <property name="xalign">1</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkComboBox" id="connection_combo">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="device_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Wi-Fi _adapter</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">device_combo</property>
- <property name="xalign">1</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkComboBox" id="device_combo">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="model">model2</property>
- <child>
- <object class="GtkCellRendererText" id="renderer2"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- <property name="width">2</property>
- </packing>
- </child>
- </object>
-</interface>
diff --git a/src/meson.build b/src/meson.build
index af133352..9647a428 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,28 +1,12 @@
src_inc = include_directories('.')
-# FIXME: although this file is contained in the libnma directory
-# it should be generated before because it's used at
-# wireless-security directory, which is needed later for
-# libnma directory.
-libnma_inc = include_directories('libnma')
-
version_conf = configuration_data()
version_conf.set('NMA_MAJOR_VERSION', nma_major_version)
version_conf.set('NMA_MINOR_VERSION', nma_minor_version)
version_conf.set('NMA_MICRO_VERSION', nma_micro_version)
-version = 'nma-version.h'
-
-version_header = configure_file(
- input: 'libnma/' + version + '.in',
- output: version,
- configuration: version_conf,
- install_dir: join_paths(nma_includedir, 'libnma')
-)
-
subdir('utils')
subdir('wireless-security')
-subdir('libnma')
subdir('connection-editor')
diff --git a/src/wireless-security/meson.build b/src/wireless-security/meson.build
index a621cb2e..288f341e 100644
--- a/src/wireless-security/meson.build
+++ b/src/wireless-security/meson.build
@@ -1,6 +1,6 @@
wireless_security_inc = include_directories('.')
-sources = [version_header] + files(
+sources = files(
'eap-method.c',
'eap-method-fast.c',
'eap-method-leap.c',
@@ -42,13 +42,13 @@ sources += gnome.compile_resources(
incs = [
top_inc,
shared_inc,
- src_inc,
- libnma_inc
+ src_inc
]
deps = [
gtk_dep,
libnm_dep,
+ libnma_dep,
libutils_libnm_dep
]
@@ -58,19 +58,3 @@ libwireless_security_libnm = static_library(
include_directories: incs,
dependencies: deps
)
-
-if enable_libnma_gtk4
- deps = [
- gtk4_dep,
- libnm_dep,
- libutils_libnm_dep
- ]
-
- libwireless_security_libnma_gtk4 = static_library(
- 'wireless-security-libnma-gtk4',
- sources: sources,
- include_directories: incs,
- dependencies: deps,
- c_args: cflags
- )
-endif