aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2011-02-14 21:00:53 +0100
committerGuido Günther <agx@sigxcpu.org>2011-02-14 21:00:53 +0100
commitc646d52761bf59f014b9c385d15309880cc5309c (patch)
tree7bb2fa05f721ca1d6263c9b33c3a8e1488d902fd /src
parentNew upstream version 0.17 (diff)
downloadkrb5-auth-dialog-c646d52761bf59f014b9c385d15309880cc5309c.tar.gz
krb5-auth-dialog-c646d52761bf59f014b9c385d15309880cc5309c.tar.bz2
krb5-auth-dialog-c646d52761bf59f014b9c385d15309880cc5309c.zip
New upstream version 2.91.6
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am9
-rw-r--r--src/Makefile.in96
-rw-r--r--src/ka-applet-priv.h40
-rw-r--r--src/ka-applet.c1448
-rw-r--r--src/ka-dialog.c121
-rw-r--r--src/ka-entry-buffer.c229
-rw-r--r--src/ka-entry-buffer.h58
-rw-r--r--src/ka-gconf.c16
-rw-r--r--src/ka-pwdialog.c18
-rw-r--r--src/ka-pwdialog.h2
-rw-r--r--src/krb5-auth-dialog.desktop.in4
-rw-r--r--src/krb5-auth-dialog.schemas.in13
-rw-r--r--src/krb5-auth-dialog.xml4
13 files changed, 1200 insertions, 858 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 591c69f..1c89d31 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -8,6 +8,10 @@ autostart_in_files = krb5-auth-dialog.desktop.in
autostart_DATA = $(autostart_in_files:.desktop.in=.desktop)
@INTLTOOL_DESKTOP_RULE@
+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)
@@ -44,11 +48,12 @@ krb5_auth_dialog_SOURCES = \
ka-plugin-loader.h \
ka-closures.h \
ka-closures.c \
+ ka-entry-buffer.h \
+ ka-entry-buffer.c \
dummy-strings.c \
$(NULL)
krb5_auth_dialog_CPPFLAGS = \
- -I$(top_srcdir)/gtksecentry \
-I$(top_srcdir)/secmem \
-DKA_DATA_DIR=\""$(pkgdatadir)"\" \
-DDATA_DIR=\""$(datadir)"\" \
@@ -71,7 +76,6 @@ krb5_auth_dialog_CFLAGS = \
$(NULL)
krb5_auth_dialog_LDADD = \
- $(top_builddir)/gtksecentry/libgtksecentry.a \
$(top_builddir)/secmem/libsecmem.a \
$(NETWORK_MANAGER_LIBS) \
$(LIBCAP) \
@@ -95,7 +99,6 @@ ka-dbus-glue.h: $(srcdir)/ka-dbus.xml
$< > $@
AM_CPPFLAGS = \
- -I $(top_srcdir)/gtksecentry/ \
-I $(top_srcdir)/secmem/ \
$(DISABLE_DEPRECATED) \
$(NULL)
diff --git a/src/Makefile.in b/src/Makefile.in
index 0162189..612e7c4 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -49,8 +49,9 @@ CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES = krb5-auth-dialog.1
CONFIG_CLEAN_VPATH_FILES =
am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" \
- "$(DESTDIR)$(autostartdir)" "$(DESTDIR)$(pkgdatadir)" \
- "$(DESTDIR)$(schemadir)" "$(DESTDIR)$(servicedir)"
+ "$(DESTDIR)$(autostartdir)" "$(DESTDIR)$(desktopdir)" \
+ "$(DESTDIR)$(pkgdatadir)" "$(DESTDIR)$(schemadir)" \
+ "$(DESTDIR)$(servicedir)"
PROGRAMS = $(bin_PROGRAMS)
am__objects_1 =
am_krb5_auth_dialog_OBJECTS = krb5_auth_dialog-ka-dialog.$(OBJEXT) \
@@ -64,17 +65,16 @@ am_krb5_auth_dialog_OBJECTS = krb5_auth_dialog-ka-dialog.$(OBJEXT) \
krb5_auth_dialog-ka-plugin.$(OBJEXT) \
krb5_auth_dialog-ka-plugin-loader.$(OBJEXT) \
krb5_auth_dialog-ka-closures.$(OBJEXT) \
+ krb5_auth_dialog-ka-entry-buffer.$(OBJEXT) \
krb5_auth_dialog-dummy-strings.$(OBJEXT) $(am__objects_1)
krb5_auth_dialog_OBJECTS = $(am_krb5_auth_dialog_OBJECTS)
am__DEPENDENCIES_1 =
-krb5_auth_dialog_DEPENDENCIES = \
- $(top_builddir)/gtksecentry/libgtksecentry.a \
- $(top_builddir)/secmem/libsecmem.a $(am__DEPENDENCIES_1) \
+krb5_auth_dialog_DEPENDENCIES = $(top_builddir)/secmem/libsecmem.a \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
AM_V_lt = $(am__v_lt_$(V))
am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
am__v_lt_0 = --silent
@@ -134,8 +134,8 @@ am__base_list = \
man1dir = $(mandir)/man1
NROFF = nroff
MANS = $(man_MANS)
-DATA = $(autostart_DATA) $(pkgdata_DATA) $(schema_DATA) \
- $(service_DATA)
+DATA = $(autostart_DATA) $(desktop_DATA) $(pkgdata_DATA) \
+ $(schema_DATA) $(service_DATA)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -155,6 +155,8 @@ CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
COMPILER_FLAGS = @COMPILER_FLAGS@
+CONTROL_CENTER_CFLAGS = @CONTROL_CENTER_CFLAGS@
+CONTROL_CENTER_LIBS = @CONTROL_CENTER_LIBS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
@@ -242,6 +244,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PAM_LIBS = @PAM_LIBS@
+PANELS_DIR = @PANELS_DIR@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
@@ -323,6 +326,9 @@ man_MANS = krb5-auth-dialog.1
autostartdir = $(sysconfdir)/xdg/autostart
autostart_in_files = krb5-auth-dialog.desktop.in
autostart_DATA = $(autostart_in_files:.desktop.in=.desktop)
+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)
@@ -353,11 +359,12 @@ krb5_auth_dialog_SOURCES = \
ka-plugin-loader.h \
ka-closures.h \
ka-closures.c \
+ ka-entry-buffer.h \
+ ka-entry-buffer.c \
dummy-strings.c \
$(NULL)
krb5_auth_dialog_CPPFLAGS = \
- -I$(top_srcdir)/gtksecentry \
-I$(top_srcdir)/secmem \
-DKA_DATA_DIR=\""$(pkgdatadir)"\" \
-DDATA_DIR=\""$(datadir)"\" \
@@ -380,7 +387,6 @@ krb5_auth_dialog_CFLAGS = \
$(NULL)
krb5_auth_dialog_LDADD = \
- $(top_builddir)/gtksecentry/libgtksecentry.a \
$(top_builddir)/secmem/libsecmem.a \
$(NETWORK_MANAGER_LIBS) \
$(LIBCAP) \
@@ -398,7 +404,6 @@ BUILT_SOURCES = \
$(NULL)
AM_CPPFLAGS = \
- -I $(top_srcdir)/gtksecentry/ \
-I $(top_srcdir)/secmem/ \
$(DISABLE_DEPRECATED) \
$(NULL)
@@ -517,6 +522,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/krb5_auth_dialog-ka-closures.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/krb5_auth_dialog-ka-dbus.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/krb5_auth_dialog-ka-dialog.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/krb5_auth_dialog-ka-entry-buffer.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/krb5_auth_dialog-ka-gconf-tools.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/krb5_auth_dialog-ka-gconf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/krb5_auth_dialog-ka-plugin-loader.Po@am__quote@
@@ -725,6 +731,22 @@ krb5_auth_dialog-ka-closures.obj: ka-closures.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(krb5_auth_dialog_CPPFLAGS) $(CPPFLAGS) $(krb5_auth_dialog_CFLAGS) $(CFLAGS) -c -o krb5_auth_dialog-ka-closures.obj `if test -f 'ka-closures.c'; then $(CYGPATH_W) 'ka-closures.c'; else $(CYGPATH_W) '$(srcdir)/ka-closures.c'; fi`
+krb5_auth_dialog-ka-entry-buffer.o: ka-entry-buffer.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(krb5_auth_dialog_CPPFLAGS) $(CPPFLAGS) $(krb5_auth_dialog_CFLAGS) $(CFLAGS) -MT krb5_auth_dialog-ka-entry-buffer.o -MD -MP -MF $(DEPDIR)/krb5_auth_dialog-ka-entry-buffer.Tpo -c -o krb5_auth_dialog-ka-entry-buffer.o `test -f 'ka-entry-buffer.c' || echo '$(srcdir)/'`ka-entry-buffer.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/krb5_auth_dialog-ka-entry-buffer.Tpo $(DEPDIR)/krb5_auth_dialog-ka-entry-buffer.Po
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ka-entry-buffer.c' object='krb5_auth_dialog-ka-entry-buffer.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(krb5_auth_dialog_CPPFLAGS) $(CPPFLAGS) $(krb5_auth_dialog_CFLAGS) $(CFLAGS) -c -o krb5_auth_dialog-ka-entry-buffer.o `test -f 'ka-entry-buffer.c' || echo '$(srcdir)/'`ka-entry-buffer.c
+
+krb5_auth_dialog-ka-entry-buffer.obj: ka-entry-buffer.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(krb5_auth_dialog_CPPFLAGS) $(CPPFLAGS) $(krb5_auth_dialog_CFLAGS) $(CFLAGS) -MT krb5_auth_dialog-ka-entry-buffer.obj -MD -MP -MF $(DEPDIR)/krb5_auth_dialog-ka-entry-buffer.Tpo -c -o krb5_auth_dialog-ka-entry-buffer.obj `if test -f 'ka-entry-buffer.c'; then $(CYGPATH_W) 'ka-entry-buffer.c'; else $(CYGPATH_W) '$(srcdir)/ka-entry-buffer.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/krb5_auth_dialog-ka-entry-buffer.Tpo $(DEPDIR)/krb5_auth_dialog-ka-entry-buffer.Po
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ka-entry-buffer.c' object='krb5_auth_dialog-ka-entry-buffer.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(krb5_auth_dialog_CPPFLAGS) $(CPPFLAGS) $(krb5_auth_dialog_CFLAGS) $(CFLAGS) -c -o krb5_auth_dialog-ka-entry-buffer.obj `if test -f 'ka-entry-buffer.c'; then $(CYGPATH_W) 'ka-entry-buffer.c'; else $(CYGPATH_W) '$(srcdir)/ka-entry-buffer.c'; fi`
+
krb5_auth_dialog-dummy-strings.o: dummy-strings.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(krb5_auth_dialog_CPPFLAGS) $(CPPFLAGS) $(krb5_auth_dialog_CFLAGS) $(CFLAGS) -MT krb5_auth_dialog-dummy-strings.o -MD -MP -MF $(DEPDIR)/krb5_auth_dialog-dummy-strings.Tpo -c -o krb5_auth_dialog-dummy-strings.o `test -f 'dummy-strings.c' || echo '$(srcdir)/'`dummy-strings.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/krb5_auth_dialog-dummy-strings.Tpo $(DEPDIR)/krb5_auth_dialog-dummy-strings.Po
@@ -804,6 +826,26 @@ uninstall-autostartDATA:
test -n "$$files" || exit 0; \
echo " ( cd '$(DESTDIR)$(autostartdir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(autostartdir)" && rm -f $$files
+install-desktopDATA: $(desktop_DATA)
+ @$(NORMAL_INSTALL)
+ test -z "$(desktopdir)" || $(MKDIR_P) "$(DESTDIR)$(desktopdir)"
+ @list='$(desktop_DATA)'; test -n "$(desktopdir)" || list=; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(desktopdir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(desktopdir)" || exit $$?; \
+ done
+
+uninstall-desktopDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(desktop_DATA)'; test -n "$(desktopdir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ test -n "$$files" || exit 0; \
+ echo " ( cd '$(DESTDIR)$(desktopdir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(desktopdir)" && rm -f $$files
install-pkgdataDATA: $(pkgdata_DATA)
@$(NORMAL_INSTALL)
test -z "$(pkgdatadir)" || $(MKDIR_P) "$(DESTDIR)$(pkgdatadir)"
@@ -965,7 +1007,7 @@ check: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) check-am
all-am: Makefile $(PROGRAMS) $(MANS) $(DATA)
installdirs:
- for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(autostartdir)" "$(DESTDIR)$(pkgdatadir)" "$(DESTDIR)$(schemadir)" "$(DESTDIR)$(servicedir)"; do \
+ for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(autostartdir)" "$(DESTDIR)$(desktopdir)" "$(DESTDIR)$(pkgdatadir)" "$(DESTDIR)$(schemadir)" "$(DESTDIR)$(servicedir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: $(BUILT_SOURCES)
@@ -1019,8 +1061,9 @@ info: info-am
info-am:
-install-data-am: install-autostartDATA install-data-local install-man \
- install-pkgdataDATA install-schemaDATA install-serviceDATA
+install-data-am: install-autostartDATA install-data-local \
+ install-desktopDATA install-man install-pkgdataDATA \
+ install-schemaDATA install-serviceDATA
install-dvi: install-dvi-am
@@ -1067,8 +1110,8 @@ ps: ps-am
ps-am:
uninstall-am: uninstall-autostartDATA uninstall-binPROGRAMS \
- uninstall-man uninstall-pkgdataDATA uninstall-schemaDATA \
- uninstall-serviceDATA
+ uninstall-desktopDATA uninstall-man uninstall-pkgdataDATA \
+ uninstall-schemaDATA uninstall-serviceDATA
uninstall-man: uninstall-man1
@@ -1079,16 +1122,17 @@ uninstall-man: uninstall-man1
distclean-generic distclean-libtool distclean-tags distdir dvi \
dvi-am html html-am info info-am install install-am \
install-autostartDATA install-binPROGRAMS install-data \
- install-data-am install-data-local install-dvi install-dvi-am \
- install-exec install-exec-am install-html install-html-am \
- install-info install-info-am install-man install-man1 \
- install-pdf install-pdf-am install-pkgdataDATA install-ps \
- install-ps-am install-schemaDATA install-serviceDATA \
- install-strip installcheck installcheck-am installdirs \
- maintainer-clean maintainer-clean-generic mostlyclean \
- mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
- pdf pdf-am ps ps-am tags uninstall uninstall-am \
- uninstall-autostartDATA uninstall-binPROGRAMS uninstall-man \
+ install-data-am install-data-local install-desktopDATA \
+ install-dvi install-dvi-am install-exec install-exec-am \
+ install-html install-html-am install-info install-info-am \
+ install-man install-man1 install-pdf install-pdf-am \
+ install-pkgdataDATA install-ps install-ps-am \
+ install-schemaDATA install-serviceDATA install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-autostartDATA \
+ uninstall-binPROGRAMS uninstall-desktopDATA uninstall-man \
uninstall-man1 uninstall-pkgdataDATA uninstall-schemaDATA \
uninstall-serviceDATA
diff --git a/src/ka-applet-priv.h b/src/ka-applet-priv.h
index 7e240a7..a64848c 100644
--- a/src/ka-applet-priv.h
+++ b/src/ka-applet-priv.h
@@ -1,6 +1,6 @@
/* Krb5 Auth Applet -- Acquire and release kerberos tickets
*
- * (C) 2008,2010 Guido Guenther <agx@sigxcpu.org>
+ * (C) 2008,2010,2011 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
@@ -33,34 +33,33 @@
#include "ka-pwdialog.h"
G_BEGIN_DECLS
-
-#define KA_NAME _("Network Authentication")
-
+#define KA_NAME _("Kerberos Authentication")
/* signals emitted by KaApplet */
-typedef enum {
- KA_SIGNAL_ACQUIRED_TGT, /* New TGT acquired */
- KA_SIGNAL_RENEWED_TGT, /* TGT got renewed */
- KA_SIGNAL_EXPIRED_TGT, /* TGT expired or ticket cache got destroyed */
- KA_SIGNAL_COUNT
+ typedef enum {
+ KA_SIGNAL_ACQUIRED_TGT, /* New TGT acquired */
+ KA_SIGNAL_RENEWED_TGT, /* TGT got renewed */
+ KA_SIGNAL_EXPIRED_TGT, /* TGT expired or ticket cache got destroyed */
+ KA_SIGNAL_COUNT
} KaAppletSignalNumber;
/* public functions */
-gboolean ka_applet_get_show_trayicon(const KaApplet* applet);
-void ka_applet_set_tgt_renewable(KaApplet* applet, gboolean renewable);
-gboolean ka_applet_get_tgt_renewable(const KaApplet* applet);
-guint ka_applet_get_pw_prompt_secs(const KaApplet* applet);
-KaPwDialog* ka_applet_get_pwdialog(const KaApplet* applet);
-GConfClient* ka_applet_get_gconf_client(const KaApplet* applet);
-void ka_applet_signal_emit(KaApplet* applet, KaAppletSignalNumber signum,
- krb5_timestamp expiry);
+gboolean ka_applet_get_show_trayicon (const KaApplet *self);
+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);
+void ka_applet_signal_emit (KaApplet *self, KaAppletSignalNumber signum,
+ krb5_timestamp expiry);
+void ka_applet_set_msg (KaApplet *self, const char *msg);
/* create the applet */
-KaApplet* ka_applet_create(void);
+KaApplet *ka_applet_create (void);
+
/* update tooltip and icon */
-int ka_applet_update_status(KaApplet* applet, krb5_timestamp expiry);
+int ka_applet_update_status (KaApplet *self, krb5_timestamp expiry);
G_END_DECLS
-
#ifdef ENABLE_DEBUG
#define KA_DEBUG(fmt,...) \
g_printf ("DEBUG: %s: " fmt "\n", __func__, ##__VA_ARGS__)
@@ -68,5 +67,4 @@ G_END_DECLS
#define KA_DEBUG(fmt,...) \
do { } while (0)
#endif /* !ENABLE_DEBUG */
-
#endif
diff --git a/src/ka-applet.c b/src/ka-applet.c
index 9beafd1..b2b2823 100644
--- a/src/ka-applet.c
+++ b/src/ka-applet.c
@@ -30,922 +30,984 @@
#include "ka-tickets.h"
#include "ka-plugin-loader.h"
#include "ka-closures.h"
-#ifdef HAVE_LIBNOTIFY
#include <libnotify/notify.h>
-#endif
#define NOTIFY_SECONDS 300
enum ka_icon {
- inv_icon = 0,
- exp_icon,
- val_icon,
+ inv_icon = 0,
+ exp_icon,
+ val_icon,
};
-enum
-{
- KA_PROP_0 = 0,
- KA_PROP_PRINCIPAL,
- KA_PROP_PK_USERID,
- KA_PROP_PK_ANCHORS,
- KA_PROP_TRAYICON,
- KA_PROP_PW_PROMPT_MINS,
- KA_PROP_TGT_FORWARDABLE,
- KA_PROP_TGT_PROXIABLE,
- KA_PROP_TGT_RENEWABLE,
+enum {
+ KA_PROP_0 = 0,
+ KA_PROP_PRINCIPAL,
+ KA_PROP_PK_USERID,
+ KA_PROP_PK_ANCHORS,
+ KA_PROP_PW_PROMPT_MINS,
+ KA_PROP_TGT_FORWARDABLE,
+ KA_PROP_TGT_PROXIABLE,
+ KA_PROP_TGT_RENEWABLE,
};
struct _KaApplet {
- GObject parent;
+ GObject parent;
- KaAppletPrivate *priv;
+ KaAppletPrivate *priv;
};
struct _KaAppletClass {
- GObjectClass parent;
+ GObjectClass parent;
- guint signals [KA_SIGNAL_COUNT];
+ guint signals[KA_SIGNAL_COUNT];
};
-G_DEFINE_TYPE(KaApplet, ka_applet, G_TYPE_OBJECT);
-
-struct _KaAppletPrivate
-{
- GtkBuilder *uixml;
- GtkStatusIcon* tray_icon; /* the tray icon */
- GtkWidget* context_menu; /* the tray icon's context menu */
- const char* icons[3]; /* for invalid, expiring and valid tickts */
- gboolean show_trayicon; /* show the trayicon */
-
- KaPwDialog *pwdialog; /* the password dialog */
- int pw_prompt_secs; /* when to start prompting for a password */
- KaPluginLoader *loader; /* Plugin loader */
-
-#ifdef HAVE_LIBNOTIFY
- NotifyNotification* notification;/* notification messages */
-#endif /* HAVE_LIBNOTIFY */
- const char* notify_gconf_key; /* disable notification gconf key */
- char* principal; /* the principal to request */
- gboolean renewable; /* credentials renewable? */
- char* pk_userid; /* "userid" for pkint */
- char* pk_anchors; /* trust anchors for pkint */
- gboolean tgt_forwardable; /* request a forwardable ticket */
- gboolean tgt_renewable; /* request a renewable ticket */
- gboolean tgt_proxiable; /* request a proxiable ticket */
-
- GConfClient *gconf; /* gconf client */
+G_DEFINE_TYPE (KaApplet, ka_applet, G_TYPE_OBJECT);
+
+struct _KaAppletPrivate {
+ GtkBuilder *uixml;
+ GtkStatusIcon *tray_icon; /* the tray icon */
+ GtkWidget *context_menu; /* the tray icon's context menu */
+ const char *icons[3]; /* for invalid, expiring and valid tickts */
+ gboolean ns_persistence; /* does the notification server support persistence */
+
+ KaPwDialog *pwdialog; /* the password dialog */
+ int pw_prompt_secs; /* when to start prompting for a password */
+ KaPluginLoader *loader; /* Plugin loader */
+
+ NotifyNotification *notification; /* notification messages */
+ char *krb_msg; /* Additional banner delivered by Kerberos */
+ const char *notify_gconf_key; /* disable notification gconf key */
+ char *principal; /* the principal to request */
+ gboolean renewable; /* credentials renewable? */
+ char *pk_userid; /* "userid" for pkint */
+ char *pk_anchors; /* trust anchors for pkint */
+ gboolean tgt_forwardable; /* request a forwardable ticket */
+ gboolean tgt_renewable; /* request a renewable ticket */
+ gboolean tgt_proxiable; /* request a proxiable ticket */
+
+ GConfClient *gconf; /* gconf client */
};
+static void ka_close_notification (KaApplet *self);
+
static void
-ka_applet_set_property (GObject *object,
- guint property_id,
+ka_applet_set_property (GObject *object,
+ guint property_id,
const GValue *value,
- GParamSpec *pspec)
+ GParamSpec *pspec)
{
- KaApplet* self = KA_APPLET (object);
+ KaApplet *self = KA_APPLET (object);
- switch (property_id) {
+ switch (property_id) {
case KA_PROP_PRINCIPAL:
- g_free (self->priv->principal);
- self->priv->principal = g_value_dup_string (value);
- KA_DEBUG ("%s: %s", pspec->name, self->priv->principal);
- break;
-
- case KA_PROP_PK_USERID:
- g_free (self->priv->pk_userid);
- self->priv->pk_userid = g_value_dup_string (value);
- KA_DEBUG ("%s: %s", pspec->name, self->priv->pk_userid);
- break;
-
- case KA_PROP_PK_ANCHORS:
- g_free (self->priv->pk_anchors);
- self->priv->pk_anchors = g_value_dup_string (value);
- KA_DEBUG ("%s: %s", pspec->name, self->priv->pk_anchors);
- break;
-
- case KA_PROP_TRAYICON:
- self->priv->show_trayicon = g_value_get_boolean (value);
- KA_DEBUG ("%s: %s", pspec->name, self->priv->show_trayicon ? "True" : "False");
- break;
+ g_free (self->priv->principal);
+ self->priv->principal = g_value_dup_string (value);
+ KA_DEBUG ("%s: %s", pspec->name, self->priv->principal);
+ break;
+
+ case KA_PROP_PK_USERID:
+ g_free (self->priv->pk_userid);
+ self->priv->pk_userid = g_value_dup_string (value);
+ KA_DEBUG ("%s: %s", pspec->name, self->priv->pk_userid);
+ break;
+
+ case KA_PROP_PK_ANCHORS:
+ g_free (self->priv->pk_anchors);
+ self->priv->pk_anchors = g_value_dup_string (value);
+ KA_DEBUG ("%s: %s", pspec->name, self->priv->pk_anchors);
+ break;
case KA_PROP_PW_PROMPT_MINS:
- self->priv->pw_prompt_secs = g_value_get_uint (value) * 60;
- KA_DEBUG ("%s: %d", pspec->name, self->priv->pw_prompt_secs/60);
- break;
+ self->priv->pw_prompt_secs = g_value_get_uint (value) * 60;
+ KA_DEBUG ("%s: %d", pspec->name, self->priv->pw_prompt_secs / 60);
+ break;
case KA_PROP_TGT_FORWARDABLE:
- self->priv->tgt_forwardable = g_value_get_boolean (value);
- KA_DEBUG ("%s: %s", pspec->name, self->priv->tgt_forwardable ? "True" : "False");
- break;
+ self->priv->tgt_forwardable = g_value_get_boolean (value);
+ KA_DEBUG ("%s: %s", pspec->name,
+ self->priv->tgt_forwardable ? "True" : "False");
+ break;
case KA_PROP_TGT_PROXIABLE:
- self->priv->tgt_proxiable = g_value_get_boolean (value);
- KA_DEBUG ("%s: %s", pspec->name, self->priv->tgt_proxiable ? "True" : "False");
- break;
+ self->priv->tgt_proxiable = g_value_get_boolean (value);
+ KA_DEBUG ("%s: %s", pspec->name,
+ self->priv->tgt_proxiable ? "True" : "False");
+ break;
case KA_PROP_TGT_RENEWABLE:
- self->priv->tgt_renewable = g_value_get_boolean (value);
- KA_DEBUG ("%s: %s", pspec->name, self->priv->tgt_renewable ? "True" : "False");
- break;
+ self->priv->tgt_renewable = g_value_get_boolean (value);
+ KA_DEBUG ("%s: %s", pspec->name,
+ self->priv->tgt_renewable ? "True" : "False");
+ break;
default:
- /* We don't have any other property... */
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
}
}
static void
-ka_applet_get_property (GObject *object,
- guint property_id,
- GValue *value,
+ka_applet_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
GParamSpec *pspec)
{
- KaApplet *self = KA_APPLET (object);
+ KaApplet *self = KA_APPLET (object);
- switch (property_id)
- {
+ switch (property_id) {
case KA_PROP_PRINCIPAL:
- g_value_set_string (value, self->priv->principal);
- break;
+ g_value_set_string (value, self->priv->principal);
+ break;
case KA_PROP_PK_USERID:
- g_value_set_string (value, self->priv->pk_userid);
- break;
+ g_value_set_string (value, self->priv->pk_userid);
+ break;
case KA_PROP_PK_ANCHORS:
- g_value_set_string (value, self->priv->pk_anchors);
- break;
-
- case KA_PROP_TRAYICON:
- g_value_set_boolean (value, self->priv->show_trayicon);
- break;
+ g_value_set_string (value, self->priv->pk_anchors);
+ break;
case KA_PROP_PW_PROMPT_MINS:
- g_value_set_uint (value, self->priv->pw_prompt_secs / 60);
- break;
+ g_value_set_uint (value, self->priv->pw_prompt_secs / 60);
+ break;
case KA_PROP_TGT_FORWARDABLE:
- g_value_set_boolean (value, self->priv->tgt_forwardable);
- break;
+ g_value_set_boolean (value, self->priv->tgt_forwardable);
+ break;
case KA_PROP_TGT_PROXIABLE:
- g_value_set_boolean (value, self->priv->tgt_proxiable);
- break;
+ g_value_set_boolean (value, self->priv->tgt_proxiable);
+ break;
case KA_PROP_TGT_RENEWABLE:
- g_value_set_boolean (value, self->priv->tgt_renewable);
- break;
+ g_value_set_boolean (value, self->priv->tgt_renewable);
+ break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
}
}
static void
-ka_applet_dispose(GObject* object)
+ka_applet_dispose (GObject *object)
{
- KaApplet* applet = KA_APPLET(object);
- GObjectClass *parent_class = G_OBJECT_CLASS (ka_applet_parent_class);
+ KaApplet *applet = KA_APPLET (object);
+ GObjectClass *parent_class = G_OBJECT_CLASS (ka_applet_parent_class);
+
+ ka_close_notification (applet);
- if (applet->priv->tray_icon) {
- g_object_unref(applet->priv->tray_icon);
- applet->priv->tray_icon = NULL;
- }
- if (applet->priv->pwdialog) {
- g_object_unref(applet->priv->pwdialog);
- applet->priv->pwdialog = NULL;
- }
- if (applet->priv->uixml) {
- g_object_unref(applet->priv->uixml);
- applet->priv->uixml = NULL;
- }
- if (applet->priv->loader) {
- g_object_unref(applet->priv->loader);
- applet->priv->loader = NULL;
- }
+ if (applet->priv->tray_icon) {
+ g_object_unref (applet->priv->tray_icon);
+ applet->priv->tray_icon = NULL;
+ }
+ if (applet->priv->pwdialog) {
+ g_object_unref (applet->priv->pwdialog);
+ applet->priv->pwdialog = NULL;
+ }
+ if (applet->priv->uixml) {
+ g_object_unref (applet->priv->uixml);
+ applet->priv->uixml = NULL;
+ }
+ if (applet->priv->loader) {
+ g_object_unref (applet->priv->loader);
+ applet->priv->loader = NULL;
+ }
- if (parent_class->dispose != NULL)
- parent_class->dispose (object);
+ if (parent_class->dispose != NULL)
+ parent_class->dispose (object);
}
static void
-ka_applet_finalize(GObject *object)
+ka_applet_finalize (GObject *object)
{
- KaApplet* applet = KA_APPLET(object);
- GObjectClass *parent_class = G_OBJECT_CLASS (ka_applet_parent_class);
+ KaApplet *applet = KA_APPLET (object);
+ GObjectClass *parent_class = G_OBJECT_CLASS (ka_applet_parent_class);
- g_free (applet->priv->principal);
- g_free (applet->priv->pk_userid);
- g_free (applet->priv->pk_anchors);
- /* no need to free applet->priv */
+ g_free (applet->priv->principal);
+ g_free (applet->priv->pk_userid);
+ g_free (applet->priv->pk_anchors);
+ g_free (applet->priv->krb_msg);
+ /* no need to free applet->priv */
- if (parent_class->finalize != NULL)
- parent_class->finalize (object);
+ if (parent_class->finalize != NULL)
+ parent_class->finalize (object);
}
static void
-ka_applet_init(KaApplet *applet)
+ka_applet_init (KaApplet *applet)
{
- applet->priv = G_TYPE_INSTANCE_GET_PRIVATE(applet,
- KA_TYPE_APPLET,
- KaAppletPrivate);
+ applet->priv = G_TYPE_INSTANCE_GET_PRIVATE (applet,
+ KA_TYPE_APPLET,
+ KaAppletPrivate);
}
static void
-ka_applet_class_init(KaAppletClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS(klass);
- GParamSpec *pspec;
- const gchar *signalNames [ KA_SIGNAL_COUNT ] = {
- "krb-tgt-acquired",
- "krb-tgt-renewed",
- "krb-tgt-expired"};
- int i;
-
- object_class->dispose = ka_applet_dispose;
- object_class->finalize = ka_applet_finalize;
- g_type_class_add_private(klass, sizeof(KaAppletPrivate));
-
- object_class->set_property = ka_applet_set_property;
- object_class->get_property = ka_applet_get_property;
-
- pspec = g_param_spec_string ("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",
- "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",
- "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_boolean("show-trayicon",
- "Show tray icon",
- "Show/Hide the tray icon",
- TRUE,
- G_PARAM_CONSTRUCT | G_PARAM_READWRITE);
- g_object_class_install_property (object_class,
- KA_PROP_TRAYICON,
- pspec);
-
- pspec = g_param_spec_uint ("pw-prompt-mins",
- "Password prompting interval",
- "Password prompting interval in minutes",
- 0, G_MAXUINT, MINUTES_BEFORE_PROMPTING,
- G_PARAM_CONSTRUCT | G_PARAM_READWRITE);
- g_object_class_install_property (object_class,
- KA_PROP_PW_PROMPT_MINS,
- pspec);
-
- pspec = g_param_spec_boolean("tgt-forwardable",
- "Forwardable ticket",
- "wether to request forwardable tickets",
- FALSE,
- G_PARAM_CONSTRUCT | G_PARAM_READWRITE);
- g_object_class_install_property (object_class,
- KA_PROP_TGT_FORWARDABLE,
- pspec);
-
- pspec = g_param_spec_boolean("tgt-proxiable",
- "Proxiable ticket",
- "wether to request proxiable tickets",
- FALSE,
- G_PARAM_CONSTRUCT | G_PARAM_READWRITE);
- g_object_class_install_property (object_class,
- KA_PROP_TGT_PROXIABLE,
- pspec);
-
- pspec = g_param_spec_boolean("tgt-renewable",
- "Renewable ticket",
- "wether to request renewable tickets",
- FALSE,
- G_PARAM_CONSTRUCT | G_PARAM_READWRITE);
- g_object_class_install_property (object_class,
- KA_PROP_TGT_RENEWABLE,
- pspec);
-
- for (i = 0; i < KA_SIGNAL_COUNT ; i++) {
- guint signalId;
- signalId =
- g_signal_new ( signalNames [i],
- G_OBJECT_CLASS_TYPE ( klass ),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL,
- NULL,
- ka_closure_VOID__STRING_UINT,
- G_TYPE_NONE,
- 2, /* number of parameters */
- G_TYPE_STRING,
- G_TYPE_UINT);
- klass->signals [i] = signalId ;
- }
-}
-
-
-static KaApplet*
-ka_applet_new(void)
-{
- return g_object_new (KA_TYPE_APPLET, NULL);
+ka_applet_class_init (KaAppletClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GParamSpec *pspec;
+
+ const gchar *signalNames[KA_SIGNAL_COUNT] = {
+ "krb-tgt-acquired",
+ "krb-tgt-renewed",
+ "krb-tgt-expired"
+ };
+ int i;
+
+ object_class->dispose = ka_applet_dispose;
+ object_class->finalize = ka_applet_finalize;
+ g_type_class_add_private (klass, sizeof (KaAppletPrivate));
+
+ object_class->set_property = ka_applet_set_property;
+ object_class->get_property = ka_applet_get_property;
+
+ pspec = g_param_spec_string ("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",
+ "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",
+ "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",
+ "Password prompting interval",
+ "Password prompting interval in minutes",
+ 0, G_MAXUINT, MINUTES_BEFORE_PROMPTING,
+ G_PARAM_CONSTRUCT | G_PARAM_READWRITE);
+ g_object_class_install_property (object_class,
+ KA_PROP_PW_PROMPT_MINS, pspec);
+
+ pspec = g_param_spec_boolean ("tgt-forwardable",
+ "Forwardable ticket",
+ "wether to request forwardable tickets",
+ FALSE,
+ G_PARAM_CONSTRUCT | G_PARAM_READWRITE);
+ g_object_class_install_property (object_class,
+ KA_PROP_TGT_FORWARDABLE, pspec);
+
+ pspec = g_param_spec_boolean ("tgt-proxiable",
+ "Proxiable ticket",
+ "wether to request proxiable tickets",
+ FALSE,
+ G_PARAM_CONSTRUCT | G_PARAM_READWRITE);
+ g_object_class_install_property (object_class,
+ KA_PROP_TGT_PROXIABLE, pspec);
+
+ pspec = g_param_spec_boolean ("tgt-renewable",
+ "Renewable ticket",
+ "wether to request renewable tickets",
+ FALSE,
+ G_PARAM_CONSTRUCT | G_PARAM_READWRITE);
+ g_object_class_install_property (object_class,
+ KA_PROP_TGT_RENEWABLE, pspec);
+
+ for (i = 0; i < KA_SIGNAL_COUNT; i++) {
+ guint signalId;
+
+ signalId = g_signal_new (signalNames[i], G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+ ka_closure_VOID__STRING_UINT,
+ G_TYPE_NONE, 2, /* number of parameters */
+ G_TYPE_STRING, G_TYPE_UINT);
+ klass->signals[i] = signalId;
+ }
+}
+
+
+static KaApplet *
+ka_applet_new (void)
+{
+ return g_object_new (KA_TYPE_APPLET, NULL);
}
/* determine the new tooltip text */
-static char*
-ka_applet_tooltip_text(int remaining)
-{
- int hours, minutes;
- gchar* tooltip_text;
-
- if (remaining > 0) {
- if (remaining >= 3600) {
- hours = remaining / 3600;
- minutes = (remaining % 3600) / 60;
- /* Translators: First number is hours, second number is minutes */
- tooltip_text = g_strdup_printf (_("Your credentials expire in %.2d:%.2dh"), hours, minutes);
- } else {
- minutes = remaining / 60;
- tooltip_text = g_strdup_printf (ngettext(
- "Your credentials expire in %d minute",
- "Your credentials expire in %d minutes",
- minutes), minutes);
- }
- } else
- tooltip_text = g_strdup (_("Your credentials have expired"));
- return tooltip_text;
+static char *
+ka_applet_tooltip_text (int remaining)
+{
+ int hours, minutes;
+ gchar *tooltip_text;
+
+ if (remaining > 0) {
+ if (remaining >= 3600) {
+ hours = remaining / 3600;
+ minutes = (remaining % 3600) / 60;
+ /* Translators: First number is hours, second number is minutes */
+ tooltip_text =
+ g_strdup_printf (_("Your credentials expire in %.2d:%.2dh"),
+ hours, minutes);
+ } else {
+ minutes = remaining / 60;
+ tooltip_text =
+ g_strdup_printf (ngettext
+ ("Your credentials expire in %d minute",
+ "Your credentials expire in %d minutes",
+ minutes), minutes);
+ }
+ } else
+ tooltip_text = g_strdup (_("Your credentials have expired"));
+ return tooltip_text;
}
/* determine the current icon */
-static const char*
-ka_applet_select_icon(KaApplet* applet, int remaining)
+static const char *
+ka_applet_select_icon (KaApplet *applet, int remaining)
{
- enum ka_icon tray_icon = inv_icon;
+ enum ka_icon status_icon = inv_icon;
- if (remaining > 0) {
- if (remaining < applet->priv->pw_prompt_secs &&
- !applet->priv->renewable)
- tray_icon = exp_icon;
- else
- tray_icon = val_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[tray_icon];
+ return applet->priv->icons[status_icon];
}
-#ifdef HAVE_LIBNOTIFY
static gboolean
-ka_show_notification (KaApplet *applet)
+ka_tray_icon_is_embedded (KaApplet *self)
{
- /* wait for the panel to be settled before showing a bubble */
- if (gtk_status_icon_is_embedded (applet->priv->tray_icon)) {
- GError *error = NULL;
- gboolean ret;
+ if (self->priv->tray_icon
+ && gtk_status_icon_is_embedded (self->priv->tray_icon))
+ return TRUE;
+ else
+ return FALSE;
+}
- ret = notify_notification_show (applet->priv->notification, &error);
- if (!ret) {
- g_assert (error);
- g_assert (error->message);
- g_warning ("Failed to show notification: %s", error->message);
- g_clear_error (&error);
- }
- } else {
- g_timeout_add_seconds (5, (GSourceFunc)ka_show_notification, applet);
- }
- return FALSE;
+
+static gboolean
+ka_show_notification (KaApplet *applet)
+{
+ /* wait for the panel to be settled before showing a bubble */
+ if (applet->priv->ns_persistence
+ || ka_tray_icon_is_embedded (applet)) {
+ GError *error = NULL;
+ gboolean ret;
+
+ ret = notify_notification_show (applet->priv->notification, &error);
+ if (!ret) {
+ g_assert (error);
+ g_assert (error->message);
+ g_warning ("Failed to show notification: %s", error->message);
+ g_clear_error (&error);
+ }
+ } else {
+ g_timeout_add_seconds (5, (GSourceFunc) ka_show_notification, applet);
+ }
+ return FALSE;
}
+/* Callback to handle disabling of notification */
static void
-ka_notify_action_cb (NotifyNotification *notification G_GNUC_UNUSED,
- gchar *action, gpointer user_data)
-{
- KaApplet *self = KA_APPLET (user_data);
+ka_notify_disable_action_cb (NotifyNotification *notification G_GNUC_UNUSED,
+ gchar *action,
+ gpointer user_data)
+{
+ KaApplet *self = KA_APPLET (user_data);
+
+ 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;
+ } else {
+ g_warning ("unkonwn action for callback");
+ }
+}
+
- 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;
- } else {
- g_warning("unkonwn action for callback");
- }
+/* Callback to handle ticket related actions */
+static void
+ka_notify_ticket_action_cb (NotifyNotification *notification G_GNUC_UNUSED,
+ gchar *action,
+ gpointer user_data)
+{
+ KaApplet *self = KA_APPLET (user_data);
+
+ g_return_if_fail (self != NULL);
+
+ if (strcmp (action, "ka-acquire-tgt") == 0) {
+ KA_DEBUG ("Getting new tgt");
+ ka_grab_credentials (self);
+ } else if (strcmp (action, "ka-remove-ccache") == 0) {
+ KA_DEBUG ("Removing ccache");
+ ka_destroy_ccache (self);
+ } else if (strcmp (action, "ka-list-tickets") == 0) {
+ KA_DEBUG ("Listing tickets");
+ ka_tickets_dialog_run ();
+ } else {
+ g_warning ("unkonwn action for callback");
+ }
}
static void
-ka_send_event_notification (KaApplet *applet,
- const char *summary,
- const char *message,
- const char *icon,
- const char *action)
-{
- const char *notify_icon;
- GError *error = NULL;
-
- g_return_if_fail (applet != NULL);
- g_return_if_fail (summary != NULL);
- g_return_if_fail (message != NULL);
-
- if (!notify_is_initted ())
- notify_init (PACKAGE);
-
- if (applet->priv->notification != NULL) {
- if (!notify_notification_close (applet->priv->notification,
- &error)) {
- if (error)
- g_warning ("Cannot close notification %s",
- error->message);
- else
- g_warning ("Cannot close notification");
- }
- g_object_unref (applet->priv->notification);
- g_clear_error (&error);
- }
-
- notify_icon = icon ? icon : "krb-valid-ticket";
-
- applet->priv->notification = \
- notify_notification_new_with_status_icon(summary,
- message,
- notify_icon,
- applet->priv->tray_icon);
-
- notify_notification_set_urgency (applet->priv->notification, NOTIFY_URGENCY_NORMAL);
- notify_notification_add_action (applet->priv->notification,
- action,
- _("Don't show me this again"),
- (NotifyActionCallback) ka_notify_action_cb,
- applet, NULL);
- ka_show_notification (applet);
+ka_close_notification (KaApplet *self)
+{
+ GError *error = NULL;
+
+ if (self->priv->notification != NULL) {
+ if (!notify_notification_close (self->priv->notification, &error)) {
+ if (error)
+ g_warning ("Cannot close notification %s", error->message);
+ else
+ g_warning ("Cannot close notification");
+ }
+ g_object_unref (self->priv->notification);
+ g_clear_error (&error);
+ self->priv->notification = NULL;
+ }
}
+
+static void
+ka_send_event_notification (KaApplet *self,
+ const char *summary,
+ const char *message,
+ const char *icon,
+ gboolean get_ticket_action)
+{
+ NotifyNotification *notification;
+ const char *hint;
+ gint timeout;
+
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (summary != NULL);
+ g_return_if_fail (message != NULL);
+
+ if (!notify_is_initted ())
+ notify_init (KA_NAME);
+
+ if (self->priv->notification) {
+ notification = self->priv->notification;
+ notify_notification_update (notification, summary, message, icon);
+ } else {
+ notification = self->priv->notification =
+#if HAVE_NOTIFY_NOTIFICATION_NEW_WITH_STATUS_ICON
+ notify_notification_new_with_status_icon (summary,
+ message,
+ icon,
+ self->priv->tray_icon);
#else
+ notify_notification_new (summary, message, icon);
+#endif
+ notify_notification_set_urgency (notification, NOTIFY_URGENCY_NORMAL);
+ }
+
+ if (self->priv->ns_persistence) {
+ hint = "resident";
+ timeout = NOTIFY_EXPIRES_NEVER;
+
+ notify_notification_set_timeout (notification, timeout);
+ notify_notification_clear_hints (notification);
+#if HAVE_NOTIFY_NOTIFICATION_SET_HINT
+ notify_notification_set_hint (notification,
+ hint,
+ g_variant_new_boolean (TRUE));
+#endif
+ }
+
+ notify_notification_clear_actions(notification);
+ /* Add List Tickets button until we moved this into cc-panl */
+ if (self->priv->ns_persistence) {
+ notify_notification_add_action (notification,
+ "ka-list-tickets",
+ _("List Tickets"),
+ (NotifyActionCallback)
+ ka_notify_ticket_action_cb,
+ self,
+ NULL);
+ }
+
+ if (get_ticket_action) {
+ notify_notification_add_action (notification,
+ "ka-acquire-tgt",
+ _("Get Ticket"),
+ (NotifyActionCallback)
+ ka_notify_ticket_action_cb,
+ self,
+ NULL);
+ } else {
+ if (!self->priv->ns_persistence) {
+ notify_notification_add_action (notification,
+ "dont-show-again",
+ _("Don't show me this again"),
+ (NotifyActionCallback)
+ ka_notify_disable_action_cb, self,
+ NULL);
+ } else {
+ notify_notification_add_action (notification,
+ "ka-remove-ccache",
+ _("Remove Credentials Cache"),
+ (NotifyActionCallback)
+ ka_notify_ticket_action_cb,
+ self,
+ NULL);
+ }
+ }
+ ka_show_notification (self);
+}
+
+
static void
-ka_send_event_notification (KaApplet *applet G_GNUC_UNUSED,
- const char *summary G_GNUC_UNUSED,
- const char *message G_GNUC_UNUSED,
- const char *icon G_GNUC_UNUSED,
- const char *action G_GNUC_UNUSED)
+ka_update_tray_icon (KaApplet *self, const char *icon, const char *tooltip)
{
+ if (self->priv->tray_icon) {
+ gtk_status_icon_set_from_icon_name (self->priv->tray_icon, icon);
+ gtk_status_icon_set_tooltip_text (self->priv->tray_icon, tooltip);
+ }
}
-#endif /* ! HAVE_LIBNOTIFY */
-
/*
* update the tray icon's tooltip and icon
* and notify listeners about acquired/expiring tickets via signals
*/
int
-ka_applet_update_status(KaApplet* applet, krb5_timestamp expiry)
-{
- int now = time(0);
- int remaining = expiry - now;
- static int last_warn = 0;
- static gboolean expiry_notified = FALSE;
- static krb5_timestamp old_expiry = 0;
- gboolean notify = TRUE;
- const char* tray_icon = ka_applet_select_icon (applet, remaining);
- char* tooltip_text = ka_applet_tooltip_text (remaining);
-
-
- if (remaining > 0) {
- if (expiry_notified) {
- ka_gconf_get_bool(applet->priv->gconf,
- KA_GCONF_KEY_NOTIFY_VALID,
- &notify);
- if (notify) {
- applet->priv->notify_gconf_key = KA_GCONF_KEY_NOTIFY_VALID;
- ka_send_event_notification (applet,
- _("Network credentials valid"),
- _("You've refreshed your Kerberos credentials."),
- "krb-valid-ticket",
- "dont-show-again");
- }
- ka_applet_signal_emit (applet, KA_SIGNAL_ACQUIRED_TGT, expiry);
- expiry_notified = FALSE;
- } else {
- 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,
- &notify);
- if (notify) {
- applet->priv->notify_gconf_key = KA_GCONF_KEY_NOTIFY_EXPIRING;
- ka_send_event_notification (applet,
- _("Network credentials expiring"),
- tooltip_text,
- "krb-expiring-ticket",
- "dont-show-again");
- }
- last_warn = now;
- }
- /* ticket lifetime got longer e.g. by kinit -R */
- if (old_expiry && expiry > old_expiry)
- ka_applet_signal_emit (applet, KA_SIGNAL_RENEWED_TGT, expiry);
- }
- } else {
- if (!expiry_notified) {
- ka_gconf_get_bool(applet->priv->gconf,
- KA_GCONF_KEY_NOTIFY_EXPIRED,
- &notify);
- if (notify) {
- applet->priv->notify_gconf_key = KA_GCONF_KEY_NOTIFY_EXPIRED;
- ka_send_event_notification (applet,
- _("Network credentials expired"),
- _("Your Kerberos credentails have expired."),
- "krb-no-valid-ticket",
- "dont-show-again");
- }
- ka_applet_signal_emit (applet, KA_SIGNAL_EXPIRED_TGT, expiry);
- expiry_notified = TRUE;
- last_warn = 0;
- }
- }
-
- old_expiry = expiry;
- gtk_status_icon_set_from_icon_name (applet->priv->tray_icon, tray_icon);
- gtk_status_icon_set_tooltip_text (applet->priv->tray_icon, tooltip_text);
- g_free(tooltip_text);
- return 0;
+ka_applet_update_status (KaApplet *applet, krb5_timestamp expiry)
+{
+ int now = time (0);
+ int remaining = expiry - now;
+ static int last_warn = 0;
+ static gboolean expiry_notified = FALSE;
+ static krb5_timestamp old_expiry = 0;
+ gboolean notify = TRUE;
+ const char *status_icon = ka_applet_select_icon (applet, remaining);
+ char *tooltip_text = ka_applet_tooltip_text (remaining);
+
+
+ if (remaining > 0) {
+ if (expiry_notified) {
+ const char* msg;
+ ka_gconf_get_bool (applet->priv->gconf,
+ KA_GCONF_KEY_NOTIFY_VALID, &notify);
+ if (notify) {
+ applet->priv->notify_gconf_key = KA_GCONF_KEY_NOTIFY_VALID;
+
+ if (applet->priv->krb_msg)
+ msg = applet->priv->krb_msg;
+ else
+ msg = _("You've refreshed your Kerberos credentials.");
+ ka_send_event_notification (applet,
+ _("Network credentials valid"),
+ msg,
+ "krb-valid-ticket",
+ FALSE);
+ }
+ ka_applet_signal_emit (applet, KA_SIGNAL_ACQUIRED_TGT, expiry);
+ expiry_notified = FALSE;
+ g_free (applet->priv->krb_msg);
+ applet->priv->krb_msg = NULL;
+ } else {
+ 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, &notify);
+ if (notify) {
+ applet->priv->notify_gconf_key =
+ KA_GCONF_KEY_NOTIFY_EXPIRING;
+ ka_send_event_notification (applet,
+ _("Network credentials expiring"),
+ tooltip_text,
+ "krb-expiring-ticket",
+ TRUE);
+ }
+ last_warn = now;
+ }
+ /* ticket lifetime got longer e.g. by kinit -R */
+ if (old_expiry && expiry > old_expiry)
+ ka_applet_signal_emit (applet, KA_SIGNAL_RENEWED_TGT, expiry);
+ }
+ } else {
+ if (!expiry_notified) {
+ ka_gconf_get_bool (applet->priv->gconf,
+ KA_GCONF_KEY_NOTIFY_EXPIRED, &notify);
+ if (notify) {
+ applet->priv->notify_gconf_key = KA_GCONF_KEY_NOTIFY_EXPIRED;
+ ka_send_event_notification (applet,
+ _("Network credentials expired"),
+ _("Your Kerberos credentails have expired."),
+ "krb-no-valid-ticket",
+ TRUE);
+ }
+ ka_applet_signal_emit (applet, KA_SIGNAL_EXPIRED_TGT, expiry);
+ expiry_notified = TRUE;
+ last_warn = 0;
+ }
+ }
+
+ old_expiry = expiry;
+ ka_update_tray_icon(applet, status_icon, tooltip_text);
+ g_free (tooltip_text);
+ return 0;
}
static void
-ka_applet_menu_add_separator_item (GtkWidget* menu)
+ka_applet_menu_add_separator_item (GtkWidget *menu)
{
- GtkWidget* menu_item;
+ GtkWidget *menu_item;
- menu_item = gtk_separator_menu_item_new ();
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
- gtk_widget_show (menu_item);
+ menu_item = gtk_separator_menu_item_new ();
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
+ gtk_widget_show (menu_item);
}
static void
-ka_applet_cb_preferences (GtkWidget* menuitem G_GNUC_UNUSED,
+ka_applet_cb_preferences (GtkWidget *menuitem G_GNUC_UNUSED,
gpointer user_data G_GNUC_UNUSED)
{
- GError *error = NULL;
-
- g_spawn_command_line_async (BIN_DIR
- G_DIR_SEPARATOR_S
- "krb5-auth-dialog-preferences",
- &error);
- if (error) {
- GtkWidget *message_dialog;
-
- message_dialog = gtk_message_dialog_new (NULL,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- _("There was an error launching the preferences dialog: %s"),
- error->message);
- gtk_window_set_resizable (GTK_WINDOW (message_dialog), FALSE);
-
- g_signal_connect (message_dialog, "response",
- G_CALLBACK (gtk_widget_destroy),
- NULL);
- gtk_widget_show (message_dialog);
- g_clear_error (&error);
- }
+ GError *error = NULL;
+
+ g_spawn_command_line_async (BIN_DIR
+ G_DIR_SEPARATOR_S
+ "gnome-control-center ka-panel", &error);
+ if (error) {
+ GtkWidget *message_dialog;
+
+ message_dialog = gtk_message_dialog_new (NULL,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ _("There was an error launching the preferences dialog: %s"),
+ error->message);
+ gtk_window_set_resizable (GTK_WINDOW (message_dialog), FALSE);
+
+ g_signal_connect (message_dialog, "response",
+ G_CALLBACK (gtk_widget_destroy), NULL);
+ gtk_widget_show (message_dialog);
+ g_clear_error (&error);
+ }
}
/* Free all resources and quit */
static void
-ka_applet_cb_quit (GtkMenuItem* menuitem G_GNUC_UNUSED, gpointer user_data)
-{
- KaApplet* applet = KA_APPLET(user_data);
-
- g_object_unref (applet);
- gtk_main_quit ();
-}
-
-
-static void
-ka_about_dialog_url_hook (GtkAboutDialog *about,
- const gchar *alink,
- gpointer data G_GNUC_UNUSED)
+ka_applet_cb_quit (GtkMenuItem *menuitem G_GNUC_UNUSED, gpointer user_data)
{
- GError *error = NULL;
-
- gtk_show_uri(gtk_window_get_screen (GTK_WINDOW (about)),
- alink, gtk_get_current_event_time(), &error);
-
- if (error) {
- GtkWidget *message_dialog;
-
- message_dialog = gtk_message_dialog_new (GTK_WINDOW (about),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- _("There was an error displaying %s:\n%s"),
- alink, error->message);
- gtk_window_set_resizable (GTK_WINDOW (message_dialog), FALSE);
+ KaApplet *applet = KA_APPLET (user_data);
- g_signal_connect (message_dialog, "response",
- G_CALLBACK (gtk_widget_destroy),
- NULL);
- gtk_widget_show (message_dialog);
- g_clear_error (&error);
- }
+ g_object_unref (applet);
+ gtk_main_quit ();
}
static void
-ka_applet_cb_about_dialog (GtkMenuItem* menuitem G_GNUC_UNUSED,
- gpointer user_data G_GNUC_UNUSED)
-{
- const gchar* authors[] = {
- "Christopher Aillon <caillon@redhat.com>",
- "Jonathan Blandford <jrb@redhat.com>",
- "Colin Walters <walters@verbum.org>",
- "Guido Günther <agx@sigxcpu.org>",
- NULL };
-
- gtk_about_dialog_set_url_hook (ka_about_dialog_url_hook, NULL, NULL);
- gtk_show_about_dialog (NULL,
- "authors", authors,
- "version", VERSION,
- "logo-icon-name", "krb-valid-ticket",
- "copyright",
- "Copyright (C) 2004,2005,2006 Red Hat, Inc.,\n"
- "2008,2009 Guido Günther",
- "website-label", PACKAGE " website",
- "website", "https://honk.sigxcpu.org/piki/projects/krb5-auth-dialog/",
- "license", "GNU General Public License Version 2",
- /* Translators: add the translators of your language here */
- "translator-credits", _("translator-credits"),
- NULL);
+ka_applet_cb_about_dialog (GtkMenuItem *menuitem G_GNUC_UNUSED,
+ gpointer user_data G_GNUC_UNUSED)
+{
+ const gchar *authors[] = {
+ "Christopher Aillon <caillon@redhat.com>",
+ "Jonathan Blandford <jrb@redhat.com>",
+ "Colin Walters <walters@verbum.org>",
+ "Guido Günther <agx@sigxcpu.org>",
+ NULL
+ };
+
+ gtk_show_about_dialog (NULL,
+ "authors", authors,
+ "version", VERSION,
+ "logo-icon-name", "krb-valid-ticket",
+ "copyright",
+ "Copyright (C) 2004,2005,2006 Red Hat, Inc.,\n"
+ "2008,2009 Guido Günther",
+ "website-label", PACKAGE " website",
+ "website",
+ "https://honk.sigxcpu.org/piki/projects/krb5-auth-dialog/",
+ "license", "GNU General Public License Version 2",
+ /* Translators: add the translators of your language here */
+ "translator-credits", _("translator-credits"),
+ NULL);
}
static void
-ka_applet_cb_show_help (GtkMenuItem* menuitem G_GNUC_UNUSED,
- gpointer user_data)
+ka_applet_cb_show_help (GtkMenuItem *menuitem G_GNUC_UNUSED,
+ gpointer user_data)
{
- KaApplet *applet = KA_APPLET(user_data);
+ KaApplet *applet = KA_APPLET (user_data);
- ka_show_help (gtk_status_icon_get_screen(applet->priv->tray_icon), NULL, NULL);
+ ka_show_help (gtk_status_icon_get_screen (applet->priv->tray_icon), NULL,
+ NULL);
}
static void
-ka_applet_cb_destroy_ccache(GtkMenuItem* menuitem G_GNUC_UNUSED,
- gpointer user_data)
+ka_applet_cb_destroy_ccache (GtkMenuItem *menuitem G_GNUC_UNUSED,
+ gpointer user_data)
{
- KaApplet *applet = KA_APPLET(user_data);
- ka_destroy_ccache(applet);
+ KaApplet *applet = KA_APPLET (user_data);
+
+ ka_destroy_ccache (applet);
}
static void
-ka_applet_cb_show_tickets(GtkMenuItem* menuitem G_GNUC_UNUSED,
- gpointer user_data G_GNUC_UNUSED)
+ka_applet_cb_show_tickets (GtkMenuItem *menuitem G_GNUC_UNUSED,
+ gpointer user_data G_GNUC_UNUSED)
{
- ka_tickets_dialog_run();
+ ka_tickets_dialog_run ();
}
/* The tray icon's context menu */
static gboolean
-ka_applet_create_context_menu (KaApplet* applet)
+ka_applet_create_context_menu (KaApplet *applet)
{
- GtkWidget* menu;
- GtkWidget* menu_item;
- GtkWidget* image;
+ GtkWidget *menu;
+ GtkWidget *menu_item;
+ GtkWidget *image;
- menu = gtk_menu_new ();
+ menu = gtk_menu_new ();
- /* kdestroy */
- menu_item = gtk_image_menu_item_new_with_mnemonic (_("Remove Credentials _Cache"));
- g_signal_connect (G_OBJECT (menu_item), "activate",
- G_CALLBACK (ka_applet_cb_destroy_ccache), applet);
- image = gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
+ /* kdestroy */
+ menu_item =
+ gtk_image_menu_item_new_with_mnemonic (_("Remove Credentials _Cache"));
+ g_signal_connect (G_OBJECT (menu_item), "activate",
+ G_CALLBACK (ka_applet_cb_destroy_ccache), applet);
+ image = gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_MENU);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
- ka_applet_menu_add_separator_item (menu);
+ ka_applet_menu_add_separator_item (menu);
- /* Ticket dialog */
- menu_item = gtk_image_menu_item_new_with_mnemonic(_("_List Tickets"));
- g_signal_connect (G_OBJECT (menu_item), "activate",
- G_CALLBACK (ka_applet_cb_show_tickets), applet);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
+ /* Ticket dialog */
+ menu_item = gtk_image_menu_item_new_with_mnemonic (_("_List Tickets"));
+ g_signal_connect (G_OBJECT (menu_item), "activate",
+ G_CALLBACK (ka_applet_cb_show_tickets), applet);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
- /* Preferences */
- menu_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_PREFERENCES, NULL);
- g_signal_connect (G_OBJECT (menu_item), "activate",
- G_CALLBACK (ka_applet_cb_preferences), applet);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
+ /* Preferences */
+ menu_item =
+ gtk_image_menu_item_new_from_stock (GTK_STOCK_PREFERENCES, NULL);
+ g_signal_connect (G_OBJECT (menu_item), "activate",
+ G_CALLBACK (ka_applet_cb_preferences), applet);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
- /* About item */
- menu_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_HELP, NULL);
- g_signal_connect (G_OBJECT (menu_item), "activate",
- G_CALLBACK (ka_applet_cb_show_help), applet);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
+ /* About item */
+ menu_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_HELP, NULL);
+ g_signal_connect (G_OBJECT (menu_item), "activate",
+ G_CALLBACK (ka_applet_cb_show_help), applet);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
- /* About item */
- menu_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_ABOUT, NULL);
- g_signal_connect (G_OBJECT (menu_item), "activate",
- G_CALLBACK (ka_applet_cb_about_dialog), applet);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
+ /* About item */
+ menu_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_ABOUT, NULL);
+ g_signal_connect (G_OBJECT (menu_item), "activate",
+ G_CALLBACK (ka_applet_cb_about_dialog), applet);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
- ka_applet_menu_add_separator_item (menu);
+ ka_applet_menu_add_separator_item (menu);
- /* Quit */
- menu_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, NULL);
- g_signal_connect (G_OBJECT (menu_item), "activate",
- G_CALLBACK (ka_applet_cb_quit), applet);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
+ /* Quit */
+ menu_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT, NULL);
+ g_signal_connect (G_OBJECT (menu_item), "activate",
+ G_CALLBACK (ka_applet_cb_quit), applet);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
- gtk_widget_show_all (menu);
- applet->priv->context_menu = menu;
+ gtk_widget_show_all (menu);
+ applet->priv->context_menu = menu;
- return TRUE;
+ return TRUE;
}
static void
-ka_tray_icon_on_menu (GtkStatusIcon* status_icon G_GNUC_UNUSED,
+ka_tray_icon_on_menu (GtkStatusIcon *status_icon G_GNUC_UNUSED,
guint button,
guint activate_time,
gpointer user_data)
{
- KaApplet *applet = KA_APPLET(user_data);
+ KaApplet *applet = KA_APPLET (user_data);
- KA_DEBUG("Trayicon right clicked: %d", applet->priv->pw_prompt_secs);
- gtk_menu_popup (GTK_MENU (applet->priv->context_menu), NULL, NULL,
- gtk_status_icon_position_menu, applet->priv->tray_icon,
- button, activate_time);
+ KA_DEBUG ("Trayicon right clicked: %d", applet->priv->pw_prompt_secs);
+ gtk_menu_popup (GTK_MENU (applet->priv->context_menu), NULL, NULL,
+ gtk_status_icon_position_menu, applet->priv->tray_icon,
+ button, activate_time);
}
static gboolean
-ka_tray_icon_on_click (GtkStatusIcon* status_icon G_GNUC_UNUSED,
+ka_tray_icon_on_click (GtkStatusIcon *status_icon G_GNUC_UNUSED,
gpointer data)
{
- KaApplet *applet = KA_APPLET(data);
+ KaApplet *applet = KA_APPLET (data);
- KA_DEBUG("Trayicon clicked: %d", applet->priv->pw_prompt_secs);
- ka_grab_credentials (applet);
- return TRUE;
+ KA_DEBUG ("Trayicon clicked: %d", applet->priv->pw_prompt_secs);
+ ka_grab_credentials (applet);
+ return TRUE;
}
static gboolean
-ka_applet_cb_show_trayicon (KaApplet* applet,
- GParamSpec* property G_GNUC_UNUSED,
- gpointer data G_GNUC_UNUSED)
+ka_applet_create_tray_icon (KaApplet *self)
{
- g_return_val_if_fail (applet != NULL, FALSE);
- g_return_val_if_fail (applet->priv->tray_icon != NULL, FALSE);
-
- gtk_status_icon_set_visible (applet->priv->tray_icon, applet->priv->show_trayicon);
- return TRUE;
-}
+ GtkStatusIcon *tray_icon;
+ if (self->priv->ns_persistence)
+ return FALSE;
-static gboolean
-ka_applet_create_tray_icon (KaApplet* applet)
-{
- GtkStatusIcon* tray_icon;
-
- tray_icon = gtk_status_icon_new ();
+ tray_icon = self->priv->tray_icon = gtk_status_icon_new ();
- g_signal_connect (G_OBJECT(tray_icon), "activate",
- G_CALLBACK(ka_tray_icon_on_click), applet);
- g_signal_connect (G_OBJECT(tray_icon),
- "popup-menu",
- G_CALLBACK(ka_tray_icon_on_menu), applet);
- gtk_status_icon_set_from_icon_name (tray_icon, applet->priv->icons[exp_icon]);
- gtk_status_icon_set_tooltip_text (tray_icon, PACKAGE);
- gtk_status_icon_set_title (tray_icon, KA_NAME);
- applet->priv->tray_icon = tray_icon;
- return TRUE;
+ g_signal_connect (G_OBJECT (tray_icon), "activate",
+ G_CALLBACK (ka_tray_icon_on_click), self);
+ g_signal_connect (G_OBJECT (tray_icon),
+ "popup-menu",
+ G_CALLBACK (ka_tray_icon_on_menu), self);
+ gtk_status_icon_set_from_icon_name (tray_icon,
+ self->priv->icons[exp_icon]);
+ gtk_status_icon_set_tooltip_text (tray_icon, PACKAGE);
+ gtk_status_icon_set_title (tray_icon, KA_NAME);
+ return TRUE;
}
static int
-ka_applet_setup_icons (KaApplet* applet)
+ka_applet_setup_icons (KaApplet *applet)
{
- /* Add application specific icons to search path */
- gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
- DATA_DIR G_DIR_SEPARATOR_S "icons");
- applet->priv->icons[val_icon] = "krb-valid-ticket";
- applet->priv->icons[exp_icon] = "krb-expiring-ticket";
- applet->priv->icons[inv_icon] = "krb-no-valid-ticket";
- return TRUE;
+ /* Add application specific icons to search path */
+ gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
+ DATA_DIR G_DIR_SEPARATOR_S "icons");
+ applet->priv->icons[val_icon] = "krb-valid-ticket";
+ applet->priv->icons[exp_icon] = "krb-expiring-ticket";
+ applet->priv->icons[inv_icon] = "krb-no-valid-ticket";
+ return TRUE;
}
guint
-ka_applet_get_pw_prompt_secs(const KaApplet* applet)
+ka_applet_get_pw_prompt_secs (const KaApplet *applet)
{
- return applet->priv->pw_prompt_secs;
+ return applet->priv->pw_prompt_secs;
}
-gboolean
-ka_applet_get_show_trayicon(const KaApplet* applet)
+void
+ka_applet_set_tgt_renewable (KaApplet *applet, gboolean renewable)
{
- return applet->priv->show_trayicon;
+ applet->priv->renewable = renewable;
}
-void
-ka_applet_set_tgt_renewable(KaApplet* applet, gboolean renewable)
+gboolean
+ka_applet_get_tgt_renewable (const KaApplet *applet)
{
- applet->priv->renewable = renewable;
+ return applet->priv->renewable;
}
-gboolean
-ka_applet_get_tgt_renewable(const KaApplet* applet)
+KaPwDialog *
+ka_applet_get_pwdialog (const KaApplet *applet)
{
- return applet->priv->renewable;
+ return applet->priv->pwdialog;
}
-KaPwDialog*
-ka_applet_get_pwdialog(const KaApplet* applet)
+GConfClient *
+ka_applet_get_gconf_client (const KaApplet *self)
{
- return applet->priv->pwdialog;
+ return self->priv->gconf;
}
-GConfClient*
-ka_applet_get_gconf_client(const KaApplet* self)
+void
+ka_applet_set_msg (KaApplet *self, const char *msg)
{
- return self->priv->gconf;
+ g_free (self->priv->krb_msg);
+ self->priv->krb_msg = g_strdup (msg);
}
void
-ka_applet_signal_emit (KaApplet* this, KaAppletSignalNumber signum,
- krb5_timestamp expiry)
+ka_applet_signal_emit (KaApplet *this,
+ KaAppletSignalNumber signum,
+ krb5_timestamp expiry)
{
- KaAppletClass *klass = KA_APPLET_GET_CLASS (this);
- char *princ;
+ KaAppletClass *klass = KA_APPLET_GET_CLASS (this);
+ char *princ;
- princ = ka_unparse_name ();
- if (!princ)
- return;
+ princ = ka_unparse_name ();
+ if (!princ)
+ return;
- g_signal_emit (this, klass->signals[signum], 0, princ, (guint32)expiry);
- g_free (princ);
+ g_signal_emit (this, klass->signals[signum], 0, princ, (guint32) expiry);
+ g_free (princ);
}
+
+static void
+ka_ns_check_persistence (KaApplet *self)
+{
+ GList *caps;
+ GList *l;
+
+ self->priv->ns_persistence = FALSE;
+ caps = notify_get_server_caps ();
+ if (caps == NULL) {
+ g_warning ("Failed to read server caps");
+ return;
+ }
+
+ l = g_list_find_custom (caps, "persistence", (GCompareFunc)strcmp);
+ if (l != NULL) {
+ self->priv->ns_persistence = TRUE;
+ KA_DEBUG ("Notification server supports persistence.");
+ }
+ g_list_foreach (caps, (GFunc) g_free, NULL);
+ g_list_free (caps);
+}
+
+
/* create the tray icon applet */
-KaApplet*
-ka_applet_create()
-{
- KaApplet* applet = ka_applet_new();
- GError *error = NULL;
- gboolean ret;
-
- if (!(ka_applet_setup_icons (applet)))
- g_error ("Failure to setup icons");
- if (!ka_applet_create_tray_icon (applet))
- g_error ("Failure to create tray icon");
- if (!ka_applet_create_context_menu (applet))
- g_error ("Failure to create context menu");
- gtk_window_set_default_icon_name (applet->priv->icons[val_icon]);
- g_signal_connect (applet, "notify::show-trayicon",
- G_CALLBACK (ka_applet_cb_show_trayicon), NULL);
-
- applet->priv->uixml = gtk_builder_new();
- ret = gtk_builder_add_from_file(applet->priv->uixml,
- KA_DATA_DIR G_DIR_SEPARATOR_S
- PACKAGE ".xml", &error);
- if (!ret) {
- g_assert (error);
- g_assert (error->message);
- g_error ("Failed to load UI XML: %s", error->message);
- }
- 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);
-
- ka_tickets_dialog_create (applet->priv->uixml);
- applet->priv->loader = ka_plugin_loader_create (applet);
- g_return_val_if_fail (applet->priv->loader != NULL, NULL);
-
- return applet;
+KaApplet *
+ka_applet_create ()
+{
+ KaApplet *applet = ka_applet_new ();
+ GError *error = NULL;
+ gboolean ret;
+
+ if (!(ka_applet_setup_icons (applet)))
+ g_error ("Failure to setup icons");
+ gtk_window_set_default_icon_name (applet->priv->icons[val_icon]);
+
+ if (!ka_applet_create_context_menu (applet))
+ g_error ("Failure to create context menu");
+
+ ka_ns_check_persistence(applet);
+ ka_applet_create_tray_icon (applet);
+
+ applet->priv->uixml = gtk_builder_new ();
+ ret = gtk_builder_add_from_file (applet->priv->uixml,
+ KA_DATA_DIR G_DIR_SEPARATOR_S
+ PACKAGE ".xml", &error);
+ if (!ret) {
+ g_assert (error);
+ g_assert (error->message);
+ g_error ("Failed to load UI XML: %s", error->message);
+ }
+ 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);
+
+ ka_tickets_dialog_create (applet->priv->uixml);
+ applet->priv->loader = ka_plugin_loader_create (applet);
+ g_return_val_if_fail (applet->priv->loader != NULL, NULL);
+
+ return applet;
}
+
+/*
+ * vim:ts:sts=4:sw=4:et:
+ */
diff --git a/src/ka-dialog.c b/src/ka-dialog.c
index f11293d..ce86367 100644
--- a/src/ka-dialog.c
+++ b/src/ka-dialog.c
@@ -32,7 +32,6 @@
#include <glib/gi18n.h>
#include <gio/gio.h>
-#include "gtksecentry.h"
#include "secmem-util.h"
#include "memory.h"
@@ -44,7 +43,7 @@
#include "ka-tickets.h"
#ifdef ENABLE_NETWORK_MANAGER
-#include <libnm_glib.h>
+#include <nm-client.h>
#endif
#ifdef HAVE_HX509_ERR_H
@@ -65,7 +64,7 @@ static int ka_renew_credentials (KaApplet* applet);
static gboolean ka_get_tgt_from_ccache (krb5_context context, krb5_creds *creds);
#ifdef ENABLE_NETWORK_MANAGER
-libnm_glib_ctx *nm_context;
+NMClient *nm_client;
#endif
/* YAY for different Kerberos implementations */
@@ -403,6 +402,9 @@ auth_dialog_prompter (krb5_context ctx G_GNUC_UNUSED,
canceled = FALSE;
canceled_creds_expiry = 0;
+ if (banner && !num_prompts)
+ ka_applet_set_msg (applet, banner);
+
for (i = 0; i < num_prompts; i++) {
const gchar *password = NULL;
int password_len = 0;
@@ -454,29 +456,30 @@ cleanup:
#ifdef ENABLE_NETWORK_MANAGER
static void
-network_state_cb (libnm_glib_ctx *context,
- gpointer data)
+ka_nm_client_state_changed_cb (NMClient *client,
+ GParamSpec *pspec G_GNUC_UNUSED,
+ gpointer data)
{
- gboolean *online = (gboolean*) data;
-
- libnm_glib_state state;
-
- state = libnm_glib_get_network_state (context);
-
- switch (state)
- {
- case LIBNM_NO_DBUS:
- case LIBNM_NO_NETWORKMANAGER:
- case LIBNM_INVALID_CONTEXT:
- /* do nothing */
- break;
- case LIBNM_NO_NETWORK_CONNECTION:
- *online = FALSE;
- break;
- case LIBNM_ACTIVE_NETWORK_CONNECTION:
- *online = TRUE;
- break;
- }
+ 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_DISCONNECTED:
+ KA_DEBUG("Network disconnected");
+ *online = FALSE;
+ break;
+ case NM_STATE_CONNECTED:
+ KA_DEBUG("Network connected");
+ *online = TRUE;
+ break;
+ }
}
#endif
@@ -484,38 +487,17 @@ network_state_cb (libnm_glib_ctx *context,
static gboolean
credentials_expiring (gpointer *data)
{
- int retval;
- gboolean give_up;
KaApplet* applet = KA_APPLET(data);
KA_DEBUG("Checking expiry <%ds", ka_applet_get_pw_prompt_secs(applet));
if (credentials_expiring_real (applet) && is_online) {
KA_DEBUG("Expiry @ %ld", creds_expiry);
- if (!ka_renew_credentials (applet)) {
+ if (!ka_renew_credentials (applet))
KA_DEBUG("Credentials renewed");
- goto out;
- }
-
- /* no popup when using a trayicon */
- if (ka_applet_get_show_trayicon(applet))
- goto out;
-
- give_up = canceled && (creds_expiry == canceled_creds_expiry);
- if (!give_up) {
- do {
- retval = grab_credentials (applet);
- give_up = canceled &&
- (creds_expiry == canceled_creds_expiry);
- } while ((retval != 0) &&
- (retval != KRB5_REALM_CANT_RESOLVE) &&
- (retval != KRB5_KDC_UNREACH) &&
- invalid_auth &&
- !give_up);
- }
}
-out:
ka_applet_update_status(applet, creds_expiry);
+
return TRUE;
}
@@ -845,7 +827,8 @@ ka_renew_credentials (KaApplet* applet)
my_creds.times.endtime);
}
out:
- creds_expiry = my_creds.times.endtime;
+ if (!retval)
+ creds_expiry = my_creds.times.endtime;
krb5_free_cred_contents (kcontext, &my_creds);
krb5_cc_close (kcontext, ccache);
return retval;
@@ -1033,10 +1016,10 @@ static void
ka_nm_shutdown(void)
{
#ifdef ENABLE_NETWORK_MANAGER
- if (nm_context) {
- libnm_glib_shutdown (nm_context);
- nm_context = NULL;
- }
+ if (nm_client) {
+ g_object_unref (nm_client);
+ nm_client = NULL;
+ }
#endif
}
@@ -1045,21 +1028,18 @@ static gboolean
ka_nm_init(void)
{
#ifdef ENABLE_NETWORK_MANAGER
- guint32 nm_callback_id;
-
- nm_context = libnm_glib_init ();
- if (!nm_context) {
- g_warning ("Could not initialize libnm_glib");
- } else {
- nm_callback_id = libnm_glib_register_callback (nm_context, network_state_cb, &is_online, NULL);
- if (nm_callback_id == 0) {
- ka_nm_shutdown ();
-
- g_warning ("Could not connect to NetworkManager, connection status will not be managed!");
- }
- }
+ nm_client = nm_client_new();
+ if (!nm_client) {
+ g_warning ("Could not initialize nm-client");
+ } else {
+ g_signal_connect(nm_client, "notify::state",
+ G_CALLBACK(ka_nm_client_state_changed_cb),
+ &is_online);
+ /* Set initial state */
+ ka_nm_client_state_changed_cb(nm_client, NULL, &is_online);
+ }
#endif /* ENABLE_NETWORK_MANAGER */
- return TRUE;
+ return TRUE;
}
@@ -1117,10 +1097,9 @@ main (int argc, char *argv[])
return 1;
ka_nm_init();
- if (credentials_expiring ((gpointer)applet)) {
- g_timeout_add_seconds (CREDENTIAL_CHECK_INTERVAL, (GSourceFunc)credentials_expiring, applet);
- monitor = monitor_ccache (applet);
- }
+ g_timeout_add_seconds (CREDENTIAL_CHECK_INTERVAL, (GSourceFunc)credentials_expiring, applet);
+ monitor = monitor_ccache (applet);
+
ka_dbus_service(applet);
gtk_main ();
}
diff --git a/src/ka-entry-buffer.c b/src/ka-entry-buffer.c
new file mode 100644
index 0000000..45587bf
--- /dev/null
+++ b/src/ka-entry-buffer.c
@@ -0,0 +1,229 @@
+/* Krb5 Auth Applet -- Acquire and release kerberos tickets
+ *
+ * (C) 2010 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.
+ *
+ */
+
+/* Create an entry buffer that uses the secmem routines for password storage */
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+#include <string.h>
+
+#include "ka-entry-buffer.h"
+#include "memory.h"
+
+struct _KaEntryBuffer {
+ GtkEntryBuffer parent;
+
+ KaEntryBufferPrivate *priv;
+};
+
+struct _KaEntryBufferClass {
+ GtkEntryBufferClass parent_class;
+};
+
+G_DEFINE_TYPE (KaEntryBuffer, ka_entry_buffer, GTK_TYPE_ENTRY_BUFFER)
+
+struct _KaEntryBufferPrivate {
+ gchar *password;
+ gsize password_size;
+ gsize password_bytes;
+ guint password_chars;
+};
+
+
+static const gchar *
+ka_entry_buffer_pw_get_text (GtkEntryBuffer *buffer,
+ gsize * n_bytes)
+{
+ KaEntryBuffer *self = KA_ENTRY_BUFFER(buffer);
+
+ if (n_bytes)
+ *n_bytes = self->priv->password_bytes;
+ if (!self->priv->password)
+ return "";
+ return self->priv->password;
+}
+
+
+static guint
+ka_entry_buffer_pw_get_length (GtkEntryBuffer *buffer)
+{
+ KaEntryBuffer *self = KA_ENTRY_BUFFER(buffer);
+ return self->priv->password_chars;
+}
+
+
+static guint
+ka_entry_buffer_pw_insert_text (GtkEntryBuffer *buffer,
+ guint position,
+ const gchar *chars,
+ guint n_chars)
+{
+ KaEntryBuffer *self = KA_ENTRY_BUFFER(buffer);
+ KaEntryBufferPrivate *pv = self->priv;
+ gsize prev_size;
+ gsize n_bytes;
+ gsize at;
+
+ n_bytes = g_utf8_offset_to_pointer (chars, n_chars) - chars;
+
+ /* Need more memory */
+ if (n_bytes + pv->password_bytes + 1 > pv->password_size) {
+ gchar *et_new;
+
+ prev_size = pv->password_size;
+
+ /* Calculate our new buffer size */
+ while (n_bytes + pv->password_bytes + 1 > pv->password_size) {
+ if (pv->password_size == 0)
+ pv->password_size = PW_MIN_SIZE;
+ else {
+ if (2 * pv->password_size < GTK_ENTRY_BUFFER_MAX_SIZE)
+ pv->password_size *= 2;
+ else {
+ pv->password_size = GTK_ENTRY_BUFFER_MAX_SIZE;
+ if (n_bytes >
+ pv->password_size - pv->password_bytes - 1) {
+ n_bytes =
+ pv->password_size - pv->password_bytes - 1;
+ n_bytes =
+ g_utf8_find_prev_char (chars,
+ chars + n_bytes + 1) -
+ chars;
+ n_chars = g_utf8_strlen (chars, n_bytes);
+ }
+ break;
+ }
+ }
+ }
+
+ et_new = secmem_malloc (pv->password_size);
+ memcpy (et_new, pv->password,
+ MIN (prev_size, pv->password_size));
+ secmem_free (pv->password);
+ pv->password = et_new;
+ }
+
+ /* Actual text insertion */
+ at = g_utf8_offset_to_pointer (pv->password,
+ position) - pv->password;
+ g_memmove (pv->password + at + n_bytes, pv->password + at,
+ pv->password_bytes - at);
+ memcpy (pv->password + at, chars, n_bytes);
+
+ /* Book keeping */
+ pv->password_bytes += n_bytes;
+ pv->password_chars += n_chars;
+ pv->password[pv->password_bytes] = '\0';
+
+ gtk_entry_buffer_emit_inserted_text (GTK_ENTRY_BUFFER(self), position, chars, n_chars);
+ return n_chars;
+}
+
+
+static guint
+ka_entry_buffer_pw_delete_text (GtkEntryBuffer *buffer,
+ guint position, guint n_chars)
+{
+ KaEntryBuffer *self = KA_ENTRY_BUFFER(buffer);
+ KaEntryBufferPrivate *pv = self->priv;
+ gsize start, end;
+
+ if (position > pv->password_chars)
+ position = pv->password_chars;
+ if (position + n_chars > pv->password_chars)
+ n_chars = pv->password_chars - position;
+
+ if (n_chars > 0) {
+ start =
+ g_utf8_offset_to_pointer (pv->password,
+ position) - pv->password;
+ end =
+ g_utf8_offset_to_pointer (pv->password,
+ position + n_chars) - pv->password;
+
+ g_memmove (pv->password + start, pv->password + end,
+ pv->password_bytes + 1 - end);
+ pv->password_chars -= n_chars;
+ pv->password_bytes -= (end - start);
+ gtk_entry_buffer_emit_deleted_text (GTK_ENTRY_BUFFER(self), position, n_chars);
+ }
+ return n_chars;
+}
+
+
+static void
+ka_entry_buffer_dispose (GObject *object)
+{
+ G_OBJECT_CLASS (ka_entry_buffer_parent_class)->dispose (object);
+}
+
+static void
+ka_entry_buffer_finalize (GObject *object)
+{
+ KaEntryBuffer *self = KA_ENTRY_BUFFER(object);
+
+ if (self->priv->password) {
+ secmem_free (self->priv->password);
+ self->priv->password_size = 0;
+ self->priv->password_bytes = 0;
+ self->priv->password_chars = 0;
+ }
+ G_OBJECT_CLASS (ka_entry_buffer_parent_class)->finalize (object);
+}
+
+static void
+ka_entry_buffer_class_init (KaEntryBufferClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkEntryBufferClass *eb_class = GTK_ENTRY_BUFFER_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (KaEntryBufferPrivate));
+
+ eb_class->get_text = ka_entry_buffer_pw_get_text;
+ eb_class->get_length = ka_entry_buffer_pw_get_length;
+ eb_class->insert_text = ka_entry_buffer_pw_insert_text;
+ eb_class->delete_text = ka_entry_buffer_pw_delete_text;
+
+ object_class->dispose = ka_entry_buffer_dispose;
+ object_class->finalize = ka_entry_buffer_finalize;
+}
+
+static void
+ka_entry_buffer_init (KaEntryBuffer *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE(self,
+ KA_TYPE_ENTRY_BUFFER,
+ KaEntryBufferPrivate);
+ self->priv->password = NULL;
+ self->priv->password_size = 0;
+ self->priv->password_bytes = 0;
+ self->priv->password_chars = 0;
+}
+
+KaEntryBuffer *
+ka_entry_buffer_new (void)
+{
+ return g_object_new (KA_TYPE_ENTRY_BUFFER, NULL);
+}
+
+/*
+ * vim:ts:sts=4:sw=4:et:
+ */
diff --git a/src/ka-entry-buffer.h b/src/ka-entry-buffer.h
new file mode 100644
index 0000000..5626ac4
--- /dev/null
+++ b/src/ka-entry-buffer.h
@@ -0,0 +1,58 @@
+/* Krb5 Auth Applet -- Acquire and release kerberos tickets
+ *
+ * (C) 2010 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_ENTRY_BUFFER_H
+#define KA_ENTRY_BUFFER_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define KA_TYPE_ENTRY_BUFFER ka_entry_buffer_get_type()
+
+#define KA_ENTRY_BUFFER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), KA_TYPE_ENTRY_BUFFER, KaEntryBuffer))
+
+#define KA_ENTRY_BUFFER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), KA_TYPE_ENTRY_BUFFER, KaEntryBufferClass))
+
+#define KA_IS_ENTRY_BUFFER(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KA_TYPE_ENTRY_BUFFER))
+
+#define KA_IS_ENTRY_BUFFER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), KA_TYPE_ENTRY_BUFFER))
+
+#define KA_ENTRY_BUFFER_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), KA_TYPE_ENTRY_BUFFER, KaEntryBufferClass))
+
+/* Minimum buffer size */
+#define PW_MIN_SIZE 32
+
+typedef struct _KaEntryBuffer KaEntryBuffer;
+typedef struct _KaEntryBufferClass KaEntryBufferClass;
+typedef struct _KaEntryBufferPrivate KaEntryBufferPrivate;
+
+GType ka_entry_buffer_get_type (void);
+
+KaEntryBuffer* ka_entry_buffer_new (void);
+
+G_END_DECLS
+
+#endif /* _KA_ENTRY_BUFFER */
diff --git a/src/ka-gconf.c b/src/ka-gconf.c
index 4e3d1aa..0735808 100644
--- a/src/ka-gconf.c
+++ b/src/ka-gconf.c
@@ -84,19 +84,6 @@ ka_gconf_set_prompt_mins (GConfClient* client, KaApplet* applet)
static gboolean
-ka_gconf_set_show_trayicon (GConfClient* client, KaApplet* applet)
-{
- gboolean show_trayicon = TRUE;
-
- if(!ka_gconf_get_bool(client, KA_GCONF_KEY_SHOW_TRAYICON, &show_trayicon)) {
- show_trayicon = TRUE;
- }
- g_object_set(applet, "show-trayicon", show_trayicon, NULL);
- return TRUE;
-}
-
-
-static gboolean
ka_gconf_set_tgt_forwardable (GConfClient* client, KaApplet* applet)
{
gboolean forwardable = FALSE;
@@ -153,8 +140,6 @@ ka_gconf_key_changed_callback (GConfClient* client,
ka_gconf_set_principal (client, applet);
} else if (g_strcmp0 (key, KA_GCONF_KEY_PROMPT_MINS) == 0) {
ka_gconf_set_prompt_mins (client, applet);
- } else if (g_strcmp0 (key, KA_GCONF_KEY_SHOW_TRAYICON) == 0) {
- ka_gconf_set_show_trayicon (client, applet);
} else if (g_strcmp0 (key, KA_GCONF_KEY_PK_USERID) == 0) {
ka_gconf_set_pk_userid (client, applet);
} else if (g_strcmp0 (key, KA_GCONF_KEY_PK_ANCHORS) == 0) {
@@ -195,7 +180,6 @@ ka_gconf_init (KaApplet* applet)
/* setup defaults */
ka_gconf_set_principal (client, applet);
ka_gconf_set_prompt_mins (client, applet);
- ka_gconf_set_show_trayicon (client, applet);
ka_gconf_set_pk_userid(client, applet);
ka_gconf_set_pk_anchors(client, applet);
ka_gconf_set_tgt_forwardable(client, applet);
diff --git a/src/ka-pwdialog.c b/src/ka-pwdialog.c
index da34471..0570ac2 100644
--- a/src/ka-pwdialog.c
+++ b/src/ka-pwdialog.c
@@ -25,6 +25,7 @@
#include "ka-applet-priv.h"
#include "ka-dialog.h"
#include "ka-pwdialog.h"
+#include "ka-entry-buffer.h"
struct _KaPwDialog {
GObject parent;
@@ -196,7 +197,7 @@ ka_pwdialog_hide (const KaPwDialog* pwdialog, gboolean force)
const gchar*
ka_pwdialog_get_password(KaPwDialog *pwdialog)
{
- return gtk_secure_entry_get_text (GTK_SECURE_ENTRY (pwdialog->priv->pw_entry));
+ return gtk_entry_get_text (GTK_ENTRY(pwdialog->priv->pw_entry));
}
gboolean
@@ -229,7 +230,6 @@ ka_pwdialog_setup (KaPwDialog* pwdialog, const gchar *krb5prompt,
{
KaPwDialogPrivate *priv = pwdialog->priv;
gchar *wrong_markup = NULL;
- GtkWidget *e;
gchar *prompt;
int pw4len;
@@ -251,13 +251,8 @@ ka_pwdialog_setup (KaPwDialog* pwdialog, const gchar *krb5prompt,
}
}
- e = gtk_entry_new ();
- gtk_secure_entry_set_invisible_char (GTK_SECURE_ENTRY (priv->pw_entry),
- gtk_entry_get_invisible_char (GTK_ENTRY (e)));
- gtk_widget_destroy (e);
-
/* Clear the password entry field */
- gtk_secure_entry_set_text (GTK_SECURE_ENTRY (priv->pw_entry), "");
+ gtk_entry_set_text (GTK_ENTRY (priv->pw_entry), "");
/* Use the prompt label that krb5 provides us */
gtk_label_set_text (GTK_LABEL (priv->krb_label), prompt);
@@ -292,18 +287,21 @@ KaPwDialog*
ka_pwdialog_create(GtkBuilder* xml)
{
KaPwDialog *pwdialog = ka_pwdialog_new();
+ KaEntryBuffer *buffer = ka_entry_buffer_new ();
KaPwDialogPrivate *priv = pwdialog->priv;
GtkWidget *entry_hbox = NULL;
priv->dialog = GTK_WIDGET (gtk_builder_get_object (xml, "krb5_dialog"));
priv->status_label = GTK_WIDGET (gtk_builder_get_object (xml, "krb5_status_label"));
priv->krb_label = GTK_WIDGET (gtk_builder_get_object (xml, "krb5_message_label"));
- priv->pw_entry = GTK_WIDGET (gtk_secure_entry_new ());
+ priv->pw_entry = GTK_WIDGET (gtk_entry_new_with_buffer (GTK_ENTRY_BUFFER(buffer)));
+ gtk_entry_set_visibility(GTK_ENTRY(priv->pw_entry), FALSE);
+ g_object_unref (buffer);
priv->error_dialog = ka_error_dialog_new();
entry_hbox = GTK_WIDGET (gtk_builder_get_object (xml, "entry_hbox"));
gtk_container_add (GTK_CONTAINER (entry_hbox), priv->pw_entry);
- gtk_secure_entry_set_activates_default (GTK_SECURE_ENTRY (priv->pw_entry), TRUE);
+ gtk_entry_set_activates_default (GTK_ENTRY (priv->pw_entry), TRUE);
gtk_widget_show (priv->pw_entry);
return pwdialog;
diff --git a/src/ka-pwdialog.h b/src/ka-pwdialog.h
index 8b39402..1c244f8 100644
--- a/src/ka-pwdialog.h
+++ b/src/ka-pwdialog.h
@@ -23,9 +23,9 @@
#include <glib.h>
#include <glib-object.h>
+#include <gtk/gtk.h>
#include "config.h"
-#include "gtksecentry.h"
G_BEGIN_DECLS
diff --git a/src/krb5-auth-dialog.desktop.in b/src/krb5-auth-dialog.desktop.in
index 6c83b31..5569646 100644
--- a/src/krb5-auth-dialog.desktop.in
+++ b/src/krb5-auth-dialog.desktop.in
@@ -1,9 +1,11 @@
[Desktop Entry]
-_Name=Network Authentication
+_Name=Kerberos Authentication
_Comment=Kerberos Network Authentication Dialog
Exec=krb5-auth-dialog
Terminal=false
Type=Application
+NoDisplay=true
+Icon=krb-valid-ticket
X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=krb5-auth-dialog
X-GNOME-Bugzilla-Component=general
diff --git a/src/krb5-auth-dialog.schemas.in b/src/krb5-auth-dialog.schemas.in
index bb59f8e..4a88f2b 100644
--- a/src/krb5-auth-dialog.schemas.in
+++ b/src/krb5-auth-dialog.schemas.in
@@ -1,19 +1,6 @@
<gconfschemafile>
<schemalist>
<schema>
- <key>/schemas/apps/krb5-auth-dialog/show_trayicon</key>
- <applyto>/apps/krb5-auth-dialog/show_trayicon</applyto>
- <owner>krb5-auth-dialog</owner>
- <type>bool</type>
- <default>1</default>
-
- <locale name="C">
- <short>Show trayicon</short>
- <long>Show a trayicon in the status area of the panel</long>
- </locale>
- </schema>
-
- <schema>
<key>/schemas/apps/krb5-auth-dialog/principal</key>
<applyto>/apps/krb5-auth-dialog/principal</applyto>
<owner>krb5-auth-dialog</owner>
diff --git a/src/krb5-auth-dialog.xml b/src/krb5-auth-dialog.xml
index 0df79ef..f36f537 100644
--- a/src/krb5-auth-dialog.xml
+++ b/src/krb5-auth-dialog.xml
@@ -4,11 +4,10 @@
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkDialog" id="krb5_dialog">
<property name="border_width">6</property>
- <property name="title" translatable="yes">Network Authentication</property>
+ <property name="title" translatable="yes">Kerberos Authentication</property>
<property name="resizable">False</property>
<property name="window_position">center-always</property>
<property name="type_hint">dialog</property>
- <property name="has_separator">False</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox2">
<property name="visible">True</property>
@@ -157,7 +156,6 @@
<property name="title" translatable="yes">Service Tickets</property>
<property name="resizable">False</property>
<property name="type_hint">normal</property>
- <property name="has_separator">False</property>
<child internal-child="vbox">
<object class="GtkVBox" id="tickets-vbox2">
<property name="visible">True</property>
bgstack15