[krb5-auth-dialog] Move from GConf to GSettings
- From: Guido Günther <guidog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [krb5-auth-dialog] Move from GConf to GSettings
- Date: Fri, 15 Mar 2013 14:20:10 +0000 (UTC)
commit aeb7f423b575d0aeb928e38bff492c2f5894f9fa
Author: Guido Günther <agx sigxcpu org>
Date: Mon Feb 20 21:54:30 2012 +0100
Move from GConf to GSettings
README | 54 +++-
configure.ac | 10 +-
etpo/Makefile.am | 2 -
po/POTFILES.in | 2 +-
src/.gitignore | 1 +
src/Makefile.am | 27 +--
src/ka-applet-priv.h | 11 +-
src/ka-applet.c | 77 +++--
src/ka-gconf-tools.c | 149 ----------
src/ka-gconf-tools.h | 48 ----
src/ka-gconf.c | 195 -------------
src/ka-gconf.h | 29 --
src/ka-kerberos.c | 2 +-
src/ka-plugin-loader.c | 27 +-
src/ka-preferences.c | 467 +++++++++++--------------------
src/ka-preferences.h | 2 +
src/ka-settings.c | 58 ++++
src/ka-settings.h | 43 +++
src/krb5-auth-dialog.schemas.in | 146 ----------
src/org.gnome.KrbAuthDialog.convert | 13 +
src/org.gnome.KrbAuthDialog.gschema.xml | 65 +++++
21 files changed, 463 insertions(+), 965 deletions(-)
---
diff --git a/README b/README
index 9eb5bae..8a2d036 100644
--- a/README
+++ b/README
@@ -4,22 +4,54 @@ it to be part of GNOME.
Configuration
=============
-Configuration settings are handled via gconf.
+Configuration settings are handled via gsettings.
You can set the principal that is used to acquire tickets via:
-gconftool-2 --type=string --set /apps/krb5-auth-dialog/principal "principal YOUR REALM"
-
-You can hide the tray icon via:
-gconftool-2 --type=bool --set /apps/krb5-auth-dialog/show_trayicon false
+gsettings set org.gnome.KrbAuthDialog principal "principal YOUR REALM"
You can set the time of the first password prompt via:
-gconftool-2 --type=int --set /apps/krb5-auth-dialog/prompt_minutes 30
+gsettings set org.gnome.KrbAuthDialog prompt-minutes 30
You can set the principals pkinit identifier via:
-gconftool-2 --type=string --set /apps/krb5-auth-dialog/pk_userid "FILE:/path/to/user.pem,/path/to/user.key"
+gsettings set org.gnome.KrbAuthDialog pk-userid "FILE:/path/to/user.pem,/path/to/user.key"
+
or if you're using a smartcard:
-gconftool-2 --type=string --set /apps/krb5-auth-dialog/pk_userid "PKCS11:/usr/lib/opensc/opensc-pkcs11.so"
+gsettings set org.gnome.KrbAuthDialog pk-userid "PKCS11:/usr/lib/opensc/opensc-pkcs11.so"
+
+DBus API
+========
+You can request a ticket granting ticket via DBus:
+
+ dbus-send --print-reply --type=method_call \
+ --dest=org.gnome.KrbAuthDialog \
+ /org/gnome/KrbAuthDialog \
+ org.gnome.KrbAuthDialog.acquireTgt \
+ string:'principal'
+
+If the sent principal doesn't match the one currently in the ticket cache the
+request fails. To request a TGT for the "default" principal use string:''.
+See examples/tgt-signals.py for information about sent DBus signals.
+
+
+Plugins
+=======
+Plugins are currently disabled by default. Individual plugins can be enabled via gsettings:
+
+Enable pam and dummy plugions:
+.
+
+You can set the principal that is used to acquire tickets via:
+gsettings set org.gnome.KrbAuthDialog principal "principal YOUR REALM"
+
+You can set the time of the first password prompt via:
+gsettings set org.gnome.KrbAuthDialog prompt-minutes 30
+
+You can set the principals pkinit identifier via:
+gsettings set org.gnome.KrbAuthDialog pk-userid "FILE:/path/to/user.pem,/path/to/user.key"
+
+or if you're using a smartcard:
+gsettings set org.gnome.KrbAuthDialog pk-userid "PKCS11:/usr/lib/opensc/opensc-pkcs11.so"
DBus API
========
@@ -39,13 +71,13 @@ See examples/tgt-signals.py for information about sent DBus signals.
Plugins
=======
-Plugins are currently disabled by default. To enable them you have to set the gconf key:
+Plugins are currently disabled by default. Individual plugins can be enabled via gsettings:
Enable pam and dummy plugions:
-gconftool-2 --set --list-type=string --type=list /apps/krb5-auth-dialog/plugins/enabled [pam,dummy]
+gsettings set org.gnome.KrbAuthDialog.plugins enabled "['pam', 'dummy']"
To list currently enabled plugins:
-gconftool-2 --get --list-type=string /apps/krb5-auth-dialog/plugins/enabled
+gsettings get org.gnome.KrbAuthDialog.plugins enabled
A Note on Translations
diff --git a/configure.ac b/configure.ac
index ae78ea2..992a102 100644
--- a/configure.ac
+++ b/configure.ac
@@ -29,11 +29,9 @@ GNOME_DOC_INIT
GTK_REQUIRED=3.0
GLIB_REQUIRED=2.28
-GCONF_REQUIRED=2.31
LIBNOTIFY_REQUIRED=0.7.0
PKG_CHECK_MODULES(GTK, [gtk+-3.0 >= $GTK_REQUIRED, glib-2.0 >= $GLIB_REQUIRED])
-PKG_CHECK_MODULES(GCONF, gconf-2.0 >= $GCONF_REQUIRED)
PKG_CHECK_MODULES(GIO, [gio-2.0, gio-unix-2.0])
PKG_CHECK_MODULES(GMODULE, gmodule-2.0)
PKG_CHECK_MODULES(LIBNOTIFY, libnotify >= $LIBNOTIFY_REQUIRED)
@@ -41,12 +39,7 @@ PKG_CHECK_MODULES(LIBNOTIFY, libnotify >= $LIBNOTIFY_REQUIRED)
dnl check for deprecated symbols:
dnl GNOME_MAINTAINER_MODE_DEFINES
-AM_GCONF_SOURCE_2
-
-AC_PATH_PROG([GCONFTOOL], [gconftool-2], [no])
-if test "$GCONFTOOL" = "no"; then
- AC_MSG_ERROR([gconftool-2 not found])
-fi
+GLIB_GSETTINGS
dnl --enable-debug=(yes|no)
AC_ARG_ENABLE(debug,
@@ -261,7 +254,6 @@ AC_MSG_NOTICE([Libraries])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([ Kerberos: $KRB5_CFLAGS $KRB5_LIBS])
AC_MSG_NOTICE([ GTK: $GTK_CFLAGS $GTK_LIBS])
-AC_MSG_NOTICE([ gconf: $GCONF_CFLAGS $GCONF_LIBS])
AC_MSG_NOTICE([ gio-unix: $GIO_UNIX_CFLAGS $GIO_UNIX_LIBS $GIO_CFLAGS $GIO_LIBS])
if test "$with_libnotify" = "yes" ; then
AC_MSG_NOTICE([ libnotify: $LIBNOTIFY_CFLAGS $LIBNOTIFY_LIBS])
diff --git a/etpo/Makefile.am b/etpo/Makefile.am
index e7fa933..584657f 100644
--- a/etpo/Makefile.am
+++ b/etpo/Makefile.am
@@ -4,7 +4,6 @@ lexer.c: grammar.h
AM_YFLAGS=-d
AM_CFLAGS=\
@GTK_CFLAGS@ \
- @GCONF_CFLAGS@ \
@KRB5_CFLAGS@ \
@NETWORK_MANAGER_CFLAGS@ \
@LIBNOTIFY_CFLAGS@ \
@@ -13,7 +12,6 @@ AM_LDFLAGS=\
@NETWORK_MANAGER_LIBS@ \
@KRB5_LIBS@ \
@LIBNOTIFY_LIBS@ \
- @GCONF_LIBS@ \
@GTK_LIBS@
DISTCLEANFILES=lexer.c
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 7485558..b65ce3d 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -7,5 +7,5 @@ src/ka-tools.c
src/ka-main-window.c
src/ka-preferences.c
src/krb5-auth-dialog.desktop.in
-src/krb5-auth-dialog.schemas.in
+src/org.gnome.KrbAuthDialog.gschema.xml
secmem/util.c
diff --git a/src/.gitignore b/src/.gitignore
index 6d9018c..3c6ac84 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -3,3 +3,4 @@ krb5-auth-dialog.1
krb5-auth-dialog.desktop
krb5-auth-dialog.schemas
org.gnome.KrbAuthDialog.service
+org.gnome.KrbAuthDialog.gschema.valid
diff --git a/src/Makefile.am b/src/Makefile.am
index 9c22dcf..3cf1a7d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -12,10 +12,11 @@ desktopdir = $(datadir)/applications
desktop_in_files = krb5-auth-dialog.desktop.in
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
-schemadir = $(GCONF_SCHEMA_FILE_DIR)
-schema_in_files = krb5-auth-dialog.schemas.in
-schema_DATA = $(schema_in_files:.schemas.in=.schemas)
- INTLTOOL_SCHEMAS_RULE@
+gsettings_SCHEMAS = org.gnome.KrbAuthDialog.gschema.xml
+ GSETTINGS_RULES@
+
+convertdir = $(datadir)/GConf/gsettings
+dist_convert_DATA = org.gnome.KrbAuthDialog.convert
servicedir = $(datadir)/dbus-1/services
service_in_files = org.gnome.KrbAuthDialog.service.in
@@ -32,10 +33,8 @@ krb5_auth_dialog_SOURCES = \
ka-applet.h \
ka-pwdialog.c \
ka-pwdialog.h \
- ka-gconf.c \
- ka-gconf.h \
- ka-gconf-tools.c \
- ka-gconf-tools.h \
+ ka-settings.c \
+ ka-settings.h \
ka-dbus.c \
ka-dbus.h \
ka-tools.c \
@@ -68,7 +67,6 @@ krb5_auth_dialog_CPPFLAGS = \
krb5_auth_dialog_CFLAGS = \
$(GMODULE_CFLAGS) \
$(GTK_CFLAGS) \
- $(GCONF_CFLAGS) \
$(KRB5_CFLAGS) \
$(NETWORK_MANAGER_CFLAGS) \
$(LIBNOTIFY_CFLAGS) \
@@ -82,7 +80,6 @@ krb5_auth_dialog_LDADD = \
$(LIBCAP) \
$(KRB5_LIBS) \
$(LIBNOTIFY_LIBS) \
- $(GCONF_LIBS) \
$(GIO_LIBS) \
$(GMODULE_LIBS) \
$(GTK_LIBS) \
@@ -103,6 +100,7 @@ EXTRA_DIST = \
$(schema_in_files) \
$(autostart_in_files) \
$(service_in_files) \
+ org.gnome.KrbAuthDialog.gschema.xml \
krb5-auth-dialog.1.in \
$(NULL)
@@ -111,12 +109,3 @@ DISTCLEANFILES = \
krb5-auth-dialog.desktop \
$(NULL)
-install-data-local: $(schema_DATA)
-if GCONF_SCHEMAS_INSTALL
- if test -z "$(DESTDIR)" ; then \
- for p in $^ ; do \
- GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $$p
2>&1 > /dev/null; \
- done \
- fi
-endif
-
diff --git a/src/ka-applet-priv.h b/src/ka-applet-priv.h
index d571230..0a8f021 100644
--- a/src/ka-applet-priv.h
+++ b/src/ka-applet-priv.h
@@ -25,7 +25,6 @@
#include <glib-object.h>
#include <glib/gprintf.h>
-#include <gconf/gconf-client.h>
#include <krb5.h>
#include "config.h"
@@ -52,11 +51,19 @@ void ka_applet_set_tgt_renewable (KaApplet *self, gboolean renewable);
gboolean ka_applet_get_tgt_renewable (const KaApplet *self);
guint ka_applet_get_pw_prompt_secs (const KaApplet *self);
KaPwDialog *ka_applet_get_pwdialog (const KaApplet *self);
-GConfClient *ka_applet_get_gconf_client (const KaApplet *self);
+GSettings *ka_applet_get_settings (const KaApplet *self);
void ka_applet_signal_emit (KaApplet *self, KaAppletSignalNumber signum,
krb5_timestamp expiry);
void ka_applet_set_msg (KaApplet *self, const char *msg);
+/* properties */
+#define KA_PROP_NAME_PRINCIPAL "principal"
+#define KA_PROP_NAME_PK_USERID "pk-userid"
+#define KA_PROP_NAME_PK_ANCHORS "pk-anchors"
+#define KA_PROP_NAME_PW_PROMPT_MINS "pw-prompt-mins"
+#define KA_PROP_NAME_TGT_FORWARDABLE "tgt-forwardable"
+#define KA_PROP_NAME_TGT_PROXIABLE "tgt-proxiable"
+#define KA_PROP_NAME_TGT_RENEWABLE "tgt-renewable"
/* create the applet */
KaApplet *ka_applet_create (void);
diff --git a/src/ka-applet.c b/src/ka-applet.c
index 203c442..697c06d 100644
--- a/src/ka-applet.c
+++ b/src/ka-applet.c
@@ -25,8 +25,7 @@
#include "ka-applet-priv.h"
#include "ka-dbus.h"
#include "ka-kerberos.h"
-#include "ka-gconf-tools.h"
-#include "ka-gconf.h"
+#include "ka-settings.h"
#include "ka-tools.h"
#include "ka-main-window.h"
#include "ka-plugin-loader.h"
@@ -91,10 +90,10 @@ struct _KaAppletPrivate {
gboolean startup_ccache; /* ccache found on startup */
gboolean auto_run; /* only start with valid ccache */
- /* GConf optins */
+ /* GSettings options */
NotifyNotification *notification; /* notification messages */
char *krb_msg; /* Additional banner delivered by Kerberos */
- const char *notify_gconf_key; /* disable notification gconf key */
+ const char *notify_key; /* name of disable notification setting key */
char *principal; /* the principal to request */
gboolean renewable; /* credentials renewable? */
char *pk_userid; /* "userid" for pkint */
@@ -103,7 +102,7 @@ struct _KaAppletPrivate {
gboolean tgt_renewable; /* request a renewable ticket */
gboolean tgt_proxiable; /* request a proxiable ticket */
- GConfClient *gconf; /* gconf client */
+ GSettings *settings; /* GSettings client */
};
@@ -369,25 +368,25 @@ ka_applet_class_init (KaAppletClass *klass)
object_class->set_property = ka_applet_set_property;
object_class->get_property = ka_applet_get_property;
- pspec = g_param_spec_string ("principal",
+ pspec = g_param_spec_string (KA_PROP_NAME_PRINCIPAL,
"Principal",
"Get/Set Kerberos principal",
"", G_PARAM_CONSTRUCT | G_PARAM_READWRITE);
g_object_class_install_property (object_class, KA_PROP_PRINCIPAL, pspec);
- pspec = g_param_spec_string ("pk-userid",
+ pspec = g_param_spec_string (KA_PROP_NAME_PK_USERID,
"PKinit identifier",
"Get/Set Pkinit identifier",
"", G_PARAM_CONSTRUCT | G_PARAM_READWRITE);
g_object_class_install_property (object_class, KA_PROP_PK_USERID, pspec);
- pspec = g_param_spec_string ("pk-anchors",
+ pspec = g_param_spec_string (KA_PROP_NAME_PK_ANCHORS,
"PKinit trust anchors",
"Get/Set Pkinit trust anchors",
"", G_PARAM_CONSTRUCT | G_PARAM_READWRITE);
g_object_class_install_property (object_class, KA_PROP_PK_ANCHORS, pspec);
- pspec = g_param_spec_uint ("pw-prompt-mins",
+ pspec = g_param_spec_uint (KA_PROP_NAME_PW_PROMPT_MINS,
"Password prompting interval",
"Password prompting interval in minutes",
0, G_MAXUINT, MINUTES_BEFORE_PROMPTING,
@@ -395,7 +394,7 @@ ka_applet_class_init (KaAppletClass *klass)
g_object_class_install_property (object_class,
KA_PROP_PW_PROMPT_MINS, pspec);
- pspec = g_param_spec_boolean ("tgt-forwardable",
+ pspec = g_param_spec_boolean (KA_PROP_NAME_TGT_FORWARDABLE,
"Forwardable ticket",
"wether to request forwardable tickets",
FALSE,
@@ -403,7 +402,7 @@ ka_applet_class_init (KaAppletClass *klass)
g_object_class_install_property (object_class,
KA_PROP_TGT_FORWARDABLE, pspec);
- pspec = g_param_spec_boolean ("tgt-proxiable",
+ pspec = g_param_spec_boolean (KA_PROP_NAME_TGT_PROXIABLE,
"Proxiable ticket",
"wether to request proxiable tickets",
FALSE,
@@ -411,7 +410,7 @@ ka_applet_class_init (KaAppletClass *klass)
g_object_class_install_property (object_class,
KA_PROP_TGT_PROXIABLE, pspec);
- pspec = g_param_spec_boolean ("tgt-renewable",
+ pspec = g_param_spec_boolean (KA_PROP_NAME_TGT_RENEWABLE,
"Renewable ticket",
"wether to request renewable tickets",
FALSE,
@@ -534,15 +533,20 @@ ka_notify_disable_action_cb (NotifyNotification *notification G_GNUC_UNUSED,
gpointer user_data)
{
KaApplet *self = KA_APPLET (user_data);
+ GSettings *ns = g_settings_get_child (self->priv->settings,
+ KA_SETTING_CHILD_NOTIFY);
if (strcmp (action, "dont-show-again") == 0) {
- KA_DEBUG ("turning of notification %s", self->priv->notify_gconf_key);
- ka_gconf_set_bool (self->priv->gconf,
- self->priv->notify_gconf_key, FALSE);
- self->priv->notify_gconf_key = NULL;
+ KA_DEBUG ("turning of notification %s", self->priv->notify_key);
+ if (!g_settings_set_boolean (ns,
+ self->priv->notify_key, FALSE)) {
+ g_warning("Failed to set %s", self->priv->notify_key);
+ }
+ self->priv->notify_key = NULL;
} else {
g_warning ("unkonwn action for callback");
}
+ g_object_unref (ns);
}
@@ -693,6 +697,18 @@ ka_update_tray_icon (KaApplet *self, const char *icon, const char *tooltip)
}
}
+/* check whether a given notification is enabled */
+static gboolean
+get_notify_enabled (KaApplet *self, const char *key)
+{
+ gboolean ret;
+ GSettings *ns = g_settings_get_child (self->priv->settings,
+ KA_SETTING_CHILD_NOTIFY);
+ ret = g_settings_get_boolean (ns, key);
+ g_object_unref (ns);
+ return ret;
+}
+
/*
* update the tray icon's tooltip and icon
* and notify listeners about acquired/expiring tickets via signals
@@ -713,10 +729,9 @@ ka_applet_update_status (KaApplet *applet, krb5_timestamp expiry)
if (remaining > 0) {
if (expiry_notified || initial_notification) {
const char* msg;
- ka_gconf_get_bool (applet->priv->gconf,
- KA_GCONF_KEY_NOTIFY_VALID, ¬ify);
+ notify = get_notify_enabled (applet, KA_SETTING_KEY_NOTIFY_VALID);
if (notify) {
- applet->priv->notify_gconf_key = KA_GCONF_KEY_NOTIFY_VALID;
+ applet->priv->notify_key = KA_SETTING_KEY_NOTIFY_VALID;
if (applet->priv->krb_msg)
msg = applet->priv->krb_msg;
@@ -740,11 +755,11 @@ ka_applet_update_status (KaApplet *applet, krb5_timestamp expiry)
if (remaining < applet->priv->pw_prompt_secs
&& (now - last_warn) > NOTIFY_SECONDS
&& !applet->priv->renewable) {
- ka_gconf_get_bool (applet->priv->gconf,
- KA_GCONF_KEY_NOTIFY_EXPIRING, ¬ify);
+ notify = get_notify_enabled (applet,
+ KA_SETTING_KEY_NOTIFY_EXPIRING);
if (notify) {
- applet->priv->notify_gconf_key =
- KA_GCONF_KEY_NOTIFY_EXPIRING;
+ applet->priv->notify_key =
+ KA_SETTING_KEY_NOTIFY_EXPIRING;
ka_send_event_notification (applet,
_("Network credentials expiring"),
tooltip_text,
@@ -759,10 +774,9 @@ ka_applet_update_status (KaApplet *applet, krb5_timestamp expiry)
}
} else {
if (!expiry_notified) {
- ka_gconf_get_bool (applet->priv->gconf,
- KA_GCONF_KEY_NOTIFY_EXPIRED, ¬ify);
+ notify = get_notify_enabled (applet, KA_SETTING_KEY_NOTIFY_EXPIRED);
if (notify) {
- applet->priv->notify_gconf_key = KA_GCONF_KEY_NOTIFY_EXPIRED;
+ applet->priv->notify_key = KA_SETTING_KEY_NOTIFY_EXPIRED;
ka_send_event_notification (applet,
_("Network credentials expired"),
_("Your Kerberos credentials have expired."),
@@ -965,10 +979,10 @@ ka_applet_get_pwdialog (const KaApplet *applet)
return applet->priv->pwdialog;
}
-GConfClient *
-ka_applet_get_gconf_client (const KaApplet *self)
+GSettings *
+ka_applet_get_settings (const KaApplet *self)
{
- return self->priv->gconf;
+ return self->priv->settings;
}
void
@@ -1043,6 +1057,7 @@ ka_applet_destroy (KaApplet* self)
}
ka_kerberos_destroy ();
+ ka_preferences_window_destroy ();
}
@@ -1078,8 +1093,8 @@ ka_applet_create ()
applet->priv->pwdialog = ka_pwdialog_create (applet->priv->uixml);
g_return_val_if_fail (applet->priv->pwdialog != NULL, NULL);
- applet->priv->gconf = ka_gconf_init (applet);
- g_return_val_if_fail (applet->priv->gconf != NULL, NULL);
+ applet->priv->settings = ka_settings_init (applet);
+ g_return_val_if_fail (applet->priv->settings != NULL, NULL);
applet->priv->loader = ka_plugin_loader_create (applet);
g_return_val_if_fail (applet->priv->loader != NULL, NULL);
diff --git a/src/ka-kerberos.c b/src/ka-kerberos.c
index e131286..7eff619 100644
--- a/src/ka-kerberos.c
+++ b/src/ka-kerberos.c
@@ -531,7 +531,7 @@ credentials_expiring_once (gpointer *data)
/*
- * set ticket options by looking at krb5.conf and gconf
+ * set ticket options by looking at krb5.conf and gsettings
*/
static void
ka_set_ticket_options (KaApplet *applet, krb5_context context,
diff --git a/src/ka-plugin-loader.c b/src/ka-plugin-loader.c
index 2321215..e21a863 100644
--- a/src/ka-plugin-loader.c
+++ b/src/ka-plugin-loader.c
@@ -16,12 +16,10 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#include <gconf/gconf-client.h>
-
#include "ka-plugin-loader.h"
#include "ka-plugin.h"
+#include "ka-settings.h"
#include "ka-applet-priv.h"
-#include "ka-gconf-tools.h"
#include <gmodule.h>
@@ -98,29 +96,33 @@ load_plugins (KaPluginLoader *self)
{
int i;
KaPluginLoaderPrivate *priv = GET_PRIVATE (self);
- const char *pname;
- GConfClient *gconf;
- GSList *plugins = NULL;
+ GSettings *settings;
+ char **plugins = NULL;
if (!g_module_supported ()) {
g_warning ("GModules are not supported on your platform!");
return;
}
- gconf = ka_applet_get_gconf_client (priv->applet);
+ settings = g_settings_get_child(ka_applet_get_settings (priv->applet),
+ KA_SETTING_CHILD_PLUGINS);
/* For now we only load the plugins on program startup */
- ka_gconf_get_string_list(gconf, KA_GCONF_KEY_PLUGINS_ENABLED, &plugins);
+ plugins = g_settings_get_strv(settings,
+ KA_SETTING_KEY_PLUGINS_ENABLED);
+
if (!plugins) {
g_message ("No plugins to load");
- return ;
+ return;
}
- for (i=0; (pname = g_slist_nth_data (plugins, i)) != NULL; i++) {
+ for (i = 0; plugins[i]; i++) {
char *path;
char *fname;
KaPlugin *plugin;
- fname = g_strdup_printf("libka-plugin-%s.%s", pname, G_MODULE_SUFFIX);
+ fname = g_strdup_printf("libka-plugin-%s.%s",
+ plugins[i],
+ G_MODULE_SUFFIX);
path = g_module_build_path (KA_PLUGINS_DIR, fname);
plugin = load_plugin (path);
@@ -131,7 +133,8 @@ load_plugins (KaPluginLoader *self)
g_free (fname);
g_free (path);
}
- g_slist_free (plugins);
+ g_strfreev (plugins);
+ g_object_unref (settings);
}
diff --git a/src/ka-preferences.c b/src/ka-preferences.c
index a80f6d9..204c6a6 100644
--- a/src/ka-preferences.c
+++ b/src/ka-preferences.c
@@ -20,7 +20,7 @@
#include "config.h"
#include "ka-preferences.h"
-#include "ka-gconf-tools.h"
+#include "ka-settings.h"
#include "ka-tools.h"
#include <glib/gi18n.h>
@@ -30,12 +30,12 @@
#define PKINIT_SMARTCARD "PKCS11:" SC_PKCS11
#define PKINIT_FILE "FILE:"
-#define N_LISTENERS 7
+#define N_BINDINGS 3
struct _KaPreferencesPrivate {
GtkBuilder *builder;
- GConfClient *client;
+ GSettings *settings;
GtkWidget *dialog;
GtkWidget *notebook;
@@ -45,28 +45,21 @@ struct _KaPreferencesPrivate {
GtkWidget *smartcard_toggle;
GtkWidget *pkanchors_entry;
GtkWidget *pkanchors_button;
- GtkWidget *forwardable_toggle;
- GtkWidget *proxiable_toggle;
- GtkWidget *renewable_toggle;
GtkWidget *prompt_mins_entry;
- guint listeners [N_LISTENERS];
- int n_listeners;
+ GBinding* bindings[N_BINDINGS];
+ int n_bindings;
} prefs;
static void
-ka_preferences_principal_notify (GConfClient *client G_GNUC_UNUSED,
- guint cnx_id G_GNUC_UNUSED,
- GConfEntry *entry,
+ka_preferences_principal_notify (GSettings *settings,
+ gchar *key,
gpointer userdata G_GNUC_UNUSED)
{
const char *principal;
- if (!entry->value || entry->value->type != GCONF_VALUE_STRING)
- return;
-
- principal = gconf_value_get_string (entry->value);
+ principal = g_settings_get_string (settings, key);
if (!principal || !strlen(principal))
gtk_entry_set_text (GTK_ENTRY (prefs.principal_entry), "");
@@ -81,63 +74,48 @@ ka_preferences_principal_notify (GConfClient *client G_GNUC_UNUSED,
static void
ka_preferences_principal_changed (GtkEntry *entry,
- gpointer userdata G_GNUC_UNUSED)
+ gpointer userdata)
{
const char *principal;
+ KaApplet *applet = KA_APPLET(userdata);
principal = gtk_entry_get_text (entry);
- if (!principal || !strlen(principal))
- gconf_client_unset (prefs.client, KA_GCONF_KEY_PRINCIPAL, NULL);
+ if (principal || strlen(principal))
+ g_object_set (applet, KA_PROP_NAME_PRINCIPAL, principal, NULL);
else
- gconf_client_set_string (prefs.client, KA_GCONF_KEY_PRINCIPAL, principal, NULL);
+ g_object_set (applet, KA_PROP_NAME_PRINCIPAL, "", NULL);
}
static void
-ka_preferences_setup_principal_entry ()
+ka_preferences_setup_principal_entry (KaApplet *applet)
{
- char *principal = NULL;
+ char *principal = NULL;
prefs.principal_entry = WID (prefs.builder, "principal_entry");
g_assert (prefs.principal_entry != NULL);
- if (!ka_gconf_get_string (prefs.client, KA_GCONF_KEY_PRINCIPAL, &principal))
+ g_object_get (applet, KA_PROP_NAME_PRINCIPAL, &principal, NULL);
+ if (!principal)
g_warning ("Getting principal failed");
-
if (principal && strlen(principal))
gtk_entry_set_text (GTK_ENTRY (prefs.principal_entry), principal);
- if (principal)
- g_free (principal);
+ g_free (principal);
g_signal_connect (prefs.principal_entry, "changed",
- G_CALLBACK (ka_preferences_principal_changed), NULL);
-
- if (!gconf_client_key_is_writable (prefs.client, KA_GCONF_KEY_PRINCIPAL, NULL)) {
- gtk_widget_set_sensitive (prefs.principal_entry, FALSE);
- }
-
- prefs.listeners [prefs.n_listeners] =
- gconf_client_notify_add (prefs.client,
- KA_GCONF_KEY_PRINCIPAL,
- (GConfClientNotifyFunc) ka_preferences_principal_notify,
- NULL, NULL, NULL);
- prefs.n_listeners++;
+ G_CALLBACK (ka_preferences_principal_changed), applet);
}
static void
-ka_preferences_pkuserid_notify (GConfClient *client G_GNUC_UNUSED,
- guint cnx_id G_GNUC_UNUSED,
- GConfEntry *entry,
- gpointer *userdata G_GNUC_UNUSED)
+ka_preferences_pkuserid_notify (GSettings *settings,
+ gchar *key,
+ gpointer userdata G_GNUC_UNUSED)
{
const char *pkuserid;
- if (!entry->value || entry->value->type != GCONF_VALUE_STRING)
- return;
-
- pkuserid = gconf_value_get_string (entry->value);
+ pkuserid = g_settings_get_string (settings, key);
if (!pkuserid || !strlen(pkuserid))
gtk_entry_set_text (GTK_ENTRY (prefs.pkuserid_entry), "");
@@ -153,62 +131,47 @@ ka_preferences_pkuserid_notify (GConfClient *client G_GNUC_UNUSED,
static void
ka_preferences_pkuserid_changed (GtkEntry *entry,
- gpointer *user_data G_GNUC_UNUSED)
+ gpointer *userdata)
{
const char *pkuserid;
+ KaApplet *applet = KA_APPLET(userdata);
pkuserid = gtk_entry_get_text (entry);
if (!pkuserid || !strlen(pkuserid))
- gconf_client_unset (prefs.client, KA_GCONF_KEY_PK_USERID, NULL);
+ g_object_set (applet, KA_PROP_NAME_PK_USERID, "", NULL);
else
- gconf_client_set_string (prefs.client, KA_GCONF_KEY_PK_USERID, pkuserid, NULL);
+ g_object_set (applet, KA_PROP_NAME_PK_USERID, pkuserid, NULL);
}
-
static void
-ka_preferences_setup_pkuserid_entry ()
+ka_preferences_setup_pkuserid_entry (KaApplet *applet)
{
char *pkuserid = NULL;
prefs.pkuserid_entry = WID(prefs.builder, "pkuserid_entry");
g_assert (prefs.pkuserid_entry != NULL);
- if (!ka_gconf_get_string (prefs.client, KA_GCONF_KEY_PK_USERID, &pkuserid))
+ g_object_get (applet, KA_PROP_NAME_PK_USERID, &pkuserid, NULL);
+ if (!pkuserid)
g_warning ("Getting pkuserid failed");
-
if (pkuserid && strlen(pkuserid))
gtk_entry_set_text (GTK_ENTRY (prefs.pkuserid_entry), pkuserid);
if (pkuserid)
g_free (pkuserid);
g_signal_connect (prefs.pkuserid_entry, "changed",
- G_CALLBACK (ka_preferences_pkuserid_changed), NULL);
- if (!gconf_client_key_is_writable (prefs.client, KA_GCONF_KEY_PK_USERID, NULL)) {
- gtk_widget_set_sensitive (prefs.pkuserid_entry, FALSE);
- }
-
- prefs.listeners [prefs.n_listeners] =
- gconf_client_notify_add (prefs.client,
- KA_GCONF_KEY_PK_USERID,
- (GConfClientNotifyFunc) ka_preferences_pkuserid_notify,
- NULL, NULL, NULL);
- prefs.n_listeners++;
+ G_CALLBACK (ka_preferences_pkuserid_changed), applet);
}
-
static void
-ka_preferences_pkanchors_notify (GConfClient *client G_GNUC_UNUSED,
- guint cnx_id G_GNUC_UNUSED,
- GConfEntry *entry,
+ka_preferences_pkanchors_notify (GSettings *settings,
+ gchar *key,
gpointer userdata G_GNUC_UNUSED)
{
const char *pkanchors;
- if (!entry->value || entry->value->type != GCONF_VALUE_STRING)
- return;
-
- pkanchors = gconf_value_get_string (entry->value);
+ pkanchors = g_settings_get_string (settings, key);
if (!pkanchors || !strlen(pkanchors))
gtk_entry_set_text (GTK_ENTRY (prefs.pkanchors_entry), "");
@@ -216,37 +179,38 @@ ka_preferences_pkanchors_notify (GConfClient *client G_GNUC_UNUSED,
const char *old_pkanchors;
old_pkanchors = gtk_entry_get_text (GTK_ENTRY (prefs.pkanchors_entry));
- if (!old_pkanchors || (old_pkanchors && strcmp (old_pkanchors, pkanchors)))
+ if (!old_pkanchors || (old_pkanchors && strcmp (old_pkanchors,
+ pkanchors)))
gtk_entry_set_text (GTK_ENTRY (prefs.pkanchors_entry), pkanchors);
}
}
-
static void
ka_preferences_pkanchors_changed (GtkEntry *entry,
- gpointer userdata G_GNUC_UNUSED)
+ gpointer userdata)
{
const char *pkanchors;
+ KaApplet *applet = KA_APPLET(userdata);
pkanchors = gtk_entry_get_text (entry);
if (!pkanchors || !strlen(pkanchors))
- gconf_client_unset (prefs.client, KA_GCONF_KEY_PK_ANCHORS, NULL);
+ g_object_set (applet, KA_PROP_NAME_PK_ANCHORS, "", NULL);
else
- gconf_client_set_string (prefs.client, KA_GCONF_KEY_PK_ANCHORS,
- pkanchors, NULL);
+ g_object_set (applet, KA_PROP_NAME_PK_ANCHORS, pkanchors, NULL);
}
static void
-ka_preferences_setup_pkanchors_entry ()
+ka_preferences_setup_pkanchors_entry (KaApplet *applet)
{
char *pkanchors = NULL;
prefs.pkanchors_entry = WID(prefs.builder, "pkanchors_entry");
g_assert (prefs.pkanchors_entry != NULL);
- if (!ka_gconf_get_string (prefs.client, KA_GCONF_KEY_PK_ANCHORS, &pkanchors))
+ g_object_get (applet, KA_PROP_NAME_PK_ANCHORS, &pkanchors, NULL);
+ if (!pkanchors)
g_warning ("Getting pkanchors failed");
if (pkanchors && strlen(pkanchors))
@@ -255,17 +219,7 @@ ka_preferences_setup_pkanchors_entry ()
g_free (pkanchors);
g_signal_connect (prefs.pkanchors_entry, "changed",
- G_CALLBACK (ka_preferences_pkanchors_changed), NULL);
- if (!gconf_client_key_is_writable (prefs.client, KA_GCONF_KEY_PK_ANCHORS, NULL)) {
- gtk_widget_set_sensitive (prefs.pkanchors_entry, FALSE);
- }
-
- prefs.listeners [prefs.n_listeners] =
- gconf_client_notify_add (prefs.client,
- KA_GCONF_KEY_PK_ANCHORS,
- (GConfClientNotifyFunc) ka_preferences_pkanchors_notify,
- NULL, NULL, NULL);
- prefs.n_listeners++;
+ G_CALLBACK (ka_preferences_pkanchors_changed), applet);
}
@@ -279,10 +233,11 @@ ka_preferences_toggle_pkuserid_entry (gboolean state, gpointer userdata G_GNUC_U
static void
ka_preferences_smartcard_toggled (GtkToggleButton *toggle,
- gpointer userdata G_GNUC_UNUSED)
+ gpointer userdata)
{
gboolean smartcard = gtk_toggle_button_get_active (toggle);
static gchar *old_path = NULL;
+ KaApplet *applet = KA_APPLET(userdata);
if (smartcard) {
const char *path;
@@ -292,31 +247,33 @@ ka_preferences_smartcard_toggled (GtkToggleButton *toggle,
g_free (old_path);
old_path = g_strdup (path);
}
+
ka_preferences_toggle_pkuserid_entry (FALSE, NULL);
- gconf_client_set_string (prefs.client, KA_GCONF_KEY_PK_USERID, PKINIT_SMARTCARD, NULL);
+ g_object_set (applet, KA_SETTING_KEY_PK_USERID, PKINIT_SMARTCARD, NULL);
} else {
ka_preferences_toggle_pkuserid_entry (TRUE, NULL);
if (old_path)
- gconf_client_set_string (prefs.client, KA_GCONF_KEY_PK_USERID, old_path, NULL);
+ g_object_set (applet, KA_SETTING_KEY_PK_USERID, old_path, NULL);
else
- gconf_client_unset (prefs.client, KA_GCONF_KEY_PK_USERID, NULL);
+ g_object_set (applet, KA_SETTING_KEY_PK_USERID, old_path, "", NULL);
}
}
static void
-ka_preferences_setup_smartcard_toggle ()
+ka_preferences_setup_smartcard_toggle (KaApplet *applet)
{
char *pkuserid = NULL;
prefs.smartcard_toggle = WID (prefs.builder, "smartcard_toggle");
g_assert (prefs.smartcard_toggle != NULL);
- if (!ka_gconf_get_string (prefs.client, KA_GCONF_KEY_PK_USERID, &pkuserid))
- g_warning ("Getting pkanchors failed");
+ g_object_get(applet, KA_PROP_NAME_PK_USERID, &pkuserid, NULL);
+ if (!pkuserid)
+ g_warning ("Getting pk userid failed");
g_signal_connect (prefs.smartcard_toggle, "toggled",
- G_CALLBACK (ka_preferences_smartcard_toggled), NULL);
+ G_CALLBACK (ka_preferences_smartcard_toggled), applet);
if (!g_strcmp0 (pkuserid, PKINIT_SMARTCARD))
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prefs.smartcard_toggle), TRUE);
@@ -411,267 +368,148 @@ ka_preferences_setup_pkanchors_button ()
}
-
static void
-ka_preferences_forwardable_toggled (GtkToggleButton *toggle,
- gpointer userdata G_GNUC_UNUSED)
+ka_preferences_setup_forwardable_toggle (KaApplet *applet)
{
- gboolean forwardable;
-
- forwardable = gtk_toggle_button_get_active (toggle);
-
- gconf_client_set_bool (prefs.client, KA_GCONF_KEY_FORWARDABLE, forwardable, NULL);
+ GBinding *binding;
+ GtkWidget *toggle;
+
+ toggle = WID (prefs.builder, "forwardable_toggle");
+ g_assert (toggle != NULL);
+
+ binding = g_object_bind_property (applet,
+ KA_PROP_NAME_TGT_FORWARDABLE,
+ toggle,
+ "active",
+ G_BINDING_BIDIRECTIONAL);
+ prefs.bindings[prefs.n_bindings] = binding;
+ prefs.n_bindings++;
}
-
static void
-ka_preferences_forwardable_notify (GConfClient *client G_GNUC_UNUSED,
- guint cnx_id G_GNUC_UNUSED,
- GConfEntry *entry,
- gpointer userdata G_GNUC_UNUSED)
-{
- gboolean forwardable;
-
- if (!entry->value || entry->value->type != GCONF_VALUE_BOOL)
- return;
-
- forwardable = gconf_value_get_bool (entry->value) != FALSE;
-
- if (forwardable != gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (prefs.forwardable_toggle)))
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prefs.forwardable_toggle), forwardable);
-}
-
-
-static gboolean
-ka_preferences_setup_forwardable_toggle ()
+ka_preferences_setup_proxiable_toggle (KaApplet *applet)
{
- gboolean forwardable;
-
- prefs.forwardable_toggle = WID (prefs.builder, "forwardable_toggle");
- g_assert (prefs.forwardable_toggle != NULL);
-
- forwardable = gconf_client_get_bool (prefs.client, KA_GCONF_KEY_FORWARDABLE, NULL);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prefs.forwardable_toggle), forwardable);
-
- g_signal_connect (prefs.forwardable_toggle, "toggled",
- G_CALLBACK (ka_preferences_forwardable_toggled), NULL);
-
- if (!gconf_client_key_is_writable (prefs.client, KA_GCONF_KEY_FORWARDABLE, NULL)) {
- gtk_widget_set_sensitive (prefs.forwardable_toggle, FALSE);
- }
-
- prefs.listeners [prefs.n_listeners] =
- gconf_client_notify_add (prefs.client,
- KA_GCONF_KEY_FORWARDABLE,
- (GConfClientNotifyFunc) ka_preferences_forwardable_notify,
- NULL, NULL, NULL);
- prefs.n_listeners++;
- return forwardable;
+ GBinding *binding;
+ GtkWidget *toggle;
+
+ toggle = WID (prefs.builder, "proxiable_toggle");
+ g_assert (toggle != NULL);
+
+ binding = g_object_bind_property (applet,
+ KA_PROP_NAME_TGT_PROXIABLE,
+ toggle,
+ "active",
+ G_BINDING_BIDIRECTIONAL);
+ prefs.bindings[prefs.n_bindings] = binding;
+ prefs.n_bindings++;
}
-
static void
-ka_preferences_proxiable_toggled (GtkToggleButton *toggle,
- gpointer userdata G_GNUC_UNUSED)
+ka_preferences_setup_renewable_toggle (KaApplet *applet)
{
- gboolean proxiable;
-
- proxiable = gtk_toggle_button_get_active (toggle);
-
- gconf_client_set_bool (prefs.client, KA_GCONF_KEY_PROXIABLE, proxiable, NULL);
-}
-
-
-static void
-ka_preferences_proxiable_notify (GConfClient *client G_GNUC_UNUSED,
- guint cnx_id G_GNUC_UNUSED,
- GConfEntry *entry,
- gpointer userdata G_GNUC_UNUSED)
-{
- gboolean proxiable;
-
- if (!entry->value || entry->value->type != GCONF_VALUE_BOOL)
- return;
-
- proxiable = gconf_value_get_bool (entry->value) != FALSE;
-
- if (proxiable != gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (prefs.proxiable_toggle)))
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prefs.proxiable_toggle), proxiable);
-}
-
-
-static gboolean
-ka_preferences_setup_proxiable_toggle ()
-{
- gboolean proxiable;
-
- prefs.proxiable_toggle = WID (prefs.builder, "proxiable_toggle");
- g_assert (prefs.proxiable_toggle != NULL);
-
- proxiable = gconf_client_get_bool (prefs.client, KA_GCONF_KEY_PROXIABLE, NULL);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prefs.proxiable_toggle), proxiable);
-
- g_signal_connect (prefs.proxiable_toggle, "toggled",
- G_CALLBACK (ka_preferences_proxiable_toggled), NULL);
-
- if (!gconf_client_key_is_writable (prefs.client, KA_GCONF_KEY_PROXIABLE, NULL)) {
- gtk_widget_set_sensitive (prefs.proxiable_toggle, FALSE);
- }
-
- prefs.listeners [prefs.n_listeners] =
- gconf_client_notify_add (prefs.client,
- KA_GCONF_KEY_PROXIABLE,
- (GConfClientNotifyFunc) ka_preferences_proxiable_notify,
- NULL, NULL, NULL);
- prefs.n_listeners++;
- return proxiable;
-}
-
-
-static void
-ka_preferences_renewable_toggled (GtkToggleButton *toggle,
- gpointer userdata G_GNUC_UNUSED)
-{
- gboolean renewable;
-
- renewable = gtk_toggle_button_get_active (toggle);
-
- gconf_client_set_bool (prefs.client, KA_GCONF_KEY_RENEWABLE, renewable, NULL);
-}
-
-
-static void
-ka_preferences_renewable_notify (GConfClient *client G_GNUC_UNUSED,
- guint cnx_id G_GNUC_UNUSED,
- GConfEntry *entry,
- gpointer userdata G_GNUC_UNUSED)
-{
- gboolean renewable;
-
- if (!entry->value || entry->value->type != GCONF_VALUE_BOOL)
- return;
-
- renewable = gconf_value_get_bool (entry->value) != FALSE;
-
- if (renewable != gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (prefs.renewable_toggle)))
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prefs.renewable_toggle), renewable);
-}
-
-
-static gboolean
-ka_preferences_setup_renewable_toggle ()
-{
- gboolean renewable;
-
- prefs.renewable_toggle = WID (prefs.builder, "renewable_toggle");
- g_assert (prefs.renewable_toggle != NULL);
-
- renewable = gconf_client_get_bool (prefs.client, KA_GCONF_KEY_RENEWABLE, NULL);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prefs.renewable_toggle), renewable);
-
- g_signal_connect (prefs.renewable_toggle, "toggled",
- G_CALLBACK (ka_preferences_renewable_toggled), NULL);
-
- if (!gconf_client_key_is_writable (prefs.client, KA_GCONF_KEY_RENEWABLE, NULL)) {
- gtk_widget_set_sensitive (prefs.renewable_toggle, FALSE);
- }
-
- prefs.listeners [prefs.n_listeners] =
- gconf_client_notify_add (prefs.client,
- KA_GCONF_KEY_RENEWABLE,
- (GConfClientNotifyFunc) ka_preferences_renewable_notify,
- NULL, NULL, NULL);
- prefs.n_listeners++;
- return renewable;
+ GBinding *binding;
+ GtkWidget *toggle;
+
+ toggle = WID (prefs.builder, "renewable_toggle");
+ g_assert (toggle != NULL);
+
+ binding = g_object_bind_property (applet,
+ KA_PROP_NAME_TGT_RENEWABLE,
+ toggle,
+ "active",
+ G_BINDING_BIDIRECTIONAL);
+ prefs.bindings[prefs.n_bindings] = binding;
+ prefs.n_bindings++;
}
static void
ka_preferences_prompt_mins_changed (GtkSpinButton *button,
- gpointer userdata G_GNUC_UNUSED)
+ gpointer userdata)
{
gint prompt_mins;
+ KaApplet *applet = KA_APPLET(userdata);
prompt_mins = gtk_spin_button_get_value_as_int (button);
- gconf_client_set_int (prefs.client, KA_GCONF_KEY_PROMPT_MINS, prompt_mins, NULL);
+ g_object_set (applet, KA_PROP_NAME_PW_PROMPT_MINS, prompt_mins, NULL);
}
static void
-ka_preferences_prompt_mins_notify (GConfClient *client G_GNUC_UNUSED,
- guint cnx_id G_GNUC_UNUSED,
- GConfEntry *entry,
+ka_preferences_prompt_mins_notify (GSettings *settings,
+ gchar *key,
gpointer userdata G_GNUC_UNUSED)
{
gint prompt_mins;
- if (!entry->value || entry->value->type != GCONF_VALUE_INT)
- return;
-
- prompt_mins = gconf_value_get_int (entry->value);
-
- if (prompt_mins != gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (prefs.prompt_mins_entry)))
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (prefs.prompt_mins_entry), prompt_mins);
+ prompt_mins = g_settings_get_int (settings, key);
+ if (prompt_mins != gtk_spin_button_get_value_as_int (
+ GTK_SPIN_BUTTON (prefs.prompt_mins_entry)))
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (prefs.prompt_mins_entry),
+ prompt_mins);
}
-
-static gint
-ka_preferences_setup_prompt_mins_entry ()
+static void
+ka_preferences_setup_prompt_mins_entry (KaApplet *applet)
{
gint prompt_mins;
prefs.prompt_mins_entry = WID (prefs.builder, "prompt_mins_entry");
g_assert (prefs.prompt_mins_entry != NULL);
- prompt_mins = gconf_client_get_int (prefs.client, KA_GCONF_KEY_PROMPT_MINS, NULL);
+ g_object_get (applet, KA_PROP_NAME_PW_PROMPT_MINS, &prompt_mins, NULL);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (prefs.prompt_mins_entry), prompt_mins);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (prefs.prompt_mins_entry),
+ prompt_mins);
g_signal_connect (prefs.prompt_mins_entry, "value-changed",
- G_CALLBACK (ka_preferences_prompt_mins_changed), NULL);
+ G_CALLBACK (ka_preferences_prompt_mins_changed), applet);
+}
- if (!gconf_client_key_is_writable (prefs.client, KA_GCONF_KEY_PROMPT_MINS, NULL)) {
- gtk_widget_set_sensitive (prefs.prompt_mins_entry, FALSE);
- }
- prefs.listeners [prefs.n_listeners] =
- gconf_client_notify_add (prefs.client,
- KA_GCONF_KEY_PROMPT_MINS,
- (GConfClientNotifyFunc) ka_preferences_prompt_mins_notify,
- NULL, NULL, NULL);
- prefs.n_listeners++;
- return prompt_mins;
+static void
+ka_preferences_settings_changed (GSettings *settings,
+ gchar *key,
+ gpointer userdata)
+{
+ KaApplet *applet = KA_APPLET (userdata);
+
+ if (!g_strcmp0 (key, KA_SETTING_KEY_PRINCIPAL))
+ ka_preferences_principal_notify (settings, key, applet);
+ else if (!g_strcmp0(key, KA_SETTING_KEY_PK_USERID))
+ ka_preferences_pkuserid_notify (settings, key, applet);
+ else if (!g_strcmp0(key, KA_SETTING_KEY_PK_ANCHORS))
+ ka_preferences_pkanchors_notify (settings, key, applet);
+ else if (!g_strcmp0(key, KA_SETTING_KEY_PW_PROMPT_MINS))
+ ka_preferences_prompt_mins_notify (settings, key, applet);
}
-
void
-ka_preferences_window_create (KaApplet *applet G_GNUC_UNUSED,
+ka_preferences_window_create (KaApplet *applet,
GtkBuilder *xml)
{
- prefs.client = gconf_client_get_default ();
- gconf_client_add_dir (prefs.client, KA_GCONF_PATH,
- GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
-
prefs.builder = xml;
- ka_preferences_setup_principal_entry (prefs);
- ka_preferences_setup_pkuserid_entry (prefs);
- ka_preferences_setup_pkuserid_button (prefs);
- ka_preferences_setup_smartcard_toggle (prefs);
- ka_preferences_setup_pkanchors_entry(prefs);
- ka_preferences_setup_pkanchors_button (prefs);
- ka_preferences_setup_forwardable_toggle (prefs);
- ka_preferences_setup_proxiable_toggle (prefs);
- ka_preferences_setup_renewable_toggle (prefs);
- ka_preferences_setup_prompt_mins_entry (prefs);
-
- g_assert (prefs.n_listeners == N_LISTENERS);
+ ka_preferences_setup_principal_entry (applet);
+ ka_preferences_setup_pkuserid_entry (applet);
+ ka_preferences_setup_pkuserid_button (applet);
+ ka_preferences_setup_smartcard_toggle (applet);
+ ka_preferences_setup_pkanchors_entry (applet);
+ ka_preferences_setup_pkanchors_button (applet);
+
+ ka_preferences_setup_forwardable_toggle (applet);
+ ka_preferences_setup_proxiable_toggle (applet);
+ ka_preferences_setup_renewable_toggle (applet);
+ ka_preferences_setup_prompt_mins_entry (applet);
+
+ g_signal_connect (ka_applet_get_settings(applet),
+ "changed",
+ G_CALLBACK (ka_preferences_settings_changed),
+ applet);
+
+ g_assert (prefs.n_bindings == N_BINDINGS);
prefs.notebook = WID (xml, "ka_notebook");
prefs.dialog = WID (xml, "krb5_preferences_dialog");
-
}
void
@@ -684,6 +522,15 @@ ka_preferences_window_show (GtkWindow *main_window)
gtk_widget_hide (prefs.dialog);
}
+void
+ka_preferences_window_destroy ()
+{
+ int i;
+
+ for (i = 0; i < prefs.n_bindings; i++)
+ g_object_unref (prefs.bindings[i]);
+}
+
/*
* vim:ts:sts=4:sw=4:et:
*/
diff --git a/src/ka-preferences.h b/src/ka-preferences.h
index 7f8e9a2..d7facb6 100644
--- a/src/ka-preferences.h
+++ b/src/ka-preferences.h
@@ -10,8 +10,10 @@
G_BEGIN_DECLS
void ka_preferences_window_create (KaApplet *applet, GtkBuilder *xml);
+void ka_preferences_window_destroy (void);
void ka_preferences_window_show (GtkWindow *main_window);
+
G_END_DECLS
#endif /* KA_PREFERENCES */
diff --git a/src/ka-settings.c b/src/ka-settings.c
new file mode 100644
index 0000000..d93d30d
--- /dev/null
+++ b/src/ka-settings.c
@@ -0,0 +1,58 @@
+/* Krb5 Auth Applet -- Acquire and release kerberos tickets
+ *
+ * (C) 2008,2009,2013 Guido Guenther <agx sigxcpu org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+#include "config.h"
+
+#include <string.h>
+
+#include "ka-applet-priv.h"
+#include "ka-settings.h"
+
+#define do_binding(NAME) \
+ g_settings_bind(settings, \
+ KA_SETTING_KEY_##NAME,\
+ applet, \
+ KA_PROP_NAME_##NAME, \
+ G_SETTINGS_BIND_DEFAULT)
+
+static void
+ka_setup_bindings(KaApplet* applet,
+ GSettings* settings)
+{
+ do_binding(PRINCIPAL);
+ do_binding(PK_USERID);
+ do_binding(PK_ANCHORS);
+ do_binding(PW_PROMPT_MINS);
+ do_binding(TGT_FORWARDABLE);
+ do_binding(TGT_PROXIABLE);
+ do_binding(TGT_RENEWABLE);
+}
+
+#undef do_binding
+
+GSettings*
+ka_settings_init (KaApplet* applet)
+{
+ GSettings *settings;
+
+ settings = g_settings_new (KA_SETTING_SCHEMA);
+
+ ka_setup_bindings(applet, settings);
+ return settings;
+}
diff --git a/src/ka-settings.h b/src/ka-settings.h
new file mode 100644
index 0000000..bbdd5fe
--- /dev/null
+++ b/src/ka-settings.h
@@ -0,0 +1,43 @@
+/* Krb5 Auth Applet -- Acquire and release kerberos tickets
+ *
+ * (C) 2008 Guido Guenther <agx sigxcpu org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef KA_GCONF_H
+#define KA_GCONF_H
+
+#include "ka-applet-priv.h"
+
+#define KA_SETTING_SCHEMA "org.gnome.KrbAuthDialog"
+#define KA_SETTING_KEY_PRINCIPAL "principal"
+#define KA_SETTING_KEY_PK_USERID "pk-userid"
+#define KA_SETTING_KEY_PK_ANCHORS "pk-anchors"
+#define KA_SETTING_KEY_PW_PROMPT_MINS "prompt-minutes"
+#define KA_SETTING_KEY_TGT_FORWARDABLE "forwardable"
+#define KA_SETTING_KEY_TGT_RENEWABLE "renewable"
+#define KA_SETTING_KEY_TGT_PROXIABLE "proxiable"
+#define KA_SETTING_CHILD_NOTIFY "notify"
+#define KA_SETTING_KEY_NOTIFY_VALID "valid"
+#define KA_SETTING_KEY_NOTIFY_EXPIRED "expired"
+#define KA_SETTING_KEY_NOTIFY_EXPIRING "expiring"
+#define KA_SETTING_CHILD_PLUGINS "plugins"
+#define KA_SETTING_KEY_PLUGINS_ENABLED "enabled"
+
+GSettings* ka_settings_init (KaApplet* applet);
+
+#endif
diff --git a/src/org.gnome.KrbAuthDialog.convert b/src/org.gnome.KrbAuthDialog.convert
new file mode 100644
index 0000000..f71168e
--- /dev/null
+++ b/src/org.gnome.KrbAuthDialog.convert
@@ -0,0 +1,13 @@
+[org.gnome.KrbAuthDialog]
+principal = /apps/krb5-auth-dialog/principal
+pk-userid = /apps/krb5-auth-dialog/pk_userid
+pk-anchors = /apps/krb5-auth-dialog/pk_anchors
+prompt-minutes = /apps/krb5-auth-dialog/prompt_minutes
+
+[org.gnome.KrbAuthDialog.notify]
+valid = /apps/krb5-auth-dialog/notify/valid
+expiring = /apps/krb5-auth-dialog/notify/expiring
+expired = /apps/krb5-auth-dialog/notify/expired
+
+[org.gnome.KrbAuthDialog.plugins]
+enabled = /apps/krb5-auth-dialog/plugins/enabled
diff --git a/src/org.gnome.KrbAuthDialog.gschema.xml b/src/org.gnome.KrbAuthDialog.gschema.xml
new file mode 100644
index 0000000..c63d7db
--- /dev/null
+++ b/src/org.gnome.KrbAuthDialog.gschema.xml
@@ -0,0 +1,65 @@
+<schemalist>
+ <schema id="org.gnome.KrbAuthDialog" path="/apps/krb5-auth-dialog/">
+ <key name="principal" type="s">
+ <default>''</default>
+ <summary>Kerberos principal</summary>
+ <description>The Kerberos principal to acquire the ticket for</description>
+ </key>
+ <key name="pk-userid" type="s">
+ <default>''</default>
+ <summary>PKINIT identifier</summary>
+ <description>The principal's public/private/certificate identifier when using PKINIT</description>
+ </key>
+ <key name="pk-anchors" type="s">
+ <default>''</default>
+ <summary>PKINIT trust anchors</summary>
+ <description>PKINIT CA certificates</description>
+ </key>
+ <key name="prompt-minutes" type="i">
+ <default>30</default>
+ <summary>Prompt minutes before expiry</summary>
+ <description>Start prompting/displaying notifications that many minutes before expiry</description>
+ </key>
+ <key name="forwardable" type="b">
+ <default>false</default>
+ <summary>Forwardable ticket</summary>
+ <description>Requested tickets should be forwardable</description>
+ </key>
+ <key name="renewable" type="b">
+ <default>false</default>
+ <summary>Renewable ticket</summary>
+ <description>Requested tickets should be renewable</description>
+ </key>
+ <key name="proxiable" type="b">
+ <default>false</default>
+ <summary>Proxiable ticket</summary>
+ <description>Requested tickets should be proxiable</description>
+ </key>
+ <child name="notify" schema="org.gnome.KrbAuthDialog.notify"/>
+ <child name="plugins" schema="org.gnome.KrbAuthDialog.plugins"/>
+ </schema>
+ <schema id="org.gnome.KrbAuthDialog.notify" path="/apps/krb5-auth-dialog/notify/">
+ <key name="valid" type="b">
+ <default>true</default>
+ <summary>valid ticket notification</summary>
+ <description>Notify user when ticket becomes valid</description>
+ </key>
+ <key name="expiring" type="b">
+ <default>true</default>
+ <summary>ticket expiring notification</summary>
+ <description>Notify user when ticket is about to expire</description>
+ </key>
+ <key name="expired" type="b">
+ <default>true</default>
+ <summary>ticket expired notification</summary>
+ <description>Notify user when ticket has expired</description>
+ </key>
+ </schema>
+ <schema id="org.gnome.KrbAuthDialog.plugins" path="/apps/krb5-auth-dialog/plugins/">
+ <key name="enabled" type="as">
+ <default>[]</default>
+ <summary>Enabled plugins</summary>
+ <description>List of plugins that should be loaded and activated on startup.</description>
+ </key>
+ </schema>
+</schemalist>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]