diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 51 | ||||
-rw-r--r-- | src/Makefile.in | 748 | ||||
-rw-r--r-- | src/main.c | 278 | ||||
-rw-r--r-- | src/polkit-mate-authentication-agent-1.desktop.in.in | 9 | ||||
-rw-r--r-- | src/polkitmateauthenticationdialog.c | 1061 | ||||
-rw-r--r-- | src/polkitmateauthenticationdialog.h | 77 | ||||
-rw-r--r-- | src/polkitmateauthenticator.c | 508 | ||||
-rw-r--r-- | src/polkitmateauthenticator.h | 56 | ||||
-rw-r--r-- | src/polkitmatelistener.c | 253 | ||||
-rw-r--r-- | src/polkitmatelistener.h | 48 |
10 files changed, 3089 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..58f9507 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,51 @@ + +FULL_LIBEXECDIR=$(libexecdir) + +desktopdir = $(sysconfdir)/xdg/autostart +desktop_DATA = polkit-mate-authentication-agent-1.desktop + +@INTLTOOL_DESKTOP_RULE@ + +polkit-mate-authentication-agent-1.desktop.in : polkit-mate-authentication-agent-1.desktop.in.in + cat polkit-mate-authentication-agent-1.desktop.in.in | sed 's,@FULL_LIBEXECDIR@,$(FULL_LIBEXECDIR),' > $@ + +libexec_PROGRAMS = polkit-mate-authentication-agent-1 + +polkit_mate_authentication_agent_1_SOURCES = \ + polkitmatelistener.h polkitmatelistener.c \ + polkitmateauthenticator.h polkitmateauthenticator.c \ + polkitmateauthenticationdialog.h polkitmateauthenticationdialog.c \ + main.c \ + $(BUILT_SOURCES) + +polkit_mate_authentication_agent_1_CPPFLAGS = \ + -I$(top_srcdir) \ + -DG_LOG_DOMAIN=\"polkit-mate-1\" \ + -DDATADIR=\""$(pkgdatadir)"\" \ + -DMATELOCALEDIR=\""$(datadir)/locale"\" \ + -DPOLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE \ + $(DISABLE_DEPRECATED) \ + $(AM_CPPFLAGS) + +polkit_mate_authentication_agent_1_CFLAGS = \ + $(GTK_CFLAGS) \ + $(MATECONF_CFLAGS) \ + $(POLKIT_AGENT_CFLAGS) \ + $(POLKIT_GOBJECT_CFLAGS) \ + $(WARN_CFLAGS) \ + $(AM_CFLAGS) + +polkit_mate_authentication_agent_1_LDFLAGS = \ + $(AM_LDFLAGS) + +polkit_mate_authentication_agent_1_LDADD = \ + $(GTK_LIBS) \ + $(MATECONF_LIBS) \ + $(POLKIT_AGENT_LIBS) \ + $(POLKIT_GOBJECT_LIBS) \ + $(INTLLIBS) + +EXTRA_DIST = polkit-mate-authentication-agent-1.desktop.in.in + +clean-local : + rm -f *~ polkit-mate-authentication-agent-1.desktop polkit-mate-authentication-agent-1.desktop.in diff --git a/src/Makefile.in b/src/Makefile.in new file mode 100644 index 0000000..fa9c25c --- /dev/null +++ b/src/Makefile.in @@ -0,0 +1,748 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 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@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@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@ +libexec_PROGRAMS = polkit-mate-authentication-agent-1$(EXEEXT) +subdir = src +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(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 = +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(libexecdir)" "$(DESTDIR)$(desktopdir)" +PROGRAMS = $(libexec_PROGRAMS) +am_polkit_mate_authentication_agent_1_OBJECTS = polkit_mate_authentication_agent_1-polkitmatelistener.$(OBJEXT) \ + polkit_mate_authentication_agent_1-polkitmateauthenticator.$(OBJEXT) \ + polkit_mate_authentication_agent_1-polkitmateauthenticationdialog.$(OBJEXT) \ + polkit_mate_authentication_agent_1-main.$(OBJEXT) +polkit_mate_authentication_agent_1_OBJECTS = \ + $(am_polkit_mate_authentication_agent_1_OBJECTS) +am__DEPENDENCIES_1 = +polkit_mate_authentication_agent_1_DEPENDENCIES = \ + $(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 +polkit_mate_authentication_agent_1_LINK = $(LIBTOOL) $(AM_V_lt) \ + --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \ + $(CCLD) $(polkit_mate_authentication_agent_1_CFLAGS) $(CFLAGS) \ + $(polkit_mate_authentication_agent_1_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_$(V)) +am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) +am__v_CC_0 = @echo " CC " $@; +AM_V_at = $(am__v_at_$(V)) +am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) +am__v_at_0 = @ +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_$(V)) +am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) +am__v_CCLD_0 = @echo " CCLD " $@; +AM_V_GEN = $(am__v_GEN_$(V)) +am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) +am__v_GEN_0 = @echo " GEN " $@; +SOURCES = $(polkit_mate_authentication_agent_1_SOURCES) +DIST_SOURCES = $(polkit_mate_authentication_agent_1_SOURCES) +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 = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +DATA = $(desktop_DATA) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@ +ALL_LINGUAS = @ALL_LINGUAS@ +AMTAR = @AMTAR@ +AM_CFLAGS = @AM_CFLAGS@ +AM_CPPFLAGS = @AM_CPPFLAGS@ +AM_CXXFLAGS = @AM_CXXFLAGS@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AM_LDFLAGS = @AM_LDFLAGS@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIRNAME = @DATADIRNAME@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DISABLE_DEPRECATED = @DISABLE_DEPRECATED@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GIRDIR = @GIRDIR@ +GIRTYPELIBDIR = @GIRTYPELIBDIR@ +GMOFILES = @GMOFILES@ +GMSGFMT = @GMSGFMT@ +GREP = @GREP@ +GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ +GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ +GTKDOC_MKPDF = @GTKDOC_MKPDF@ +GTKDOC_REBASE = @GTKDOC_REBASE@ +GTK_CFLAGS = @GTK_CFLAGS@ +GTK_LIBS = @GTK_LIBS@ +G_IR_COMPILER = @G_IR_COMPILER@ +G_IR_GENERATE = @G_IR_GENERATE@ +G_IR_SCANNER = @G_IR_SCANNER@ +HTML_DIR = @HTML_DIR@ +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_EXTRACT = @INTLTOOL_EXTRACT@ +INTLTOOL_MERGE = @INTLTOOL_MERGE@ +INTLTOOL_PERL = @INTLTOOL_PERL@ +INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ +INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ +INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_AGE = @LT_AGE@ +LT_CURRENT = @LT_CURRENT@ +LT_REVISION = @LT_REVISION@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MSGFMT = @MSGFMT@ +MSGFMT_OPTS = @MSGFMT_OPTS@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +POFILES = @POFILES@ +POLKIT_AGENT_CFLAGS = @POLKIT_AGENT_CFLAGS@ +POLKIT_AGENT_LIBS = @POLKIT_AGENT_LIBS@ +POLKIT_GOBJECT_CFLAGS = @POLKIT_GOBJECT_CFLAGS@ +POLKIT_GOBJECT_LIBS = @POLKIT_GOBJECT_LIBS@ +POSUB = @POSUB@ +PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ +PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +WARN_CFLAGS = @WARN_CFLAGS@ +XGETTEXT = @XGETTEXT@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +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@ +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@ +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_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +FULL_LIBEXECDIR = $(libexecdir) +desktopdir = $(sysconfdir)/xdg/autostart +desktop_DATA = polkit-mate-authentication-agent-1.desktop +polkit_mate_authentication_agent_1_SOURCES = \ + polkitmatelistener.h polkitmatelistener.c \ + polkitmateauthenticator.h polkitmateauthenticator.c \ + polkitmateauthenticationdialog.h polkitmateauthenticationdialog.c \ + main.c \ + $(BUILT_SOURCES) + +polkit_mate_authentication_agent_1_CPPFLAGS = \ + -I$(top_srcdir) \ + -DG_LOG_DOMAIN=\"polkit-mate-1\" \ + -DDATADIR=\""$(pkgdatadir)"\" \ + -DMATELOCALEDIR=\""$(datadir)/locale"\" \ + -DPOLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE \ + $(DISABLE_DEPRECATED) \ + $(AM_CPPFLAGS) + +polkit_mate_authentication_agent_1_CFLAGS = \ + $(GTK_CFLAGS) \ + $(MATECONF_CFLAGS) \ + $(POLKIT_AGENT_CFLAGS) \ + $(POLKIT_GOBJECT_CFLAGS) \ + $(WARN_CFLAGS) \ + $(AM_CFLAGS) + +polkit_mate_authentication_agent_1_LDFLAGS = \ + $(AM_LDFLAGS) + +polkit_mate_authentication_agent_1_LDADD = \ + $(GTK_LIBS) \ + $(MATECONF_LIBS) \ + $(POLKIT_AGENT_LIBS) \ + $(POLKIT_GOBJECT_LIBS) \ + $(INTLLIBS) + +EXTRA_DIST = polkit-mate-authentication-agent-1.desktop.in.in +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 ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign 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 +$(am__aclocal_m4_deps): +install-libexecPROGRAMS: $(libexec_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(libexecdir)" || $(MKDIR_P) "$(DESTDIR)$(libexecdir)" + @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p || test -f $$p1; \ + then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(libexecdir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(libexecdir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-libexecPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(libexecdir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(libexecdir)" && rm -f $$files + +clean-libexecPROGRAMS: + @list='$(libexec_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +polkit-mate-authentication-agent-1$(EXEEXT): $(polkit_mate_authentication_agent_1_OBJECTS) $(polkit_mate_authentication_agent_1_DEPENDENCIES) + @rm -f polkit-mate-authentication-agent-1$(EXEEXT) + $(AM_V_CCLD)$(polkit_mate_authentication_agent_1_LINK) $(polkit_mate_authentication_agent_1_OBJECTS) $(polkit_mate_authentication_agent_1_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/polkit_mate_authentication_agent_1-main.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/polkit_mate_authentication_agent_1-polkitmateauthenticationdialog.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/polkit_mate_authentication_agent_1-polkitmateauthenticator.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/polkit_mate_authentication_agent_1-polkitmatelistener.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@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@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@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@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@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 $@ $< + +polkit_mate_authentication_agent_1-polkitmatelistener.o: polkitmatelistener.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(polkit_mate_authentication_agent_1_CPPFLAGS) $(CPPFLAGS) $(polkit_mate_authentication_agent_1_CFLAGS) $(CFLAGS) -MT polkit_mate_authentication_agent_1-polkitmatelistener.o -MD -MP -MF $(DEPDIR)/polkit_mate_authentication_agent_1-polkitmatelistener.Tpo -c -o polkit_mate_authentication_agent_1-polkitmatelistener.o `test -f 'polkitmatelistener.c' || echo '$(srcdir)/'`polkitmatelistener.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/polkit_mate_authentication_agent_1-polkitmatelistener.Tpo $(DEPDIR)/polkit_mate_authentication_agent_1-polkitmatelistener.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='polkitmatelistener.c' object='polkit_mate_authentication_agent_1-polkitmatelistener.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(polkit_mate_authentication_agent_1_CPPFLAGS) $(CPPFLAGS) $(polkit_mate_authentication_agent_1_CFLAGS) $(CFLAGS) -c -o polkit_mate_authentication_agent_1-polkitmatelistener.o `test -f 'polkitmatelistener.c' || echo '$(srcdir)/'`polkitmatelistener.c + +polkit_mate_authentication_agent_1-polkitmatelistener.obj: polkitmatelistener.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(polkit_mate_authentication_agent_1_CPPFLAGS) $(CPPFLAGS) $(polkit_mate_authentication_agent_1_CFLAGS) $(CFLAGS) -MT polkit_mate_authentication_agent_1-polkitmatelistener.obj -MD -MP -MF $(DEPDIR)/polkit_mate_authentication_agent_1-polkitmatelistener.Tpo -c -o polkit_mate_authentication_agent_1-polkitmatelistener.obj `if test -f 'polkitmatelistener.c'; then $(CYGPATH_W) 'polkitmatelistener.c'; else $(CYGPATH_W) '$(srcdir)/polkitmatelistener.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/polkit_mate_authentication_agent_1-polkitmatelistener.Tpo $(DEPDIR)/polkit_mate_authentication_agent_1-polkitmatelistener.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='polkitmatelistener.c' object='polkit_mate_authentication_agent_1-polkitmatelistener.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(polkit_mate_authentication_agent_1_CPPFLAGS) $(CPPFLAGS) $(polkit_mate_authentication_agent_1_CFLAGS) $(CFLAGS) -c -o polkit_mate_authentication_agent_1-polkitmatelistener.obj `if test -f 'polkitmatelistener.c'; then $(CYGPATH_W) 'polkitmatelistener.c'; else $(CYGPATH_W) '$(srcdir)/polkitmatelistener.c'; fi` + +polkit_mate_authentication_agent_1-polkitmateauthenticator.o: polkitmateauthenticator.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(polkit_mate_authentication_agent_1_CPPFLAGS) $(CPPFLAGS) $(polkit_mate_authentication_agent_1_CFLAGS) $(CFLAGS) -MT polkit_mate_authentication_agent_1-polkitmateauthenticator.o -MD -MP -MF $(DEPDIR)/polkit_mate_authentication_agent_1-polkitmateauthenticator.Tpo -c -o polkit_mate_authentication_agent_1-polkitmateauthenticator.o `test -f 'polkitmateauthenticator.c' || echo '$(srcdir)/'`polkitmateauthenticator.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/polkit_mate_authentication_agent_1-polkitmateauthenticator.Tpo $(DEPDIR)/polkit_mate_authentication_agent_1-polkitmateauthenticator.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='polkitmateauthenticator.c' object='polkit_mate_authentication_agent_1-polkitmateauthenticator.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(polkit_mate_authentication_agent_1_CPPFLAGS) $(CPPFLAGS) $(polkit_mate_authentication_agent_1_CFLAGS) $(CFLAGS) -c -o polkit_mate_authentication_agent_1-polkitmateauthenticator.o `test -f 'polkitmateauthenticator.c' || echo '$(srcdir)/'`polkitmateauthenticator.c + +polkit_mate_authentication_agent_1-polkitmateauthenticator.obj: polkitmateauthenticator.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(polkit_mate_authentication_agent_1_CPPFLAGS) $(CPPFLAGS) $(polkit_mate_authentication_agent_1_CFLAGS) $(CFLAGS) -MT polkit_mate_authentication_agent_1-polkitmateauthenticator.obj -MD -MP -MF $(DEPDIR)/polkit_mate_authentication_agent_1-polkitmateauthenticator.Tpo -c -o polkit_mate_authentication_agent_1-polkitmateauthenticator.obj `if test -f 'polkitmateauthenticator.c'; then $(CYGPATH_W) 'polkitmateauthenticator.c'; else $(CYGPATH_W) '$(srcdir)/polkitmateauthenticator.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/polkit_mate_authentication_agent_1-polkitmateauthenticator.Tpo $(DEPDIR)/polkit_mate_authentication_agent_1-polkitmateauthenticator.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='polkitmateauthenticator.c' object='polkit_mate_authentication_agent_1-polkitmateauthenticator.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(polkit_mate_authentication_agent_1_CPPFLAGS) $(CPPFLAGS) $(polkit_mate_authentication_agent_1_CFLAGS) $(CFLAGS) -c -o polkit_mate_authentication_agent_1-polkitmateauthenticator.obj `if test -f 'polkitmateauthenticator.c'; then $(CYGPATH_W) 'polkitmateauthenticator.c'; else $(CYGPATH_W) '$(srcdir)/polkitmateauthenticator.c'; fi` + +polkit_mate_authentication_agent_1-polkitmateauthenticationdialog.o: polkitmateauthenticationdialog.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(polkit_mate_authentication_agent_1_CPPFLAGS) $(CPPFLAGS) $(polkit_mate_authentication_agent_1_CFLAGS) $(CFLAGS) -MT polkit_mate_authentication_agent_1-polkitmateauthenticationdialog.o -MD -MP -MF $(DEPDIR)/polkit_mate_authentication_agent_1-polkitmateauthenticationdialog.Tpo -c -o polkit_mate_authentication_agent_1-polkitmateauthenticationdialog.o `test -f 'polkitmateauthenticationdialog.c' || echo '$(srcdir)/'`polkitmateauthenticationdialog.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/polkit_mate_authentication_agent_1-polkitmateauthenticationdialog.Tpo $(DEPDIR)/polkit_mate_authentication_agent_1-polkitmateauthenticationdialog.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='polkitmateauthenticationdialog.c' object='polkit_mate_authentication_agent_1-polkitmateauthenticationdialog.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(polkit_mate_authentication_agent_1_CPPFLAGS) $(CPPFLAGS) $(polkit_mate_authentication_agent_1_CFLAGS) $(CFLAGS) -c -o polkit_mate_authentication_agent_1-polkitmateauthenticationdialog.o `test -f 'polkitmateauthenticationdialog.c' || echo '$(srcdir)/'`polkitmateauthenticationdialog.c + +polkit_mate_authentication_agent_1-polkitmateauthenticationdialog.obj: polkitmateauthenticationdialog.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(polkit_mate_authentication_agent_1_CPPFLAGS) $(CPPFLAGS) $(polkit_mate_authentication_agent_1_CFLAGS) $(CFLAGS) -MT polkit_mate_authentication_agent_1-polkitmateauthenticationdialog.obj -MD -MP -MF $(DEPDIR)/polkit_mate_authentication_agent_1-polkitmateauthenticationdialog.Tpo -c -o polkit_mate_authentication_agent_1-polkitmateauthenticationdialog.obj `if test -f 'polkitmateauthenticationdialog.c'; then $(CYGPATH_W) 'polkitmateauthenticationdialog.c'; else $(CYGPATH_W) '$(srcdir)/polkitmateauthenticationdialog.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/polkit_mate_authentication_agent_1-polkitmateauthenticationdialog.Tpo $(DEPDIR)/polkit_mate_authentication_agent_1-polkitmateauthenticationdialog.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='polkitmateauthenticationdialog.c' object='polkit_mate_authentication_agent_1-polkitmateauthenticationdialog.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(polkit_mate_authentication_agent_1_CPPFLAGS) $(CPPFLAGS) $(polkit_mate_authentication_agent_1_CFLAGS) $(CFLAGS) -c -o polkit_mate_authentication_agent_1-polkitmateauthenticationdialog.obj `if test -f 'polkitmateauthenticationdialog.c'; then $(CYGPATH_W) 'polkitmateauthenticationdialog.c'; else $(CYGPATH_W) '$(srcdir)/polkitmateauthenticationdialog.c'; fi` + +polkit_mate_authentication_agent_1-main.o: main.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(polkit_mate_authentication_agent_1_CPPFLAGS) $(CPPFLAGS) $(polkit_mate_authentication_agent_1_CFLAGS) $(CFLAGS) -MT polkit_mate_authentication_agent_1-main.o -MD -MP -MF $(DEPDIR)/polkit_mate_authentication_agent_1-main.Tpo -c -o polkit_mate_authentication_agent_1-main.o `test -f 'main.c' || echo '$(srcdir)/'`main.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/polkit_mate_authentication_agent_1-main.Tpo $(DEPDIR)/polkit_mate_authentication_agent_1-main.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='main.c' object='polkit_mate_authentication_agent_1-main.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(polkit_mate_authentication_agent_1_CPPFLAGS) $(CPPFLAGS) $(polkit_mate_authentication_agent_1_CFLAGS) $(CFLAGS) -c -o polkit_mate_authentication_agent_1-main.o `test -f 'main.c' || echo '$(srcdir)/'`main.c + +polkit_mate_authentication_agent_1-main.obj: main.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(polkit_mate_authentication_agent_1_CPPFLAGS) $(CPPFLAGS) $(polkit_mate_authentication_agent_1_CFLAGS) $(CFLAGS) -MT polkit_mate_authentication_agent_1-main.obj -MD -MP -MF $(DEPDIR)/polkit_mate_authentication_agent_1-main.Tpo -c -o polkit_mate_authentication_agent_1-main.obj `if test -f 'main.c'; then $(CYGPATH_W) 'main.c'; else $(CYGPATH_W) '$(srcdir)/main.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/polkit_mate_authentication_agent_1-main.Tpo $(DEPDIR)/polkit_mate_authentication_agent_1-main.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='main.c' object='polkit_mate_authentication_agent_1-main.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(polkit_mate_authentication_agent_1_CPPFLAGS) $(CPPFLAGS) $(polkit_mate_authentication_agent_1_CFLAGS) $(CFLAGS) -c -o polkit_mate_authentication_agent_1-main.obj `if test -f 'main.c'; then $(CYGPATH_W) 'main.c'; else $(CYGPATH_W) '$(srcdir)/main.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +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 + +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; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + 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; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + 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)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__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 "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$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) $(DATA) +installdirs: + for dir in "$(DESTDIR)$(libexecdir)" "$(DESTDIR)$(desktopdir)"; 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: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +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-generic clean-libexecPROGRAMS clean-libtool \ + clean-local 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 + +html-am: + +info: info-am + +info-am: + +install-data-am: install-desktopDATA + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-libexecPROGRAMS + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +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-desktopDATA uninstall-libexecPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libexecPROGRAMS clean-libtool clean-local ctags \ + distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-desktopDATA install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-libexecPROGRAMS \ + install-man install-pdf install-pdf-am install-ps \ + install-ps-am 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-desktopDATA uninstall-libexecPROGRAMS + + +@INTLTOOL_DESKTOP_RULE@ + +polkit-mate-authentication-agent-1.desktop.in : polkit-mate-authentication-agent-1.desktop.in.in + cat polkit-mate-authentication-agent-1.desktop.in.in | sed 's,@FULL_LIBEXECDIR@,$(FULL_LIBEXECDIR),' > $@ + +clean-local : + rm -f *~ polkit-mate-authentication-agent-1.desktop polkit-mate-authentication-agent-1.desktop.in + +# 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/main.c b/src/main.c new file mode 100644 index 0000000..a18dc13 --- /dev/null +++ b/src/main.c @@ -0,0 +1,278 @@ +/* + * Copyright (C) 2009 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * Author: David Zeuthen <[email protected]> + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <string.h> +#include <gtk/gtk.h> +#include <glib/gi18n.h> +#include <polkitagent/polkitagent.h> + +#include "polkitmatelistener.h" + +/* the Authority */ +static PolkitAuthority *authority = NULL; + +/* the session we are servicing */ +static PolkitSubject *session = NULL; + +/* the current set of temporary authorizations */ +static GList *current_temporary_authorizations = NULL; + +static GtkStatusIcon *status_icon = NULL; + +static void +revoke_tmp_authz_cb (GObject *source_object, + GAsyncResult *res, + gpointer user_data) +{ + GError *error; + + error = NULL; + polkit_authority_revoke_temporary_authorizations_finish (POLKIT_AUTHORITY (source_object), + res, + &error); + if (error != NULL) + { + g_warning ("Error revoking temporary authorizations: %s", error->message); + g_error_free (error); + } +} + +static void +revoke_tmp_authz (void) +{ + polkit_authority_revoke_temporary_authorizations (authority, + session, + NULL, + revoke_tmp_authz_cb, + NULL); +} + +static void +on_status_icon_activate (GtkStatusIcon *status_icon, + gpointer user_data) +{ + revoke_tmp_authz (); +} + +static void +on_status_icon_popup_menu (GtkStatusIcon *status_icon, + guint button, + guint activate_time, + gpointer user_data) +{ + revoke_tmp_authz (); +} + +static void +update_temporary_authorization_icon_real (void) +{ + +#if 0 + GList *l; + g_debug ("have %d tmp authorizations", g_list_length (current_temporary_authorizations)); + for (l = current_temporary_authorizations; l != NULL; l = l->next) + { + PolkitTemporaryAuthorization *authz = POLKIT_TEMPORARY_AUTHORIZATION (l->data); + + g_debug ("have tmp authz for action %s (subject %s) with id %s (obtained %d, expires %d)", + polkit_temporary_authorization_get_action_id (authz), + polkit_subject_to_string (polkit_temporary_authorization_get_subject (authz)), + polkit_temporary_authorization_get_id (authz), + (gint) polkit_temporary_authorization_get_time_obtained (authz), + (gint) polkit_temporary_authorization_get_time_expires (authz)); + } +#endif + + /* TODO: + * + * - we could do something fancy like displaying a window with the tmp authz + * when the icon is clicked... + * + * - we could do some work using polkit_subject_exists() to ignore tmp authz + * for subjects that no longer exists.. this is because temporary authorizations + * are only valid for the subject that trigger the authentication dialog. + * + * Maybe the authority could do this, would probably involve some polling, but + * it seems cleaner to do this server side. + */ + + if (current_temporary_authorizations != NULL) + { + /* show icon */ + if (status_icon == NULL) + { + status_icon = gtk_status_icon_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION); + gtk_status_icon_set_tooltip_text (status_icon, + _("Click the icon to drop all elevated privileges")); + g_signal_connect (status_icon, + "activate", + G_CALLBACK (on_status_icon_activate), + NULL); + g_signal_connect (status_icon, + "popup-menu", + G_CALLBACK (on_status_icon_popup_menu), + NULL); + } + } + else + { + /* hide icon */ + if (status_icon != NULL) + { + gtk_status_icon_set_visible (status_icon, FALSE); + g_object_unref (status_icon); + status_icon = NULL; + } + } +} + +static void +enumerate_temporary_authorizations_cb (GObject *source_object, + GAsyncResult *res, + gpointer user_data) +{ + PolkitAuthority *authority = POLKIT_AUTHORITY (source_object); + GList *temporary_authorizations; + GError *error; + + temporary_authorizations = NULL; + + error = NULL; + temporary_authorizations = polkit_authority_enumerate_temporary_authorizations_finish (authority, + res, + &error); + if (error != NULL) + { + g_warning ("Error enumerating temporary authorizations: %s", error->message); + g_error_free (error); + goto out; + } + + g_list_foreach (current_temporary_authorizations, (GFunc) g_object_unref, NULL); + g_list_free (current_temporary_authorizations); + + current_temporary_authorizations = temporary_authorizations; + + update_temporary_authorization_icon_real (); + + out: + ; +} + +static void +update_temporary_authorization_icon (PolkitAuthority *authority) +{ + polkit_authority_enumerate_temporary_authorizations (authority, + session, + NULL, + enumerate_temporary_authorizations_cb, + NULL); +} + +static void +on_authority_changed (PolkitAuthority *authority, + gpointer user_data) +{ + update_temporary_authorization_icon (authority); +} + +int +main (int argc, char **argv) +{ + gint ret; + GMainLoop *loop; + PolkitAgentListener *listener; + GError *error; + + g_type_init (); + gtk_init (&argc, &argv); + + loop = NULL; + authority = NULL; + listener = NULL; + session = NULL; + ret = 1; + + bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR); +#if HAVE_BIND_TEXTDOMAIN_CODESET + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); +#endif + textdomain (GETTEXT_PACKAGE); + + loop = g_main_loop_new (NULL, FALSE); + + error = NULL; + authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error); + if (authority == NULL) + { + g_warning ("Error getting authority: %s", error->message); + g_error_free (error); + goto out; + } + g_signal_connect (authority, + "changed", + G_CALLBACK (on_authority_changed), + NULL); + + listener = polkit_mate_listener_new (); + + error = NULL; + session = polkit_unix_session_new_for_process_sync (getpid (), NULL, &error); + if (error != NULL) + { + g_warning ("Unable to determine the session we are in: %s", error->message); + g_error_free (error); + goto out; + } + + error = NULL; + if (!polkit_agent_register_listener (listener, + session, + "/org/mate/PolicyKit1/AuthenticationAgent", + &error)) + { + g_printerr ("Cannot register authentication agent: %s\n", error->message); + g_error_free (error); + goto out; + } + + update_temporary_authorization_icon (authority); + + g_main_loop_run (loop); + + ret = 0; + + out: + if (authority != NULL) + g_object_unref (authority); + if (session != NULL) + g_object_unref (session); + if (listener != NULL) + g_object_unref (listener); + if (loop != NULL) + g_main_loop_unref (loop); + + return ret; +} diff --git a/src/polkit-mate-authentication-agent-1.desktop.in.in b/src/polkit-mate-authentication-agent-1.desktop.in.in new file mode 100644 index 0000000..7cc1003 --- /dev/null +++ b/src/polkit-mate-authentication-agent-1.desktop.in.in @@ -0,0 +1,9 @@ +[Desktop Entry] +_Name=PolicyKit Authentication Agent +_Comment=PolicyKit Authentication Agent +Exec=@FULL_LIBEXECDIR@/polkit-mate-authentication-agent-1 +Terminal=false +Type=Application +Categories= +NoDisplay=true +OnlyShowIn=MATE; diff --git a/src/polkitmateauthenticationdialog.c b/src/polkitmateauthenticationdialog.c new file mode 100644 index 0000000..0d39890 --- /dev/null +++ b/src/polkitmateauthenticationdialog.c @@ -0,0 +1,1061 @@ +/* + * Copyright (C) 2009 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * Author: David Zeuthen <[email protected]> + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#define _GNU_SOURCE +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <pwd.h> +#include <errno.h> + +#include <glib/gi18n-lib.h> +#include <gtk/gtk.h> + +#include "polkitmateauthenticationdialog.h" + +#define RESPONSE_USER_SELECTED 1001 + +struct _PolkitMateAuthenticationDialogPrivate +{ + GtkWidget *user_combobox; + GtkWidget *prompt_label; + GtkWidget *password_entry; + GtkWidget *auth_button; + GtkWidget *cancel_button; + GtkWidget *info_label; + GtkWidget *table_alignment; + + gchar *message; + gchar *action_id; + gchar *vendor; + gchar *vendor_url; + gchar *icon_name; + PolkitDetails *details; + + gchar **users; + gchar *selected_user; + + gboolean is_running; + + GtkListStore *store; +}; + +G_DEFINE_TYPE (PolkitMateAuthenticationDialog, polkit_mate_authentication_dialog, GTK_TYPE_DIALOG); + +enum { + PROP_0, + PROP_ACTION_ID, + PROP_VENDOR, + PROP_VENDOR_URL, + PROP_ICON_NAME, + PROP_MESSAGE, + PROP_DETAILS, + PROP_USERS, + PROP_SELECTED_USER, +}; + +enum { + PIXBUF_COL, + TEXT_COL, + USERNAME_COL, + N_COL +}; + +static void +user_combobox_set_sensitive (GtkCellLayout *cell_layout, + GtkCellRenderer *cell, + GtkTreeModel *tree_model, + GtkTreeIter *iter, + gpointer user_data) +{ + GtkTreePath *path; + gint *indices; + gboolean sensitive; + + path = gtk_tree_model_get_path (tree_model, iter); + indices = gtk_tree_path_get_indices (path); + if (indices[0] == 0) + sensitive = FALSE; + else + sensitive = TRUE; + gtk_tree_path_free (path); + + g_object_set (cell, "sensitive", sensitive, NULL); +} + +static void +user_combobox_changed (GtkComboBox *widget, + gpointer user_data) +{ + PolkitMateAuthenticationDialog *dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (user_data); + GtkTreeIter iter; + gchar *user_name; + + if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter)) + { + gtk_tree_model_get (GTK_TREE_MODEL (dialog->priv->store), &iter, USERNAME_COL, &user_name, -1); + + g_free (dialog->priv->selected_user); + dialog->priv->selected_user = user_name; + + g_object_notify (G_OBJECT (dialog), "selected-user"); + + gtk_dialog_response (GTK_DIALOG (dialog), RESPONSE_USER_SELECTED); + + /* make the password entry and Authenticate button sensitive again */ + gtk_widget_set_sensitive (dialog->priv->prompt_label, TRUE); + gtk_widget_set_sensitive (dialog->priv->password_entry, TRUE); + gtk_widget_set_sensitive (dialog->priv->auth_button, TRUE); + } +} + +static void +create_user_combobox (PolkitMateAuthenticationDialog *dialog) +{ + int n; + GtkComboBox *combo; + GtkTreeIter iter; + GtkCellRenderer *renderer; + + /* if we've already built the list of admin users once, then avoid + * doing it again.. (this is mainly used when the user entered the + * wrong password and the dialog is recycled) + */ + if (dialog->priv->store != NULL) + return; + + combo = GTK_COMBO_BOX (dialog->priv->user_combobox); + dialog->priv->store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING); + + gtk_list_store_append (dialog->priv->store, &iter); + gtk_list_store_set (dialog->priv->store, &iter, + PIXBUF_COL, NULL, + TEXT_COL, _("Select user..."), + USERNAME_COL, NULL, + -1); + + + /* For each user */ + for (n = 0; dialog->priv->users[n] != NULL; n++) + { + gchar *gecos; + gchar *real_name; + GdkPixbuf *pixbuf; + struct passwd *passwd; + + /* we're single threaded so this is fine */ + errno = 0; + passwd = getpwnam (dialog->priv->users[n]); + if (passwd == NULL) + { + g_warning ("Error doing getpwnam(\"%s\"): %s", dialog->priv->users[n], strerror (errno)); + continue; + } + + if (passwd->pw_gecos != NULL) + gecos = g_locale_to_utf8 (passwd->pw_gecos, -1, NULL, NULL, NULL); + else + gecos = NULL; + + if (gecos != NULL && strlen (gecos) > 0) + { + gchar *first_comma; + first_comma = strchr (gecos, ','); + if (first_comma != NULL) + *first_comma = '\0'; + } + if (gecos != NULL && strlen (gecos) > 0 && strcmp (gecos, dialog->priv->users[n]) != 0) + real_name = g_strdup_printf (_("%s (%s)"), gecos, dialog->priv->users[n]); + else + real_name = g_strdup (dialog->priv->users[n]); + g_free (gecos); + + /* Load users face */ + pixbuf = NULL; + if (passwd->pw_dir != NULL) + { + gchar *path; + path = g_strdup_printf ("%s/.face", passwd->pw_dir); + /* TODO: we probably shouldn't hard-code the size to 16x16 */ + pixbuf = gdk_pixbuf_new_from_file_at_scale (path, 16, 16, TRUE, NULL); + g_free (path); + } + + /* fall back to stock_person icon */ + if (pixbuf == NULL) + { + pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), + "stock_person", + GTK_ICON_SIZE_MENU, + 0, + NULL); + } + + gtk_list_store_append (dialog->priv->store, &iter); + gtk_list_store_set (dialog->priv->store, &iter, + PIXBUF_COL, pixbuf, + TEXT_COL, real_name, + USERNAME_COL, dialog->priv->users[n], + -1); + + g_free (real_name); + g_object_unref (pixbuf); + } + + gtk_combo_box_set_model (combo, GTK_TREE_MODEL (dialog->priv->store)); + + renderer = gtk_cell_renderer_pixbuf_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), + renderer, + "pixbuf", PIXBUF_COL, + NULL); + gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo), + renderer, + user_combobox_set_sensitive, + NULL, NULL); + + renderer = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), + renderer, + "text", TEXT_COL, + NULL); + gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo), + renderer, + user_combobox_set_sensitive, + NULL, NULL); + + /* Initially select the "Select user..." ... */ + gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0); + + /* Listen when a new user is selected */ + g_signal_connect (GTK_WIDGET (combo), + "changed", + G_CALLBACK (user_combobox_changed), + dialog); +} + +static GtkWidget * +get_image (PolkitMateAuthenticationDialog *dialog) +{ + GdkPixbuf *pixbuf; + GdkPixbuf *copy_pixbuf; + GdkPixbuf *vendor_pixbuf; + GtkWidget *image; + + pixbuf = NULL; + copy_pixbuf = NULL; + vendor_pixbuf = NULL; + + if (dialog->priv->icon_name == NULL || strlen (dialog->priv->icon_name) == 0) + { + image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION, GTK_ICON_SIZE_DIALOG); + goto out; + } + + vendor_pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), + dialog->priv->icon_name, + 48, + 0, + NULL); + if (vendor_pixbuf == NULL) + { + g_warning ("No icon for themed icon with name '%s'", dialog->priv->icon_name); + image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION, GTK_ICON_SIZE_DIALOG); + goto out; + } + + + pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), + GTK_STOCK_DIALOG_AUTHENTICATION, + 48, + 0, + NULL); + if (pixbuf == NULL) + goto out; + + /* need to copy the pixbuf since we're modifying it */ + copy_pixbuf = gdk_pixbuf_copy (pixbuf); + if (copy_pixbuf == NULL) + goto out; + + /* blend the vendor icon in the bottom right quarter */ + gdk_pixbuf_composite (vendor_pixbuf, + copy_pixbuf, + 24, 24, 24, 24, + 24, 24, 0.5, 0.5, + GDK_INTERP_BILINEAR, + 255); + + image = gtk_image_new_from_pixbuf (copy_pixbuf); + +out: + if (pixbuf != NULL) + g_object_unref (pixbuf); + + if (copy_pixbuf != NULL) + g_object_unref (copy_pixbuf); + + if (vendor_pixbuf != NULL) + g_object_unref (vendor_pixbuf); + + return image; +} + +static void +polkit_mate_authentication_dialog_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + PolkitMateAuthenticationDialog *dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object); + + switch (prop_id) + { + case PROP_DETAILS: + dialog->priv->details = g_value_dup_object (value); + break; + + case PROP_ACTION_ID: + dialog->priv->action_id = g_value_dup_string (value); + break; + + case PROP_VENDOR: + dialog->priv->vendor = g_value_dup_string (value); + break; + + case PROP_VENDOR_URL: + dialog->priv->vendor_url = g_value_dup_string (value); + break; + + case PROP_ICON_NAME: + dialog->priv->icon_name = g_value_dup_string (value); + break; + + case PROP_MESSAGE: + dialog->priv->message = g_value_dup_string (value); + break; + + case PROP_USERS: + dialog->priv->users = g_value_dup_boxed (value); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +polkit_mate_authentication_dialog_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + PolkitMateAuthenticationDialog *dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object); + + switch (prop_id) + { + case PROP_MESSAGE: + g_value_set_string (value, dialog->priv->message); + break; + + /* TODO: rest of the properties */ + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static GtkWidget * +add_row (GtkWidget *table, int row, const char *label_text, GtkWidget *entry) +{ + GtkWidget *label; + + label = gtk_label_new_with_mnemonic (label_text); + gtk_label_set_use_markup (GTK_LABEL (label), TRUE); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); + + gtk_table_attach (GTK_TABLE (table), label, + 0, 1, row, row + 1, + GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_table_attach_defaults (GTK_TABLE (table), entry, + 1, 2, row, row + 1); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry); + + return label; +} + +static void +action_id_activated (GtkLabel *url_label, gpointer user_data) +{ +#if 0 + GError *error; + DBusGConnection *bus; + DBusGProxy *manager_proxy; + + error = NULL; + bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error); + if (bus == NULL) + { + g_warning ("Couldn't connect to session bus: %s", error->message); + g_error_free (error); + goto out; + } + + manager_proxy = dbus_g_proxy_new_for_name (bus, + "org.mate.PolicyKit.AuthorizationManager", + "/", + "org.mate.PolicyKit.AuthorizationManager.SingleInstance"); + if (manager_proxy == NULL) + { + g_warning ("Could not construct manager_proxy object; bailing out"); + goto out; + } + + if (!dbus_g_proxy_call (manager_proxy, + "ShowAction", + &error, + G_TYPE_STRING, gtk_label_get_current_uri (GTK_LABEL (url_label)), + G_TYPE_INVALID, + G_TYPE_INVALID)) + { + if (error != NULL) + { + g_warning ("Failed to call into manager: %s", error->message); + g_error_free (error); + } + else + { + g_warning ("Failed to call into manager"); + } + goto out; + } + +out: + ; +#endif +} + +static void +polkit_mate_authentication_dialog_init (PolkitMateAuthenticationDialog *dialog) +{ + dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (dialog, + POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG, + PolkitMateAuthenticationDialogPrivate); +} + +static void +polkit_mate_authentication_dialog_finalize (GObject *object) +{ + PolkitMateAuthenticationDialog *dialog; + + dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object); + + g_free (dialog->priv->message); + g_free (dialog->priv->action_id); + g_free (dialog->priv->vendor); + g_free (dialog->priv->vendor_url); + g_free (dialog->priv->icon_name); + if (dialog->priv->details != NULL) + g_object_unref (dialog->priv->details); + + g_strfreev (dialog->priv->users); + g_free (dialog->priv->selected_user); + + if (dialog->priv->store != NULL) + g_object_unref (dialog->priv->store); + + if (G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->finalize != NULL) + G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->finalize (object); +} + +static void +polkit_mate_authentication_dialog_constructed (GObject *object) +{ + PolkitMateAuthenticationDialog *dialog; + GtkWidget *hbox; + GtkWidget *main_vbox; + GtkWidget *vbox; + GtkWidget *table_alignment; + GtkWidget *table; + GtkWidget *details_expander; + GtkWidget *details_vbox; + GtkWidget *label; + GtkWidget *image; + GtkWidget *content_area; + GtkWidget *action_area; + gboolean have_user_combobox; + gchar *s; + guint rows; + + dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object); + + if (G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->constructed != NULL) + G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->constructed (object); + + have_user_combobox = FALSE; + + dialog->priv->cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog), + GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL); + dialog->priv->auth_button = gtk_dialog_add_button (GTK_DIALOG (dialog), + _("_Authenticate"), + GTK_RESPONSE_OK); + gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); + + content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); + action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog)); + + gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); + gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); + gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */ + gtk_container_set_border_width (GTK_CONTAINER (action_area), 5); + gtk_box_set_spacing (GTK_BOX (action_area), 6); + gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); + gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_DIALOG_AUTHENTICATION); + + hbox = gtk_hbox_new (FALSE, 12); + gtk_container_set_border_width (GTK_CONTAINER (hbox), 5); + gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 0); + + image = get_image (dialog); + gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0); + gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); + + main_vbox = gtk_vbox_new (FALSE, 10); + gtk_box_pack_start (GTK_BOX (hbox), main_vbox, TRUE, TRUE, 0); + + /* main message */ + label = gtk_label_new (NULL); + s = g_strdup_printf ("<big><b>%s</b></big>", dialog->priv->message); + gtk_label_set_markup (GTK_LABEL (label), s); + g_free (s); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); + gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0); + + /* secondary message */ + label = gtk_label_new (NULL); + if (g_strv_length (dialog->priv->users) > 1) + { + gtk_label_set_markup (GTK_LABEL (label), + _("An application is attempting to perform an action that requires privileges. " + "Authentication as one of the users below is required to perform this action.")); + } + else + { + if (strcmp (g_get_user_name (), dialog->priv->users[0]) == 0) + { + gtk_label_set_markup (GTK_LABEL (label), + _("An application is attempting to perform an action that requires privileges. " + "Authentication is required to perform this action.")); + } + else + { + gtk_label_set_markup (GTK_LABEL (label), + _("An application is attempting to perform an action that requires privileges. " + "Authentication as the super user is required to perform this action.")); + } + } + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); + gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0); + + /* user combobox */ + if (g_strv_length (dialog->priv->users) > 1) + { + dialog->priv->user_combobox = gtk_combo_box_new (); + gtk_box_pack_start (GTK_BOX (main_vbox), GTK_WIDGET (dialog->priv->user_combobox), FALSE, FALSE, 0); + + create_user_combobox (dialog); + + have_user_combobox = TRUE; + } + else + { + dialog->priv->selected_user = g_strdup (dialog->priv->users[0]); + } + + /* password entry */ + vbox = gtk_vbox_new (FALSE, 0); + gtk_box_pack_start (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0); + + table_alignment = gtk_alignment_new (0.0, 0.0, 1.0, 1.0); + gtk_box_pack_start (GTK_BOX (vbox), table_alignment, FALSE, FALSE, 0); + table = gtk_table_new (1, 2, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 12); + gtk_table_set_row_spacings (GTK_TABLE (table), 6); + gtk_container_add (GTK_CONTAINER (table_alignment), table); + dialog->priv->password_entry = gtk_entry_new (); + gtk_entry_set_visibility (GTK_ENTRY (dialog->priv->password_entry), FALSE); + dialog->priv->prompt_label = add_row (table, 0, _("_Password:"), dialog->priv->password_entry); + + g_signal_connect_swapped (dialog->priv->password_entry, "activate", + G_CALLBACK (gtk_window_activate_default), + dialog); + + dialog->priv->table_alignment = table_alignment; + /* initially never show the password entry stuff; we'll toggle it on/off so it's + * only shown when prompting for a password */ + gtk_widget_set_no_show_all (dialog->priv->table_alignment, TRUE); + + /* A label for showing PAM_TEXT_INFO and PAM_TEXT_ERROR messages */ + label = gtk_label_new (NULL); + gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + dialog->priv->info_label = label; + + /* Details */ + details_expander = gtk_expander_new_with_mnemonic (_("<small><b>_Details</b></small>")); + gtk_expander_set_use_markup (GTK_EXPANDER (details_expander), TRUE); + gtk_box_pack_start (GTK_BOX (content_area), details_expander, FALSE, FALSE, 0); + + details_vbox = gtk_vbox_new (FALSE, 10); + gtk_container_add (GTK_CONTAINER (details_expander), details_vbox); + + table_alignment = gtk_alignment_new (0.0, 0.0, 1.0, 1.0); + gtk_box_pack_start (GTK_BOX (details_vbox), table_alignment, FALSE, FALSE, 0); + table = gtk_table_new (1, 3, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 12); + gtk_table_set_row_spacings (GTK_TABLE (table), 6); + gtk_container_add (GTK_CONTAINER (table_alignment), table); + + /* TODO: sort keys? */ + rows = 0; + if (dialog->priv->details != NULL) + { + guint n; + gchar **keys; + + keys = polkit_details_get_keys (dialog->priv->details); + for (n = 0; keys[n] != NULL; n++) + { + const gchar *key = keys[n]; + const gchar *value; + + value = polkit_details_lookup (dialog->priv->details, key); + + label = gtk_label_new (NULL); + s = g_strdup_printf ("<small>%s</small>", value); + gtk_label_set_markup (GTK_LABEL (label), s); + g_free (s); + gtk_misc_set_alignment (GTK_MISC (label), 0, 1.0); + s = g_strdup_printf ("<small><b>%s:</b></small>", key); + add_row (table, rows, s, label); + g_free (s); + + rows++; + } + g_strfreev (keys); + } + + /* --- */ + + label = gtk_label_new (NULL); + gtk_label_set_use_markup (GTK_LABEL (label), TRUE); + s = g_strdup_printf ("<small><a href=\"%s\">%s</a></small>", + dialog->priv->action_id, + dialog->priv->action_id); + gtk_label_set_markup (GTK_LABEL (label), s); + g_free (s); + gtk_misc_set_alignment (GTK_MISC (label), 0, 1.0); + add_row (table, rows++, _("<small><b>Action:</b></small>"), label); + g_signal_connect (label, "activate-link", G_CALLBACK (action_id_activated), NULL); + + s = g_strdup_printf (_("Click to edit %s"), dialog->priv->action_id); + gtk_widget_set_tooltip_markup (label, s); + g_free (s); + + /* --- */ + + label = gtk_label_new (NULL); + gtk_label_set_use_markup (GTK_LABEL (label), TRUE); + s = g_strdup_printf ("<small><a href=\"%s\">%s</a></small>", + dialog->priv->vendor_url, + dialog->priv->vendor); + gtk_label_set_markup (GTK_LABEL (label), s); + g_free (s); + gtk_misc_set_alignment (GTK_MISC (label), 0, 1.0); + add_row (table, rows++, _("<small><b>Vendor:</b></small>"), label); + + s = g_strdup_printf (_("Click to open %s"), dialog->priv->vendor_url); + gtk_widget_set_tooltip_markup (label, s); + g_free (s); + + if (have_user_combobox) + { + /* ... and make the password entry and "Authenticate" button insensitive */ + gtk_widget_set_sensitive (dialog->priv->prompt_label, FALSE); + gtk_widget_set_sensitive (dialog->priv->password_entry, FALSE); + gtk_widget_set_sensitive (dialog->priv->auth_button, FALSE); + } + else + { + } + + gtk_widget_realize (GTK_WIDGET (dialog)); + +} + +static void +polkit_mate_authentication_dialog_class_init (PolkitMateAuthenticationDialogClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (klass, sizeof (PolkitMateAuthenticationDialogPrivate)); + + gobject_class->finalize = polkit_mate_authentication_dialog_finalize; + gobject_class->get_property = polkit_mate_authentication_dialog_get_property; + gobject_class->set_property = polkit_mate_authentication_dialog_set_property; + gobject_class->constructed = polkit_mate_authentication_dialog_constructed; + + g_object_class_install_property (gobject_class, + PROP_DETAILS, + g_param_spec_object ("details", + NULL, + NULL, + POLKIT_TYPE_DETAILS, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_NAME | + G_PARAM_STATIC_NICK | + G_PARAM_STATIC_BLURB)); + + g_object_class_install_property (gobject_class, + PROP_ACTION_ID, + g_param_spec_string ("action-id", + NULL, + NULL, + NULL, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_NAME | + G_PARAM_STATIC_NICK | + G_PARAM_STATIC_BLURB)); + + g_object_class_install_property (gobject_class, + PROP_VENDOR, + g_param_spec_string ("vendor", + NULL, + NULL, + NULL, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_NAME | + G_PARAM_STATIC_NICK | + G_PARAM_STATIC_BLURB)); + + g_object_class_install_property (gobject_class, + PROP_VENDOR_URL, + g_param_spec_string ("vendor-url", + NULL, + NULL, + NULL, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_NAME | + G_PARAM_STATIC_NICK | + G_PARAM_STATIC_BLURB)); + + g_object_class_install_property (gobject_class, + PROP_ICON_NAME, + g_param_spec_string ("icon-name", + NULL, + NULL, + NULL, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_NAME | + G_PARAM_STATIC_NICK | + G_PARAM_STATIC_BLURB)); + + + g_object_class_install_property (gobject_class, + PROP_MESSAGE, + g_param_spec_string ("message", + NULL, + NULL, + NULL, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_NAME | + G_PARAM_STATIC_NICK | + G_PARAM_STATIC_BLURB)); + + g_object_class_install_property (gobject_class, + PROP_USERS, + g_param_spec_boxed ("users", + NULL, + NULL, + G_TYPE_STRV, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_NAME | + G_PARAM_STATIC_NICK | + G_PARAM_STATIC_BLURB)); + + g_object_class_install_property (gobject_class, + PROP_SELECTED_USER, + g_param_spec_string ("selected-user", + NULL, + NULL, + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_NAME | + G_PARAM_STATIC_NICK | + G_PARAM_STATIC_BLURB)); +} + +/** + * polkit_mate_authentication_dialog_new: + * + * Yada yada yada... + * + * Returns: A new password dialog. + **/ +GtkWidget * +polkit_mate_authentication_dialog_new (const gchar *action_id, + const gchar *vendor, + const gchar *vendor_url, + const gchar *icon_name, + const gchar *message_markup, + PolkitDetails *details, + gchar **users) +{ + PolkitMateAuthenticationDialog *dialog; + GtkWindow *window; + + dialog = g_object_new (POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG, + "action-id", action_id, + "vendor", vendor, + "vendor-url", vendor_url, + "icon-name", icon_name, + "message", message_markup, + "details", details, + "users", users, + NULL); + + window = GTK_WINDOW (dialog); + + gtk_window_set_position (window, GTK_WIN_POS_CENTER); + gtk_window_set_modal (window, TRUE); + gtk_window_set_resizable (window, FALSE); + gtk_window_set_keep_above (window, TRUE); + gtk_window_set_title (window, _("Authenticate")); + g_signal_connect (dialog, "close", G_CALLBACK (gtk_widget_hide), NULL); + + return GTK_WIDGET (dialog); +} + +/** + * polkit_mate_authentication_dialog_indicate_error: + * @dialog: the auth dialog + * + * Call this function to indicate an authentication error; typically shakes the window + **/ +void +polkit_mate_authentication_dialog_indicate_error (PolkitMateAuthenticationDialog *dialog) +{ + int x, y; + int n; + int diff; + + /* TODO: detect compositing manager and do fancy stuff here */ + + gtk_window_get_position (GTK_WINDOW (dialog), &x, &y); + + for (n = 0; n < 10; n++) + { + if (n % 2 == 0) + diff = -15; + else + diff = 15; + + gtk_window_move (GTK_WINDOW (dialog), x + diff, y); + + while (gtk_events_pending ()) + { + gtk_main_iteration (); + } + + g_usleep (10000); + } + + gtk_window_move (GTK_WINDOW (dialog), x, y); +} + +/** + * polkit_mate_authentication_dialog_run_until_user_is_selected: + * @dialog: A #PolkitMateAuthenticationDialog. + * + * Runs @dialog in a recursive main loop until a user have been selected. + * + * If there is only one element in the the users array (which is set upon construction) or + * an user has already been selected, this function returns immediately with the return + * value %TRUE. + * + * Returns: %TRUE if a user is selected (use polkit_mate_dialog_get_selected_user() to obtain the user) or + * %FALSE if the dialog was cancelled. + **/ +gboolean +polkit_mate_authentication_dialog_run_until_user_is_selected (PolkitMateAuthenticationDialog *dialog) +{ + gboolean ret; + gint response; + + ret = FALSE; + + if (dialog->priv->selected_user != NULL) + { + ret = TRUE; + goto out; + } + + dialog->priv->is_running = TRUE; + + response = gtk_dialog_run (GTK_DIALOG (dialog)); + + dialog->priv->is_running = FALSE; + + if (response == RESPONSE_USER_SELECTED) + ret = TRUE; + + out: + return ret; +} + +/** + * polkit_mate_authentication_dialog_run_until_response_for_prompt: + * @dialog: A #PolkitMateAuthenticationDialog. + * @prompt: The prompt to present the user with. + * @echo_chars: Whether characters should be echoed in the password entry box. + * @was_cancelled: Set to %TRUE if the dialog was cancelled. + * @new_user_selected: Set to %TRUE if another user was selected. + * + * Runs @dialog in a recursive main loop until a response to @prompt have been obtained from the user. + * + * Returns: The response (free with g_free()) or %NULL if one of @was_cancelled or @new_user_selected + * has been set to %TRUE. + **/ +gchar * +polkit_mate_authentication_dialog_run_until_response_for_prompt (PolkitMateAuthenticationDialog *dialog, + const gchar *prompt, + gboolean echo_chars, + gboolean *was_cancelled, + gboolean *new_user_selected) +{ + gint response; + gchar *ret; + + gtk_label_set_text_with_mnemonic (GTK_LABEL (dialog->priv->prompt_label), prompt); + gtk_entry_set_visibility (GTK_ENTRY (dialog->priv->password_entry), echo_chars); + gtk_entry_set_text (GTK_ENTRY (dialog->priv->password_entry), ""); + gtk_widget_grab_focus (dialog->priv->password_entry); + + ret = NULL; + + if (was_cancelled != NULL) + *was_cancelled = FALSE; + + if (new_user_selected != NULL) + *new_user_selected = FALSE; + + dialog->priv->is_running = TRUE; + + gtk_widget_set_no_show_all (dialog->priv->table_alignment, FALSE); + gtk_widget_show_all (dialog->priv->table_alignment); + + response = gtk_dialog_run (GTK_DIALOG (dialog)); + + gtk_widget_hide_all (dialog->priv->table_alignment); + gtk_widget_set_no_show_all (dialog->priv->table_alignment, TRUE); + + dialog->priv->is_running = FALSE; + + if (response == GTK_RESPONSE_OK) + { + ret = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->priv->password_entry))); + } + else if (response == RESPONSE_USER_SELECTED) + { + if (new_user_selected != NULL) + *new_user_selected = TRUE; + } + else + { + if (was_cancelled != NULL) + *was_cancelled = TRUE; + } + + return ret; +} + +/** + * polkit_mate_authentication_dialog_get_selected_user: + * @dialog: A #PolkitMateAuthenticationDialog. + * + * Gets the currently selected user. + * + * Returns: The currently selected user (free with g_free()) or %NULL if no user is currently selected. + **/ +gchar * +polkit_mate_authentication_dialog_get_selected_user (PolkitMateAuthenticationDialog *dialog) +{ + return g_strdup (dialog->priv->selected_user); +} + +void +polkit_mate_authentication_dialog_set_info_message (PolkitMateAuthenticationDialog *dialog, + const gchar *info_markup) +{ + gtk_label_set_markup (GTK_LABEL (dialog->priv->info_label), info_markup); +} + + +/** + * polkit_mate_authentication_dialog_cancel: + * @dialog: A #PolkitMateAuthenticationDialog. + * + * Cancels the dialog if it is currenlty running. + * + * Returns: %TRUE if the dialog was running. + **/ +gboolean +polkit_mate_authentication_dialog_cancel (PolkitMateAuthenticationDialog *dialog) +{ + if (!dialog->priv->is_running) + return FALSE; + + gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL); + + return TRUE; +} diff --git a/src/polkitmateauthenticationdialog.h b/src/polkitmateauthenticationdialog.h new file mode 100644 index 0000000..debcf1b --- /dev/null +++ b/src/polkitmateauthenticationdialog.h @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2009 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * Author: David Zeuthen <[email protected]> + */ + +#ifndef __POLKIT_MATE_AUTHENTICATION_DIALOG_H +#define __POLKIT_MATE_AUTHENTICATION_DIALOG_H + +#include <gtk/gtk.h> +#include <polkit/polkit.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG (polkit_mate_authentication_dialog_get_type ()) +#define POLKIT_MATE_AUTHENTICATION_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG, PolkitMateAuthenticationDialog)) +#define POLKIT_MATE_AUTHENTICATION_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG, PolkitMateAuthenticationDialogClass)) +#define POLKIT_MATE_IS_AUTHENTICATION_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG)) +#define POLKIT_MATE_IS_AUTHENTICATION_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG)) + +typedef struct _PolkitMateAuthenticationDialog PolkitMateAuthenticationDialog; +typedef struct _PolkitMateAuthenticationDialogClass PolkitMateAuthenticationDialogClass; +typedef struct _PolkitMateAuthenticationDialogPrivate PolkitMateAuthenticationDialogPrivate; + +struct _PolkitMateAuthenticationDialog +{ + GtkDialog parent_instance; + PolkitMateAuthenticationDialogPrivate *priv; +}; + +struct _PolkitMateAuthenticationDialogClass +{ + GtkDialogClass parent_class; +}; + +GType polkit_mate_authentication_dialog_get_type (void); +GtkWidget *polkit_mate_authentication_dialog_new (const gchar *action_id, + const gchar *vendor, + const gchar *vendor_url, + const gchar *icon_name, + const gchar *message_markup, + PolkitDetails *details, + gchar **users); +gchar *polkit_mate_authentication_dialog_get_selected_user (PolkitMateAuthenticationDialog *dialog); +gboolean polkit_mate_authentication_dialog_run_until_user_is_selected (PolkitMateAuthenticationDialog *dialog); +gchar *polkit_mate_authentication_dialog_run_until_response_for_prompt (PolkitMateAuthenticationDialog *dialog, + const gchar *prompt, + gboolean echo_chars, + gboolean *was_cancelled, + gboolean *new_user_selected); +gboolean polkit_mate_authentication_dialog_cancel (PolkitMateAuthenticationDialog *dialog); +void polkit_mate_authentication_dialog_indicate_error (PolkitMateAuthenticationDialog *dialog); +void polkit_mate_authentication_dialog_set_info_message (PolkitMateAuthenticationDialog *dialog, + const gchar *info_markup); + +#ifdef __cplusplus +} +#endif + +#endif /* __POLKIT_MATE_AUTHENTICATION_DIALOG_H */ diff --git a/src/polkitmateauthenticator.c b/src/polkitmateauthenticator.c new file mode 100644 index 0000000..11d28d2 --- /dev/null +++ b/src/polkitmateauthenticator.c @@ -0,0 +1,508 @@ +/* + * Copyright (C) 2009 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * Author: David Zeuthen <[email protected]> + */ + + +#include "config.h" + +#include <string.h> +#include <sys/types.h> +#include <pwd.h> +#include <glib/gi18n.h> + +#include <polkit/polkit.h> +#include <polkitagent/polkitagent.h> + +#include "polkitmateauthenticator.h" +#include "polkitmateauthenticationdialog.h" + +struct _PolkitMateAuthenticator +{ + GObject parent_instance; + + PolkitAuthority *authority; + gchar *action_id; + gchar *message; + gchar *icon_name; + PolkitDetails *details; + gchar *cookie; + GList *identities; + + PolkitActionDescription *action_desc; + gchar **users; + + gboolean gained_authorization; + gboolean was_cancelled; + gboolean new_user_selected; + gchar *selected_user; + + PolkitAgentSession *session; + GtkWidget *dialog; + GMainLoop *loop; +}; + +struct _PolkitMateAuthenticatorClass +{ + GObjectClass parent_class; + +}; + +enum +{ + COMPLETED_SIGNAL, + LAST_SIGNAL, +}; + +static guint signals[LAST_SIGNAL] = {0}; + +G_DEFINE_TYPE (PolkitMateAuthenticator, polkit_mate_authenticator, G_TYPE_OBJECT); + +static void +polkit_mate_authenticator_init (PolkitMateAuthenticator *authenticator) +{ +} + +static void +polkit_mate_authenticator_finalize (GObject *object) +{ + PolkitMateAuthenticator *authenticator; + + authenticator = POLKIT_MATE_AUTHENTICATOR (object); + + if (authenticator->authority != NULL) + g_object_unref (authenticator->authority); + g_free (authenticator->action_id); + g_free (authenticator->message); + g_free (authenticator->icon_name); + if (authenticator->details != NULL) + g_object_unref (authenticator->details); + g_free (authenticator->cookie); + g_list_foreach (authenticator->identities, (GFunc) g_object_unref, NULL); + g_list_free (authenticator->identities); + + if (authenticator->action_desc != NULL) + g_object_unref (authenticator->action_desc); + g_strfreev (authenticator->users); + + g_free (authenticator->selected_user); + if (authenticator->session != NULL) + g_object_unref (authenticator->session); + if (authenticator->dialog != NULL) + gtk_widget_destroy (authenticator->dialog); + if (authenticator->loop != NULL) + g_main_loop_unref (authenticator->loop); + + if (G_OBJECT_CLASS (polkit_mate_authenticator_parent_class)->finalize != NULL) + G_OBJECT_CLASS (polkit_mate_authenticator_parent_class)->finalize (object); +} + +static void +polkit_mate_authenticator_class_init (PolkitMateAuthenticatorClass *klass) +{ + GObjectClass *gobject_class; + + gobject_class = G_OBJECT_CLASS (klass); + + gobject_class->finalize = polkit_mate_authenticator_finalize; + + /** + * PolkitMateAuthenticator::completed: + * @authenticator: A #PolkitMateAuthenticator. + * @gained_authorization: Whether the authorization was gained. + * + * Emitted when the authentication is completed. The user is supposed to dispose of @authenticator + * upon receiving this signal. + **/ + signals[COMPLETED_SIGNAL] = g_signal_new ("completed", + POLKIT_MATE_TYPE_AUTHENTICATOR, + G_SIGNAL_RUN_LAST, + 0, /* class offset */ + NULL, /* accumulator */ + NULL, /* accumulator data */ + g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, + 1, + G_TYPE_BOOLEAN); +} + +static PolkitActionDescription * +get_desc_for_action (PolkitAuthority *authority, + const gchar *action_id) +{ + GList *action_descs; + GList *l; + PolkitActionDescription *result; + + result = NULL; + + action_descs = polkit_authority_enumerate_actions_sync (authority, + NULL, + NULL); + for (l = action_descs; l != NULL; l = l->next) + { + PolkitActionDescription *action_desc = POLKIT_ACTION_DESCRIPTION (l->data); + + if (strcmp (polkit_action_description_get_action_id (action_desc), action_id) == 0) + { + result = g_object_ref (action_desc); + goto out; + } + } + + out: + + g_list_foreach (action_descs, (GFunc) g_object_unref, NULL); + g_list_free (action_descs); + + return result; +} + +static void +on_dialog_deleted (GtkWidget *widget, + GdkEvent *event, + gpointer user_data) +{ + PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data); + + polkit_mate_authenticator_cancel (authenticator); +} + +static void +on_user_selected (GObject *object, + GParamSpec *pspec, + gpointer user_data) +{ + PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data); + + /* clear any previous messages */ + polkit_mate_authentication_dialog_set_info_message (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog), ""); + + polkit_mate_authenticator_cancel (authenticator); + authenticator->new_user_selected = TRUE; +} + +PolkitMateAuthenticator * +polkit_mate_authenticator_new (const gchar *action_id, + const gchar *message, + const gchar *icon_name, + PolkitDetails *details, + const gchar *cookie, + GList *identities) +{ + PolkitMateAuthenticator *authenticator; + GList *l; + guint n; + GError *error; + + authenticator = POLKIT_MATE_AUTHENTICATOR (g_object_new (POLKIT_MATE_TYPE_AUTHENTICATOR, NULL)); + + error = NULL; + authenticator->authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error); + if (authenticator->authority == NULL) + { + g_critical ("Error getting authority: %s", error->message); + g_error_free (error); + goto error; + } + + authenticator->action_id = g_strdup (action_id); + authenticator->message = g_strdup (message); + authenticator->icon_name = g_strdup (icon_name); + if (details != NULL) + authenticator->details = g_object_ref (details); + authenticator->cookie = g_strdup (cookie); + authenticator->identities = g_list_copy (identities); + g_list_foreach (authenticator->identities, (GFunc) g_object_ref, NULL); + + authenticator->action_desc = get_desc_for_action (authenticator->authority, + authenticator->action_id); + if (authenticator->action_desc == NULL) + goto error; + + authenticator->users = g_new0 (gchar *, g_list_length (authenticator->identities) + 1); + for (l = authenticator->identities, n = 0; l != NULL; l = l->next, n++) + { + PolkitUnixUser *user = POLKIT_UNIX_USER (l->data); + uid_t uid; + struct passwd *passwd; + + uid = polkit_unix_user_get_uid (user); + passwd = getpwuid (uid); + authenticator->users[n] = g_strdup (passwd->pw_name); + } + + authenticator->dialog = polkit_mate_authentication_dialog_new + (authenticator->action_id, + polkit_action_description_get_vendor_name (authenticator->action_desc), + polkit_action_description_get_vendor_url (authenticator->action_desc), + authenticator->icon_name, + authenticator->message, + authenticator->details, + authenticator->users); + g_signal_connect (authenticator->dialog, + "delete-event", + G_CALLBACK (on_dialog_deleted), + authenticator); + g_signal_connect (authenticator->dialog, + "notify::selected-user", + G_CALLBACK (on_user_selected), + authenticator); + + return authenticator; + + error: + g_object_unref (authenticator); + return NULL; +} + +static void +session_request (PolkitAgentSession *session, + const char *request, + gboolean echo_on, + gpointer user_data) +{ + PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data); + gchar *password; + gchar *modified_request; + + password = NULL; + + //g_debug ("in conversation_pam_prompt, request='%s', echo_on=%d", request, echo_on); + + /* Fix up, and localize, password prompt if it's password auth */ + if (g_ascii_strncasecmp (request, "password:", 9) == 0) + { + if (strcmp (g_get_user_name (), authenticator->selected_user) != 0) + { + modified_request = g_strdup_printf (_("_Password for %s:"), authenticator->selected_user); + } + else + { + modified_request = g_strdup (_("_Password:")); + } + } + else + { + modified_request = g_strdup (request); + } + + gtk_widget_show_all (GTK_WIDGET (authenticator->dialog)); + gtk_window_present (GTK_WINDOW (authenticator->dialog)); + password = polkit_mate_authentication_dialog_run_until_response_for_prompt (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog), + modified_request, + echo_on, + &authenticator->was_cancelled, + &authenticator->new_user_selected); + + /* cancel auth unless user provided a password */ + if (password == NULL) + { + polkit_mate_authenticator_cancel (authenticator); + goto out; + } + else + { + polkit_agent_session_response (authenticator->session, password); + g_free (password); + } + +out: + g_free (modified_request); +} + +static void +session_show_error (PolkitAgentSession *session, + const gchar *msg, + gpointer user_data) +{ + PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data); + gchar *s; + + s = g_strconcat ("<b>", msg, "</b>", NULL); + polkit_mate_authentication_dialog_set_info_message (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog), s); + g_free (s); +} + +static void +session_show_info (PolkitAgentSession *session, + const gchar *msg, + gpointer user_data) +{ + PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data); + gchar *s; + + s = g_strconcat ("<b>", msg, "</b>", NULL); + polkit_mate_authentication_dialog_set_info_message (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog), s); + g_free (s); + + gtk_widget_show_all (GTK_WIDGET (authenticator->dialog)); + gtk_window_present (GTK_WINDOW (authenticator->dialog)); +} + + +static void +session_completed (PolkitAgentSession *session, + gboolean gained_authorization, + gpointer user_data) +{ + PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data); + + authenticator->gained_authorization = gained_authorization; + + //g_debug ("in conversation_done gained=%d", gained_authorization); + + g_main_loop_quit (authenticator->loop); +} + + +static gboolean +do_initiate (gpointer user_data) +{ + PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data); + PolkitIdentity *identity; + gint num_tries; + + gtk_widget_show_all (GTK_WIDGET (authenticator->dialog)); + gtk_window_present (GTK_WINDOW (authenticator->dialog)); + if (!polkit_mate_authentication_dialog_run_until_user_is_selected (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog))) + { + /* user cancelled the dialog */ + /*g_debug ("User cancelled before selecting a user");*/ + authenticator->was_cancelled = TRUE; + goto out; + } + + authenticator->loop = g_main_loop_new (NULL, TRUE); + + num_tries = 0; + + try_again: + + g_free (authenticator->selected_user); + authenticator->selected_user = polkit_mate_authentication_dialog_get_selected_user (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog)); + + /*g_debug ("Authenticating user %s", authenticator->selected_user);*/ + identity = polkit_unix_user_new_for_name (authenticator->selected_user, NULL); + + authenticator->session = polkit_agent_session_new (identity, authenticator->cookie); + + g_object_unref (identity); + + g_signal_connect (authenticator->session, + "request", + G_CALLBACK (session_request), + authenticator); + + g_signal_connect (authenticator->session, + "show-info", + G_CALLBACK (session_show_info), + authenticator); + + g_signal_connect (authenticator->session, + "show-error", + G_CALLBACK (session_show_error), + authenticator); + + g_signal_connect (authenticator->session, + "completed", + G_CALLBACK (session_completed), + authenticator); + + polkit_agent_session_initiate (authenticator->session); + + g_main_loop_run (authenticator->loop); + + /*g_debug ("gained_authorization=%d was_cancelled=%d new_user_selected=%d.", + authenticator->gained_authorization, + authenticator->was_cancelled, + authenticator->new_user_selected);*/ + + if (authenticator->new_user_selected) + { + /*g_debug ("New user selected");*/ + authenticator->new_user_selected = FALSE; + g_object_unref (authenticator->session); + authenticator->session = NULL; + goto try_again; + } + + num_tries++; + + if (!authenticator->gained_authorization && !authenticator->was_cancelled) + { + if (authenticator->dialog != NULL) + { + gchar *s; + + s = g_strconcat ("<b>", _("Authentication Failure"), "</b>", NULL); + polkit_mate_authentication_dialog_set_info_message ( + POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog), + s); + g_free (s); + gtk_widget_queue_draw (authenticator->dialog); + + /* shake the dialog to indicate error */ + polkit_mate_authentication_dialog_indicate_error (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog)); + + if (num_tries < 3) + { + g_object_unref (authenticator->session); + authenticator->session = NULL; + goto try_again; + } + } + } + + out: + g_signal_emit_by_name (authenticator, "completed", authenticator->gained_authorization); + + g_object_unref (authenticator); + + return FALSE; +} + +void +polkit_mate_authenticator_initiate (PolkitMateAuthenticator *authenticator) +{ + /* run from idle since we're going to block the main loop in the dialog (which has a recursive mainloop) */ + g_idle_add (do_initiate, g_object_ref (authenticator)); +} + +void +polkit_mate_authenticator_cancel (PolkitMateAuthenticator *authenticator) +{ + if (authenticator->dialog != NULL) + polkit_mate_authentication_dialog_cancel (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog)); + + authenticator->was_cancelled = TRUE; + + if (authenticator->session != NULL) + { + polkit_agent_session_cancel (authenticator->session); + } +} + +const gchar * +polkit_mate_authenticator_get_cookie (PolkitMateAuthenticator *authenticator) +{ + return authenticator->cookie; +} + + diff --git a/src/polkitmateauthenticator.h b/src/polkitmateauthenticator.h new file mode 100644 index 0000000..4c56477 --- /dev/null +++ b/src/polkitmateauthenticator.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2009 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * Author: David Zeuthen <[email protected]> + */ + +#ifndef __POLKIT_MATE_AUTHENTICATOR_H +#define __POLKIT_MATE_AUTHENTICATOR_H + +#include <glib-object.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define POLKIT_MATE_TYPE_AUTHENTICATOR (polkit_mate_authenticator_get_type()) +#define POLKIT_MATE_AUTHENTICATOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_MATE_TYPE_AUTHENTICATOR, PolkitMateAuthenticator)) +#define POLKIT_MATE_AUTHENTICATOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), POLKIT_MATE_TYPE_AUTHENTICATOR, PolkitMateAuthenticatorClass)) +#define POLKIT_MATE_AUTHENTICATOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_MATE_TYPE_AUTHENTICATOR, PolkitMateAuthenticatorClass)) +#define POLKIT_MATE_IS_AUTHENTICATOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_MATE_TYPE_AUTHENTICATOR)) +#define POLKIT_MATE_IS_AUTHENTICATOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_MATE_TYPE_AUTHENTICATOR)) + +typedef struct _PolkitMateAuthenticator PolkitMateAuthenticator; +typedef struct _PolkitMateAuthenticatorClass PolkitMateAuthenticatorClass; + +GType polkit_mate_authenticator_get_type (void) G_GNUC_CONST; +PolkitMateAuthenticator *polkit_mate_authenticator_new (const gchar *action_id, + const gchar *message, + const gchar *icon_name, + PolkitDetails *details, + const gchar *cookie, + GList *identities); +void polkit_mate_authenticator_initiate (PolkitMateAuthenticator *authenticator); +void polkit_mate_authenticator_cancel (PolkitMateAuthenticator *authenticator); +const gchar *polkit_mate_authenticator_get_cookie (PolkitMateAuthenticator *authenticator); + +#ifdef __cplusplus +} +#endif + +#endif /* __POLKIT_MATE_AUTHENTICATOR_H */ diff --git a/src/polkitmatelistener.c b/src/polkitmatelistener.c new file mode 100644 index 0000000..d70836f --- /dev/null +++ b/src/polkitmatelistener.c @@ -0,0 +1,253 @@ +/* + * Copyright (C) 2009 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * Author: David Zeuthen <[email protected]> + */ + + +#include "config.h" + +#include <string.h> + +#include "polkitmatelistener.h" +#include "polkitmateauthenticator.h" + +struct _PolkitMateListener +{ + PolkitAgentListener parent_instance; + + /* we support multiple authenticators - they are simply queued up */ + GList *authenticators; + + PolkitMateAuthenticator *active_authenticator; +}; + +struct _PolkitMateListenerClass +{ + PolkitAgentListenerClass parent_class; +}; + +static void polkit_mate_listener_initiate_authentication (PolkitAgentListener *listener, + const gchar *action_id, + const gchar *message, + const gchar *icon_name, + PolkitDetails *details, + const gchar *cookie, + GList *identities, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +static gboolean polkit_mate_listener_initiate_authentication_finish (PolkitAgentListener *listener, + GAsyncResult *res, + GError **error); + +G_DEFINE_TYPE (PolkitMateListener, polkit_mate_listener, POLKIT_AGENT_TYPE_LISTENER); + +static void +polkit_mate_listener_init (PolkitMateListener *listener) +{ +} + +static void +polkit_mate_listener_finalize (GObject *object) +{ + PolkitMateListener *listener; + + listener = POLKIT_MATE_LISTENER (object); + + if (G_OBJECT_CLASS (polkit_mate_listener_parent_class)->finalize != NULL) + G_OBJECT_CLASS (polkit_mate_listener_parent_class)->finalize (object); +} + +static void +polkit_mate_listener_class_init (PolkitMateListenerClass *klass) +{ + GObjectClass *gobject_class; + PolkitAgentListenerClass *listener_class; + + gobject_class = G_OBJECT_CLASS (klass); + listener_class = POLKIT_AGENT_LISTENER_CLASS (klass); + + gobject_class->finalize = polkit_mate_listener_finalize; + + listener_class->initiate_authentication = polkit_mate_listener_initiate_authentication; + listener_class->initiate_authentication_finish = polkit_mate_listener_initiate_authentication_finish; +} + +PolkitAgentListener * +polkit_mate_listener_new (void) +{ + return POLKIT_AGENT_LISTENER (g_object_new (POLKIT_MATE_TYPE_LISTENER, NULL)); +} + +typedef struct +{ + PolkitMateListener *listener; + PolkitMateAuthenticator *authenticator; + + GSimpleAsyncResult *simple; + GCancellable *cancellable; + + gulong cancel_id; +} AuthData; + +static AuthData * +auth_data_new (PolkitMateListener *listener, + PolkitMateAuthenticator *authenticator, + GSimpleAsyncResult *simple, + GCancellable *cancellable) +{ + AuthData *data; + + data = g_new0 (AuthData, 1); + data->listener = g_object_ref (listener); + data->authenticator = g_object_ref (authenticator); + data->simple = g_object_ref (simple); + data->cancellable = g_object_ref (cancellable); + return data; +} + +static void +auth_data_free (AuthData *data) +{ + g_object_unref (data->listener); + g_object_unref (data->authenticator); + g_object_unref (data->simple); + if (data->cancellable != NULL && data->cancel_id > 0) + g_signal_handler_disconnect (data->cancellable, data->cancel_id); + g_object_unref (data->cancellable); + g_free (data); +} + +static void +maybe_initiate_next_authenticator (PolkitMateListener *listener) +{ + if (listener->active_authenticator == NULL && listener->authenticators != NULL) + { + polkit_mate_authenticator_initiate (POLKIT_MATE_AUTHENTICATOR (listener->authenticators->data)); + listener->active_authenticator = listener->authenticators->data; + } +} + +static void +authenticator_completed (PolkitMateAuthenticator *authenticator, + gboolean gained_authorization, + gpointer user_data) +{ + AuthData *data = user_data; + + data->listener->authenticators = g_list_remove (data->listener->authenticators, authenticator); + if (authenticator == data->listener->active_authenticator) + data->listener->active_authenticator = NULL; + + g_object_unref (authenticator); + + g_simple_async_result_complete (data->simple); + g_object_unref (data->simple); + + maybe_initiate_next_authenticator (data->listener); + + auth_data_free (data); +} + +static void +cancelled_cb (GCancellable *cancellable, + gpointer user_data) +{ + AuthData *data = user_data; + + polkit_mate_authenticator_cancel (data->authenticator); +} + +static void +polkit_mate_listener_initiate_authentication (PolkitAgentListener *agent_listener, + const gchar *action_id, + const gchar *message, + const gchar *icon_name, + PolkitDetails *details, + const gchar *cookie, + GList *identities, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + PolkitMateListener *listener = POLKIT_MATE_LISTENER (agent_listener); + GSimpleAsyncResult *simple; + PolkitMateAuthenticator *authenticator; + AuthData *data; + + simple = g_simple_async_result_new (G_OBJECT (listener), + callback, + user_data, + polkit_mate_listener_initiate_authentication); + + authenticator = polkit_mate_authenticator_new (action_id, + message, + icon_name, + details, + cookie, + identities); + if (authenticator == NULL) + { + g_simple_async_result_set_error (simple, + POLKIT_ERROR, + POLKIT_ERROR_FAILED, + "Error creating authentication object"); + g_simple_async_result_complete (simple); + goto out; + } + + data = auth_data_new (listener, authenticator, simple, cancellable); + + g_signal_connect (authenticator, + "completed", + G_CALLBACK (authenticator_completed), + data); + + if (cancellable != NULL) + { + data->cancel_id = g_signal_connect (cancellable, + "cancelled", + G_CALLBACK (cancelled_cb), + data); + } + + listener->authenticators = g_list_append (listener->authenticators, authenticator); + + maybe_initiate_next_authenticator (listener); + + out: + ; +} + +static gboolean +polkit_mate_listener_initiate_authentication_finish (PolkitAgentListener *listener, + GAsyncResult *res, + GError **error) +{ + GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res); + + g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == polkit_mate_listener_initiate_authentication); + + if (g_simple_async_result_propagate_error (simple, error)) + return FALSE; + + return TRUE; +} + diff --git a/src/polkitmatelistener.h b/src/polkitmatelistener.h new file mode 100644 index 0000000..c85b3b0 --- /dev/null +++ b/src/polkitmatelistener.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2009 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * Author: David Zeuthen <[email protected]> + */ + +#ifndef __POLKIT_MATE_LISTENER_H +#define __POLKIT_MATE_LISTENER_H + +#include <polkitagent/polkitagent.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define POLKIT_MATE_TYPE_LISTENER (polkit_mate_listener_get_type()) +#define POLKIT_MATE_LISTENER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_MATE_TYPE_LISTENER, PolkitMateListener)) +#define POLKIT_MATE_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), POLKIT_MATE_TYPE_LISTENER, PolkitMateListenerClass)) +#define POLKIT_MATE_LISTENER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_MATE_TYPE_LISTENER, PolkitMateListenerClass)) +#define POLKIT_MATE_IS_LISTENER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_MATE_TYPE_LISTENER)) +#define POLKIT_MATE_IS_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_MATE_TYPE_LISTENER)) + +typedef struct _PolkitMateListener PolkitMateListener; +typedef struct _PolkitMateListenerClass PolkitMateListenerClass; + +GType polkit_mate_listener_get_type (void) G_GNUC_CONST; +PolkitAgentListener *polkit_mate_listener_new (void); + +#ifdef __cplusplus +} +#endif + +#endif /* __POLKIT_MATE_LISTENER_H */ |