[krb5-auth-dialog: 3/15] kerberos: Use GNetworkMonitor
- From: Guido Günther <guidog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [krb5-auth-dialog: 3/15] kerberos: Use GNetworkMonitor
- Date: Sat, 6 Feb 2021 19:16:58 +0000 (UTC)
commit 785abe2277b567e77519d9b18ee06419b031b5ce
Author: Guido Günther <agx sigxcpu org>
Date: Sat Feb 6 15:22:19 2021 +0100
kerberos: Use GNetworkMonitor
This avoids a NM dependency.
.gitlab-ci.yml | 1 -
configure.ac | 31 ++----------------------
etpo/Makefile.am | 2 --
src/Makefile.am | 2 --
src/ka-applet.c | 18 --------------
src/ka-kerberos.c | 71 +++++++++----------------------------------------------
6 files changed, 13 insertions(+), 112 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 6f56c9c..ea9bc45 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -11,7 +11,6 @@ variables:
libglib2.0-dev
libgtk-3-dev
libkrb5-dev
- libnm-dev
libpam0g-dev
pkg-config
yelp-tools
diff --git a/configure.ac b/configure.ac
index 50f4696..4a5bd8d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,10 +28,10 @@ KA_COMPILE_WARNINGS([maximum])
YELP_HELP_INIT
GTK_REQUIRED=3.14
-GLIB_REQUIRED=2.28
+GLIB_REQUIRED=2.32
PKG_CHECK_MODULES(GTK, [gtk+-3.0 >= $GTK_REQUIRED, glib-2.0 >= $GLIB_REQUIRED])
-PKG_CHECK_MODULES(GIO, [gio-2.0, gio-unix-2.0])
+PKG_CHECK_MODULES(GIO, [gio-2.0 >= $GLIB_REQUIRED, gio-unix-2.0])
PKG_CHECK_MODULES(GMODULE, gmodule-2.0)
dnl check for deprecated symbols:
@@ -136,28 +136,6 @@ CFLAGS="$savedCFLAGS"
LIBS="$savedLIBS"
-dnl NetworkManager
-AC_MSG_CHECKING([whether to enable NetworkManager support])
-AC_ARG_ENABLE([network-manager],
- AS_HELP_STRING([--enable-network-manager],[Whether to enable automatic network status with
NetworkManager]),
- [],[enable_network_manager=autodetect])
-AC_MSG_RESULT([$enable_network_manager])
-
-if test "x$enable_network_manager" != "xno"; then
- PKG_CHECK_MODULES([NETWORK_MANAGER],[libnm],
- AC_DEFINE([HAVE_LIBNM],[1],[Define if libnm is available])
- [enable_network_manager=yes],
- [enable_network_manager=no])
- AC_SUBST([NETWORK_MANAGER_CFLAGS])
- AC_SUBST([NETWORK_MANAGER_LIBS])
-fi
-
-if test "x$enable_network_manager" = "xyes"; then
- AC_DEFINE([ENABLE_NETWORK_MANAGER],[1],[Define for NetworkManager support])
-fi
-AM_CONDITIONAL([ENABLE_NETWORK_MANAGER],[test "x$enable_network_manager" = "xyes"])
-
-
dnl secmem
dnl Checks for library functions.
AC_CHECK_FUNCS(seteuid stpcpy mmap)
@@ -247,11 +225,6 @@ AC_MSG_NOTICE([])
AC_MSG_NOTICE([ Kerberos: $KRB5_CFLAGS $KRB5_LIBS])
AC_MSG_NOTICE([ GTK: $GTK_CFLAGS $GTK_LIBS])
AC_MSG_NOTICE([ gio-unix: $GIO_UNIX_CFLAGS $GIO_UNIX_LIBS $GIO_CFLAGS $GIO_LIBS])
-if test "$enable_network_manager" = "yes" ; then
-AC_MSG_NOTICE([ Network Manager: $NETWORK_MANAGER_CFLAGS $NETWORK_MANAGER_LIBS])
-else
-AC_MSG_NOTICE([ Network Manager: no])
-fi
AC_MSG_NOTICE([])
AC_MSG_NOTICE([Miscellaneous])
AC_MSG_NOTICE([])
diff --git a/etpo/Makefile.am b/etpo/Makefile.am
index c496c91..dc687ec 100644
--- a/etpo/Makefile.am
+++ b/etpo/Makefile.am
@@ -5,10 +5,8 @@ AM_YFLAGS=-d
AM_CFLAGS=\
@GTK_CFLAGS@ \
@KRB5_CFLAGS@ \
- @NETWORK_MANAGER_CFLAGS@ \
@CFLAGS@
AM_LDFLAGS=\
- @NETWORK_MANAGER_LIBS@ \
@KRB5_LIBS@ \
@GTK_LIBS@
diff --git a/src/Makefile.am b/src/Makefile.am
index ba6f403..31af7f1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -73,14 +73,12 @@ krb5_auth_dialog_CFLAGS = \
$(GMODULE_CFLAGS) \
$(GTK_CFLAGS) \
$(KRB5_CFLAGS) \
- $(NETWORK_MANAGER_CFLAGS) \
$(WARN_CFLAGS) \
$(AM_CFLAGS) \
$(NULL)
krb5_auth_dialog_LDADD = \
$(top_builddir)/secmem/libsecmem.a \
- $(NETWORK_MANAGER_LIBS) \
$(LIBCAP) \
$(KRB5_LIBS) \
$(GIO_LIBS) \
diff --git a/src/ka-applet.c b/src/ka-applet.c
index 3d8d631..075a82e 100644
--- a/src/ka-applet.c
+++ b/src/ka-applet.c
@@ -668,24 +668,6 @@ ka_applet_tooltip_text (int remaining)
}
-/* determine the current icon */
-static const char *
-ka_applet_select_icon (KaApplet *applet, int remaining)
-{
- enum ka_icon status_icon = inv_icon;
-
- if (remaining > 0) {
- if (remaining < applet->priv->pw_prompt_secs &&
- !applet->priv->renewable)
- status_icon = exp_icon;
- else
- status_icon = val_icon;
- }
-
- return applet->priv->icons[status_icon];
-}
-
-
static void
ka_send_event_notification (KaApplet *self,
const char *summary,
diff --git a/src/ka-kerberos.c b/src/ka-kerberos.c
index 6526a72..9c2b9b7 100644
--- a/src/ka-kerberos.c
+++ b/src/ka-kerberos.c
@@ -40,10 +40,6 @@
#include "ka-tools.h"
#include "ka-main-window.h"
-#ifdef ENABLE_NETWORK_MANAGER
-# include <NetworkManager.h>
-#endif
-
#ifdef HAVE_HX509_ERR_H
#include <hx509_err.h>
#endif
@@ -63,10 +59,6 @@ static int ka_renew_credentials (KaApplet *applet);
static gboolean ka_get_tgt_from_ccache (krb5_context context,
krb5_creds *creds);
-#ifdef ENABLE_NETWORK_MANAGER
-NMClient *nm_client;
-#endif
-
/* YAY for different Kerberos implementations */
static int
get_cred_forwardable (krb5_creds *creds)
@@ -483,36 +475,18 @@ auth_dialog_prompter (krb5_context ctx G_GNUC_UNUSED,
}
-#ifdef ENABLE_NETWORK_MANAGER
static void
-ka_nm_client_state_changed_cb (NMClient * client,
- GParamSpec *pspec G_GNUC_UNUSED, gpointer data)
+ka_network_available_changed_cb (GNetworkMonitor *mon,
+ GParamSpec *pspec G_GNUC_UNUSED,
+ gpointer data)
{
- NMState state;
gboolean *online = (gboolean *) data;
- state = nm_client_get_state (client);
- switch (state) {
- case NM_STATE_UNKNOWN:
- case NM_STATE_ASLEEP:
- case NM_STATE_CONNECTING:
- KA_DEBUG ("Network state: %d", state);
- /* do nothing */
- break;
- case NM_STATE_DISCONNECTING:
- case NM_STATE_DISCONNECTED:
- KA_DEBUG ("Network disconnected");
- *online = FALSE;
- break;
- case NM_STATE_CONNECTED_LOCAL:
- case NM_STATE_CONNECTED_SITE:
- case NM_STATE_CONNECTED_GLOBAL:
- KA_DEBUG ("Network connected");
- *online = TRUE;
- break;
- }
+ /* TODO: better bind to a property */
+ *online = g_network_monitor_get_network_available (mon);
+ KA_DEBUG ("Network state: %sline", *online ? "on" : "off");
}
-#endif
+
/* credentials expiring timer */
static gboolean
@@ -1071,36 +1045,15 @@ ka_secmem_init (void)
static void
-ka_nm_shutdown (void)
-{
-#ifdef ENABLE_NETWORK_MANAGER
- if (nm_client) {
- g_object_unref (nm_client);
- nm_client = NULL;
- }
-#endif
-}
-
-
-static gboolean
ka_nm_init (void)
{
-#ifdef ENABLE_NETWORK_MANAGER
- GError *error = NULL;
+ GNetworkMonitor *mon = g_network_monitor_get_default ();
- nm_client = nm_client_new (NULL, &error);
- if (!nm_client) {
- g_warning ("Could not initialize nm-client: %s", error->message);
- g_error_free (error);
- return FALSE;
- }
- g_signal_connect (nm_client, "notify::state",
- G_CALLBACK (ka_nm_client_state_changed_cb),
+ g_signal_connect (mon, "notify::network-available",
+ G_CALLBACK (ka_network_available_changed_cb),
&is_online);
/* Set initial state */
- ka_nm_client_state_changed_cb (nm_client, NULL, &is_online);
-#endif /* ENABLE_NETWORK_MANAGER */
- return TRUE;
+ ka_network_available_changed_cb (mon, NULL, &is_online);
}
@@ -1123,8 +1076,6 @@ ka_kerberos_init (KaApplet *applet)
gboolean
ka_kerberos_destroy ()
{
- ka_nm_shutdown ();
-
if (ccache_monitor)
g_object_unref (ccache_monitor);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]