From d0f7048e94abe3371aeeba6f5cd115959e332b09 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Sun, 1 Mar 2009 15:00:15 +0100 Subject: Imported Upstream version 0.8+svn128 --- src/.cvsignore | 5 + src/Makefile.am | 23 +- src/Makefile.in | 710 ------------------------------------------ src/dummy-strings.c | 4 +- src/krb5-auth-applet-dbus.xml | 14 + src/krb5-auth-applet.c | 464 ++++++++++++++++++++++----- src/krb5-auth-applet.h | 59 ++-- src/krb5-auth-dbus.c | 32 +- src/krb5-auth-dbus.h | 7 + src/krb5-auth-dialog.c | 202 ++++++++---- src/krb5-auth-dialog.h | 4 +- src/krb5-auth-gconf.c | 55 ++-- src/krb5-auth-gconf.h | 2 +- src/krb5-auth-notify.c | 66 ---- src/krb5-auth-notify.h | 28 -- 15 files changed, 671 insertions(+), 1004 deletions(-) create mode 100644 src/.cvsignore delete mode 100644 src/Makefile.in create mode 100644 src/krb5-auth-applet-dbus.xml delete mode 100644 src/krb5-auth-notify.c delete mode 100644 src/krb5-auth-notify.h (limited to 'src') diff --git a/src/.cvsignore b/src/.cvsignore new file mode 100644 index 0000000..b18d7e7 --- /dev/null +++ b/src/.cvsignore @@ -0,0 +1,5 @@ +Makefile +Makefile.in +krb5-auth-dialog +krb5-auth-dialog.1 +krb5-auth-dialog.desktop diff --git a/src/Makefile.am b/src/Makefile.am index 18ab709..1ff6ac0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,5 +1,5 @@ INCLUDES = \ - -DGLADEDIR=\""$(gladedir)/"\" \ + -DKA_DATA_DIR=\""$(pkgdatadir)"\" \ -DLOCALE_DIR=\""$(localedir)/"\" bin_PROGRAMS = krb5-auth-dialog @@ -24,8 +24,6 @@ krb5_auth_dialog_SOURCES = \ krb5-auth-applet.h \ krb5-auth-gconf.c \ krb5-auth-gconf.h \ - krb5-auth-notify.c \ - krb5-auth-notify.h \ krb5-auth-dbus.c \ krb5-auth-dbus.h \ dummy-strings.c @@ -41,17 +39,28 @@ krb5_auth_dialog_LDADD = \ @GLADE_LIBS@ \ @GTK_LIBS@ +BUILT_SOURCES = \ + krb5-auth-applet-dbus-glue.h + +krb5-auth-applet-dbus-glue.h: $(srcdir)/krb5-auth-applet-dbus.xml + dbus-binding-tool \ + --mode=glib-server \ + --prefix=krb5_auth_dialog \ + $< > $@ + AM_CPPFLAGS = -I $(top_srcdir)/gtksecentry/ -I $(top_srcdir)/secmem/ -gladedir = $(datadir)/krb5-auth-dialog -glade_DATA = \ +pkgdatadir = $(datadir)/krb5-auth-dialog +pkgdata_DATA = \ krb5-auth-dialog.glade EXTRA_DIST = \ - $(glade_DATA) \ + $(pkgdata_DATA) \ $(schema_in_files) \ $(autostart_in_files) \ krb5-auth-dialog.1.in CLEANFILES = $(schema_DATA) -DISTCLEANFILES = krb5-auth-dialog.desktop +DISTCLEANFILES = \ + krb5-auth-dialog.desktop \ + krb5-auth-applet-dbus-glue.h diff --git a/src/Makefile.in b/src/Makefile.in deleted file mode 100644 index d7ca9ac..0000000 --- a/src/Makefile.in +++ /dev/null @@ -1,710 +0,0 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - - -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -bin_PROGRAMS = krb5-auth-dialog$(EXEEXT) -subdir = src -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - $(srcdir)/krb5-auth-dialog.1.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ - $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = krb5-auth-dialog.1 -am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" \ - "$(DESTDIR)$(autostartdir)" "$(DESTDIR)$(gladedir)" \ - "$(DESTDIR)$(schemadir)" -binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) -PROGRAMS = $(bin_PROGRAMS) -am_krb5_auth_dialog_OBJECTS = krb5-auth-dialog.$(OBJEXT) \ - krb5-auth-applet.$(OBJEXT) krb5-auth-gconf.$(OBJEXT) \ - krb5-auth-notify.$(OBJEXT) krb5-auth-dbus.$(OBJEXT) \ - dummy-strings.$(OBJEXT) -krb5_auth_dialog_OBJECTS = $(am_krb5_auth_dialog_OBJECTS) -krb5_auth_dialog_DEPENDENCIES = ../gtksecentry/libgtksecentry.a \ - ../secmem/libsecmem.a -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ - $(LDFLAGS) -o $@ -SOURCES = $(krb5_auth_dialog_SOURCES) -DIST_SOURCES = $(krb5_auth_dialog_SOURCES) -man1dir = $(mandir)/man1 -NROFF = nroff -MANS = $(man_MANS) -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; -autostartDATA_INSTALL = $(INSTALL_DATA) -gladeDATA_INSTALL = $(INSTALL_DATA) -schemaDATA_INSTALL = $(INSTALL_DATA) -DATA = $(autostart_DATA) $(glade_DATA) $(schema_DATA) -ETAGS = etags -CTAGS = ctags -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CATALOGS = @CATALOGS@ -CATOBJEXT = @CATOBJEXT@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DATADIRNAME = @DATADIRNAME@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DSYMUTIL = @DSYMUTIL@ -ECHO = @ECHO@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -F77 = @F77@ -FFLAGS = @FFLAGS@ -GCONF_CFLAGS = @GCONF_CFLAGS@ -GCONF_LIBS = @GCONF_LIBS@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLADE_CFLAGS = @GLADE_CFLAGS@ -GLADE_LIBS = @GLADE_LIBS@ -GMOFILES = @GMOFILES@ -GMSGFMT = @GMSGFMT@ -GREP = @GREP@ -GTK_CFLAGS = @GTK_CFLAGS@ -GTK_LIBS = @GTK_LIBS@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INSTOBJEXT = @INSTOBJEXT@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_CAVES_RULE = @INTLTOOL_CAVES_RULE@ -INTLTOOL_DESKTOP_RULE = @INTLTOOL_DESKTOP_RULE@ -INTLTOOL_DIRECTORY_RULE = @INTLTOOL_DIRECTORY_RULE@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_KBD_RULE = @INTLTOOL_KBD_RULE@ -INTLTOOL_KEYS_RULE = @INTLTOOL_KEYS_RULE@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_OAF_RULE = @INTLTOOL_OAF_RULE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_POLICY_RULE = @INTLTOOL_POLICY_RULE@ -INTLTOOL_PONG_RULE = @INTLTOOL_PONG_RULE@ -INTLTOOL_PROP_RULE = @INTLTOOL_PROP_RULE@ -INTLTOOL_SCHEMAS_RULE = @INTLTOOL_SCHEMAS_RULE@ -INTLTOOL_SERVER_RULE = @INTLTOOL_SERVER_RULE@ -INTLTOOL_SERVICE_RULE = @INTLTOOL_SERVICE_RULE@ -INTLTOOL_SHEET_RULE = @INTLTOOL_SHEET_RULE@ -INTLTOOL_SOUNDLIST_RULE = @INTLTOOL_SOUNDLIST_RULE@ -INTLTOOL_THEME_RULE = @INTLTOOL_THEME_RULE@ -INTLTOOL_UI_RULE = @INTLTOOL_UI_RULE@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_XAM_RULE = @INTLTOOL_XAM_RULE@ -INTLTOOL_XML_NOMERGE_RULE = @INTLTOOL_XML_NOMERGE_RULE@ -INTLTOOL_XML_RULE = @INTLTOOL_XML_RULE@ -KRB5_CFLAGS = @KRB5_CFLAGS@ -KRB5_CONFIG = @KRB5_CONFIG@ -KRB5_LIBS = @KRB5_LIBS@ -LDFLAGS = @LDFLAGS@ -LEX = @LEX@ -LEXLIB = @LEXLIB@ -LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -LIBCAP = @LIBCAP@ -LIBNOTIFY_CFLAGS = @LIBNOTIFY_CFLAGS@ -LIBNOTIFY_LIBS = @LIBNOTIFY_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MKDIR_P = @MKDIR_P@ -MKINSTALLDIRS = @MKINSTALLDIRS@ -MSGFMT = @MSGFMT@ -MSGFMT_OPTS = @MSGFMT_OPTS@ -MSGMERGE = @MSGMERGE@ -NETWORK_MANAGER_CFLAGS = @NETWORK_MANAGER_CFLAGS@ -NETWORK_MANAGER_LIBS = @NETWORK_MANAGER_LIBS@ -NMEDIT = @NMEDIT@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PKG_CONFIG = @PKG_CONFIG@ -POFILES = @POFILES@ -POSUB = @POSUB@ -PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ -PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ -RANLIB = @RANLIB@ -SED = @SED@ -SETCAP = @SETCAP@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -USE_NLS = @USE_NLS@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -YACC = @YACC@ -YFLAGS = @YFLAGS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_F77 = @ac_ct_F77@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -check_interval = @check_interval@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -minimum_lifetime = @minimum_lifetime@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -INCLUDES = \ - -DGLADEDIR=\""$(gladedir)/"\" \ - -DLOCALE_DIR=\""$(localedir)/"\" - -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) -schemadir = $(sysconfdir)/gconf/schemas -schema_in_files = $(PACKAGE).schemas.in -schema_DATA = $(PACKAGE).schemas -krb5_auth_dialog_SOURCES = \ - krb5-auth-dialog.c \ - krb5-auth-dialog.h \ - krb5-auth-applet.c \ - krb5-auth-applet.h \ - krb5-auth-gconf.c \ - krb5-auth-gconf.h \ - krb5-auth-notify.c \ - krb5-auth-notify.h \ - krb5-auth-dbus.c \ - krb5-auth-dbus.h \ - dummy-strings.c - -krb5_auth_dialog_LDADD = \ - ../gtksecentry/libgtksecentry.a \ - ../secmem/libsecmem.a \ - @NETWORK_MANAGER_LIBS@ \ - @KRB5_LIBS@ \ - @LIBNOTIFY_LIBS@ \ - @DBUS_LIBS@ \ - @GCONF_LIBS@ \ - @GLADE_LIBS@ \ - @GTK_LIBS@ - -AM_CPPFLAGS = -I $(top_srcdir)/gtksecentry/ -I $(top_srcdir)/secmem/ -gladedir = $(datadir)/krb5-auth-dialog -glade_DATA = \ - krb5-auth-dialog.glade - -EXTRA_DIST = \ - $(glade_DATA) \ - $(schema_in_files) \ - $(autostart_in_files) \ - krb5-auth-dialog.1.in - -CLEANFILES = $(schema_DATA) -DISTCLEANFILES = krb5-auth-dialog.desktop -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -krb5-auth-dialog.1: $(top_builddir)/config.status $(srcdir)/krb5-auth-dialog.1.in - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ -install-binPROGRAMS: $(bin_PROGRAMS) - @$(NORMAL_INSTALL) - test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" - @list='$(bin_PROGRAMS)'; for p in $$list; do \ - p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ - if test -f $$p \ - || test -f $$p1 \ - ; then \ - f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ - echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ - $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ - else :; fi; \ - done - -uninstall-binPROGRAMS: - @$(NORMAL_UNINSTALL) - @list='$(bin_PROGRAMS)'; for p in $$list; do \ - f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ - echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ - rm -f "$(DESTDIR)$(bindir)/$$f"; \ - done - -clean-binPROGRAMS: - @list='$(bin_PROGRAMS)'; for p in $$list; do \ - f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f $$p $$f"; \ - rm -f $$p $$f ; \ - done -krb5-auth-dialog$(EXEEXT): $(krb5_auth_dialog_OBJECTS) $(krb5_auth_dialog_DEPENDENCIES) - @rm -f krb5-auth-dialog$(EXEEXT) - $(LINK) $(krb5_auth_dialog_OBJECTS) $(krb5_auth_dialog_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dummy-strings.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/krb5-auth-applet.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/krb5-auth-dbus.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/krb5-auth-dialog.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/krb5-auth-gconf.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/krb5-auth-notify.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c $< - -.c.obj: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs -install-man1: $(man1_MANS) $(man_MANS) - @$(NORMAL_INSTALL) - test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)" - @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \ - l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ - for i in $$l2; do \ - case "$$i" in \ - *.1*) list="$$list $$i" ;; \ - esac; \ - done; \ - for i in $$list; do \ - if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ - else file=$$i; fi; \ - ext=`echo $$i | sed -e 's/^.*\\.//'`; \ - case "$$ext" in \ - 1*) ;; \ - *) ext='1' ;; \ - esac; \ - inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ - inst=`echo $$inst | sed -e 's/^.*\///'`; \ - inst=`echo $$inst | sed '$(transform)'`.$$ext; \ - echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ - $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst"; \ - done -uninstall-man1: - @$(NORMAL_UNINSTALL) - @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \ - l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ - for i in $$l2; do \ - case "$$i" in \ - *.1*) list="$$list $$i" ;; \ - esac; \ - done; \ - for i in $$list; do \ - ext=`echo $$i | sed -e 's/^.*\\.//'`; \ - case "$$ext" in \ - 1*) ;; \ - *) ext='1' ;; \ - esac; \ - inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ - inst=`echo $$inst | sed -e 's/^.*\///'`; \ - inst=`echo $$inst | sed '$(transform)'`.$$ext; \ - echo " rm -f '$(DESTDIR)$(man1dir)/$$inst'"; \ - rm -f "$(DESTDIR)$(man1dir)/$$inst"; \ - done -install-autostartDATA: $(autostart_DATA) - @$(NORMAL_INSTALL) - test -z "$(autostartdir)" || $(MKDIR_P) "$(DESTDIR)$(autostartdir)" - @list='$(autostart_DATA)'; for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - f=$(am__strip_dir) \ - echo " $(autostartDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(autostartdir)/$$f'"; \ - $(autostartDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(autostartdir)/$$f"; \ - done - -uninstall-autostartDATA: - @$(NORMAL_UNINSTALL) - @list='$(autostart_DATA)'; for p in $$list; do \ - f=$(am__strip_dir) \ - echo " rm -f '$(DESTDIR)$(autostartdir)/$$f'"; \ - rm -f "$(DESTDIR)$(autostartdir)/$$f"; \ - done -install-gladeDATA: $(glade_DATA) - @$(NORMAL_INSTALL) - test -z "$(gladedir)" || $(MKDIR_P) "$(DESTDIR)$(gladedir)" - @list='$(glade_DATA)'; for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - f=$(am__strip_dir) \ - echo " $(gladeDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(gladedir)/$$f'"; \ - $(gladeDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(gladedir)/$$f"; \ - done - -uninstall-gladeDATA: - @$(NORMAL_UNINSTALL) - @list='$(glade_DATA)'; for p in $$list; do \ - f=$(am__strip_dir) \ - echo " rm -f '$(DESTDIR)$(gladedir)/$$f'"; \ - rm -f "$(DESTDIR)$(gladedir)/$$f"; \ - done -install-schemaDATA: $(schema_DATA) - @$(NORMAL_INSTALL) - test -z "$(schemadir)" || $(MKDIR_P) "$(DESTDIR)$(schemadir)" - @list='$(schema_DATA)'; for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - f=$(am__strip_dir) \ - echo " $(schemaDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(schemadir)/$$f'"; \ - $(schemaDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(schemadir)/$$f"; \ - done - -uninstall-schemaDATA: - @$(NORMAL_UNINSTALL) - @list='$(schema_DATA)'; for p in $$list; do \ - f=$(am__strip_dir) \ - echo " rm -f '$(DESTDIR)$(schemadir)/$$f'"; \ - rm -f "$(DESTDIR)$(schemadir)/$$f"; \ - done - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique; \ - fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$tags$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$tags $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && cd $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) $$here - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(PROGRAMS) $(MANS) $(DATA) -installdirs: - for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(autostartdir)" "$(DESTDIR)$(gladedir)" "$(DESTDIR)$(schemadir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -info: info-am - -info-am: - -install-data-am: install-autostartDATA install-gladeDATA install-man \ - install-schemaDATA - -install-dvi: install-dvi-am - -install-exec-am: install-binPROGRAMS - -install-html: install-html-am - -install-info: install-info-am - -install-man: install-man1 - -install-pdf: install-pdf-am - -install-ps: install-ps-am - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-autostartDATA uninstall-binPROGRAMS \ - uninstall-gladeDATA uninstall-man uninstall-schemaDATA - -uninstall-man: uninstall-man1 - -.MAKE: install-am install-strip - -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ - clean-generic clean-libtool ctags distclean distclean-compile \ - 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-dvi install-dvi-am install-exec \ - install-exec-am install-gladeDATA install-html install-html-am \ - install-info install-info-am install-man install-man1 \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-schemaDATA 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-gladeDATA uninstall-man uninstall-man1 \ - uninstall-schemaDATA - -@INTLTOOL_DESKTOP_RULE@ - -%.schemas: $(srcdir)/%.schemas.in - sed -e "s,::PACKAGE::,$(PACKAGE)," < $< > $@ -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/dummy-strings.c b/src/dummy-strings.c index e107293..6f29d54 100644 --- a/src/dummy-strings.c +++ b/src/dummy-strings.c @@ -132,7 +132,7 @@ realm %s. %s."), /* kpasswd_strings.et:kpws:KPW_STR_CANT_OPEN_ADMIN_SERVER */ N_("while releasing permanent lock"), /* import_err.et:imp:IMPORT_RENAME_UNLOCK */ N_("while closing databases"), /* import_err.et:imp:IMPORT_RENAME_CLOSE */ N_("while retrieving configuration parameters"), /* import_err.et:imp:IMPORT_GET_PARAMS */ - N_("$Id$"), /* kdc5_err.et:kdc5:KDC5_RCSID */ + N_("$Id: dummy-strings.c 35 2005-10-31 21:55:46Z caillon $"), /* kdc5_err.et:kdc5:KDC5_RCSID */ N_("No server port found"), /* kdc5_err.et:kdc5:KDC5_NOPORT */ N_("Network not initialized"), /* kdc5_err.et:kdc5:KDC5_NONET */ N_("Short write while sending response"), /* kdc5_err.et:kdc5:KDC5_IO_RESPONSE */ @@ -385,7 +385,7 @@ realm %s. %s."), /* kpasswd_strings.et:kpws:KPW_STR_CANT_OPEN_ADMIN_SERVER */ N_("Bad magic number for passwd_phrase_element"), /* kv5m_err.et:kv5m:KV5M_PASSWD_PHRASE_ELEMENT */ N_("Bad magic number for GSSAPI OID"), /* kv5m_err.et:kv5m:KV5M_GSS_OID */ N_("Bad magic number for GSSAPI QUEUE"), /* kv5m_err.et:kv5m:KV5M_GSS_QUEUE */ - N_("$Id$"), /* kdb5_err.et:kdb5:KRB5_KDB_RCSID */ + N_("$Id: dummy-strings.c 35 2005-10-31 21:55:46Z caillon $"), /* kdb5_err.et:kdb5:KRB5_KDB_RCSID */ N_("Entry already exists in database"), /* kdb5_err.et:kdb5:KRB5_KDB_INUSE */ N_("Database store error"), /* kdb5_err.et:kdb5:KRB5_KDB_UK_SERROR */ N_("Database read error"), /* kdb5_err.et:kdb5:KRB5_KDB_UK_RERROR */ diff --git a/src/krb5-auth-applet-dbus.xml b/src/krb5-auth-applet-dbus.xml new file mode 100644 index 0000000..eeb151d --- /dev/null +++ b/src/krb5-auth-applet-dbus.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/krb5-auth-applet.c b/src/krb5-auth-applet.c index c915240..996d862 100644 --- a/src/krb5-auth-applet.c +++ b/src/krb5-auth-applet.c @@ -1,6 +1,6 @@ /* Krb5 Auth Applet -- Acquire and release kerberos tickets * - * (C) 2008 Guido Guenther + * (C) 2008,2009 Guido Guenther * * 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 @@ -24,7 +24,9 @@ #include "krb5-auth-applet.h" #include "krb5-auth-dialog.h" -#include "krb5-auth-notify.h" +#ifdef HAVE_LIBNOTIFY +#include +#endif #define NOTIFY_SECONDS 300 @@ -34,10 +36,222 @@ enum ka_icon { val_icon, }; +enum +{ + KA_PROP_0 = 0, + KA_PROP_PRINCIPAL, + KA_PROP_PK_USERID, + KA_PROP_TRAYICON, + KA_PROP_PW_PROMPT_MINS, +}; + +struct _KaApplet { + GObject parent; + + KaAppletPrivate *priv; +}; + +struct _KaAppletClass { + GObjectClass parent; +}; + +G_DEFINE_TYPE(KaApplet, ka_applet, G_TYPE_OBJECT); + +struct _KaAppletPrivate +{ + 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 */ + + /* The password dialog */ + GtkWidget* pw_dialog; /* the password dialog itself */ + GladeXML* pw_xml; /* the dialog's glade xml */ + GtkWidget* pw_label; /* the wrong password/timeout label */ + int pw_prompt_secs; /* when to start prompting for a password */ + gboolean pw_dialog_persist; /* don't hide the dialog when creds are still valid */ + +#ifdef HAVE_LIBNOTIFY + NotifyNotification* notification;/* notification messages */ +#endif /* HAVE_LIBNOTIFY */ + char* principal; /* the principal to request */ + gboolean renewable; /* credentials renewable? */ + char* pk_userid; /* "userid" for pkint */ +}; + +static void +ka_applet_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + KaApplet* self = KA_APPLET (object); + + 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_TRAYICON: + self->priv->show_trayicon = g_value_get_boolean (value); + KA_DEBUG ("%s: %s", pspec->name, self->priv->show_trayicon ? "True" : "False"); + 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; + + default: + /* 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, + GParamSpec *pspec) +{ + KaApplet *self = KA_APPLET (object); + + switch (property_id) + { + case KA_PROP_PRINCIPAL: + g_value_set_string (value, self->priv->principal); + break; + + case KA_PROP_PK_USERID: + g_value_set_string (value, self->priv->pk_userid); + break; + + case KA_PROP_TRAYICON: + g_value_set_boolean (value, self->priv->show_trayicon); + break; + + case KA_PROP_PW_PROMPT_MINS: + g_value_set_uint (value, self->priv->pw_prompt_secs / 60); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + + +static void +ka_applet_dispose(GObject* object) +{ + KaApplet* applet = KA_APPLET(object); + GObjectClass *parent_class = G_OBJECT_CLASS (ka_applet_parent_class); + + if (applet->priv->tray_icon) { + g_object_unref(applet->priv->tray_icon); + applet->priv->tray_icon = NULL; + } + if (applet->priv->pw_xml) { + g_object_unref(applet->priv->pw_xml); + applet->priv->pw_xml = NULL; + } + + if (parent_class->dispose != NULL) + parent_class->dispose (object); +} + + +static void +ka_applet_finalize(GObject *object) +{ + 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); + /* no need to free applet->priv */ + + if (parent_class->finalize != NULL) + parent_class->finalize (object); +} + +static void +ka_applet_init(KaApplet *applet) +{ + 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; + + 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_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); +} + + +KaApplet *ka_applet_new(void) +{ + return g_object_new (KA_TYPE_APPLET, NULL); +} + /* determine the new tooltip text */ static char* -ka_tooltip_text(Krb5AuthApplet* applet, int remaining) +ka_applet_tooltip_text(KaApplet* applet, int remaining) { int hours, minutes; gchar* tooltip_text; @@ -62,32 +276,64 @@ ka_tooltip_text(Krb5AuthApplet* applet, int remaining) /* determine the current icon */ static const char* -ka_select_icon(Krb5AuthApplet* applet, int remaining) +ka_applet_select_icon(KaApplet* applet, int remaining) { enum ka_icon tray_icon = inv_icon; if (remaining > 0) { - if (remaining < applet->pw_prompt_secs && - !applet->renewable) + if (remaining < applet->priv->pw_prompt_secs && + !applet->priv->renewable) tray_icon = exp_icon; else tray_icon = val_icon; } - return applet->icons[tray_icon]; + return applet->priv->icons[tray_icon]; +} + + +void +ka_send_event_notification (KaApplet *applet __attribute__((__unused__)), + const char *summary __attribute__((__unused__)), + const char *message __attribute__((__unused__)), + const char *icon __attribute__((__unused__))) +{ +#ifdef HAVE_LIBNOTIFY + const char *notify_icon; + + 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) { + notify_notification_close (applet->priv->notification, NULL); + g_object_unref (applet->priv->notification); + } + + notify_icon = icon ? icon : "gtk-dialog-authentication"; + + 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_show (applet->priv->notification, NULL); +#endif /* HAVE_LIBNOTIFY */ } /* update the tray icon's tooltip and icon */ int -ka_update_status(Krb5AuthApplet* applet, krb5_timestamp expiry) +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; - const char* tray_icon = ka_select_icon (applet, remaining); - char* tooltip_text = ka_tooltip_text (applet, remaining); + const char* tray_icon = ka_applet_select_icon (applet, remaining); + char* tooltip_text = ka_applet_tooltip_text (applet, remaining); if (remaining > 0) { if (expiry_notified) { @@ -95,8 +341,8 @@ ka_update_status(Krb5AuthApplet* applet, krb5_timestamp expiry) _("Network credentials valid"), _("Your Kerberos credentials have been refreshed."), NULL); expiry_notified = FALSE; - } else if (remaining < applet->pw_prompt_secs && (now - last_warn) > NOTIFY_SECONDS && - !applet->renewable) { + } else if (remaining < applet->priv->pw_prompt_secs && (now - last_warn) > NOTIFY_SECONDS && + !applet->priv->renewable) { ka_send_event_notification (applet, _("Network credentials expiring"), tooltip_text, NULL); @@ -112,54 +358,53 @@ ka_update_status(Krb5AuthApplet* applet, krb5_timestamp expiry) } } - gtk_status_icon_set_from_icon_name (applet->tray_icon, tray_icon); - gtk_status_icon_set_tooltip (applet->tray_icon, tooltip_text); + gtk_status_icon_set_from_icon_name (applet->priv->tray_icon, tray_icon); + gtk_status_icon_set_tooltip (applet->priv->tray_icon, tooltip_text); g_free(tooltip_text); return 0; } static void -ka_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); } /* Free all resources and quit */ static void -ka_quit_applet (GtkMenuItem* menuitem, gpointer user_data) +ka_applet_cb_quit (GtkMenuItem* menuitem, gpointer user_data) { - Krb5AuthApplet* applet = (Krb5AuthApplet*) user_data; + KaApplet* applet = KA_APPLET(user_data); - g_free (applet->principal); - g_free (applet); + g_object_unref (applet); gtk_main_quit (); } static void -ka_about_dialog (GtkMenuItem* menuitem, gpointer user_data) +ka_applet_cb_about_dialog (GtkMenuItem* menuitem, gpointer user_data) { gchar* authors[] = { "Christopher Aillon ", "Colin Walters ", - "Guido Günther ", + "Guido Günther ", NULL }; gtk_show_about_dialog (NULL, - "authors", authors, - "version", VERSION, - "copyright", "Copyright (C) 2004,2005,2006 Red Hat, Inc.,\n2008 Guido Günther", - NULL); + "authors", authors, + "version", VERSION, + "copyright", "Copyright (C) 2004,2005,2006 Red Hat, Inc.,\n2008,2009 Guido Günther", + NULL); } /* The tray icon's context menu */ -static GtkWidget* -ka_create_context_menu (Krb5AuthApplet* applet) +static gboolean +ka_applet_create_context_menu (KaApplet* applet) { GtkWidget* menu; GtkWidget* menu_item; @@ -170,43 +415,44 @@ ka_create_context_menu (Krb5AuthApplet* applet) /* kdestroy */ menu_item = gtk_image_menu_item_new_with_mnemonic (_("Remove Credentials _Cache")); g_signal_connect (G_OBJECT (menu_item), "activate", G_CALLBACK (ka_destroy_cache), 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); + 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_menu_add_separator_item (menu); + ka_applet_menu_add_separator_item (menu); /* About item */ menu_item = gtk_image_menu_item_new_with_mnemonic (_("_About")); - g_signal_connect (G_OBJECT (menu_item), "activate", G_CALLBACK (ka_about_dialog), applet); + g_signal_connect (G_OBJECT (menu_item), "activate", G_CALLBACK (ka_applet_cb_about_dialog), applet); image = gtk_image_new_from_stock (GTK_STOCK_ABOUT, 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_menu_add_separator_item (menu); + ka_applet_menu_add_separator_item (menu); /* Quit */ menu_item = gtk_image_menu_item_new_with_mnemonic (_("_Quit")); - g_signal_connect (G_OBJECT (menu_item), "activate", G_CALLBACK (ka_quit_applet), applet); - image = gtk_image_new_from_stock (GTK_STOCK_QUIT, GTK_ICON_SIZE_MENU); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image); + g_signal_connect (G_OBJECT (menu_item), "activate", G_CALLBACK (ka_applet_cb_quit), applet); + image = gtk_image_new_from_stock (GTK_STOCK_QUIT, 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); gtk_widget_show_all (menu); + applet->priv->context_menu = menu; - return menu; + return TRUE; } static void ka_tray_icon_on_menu (GtkStatusIcon* status_icon, guint button, - guint activate_time, gpointer user_data) + guint activate_time, gpointer user_data) { - Krb5AuthApplet* applet = (Krb5AuthApplet*) user_data; + KaApplet *applet = KA_APPLET(user_data); - KA_DEBUG("Trayicon right clicked: %d", applet->pw_prompt_secs); - gtk_menu_popup (GTK_MENU (applet->context_menu), NULL, NULL, - gtk_status_icon_position_menu, applet->tray_icon, + 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); } @@ -214,67 +460,143 @@ ka_tray_icon_on_menu (GtkStatusIcon* status_icon, guint button, static gboolean ka_tray_icon_on_click (GtkStatusIcon* status_icon, gpointer data) { - Krb5AuthApplet* applet = (Krb5AuthApplet*) data; - g_return_val_if_fail (applet != NULL, FALSE); + KaApplet *applet = KA_APPLET(data); - KA_DEBUG("Trayicon clicked: %d", applet->pw_prompt_secs); + KA_DEBUG("Trayicon clicked: %d", applet->priv->pw_prompt_secs); ka_grab_credentials (applet); return TRUE; } -gboolean -ka_show_tray_icon (Krb5AuthApplet* applet) +static gboolean +ka_applet_cb_show_trayicon (KaApplet* applet, GParamSpec* property, gpointer data) { g_return_val_if_fail (applet != NULL, FALSE); - g_return_val_if_fail (applet->tray_icon != NULL, FALSE); + g_return_val_if_fail (applet->priv->tray_icon != NULL, FALSE); - gtk_status_icon_set_visible (applet->tray_icon, applet->show_trayicon); + gtk_status_icon_set_visible (applet->priv->tray_icon, applet->priv->show_trayicon); return TRUE; } -static GtkStatusIcon* -ka_create_tray_icon (Krb5AuthApplet* applet) +static gboolean +ka_applet_create_tray_icon (KaApplet* applet) { GtkStatusIcon* tray_icon; tray_icon = gtk_status_icon_new (); + g_signal_connect (G_OBJECT(tray_icon), "activate", - G_CALLBACK(ka_tray_icon_on_click), applet); + 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->icons[exp_icon]); - gtk_status_icon_set_tooltip (tray_icon, PACKAGE); - return tray_icon; + gtk_status_icon_set_from_icon_name (tray_icon, applet->priv->icons[exp_icon]); + gtk_status_icon_set_tooltip (tray_icon, PACKAGE); + applet->priv->tray_icon = tray_icon; + return TRUE; } -int -ka_setup_icons (Krb5AuthApplet* applet) +static int +ka_applet_setup_icons (KaApplet* applet) +{ + /* Add application specific icons to search path */ + gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), + KA_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; +} + + +static gboolean +ka_applet_glade_init(KaApplet *applet) { - applet->icons[val_icon] = "krb-valid-ticket"; - applet->icons[exp_icon] = "krb-expiring-ticket"; - applet->icons[inv_icon] = "krb-no-valid-ticket"; + KaAppletPrivate *priv = applet->priv; + + priv->pw_xml = glade_xml_new (KA_DATA_DIR G_DIR_SEPARATOR_S + PACKAGE ".glade", NULL, NULL); + priv->pw_label = glade_xml_get_widget (priv->pw_xml, "krb5_wrong_label"); + priv->pw_dialog = glade_xml_get_widget (priv->pw_xml, "krb5_dialog"); + return TRUE; } +GladeXML* +ka_applet_get_pwdialog_xml(const KaApplet* applet) +{ + return applet->priv->pw_xml; +} + +guint +ka_applet_get_pw_prompt_secs(const KaApplet* applet) +{ + return applet->priv->pw_prompt_secs; +} + +gboolean +ka_applet_get_show_trayicon(const KaApplet* applet) +{ + return applet->priv->show_trayicon; +} + +void +ka_applet_set_tgt_renewable(KaApplet* applet, gboolean renewable) +{ + applet->priv->renewable = renewable; +} + +gboolean +ka_applet_get_tgt_renewable(const KaApplet* applet) +{ + return applet->priv->renewable; +} + +gint ka_applet_run_pw_dialog(const KaApplet* applet) +{ + return gtk_dialog_run (GTK_DIALOG (applet->priv->pw_dialog)); +} + +void +ka_applet_hide_pw_dialog(KaApplet* applet, gboolean force) +{ + KA_DEBUG("PW Dialog persist: %d", applet->priv->pw_dialog_persist); + if (!applet->priv->pw_dialog_persist || force) + gtk_widget_hide(applet->priv->pw_dialog); +} + +void +ka_applet_set_pw_dialog_persist(KaApplet* applet, gboolean persist) +{ + applet->priv->pw_dialog_persist = persist; +} + +GtkWidget* +ka_applet_get_pw_label(const KaApplet* applet) +{ + return applet->priv->pw_label; +} + /* create the tray icon applet */ -Krb5AuthApplet* -ka_create_applet() +KaApplet* +ka_applet_create() { - Krb5AuthApplet* applet = g_malloc0 (sizeof(Krb5AuthApplet)); + KaApplet* applet = ka_applet_new(); + + ka_applet_glade_init(applet); - if (!(ka_setup_icons (applet))) + if (!(ka_applet_setup_icons (applet))) g_error ("Failure to setup icons"); - if (!(applet->tray_icon = ka_create_tray_icon (applet))) + if (!ka_applet_create_tray_icon (applet)) g_error ("Failure to create tray icon"); - if (!(applet->context_menu = ka_create_context_menu (applet))) + if (!ka_applet_create_context_menu (applet)) g_error ("Failure to create context menu"); - gtk_window_set_default_icon_name (applet->icons[val_icon]); - ka_show_tray_icon (applet); + 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); return applet; } diff --git a/src/krb5-auth-applet.h b/src/krb5-auth-applet.h index e137794..a33be55 100644 --- a/src/krb5-auth-applet.h +++ b/src/krb5-auth-applet.h @@ -22,6 +22,7 @@ #define KRB5_AUTH_APPLET_H #include +#include #include #include #include @@ -32,32 +33,46 @@ #include "config.h" -typedef struct { - 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 */ +G_BEGIN_DECLS - /* The password dialog */ - GtkWidget* pw_dialog; /* the password dialog itself */ - GladeXML* pw_xml; /* the dialog's glade xml */ - GtkWidget* pw_wrong_label; /* the wrong password/timeout label */ - int pw_prompt_secs; /* when to start prompting for a password */ - gboolean pw_dialog_persist; /* don't hide the dialog when creds are still valid */ +#define KA_TYPE_APPLET (ka_applet_get_type ()) +#define KA_APPLET(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), KA_TYPE_APPLET, KaApplet)) +#define KA_APPLET_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), KA_TYPE_APPLET, KaAppletClass)) +#define KA_IS_APPLET(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KA_TYPE_APPLET)) +#define KA_IS_APPLET_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), KA_TYPE_APPLET)) +#define KA_APPLET_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), KA_TYPE_APPLET, KaAppletClass)) -#ifdef HAVE_LIBNOTIFY - NotifyNotification* notification;/* notification messages */ -#endif /* HAVE_LIBNOTIFY */ - char* principal; /* the principal to request */ - gboolean renewable; /* credentials renewable? */ - char* pk_userid; /* "userid" for pkint */ -} Krb5AuthApplet; +typedef struct _KaApplet KaApplet; +typedef struct _KaAppletClass KaAppletClass; +typedef struct _KaAppletPrivate KaAppletPrivate; + +GType ka_applet_get_type (void); +KaApplet* ka_applet_new(void) G_GNUC_MALLOC; + +/* 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); + +/* password dialog */ +gint ka_applet_run_pw_dialog(const KaApplet* applet); +GladeXML* ka_applet_get_pwdialog_xml(const KaApplet* applet); +void ka_applet_hide_pw_dialog(KaApplet* applet, gboolean force); +GtkWidget* ka_applet_get_pw_label(const KaApplet* applet); +void ka_applet_set_pw_dialog_persist(KaApplet* applet, gboolean persist); + +G_END_DECLS -Krb5AuthApplet* ka_create_applet(); +/* create the applet */ +KaApplet* ka_applet_create(); /* update tooltip and icon */ -int ka_update_status(Krb5AuthApplet* applet, krb5_timestamp expiry); -/* show or hide the tray icon */ -gboolean ka_show_tray_icon(Krb5AuthApplet* applet); +int ka_applet_update_status(KaApplet* applet, krb5_timestamp expiry); #ifdef ENABLE_DEBUG #define KA_DEBUG(fmt,...) \ diff --git a/src/krb5-auth-dbus.c b/src/krb5-auth-dbus.c index f658c8d..b4c8742 100644 --- a/src/krb5-auth-dbus.c +++ b/src/krb5-auth-dbus.c @@ -1,6 +1,6 @@ /* Krb5 Auth Applet -- Acquire and release kerberos tickets * - * (C) 2008 Guido Guenther + * (C) 2008,2009 Guido Guenther * * 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 @@ -23,13 +23,38 @@ #include #include "krb5-auth-applet.h" #include "krb5-auth-dbus.h" +#include "krb5-auth-applet-dbus-glue.h" + +static DBusGConnection *session; + +gboolean +ka_dbus_acquire_tgt (KaApplet *applet, + const gchar *principal, DBusGMethodInvocation *context) +{ + gboolean success; + + KA_DEBUG("Getting TGT for '%s'", principal); + success = ka_check_credentials(applet, principal); + dbus_g_method_return(context, success); + return TRUE; +} + + +gboolean +ka_dbus_service(KaApplet* applet) +{ + dbus_g_connection_register_g_object (session, + "/org/gnome/KrbAuthDialog", + G_OBJECT(applet)); + return TRUE; +} + gboolean ka_dbus_connect(unsigned int* status) { guint request_name_reply; unsigned int flags; - DBusGConnection *session; DBusGProxy *bus_proxy; GError* error = NULL; @@ -46,6 +71,9 @@ ka_dbus_connect(unsigned int* status) "/org/freedesktop/DBus", "org.freedesktop.DBus"); + dbus_g_object_type_install_info(KA_TYPE_APPLET, + &dbus_glib_krb5_auth_dialog_object_info); + if (!dbus_g_proxy_call (bus_proxy, "RequestName", &error, diff --git a/src/krb5-auth-dbus.h b/src/krb5-auth-dbus.h index 6ef0bf0..2f0af61 100644 --- a/src/krb5-auth-dbus.h +++ b/src/krb5-auth-dbus.h @@ -22,7 +22,14 @@ #define KRB5_AUTH_DBUS_H #include +#include +#include +#include "krb5-auth-applet.h" gboolean ka_dbus_connect(unsigned int* status); +gboolean ka_dbus_service(KaApplet* applet); +gboolean ka_dbus_acquire_tgt (KaApplet *applet, + const gchar *principal, + DBusGMethodInvocation *context); #endif /* KRB5_AUTH_DBUS_H */ diff --git a/src/krb5-auth-dialog.c b/src/krb5-auth-dialog.c index 3beaa8b..dfd5ef5 100644 --- a/src/krb5-auth-dialog.c +++ b/src/krb5-auth-dialog.c @@ -2,6 +2,8 @@ * Copyright (C) 2004,2005,2006 Red Hat, Inc. * Authored by Christopher Aillon * + * Copyright (C) 2008,2009 Guido Guenther + * * 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, or (at your option) @@ -55,8 +57,8 @@ static gboolean canceled; static gboolean invalid_auth; static gboolean always_run; -static int grab_credentials (Krb5AuthApplet* applet); -static int ka_renew_credentials (Krb5AuthApplet* applet); +static int grab_credentials (KaApplet* applet); +static int ka_renew_credentials (KaApplet* applet); static gboolean ka_get_tgt_from_ccache (krb5_context context, krb5_creds *creds); /* YAY for different Kerberos implementations */ @@ -160,13 +162,13 @@ ka_krb5_cc_clear_mcred(krb5_creds* mcred) /* ***************************************************************** */ static gboolean -credentials_expiring_real (Krb5AuthApplet* applet) +credentials_expiring_real (KaApplet* applet) { krb5_creds my_creds; krb5_timestamp now; gboolean retval = FALSE; - applet->renewable = FALSE; + ka_applet_set_tgt_renewable(applet, FALSE); if (!ka_get_tgt_from_ccache (kcontext, &my_creds)) { creds_expiry = 0; retval = TRUE; @@ -179,18 +181,18 @@ credentials_expiring_real (Krb5AuthApplet* applet) } creds_expiry = my_creds.times.endtime; if ((krb5_timeofday(kcontext, &now) == 0) && - (now + applet->pw_prompt_secs > my_creds.times.endtime)) + (now + ka_applet_get_pw_prompt_secs(applet) > my_creds.times.endtime)) retval = TRUE; /* If our creds are expiring, determine whether they are renewable */ if (retval && get_cred_renewable(&my_creds) && my_creds.times.renew_till > now) { - applet->renewable = TRUE; + ka_applet_set_tgt_renewable(applet, TRUE); } krb5_free_cred_contents (kcontext, &my_creds); out: - ka_update_status(applet, creds_expiry); + ka_applet_update_status(applet, creds_expiry); return retval; } @@ -246,25 +248,21 @@ krb5_auth_dialog_wrong_label_update_expiry (GtkWidget* label) static gboolean krb5_auth_dialog_do_updates (gpointer data) { - Krb5AuthApplet* applet = (Krb5AuthApplet*)data; + KaApplet* applet = KA_APPLET(data); g_return_val_if_fail (applet != NULL, FALSE); - /* Update creds_expiry and close the applet if we got the creds by other means (e.g. kinit) */ - if (!credentials_expiring_real(applet)) { - KA_DEBUG("PW Dialog persist: %d", applet->pw_dialog_persist); - if (!applet->pw_dialog_persist) - gtk_widget_hide(applet->pw_dialog); - } + if (!credentials_expiring_real(applet)) + ka_applet_hide_pw_dialog(applet, FALSE); /* Update the expiry information in the dialog */ - krb5_auth_dialog_wrong_label_update_expiry (applet->pw_wrong_label); + krb5_auth_dialog_wrong_label_update_expiry (ka_applet_get_pw_label(applet)); return TRUE; } static void -krb5_auth_dialog_setup (Krb5AuthApplet *applet, +krb5_auth_dialog_setup (KaApplet *applet, const gchar *krb5prompt, gboolean hide_password) { @@ -275,7 +273,6 @@ krb5_auth_dialog_setup (Krb5AuthApplet *applet, gchar *prompt; int pw4len; - if (krb5prompt == NULL) { prompt = g_strdup (_("Please enter your Kerberos password.")); } else { @@ -295,17 +292,19 @@ krb5_auth_dialog_setup (Krb5AuthApplet *applet, } /* Clear the password entry field */ - entry = glade_xml_get_widget (applet->pw_xml, "krb5_entry"); + entry = glade_xml_get_widget (ka_applet_get_pwdialog_xml(applet), + "krb5_entry"); gtk_secure_entry_set_text (GTK_SECURE_ENTRY (entry), ""); /* Use the prompt label that krb5 provides us */ - label = glade_xml_get_widget (applet->pw_xml, "krb5_message_label"); + label = glade_xml_get_widget (ka_applet_get_pwdialog_xml(applet), + "krb5_message_label"); gtk_label_set_text (GTK_LABEL (label), prompt); /* Add our extra message hints, if any */ wrong_text = NULL; - if (applet->pw_wrong_label) { + if (ka_applet_get_pw_label(applet)) { if (invalid_auth) { wrong_text = g_strdup (_("The password you entered is invalid")); } else { @@ -322,11 +321,11 @@ krb5_auth_dialog_setup (Krb5AuthApplet *applet, if (wrong_text) { wrong_markup = g_strdup_printf ("%s", wrong_text); - gtk_label_set_markup (GTK_LABEL (applet->pw_wrong_label), wrong_markup); + gtk_label_set_markup (GTK_LABEL (ka_applet_get_pw_label(applet)), wrong_markup); g_free(wrong_text); g_free(wrong_markup); } else { - gtk_label_set_text (GTK_LABEL (applet->pw_wrong_label), ""); + gtk_label_set_text (GTK_LABEL (ka_applet_get_pw_label(applet)), ""); } g_free (prompt); } @@ -340,7 +339,7 @@ auth_dialog_prompter (krb5_context ctx, int num_prompts, krb5_prompt prompts[]) { - Krb5AuthApplet* applet = (Krb5AuthApplet*)data; + KaApplet* applet = KA_APPLET(data); krb5_error_code errcode; int i; @@ -359,11 +358,11 @@ auth_dialog_prompter (krb5_context ctx, errcode = KRB5_LIBOS_CANTREADPWD; krb5_auth_dialog_setup (applet, (gchar *) prompts[i].prompt, prompts[i].hidden); - entry = glade_xml_get_widget (applet->pw_xml, "krb5_entry"); + entry = glade_xml_get_widget (ka_applet_get_pwdialog_xml(applet), "krb5_entry"); gtk_widget_grab_focus (entry); source_id = g_timeout_add_seconds (5, (GSourceFunc)krb5_auth_dialog_do_updates, applet); - response = gtk_dialog_run (GTK_DIALOG (applet->pw_dialog)); + response = ka_applet_run_pw_dialog (applet); switch (response) { case GTK_RESPONSE_OK: @@ -394,8 +393,8 @@ auth_dialog_prompter (krb5_context ctx, errcode = 0; } cleanup: + ka_applet_hide_pw_dialog (applet, TRUE); /* Reset this, so we know the next time we get a TRUE value, it is accurate. */ - gtk_widget_hide (applet->pw_dialog); invalid_auth = FALSE; return errcode; @@ -431,14 +430,15 @@ network_state_cb (libnm_glib_ctx *context, } #endif +/* credentials expiring timer */ static gboolean credentials_expiring (gpointer *data) { int retval; gboolean give_up; - Krb5AuthApplet* applet = (Krb5AuthApplet*) data; + KaApplet* applet = KA_APPLET(data); - KA_DEBUG("Checking expiry <%ds", applet->pw_prompt_secs); + 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); @@ -448,7 +448,7 @@ credentials_expiring (gpointer *data) } /* no popup when using a trayicon */ - if (applet->show_trayicon) + if (ka_applet_get_show_trayicon(applet)) goto out; give_up = canceled && (creds_expiry == canceled_creds_expiry); @@ -465,13 +465,13 @@ credentials_expiring (gpointer *data) } } out: - ka_update_status(applet, creds_expiry); + ka_applet_update_status(applet, creds_expiry); return TRUE; } static void -set_options_from_creds(const Krb5AuthApplet* applet, +set_options_from_creds(const KaApplet* applet, krb5_context context, krb5_creds *in, krb5_get_init_creds_opt *out) @@ -496,7 +496,7 @@ set_options_from_creds(const Krb5AuthApplet* applet, renew_lifetime); } if (in->times.endtime > - in->times.starttime + applet->pw_prompt_secs) { + in->times.starttime + ka_applet_get_pw_prompt_secs(applet)) { krb5_get_init_creds_opt_set_tkt_life(out, in->times.endtime - in->times.starttime); @@ -507,16 +507,13 @@ set_options_from_creds(const Krb5AuthApplet* applet, static krb5_error_code -ka_auth_pkinit(Krb5AuthApplet* applet, krb5_creds* creds) +ka_auth_pkinit(KaApplet* applet, krb5_creds* creds, const char* pk_userid) { #ifdef ENABLE_PKINIT krb5_get_init_creds_opt *opts = NULL; krb5_error_code retval; - KA_DEBUG("pkinit with %s", applet->pk_userid); - - if (!applet->pk_userid) - return 0; + KA_DEBUG("pkinit with '%s'", pk_userid); retval = krb5_get_init_creds_opt_alloc (kcontext, &opts); if (retval) @@ -525,7 +522,7 @@ ka_auth_pkinit(Krb5AuthApplet* applet, krb5_creds* creds) retval = krb5_get_init_creds_opt_set_pkinit(kcontext, opts, kprincipal, - applet->pk_userid, + pk_userid, NULL, /* x509 anchors */ NULL, NULL, @@ -549,35 +546,54 @@ out: } +krb5_error_code +ka_parse_name(KaApplet* applet, krb5_context kcontext, krb5_principal* kprinc) +{ + krb5_error_code ret; + gchar *principal = NULL; + + g_object_get(applet, "principal", &principal, + NULL); + + ret = krb5_parse_name(kcontext, principal, + kprinc); + + g_free(principal); + return ret; +} + + /* grab credentials interactively */ static int -grab_credentials (Krb5AuthApplet* applet) +grab_credentials (KaApplet* applet) { krb5_error_code retval; krb5_creds my_creds; krb5_ccache ccache; krb5_get_init_creds_opt *opt = NULL; + gchar *pk_userid = NULL; + + g_object_get(applet, "pk-userid", &pk_userid, + NULL); memset(&my_creds, 0, sizeof(my_creds)); if (kprincipal == NULL) { - retval = krb5_parse_name(kcontext, applet->principal, - &kprincipal); - if (retval) { - return retval; - } + retval = ka_parse_name(applet, kcontext, &kprincipal); + if (retval) + goto out2; } retval = krb5_cc_default (kcontext, &ccache); if (retval) - return retval; + goto out2; #if ENABLE_PKINIT - if (applet->pk_userid) { /* try pkinit */ + if (pk_userid && strlen(pk_userid)) { /* try pkinit */ #else if (0) { #endif - retval = ka_auth_pkinit(applet, &my_creds); + retval = ka_auth_pkinit(applet, &my_creds, pk_userid); } else { retval = krb5_get_init_creds_opt_alloc (kcontext, &opt); if (retval) @@ -620,13 +636,15 @@ out: krb5_get_init_creds_opt_free(kcontext, opt); krb5_free_cred_contents (kcontext, &my_creds); krb5_cc_close (kcontext, ccache); +out2: + g_free(pk_userid); return retval; } /* try to renew the credentials noninteractively */ static int -ka_renew_credentials (Krb5AuthApplet* applet) +ka_renew_credentials (KaApplet* applet) { krb5_error_code retval; krb5_creds my_creds; @@ -634,8 +652,7 @@ ka_renew_credentials (Krb5AuthApplet* applet) krb5_get_init_creds_opt opts; if (kprincipal == NULL) { - retval = krb5_parse_name(kcontext, applet->principal, - &kprincipal); + retval = ka_parse_name(applet, kcontext, &kprincipal); if (retval) return retval; } @@ -653,7 +670,7 @@ ka_renew_credentials (Krb5AuthApplet* applet) krb5_get_init_creds_opt_init (&opts); set_options_from_creds (applet, kcontext, &my_creds, &opts); - if (applet->renewable) { + if (ka_applet_get_tgt_renewable(applet)) { retval = get_renewed_creds (kcontext, &my_creds, kprincipal, ccache, NULL); if (retval) goto out; @@ -741,7 +758,7 @@ using_krb5() void ka_destroy_cache (GtkMenuItem *menuitem, gpointer data) { - Krb5AuthApplet* applet = (Krb5AuthApplet*) data; + KaApplet *applet = KA_APPLET(data); krb5_ccache ccache; const char* cache; krb5_error_code ret; @@ -768,14 +785,66 @@ ka_error_dialog(int err) } -/* this is done on leftclick, update the tooltip immediately */ -void -ka_grab_credentials (Krb5AuthApplet* applet) +/* + * check if we have valid credentials for the requested principal - if not, grab them + * principal: requested principal - if empty use default + */ +gboolean +ka_check_credentials (KaApplet *applet, const char* newprincipal) +{ + gboolean renewable; + gboolean success = FALSE; + int retval; + char* principal; + + g_object_get(applet, "principal", &principal, + NULL); + + if (strlen(newprincipal)) { + krb5_principal knewprinc; + + /* no ticket cache: is requested princ the one from our config? */ + if (!kprincipal && g_strcmp0(principal, newprincipal)) { + KA_DEBUG("Requested principal %s not %s", principal, newprincipal); + goto out; + } + + /* ticket cache: check if the requested principal is the one we have */ + retval = krb5_parse_name(kcontext, newprincipal, &knewprinc); + if (retval) { + g_warning ("Cannot parse principal '%s'", newprincipal); + goto out; + } + if (kprincipal && !krb5_principal_compare (kcontext, kprincipal, knewprinc)) { + KA_DEBUG("Current Principal '%s' not '%s'", principal, newprincipal); + krb5_free_principal(kcontext, knewprinc); + goto out; + } + krb5_free_principal(kcontext, knewprinc); + } + + if (credentials_expiring_real (applet)) { + if (!is_online) + success = FALSE; + else + success = ka_grab_credentials (applet); + } else + success = TRUE; +out: + g_free (principal); + return success; +} + + +/* initiate grabbing of credentials (e.g. on leftclick of tray icon) */ +gboolean +ka_grab_credentials (KaApplet* applet) { int retval; gboolean retry; + int success = FALSE; - applet->pw_dialog_persist = TRUE; + ka_applet_set_pw_dialog_persist(applet, TRUE); do { retry = TRUE; retval = grab_credentials (applet); @@ -783,6 +852,7 @@ ka_grab_credentials (Krb5AuthApplet* applet) continue; switch (retval) { case 0: /* success */ + success = TRUE; case KRB5_LIBOS_PWDINTR: /* canceled (heimdal) */ case KRB5_LIBOS_CANTREADPWD: /* canceled (mit) */ retry = FALSE; @@ -795,8 +865,10 @@ ka_grab_credentials (Krb5AuthApplet* applet) } } while(retry); - applet->pw_dialog_persist = FALSE; + ka_applet_set_pw_dialog_persist(applet, FALSE); credentials_expiring_real(applet); + + return success; } @@ -835,7 +907,7 @@ ka_secmem_init () int main (int argc, char *argv[]) { - Krb5AuthApplet *applet; + KaApplet *applet; GOptionContext *context; GError *error = NULL; @@ -878,20 +950,15 @@ main (int argc, char *argv[]) always_run = TRUE; } if (using_krb5 () || always_run) { - applet = ka_create_applet (); + g_set_application_name (_("Network Authentication")); + glade_set_custom_handler (&ka_create_gtk_secure_entry, NULL); + + applet = ka_applet_create (); if (!applet) return 1; if (!ka_gconf_init (applet, argc, argv)) return 1; - /* setup the pw dialog */ - glade_set_custom_handler (&ka_create_gtk_secure_entry, NULL); - applet->pw_xml = glade_xml_new (GLADEDIR "krb5-auth-dialog.glade", NULL, NULL); - applet->pw_wrong_label = glade_xml_get_widget (applet->pw_xml, "krb5_wrong_label"); - applet->pw_dialog = glade_xml_get_widget (applet->pw_xml, "krb5_dialog"); - - g_set_application_name (_("Network Authentication")); - #ifdef ENABLE_NETWORK_MANAGER nm_context = libnm_glib_init (); if (!nm_context) { @@ -910,6 +977,7 @@ main (int argc, char *argv[]) if (credentials_expiring ((gpointer)applet)) { g_timeout_add_seconds (CREDENTIAL_CHECK_INTERVAL, (GSourceFunc)credentials_expiring, applet); } + ka_dbus_service(applet); gtk_main (); } diff --git a/src/krb5-auth-dialog.h b/src/krb5-auth-dialog.h index 77a9891..1ecc93d 100644 --- a/src/krb5-auth-dialog.h +++ b/src/krb5-auth-dialog.h @@ -24,7 +24,7 @@ #include "krb5-auth-applet.h" void ka_destroy_cache (GtkMenuItem *menuitem, gpointer user_data); -void ka_grab_credentials(Krb5AuthApplet* applet); - +gboolean ka_grab_credentials(KaApplet* applet); +gboolean ka_check_credentials (KaApplet *applet, const char* principal); #endif diff --git a/src/krb5-auth-gconf.c b/src/krb5-auth-gconf.c index a11370c..fd573c1 100644 --- a/src/krb5-auth-gconf.c +++ b/src/krb5-auth-gconf.c @@ -1,6 +1,6 @@ /* Krb5 Auth Applet -- Acquire and release kerberos tickets * - * (C) 2008 Guido Guenther + * (C) 2008,2009 Guido Guenther * * 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 @@ -111,52 +111,55 @@ ka_gconf_get_bool (GConfClient* client, static gboolean -ka_gconf_set_principal (GConfClient* client, Krb5AuthApplet* applet) +ka_gconf_set_principal (GConfClient* client, KaApplet* applet) { - g_free (applet->principal); - applet->principal = NULL; - if(!ka_gconf_get_string (client, KA_GCONF_KEY_PRINCIPAL, &applet->principal)) { - applet->principal = g_strdup (g_get_user_name()); + gchar* principal = NULL; + + if(!ka_gconf_get_string (client, KA_GCONF_KEY_PRINCIPAL, &principal)) { + principal = g_strdup (g_get_user_name()); } - KA_DEBUG("Setting principal to %s", applet->principal); - // FIXME: need to send set-principal signal + g_object_set(applet, "principal", principal, NULL); + g_free (principal); return TRUE; } static gboolean -ka_gconf_set_pk_userid (GConfClient* client, Krb5AuthApplet* applet) +ka_gconf_set_pk_userid (GConfClient* client, KaApplet* applet) { - g_free (applet->pk_userid); - if(!ka_gconf_get_string (client, KA_GCONF_KEY_PK_USERID, &applet->pk_userid)) { - applet->pk_userid = NULL; + gchar* pk_userid = NULL; + + if(!ka_gconf_get_string (client, KA_GCONF_KEY_PK_USERID, &pk_userid)) { + pk_userid = g_strdup (""); } - KA_DEBUG("Setting pk_userid to %s", applet->pk_userid ? applet->pk_userid : ""); + g_object_set(applet, "pk_userid", pk_userid, NULL); + g_free (pk_userid); return TRUE; } static gboolean -ka_gconf_set_prompt_mins (GConfClient* client, Krb5AuthApplet* applet) +ka_gconf_set_prompt_mins (GConfClient* client, KaApplet* applet) { - if(!ka_gconf_get_int (client, KA_GCONF_KEY_PROMPT_MINS, &applet->pw_prompt_secs)) { - applet->pw_prompt_secs = MINUTES_BEFORE_PROMPTING; + gint prompt_mins = 0; + + if(!ka_gconf_get_int (client, KA_GCONF_KEY_PROMPT_MINS, &prompt_mins)) { + prompt_mins = MINUTES_BEFORE_PROMPTING; } - applet->pw_prompt_secs *= 60; - KA_DEBUG("Setting prompting timer to %d seconds", applet->pw_prompt_secs); + g_object_set(applet, "pw-prompt-mins", prompt_mins, NULL); return TRUE; } static gboolean -ka_gconf_set_show_trayicon (GConfClient* client, Krb5AuthApplet* applet) +ka_gconf_set_show_trayicon (GConfClient* client, KaApplet* applet) { - if(!ka_gconf_get_bool(client, KA_GCONF_KEY_SHOW_TRAYICON, &applet->show_trayicon)) { - applet->show_trayicon = TRUE; + gboolean show_trayicon = FALSE; + + if(!ka_gconf_get_bool(client, KA_GCONF_KEY_SHOW_TRAYICON, &show_trayicon)) { + show_trayicon = TRUE; } - KA_DEBUG("Show trayicon: %s", (applet->show_trayicon ? "yes" : "no" )); - // FIXME: send show trayicon signal - ka_show_tray_icon(applet); + g_object_set(applet, "show-trayicon", show_trayicon, NULL); return TRUE; } @@ -169,7 +172,7 @@ ka_gconf_key_changed_callback (GConfClient* client, { const char* key; - Krb5AuthApplet* applet = (Krb5AuthApplet*)user_data; + KaApplet* applet = KA_APPLET(user_data); key = gconf_entry_get_key (entry); if (!key) return; @@ -190,7 +193,7 @@ ka_gconf_key_changed_callback (GConfClient* client, gboolean -ka_gconf_init (Krb5AuthApplet* applet, int argc, char* argv[]) +ka_gconf_init (KaApplet* applet, int argc, char* argv[]) { GError *error = NULL; GConfClient* client; diff --git a/src/krb5-auth-gconf.h b/src/krb5-auth-gconf.h index ec85704..3d2baae 100644 --- a/src/krb5-auth-gconf.h +++ b/src/krb5-auth-gconf.h @@ -23,6 +23,6 @@ #include "krb5-auth-applet.h" -gboolean ka_gconf_init (Krb5AuthApplet* applet, int argc, char* argv[]); +gboolean ka_gconf_init (KaApplet* applet, int argc, char* argv[]); #endif diff --git a/src/krb5-auth-notify.c b/src/krb5-auth-notify.c deleted file mode 100644 index 019662e..0000000 --- a/src/krb5-auth-notify.c +++ /dev/null @@ -1,66 +0,0 @@ -/* Krb5 Auth Applet -- Acquire and release kerberos tickets - * - * (C) 2008 Guido Guenther - * - * 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 "krb5-auth-applet.h" -#include "krb5-auth-notify.h" - -#ifdef HAVE_LIBNOTIFY -#include - -void -ka_send_event_notification (Krb5AuthApplet *applet, - const char *summary, - const char *message, - const char *icon) -{ - const char *notify_icon; - - 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->notification != NULL) { - notify_notification_close (applet->notification, NULL); - g_object_unref (applet->notification); - } - - notify_icon = icon ? icon : "gtk-dialog-authentication"; - - applet->notification = \ - notify_notification_new_with_status_icon(summary, message, notify_icon, applet->tray_icon); - - notify_notification_set_urgency (applet->notification, NOTIFY_URGENCY_NORMAL); - notify_notification_show (applet->notification, NULL); -} - -#else /* HAVE_LIBNOTIFY */ - -void -ka_send_event_notification (Krb5AuthApplet *applet __attribute__((__unused__)), - const char *summary __attribute__((__unused__)), - const char *message __attribute__((__unused__)), - const char *icon __attribute__((__unused__))) -{ -} - -#endif /* HAVE_LIBNOTIFY */ diff --git a/src/krb5-auth-notify.h b/src/krb5-auth-notify.h deleted file mode 100644 index 9c0ce55..0000000 --- a/src/krb5-auth-notify.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Krb5 Auth Applet -- Acquire and release kerberos tickets - * - * (C) 2008 Guido Guenther - * - * 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 KRB5_AUTH_NOTIFY_H -#define KRB5_AUTH_NOTIFY_H - -void ka_send_event_notification (Krb5AuthApplet *applet, - const char *summary, - const char *message, - const char *icon); -#endif -- cgit