[PolicyKit-gnome] Rip out stuff no longer needed for PolicyKit 1.0
- From: David Zeuthen <davidz src gnome org>
- To: svn-commits-list gnome org
- Subject: [PolicyKit-gnome] Rip out stuff no longer needed for PolicyKit 1.0
- Date: Mon, 8 Jun 2009 16:14:30 -0400 (EDT)
commit 1376bdae89a3e0e6afc3c718b75d148203235344
Author: David Zeuthen <davidz redhat com>
Date: Mon Jun 8 16:11:40 2009 -0400
Rip out stuff no longer needed for PolicyKit 1.0
---
README | 12 +-
configure.ac | 40 -
data/Makefile.am | 49 -
...esktop.PolicyKit.AuthenticationAgent.service.in | 3 -
...gnome.PolicyKit.AuthorizationManager.service.in | 3 -
data/org.gnome.PolicyKit.service.in | 3 -
data/polkit-gnome-authorization.desktop.in | 11 -
data/polkit-gnome.pc.in | 11 -
data/polkit-gnome.schemas.in | 60 -
doc/Makefile.am | 83 -
doc/auth-details.png | Bin 33008 -> 0 bytes
doc/auth-retain-always.png | Bin 30495 -> 0 bytes
doc/auth-retain-session.png | Bin 29800 -> 0 bytes
doc/auth-root.png | Bin 26805 -> 0 bytes
doc/auth-self.png | Bin 28037 -> 0 bytes
doc/auth-wheel-group-1.png | Bin 35436 -> 0 bytes
doc/auth-wheel-group-2.png | Bin 37226 -> 0 bytes
doc/polkit-gnome-docs.xml | 245 ---
doc/polkit-gnome-example-auth-dialog-twiddle.png | Bin 39378 -> 0 bytes
doc/polkit-gnome-example-screenshot-authorized.png | Bin 104073 -> 0 bytes
doc/polkit-gnome-example-screenshot.png | Bin 101821 -> 0 bytes
doc/version.xml.in | 1 -
examples/Makefile.am | 51 -
examples/org.gnome.policykit.examples.policy.in | 103 -
examples/polkit-gnome-example.c | 452 -----
po/POTFILES.in | 14 +-
po/POTFILES.skip | 1 +
polkit-gnome/Makefile.am | 51 -
polkit-gnome/polkit-gnome-action.c | 2125 --------------------
polkit-gnome/polkit-gnome-action.h | 96 -
polkit-gnome/polkit-gnome-auth.c | 167 --
polkit-gnome/polkit-gnome-auth.h | 55 -
polkit-gnome/polkit-gnome-context.c | 370 ----
polkit-gnome/polkit-gnome-context.h | 111 -
polkit-gnome/polkit-gnome-toggle-action.c | 929 ---------
polkit-gnome/polkit-gnome-toggle-action.h | 85 -
polkit-gnome/polkit-gnome.h | 37 -
src/polkitgnomeauthenticationdialog.c | 1 -
38 files changed, 5 insertions(+), 5164 deletions(-)
diff --git a/README b/README
index cd7c7ff..32f4897 100644
--- a/README
+++ b/README
@@ -1,13 +1,5 @@
-PolicyKit-gnome provides
-
- - An Authentication Agent for PolicyKit that integrates well with the
- GNOME desktop environment
-
- - A shared library to easily integrate usage of PolicyKit into GTK+
- applications
-
- - A proof-of-concept applet (that is subject to change) for managing
- authorizations
+PolicyKit-gnome provides an Authentication Agent for PolicyKit that
+integrates well with the GNOME desktop environment
See http://www.freedesktop.org/wiki/Software/PolicyKit for lots of
documentation, mailing lists, etc. about PolicyKit.
diff --git a/configure.ac b/configure.ac
index 6396db8..5d8c7f9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -108,22 +108,15 @@ fi
# *****
GNOME_COMMON_INIT
-GNOME_DOC_INIT
GNOME_DEBUG_CHECK
GNOME_COMPILE_WARNINGS([maximum])
GNOME_MAINTAINER_MODE_DEFINES
-AC_ARG_ENABLE(gtk-doc, AC_HELP_STRING([--enable-gtk-doc],
- [use gtk-doc to build documentation [default=yes]]),,
- enable_gtk_doc=yes)
-GTK_DOC_CHECK([1.3])
-
# ***************************
# Check for required packages
# ***************************
GTK_REQUIRED=2.13.6
-GCONF_REQUIRED=2.8
POLKIT_AGENT_REQUIRED=0.90
POLKIT_GOBJECT_REQUIRED=0.90
@@ -131,10 +124,6 @@ PKG_CHECK_MODULES(GTK, gtk+-2.0 >= $GTK_REQUIRED)
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)
-PKG_CHECK_MODULES(GCONF, gconf-2.0 >= $GCONF_REQUIRED)
-AC_SUBST(GCONF_CFLAGS)
-AC_SUBST(GCONF_LIBS)
-
PKG_CHECK_MODULES(POLKIT_AGENT, polkit-agent-1 >= $POLKIT_AGENT_REQUIRED)
AC_SUBST(POLKIT_AGENT_CFLAGS)
AC_SUBST(POLKIT_AGENT_LIBS)
@@ -149,26 +138,6 @@ AC_ARG_ENABLE([examples],
AM_CONDITIONAL(BUILD_EXAMPLES, test "x$enable_examples" = "xyes")
-#if test "x$enable_examples" = "xyes"; then
-# AC_CHECK_PROG([POLKIT_POLICY_FILE_VALIDATE],
-# [polkit-policy-file-validate], [polkit-policy-file-validate])
-# if test -z "$POLKIT_POLICY_FILE_VALIDATE"; then
-# AC_MSG_ERROR([polkit-policy-file-validate not found])
-# fi
-#fi
-
-dnl ==============================================
-dnl Special GConf section
-dnl ==============================================
-
-AC_PATH_PROG(GCONFTOOL, gconftool-2, no)
-
-if test x"$GCONFTOOL" = xno; then
- AC_MSG_ERROR([gconftool-2 executable not found in your path - should be installed with GConf])
-fi
-
-AM_GCONF_SOURCE_2
-
# ********************
# Internationalisation
# ********************
@@ -188,14 +157,6 @@ AC_SUBST([AM_CFLAGS])
AC_SUBST([AM_CXXFLAGS])
AC_SUBST([AM_LDFLAGS])
-#data/Makefile
-#data/polkit-gnome.pc
-#examples/Makefile
-#polkit-gnome/Makefile
-#tools/Makefile
-#doc/Makefile
-#doc/version.xml
-
AC_CONFIG_FILES([
Makefile
src/Makefile
@@ -222,5 +183,4 @@ echo "
cppflags: ${CPPFLAGS}
Maintainer mode: ${USE_MAINTAINER_MODE}
- Building api docs: ${enable_gtk_doc}
"
diff --git a/data/Makefile.am b/data/Makefile.am
deleted file mode 100644
index 66286cd..0000000
--- a/data/Makefile.am
+++ /dev/null
@@ -1,49 +0,0 @@
-schema_in_files = polkit-gnome.schemas.in
-schemadir = $(GCONF_SCHEMA_FILE_DIR)
-schema_DATA = $(schema_in_files:.schemas.in=.schemas)
-
- INTLTOOL_SCHEMAS_RULE@
-
-# don't do this if we are building in eg. rpm
-if GCONF_SCHEMAS_INSTALL
-install-data-local:
- if test -z "$(DESTDIR)" ; then \
- for p in $(schema_DATA) ; do \
- GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $$p; \
- done \
- fi
-endif
-
- INTLTOOL_DESKTOP_RULE@
-desktopdir = $(datadir)/applications
-desktop_in_files = polkit-gnome-authorization.desktop.in
-desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
-
-servicedir = $(datadir)/dbus-1/services
-service_in_files = org.gnome.PolicyKit.service.in \
- org.gnome.PolicyKit.AuthorizationManager.service.in \
- gnome-org.freedesktop.PolicyKit.AuthenticationAgent.service.in
-service_DATA = $(service_in_files:.service.in=.service)
-
-org.gnome.PolicyKit.service : org.gnome.PolicyKit.service.in Makefile
- @sed -e "s|\ libexecdir\@|$(libexecdir)|" $< > $@
-
-gnome-org.freedesktop.PolicyKit.AuthenticationAgent.service : gnome-org.freedesktop.PolicyKit.AuthenticationAgent.service.in Makefile
- @sed -e "s|\ libexecdir\@|$(libexecdir)|" $< > $@
-
-org.gnome.PolicyKit.AuthorizationManager.service : org.gnome.PolicyKit.AuthorizationManager.service.in Makefile
- @sed -e "s|\ bindir\@|$(bindir)|" $< > $@
-
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = polkit-gnome.pc
-
-DISTCLEANFILES = $(service_DATA) $(desktop_DATA) $(pkgconfig_DATA)
-
-EXTRA_DIST = \
- $(service_in_files) \
- $(desktop_in_files) \
- $(schema_in_files) \
- polkit-gnome.pc.in
-
-clean-local :
- rm -f *~ $(service_DATA) $(pkgconfig_DATA) $(schema_DATA)
diff --git a/data/gnome-org.freedesktop.PolicyKit.AuthenticationAgent.service.in b/data/gnome-org.freedesktop.PolicyKit.AuthenticationAgent.service.in
deleted file mode 100644
index aa163a5..0000000
--- a/data/gnome-org.freedesktop.PolicyKit.AuthenticationAgent.service.in
+++ /dev/null
@@ -1,3 +0,0 @@
-[D-BUS Service]
-Name=org.freedesktop.PolicyKit.AuthenticationAgent
-Exec= libexecdir@/polkit-gnome-manager
diff --git a/data/org.gnome.PolicyKit.AuthorizationManager.service.in b/data/org.gnome.PolicyKit.AuthorizationManager.service.in
deleted file mode 100644
index b5ae1d4..0000000
--- a/data/org.gnome.PolicyKit.AuthorizationManager.service.in
+++ /dev/null
@@ -1,3 +0,0 @@
-[D-BUS Service]
-Name=org.gnome.PolicyKit.AuthorizationManager
-Exec= bindir@/polkit-gnome-authorization
diff --git a/data/org.gnome.PolicyKit.service.in b/data/org.gnome.PolicyKit.service.in
deleted file mode 100644
index d99cdef..0000000
--- a/data/org.gnome.PolicyKit.service.in
+++ /dev/null
@@ -1,3 +0,0 @@
-[D-BUS Service]
-Name=org.gnome.PolicyKit
-Exec= libexecdir@/polkit-gnome-manager
diff --git a/data/polkit-gnome-authorization.desktop.in b/data/polkit-gnome-authorization.desktop.in
deleted file mode 100644
index d5f0dfb..0000000
--- a/data/polkit-gnome-authorization.desktop.in
+++ /dev/null
@@ -1,11 +0,0 @@
-[Desktop Entry]
-Encoding=UTF-8
-_Name=Authorizations
-_Comment=Configure authorizations
-Icon=gtk-dialog-authentication
-Exec=polkit-gnome-authorization
-Terminal=false
-Type=Application
-Categories=Settings;X-GNOME-SystemSettings;
-OnlyShowIn=GNOME;
-StartupNotify=true
diff --git a/data/polkit-gnome.pc.in b/data/polkit-gnome.pc.in
deleted file mode 100644
index f2576ea..0000000
--- a/data/polkit-gnome.pc.in
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix= prefix@
-exec_prefix= exec_prefix@
-libdir= libdir@
-includedir= includedir@
-
-Name: polkit-gnome
-Description: PolicyKit add-on library for GNOME
-Version: @VERSION@
-Requires: polkit polkit-dbus polkit-grant gtk+-2.0
-Libs: -L${libdir} -lpolkit-gnome
-Cflags: -I${includedir}/PolicyKit
diff --git a/data/polkit-gnome.schemas.in b/data/polkit-gnome.schemas.in
deleted file mode 100644
index 6d5f0fc..0000000
--- a/data/polkit-gnome.schemas.in
+++ /dev/null
@@ -1,60 +0,0 @@
-<gconfschemafile>
- <schemalist>
-
- <schema>
- <key>/schemas/desktop/gnome/policykit/auth_dialog_grab_keyboard</key>
- <applyto>/desktop/gnome/policykit/auth_dialog_grab_keyboard</applyto>
- <owner>policykit-gnome</owner>
- <type>bool</type>
- <default>true</default>
- <locale name="C">
- <short>Whether the authentication dialog should grab the keyboard</short>
- <long>
- If set to true, the authentication dialog from PolicyKit-gnome will grab the keyboard,
- so that you will not be able to type in other programs while the dialog is active.
- Use this if your window manager does not focus the authentication dialog automatically,
- and you want to avoid accidentally typing passwords in other programs.
- </long>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/desktop/gnome/policykit/auth_dialog_retain_authorization</key>
- <applyto>/desktop/gnome/policykit/auth_dialog_retain_authorization</applyto>
- <owner>policykit-gnome</owner>
- <type>bool</type>
- <default>true</default>
- <locale name="C">
- <short>Whether the retain authorization check box is checked by default</short>
- <long>
- If set to true, then "retain authorization" check box (if present) is
- checked by default in the authentication dialog unless the action
- is mentioned in the
- "/desktop/gnome/policykit/auth_dialog_retain_authorization_blacklist"
- key.
- </long>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/desktop/gnome/policykit/auth_dialog_retain_authorization_blacklist</key>
- <applyto>/desktop/gnome/policykit/auth_dialog_retain_authorization_blacklist</applyto>
- <owner>policykit-gnome</owner>
- <type>list</type>
- <list_type>string</list_type>
- <default>[]</default>
- <locale name="C">
- <short>A list of actions where the "retain authorization" checkbox isn't checked by default</short>
- <long>
- A list of PolicyKit action where the "retain authorization"
- checkbox isn't checked by default; this list is maintained
- by the authentication dialog code itself. For example, if a
- user unchecks the "retain authorization" check box for an
- action and successfully obtains an authorization for the
- action, the action will be added to this list.
- </long>
- </locale>
- </schema>
-
- </schemalist>
-</gconfschemafile>
diff --git a/doc/Makefile.am b/doc/Makefile.am
deleted file mode 100644
index 65e2081..0000000
--- a/doc/Makefile.am
+++ /dev/null
@@ -1,83 +0,0 @@
-## Process this file with automake to create Makefile.in.
-
-NULL =
-
-AUTOMAKE_OPTIONS = 1.7
-
-# The name of the module.
-DOC_MODULE=polkit-gnome
-
-# The top-level SGML file.
-DOC_MAIN_SGML_FILE=polkit-gnome-docs.xml
-
-# Extra options to supply to gtkdoc-scan
-SCAN_OPTIONS=--ignore-headers=config.h
-
-# The directory containing the source code. Relative to $(srcdir)
-DOC_SOURCE_DIR=../polkit-gnome
-
-# Used for dependencies
-HFILE_GLOB=$(top_srcdir)/polkit-gnome/*.h
-CFILE_GLOB=$(top_srcdir)/polkit-gnome/*.c
-
-# Headers to ignore
-IGNORE_HFILES= \
- $(NULL)
-
-# CFLAGS and LDFLAGS for compiling scan program. Only needed
-# if $(DOC_MODULE).types is non-empty.
-INCLUDES = \
- $(GTK_CFLAGS) \
- $(DBUS_GLIB_CFLAGS) \
- $(POLKIT_DBUS_CFLAGS) \
- $(POLKIT_GRANT_CFLAGS) \
- -I$(top_srcdir) \
- -I$(top_builddir) \
- $(NULL)
-
-GTKDOC_LIBS = \
- $(GTK_LIBS) \
- $(DBUS_GLIB_LIBS) \
- $(POLKIT_DBUS_LIBS) \
- $(POLKIT_GRANT_LIBS) \
- $(top_builddir)/polkit-gnome/libpolkit-gnome.la \
- $(NULL)
-
-# Extra options to supply to gtkdoc-mkdb
-MKDB_OPTIONS=--sgml-mode --output-format=xml
-
-# Extra options to supply to gtkdoc-mktmpl
-MKTMPL_OPTIONS=
-
-# Non-autogenerated SGML files to be included in $(DOC_MAIN_SGML_FILE)
-content_files = \
- version.xml \
- $(NULL)
-
-# Images to copy into HTML directory
-HTML_IMAGES = \
- polkit-gnome-example-screenshot.png \
- polkit-gnome-example-screenshot-authorized.png \
- polkit-gnome-example-auth-dialog-twiddle.png \
- auth-details.png \
- auth-retain-always.png \
- auth-retain-session.png \
- auth-root.png \
- auth-self.png \
- auth-wheel-group-1.png \
- auth-wheel-group-2.png
-
-# Extra options to supply to gtkdoc-fixref
-FIXXREF_OPTIONS=
-
-MAINTAINERCLEANFILES = \
- *~ \
- Makefile.in \
- polkit-gnome.types \
- polkit-gnome-*.txt \
- $(NULL)
-
-include $(top_srcdir)/gtk-doc.make
-
-# Version information for marking the documentation
-EXTRA_DIST += version.xml.in
diff --git a/doc/auth-details.png b/doc/auth-details.png
deleted file mode 100644
index d7e0084..0000000
Binary files a/doc/auth-details.png and /dev/null differ
diff --git a/doc/auth-retain-always.png b/doc/auth-retain-always.png
deleted file mode 100644
index 1bc9dd7..0000000
Binary files a/doc/auth-retain-always.png and /dev/null differ
diff --git a/doc/auth-retain-session.png b/doc/auth-retain-session.png
deleted file mode 100644
index e83b8c2..0000000
Binary files a/doc/auth-retain-session.png and /dev/null differ
diff --git a/doc/auth-root.png b/doc/auth-root.png
deleted file mode 100644
index 8a94867..0000000
Binary files a/doc/auth-root.png and /dev/null differ
diff --git a/doc/auth-self.png b/doc/auth-self.png
deleted file mode 100644
index efb9fbf..0000000
Binary files a/doc/auth-self.png and /dev/null differ
diff --git a/doc/auth-wheel-group-1.png b/doc/auth-wheel-group-1.png
deleted file mode 100644
index 2f478d7..0000000
Binary files a/doc/auth-wheel-group-1.png and /dev/null differ
diff --git a/doc/auth-wheel-group-2.png b/doc/auth-wheel-group-2.png
deleted file mode 100644
index da544b4..0000000
Binary files a/doc/auth-wheel-group-2.png and /dev/null differ
diff --git a/doc/polkit-gnome-docs.xml b/doc/polkit-gnome-docs.xml
deleted file mode 100644
index b1bdbf3..0000000
--- a/doc/polkit-gnome-docs.xml
+++ /dev/null
@@ -1,245 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
- "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
-<!ENTITY version SYSTEM "version.xml">
-]>
-<book id="index" xmlns:xi="http://www.w3.org/2003/XInclude">
- <bookinfo>
- <title>PolicyKit-gnome Library Reference Manual</title>
- <releaseinfo>Version &version;</releaseinfo>
- <authorgroup>
- <author>
- <firstname>David</firstname>
- <surname>Zeuthen</surname>
- <affiliation>
- <address>
- <email>david fubar dk</email>
- </address>
- </affiliation>
- </author>
- </authorgroup>
-
- <copyright>
- <year>2007</year>
- <holder>The PolicyKit-gnome Authors</holder>
- </copyright>
-
- <legalnotice>
- <para>
- Permission is granted to copy, distribute and/or modify this
- document under the terms of the <citetitle>GNU Free
- Documentation License</citetitle>, Version 1.1 or any later
- version published by the Free Software Foundation with no
- Invariant Sections, no Front-Cover Texts, and no Back-Cover
- Texts. You may obtain a copy of the <citetitle>GNU Free
- Documentation License</citetitle> from the Free Software
- Foundation by visiting <ulink type="http"
- url="http://www.fsf.org">their Web site</ulink> or by writing
- to:
-
- <address>
- The Free Software Foundation, Inc.,
- <street>59 Temple Place</street> - Suite 330,
- <city>Boston</city>, <state>MA</state> <postcode>02111-1307</postcode>,
- <country>USA</country>
- </address>
- </para>
-
- <para>
- Many of the names used by companies to distinguish their
- products and services are claimed as trademarks. Where those
- names appear in any GNOME documentation, and those trademarks
- are made aware to the members of the GNOME Documentation
- Project, the names have been printed in caps or initial caps.
- </para>
- </legalnotice>
- </bookinfo>
-
- <reference id="ref-core">
- <title>API Reference</title>
- <partintro>
- <para>
- This part presents the class and function reference for the
- PolicyKit-gnome library, <literal>libpolkit-gnome</literal>.
- </para>
- </partintro>
- <xi:include href="xml/polkit-gnome-context.xml"/>
- <xi:include href="xml/polkit-gnome-action.xml"/>
- <xi:include href="xml/polkit-gnome-toggle-action.xml"/>
- <xi:include href="xml/polkit-gnome-auth.xml"/>
- </reference>
-
- <reference id="ref-auth-daemon">
- <title>Authentication Agent</title>
- <partintro>
- <para>
- This part discusses the GNOME/GTK+ specific Authentication
- Agent.
- </para>
- </partintro>
-
- <refsect1 id="ref-auth-daemon-overview">
- <title>Overview</title>
- <para>
- The PolicyKit model provides letting an user authenticate in
- order to gain the privilege to let a Mechanism carry work out
- related to a specific Action on the users behalf. In the
- PolicyKit libraries, this functionality is programmatically
- exposed in the PolKitGrant class. As it's tedious to use this
- low-level functionality from a GTK+ or GNOME application, the
- high-level functionality is wrapped in a D-Bus service
- available on the session message bus. The way it works is that
- when an application needs privileges, it can call into this
- D-Bus service and an authentication dialog will appear. When
- the user is done with the authentication dialog, the
- application recieves a reply from the D-Bus containing a
- boolean indicating whether the user gained the privilege or
- not.
- </para>
- </refsect1>
-
- <refsect1 id="ref-auth-daemon-overview-dbus">
- <title>D-Bus interface</title>
- <para>
- The D-Bus service is available on the session message bus with
- the
- name <literal>org.freedesktop.PolicyKit.AuthenticationAgent</literal>
- and exports a single object <literal>/</literal> that
- implements the
- interface <literal>org.freedesktop.PolicyKit.AuthenticationAgent</literal>. The
- D-Bus introspection XML looks like this
- </para>
- <programlisting><xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="../src/polkit-gnome-manager.xml" parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
- <para>
- The <literal>ObtainAuthorization()</literal> method may throw
- an exception if another client is currently using the service
- to show an authentication dialog. In practice this should
- never happen because the authentication daemon grabs the X11
- keyboard and pointer thus preventing the user from activating
- widgets in other applications that would lead to calling into
- the <literal>ObtainAuthorization</literal> method.
- </para>
- </refsect1>
-
- <refsect1 id="ref-auth-daemon-operation">
- <title>Operation</title>
- <para>
- The authentication daemon uses
- <literal>libpolkit-grant</literal> which in turn uses PAM for
- authentication services (however, other authentication
- back-ends can be plugged in as required). As such, a wide
- range of authentication mechanisms are available.
- </para>
- <para>
- The authentication daemon is using D-Bus activation and exits
- after 30 seconds of inactivity. Thus the code implementing
- this dialog only runs when necessary.
- </para>
- </refsect1>
-
- <refsect1 id="ref-auth-daemon-ui-elements">
- <title>UI elements</title>
- <para>
- The appearance of the authentication dialog depends on the
- result from PolicyKit and also whether administrator
- authentication is defined as "authenticate as the root user"
- or "authenticate as one of the users from UNIX group wheel" or
- however the PolicyKit library is configured (see
- the <literal>PolicyKit.conf(5)</literal> manual page for
- details). Note that some of the screenshots below were made on
- a system set up to use
- the <ulink url="http://thinkfinger.sourceforge.net/"><citetitle>ThinkFinger</citetitle></ulink>
- PAM module.
- </para>
-
- <para>
- The text shown in the authentication dialogs stems from the
- PolicyKit <literal>.policy</literal> XML files residing
- in <literal>/usr/share/PolicyKit/policy</literal> and is read
- by the authentication daemon when an applications uses
- the <literal>ShowDialog()</literal> method. Thus, what the
- user sees is not under application control (e.g. it's not
- passed from the application) which rules out a class of
- attacks where applications are trying to fool the user into
- gaining a privilege.
- </para>
-
- <para>
- Authentication dialog where the user is asked to authenticate
- as herself:
- </para>
- <para>
- <inlinegraphic fileref="auth-self.png" format="PNG"/>
- </para>
- <para>
- Authentication dialog where the user is asked to authenticate
- as an administrative user and PolicyKit is configured to use
- the root password for this:
- </para>
- <para>
- <inlinegraphic fileref="auth-root.png" format="PNG"/>
- </para>
- <para>
- Authentication dialog where the user is asked to authenticate
- as an administrative user and PolicyKit is configured to use
- the UNIX wheel group for this:
- </para>
- <para>
- <inlinegraphic fileref="auth-wheel-group-1.png" format="PNG"/>
- </para>
- <para>
- Same authentication dialog, showing drop down box where the
- user can be selected:
- </para>
- <para>
- <inlinegraphic fileref="auth-wheel-group-2.png" format="PNG"/>
- </para>
- <para>
- Authentication dialog showing an Action where the privilege
- can be retained indefinitely:
- </para>
- <para>
- <inlinegraphic fileref="auth-retain-always.png" format="PNG"/>
- </para>
- <para>
- Authentication dialog showing an Action where the privilege
- can be retained only for the remainer of the desktop session:
- </para>
- <para>
- <inlinegraphic fileref="auth-retain-session.png" format="PNG"/>
- </para>
- <para>
- The details view detailing what Action is being asked for as
- well as what application is requesting the authentication:
- </para>
- <para>
- <inlinegraphic fileref="auth-details.png" format="PNG"/>
- </para>
- </refsect1>
-
- </reference>
-
- <!-- License -->
-
- <appendix id="license">
- <title>License</title>
- <para>
- The polkit-gnome library (polkit-gnome/*) is licensed to you
- under the GNU Lesser General Public License version 2 or
- later.
- </para>
- <para>
- The PolicyKit GNOME authentication D-Bus service (src/*) is
- licensed to you under the GNU General Public License version 2
- or later.
- </para>
- <para>
- Both licenses are included here. Some individual source code
- files and/or binaries may be under the GPL only.
- </para>
- <para>
- Each source code file is marked with the proper copyright
- information.
- </para>
- </appendix>
-</book>
diff --git a/doc/polkit-gnome-example-auth-dialog-twiddle.png b/doc/polkit-gnome-example-auth-dialog-twiddle.png
deleted file mode 100644
index f94c369..0000000
Binary files a/doc/polkit-gnome-example-auth-dialog-twiddle.png and /dev/null differ
diff --git a/doc/polkit-gnome-example-screenshot-authorized.png b/doc/polkit-gnome-example-screenshot-authorized.png
deleted file mode 100644
index 41825f5..0000000
Binary files a/doc/polkit-gnome-example-screenshot-authorized.png and /dev/null differ
diff --git a/doc/polkit-gnome-example-screenshot.png b/doc/polkit-gnome-example-screenshot.png
deleted file mode 100644
index dd5d89f..0000000
Binary files a/doc/polkit-gnome-example-screenshot.png and /dev/null differ
diff --git a/doc/version.xml.in b/doc/version.xml.in
deleted file mode 100644
index d78bda9..0000000
--- a/doc/version.xml.in
+++ /dev/null
@@ -1 +0,0 @@
- VERSION@
diff --git a/examples/Makefile.am b/examples/Makefile.am
deleted file mode 100644
index cbd0639..0000000
--- a/examples/Makefile.am
+++ /dev/null
@@ -1,51 +0,0 @@
-
-bin_PROGRAMS = polkit-gnome-example
-
-polkit_gnome_example_SOURCES = \
- polkit-gnome-example.c
-
-polkit_gnome_example_CPPFLAGS = \
- -I$(top_srcdir) \
- -DLIBEXECDIR=\""$(libexecdir)"\" \
- -DDATADIR=\""$(pkgdatadir)"\" \
- -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
- $(DISABLE_DEPRECATED) \
- $(AM_CPPFLAGS)
-
-polkit_gnome_example_CFLAGS = \
- $(GTK_CFLAGS) \
- $(DBUS_GLIB_CFLAGS) \
- $(POLKIT_DBUS_CFLAGS) \
- $(WARN_CFLAGS) \
- $(AM_CFLAGS)
-
-polkit_gnome_example_LDFLAGS = \
- $(AM_LDFLAGS)
-
-polkit_gnome_example_LDADD = \
- $(GTK_LIBS) \
- $(DBUS_GLIB_LIBS) \
- $(POLKIT_DBUS_LIBS) \
- $(POLKIT_GRANT_LIBS) \
- $(INTLLIBS) \
- $(top_builddir)/polkit-gnome/libpolkit-gnome.la
-
-# PolicyKit action definitions for this example
-#
-polkit_policydir = $(datadir)/PolicyKit/policy
-dist_polkit_policy_DATA = org.gnome.policykit.examples.policy
-
-# You will need a recent intltool or the patch from this bug
-# http://bugzilla.gnome.org/show_bug.cgi?id=462312
- INTLTOOL_POLICY_RULE@
-
-check:
- $(POLKIT_POLICY_FILE_VALIDATE) $(top_srcdir)/examples/$(dist_polkit_policy_DATA)
-
-EXTRA_DIST = org.gnome.policykit.examples.policy.in
-
-CLEANFILES = $(BUILT_SOURCES)
-DISTCLEANFILES = org.gnome.policykit.examples.policy
-
-clean-local :
- rm -f *~
diff --git a/examples/org.gnome.policykit.examples.policy.in b/examples/org.gnome.policykit.examples.policy.in
deleted file mode 100644
index ca727fb..0000000
--- a/examples/org.gnome.policykit.examples.policy.in
+++ /dev/null
@@ -1,103 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!DOCTYPE policyconfig PUBLIC
- "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
- "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
-
-<!--
-Policy definitions for PolicyKit-Gnome example
-
-Copyright (c) 2007 David Zeuthen <david fubar dk>
-
-NOTE: If you make changes to this file, make sure to validate the file
-using the polkit-policy-file-validate(1) tool. Changes made to this
-file are instantly applied.
--->
-
-<policyconfig>
-
- <action id="org.gnome.policykit.examples.jump">
- <_description>Jump</_description>
- <_message>System policy prevents the PolicyKit-gnome example helper from Jumping</_message>
- <defaults>
- <allow_inactive>no</allow_inactive>
- <allow_active>auth_self_one_shot</allow_active>
- </defaults>
- </action>
-
- <action id="org.gnome.policykit.examples.frobnicate">
- <_description>Frobnicate</_description>
- <_message>System policy prevents the PolicyKit-gnome example helper from Frobnicating</_message>
- <defaults>
- <allow_inactive>no</allow_inactive>
- <allow_active>auth_self</allow_active>
- </defaults>
- </action>
-
- <action id="org.gnome.policykit.examples.tweak">
- <_description>Tweak</_description>
- <_message>System policy prevents the PolicyKit-gnome example helper from Tweaking</_message>
- <defaults>
- <allow_inactive>no</allow_inactive>
- <allow_active>auth_admin</allow_active>
- </defaults>
- </action>
-
- <action id="org.gnome.policykit.examples.twiddle">
- <_description>Twiddle</_description>
- <_message>System policy prevents the PolicyKit-gnome example helper from Twiddling</_message>
- <defaults>
- <allow_inactive>no</allow_inactive>
- <allow_active>auth_admin_keep_always</allow_active>
- </defaults>
- </action>
-
- <action id="org.gnome.policykit.examples.punch">
- <_description>Punch</_description>
- <_message>System policy prevents the PolicyKit-gnome example helper from Punching</_message>
- <defaults>
- <allow_inactive>no</allow_inactive>
- <allow_active>auth_self_keep_session</allow_active>
- </defaults>
- </action>
-
- <action id="org.gnome.policykit.examples.toggle">
- <_description>Toggle</_description>
- <_message>System policy prevents the PolicyKit-gnome example helper from Toggling</_message>
- <defaults>
- <allow_inactive>no</allow_inactive>
- <allow_active>auth_admin_keep_always</allow_active>
- </defaults>
- </action>
-
- <action id="org.gnome.policykit.examples.kick-foo">
- <_description>Kick foo</_description>
- <_message>System policy prevents the PolicyKit-gnome example helper from Kicking foo</_message>
- <defaults>
- <allow_inactive>no</allow_inactive>
- <allow_active>auth_self</allow_active>
- </defaults>
- <annotate key="org.gnome.policykit.examples.kick-path">foo</annotate>
- </action>
-
- <action id="org.gnome.policykit.examples.kick-bar">
- <_description>Kick bar</_description>
- <_message>System policy prevents the PolicyKit-gnome example helper from Kicking bar</_message>
- <defaults>
- <allow_inactive>no</allow_inactive>
- <allow_active>auth_self</allow_active>
- </defaults>
- <annotate key="org.gnome.policykit.examples.kick-path">bar</annotate>
- </action>
-
- <action id="org.gnome.policykit.examples.kick-baz">
- <_description>Kick baz</_description>
- <_message>System policy prevents the PolicyKit-gnome example helper from Kicking baz</_message>
- <defaults>
- <allow_inactive>no</allow_inactive>
- <allow_active>auth_self</allow_active>
- </defaults>
- <annotate key="org.gnome.policykit.examples.kick-path">baz</annotate>
- </action>
-
-</policyconfig>
diff --git a/examples/polkit-gnome-example.c b/examples/polkit-gnome-example.c
deleted file mode 100644
index 57d5e1c..0000000
--- a/examples/polkit-gnome-example.c
+++ /dev/null
@@ -1,452 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
- *
- * polkit-gnome-example: Simple example showing how a GTK+ application
- * can use PolicyKit.
- *
- * Copyright (C) 2007 David Zeuthen <david fubar dk>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <sys/types.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <glib/gi18n.h>
-#include <polkit-gnome/polkit-gnome.h>
-
-static GtkWidget *toplevel_window;
-static PolKitGnomeContext *pkgc;
-
-static void
-_button_toggled (GtkToggleButton *toggle_button, PolKitGnomeAction *action)
-{
- g_debug ("in _button_toggled for action '%s'", gtk_action_get_name (GTK_ACTION (action)));
-}
-
-static void
-_button_clicked (GtkToggleButton *toggle_button, PolKitGnomeAction *action)
-{
- g_debug ("in _button_clicked for '%s'", gtk_action_get_name (GTK_ACTION (action)));
-}
-
-/* This function is called when the following two conditions are true
- *
- * - the user clicks one of the buttons created via the method
- * polkit_gnome_action_create_button() (see main() below)
- *
- * - For the PolKitAction associated with the button, PolicyKit
- * reports either 'no' or 'yes'.
- *
- * In the event the user clicks a button and he is not privileged
- * (e.g. PolicyKit returns one of the 'auth' results) he will be
- * asked to authenticate; this all happens behind the scenes; the
- * application _only_ gets the ::activate signal on PolKitGnomeAction
- * instances when PolicyKit reports that the user is privileged.
- *
- * Note that for action org.gnome.policykit.examples.tweak, the
- * corresponding PolKitGnomeAction is configured to be sensitive (see
- * main() below) even when PolicyKit reports 'no'. Hence we need to
- * handle that case too and we do that by popping up a dialog. Note
- * that this can only be triggered by adding a stanza like
- *
- * <match action="org.gnome.policykit.examples.tweak">
- * <return result="no"/>
- * </match>
- *
- * to the /etc/PolicyKit/PolicyKit.conf file.
- */
-static void
-activate_polkit_gnome_action (PolKitGnomeAction *action, gpointer user_data)
-{
- PolKitCaller *pk_caller;
- PolKitAction *pk_action;
- PolKitResult pk_result;
- DBusError dbus_error;
-
- if (strcmp (gtk_action_get_name (GTK_ACTION (action)), "toggle") == 0) {
- /* we're not supposed to run actions when the
- * authorization is flipped.. we're supposed to make
- * some UI sensitive and de-sensitive.. (one use at least) */
- g_debug ("toggled for '%s'", gtk_action_get_name (GTK_ACTION (action)));
- return;
- }
-
- g_debug ("pretending to be the mechanism for action '%s'", gtk_action_get_name (GTK_ACTION (action)));
-
- g_object_get (action, "polkit-action", &pk_action, NULL);
-
- dbus_error_init (&dbus_error);
- pk_caller = polkit_tracker_get_caller_from_pid (pkgc->pk_tracker,
- getpid (),
- &dbus_error);
- if (pk_caller == NULL) {
- g_warning ("Cannot get PolKitCaller object for ourselves (pid=%d): %s: %s",
- getpid (), dbus_error.name, dbus_error.message);
- dbus_error_free (&dbus_error);
- } else {
- /* note how we pass #TRUE to revoke_if_one_shot - this is because we're
- * pretending to be the mechanism
- */
- pk_result = polkit_context_is_caller_authorized (pkgc->pk_context,
- pk_action,
- pk_caller,
- TRUE,
- NULL);
-
- polkit_caller_unref (pk_caller);
- }
-
- polkit_action_unref (pk_action);
-
-}
-
-static void
-activate_action (GtkAction *action, gpointer user_data)
-{
- if (g_ascii_strcasecmp (gtk_action_get_name (action), "Quit") == 0) {
- exit (0);
- } else if (g_ascii_strcasecmp (gtk_action_get_name (action), "About") == 0) {
- const char *authors[] = {
- "David Zeuthen <david fubar dk>",
- NULL};
- const char *documenters[] = {
- "David Zeuthen <david fubar dk>",
- NULL};
-
-
- gtk_show_about_dialog (NULL,
- "version", VERSION,
- "copyright", _("Copyright © 2007 David Zeuthen"),
- "website-label", _("PolicyKit-gnome Website"),
- "website", "http://hal.freedesktop.org/docs/PolicyKit-gnome/",
- "program-name", _("PolicyKit-gnome demo"),
- "comments", _("PolicyKit for the GNOME desktop"),
- "logo-icon-name", GTK_STOCK_DIALOG_AUTHENTICATION,
- "authors", authors,
- "documenters", documenters,
- NULL);
-
- }
-}
-
-static GtkActionEntry entries[] = {
- { "FileMenu", NULL, N_("_File") }, /* name, stock id, label */
- { "ActionsMenu", NULL, N_("_Actions") }, /* name, stock id, label */
- { "HelpMenu", NULL, N_("_Help") }, /* name, stock id, label */
-
- { "Quit", GTK_STOCK_QUIT, /* name, stock id */
- N_("_Quit"), "<control>Q", /* label, accelerator */
- N_("Quit"), /* tooltip */
- G_CALLBACK (activate_action) },
-
- { "About", GTK_STOCK_ABOUT, /* name, stock id */
- N_("_About"), "<control>A", /* label, accelerator */
- N_("About"), /* tooltip */
- G_CALLBACK (activate_action) },
-};
-static guint n_entries = G_N_ELEMENTS (entries);
-
-static const gchar *ui_info =
-"<ui>"
-" <menubar name='MenuBar'>"
-" <menu action='FileMenu'>"
-" <menuitem action='Quit'/>"
-" </menu>"
-" <menu action='ActionsMenu'>"
-" <menuitem action='frobnicate'/>"
-" <menuitem action='jump'/>"
-" <menuitem action='tweak'/>"
-" <menuitem action='twiddle'/>"
-" <menuitem action='punch'/>"
-" <menuitem action='toggle'/>"
-" </menu>"
-" <menu action='HelpMenu'>"
-" <menuitem action='About'/>"
-" </menu>"
-" </menubar>"
-" <toolbar name='ToolBar'>"
-" <toolitem action='Quit'/>"
-" <toolitem action='About'/>"
-" <separator action='Sep1'/>"
-" <toolitem action='frobnicate'/>"
-" <toolitem action='jump'/>"
-" <toolitem action='tweak'/>"
-" <toolitem action='twiddle'/>"
-" <toolitem action='punch'/>"
-" <toolitem action='toggle'/>"
-" </toolbar>"
-"</ui>";
-
-int
-main (int argc, char **argv)
-{
- GtkWidget *hbox;
- GtkWidget *vbox;
- GtkWidget *vbox2;
- GtkWidget *label;
- GMainLoop*loop;
- PolKitAction *pk_action;
- PolKitGnomeAction *action;
- GtkWidget *button;
- GtkUIManager *ui;
- GtkActionGroup *actions;
-
- gtk_init (&argc, &argv);
-
- pkgc = polkit_gnome_context_get (NULL);
-
- loop = g_main_loop_new (NULL, FALSE);
-
- toplevel_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-
- actions = gtk_action_group_new ("Actions");
- gtk_action_group_add_actions (actions, entries, n_entries, NULL);
-
- ui = gtk_ui_manager_new ();
- gtk_ui_manager_insert_action_group (ui, actions, 0);
-
- gtk_window_add_accel_group (GTK_WINDOW (toplevel_window),
- gtk_ui_manager_get_accel_group (ui));
-
-
- gtk_ui_manager_add_ui_from_string (ui, ui_info, -1, NULL);
-
- /*----------------------------------------------------------------*/
-
- vbox = gtk_vbox_new (FALSE, 10);
- gtk_container_add (GTK_CONTAINER (toplevel_window), vbox);
-
- vbox2 = gtk_vbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0);
-
- /*----------------------------------------------------------------*/
-
- label = gtk_label_new (NULL);
- gtk_label_set_markup (GTK_LABEL (label), _("Making the helper <b>Frobnicate</b> requires the "
- "user to authenticate. The authorization is kept for "
- "the life time of the process"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
-
- pk_action = polkit_action_new ();
- polkit_action_set_action_id (pk_action, "org.gnome.policykit.examples.frobnicate");
- action = polkit_gnome_action_new_default ("frobnicate", pk_action, _("Frobnicate!"), NULL);
- polkit_action_unref (pk_action);
- g_signal_connect (action, "activate", G_CALLBACK (activate_polkit_gnome_action), NULL);
- gtk_action_group_add_action (actions, GTK_ACTION (action));
- button = polkit_gnome_action_create_button (action);
- gtk_box_pack_start (GTK_BOX (vbox),
- button,
- FALSE, FALSE, 0);
- g_signal_connect (button, "clicked", G_CALLBACK (_button_clicked), action);
-
- /*----------------------------------------------------------------*/
- gtk_box_pack_start (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, FALSE, 0);
- /*----------------------------------------------------------------*/
-
- label = gtk_label_new (NULL);
- gtk_label_set_markup (GTK_LABEL (label), _("Making the helper <b>Jump</b> requires the "
- "user to authenticate. This is a one-shot authorization."));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
-
- pk_action = polkit_action_new ();
- polkit_action_set_action_id (pk_action, "org.gnome.policykit.examples.jump");
- action = polkit_gnome_action_new_default ("jump", pk_action, _("Jump!"), NULL);
- polkit_action_unref (pk_action);
- g_signal_connect (action, "activate", G_CALLBACK (activate_polkit_gnome_action), NULL);
- gtk_action_group_add_action (actions, GTK_ACTION (action));
- button = polkit_gnome_action_create_button (action);
- gtk_box_pack_start (GTK_BOX (vbox),
- button,
- FALSE, FALSE, 0);
- g_signal_connect (button, "clicked", G_CALLBACK (_button_clicked), action);
-
- /*----------------------------------------------------------------*/
- gtk_box_pack_start (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, FALSE, 0);
- /*----------------------------------------------------------------*/
-
- label = gtk_label_new (NULL);
- gtk_label_set_markup (GTK_LABEL (label), _("Making the helper <b>Tweak</b> requires a system "
- "administrator to authenticate. This instance "
- "overrides the defaults set in polkit_gnome_action_new()."));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
-
- pk_action = polkit_action_new ();
- polkit_action_set_action_id (pk_action, "org.gnome.policykit.examples.tweak");
- action = polkit_gnome_action_new_default ("tweak", pk_action, _("Tweak!"), NULL);
- polkit_action_unref (pk_action);
-
- /* For this particular GtkAction instance, we want to customize the appearence */
- g_object_set (action,
- "no-visible", TRUE,
- "no-sensitive", TRUE,
- "no-short-label", _("Tweak"),
- "no-label", _("Tweak (long)"),
- "no-tooltip", _("If your admin wasn't annoying, you could do this"),
- "no-icon-name", GTK_STOCK_NO,
-
- "auth-visible", TRUE,
- "auth-sensitive", TRUE,
- "auth-short-label", _("Tweak..."),
- "auth-label", _("Tweak... (long)"),
- "auth-tooltip", _("Only card carrying tweakers can do this!"),
- "auth-icon-name", GTK_STOCK_DIALOG_AUTHENTICATION,
-
- "yes-visible", TRUE,
- "yes-sensitive", TRUE,
- "yes-short-label", _("Tweak!"),
- "yes-label", _("Tweak! (long)"),
- "yes-tooltip", _("Go ahead, tweak tweak tweak!"),
- "yes-icon-name", GTK_STOCK_YES,
- NULL);
-
- g_signal_connect (action, "activate", G_CALLBACK (activate_polkit_gnome_action), NULL);
- gtk_action_group_add_action (actions, GTK_ACTION (action));
- button = polkit_gnome_action_create_button (action);
- gtk_box_pack_start (GTK_BOX (vbox),
- button,
- FALSE, FALSE, 0);
- g_signal_connect (button, "clicked", G_CALLBACK (_button_clicked), action);
-
- /*----------------------------------------------------------------*/
- gtk_box_pack_start (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, FALSE, 0);
- /*----------------------------------------------------------------*/
-
- label = gtk_label_new (NULL);
- gtk_label_set_markup (GTK_LABEL (label), _("Making the helper <b>Twiddle</b> requires a system "
- "administrator to authenticate. Once authenticated, this "
- "privilege can be retained indefinitely."));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
-
- pk_action = polkit_action_new ();
- polkit_action_set_action_id (pk_action, "org.gnome.policykit.examples.twiddle");
- action = polkit_gnome_action_new_default ("twiddle", pk_action, _("Twiddle!"), NULL);
- polkit_action_unref (pk_action);
- g_signal_connect (action, "activate", G_CALLBACK (activate_polkit_gnome_action), NULL);
- gtk_action_group_add_action (actions, GTK_ACTION (action));
- button = polkit_gnome_action_create_button (action);
- gtk_box_pack_start (GTK_BOX (vbox),
- button,
- FALSE, FALSE, 0);
- g_signal_connect (button, "clicked", G_CALLBACK (_button_clicked), action);
-
- /*----------------------------------------------------------------*/
- gtk_box_pack_start (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, FALSE, 0);
- /*----------------------------------------------------------------*/
-
- label = gtk_label_new (NULL);
- gtk_label_set_markup (GTK_LABEL (label), _("Making the helper <b>Punch</b> requires the user to "
- "authenticate. Once authenticated, this privilege can "
- "be retained for the remainder of the desktop session."));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
-
- pk_action = polkit_action_new ();
- polkit_action_set_action_id (pk_action, "org.gnome.policykit.examples.punch");
- action = polkit_gnome_action_new_default ("punch", pk_action, _("Punch!"), NULL);
- polkit_action_unref (pk_action);
- g_signal_connect (action, "activate", G_CALLBACK (activate_polkit_gnome_action), NULL);
- gtk_action_group_add_action (actions, GTK_ACTION (action));
- button = polkit_gnome_action_create_button (action);
- gtk_box_pack_start (GTK_BOX (vbox),
- polkit_gnome_action_create_button (action),
- FALSE, FALSE, 0);
- g_signal_connect (button, "clicked", G_CALLBACK (_button_clicked), action);
-
- /*----------------------------------------------------------------*/
- gtk_box_pack_start (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, FALSE, 0);
- /*----------------------------------------------------------------*/
-
- label = gtk_label_new (NULL);
- gtk_label_set_markup (GTK_LABEL (label), _("The <b>Toggle</b> action demonstrates the use of "
- "PolicyKit to drive a GtkToggleButton; it's an intuitive "
- "way to ask users to give up authorizations when they "
- "are done with them. E.g. the button is 'pressed in' exactly"
- "when the authorization is held. Toggling the button means "
- "obtaining resp. revoking the authorization in question."));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
-
- pk_action = polkit_action_new ();
- polkit_action_set_action_id (pk_action, "org.gnome.policykit.examples.toggle");
- PolKitGnomeToggleAction *toggle_action;
- toggle_action = polkit_gnome_toggle_action_new_default ("toggle", pk_action,
- _("Click to make changes..."),
- _("Click to prevent changes"));
- //g_object_set (toggle_action, "target-pid", 24887, NULL);
- polkit_action_unref (pk_action);
- g_signal_connect (toggle_action, "activate", G_CALLBACK (activate_polkit_gnome_action), NULL);
- gtk_action_group_add_action (actions, GTK_ACTION (toggle_action));
- GtkWidget *toggle_button;
- toggle_button = polkit_gnome_toggle_action_create_toggle_button (toggle_action);
- g_signal_connect (toggle_button, "toggled", G_CALLBACK (_button_toggled), toggle_action);
- gtk_box_pack_start (GTK_BOX (vbox),
- toggle_button,
- FALSE, FALSE, 0);
-
- /*----------------------------------------------------------------*/
- gtk_box_pack_start (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, FALSE, 0);
- /*----------------------------------------------------------------*/
-
- hbox = gtk_hbox_new (FALSE, 5);
- gtk_box_pack_start (GTK_BOX (hbox), gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO,
- GTK_ICON_SIZE_SMALL_TOOLBAR), FALSE, FALSE, 0);
- label = gtk_label_new (NULL);
- gtk_label_set_markup (GTK_LABEL (label), _("<i>Tip: try editing /etc/PolicyKit/Policy.conf and see the proxy widgets update in real-time.</i>."));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
-
- /*----------------------------------------------------------------*/
-
- g_object_unref (actions);
-
- gtk_box_pack_start (GTK_BOX (vbox2),
- gtk_ui_manager_get_widget (ui, "/MenuBar"),
- FALSE, FALSE, 0);
-
- GtkWidget *toolbar;
- toolbar = gtk_ui_manager_get_widget (ui, "/ToolBar");
- gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH);
- gtk_box_pack_start (GTK_BOX (vbox2),
- toolbar,
- FALSE, FALSE, 0);
-
- /*----------------------------------------------------------------*/
-
- gtk_window_set_default_size (GTK_WINDOW (toplevel_window), 700, 0);
- gtk_window_set_title (GTK_WINDOW (toplevel_window), _("PolicyKit-gnome demo"));
- g_signal_connect (toplevel_window, "delete-event", (GCallback) exit, NULL);
- gtk_widget_show_all (toplevel_window);
-
- g_main_loop_run (loop);
- return 0;
-}
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 81f4763..22066a4 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,16 +1,6 @@
-#data/polkit-gnome-authorization.desktop.in
-#data/polkit-gnome.schemas.in
-#examples/polkit-gnome-example.c
-#examples/org.gnome.policykit.examples.policy.in
-#polkit-gnome/polkit-gnome-action.c
-#polkit-gnome/polkit-gnome-auth.c
-#polkit-gnome/polkit-gnome-context.c
-#polkit-gnome/polkit-gnome-toggle-action.c
-#tools/polkit-gnome-authorization.c
-#src/polkit-gnome-manager.c
-
# List of source files containing translatable strings.
# Please keep this file sorted alphabetically.
[encoding: UTF-8]
src/main.c
-src/polkit-gnome-auth-dialog.c
+src/polkitgnomeauthenticationdialog.c
+src/polkitgnomeauthenticator.c
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
new file mode 100644
index 0000000..480daa6
--- /dev/null
+++ b/po/POTFILES.skip
@@ -0,0 +1 @@
+tools/polkit-gnome-authorization.c
diff --git a/polkit-gnome/Makefile.am b/polkit-gnome/Makefile.am
deleted file mode 100644
index 6791dbf..0000000
--- a/polkit-gnome/Makefile.am
+++ /dev/null
@@ -1,51 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-INCLUDES = \
- -I$(top_builddir) -I$(top_srcdir) \
- -DPACKAGE_LIBEXECDIR=\""$(libexecdir)"\" \
- -DPACKAGE_SYSCONFDIR=\""$(sysconfdir)"\" \
- -DPACKAGE_DATADIR=\""$(datadir)"\" \
- -DPACKAGE_BINDIR=\""$(bindir)"\" \
- -DPACKAGE_LOCALSTATEDIR=\""$(localstatedir)"\" \
- -DPACKAGE_LOCALEDIR=\""$(localedir)"\" \
- -DPACKAGE_LIBDIR=\""$(libdir)"\" \
- -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT \
- -DPOLKIT_GNOME_COMPILATION
-
-lib_LTLIBRARIES=libpolkit-gnome.la
-
-libpolkit_gnomeincludedir=$(includedir)/PolicyKit/polkit-gnome
-
-libpolkit_gnomeinclude_HEADERS = \
- polkit-gnome.h \
- polkit-gnome-context.h \
- polkit-gnome-action.h \
- polkit-gnome-toggle-action.h \
- polkit-gnome-auth.h
-
-libpolkit_gnome_la_SOURCES = \
- polkit-gnome-context.h polkit-gnome-context.c \
- polkit-gnome-action.h polkit-gnome-action.c \
- polkit-gnome-toggle-action.h polkit-gnome-toggle-action.c \
- polkit-gnome-auth.h polkit-gnome-auth.c
-
-libpolkit_gnome_la_CFLAGS = \
- $(GTK_CFLAGS) \
- $(DBUS_GLIB_CFLAGS) \
- $(POLKIT_DBUS_CFLAGS) \
- $(POLKIT_GRANT_CFLAGS) \
- $(WARN_CFLAGS) \
- $(AM_CFLAGS)
-
-libpolkit_gnome_la_LIBADD = \
- $(GTK_LIBS) \
- $(DBUS_GLIB_LIBS) \
- $(POLKIT_DBUS_LIBS) \
- $(POLKIT_GRANT_LIBS) \
- $(INTLLIBS)
-
-libpolkit_gnome_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
-
-clean-local :
- rm -f *~ $(BUILT_SOURCES)
-
diff --git a/polkit-gnome/polkit-gnome-action.c b/polkit-gnome/polkit-gnome-action.c
deleted file mode 100644
index d4b4b4c..0000000
--- a/polkit-gnome/polkit-gnome-action.c
+++ /dev/null
@@ -1,2125 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-/***************************************************************************
- *
- * polkit-gnome-action.c :
- *
- * Copyright (C) 2007 David Zeuthen, <david fubar dk>
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- *
- **************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <fcntl.h>
-
-#include <glib.h>
-#include <glib/gi18n-lib.h>
-#include <glib-object.h>
-
-#include <gtk/gtk.h>
-#include <gdk/gdkx.h>
-
-#define DBUS_API_SUBJECT_TO_CHANGE
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include <polkit/polkit.h>
-#include <polkit-dbus/polkit-dbus.h>
-
-#include "polkit-gnome-context.h"
-#include "polkit-gnome-action.h"
-#include "polkit-gnome-auth.h"
-
-/**
- * SECTION:polkit-gnome-action
- * @short_description: A GtkAction subclass where instances can be tied to a specific PolicyKit action.
- *
- * Actions in GTK+ represent operations that the user can be perform,
- * along with some information how it should be presented in the
- * interface. Each action provides methods to create icons, menu items
- * and toolbar items representing itself. Each action can have one or
- * more proxy menu item, toolbar button or other proxy
- * widgets. Proxies mirror the state of the action (text label,
- * tooltip, icon, visible, sensitive, etc), and should change when the
- * action's state changes. When the proxy is activated, it should
- * activate its action.
- *
- * Instances of #PolKitGnomeAction class updates the label, tooltip,
- * icon-name, visible and properties of the parent #GtkAction instance
- * according to what result PolicyKit gives about a given
- * #PolKitAction object. The #PolKitGnomeContext class is used
- * internally to track changes. This means that external events (such
- * as the editing of the /etc/PolicyKit/PolicyKit.conf file,
- * ConsoleKit session activity changes or if the user gains a
- * privilege via authentication) will trigger the action, and thus
- * connected proxy widgets, to be updated.
- *
- * In addition, the #PolKitGnomeAction class intercepts the ::activate
- * signal defined in #GtkAction. When the result from PolicyKit is
- * yes, the signal is propagated. If the result is auth,
- * polkit_gnome_auth_show_dialog() will be used to bring up an
- * authentication dialog for the given #PolKitAction. If the user
- * succesfully gained the privilege, a ::activate signal will be
- * synthesized. If the result is no, the signal is also propagated.
- *
- * As a result, everything happens under the covers; the application
- * programmer using #PolKitGnomeAction will only get the ::activate
- * signal when the answer from PolicyKit is yes and as such don't have
- * to worry about bringing up authentication dialogs if the property
- * "no-sensitive" is set to #FALSE.
- *
- * When an authentication dialog is show, the #PolKitGnomeAction class
- * will pass the XID of the top-level window that the proxy widget
- * causing the activation to polkit_gnome_auth_show_dialog().
- *
- * An example of how to use #PolKitGnomeAction follows. First, build
- * the following program
- *
- * <programlisting><xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="../../examples/polkit-gnome-example.c" parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
- *
- * with
- *
- * <programlisting>gcc -o polkit-gnome-example `pkg-config --cflags --libs polkit-gnome` polkit-gnome-example.c</programlisting>
- *
- * Then, put the following content
- *
- * <programlisting><xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="../../examples/polkit-gnome-example.policy" parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
- *
- * into a file
- * <literal>/usr/share/PolicyKit/policy/polkit-gnome-example.policy</literal>. Finally,
- * run <literal>polkit-gnome-example</literal>. It should display a
- * window like this:
- *
- * <inlinegraphic fileref="polkit-gnome-example-screenshot.png" format="PNG"/>
- *
- * If the "Twiddle!" button is pressed, an authentication dialog
- * should pop up
- *
- * <inlinegraphic fileref="polkit-gnome-example-auth-dialog-twiddle.png" format="PNG"/>
- *
- * Here is how what the application looks like if the user gains
- * authorization for all the actions:
- *
- * <inlinegraphic fileref="polkit-gnome-example-screenshot-authorized.png" format="PNG"/>
- *
- * Regarding how to build an example mechanism that this GTK+
- * application can take advantage of, please refer to the
- * #PolKitContext class for examples.
- **/
-
-#define POLKIT_GNOME_ACTION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), POLKIT_GNOME_TYPE_ACTION, PolKitGnomeActionPrivate))
-
-static void polkit_gnome_action_activate (PolKitGnomeAction *action);
-static void _auth_start (PolKitGnomeAction *action);
-
-static void polkit_gnome_action_set_polkit_action (PolKitGnomeAction *action, PolKitAction *pk_action);
-static void polkit_gnome_action_set_polkit_action_sufficient (PolKitGnomeAction *action, const GValue *pk_action_array);
-
-static void polkit_gnome_action_set_self_blocked_visible (PolKitGnomeAction *action, gboolean visible);
-static void polkit_gnome_action_set_self_blocked_sensitive (PolKitGnomeAction *action, gboolean sensitive);
-static void polkit_gnome_action_set_self_blocked_short_label (PolKitGnomeAction *action, const gchar *short_label);
-static void polkit_gnome_action_set_self_blocked_label (PolKitGnomeAction *action, const gchar *label);
-static void polkit_gnome_action_set_self_blocked_tooltip (PolKitGnomeAction *action, const gchar *tooltip);
-static void polkit_gnome_action_set_self_blocked_icon_name (PolKitGnomeAction *action, const gchar *icon_name);
-
-static void polkit_gnome_action_set_no_visible (PolKitGnomeAction *action, gboolean visible);
-static void polkit_gnome_action_set_no_sensitive (PolKitGnomeAction *action, gboolean sensitive);
-static void polkit_gnome_action_set_no_short_label (PolKitGnomeAction *action, const gchar *short_label);
-static void polkit_gnome_action_set_no_label (PolKitGnomeAction *action, const gchar *label);
-static void polkit_gnome_action_set_no_tooltip (PolKitGnomeAction *action, const gchar *tooltip);
-static void polkit_gnome_action_set_no_icon_name (PolKitGnomeAction *action, const gchar *icon_name);
-
-static void polkit_gnome_action_set_auth_visible (PolKitGnomeAction *action, gboolean visible);
-static void polkit_gnome_action_set_auth_sensitive (PolKitGnomeAction *action, gboolean sensitive);
-static void polkit_gnome_action_set_auth_short_label (PolKitGnomeAction *action, const gchar *short_label);
-static void polkit_gnome_action_set_auth_label (PolKitGnomeAction *action, const gchar *label);
-static void polkit_gnome_action_set_auth_tooltip (PolKitGnomeAction *action, const gchar *tooltip);
-static void polkit_gnome_action_set_auth_icon_name (PolKitGnomeAction *action, const gchar *icon_name);
-
-static void polkit_gnome_action_set_yes_visible (PolKitGnomeAction *action, gboolean visible);
-static void polkit_gnome_action_set_yes_sensitive (PolKitGnomeAction *action, gboolean sensitive);
-static void polkit_gnome_action_set_yes_short_label (PolKitGnomeAction *action, const gchar *short_label);
-static void polkit_gnome_action_set_yes_label (PolKitGnomeAction *action, const gchar *label);
-static void polkit_gnome_action_set_yes_tooltip (PolKitGnomeAction *action, const gchar *tooltip);
-static void polkit_gnome_action_set_yes_icon_name (PolKitGnomeAction *action, const gchar *icon_name);
-
-static void polkit_gnome_action_set_target_pid (PolKitGnomeAction *action, guint target_pid);
-
-static void _pk_config_changed (PolKitGnomeContext *pk_g_context, PolKitGnomeAction *action);
-static void _pk_console_kit_db_changed (PolKitGnomeContext *pk_g_context, PolKitGnomeAction *action);
-
-struct _PolKitGnomeActionPrivate
-{
- gboolean self_blocked_visible;
- gboolean self_blocked_sensitive;
- gchar *self_blocked_short_label;
- gchar *self_blocked_label;
- gchar *self_blocked_tooltip;
- gchar *self_blocked_icon_name;
-
- gboolean no_visible;
- gboolean no_sensitive;
- gchar *no_short_label;
- gchar *no_label;
- gchar *no_tooltip;
- gchar *no_icon_name;
-
- gboolean auth_visible;
- gboolean auth_sensitive;
- gchar *auth_short_label;
- gchar *auth_label;
- gchar *auth_tooltip;
- gchar *auth_icon_name;
-
- gboolean yes_visible;
- gboolean yes_sensitive;
- gchar *yes_short_label;
- gchar *yes_label;
- gchar *yes_tooltip;
- gchar *yes_icon_name;
-
- gboolean master_visible;
- gboolean master_sensitive;
-
- PolKitAction *polkit_action;
- GSList *polkit_action_sufficient;
-
- gboolean polkit_action_set_once;
-
- guint target_pid;
-
- /* the current PolicyKit result for the given polkit_action_id */
- PolKitResult pk_result;
-
- PolKitGnomeContext *pk_g_context;
-
- gulong config_changed_handler_id;
- gulong console_kit_db_changed_handler_id;
-};
-
-enum
-{
- AUTH_START_SIGNAL,
- AUTH_END_SIGNAL,
- POLKIT_RESULT_CHANGED_SIGNAL,
- LAST_SIGNAL
-};
-
-enum
-{
- PROP_0,
- PROP_POLKIT_ACTION_OBJ,
- PROP_POLKIT_ACTION_OBJ_SUFFICIENT,
-
- PROP_POLKIT_SELF_BLOCKED_VISIBLE,
- PROP_POLKIT_SELF_BLOCKED_SENSITIVE,
- PROP_POLKIT_SELF_BLOCKED_SHORT_LABEL,
- PROP_POLKIT_SELF_BLOCKED_LABEL,
- PROP_POLKIT_SELF_BLOCKED_TOOLTIP,
- PROP_POLKIT_SELF_BLOCKED_ICON_NAME,
-
- PROP_POLKIT_NO_VISIBLE,
- PROP_POLKIT_NO_SENSITIVE,
- PROP_POLKIT_NO_SHORT_LABEL,
- PROP_POLKIT_NO_LABEL,
- PROP_POLKIT_NO_TOOLTIP,
- PROP_POLKIT_NO_ICON_NAME,
-
- PROP_POLKIT_AUTH_VISIBLE,
- PROP_POLKIT_AUTH_SENSITIVE,
- PROP_POLKIT_AUTH_SHORT_LABEL,
- PROP_POLKIT_AUTH_LABEL,
- PROP_POLKIT_AUTH_TOOLTIP,
- PROP_POLKIT_AUTH_ICON_NAME,
-
- PROP_POLKIT_YES_VISIBLE,
- PROP_POLKIT_YES_SENSITIVE,
- PROP_POLKIT_YES_SHORT_LABEL,
- PROP_POLKIT_YES_LABEL,
- PROP_POLKIT_YES_TOOLTIP,
- PROP_POLKIT_YES_ICON_NAME,
-
- PROP_POLKIT_MASTER_VISIBLE,
- PROP_POLKIT_MASTER_SENSITIVE,
-
- PROP_POLKIT_TARGET_PID,
-};
-
-G_DEFINE_TYPE (PolKitGnomeAction, polkit_gnome_action, GTK_TYPE_ACTION)
-
-static void set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-static GObjectClass *parent_class = NULL;
-static guint signals[LAST_SIGNAL] = { 0 };
-
-static void
-polkit_gnome_action_init (PolKitGnomeAction *action)
-{
- action->priv = POLKIT_GNOME_ACTION_GET_PRIVATE (action);
-
-
-}
-
-
-static void
-free_pk_action_sufficient (PolKitGnomeAction *action)
-{
- if (action->priv->polkit_action_sufficient != NULL) {
- GSList *l;
-
- for (l = action->priv->polkit_action_sufficient; l != NULL; l = g_slist_next (l)) {
- polkit_action_unref ((PolKitAction *) l->data);
- }
- g_slist_free (action->priv->polkit_action_sufficient);
- action->priv->polkit_action_sufficient = NULL;
- }
-}
-
-static void
-polkit_gnome_action_finalize (GObject *object)
-{
- PolKitGnomeAction *action;
-
- action = POLKIT_GNOME_ACTION (object);
-
- if (action->priv->polkit_action != NULL)
- polkit_action_unref (action->priv->polkit_action);
-
- g_free (action->priv->self_blocked_short_label);
- g_free (action->priv->self_blocked_label);
- g_free (action->priv->self_blocked_tooltip);
- g_free (action->priv->self_blocked_icon_name);
-
- g_free (action->priv->no_short_label);
- g_free (action->priv->no_label);
- g_free (action->priv->no_tooltip);
- g_free (action->priv->no_icon_name);
-
- g_free (action->priv->auth_short_label);
- g_free (action->priv->auth_label);
- g_free (action->priv->auth_tooltip);
- g_free (action->priv->auth_icon_name);
-
- g_free (action->priv->yes_short_label);
- g_free (action->priv->yes_label);
- g_free (action->priv->yes_tooltip);
- g_free (action->priv->yes_icon_name);
-
- free_pk_action_sufficient (action);
-
- if (action->priv->pk_g_context != NULL) {
- g_signal_handler_disconnect (action->priv->pk_g_context, action->priv->config_changed_handler_id);
- g_signal_handler_disconnect (action->priv->pk_g_context, action->priv->console_kit_db_changed_handler_id);
- g_object_unref (action->priv->pk_g_context);
- }
-
- G_OBJECT_CLASS (polkit_gnome_action_parent_class)->finalize (object);
-}
-
-static void
-_ensure_pk_g_context (PolKitGnomeAction *action)
-{
- if (action->priv->pk_g_context == NULL) {
- action->priv->pk_g_context = polkit_gnome_context_get (NULL);
-
- action->priv->config_changed_handler_id = g_signal_connect (
- action->priv->pk_g_context,
- "config-changed",
- G_CALLBACK (_pk_config_changed),
- action);
-
- action->priv->console_kit_db_changed_handler_id = g_signal_connect (
- action->priv->pk_g_context,
- "console-kit-db-changed",
- G_CALLBACK (_pk_console_kit_db_changed),
- action);
- }
-}
-
-static GObject *
-polkit_gnome_action_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
-{
- PolKitGnomeAction *action;
- PolKitGnomeActionClass *klass;
-
- klass = POLKIT_GNOME_ACTION_CLASS (g_type_class_peek (POLKIT_GNOME_TYPE_ACTION));
-
- action = POLKIT_GNOME_ACTION (G_OBJECT_CLASS (parent_class)->constructor (type,
- n_construct_properties,
- construct_properties));
-
- action->priv->master_visible = TRUE;
- action->priv->master_sensitive = TRUE;
-
- return G_OBJECT (action);
-}
-
-
-static void
-polkit_gnome_action_class_init (PolKitGnomeActionClass *klass)
-{
- GObjectClass *gobject_class;
- GtkActionClass *action_class;
-
- parent_class = g_type_class_peek_parent (klass);
- gobject_class = G_OBJECT_CLASS (klass);
- action_class = GTK_ACTION_CLASS (klass);
-
- gobject_class->constructor = polkit_gnome_action_constructor;
- gobject_class->set_property = set_property;
- gobject_class->get_property = get_property;
- gobject_class->finalize = polkit_gnome_action_finalize;
-
- action_class->activate = (void (*)(GtkAction*)) polkit_gnome_action_activate;
-
- klass->auth_start = _auth_start;
-
- g_object_class_install_property (gobject_class,
- PROP_POLKIT_ACTION_OBJ,
- g_param_spec_pointer ("polkit-action",
- "The PolKitAction object this GTK+ action is tracking",
- "The PolKitAction object this GTK+ action is tracking",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (gobject_class,
- PROP_POLKIT_ACTION_OBJ_SUFFICIENT,
- g_param_spec_value_array (
- "polkit-action-sufficient",
- "An array of PolKitAction objects that are sufficient to have authorizations for.",
- "An array of PolKitAction objects that are sufficient to have authorizations for.",
- g_param_spec_pointer (
- "polkit-action-sufficient-member",
- "PolKitAction member of polkit-action-sufficient",
- "PolKitAction member of polkit-action-sufficient",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT),
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- /*------------------------------*/
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_SELF_BLOCKED_VISIBLE,
- g_param_spec_boolean (
- "self-blocked-visible",
- "If PolicyKit evaluates the result as 'no' and the reason is that the user has a self-granted negative authorization, whether the action will be visible",
- "If PolicyKit evaluates the result as 'no' and the reason is that the user has a self-granted negative authorization, whether the action will be visible",
- TRUE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_SELF_BLOCKED_SENSITIVE,
- g_param_spec_boolean (
- "self-blocked-sensitive",
- "If PolicyKit evaluates the result as 'no' and the reason is that the user has a self-granted negative authorization, whether the action will be sensitive",
- "If PolicyKit evaluates the result as 'no' and the reason is that the user has a self-granted negative authorization, whether the action will be sensitive",
- FALSE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_SELF_BLOCKED_SHORT_LABEL,
- g_param_spec_string (
- "self-blocked-short-label",
- "If PolicyKit evaluates the result as 'no' and the reason is that the user has a self-granted negative authorization, use this short-label",
- "If PolicyKit evaluates the result as 'no' and the reason is that the user has a self-granted negative authorization, use this short-label",
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_SELF_BLOCKED_LABEL,
- g_param_spec_string (
- "self-blocked-label",
- "If PolicyKit evaluates the result as 'no' and the reason is that the user has a self-granted negative authorization, use this label",
- "If PolicyKit evaluates the result as 'no' and the reason is that the user has a self-granted negative authorization, use this label",
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_SELF_BLOCKED_TOOLTIP,
- g_param_spec_string (
- "self-blocked-tooltip",
- "If PolicyKit evaluates the result as 'no' and the reason is that the user has a self-granted negative authorization, use this tooltip",
- "If PolicyKit evaluates the result as 'no' and the reason is that the user has a self-granted negative authorization, use this tooltip",
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_SELF_BLOCKED_ICON_NAME,
- g_param_spec_string (
- "self-blocked-icon-name",
- "If PolicyKit evaluates the result as 'no' and the reason is that the user has a self-granted negative authorization, use this icon-name",
- "If PolicyKit evaluates the result as 'no' and the reason is that the user has a self-granted negative authorization, use this icon-name",
- NULL,
- G_PARAM_READWRITE));
-
- /*------------------------------*/
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_NO_VISIBLE,
- g_param_spec_boolean (
- "no-visible",
- "If PolicyKit evaluates the result as 'no', whether the action will be visible",
- "If PolicyKit evaluates the result as 'no', whether the action will be visible",
- TRUE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_NO_SENSITIVE,
- g_param_spec_boolean (
- "no-sensitive",
- "If PolicyKit evaluates the result as 'no', whether the action will be sensitive",
- "If PolicyKit evaluates the result as 'no', whether the action will be sensitive",
- FALSE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_NO_SHORT_LABEL,
- g_param_spec_string (
- "no-short-label",
- "If PolicyKit evaluates the result as 'no', use this short-label",
- "If PolicyKit evaluates the result as 'no', use this short-label",
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_NO_LABEL,
- g_param_spec_string (
- "no-label",
- "If PolicyKit evaluates the result as 'no', use this label",
- "If PolicyKit evaluates the result as 'no', use this label",
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_NO_TOOLTIP,
- g_param_spec_string (
- "no-tooltip",
- "If PolicyKit evaluates the result as 'no', use this tooltip",
- "If PolicyKit evaluates the result as 'no', use this tooltip",
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_NO_ICON_NAME,
- g_param_spec_string (
- "no-icon-name",
- "If PolicyKit evaluates the result as 'no', use this icon-name",
- "If PolicyKit evaluates the result as 'no', use this icon-name",
- NULL,
- G_PARAM_READWRITE));
-
- /*------------------------------*/
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_AUTH_VISIBLE,
- g_param_spec_boolean (
- "auth-visible",
- "If PolicyKit evaluates the result as 'auth', whether the action will be visible",
- "If PolicyKit evaluates the result as 'auth', whether the action will be visible",
- TRUE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_AUTH_SENSITIVE,
- g_param_spec_boolean (
- "auth-sensitive",
- "If PolicyKit evaluates the result as 'auth', whether the action will be sensitive",
- "If PolicyKit evaluates the result as 'auth', whether the action will be sensitive",
- TRUE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_AUTH_SHORT_LABEL,
- g_param_spec_string (
- "auth-short-label",
- "If PolicyKit evaluates the result as 'auth', use this short-label",
- "If PolicyKit evaluates the result as 'auth', use this short-label",
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_AUTH_LABEL,
- g_param_spec_string (
- "auth-label",
- "If PolicyKit evaluates the result as 'auth', use this label",
- "If PolicyKit evaluates the result as 'auth', use this label",
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_AUTH_TOOLTIP,
- g_param_spec_string (
- "auth-tooltip",
- "If PolicyKit evaluates the result as 'auth', use this tooltip",
- "If PolicyKit evaluates the result as 'auth', use this tooltip",
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_AUTH_ICON_NAME,
- g_param_spec_string (
- "auth-icon-name",
- "If PolicyKit evaluates the result as 'auth', use this icon-name",
- "If PolicyKit evaluates the result as 'auth', use this icon-name",
- NULL,
- G_PARAM_READWRITE));
-
- /*------------------------------*/
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_YES_VISIBLE,
- g_param_spec_boolean (
- "yes-visible",
- "If PolicyKit evaluates the result as 'yes', whether the action will be visible",
- "If PolicyKit evaluates the result as 'yes', whether the action will be visible",
- TRUE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_YES_SENSITIVE,
- g_param_spec_boolean (
- "yes-sensitive",
- "If PolicyKit evaluates the result as 'yes', whether the action will be sensitive",
- "If PolicyKit evaluates the result as 'yes', whether the action will be sensitive",
- TRUE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_YES_SHORT_LABEL,
- g_param_spec_string (
- "yes-short-label",
- "If PolicyKit evaluates the result as 'yes', use this short-label",
- "If PolicyKit evaluates the result as 'yes', use this short-label",
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_YES_LABEL,
- g_param_spec_string (
- "yes-label",
- "If PolicyKit evaluates the result as 'yes', use this label",
- "If PolicyKit evaluates the result as 'yes', use this label",
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_YES_TOOLTIP,
- g_param_spec_string (
- "yes-tooltip",
- "If PolicyKit evaluates the result as 'yes', use this tooltip",
- "If PolicyKit evaluates the result as 'yes', use this tooltip",
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_YES_ICON_NAME,
- g_param_spec_string (
- "yes-icon-name",
- "If PolicyKit evaluates the result as 'yes', use this icon-name",
- "If PolicyKit evaluates the result as 'yes', use this icon-name",
- NULL,
- G_PARAM_READWRITE));
-
- /*------------------------------*/
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_MASTER_VISIBLE,
- g_param_spec_boolean (
- "master-visible",
- "Can be set to FALSE to force invisibility no matter what PolicyKit reports",
- "Can be set to FALSE to force invisibility no matter what PolicyKit reports",
- TRUE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_MASTER_SENSITIVE,
- g_param_spec_boolean (
- "master-sensitive",
- "Can be set to FALSE to force insensitivity no matter what PolicyKit reports",
- "Can be set to FALSE to force insensitivity no matter what PolicyKit reports",
- TRUE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_TARGET_PID,
- g_param_spec_uint (
- "target-pid",
- "The target process id to receive the authorization; if 0 it is the current process",
- "The target process id to receive the authorization; if 0 it is the current process",
- 0,
- G_MAXUINT,
- 0,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- /**
- * PolKitGnomeAction::auth-start:
- * @action: the object
- *
- * The ::auth-start signal is emitted when an authentication
- * session starts.
- **/
- signals [AUTH_START_SIGNAL] =
- g_signal_new ("auth-start",
- G_TYPE_FROM_CLASS (gobject_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PolKitGnomeActionClass, auth_start),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- /**
- * PolKitGnomeAction::auth-end:
- * @action: the object
- * @gained_privilege: whether the privilege was gained
- *
- * The ::auth-end signal is emitted when the an authentication
- * session ends and carries information about whether the
- * privilege was obtained or not.
- **/
- signals [AUTH_END_SIGNAL] =
- g_signal_new ("auth-end",
- G_TYPE_FROM_CLASS (gobject_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PolKitGnomeActionClass, auth_end),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE,
- 1, G_TYPE_BOOLEAN);
-
- /**
- * PolKitGnomeAction::polkit-result-changed:
- * @action: the object
- * @current_result: current #PolKitResult from PolicyKit regarding given #PolKitAction object
- *
- * The ::polkit-result-changed signal is emitted when the
- * PolicyKit result changes. This can happen when external
- * factors (config file, ConsoleKit, privilege granted /
- * revoked) change since the #PolKitGnomeAction class listens
- * for events using the #PolKitGnomeContext class.
- **/
- signals [POLKIT_RESULT_CHANGED_SIGNAL] =
- g_signal_new ("polkit-result-changed",
- G_TYPE_FROM_CLASS (gobject_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PolKitGnomeActionClass, polkit_result_changed),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE,
- 1, G_TYPE_INT);
-
-
- g_type_class_add_private (gobject_class, sizeof (PolKitGnomeActionPrivate));
-}
-
-static pid_t
-_get_target_pid (PolKitGnomeAction *action)
-{
- pid_t pid;
-
- if (action != NULL && action->priv->target_pid != 0)
- pid = action->priv->target_pid;
- else
- pid = getpid ();
-
- return pid;
-}
-
-static PolKitResult
-_compute_polkit_result_direct (PolKitGnomeAction *action)
-{
- PolKitCaller *pk_caller;
- PolKitResult pk_result;
- DBusError dbus_error;
-
- _ensure_pk_g_context (action);
-
- dbus_error_init (&dbus_error);
- pk_caller = polkit_tracker_get_caller_from_pid (action->priv->pk_g_context->pk_tracker,
- _get_target_pid (action),
- &dbus_error);
- if (pk_caller == NULL) {
- g_warning ("Cannot get PolKitCaller object for target (pid=%d): %s: %s",
- _get_target_pid (action), dbus_error.name, dbus_error.message);
- dbus_error_free (&dbus_error);
-
- /* this is bad so cop-out to UKNOWN */
- pk_result = POLKIT_RESULT_UNKNOWN;
- } else {
- pk_result = polkit_context_is_caller_authorized (action->priv->pk_g_context->pk_context,
- action->priv->polkit_action,
- pk_caller,
- FALSE,
- NULL);
- if (pk_result != POLKIT_RESULT_YES) {
- GSList *i;
-
- /* no dice.. see if one if the sufficient actions, if any, yields a YES */
- for (i = action->priv->polkit_action_sufficient; i != NULL; i = g_slist_next (i)) {
- PolKitResult r;
- PolKitAction *a = (PolKitAction *) i->data;
-
- r = polkit_context_is_caller_authorized (action->priv->pk_g_context->pk_context,
- a,
- pk_caller,
- FALSE,
- NULL);
-
- if (r == POLKIT_RESULT_YES) {
- pk_result = r;
- break;
- }
- }
- }
- }
-
- if (pk_caller != NULL)
- polkit_caller_unref (pk_caller);
-
- return pk_result;
-}
-
-/* returns TRUE if the result changed */
-static gboolean
-_compute_polkit_result (PolKitGnomeAction *action)
-{
- PolKitResult old_result;
-
- old_result = action->priv->pk_result;
- action->priv->pk_result = POLKIT_RESULT_UNKNOWN;
-
- if (action->priv->polkit_action == NULL) {
- action->priv->pk_result = POLKIT_RESULT_YES;
- } else {
- action->priv->pk_result = _compute_polkit_result_direct (action);
- }
-
- return old_result != action->priv->pk_result;
-}
-
-static void
-_update_action (PolKitGnomeAction *action)
-{
- PolKitGnomeContext *pkgc;
- PolKitAuthorizationDB *authdb;
-
- pkgc = polkit_gnome_context_get (NULL);
- authdb = polkit_context_get_authorization_db (pkgc->pk_context);
-
- switch (action->priv->pk_result) {
- default:
- case POLKIT_RESULT_UNKNOWN:
- case POLKIT_RESULT_NO:
- /* TODO: see if we're self-blocked */
-
- if (action->priv->polkit_action != NULL &&
- polkit_authorization_db_is_uid_blocked_by_self (authdb,
- action->priv->polkit_action,
- getuid (),
- NULL)) {
- g_object_set (action,
- "visible", action->priv->self_blocked_visible && action->priv->master_visible,
- "sensitive", action->priv->self_blocked_sensitive && action->priv->master_sensitive,
- "short-label", action->priv->self_blocked_short_label,
- "label", action->priv->self_blocked_label,
- "tooltip", action->priv->self_blocked_tooltip,
- "icon-name", action->priv->self_blocked_icon_name,
- NULL);
- } else {
- g_object_set (action,
- "visible", action->priv->no_visible && action->priv->master_visible,
- "sensitive", action->priv->no_sensitive && action->priv->master_sensitive,
- "short-label", action->priv->no_short_label,
- "label", action->priv->no_label,
- "tooltip", action->priv->no_tooltip,
- "icon-name", action->priv->no_icon_name,
- NULL);
- }
- break;
-
- case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_ONE_SHOT:
- case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH:
- case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_SESSION:
- case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_ALWAYS:
- case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_ONE_SHOT:
- case POLKIT_RESULT_ONLY_VIA_SELF_AUTH:
- case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION:
- case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS:
- g_object_set (action,
- "visible", action->priv->auth_visible && action->priv->master_visible,
- "sensitive", action->priv->auth_sensitive && action->priv->master_sensitive,
- "short-label", action->priv->auth_short_label,
- "label", action->priv->auth_label,
- "tooltip", action->priv->auth_tooltip,
- "icon-name", action->priv->auth_icon_name,
- NULL);
- break;
-
- case POLKIT_RESULT_YES:
- g_object_set (action,
- "visible", action->priv->yes_visible && action->priv->master_visible,
- "sensitive", action->priv->yes_sensitive && action->priv->master_sensitive,
- "short-label", action->priv->yes_short_label,
- "label", action->priv->yes_label,
- "tooltip", action->priv->yes_tooltip,
- "icon-name", action->priv->yes_icon_name,
- NULL);
- break;
- }
-}
-
-static void
-_pk_config_changed (PolKitGnomeContext *pk_g_context, PolKitGnomeAction *action)
-{
- gboolean result_changed;
- result_changed = _compute_polkit_result (action);
- _update_action (action);
- if (result_changed) {
- g_signal_emit (action, signals [POLKIT_RESULT_CHANGED_SIGNAL], 0, action->priv->pk_result);
- }
-}
-
-static void
-_pk_console_kit_db_changed (PolKitGnomeContext *pk_g_context, PolKitGnomeAction *action)
-{
- /* for now, just use the same code as above... */
- _pk_config_changed (pk_g_context, action);
-}
-
-
-/**
- * polkit_gnome_action_new:
- * @name: A unique name for the action
- *
- * Creates a new #PolKitGnomeAction object. The typical use for this
- * function is for specialized use where
- * polkit_gnome_action_new_default() does not meet the needs of the
- * application. A short example of the usage of this contructor
- * follows.
- *
- * If the 'polkit-action' property is #NULL the behavior is similar to
- * as if a #PolKitAction returned #POLKIT_RESULT_YES.
- *
- * One can set the 'polkit-action-sufficient' property to a
- * #GValueArray of pointers to #PolKitAction objects. The semantics of
- * this property is that if the user is authorized for any of the
- * given actions in 'polkit-action-sufficient' then the behavior is
- * the same as if they're authorized for the action denoted by
- * 'polkit-action'. This is useful in a setup where you have two
- * similar actions and one implies the other. For example, in
- * gnome-system-monitor there are two actions
- * <literal>org.gnome.system-monitor.increase-own-priority</literal>
- * (Increase the priority of a process owned by yourself) and
- * <literal>org.gnome.system-monitor.change-priorty</literal> (Change
- * priority of any process). As the latter clearly implies the former,
- * one would set the latter in the 'polkit-action-sufficient'
- * property when constructing a #PolKitAction for the former.
- *
- * <programlisting>
- * PolKitAction *polkit_action;
- * PolKitGnomeAction *action;
- *
- * polkit_action = polkit_action_new ();
- * polkit_action_set_action_id (polkit_action, "org.example.some-policykit-action");
- *
- * action = polkit_gnome_action_new ("blabla", NULL);
- * g_object_set (action,
- * "polkit-action", polkit_action,
- * "no-visible", TRUE,
- * "no-sensitive", FALSE,
- * "no-short-label", "The Action no can do!",
- * "no-label", "The Action is not permitted!",
- * "no-tooltip", "The Tooltip (no)",
- * "no-icon-name", GTK_STOCK_NO,
- *
- * "auth-visible", TRUE,
- * "auth-sensitive", TRUE,
- * "auth-short-label", "The Action requires auth...",
- * "auth-label", "The Action requires auth...",
- * "auth-tooltip", "The Tooltip (auth)",
- * "auth-icon-name", GTK_STOCK_DIALOG_AUTHENTICATION,
- *
- * "yes-visible", TRUE,
- * "yes-sensitive", TRUE,
- * "yes-short-label", "Action!",
- * "yes-label", "Just do the Action!",
- * "yes-tooltip", "The Tooltip (yes)",
- * "yes-icon-name", GTK_STOCK_YES,
- * NULL);
- * </programlisting>
- *
- * Returns: a new #PolKitGnomeAction or #NULL if error is set
- */
-PolKitGnomeAction *
-polkit_gnome_action_new (const gchar *name)
-{
- PolKitGnomeAction *action = NULL;
-
- action = g_object_new (POLKIT_GNOME_TYPE_ACTION,
- "name", name,
- NULL);
-
- return action;
-}
-
-/**
- * polkit_gnome_action_new_default:
- * @name: A unique name for the action
- * @polkit_action: the #PolKitAction to track
- * @label: the label to use (will also apply to short-label)
- * @tooltip: the tool tip to use
- *
- * Creates a new #PolKitGnomeAction object with the default
- * behavior for a given #PolKitAction object.
- *
- * Default behavior is defined by the label and tooltip being
- * identical across all three four states, the action being visible in
- * all four states, and the action being insensitive only in the state
- * where the result from PolicyKit is no and self-blocked. Only when
- * PolicyKit returns one of the 'auth*' results, the icon_name
- * property will be set to #GTK_STOCK_DIALOG_AUTHENTICATION.
- *
- * The caller can always modify individual aspects of the action after
- * creation, e.g. change the tooltip for the self-blocked, no, auth
- * and yes states.
- *
- * If the given polkit_action is #NULL the behavior is similar to as
- * if a #PolKitAction returned #POLKIT_RESULT_YES.
- *
- * Returns: a new #PolKitGnomeAction or #NULL if error is set
- */
-PolKitGnomeAction *
-polkit_gnome_action_new_default (const gchar *name,
- PolKitAction *polkit_action,
- const gchar *label,
- const gchar *tooltip)
-{
- PolKitGnomeAction *action;
-
- action = g_object_new (POLKIT_GNOME_TYPE_ACTION,
- "name", name,
- "polkit-action", polkit_action,
-
- "self-blocked-visible", TRUE,
- "self-blocked-sensitive", FALSE,
- "self-blocked-short-label", label,
- "self-blocked-label", label,
- "self-blocked-tooltip", tooltip,
- "self-blocked-icon-name", NULL,
-
- "no-visible", TRUE,
- "no-sensitive", FALSE,
- "no-short-label", label,
- "no-label", label,
- "no-tooltip", tooltip,
- "no-icon-name", NULL,
-
- "auth-visible", TRUE,
- "auth-sensitive", TRUE,
- "auth-short-label", label,
- "auth-label", label,
- "auth-tooltip", tooltip,
- "auth-icon-name", GTK_STOCK_DIALOG_AUTHENTICATION,
-
- "yes-visible", TRUE,
- "yes-sensitive", TRUE,
- "yes-short-label", label,
- "yes-label", label,
- "yes-tooltip", tooltip,
- "yes-icon-name", NULL,
-
- "master-visible", TRUE,
- "master-sensitive", TRUE,
- NULL);
-
- return action;
-}
-
-/*----------------------------------------------------------------------------------------------------*/
-
-/**
- * polkit_gnome_action_set_polkit_action:
- * @action: The #PolKitGnomeAction object
- * @pk_action: The #PolKitAction object
- *
- * Sets the #PolKitAction object to track for updating the GTK+ action.
- */
-static void
-polkit_gnome_action_set_polkit_action (PolKitGnomeAction *action, PolKitAction *pk_action)
-{
-
- /* Don't bother updating polkit_action if it's the same
- * value.. it will just cause a lot of unnecessary work as
- * we'll recompute the answer via PolicyKit..
- *
- * unless it's on the initial call (where priv->polkit_action
- * is alread NULL) because we need that initial update;
- */
- if (!action->priv->polkit_action_set_once || action->priv->polkit_action != pk_action) {
-
- action->priv->polkit_action_set_once = TRUE;
-
- if (action->priv->polkit_action != NULL)
- polkit_action_unref (action->priv->polkit_action);
-
- action->priv->polkit_action = pk_action != NULL ? polkit_action_ref (pk_action) : NULL;
-
- _compute_polkit_result (action);
- _update_action (action);
- }
-}
-
-static void
-polkit_gnome_action_set_polkit_action_sufficient (PolKitGnomeAction *action, const GValue *pk_action_array)
-{
- unsigned int n;
- GValueArray *value_array;
-
- free_pk_action_sufficient (action);
-
- if (pk_action_array == NULL)
- goto out;
-
- value_array = g_value_get_boxed (pk_action_array);
- if (value_array == NULL)
- goto out;
-
- for (n = 0; n < value_array->n_values; n++) {
- PolKitAction *pk_action;
-
- pk_action = (PolKitAction *) g_value_get_pointer (& (value_array->values[n]));
- action->priv->polkit_action_sufficient = g_slist_prepend (action->priv->polkit_action_sufficient,
- polkit_action_ref (pk_action));
- char *s;
- polkit_action_get_action_id (pk_action, &s);
- g_warning ("Setting sufficient %d: %s", n, s);
- }
-
-out:
- _compute_polkit_result (action);
- _update_action (action);
-}
-
-
-/**
- * polkit_gnome_action_get_polkit_result:
- * @action: The #PolKitGnomeAction object
- *
- * Gets the #PolKitResult that indicates whether the user is
- * privileged to do the #PolKitAction associated with this
- * #PolKitGnomeAction object.
- *
- * Returns: The #PolKitAction object. The caller shall not unref this object.
- */
-PolKitResult
-polkit_gnome_action_get_polkit_result (PolKitGnomeAction *action)
-{
- _compute_polkit_result (action);
- _update_action (action);
- return action->priv->pk_result;
-}
-
-/**
- * polkit_gnome_action_get_sensitive:
- * @action: The #PolKitGnomeAction object
- *
- * Get the master sensitivity, see PolKitGnomeAction:master-sensitive:
- * for details.
- *
- * Returns: the master sensitivity
- */
-gboolean
-polkit_gnome_action_get_sensitive (PolKitGnomeAction *action)
-{
- return action->priv->master_sensitive;
-}
-
-/**
- * polkit_gnome_action_set_sensitive:
- * @action: The #PolKitGnomeAction object
- * @sensitive: master sensitivity
- *
- * Set the master sensitivity, see PolKitGnomeAction:master-sensitive:
- * for details.
- */
-void
-polkit_gnome_action_set_sensitive (PolKitGnomeAction *action, gboolean sensitive)
-{
- if (action->priv->master_sensitive == sensitive)
- return;
- action->priv->master_sensitive = sensitive;
- _update_action (action);
-}
-
-static void
-polkit_gnome_action_set_target_pid (PolKitGnomeAction *action, guint target_pid)
-{
- action->priv->target_pid = target_pid;
- _compute_polkit_result (action);
- _update_action (action);
-}
-
-/**
- * polkit_gnome_action_get_visible:
- * @action: The #PolKitGnomeAction object
- *
- * Get the master visibility, see PolKitGnomeAction:master-visible:
- * for details.
- *
- * Returns: the master visibility
- */
-gboolean
-polkit_gnome_action_get_visible (PolKitGnomeAction *action)
-{
- return action->priv->master_visible;
-}
-
-/**
- * polkit_gnome_action_set_visible:
- * @action: The #PolKitGnomeAction object
- * @visible: master visibility
- *
- * Set the master visibility, see PolKitGnomeAction:master-visible:
- * for details.
- */
-void
-polkit_gnome_action_set_visible (PolKitGnomeAction *action, gboolean visible)
-{
- if (action->priv->master_visible == visible)
- return;
- action->priv->master_visible = visible;
- _update_action (action);
-}
-
-/*----------------------------------------------------------------------------------------------------*/
-
-/**
- * polkit_gnome_action_set_self_blocked_visible:
- * @action: The #PolKitGnomeAction object
- * @visible: new value
- *
- * Sets the value of visible to use when PolicyKit returns the answer
- * no (and the reason is that the user has a self-granted negative
- * authorization) for the current #PolKitAction being tracked.
- */
-static void
-polkit_gnome_action_set_self_blocked_visible (PolKitGnomeAction *action, gboolean visible)
-{
- action->priv->self_blocked_visible = visible;
- _update_action (action);
-}
-
-/**
- * polkit_gnome_action_set_self_blocked_sensitive:
- * @action: The #PolKitGnomeAction object
- * @sensitive: new value
- *
- * Sets the value of sensitive to use when PolicyKit returns the
- * answer no (and the reason is that the user has a self-granted
- * negative authorization) for the current #PolKitAction being
- * tracked.
- */
-static void
-polkit_gnome_action_set_self_blocked_sensitive (PolKitGnomeAction *action, gboolean sensitive)
-{
- action->priv->self_blocked_sensitive = sensitive;
- _update_action (action);
-}
-
-/**
- * polkit_gnome_action_set_self_blocked_short_label:
- * @action: The #PolKitGnomeAction object
- * @short_label: new value
- *
- * Sets the value of short-label to use when PolicyKit returns the
- * answer no (and the reason is that the user has a self-granted
- * negative authorization) for the current #PolKitAction being
- * tracked.
- */
-static void
-polkit_gnome_action_set_self_blocked_short_label (PolKitGnomeAction *action, const gchar *short_label)
-{
- g_free (action->priv->self_blocked_short_label);
- action->priv->self_blocked_short_label = g_strdup (short_label);
- _update_action (action);
-}
-
-/**
- * polkit_gnome_action_set_self_blocked_label:
- * @action: The #PolKitGnomeAction object
- * @label: new value
- *
- * Sets the value of label to use when PolicyKit returns the answer
- * no (and the reason is that the user has a self-granted
- * negative authorization) for the current #PolKitAction being
- * tracked.
- */
-static void
-polkit_gnome_action_set_self_blocked_label (PolKitGnomeAction *action, const gchar *label)
-{
- g_free (action->priv->self_blocked_label);
- action->priv->self_blocked_label = g_strdup (label);
- _update_action (action);
-}
-
-/**
- * polkit_gnome_action_set_self_blocked_tooltip:
- * @action: The #PolKitGnomeAction object
- * @tooltip: new value
- *
- * Sets the value of tooltip to use when PolicyKit returns the answer
- * no (and the reason is that the user has a self-granted negative
- * authorization) for the current #PolKitAction being tracked.
- */
-static void
-polkit_gnome_action_set_self_blocked_tooltip (PolKitGnomeAction *action, const gchar *tooltip)
-{
- g_free (action->priv->self_blocked_tooltip);
- action->priv->self_blocked_tooltip = g_strdup (tooltip);
- _update_action (action);
-}
-
-/**
- * polkit_gnome_action_set_self_blocked_icon_name:
- * @action: The #PolKitGnomeAction object
- * @icon_name: new value
- *
- * Sets the value of icon_name to use when PolicyKit returns the
- * answer no (and the reason is that the user has a self-granted
- * negative authorization) for the current #PolKitAction being
- * tracked.
- */
-static void
-polkit_gnome_action_set_self_blocked_icon_name (PolKitGnomeAction *action, const gchar *icon_name)
-{
- g_free (action->priv->self_blocked_icon_name);
- action->priv->self_blocked_icon_name = g_strdup (icon_name);
- _update_action (action);
-}
-
-/*----------------------------------------------------------------------------------------------------*/
-
-/**
- * polkit_gnome_action_set_no_visible:
- * @action: The #PolKitGnomeAction object
- * @visible: new value
- *
- * Sets the value of visible to use when PolicyKit returns the answer
- * no for the current #PolKitAction being tracked.
- */
-static void
-polkit_gnome_action_set_no_visible (PolKitGnomeAction *action, gboolean visible)
-{
- action->priv->no_visible = visible;
- _update_action (action);
-}
-
-/**
- * polkit_gnome_action_set_no_sensitive:
- * @action: The #PolKitGnomeAction object
- * @sensitive: new value
- *
- * Sets the value of sensitive to use when PolicyKit returns the answer
- * no for the current #PolKitAction being tracked.
- */
-static void
-polkit_gnome_action_set_no_sensitive (PolKitGnomeAction *action, gboolean sensitive)
-{
- action->priv->no_sensitive = sensitive;
- _update_action (action);
-}
-
-/**
- * polkit_gnome_action_set_no_short_label:
- * @action: The #PolKitGnomeAction object
- * @short_label: new value
- *
- * Sets the value of short-label to use when PolicyKit returns the
- * answer no for the current #PolKitAction being tracked.
- */
-static void
-polkit_gnome_action_set_no_short_label (PolKitGnomeAction *action, const gchar *short_label)
-{
- g_free (action->priv->no_short_label);
- action->priv->no_short_label = g_strdup (short_label);
- _update_action (action);
-}
-
-/**
- * polkit_gnome_action_set_no_label:
- * @action: The #PolKitGnomeAction object
- * @label: new value
- *
- * Sets the value of label to use when PolicyKit returns the answer no
- * for the current #PolKitAction being tracked.
- */
-static void
-polkit_gnome_action_set_no_label (PolKitGnomeAction *action, const gchar *label)
-{
- g_free (action->priv->no_label);
- action->priv->no_label = g_strdup (label);
- _update_action (action);
-}
-
-/**
- * polkit_gnome_action_set_no_tooltip:
- * @action: The #PolKitGnomeAction object
- * @tooltip: new value
- *
- * Sets the value of tooltip to use when PolicyKit returns the answer
- * no for the current #PolKitAction being tracked.
- */
-static void
-polkit_gnome_action_set_no_tooltip (PolKitGnomeAction *action, const gchar *tooltip)
-{
- g_free (action->priv->no_tooltip);
- action->priv->no_tooltip = g_strdup (tooltip);
- _update_action (action);
-}
-
-/**
- * polkit_gnome_action_set_no_icon_name:
- * @action: The #PolKitGnomeAction object
- * @icon_name: new value
- *
- * Sets the value of icon_name to use when PolicyKit returns the
- * answer no for the current #PolKitAction being tracked.
- */
-static void
-polkit_gnome_action_set_no_icon_name (PolKitGnomeAction *action, const gchar *icon_name)
-{
- g_free (action->priv->no_icon_name);
- action->priv->no_icon_name = g_strdup (icon_name);
- _update_action (action);
-}
-
-/*----------------------------------------------------------------------------------------------------*/
-
-/**
- * polkit_gnome_action_set_auth_visible:
- * @action: The #PolKitGnomeAction object
- * @visible: new value
- *
- * Sets the value of visible to use when PolicyKit returns the answer
- * auth* for the current #PolKitAction being tracked.
- */
-static void
-polkit_gnome_action_set_auth_visible (PolKitGnomeAction *action, gboolean visible)
-{
- action->priv->auth_visible = visible;
- _update_action (action);
-}
-
-/**
- * polkit_gnome_action_set_auth_sensitive:
- * @action: The #PolKitGnomeAction object
- * @sensitive: new value
- *
- * Sets the value of sensitive to use when PolicyKit returns the answer
- * auth* for the current #PolKitAction being tracked.
- */
-static void
-polkit_gnome_action_set_auth_sensitive (PolKitGnomeAction *action, gboolean sensitive)
-{
- action->priv->auth_sensitive = sensitive;
- _update_action (action);
-}
-
-/**
- * polkit_gnome_action_set_auth_short_label:
- * @action: The #PolKitGnomeAction object
- * @short_label: new value
- *
- * Sets the value of short-label to use when PolicyKit returns the
- * answer auth for the current #PolKitAction being tracked.
- */
-static void
-polkit_gnome_action_set_auth_short_label (PolKitGnomeAction *action, const gchar *short_label)
-{
- g_free (action->priv->auth_short_label);
- action->priv->auth_short_label = g_strdup (short_label);
- _update_action (action);
-}
-
-/**
- * polkit_gnome_action_set_auth_label:
- * @action: The #PolKitGnomeAction object
- * @label: new value
- *
- * Sets the value of label to use when PolicyKit returns the answer auth*
- * for the current #PolKitAction being tracked.
- */
-static void
-polkit_gnome_action_set_auth_label (PolKitGnomeAction *action, const gchar *label)
-{
- g_free (action->priv->auth_label);
- action->priv->auth_label = g_strdup (label);
- _update_action (action);
-}
-
-/**
- * polkit_gnome_action_set_auth_tooltip:
- * @action: The #PolKitGnomeAction object
- * @tooltip: new value
- *
- * Sets the value of tooltip to use when PolicyKit returns the answer
- * auth* for the current #PolKitAction being tracked.
- */
-static void
-polkit_gnome_action_set_auth_tooltip (PolKitGnomeAction *action, const gchar *tooltip)
-{
- g_free (action->priv->auth_tooltip);
- action->priv->auth_tooltip = g_strdup (tooltip);
- _update_action (action);
-}
-
-/**
- * polkit_gnome_action_set_auth_icon_name:
- * @action: The #PolKitGnomeAction object
- * @icon_name: new value
- *
- * Sets the value of icon_name to use when PolicyKit returns the
- * answer auth* for the current #PolKitAction being tracked.
- */
-static void
-polkit_gnome_action_set_auth_icon_name (PolKitGnomeAction *action, const gchar *icon_name)
-{
- g_free (action->priv->auth_icon_name);
- action->priv->auth_icon_name = g_strdup (icon_name);
- _update_action (action);
-}
-
-/*----------------------------------------------------------------------------------------------------*/
-
-/**
- * polkit_gnome_action_set_yes_visible:
- * @action: The #PolKitGnomeAction object
- * @visible: new value
- *
- * Sets the value of visible to use when PolicyKit returns the answer
- * yes for the current #PolKitAction being tracked.
- */
-static void
-polkit_gnome_action_set_yes_visible (PolKitGnomeAction *action, gboolean visible)
-{
- action->priv->yes_visible = visible;
- _update_action (action);
-}
-
-/**
- * polkit_gnome_action_set_yes_sensitive:
- * @action: The #PolKitGnomeAction object
- * @sensitive: new value
- *
- * Sets the value of sensitive to use when PolicyKit returns the answer
- * yes for the current #PolKitAction being tracked.
- */
-static void
-polkit_gnome_action_set_yes_sensitive (PolKitGnomeAction *action, gboolean sensitive)
-{
- action->priv->yes_sensitive = sensitive;
- _update_action (action);
-}
-
-/**
- * polkit_gnome_action_set_yes_short_label:
- * @action: The #PolKitGnomeAction object
- * @short_label: new value
- *
- * Sets the value of short-label to use when PolicyKit returns the
- * answer yes for the current #PolKitAction being tracked.
- */
-static void
-polkit_gnome_action_set_yes_short_label (PolKitGnomeAction *action, const gchar *short_label)
-{
- g_free (action->priv->yes_short_label);
- action->priv->yes_short_label = g_strdup (short_label);
- _update_action (action);
-}
-
-/**
- * polkit_gnome_action_set_yes_label:
- * @action: The #PolKitGnomeAction object
- * @label: new value
- *
- * Sets the value of label to use when PolicyKit returns the answer yes
- * for the current #PolKitAction being tracked.
- */
-static void
-polkit_gnome_action_set_yes_label (PolKitGnomeAction *action, const gchar *label)
-{
- g_free (action->priv->yes_label);
- action->priv->yes_label = g_strdup (label);
- _update_action (action);
-}
-
-/**
- * polkit_gnome_action_set_yes_tooltip:
- * @action: The #PolKitGnomeAction object
- * @tooltip: new value
- *
- * Sets the value of tooltip to use when PolicyKit returns the answer
- * yes for the current #PolKitAction being tracked.
- */
-static void
-polkit_gnome_action_set_yes_tooltip (PolKitGnomeAction *action, const gchar *tooltip)
-{
- g_free (action->priv->yes_tooltip);
- action->priv->yes_tooltip = g_strdup (tooltip);
- _update_action (action);
-}
-
-/**
- * polkit_gnome_action_set_yes_icon_name:
- * @action: The #PolKitGnomeAction object
- * @icon_name: new value
- *
- * Sets the value of icon_name to use when PolicyKit returns the
- * answer yes for the current #PolKitAction being tracked.
- */
-static void
-polkit_gnome_action_set_yes_icon_name (PolKitGnomeAction *action, const gchar *icon_name)
-{
- g_free (action->priv->yes_icon_name);
- action->priv->yes_icon_name = g_strdup (icon_name);
- _update_action (action);
-}
-
-/*----------------------------------------------------------------------------------------------------*/
-
-static void
-get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- PolKitGnomeAction *action = POLKIT_GNOME_ACTION (object);
-
- switch (prop_id)
- {
- case PROP_POLKIT_ACTION_OBJ:
- g_value_set_pointer (value, action->priv->polkit_action != NULL ? polkit_action_ref (action->priv->polkit_action) : NULL);
- break;
-
- case PROP_POLKIT_ACTION_OBJ_SUFFICIENT:
- //TODO: g_value_set_pointer (value, action->priv->polkit_action != NULL ? polkit_action_ref (action->priv->polkit_action) : NULL);
- break;
-
- case PROP_POLKIT_SELF_BLOCKED_VISIBLE:
- g_value_set_boolean (value, action->priv->self_blocked_visible);
- break;
- case PROP_POLKIT_SELF_BLOCKED_SENSITIVE:
- g_value_set_boolean (value, action->priv->self_blocked_sensitive);
- break;
- case PROP_POLKIT_SELF_BLOCKED_SHORT_LABEL:
- g_value_set_string (value, action->priv->self_blocked_short_label);
- break;
- case PROP_POLKIT_SELF_BLOCKED_LABEL:
- g_value_set_string (value, action->priv->self_blocked_label);
- break;
- case PROP_POLKIT_SELF_BLOCKED_TOOLTIP:
- g_value_set_string (value, action->priv->self_blocked_tooltip);
- break;
- case PROP_POLKIT_SELF_BLOCKED_ICON_NAME:
- g_value_set_string (value, action->priv->self_blocked_icon_name);
- break;
-
- case PROP_POLKIT_NO_VISIBLE:
- g_value_set_boolean (value, action->priv->no_visible);
- break;
- case PROP_POLKIT_NO_SENSITIVE:
- g_value_set_boolean (value, action->priv->no_sensitive);
- break;
- case PROP_POLKIT_NO_SHORT_LABEL:
- g_value_set_string (value, action->priv->no_short_label);
- break;
- case PROP_POLKIT_NO_LABEL:
- g_value_set_string (value, action->priv->no_label);
- break;
- case PROP_POLKIT_NO_TOOLTIP:
- g_value_set_string (value, action->priv->no_tooltip);
- break;
- case PROP_POLKIT_NO_ICON_NAME:
- g_value_set_string (value, action->priv->no_icon_name);
- break;
-
- case PROP_POLKIT_AUTH_VISIBLE:
- g_value_set_boolean (value, action->priv->auth_visible);
- break;
- case PROP_POLKIT_AUTH_SENSITIVE:
- g_value_set_boolean (value, action->priv->auth_sensitive);
- break;
- case PROP_POLKIT_AUTH_SHORT_LABEL:
- g_value_set_string (value, action->priv->auth_short_label);
- break;
- case PROP_POLKIT_AUTH_LABEL:
- g_value_set_string (value, action->priv->auth_label);
- break;
- case PROP_POLKIT_AUTH_TOOLTIP:
- g_value_set_string (value, action->priv->auth_tooltip);
- break;
- case PROP_POLKIT_AUTH_ICON_NAME:
- g_value_set_string (value, action->priv->auth_icon_name);
- break;
-
- case PROP_POLKIT_YES_VISIBLE:
- g_value_set_boolean (value, action->priv->yes_visible);
- break;
- case PROP_POLKIT_YES_SENSITIVE:
- g_value_set_boolean (value, action->priv->yes_sensitive);
- break;
- case PROP_POLKIT_YES_SHORT_LABEL:
- g_value_set_string (value, action->priv->yes_short_label);
- break;
- case PROP_POLKIT_YES_LABEL:
- g_value_set_string (value, action->priv->yes_label);
- break;
- case PROP_POLKIT_YES_TOOLTIP:
- g_value_set_string (value, action->priv->yes_tooltip);
- break;
- case PROP_POLKIT_YES_ICON_NAME:
- g_value_set_string (value, action->priv->yes_icon_name);
- break;
-
- case PROP_POLKIT_MASTER_VISIBLE:
- g_value_set_boolean (value, action->priv->master_visible);
- break;
- case PROP_POLKIT_MASTER_SENSITIVE:
- g_value_set_boolean (value, action->priv->master_sensitive);
- break;
-
- case PROP_POLKIT_TARGET_PID:
- g_value_set_uint (value, action->priv->target_pid);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- PolKitGnomeAction *action = POLKIT_GNOME_ACTION (object);
-
- switch (prop_id)
- {
- case PROP_POLKIT_ACTION_OBJ:
- polkit_gnome_action_set_polkit_action (action, g_value_get_pointer (value));
- break;
-
- case PROP_POLKIT_ACTION_OBJ_SUFFICIENT:
- polkit_gnome_action_set_polkit_action_sufficient (action, value);
- break;
-
- case PROP_POLKIT_SELF_BLOCKED_VISIBLE:
- polkit_gnome_action_set_self_blocked_visible (action, g_value_get_boolean (value));
- break;
- case PROP_POLKIT_SELF_BLOCKED_SENSITIVE:
- polkit_gnome_action_set_self_blocked_sensitive (action, g_value_get_boolean (value));
- break;
- case PROP_POLKIT_SELF_BLOCKED_SHORT_LABEL:
- polkit_gnome_action_set_self_blocked_short_label (action, g_value_get_string (value));
- break;
- case PROP_POLKIT_SELF_BLOCKED_LABEL:
- polkit_gnome_action_set_self_blocked_label (action, g_value_get_string (value));
- break;
- case PROP_POLKIT_SELF_BLOCKED_TOOLTIP:
- polkit_gnome_action_set_self_blocked_tooltip (action, g_value_get_string (value));
- break;
- case PROP_POLKIT_SELF_BLOCKED_ICON_NAME:
- polkit_gnome_action_set_self_blocked_icon_name (action, g_value_get_string (value));
- break;
-
- case PROP_POLKIT_NO_VISIBLE:
- polkit_gnome_action_set_no_visible (action, g_value_get_boolean (value));
- break;
- case PROP_POLKIT_NO_SENSITIVE:
- polkit_gnome_action_set_no_sensitive (action, g_value_get_boolean (value));
- break;
- case PROP_POLKIT_NO_SHORT_LABEL:
- polkit_gnome_action_set_no_short_label (action, g_value_get_string (value));
- break;
- case PROP_POLKIT_NO_LABEL:
- polkit_gnome_action_set_no_label (action, g_value_get_string (value));
- break;
- case PROP_POLKIT_NO_TOOLTIP:
- polkit_gnome_action_set_no_tooltip (action, g_value_get_string (value));
- break;
- case PROP_POLKIT_NO_ICON_NAME:
- polkit_gnome_action_set_no_icon_name (action, g_value_get_string (value));
- break;
-
- case PROP_POLKIT_AUTH_VISIBLE:
- polkit_gnome_action_set_auth_visible (action, g_value_get_boolean (value));
- break;
- case PROP_POLKIT_AUTH_SENSITIVE:
- polkit_gnome_action_set_auth_sensitive (action, g_value_get_boolean (value));
- break;
- case PROP_POLKIT_AUTH_SHORT_LABEL:
- polkit_gnome_action_set_auth_short_label (action, g_value_get_string (value));
- break;
- case PROP_POLKIT_AUTH_LABEL:
- polkit_gnome_action_set_auth_label (action, g_value_get_string (value));
- break;
- case PROP_POLKIT_AUTH_TOOLTIP:
- polkit_gnome_action_set_auth_tooltip (action, g_value_get_string (value));
- break;
- case PROP_POLKIT_AUTH_ICON_NAME:
- polkit_gnome_action_set_auth_icon_name (action, g_value_get_string (value));
- break;
-
- case PROP_POLKIT_YES_VISIBLE:
- polkit_gnome_action_set_yes_visible (action, g_value_get_boolean (value));
- break;
- case PROP_POLKIT_YES_SENSITIVE:
- polkit_gnome_action_set_yes_sensitive (action, g_value_get_boolean (value));
- break;
- case PROP_POLKIT_YES_SHORT_LABEL:
- polkit_gnome_action_set_yes_short_label (action, g_value_get_string (value));
- break;
- case PROP_POLKIT_YES_LABEL:
- polkit_gnome_action_set_yes_label (action, g_value_get_string (value));
- break;
- case PROP_POLKIT_YES_TOOLTIP:
- polkit_gnome_action_set_yes_tooltip (action, g_value_get_string (value));
- break;
- case PROP_POLKIT_YES_ICON_NAME:
- polkit_gnome_action_set_yes_icon_name (action, g_value_get_string (value));
- break;
-
- case PROP_POLKIT_MASTER_VISIBLE:
- polkit_gnome_action_set_visible (action, g_value_get_boolean (value));
- break;
- case PROP_POLKIT_MASTER_SENSITIVE:
- polkit_gnome_action_set_sensitive (action, g_value_get_boolean (value));
- break;
-
- case PROP_POLKIT_TARGET_PID:
- polkit_gnome_action_set_target_pid (action, g_value_get_uint (value));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static XID
-_get_xid_from_proxy_widgets (PolKitGnomeAction *action)
-{
- XID xid;
- GSList *i;
- GSList *proxies;
-
- /* unfortunately there's no way to get the proxy that caused
- * the ::activate signal.. so go through proxies and pick the
- * first one.. */
-
- /* TODO: this won't work for menus (mclasen) */
-
- xid = 0;
-
- proxies = gtk_action_get_proxies (GTK_ACTION (action));
-
- for (i = proxies; i != NULL; i = i->next) {
- GtkWidget *top_level;
- GtkWidget *proxy = i->data;
-
- top_level = gtk_widget_get_toplevel (proxy);
-
- if (top_level == NULL)
- continue;
-
- if (! (GTK_WIDGET_TOPLEVEL (top_level) && GTK_IS_WINDOW (top_level)))
- continue;
-
- if (top_level->window == NULL)
- continue;
-
- xid = gdk_x11_drawable_get_xid (GDK_WINDOW (top_level->window));
-
- if (xid != 0)
- break;
- }
-
- return xid;
-}
-
-static void
-_show_dialog_cb (PolKitAction *pk_action,
- gboolean gained_privilege,
- GError *error,
- gpointer user_data)
-{
- PolKitGnomeAction *action = POLKIT_GNOME_ACTION (user_data);
-
- if (gained_privilege) {
- /* better make sure our local pk_result is up-to-date.. */
- _compute_polkit_result (action);
-
- //g_debug ("end auth, obtained it");
-
- /* now emit the 'activate' signal again.. */
- gtk_action_activate (GTK_ACTION (action));
-
- } else {
- //g_debug ("end auth, didn't obtain it");
-
- if (error != NULL) {
- g_warning ("Caught error: %s", error->message);
- g_error_free (error);
- }
- }
-
- g_signal_emit (action, signals [AUTH_END_SIGNAL], 0, gained_privilege);
-}
-
-static void
-_auth_start (PolKitGnomeAction *action)
-{
- GError *error = NULL;
-
- //g_debug ("starting auth");
- if (!polkit_gnome_auth_obtain (action->priv->polkit_action,
- (guint) _get_xid_from_proxy_widgets (action),
- (guint) _get_target_pid (action),
- _show_dialog_cb,
- action,
- &error)) {
- g_warning ("Caught error: %s", error->message);
- g_error_free (error);
- }
-}
-
-static void
-polkit_gnome_action_activate (PolKitGnomeAction *action)
-{
- switch (action->priv->pk_result) {
- case POLKIT_RESULT_YES:
- /* If PolicyKit says yes.. then let 'activate' signal
- * propagate
- */
- break;
-
- case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_ONE_SHOT:
- case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH:
- case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_SESSION:
- case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_ALWAYS:
- case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_ONE_SHOT:
- case POLKIT_RESULT_ONLY_VIA_SELF_AUTH:
- case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION:
- case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS:
- /* Otherwise, if the action needs auth.. stop the emission
- * and start auth process..
- */
-
- g_signal_stop_emission_by_name (action, "activate");
-
- if (action->priv->polkit_action != NULL) {
- g_signal_emit (action, signals [AUTH_START_SIGNAL], 0);
- }
- break;
-
- default:
- case POLKIT_RESULT_NO:
- /* If PolicyKit says no... and we got here.. it means
- * that the user set the property "no-sensitive" to
- * TRUE.. Otherwise we couldn't be handling this signal.
- *
- * Hence, they probably have a good reason for doing
- * this so do let the 'activate' signal propagate..
- */
- break;
- }
-}
-
-static void
-_update_tooltips (PolKitGnomeAction *action, GParamSpec *arg1, GtkWidget *widget)
-{
- GtkTooltips *tips;
- GtkTooltipsData *ttd;
- gchar *tip_str;
-
- ttd = gtk_tooltips_data_get (widget);
-
- if (ttd == NULL) {
- tips = gtk_tooltips_new ();
- } else {
- tips = ttd->tooltips;
- }
-
- tip_str = NULL;
- g_object_get (action, "tooltip", &tip_str, NULL);
-
- /* TODO: if there is no tooltip the tip_str is NULL.
- * Unfortunately it seems that the tooltip isn't
- * cleared.. mmm.. gtk+ bug?
- */
- gtk_tooltips_set_tip (tips, widget, tip_str, tip_str);
- g_free (tip_str);
-}
-
-static void
-_update_label (PolKitGnomeAction *action, GParamSpec *arg1, GtkWidget *widget)
-{
- char *label;
-
- label = NULL;
- g_object_get (action, "label", &label, NULL);
- gtk_button_set_label (GTK_BUTTON (widget), label);
- g_free (label);
-}
-
-static void
-_update_icon_name (PolKitGnomeAction *action, GParamSpec *arg1, GtkWidget *widget)
-{
- gtk_button_set_image (GTK_BUTTON (widget), gtk_action_create_icon (GTK_ACTION (action), GTK_ICON_SIZE_BUTTON));
-}
-
-static void
-_button_clicked (GtkButton *button, PolKitGnomeAction *action)
-{
- /* g_debug ("in _button_clicked"); */
-
- switch (action->priv->pk_result) {
- case POLKIT_RESULT_YES:
- break;
-
- case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_ONE_SHOT:
- case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH:
- case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_SESSION:
- case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_ALWAYS:
- case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_ONE_SHOT:
- case POLKIT_RESULT_ONLY_VIA_SELF_AUTH:
- case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION:
- case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS:
- /* g_debug ("blocking clicked"); */
- g_signal_stop_emission_by_name (button, "clicked");
- break;
-
- default:
- case POLKIT_RESULT_NO:
- break;
- }
-}
-
-static void
-_button_auth_end (PolKitGnomeAction *action, gboolean gained_privilege, GtkWidget *button)
-{
- /* g_debug ("in _button_auth_end gained_privilege=%d", gained_privilege); */
- if (gained_privilege) {
- /* g_debug ("emitting clicked"); */
- gtk_action_block_activate_from (GTK_ACTION (action), button);
- g_signal_emit_by_name (button, "clicked");
- gtk_action_unblock_activate_from (GTK_ACTION (action), button);
- }
-}
-
-/**
- * polkit_gnome_action_create_button:
- * @action: The #PolKitGnomeAction object
- *
- * Create a button for the given action that displays the label,
- * tooltip and icon_name corresponding to whether the state, according
- * to PolicyKit, is no, auth or yes.
- *
- * Returns: A #GtkButton instance connected to the action
- */
-GtkWidget *
-polkit_gnome_action_create_button (PolKitGnomeAction *action)
-{
- GtkWidget *button;
-
- button = gtk_button_new ();
-
- gtk_action_connect_proxy (GTK_ACTION (action), button);
-
- _update_label (action, NULL, button);
- _update_tooltips (action, NULL, button);
- _update_icon_name (action, NULL, button);
-
- g_signal_connect (action, "notify::tooltip", G_CALLBACK (_update_tooltips), button);
- g_signal_connect (action, "notify::label", G_CALLBACK (_update_label), button);
- g_signal_connect (action, "notify::icon-name", G_CALLBACK (_update_icon_name), button);
-
- /* hook into the ::clicked signal and block it unless
- * PolicyKit says it's good to go. This is necessary when the
- * button is embedded in e.g. a GtkDialog since that class
- * hooks in ::clicked signals from GtkButton instances...
- *
- * Also, hook into ::auth_end signal from the
- * PolKitGnomeAction and synthesize ::clicked the signal if
- * the privilege was gained..
- */
- g_signal_connect (button, "clicked", G_CALLBACK (_button_clicked), action);
- g_signal_connect (action, "auth-end", G_CALLBACK (_button_auth_end), button);
-
- return button;
-}
diff --git a/polkit-gnome/polkit-gnome-action.h b/polkit-gnome/polkit-gnome-action.h
deleted file mode 100644
index 1453733..0000000
--- a/polkit-gnome/polkit-gnome-action.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-/***************************************************************************
- *
- * polkit-gnome-action.h :
- *
- * Copyright (C) 2007 David Zeuthen, <david fubar dk>
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- *
- **************************************************************************/
-
-#if !defined (POLKIT_GNOME_COMPILATION) && !defined(_POLKIT_GNOME_INSIDE_POLKIT_GNOME_H)
-#error "Only <polkit-gnome/polkit-gnome.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef __POLKIT_GNOME_ACTION_H__
-#define __POLKIT_GNOME_ACTION_H__
-
-#include <gtk/gtk.h>
-#include <polkit/polkit.h>
-
-G_BEGIN_DECLS
-
-#define POLKIT_GNOME_TYPE_ACTION (polkit_gnome_action_get_type ())
-#define POLKIT_GNOME_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), POLKIT_GNOME_TYPE_ACTION, PolKitGnomeAction))
-#define POLKIT_GNOME_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), POLKIT_GNOME_TYPE_ACTION, PolKitGnomeActionClass))
-#define POLKIT_GNOME_IS_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), POLKIT_GNOME_TYPE_ACTION))
-#define POLKIT_GNOME_IS_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), POLKIT_GNOME_TYPE_ACTION))
-#define POLKIT_GNOME_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), POLKIT_GNOME_TYPE_ACTION, PolKitGnomeActionClass))
-
-typedef struct _PolKitGnomeAction PolKitGnomeAction;
-typedef struct _PolKitGnomeActionPrivate PolKitGnomeActionPrivate;
-typedef struct _PolKitGnomeActionClass PolKitGnomeActionClass;
-
-/**
- * PolKitGnomeAction:
- *
- * The PolKitGnomeAction struct contains only private data members and should not be accessed directly.
- */
-struct _PolKitGnomeAction
-{
- /*< private >*/
- GtkAction parent;
- PolKitGnomeActionPrivate *priv;
-};
-
-struct _PolKitGnomeActionClass
-{
- GtkActionClass parent_class;
-
- /* Signals */
- void (* auth_start) (PolKitGnomeAction *action);
- void (* auth_end) (PolKitGnomeAction *action, gboolean gained_privilege);
- void (* polkit_result_changed) (PolKitGnomeAction *action, PolKitResult current_result);
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
-};
-
-GType polkit_gnome_action_get_type (void) G_GNUC_CONST;
-PolKitGnomeAction *polkit_gnome_action_new (const gchar *name);
-PolKitGnomeAction *polkit_gnome_action_new_default (const gchar *name,
- PolKitAction *polkit_action,
- const gchar *label,
- const gchar *tooltip);
-PolKitResult polkit_gnome_action_get_polkit_result (PolKitGnomeAction *action);
-
-gboolean polkit_gnome_action_get_sensitive (PolKitGnomeAction *action);
-void polkit_gnome_action_set_sensitive (PolKitGnomeAction *action,
- gboolean sensitive);
-
-gboolean polkit_gnome_action_get_visible (PolKitGnomeAction *action);
-void polkit_gnome_action_set_visible (PolKitGnomeAction *action,
- gboolean visible);
-
-GtkWidget *polkit_gnome_action_create_button (PolKitGnomeAction *action);
-
-G_END_DECLS
-
-#endif /* __POLKIT_GNOME_ACTION_H__ */
diff --git a/polkit-gnome/polkit-gnome-auth.c b/polkit-gnome/polkit-gnome-auth.c
deleted file mode 100644
index 956c9fb..0000000
--- a/polkit-gnome/polkit-gnome-auth.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-/***************************************************************************
- *
- * polkit-gnome-auth.c : Show authentication dialogs to gain privileges
- *
- * Copyright (C) 2007 David Zeuthen, <david fubar dk>
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- *
- **************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <fcntl.h>
-
-#include <glib.h>
-#include <glib/gi18n-lib.h>
-#include <glib-object.h>
-
-#include <gtk/gtk.h>
-#include <gdk/gdkx.h>
-
-#define DBUS_API_SUBJECT_TO_CHANGE
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include "polkit-gnome-auth.h"
-
-/**
- * SECTION:polkit-gnome-auth
- * @title: Authentication Dialogs
- * @short_description: Show authentication dialogs to gain privileges
- *
- * Show authentication dialogs to gain privileges.
- *
- **/
-
-
-typedef struct {
- PolKitAction *action;
- PolKitGnomeAuthCB callback;
- gpointer user_data;
-} CallClosure;
-
-static void
-_notify_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
-{
- GError *error;
- CallClosure *c = (CallClosure *) user_data;
- gboolean gained_privilege;
-
- error = NULL;
- if (!dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_BOOLEAN, &gained_privilege, G_TYPE_INVALID)) {
- gained_privilege = FALSE;
- }
-
- /* perform the callback */
- c->callback (c->action, gained_privilege, error, c->user_data);
-
- g_object_unref (proxy);
- polkit_action_unref (c->action);
-}
-
-/**
- * polkit_gnome_auth_obtain:
- * @action: The #PolKitAction to make the user authenticate for
- * @xid: X11 window ID for the window that the dialog will be transient for. If there is no window, pass 0.
- * @pid: Process ID of process to grant authorization to. Normally one wants to pass result of getpid().
- * @callback: Function to call when authentication is done
- * @user_data: Data to pass to the callback function
- * @error: Return location for error
- *
- * Applications can use this function to show a dialog for the user
- * asking her to authenticate in order to gain privileges to do the
- * given action. The authentication, for security reasons, happens in
- * a separate process; this function is merely a wrapper around a
- * D-Bus call across the session message bus to the
- * <literal>org.freedesktop.PolicyKit.AuthenticationAgent</literal>
- * service. Depending on the setup, this may be the Authentication
- * Agent shipped with PolicyKit-gnome or it may be another
- * implementation. For example, if the user is in KDE it may be an
- * Authentication Agent using the Qt toolkit.
- *
- * The Authentication Agent shipped with PolicyKit-gnome is described
- * in <link linkend="ref-auth-daemon">this section</link>.
- *
- * This function is similar to the polkit_auth_obtain() function
- * supplied in <literal>libpolkit-dbus</literal> except that this
- * function is asynchronous.
- *
- * Returns: #TRUE if the authentication session was scheduled to
- * start. #FALSE if error is set (and no callback will be made).
- */
-gboolean
-polkit_gnome_auth_obtain (PolKitAction *action,
- guint xid,
- pid_t pid,
- PolKitGnomeAuthCB callback,
- gpointer user_data,
- GError **error)
-{
- char *polkit_action_id;
- gboolean ret;
- CallClosure *c;
- DBusGConnection *session_bus;
- DBusGProxy *polkit_gnome_proxy;
-
- ret = FALSE;
-
- if ((session_bus = dbus_g_bus_get (DBUS_BUS_SESSION, error)) == NULL) {
- goto error;
- }
-
- /* TODO: this can fail.. */
- polkit_action_get_action_id (action, &polkit_action_id);
-
- polkit_gnome_proxy = dbus_g_proxy_new_for_name (session_bus,
- "org.freedesktop.PolicyKit.AuthenticationAgent", /* bus name */
- "/", /* object */
- "org.freedesktop.PolicyKit.AuthenticationAgent");/* interface */
-
- c = g_new0 (CallClosure, 1);
- c->action = polkit_action_ref (action);
- c->callback = callback;
- c->user_data = user_data;
-
- dbus_g_proxy_begin_call_with_timeout (polkit_gnome_proxy,
- "ObtainAuthorization",
- _notify_callback,
- c,
- g_free,
- INT_MAX,
- /* parameters: */
- G_TYPE_STRING, polkit_action_id, /* action_id */
- G_TYPE_UINT, xid, /* X11 window ID */
- G_TYPE_UINT, pid, /* process id */
- G_TYPE_INVALID);
-
- ret = TRUE;
-error:
- return ret;
-}
-
diff --git a/polkit-gnome/polkit-gnome-auth.h b/polkit-gnome/polkit-gnome-auth.h
deleted file mode 100644
index 6af5fd9..0000000
--- a/polkit-gnome/polkit-gnome-auth.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-/***************************************************************************
- *
- * polkit-gnome-auth.h : Show authentication dialogs to gain privileges
- *
- * Copyright (C) 2007 David Zeuthen, <david fubar dk>
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- *
- **************************************************************************/
-
-#if !defined (POLKIT_GNOME_COMPILATION) && !defined(_POLKIT_GNOME_INSIDE_POLKIT_GNOME_H)
-#error "Only <polkit-gnome/polkit-gnome.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef __POLKIT_GNOME_AUTH_H
-#define __POLKIT_GNOME_AUTH_H
-
-#include <polkit/polkit.h>
-
-/**
- * PolKitGnomeAuthCB:
- * @action: the #PolKitAction passed in polkit_gnome_auth_show_dialog()
- * @gained_privilege: whether the user gained the privilege. Set to
- * #FALSE if error is set. If set to #TRUE, error will not be set.
- * @error: if the call failed, this parameter will be non-#NULL. The
- * callee shall free the error.
- * @user_data: user data
- *
- * The type of the callback function for
- * polkit_gnome_auth_show_dialog().
- */
-typedef void (*PolKitGnomeAuthCB) (PolKitAction *action, gboolean gained_privilege, GError *error, gpointer user_data);
-
-gboolean polkit_gnome_auth_obtain (PolKitAction *action,
- guint xid,
- pid_t pid,
- PolKitGnomeAuthCB callback,
- gpointer user_data,
- GError **error);
-
-#endif /* __POLKIT_GNOME_AUTH_H */
diff --git a/polkit-gnome/polkit-gnome-context.c b/polkit-gnome/polkit-gnome-context.c
deleted file mode 100644
index 4beaf0c..0000000
--- a/polkit-gnome/polkit-gnome-context.c
+++ /dev/null
@@ -1,370 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-/***************************************************************************
- *
- * polkit-gnome-context.c : Convenience functions for using PolicyKit
- * from GTK+ and GNOME applications.
- *
- * Copyright (C) 2007 David Zeuthen, <david fubar dk>
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- *
- **************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <fcntl.h>
-
-#include <glib.h>
-#include <glib/gi18n-lib.h>
-#include <glib-object.h>
-
-#include <gtk/gtk.h>
-#include <gdk/gdkx.h>
-
-#define DBUS_API_SUBJECT_TO_CHANGE
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include <polkit/polkit.h>
-#include <polkit-dbus/polkit-dbus.h>
-
-#include "polkit-gnome-context.h"
-
-/**
- * SECTION:polkit-gnome-context
- * @short_description: Convenience functions for using PolicyKit from GTK+ and GNOME applications.
- *
- * This class provides convenience functions for using PolicyKit from
- * GTK+ and GNOME applications including setting up main loop
- * integration and system bus connections. Rather than using
- * callbacks, GObject signals are provided when external factors
- * change (e.g. the PolicyKit.conf configuration file changes or
- * ConsoleKit reports activity changes).
- *
- * Actual usage of PolicyKit is still through the main PolicyKit API
- * through the public pk_context and pk_tracker variables.
- *
- * This class is implemented as a singleton meaning that several
- * callers will share the underlying #PolKitContext and #PolKitTracker
- * objects. Do not use any of the life cycle methods of these objects;
- * only use them to gather information.
- **/
-
-#define POLKIT_GNOME_CONTEXT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), POLKIT_GNOME_TYPE_CONTEXT, PolKitGnomeContextPrivate))
-
-struct _PolKitGnomeContextPrivate
-{
- DBusGConnection *system_bus;
-};
-
-enum
-{
- CONFIG_CHANGED,
- CONSOLE_KIT_DB_CHANGED,
- LAST_SIGNAL
-};
-
-/* our static singleton instance */
-static PolKitGnomeContext *_singleton = NULL;
-
-G_DEFINE_TYPE (PolKitGnomeContext, polkit_gnome_context, G_TYPE_OBJECT)
-
-static GObjectClass *parent_class = NULL;
-static guint signals[LAST_SIGNAL] = { 0 };
-
-static void
-polkit_gnome_context_init (PolKitGnomeContext *context)
-{
- context->priv = POLKIT_GNOME_CONTEXT_GET_PRIVATE (context);
-}
-
-static void
-polkit_gnome_context_finalize (GObject *object)
-{
- PolKitGnomeContext *context;
-
- context = POLKIT_GNOME_CONTEXT (object);
-
- /* Remove the match rules we added; pass NULL for error so we
- * don't block; we can't really properly handle the error
- * anyway...
- */
- dbus_bus_remove_match (dbus_g_connection_get_connection (_singleton->priv->system_bus),
- "type='signal'"
- ",interface='"DBUS_INTERFACE_DBUS"'"
- ",sender='"DBUS_SERVICE_DBUS"'"
- ",member='NameOwnerChanged'",
- NULL);
- dbus_bus_remove_match (dbus_g_connection_get_connection (_singleton->priv->system_bus),
- "type='signal',sender='org.freedesktop.ConsoleKit'",
- NULL);
-
- if (context->pk_context != NULL) {
- polkit_context_unref (context->pk_context);
- }
-
- if (context->pk_tracker != NULL) {
- polkit_tracker_unref (context->pk_tracker);
- }
-
- _singleton = NULL;
-
- G_OBJECT_CLASS (polkit_gnome_context_parent_class)->finalize (object);
-}
-
-static void
-polkit_gnome_context_class_init (PolKitGnomeContextClass *klass)
-{
- GObjectClass *gobject_class;
-
- parent_class = g_type_class_peek_parent (klass);
- gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->finalize = polkit_gnome_context_finalize;
-
- /**
- * PolKitGnomeContext::config-changed:
- * @context: the object
- *
- * The ::config-changed signal is emitted when PolicyKit
- * configuration (e.g. /etc/PolicyKit/PolicyKit.conf or
- * .policy files) changes content.
- *
- * As this is one contributing factor to what answer PolicyKit
- * will return, the caller should act on this signal and query
- * PolicyKit for any actions it cares about.
- **/
- signals [CONFIG_CHANGED] =
- g_signal_new ("config-changed",
- G_TYPE_FROM_CLASS (gobject_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PolKitGnomeContextClass, config_changed),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- /**
- * PolKitGnomeContext::console-kit-db-changed:
- * @context: the object
- *
- * The ::console-kit-db-changed signal is emitted when
- * ConsoleKit configuration changes; e.g. when a session
- * becomes active or inactive.
- *
- * As this is one contributing factor to what answer PolicyKit
- * will return, the caller should act on this signal and query
- * PolicyKit for any actions it cares about.
- **/
- signals [CONSOLE_KIT_DB_CHANGED] =
- g_signal_new ("console-kit-db-changed",
- G_TYPE_FROM_CLASS (gobject_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PolKitGnomeContextClass, console_kit_db_changed),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- g_type_class_add_private (gobject_class, sizeof (PolKitGnomeContextPrivate));
-}
-
-
-static gboolean
-io_watch_have_data (GIOChannel *channel, GIOCondition condition, gpointer user_data)
-{
- int fd;
- PolKitContext *pk_context = user_data;
- fd = g_io_channel_unix_get_fd (channel);
- polkit_context_io_func (pk_context, fd);
- return TRUE;
-}
-
-static int
-io_add_watch (PolKitContext *pk_context, int fd)
-{
- guint id = 0;
- GIOChannel *channel;
- channel = g_io_channel_unix_new (fd);
- if (channel == NULL)
- goto out;
- id = g_io_add_watch (channel, G_IO_IN, io_watch_have_data, pk_context);
- if (id == 0) {
- g_io_channel_unref (channel);
- goto out;
- }
- g_io_channel_unref (channel);
-out:
- return id;
-}
-
-static void
-io_remove_watch (PolKitContext *pk_context, int watch_id)
-{
- g_source_remove (watch_id);
-}
-
-
-static void
-pk_config_changed (PolKitContext *pk_context, void *user_data)
-{
- PolKitGnomeContext *context = POLKIT_GNOME_CONTEXT (user_data);
-
- /* g_debug ("ggg PolicyKit config changed"); */
- g_signal_emit (context, signals [CONFIG_CHANGED], 0);
-}
-
-
-static DBusHandlerResult
-_filter (DBusConnection *connection, DBusMessage *message, void *user_data)
-{
- PolKitGnomeContext *context = POLKIT_GNOME_CONTEXT (user_data);
-
- /* pass NameOwnerChanged signals from the bus and ConsoleKit to PolKitTracker */
- if (dbus_message_is_signal (message, DBUS_INTERFACE_DBUS, "NameOwnerChanged") ||
- (dbus_message_get_interface (message) != NULL &&
- g_str_has_prefix (dbus_message_get_interface (message), "org.freedesktop.ConsoleKit"))) {
- if (polkit_tracker_dbus_func (context->pk_tracker, message)) {
- /* The ConsoleKit database has changed */
- /* g_debug ("ggg ConsoleKit database changed"); */
- g_signal_emit (context, signals [CONSOLE_KIT_DB_CHANGED], 0);
- }
- }
-
- /* other filters might want to process this message too */
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-}
-
-/**
- * polkit_gnome_context_get:
- * @error: return location for error
- *
- * Returns a #PolKitGnomeContext object. The context is a global
- * singleton that may be shared with other callers of this function.
- *
- * This operation can fail if the system message bus is not available.
- *
- * When done with using this object, call g_object_unref(). This is
- * such that resources can be freed when all callers have unreffed it.
- *
- * Returns: a new #PolKitGnomeContext or NULL if error is set
- */
-PolKitGnomeContext *
-polkit_gnome_context_get (GError **error)
-{
- DBusError dbus_error;
- PolKitError *pk_error;
-
- if (_singleton != NULL)
- return g_object_ref (_singleton);
-
- /* g_debug ("Constructing singleton"); */
-
- _singleton = g_object_new (POLKIT_GNOME_TYPE_CONTEXT, NULL);
-
- if ((_singleton->priv->system_bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, error)) == NULL) {
- goto error;
- }
-
- _singleton->pk_context = polkit_context_new ();
- polkit_context_set_io_watch_functions (_singleton->pk_context, io_add_watch, io_remove_watch);
- polkit_context_set_config_changed (_singleton->pk_context, pk_config_changed, _singleton);
-
- pk_error = NULL;
- if (!polkit_context_init (_singleton->pk_context, &pk_error)) {
- g_warning ("Failed to initialize PolicyKit context: %s", polkit_error_get_error_message (pk_error));
- if (error != NULL) {
- *error = g_error_new_literal (POLKIT_GNOME_CONTEXT_ERROR,
- POLKIT_GNOME_CONTEXT_ERROR_FAILED,
- polkit_error_get_error_message (pk_error));
- }
- polkit_error_free (pk_error);
- goto error;
- }
-
- /* TODO FIXME: I'm pretty sure dbus-glib blows in a way that
- * we can't say we're interested in all signals from all
- * members on all interfaces for a given service... So we do
- * this..
- */
-
- dbus_error_init (&dbus_error);
-
- /* need to listen to NameOwnerChanged */
- dbus_bus_add_match (dbus_g_connection_get_connection (_singleton->priv->system_bus),
- "type='signal'"
- ",interface='"DBUS_INTERFACE_DBUS"'"
- ",sender='"DBUS_SERVICE_DBUS"'"
- ",member='NameOwnerChanged'",
- &dbus_error);
-
- if (dbus_error_is_set (&dbus_error)) {
- dbus_set_g_error (error, &dbus_error);
- dbus_error_free (&dbus_error);
- goto error;
- }
-
- /* need to listen to ConsoleKit signals */
- dbus_bus_add_match (dbus_g_connection_get_connection (_singleton->priv->system_bus),
- "type='signal',sender='org.freedesktop.ConsoleKit'",
- &dbus_error);
-
- if (dbus_error_is_set (&dbus_error)) {
- dbus_set_g_error (error, &dbus_error);
- dbus_error_free (&dbus_error);
- goto error;
- }
-
- if (!dbus_connection_add_filter (dbus_g_connection_get_connection (_singleton->priv->system_bus),
- _filter,
- _singleton,
- NULL)) {
- *error = g_error_new_literal (POLKIT_GNOME_CONTEXT_ERROR,
- POLKIT_GNOME_CONTEXT_ERROR_FAILED,
- "Cannot add D-Bus filter");
- goto error;
- }
-
- _singleton->pk_tracker = polkit_tracker_new ();
- polkit_tracker_set_system_bus_connection (_singleton->pk_tracker,
- dbus_g_connection_get_connection (_singleton->priv->system_bus));
- polkit_tracker_init (_singleton->pk_tracker);
-
- return _singleton;
-
-error:
- g_object_unref (_singleton);
- return NULL;
-}
-
-GQuark
-polkit_gnome_context_error_quark (void)
-{
- return g_quark_from_static_string ("polkit-gnome-context-error-quark");
-}
diff --git a/polkit-gnome/polkit-gnome-context.h b/polkit-gnome/polkit-gnome-context.h
deleted file mode 100644
index 07d63ee..0000000
--- a/polkit-gnome/polkit-gnome-context.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-/***************************************************************************
- *
- * polkit-gnome-context.h : Convenience functions for using PolicyKit
- * from GTK+ and GNOME applications.
- *
- * Copyright (C) 2007 David Zeuthen, <david fubar dk>
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- *
- **************************************************************************/
-
-#if !defined (POLKIT_GNOME_COMPILATION) && !defined(_POLKIT_GNOME_INSIDE_POLKIT_GNOME_H)
-#error "Only <polkit-gnome/polkit-gnome.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef __POLKIT_GNOME_CONTEXT_H__
-#define __POLKIT_GNOME_CONTEXT_H__
-
-#include <glib-object.h>
-#include <polkit-dbus/polkit-dbus.h>
-
-G_BEGIN_DECLS
-
-#define POLKIT_GNOME_TYPE_CONTEXT (polkit_gnome_context_get_type ())
-#define POLKIT_GNOME_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), POLKIT_GNOME_TYPE_CONTEXT, PolKitGnomeContext))
-#define POLKIT_GNOME_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), POLKIT_GNOME_TYPE_CONTEXT, PolKitGnomeContextClass))
-#define POLKIT_GNOME_IS_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), POLKIT_GNOME_TYPE_CONTEXT))
-#define POLKIT_GNOME_IS_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), POLKIT_GNOME_TYPE_CONTEXT))
-#define POLKIT_GNOME_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), POLKIT_GNOME_TYPE_CONTEXT, PolKitGnomeContextClass))
-
-/**
- * POLKIT_GNOME_CONTEXT_ERROR:
- *
- * Error domain for using the GNOME PolicyKit context. Errors in this
- * domain will be from the #PolKitGnomeContextError enumeration. See
- * #GError for information on error domains.
- */
-#define POLKIT_GNOME_CONTEXT_ERROR polkit_gnome_context_error_quark ()
-
-/**
- * PolKitGnomeContextError:
- * @POLKIT_GNOME_CONTEXT_ERROR_FAILED: General error
- *
- * Error codes describing how #PolKitGnomeContext can fail.
- */
-typedef enum
-{
- POLKIT_GNOME_CONTEXT_ERROR_FAILED
-} PolKitGnomeContextError;
-
-
-typedef struct _PolKitGnomeContext PolKitGnomeContext;
-typedef struct _PolKitGnomeContextPrivate PolKitGnomeContextPrivate;
-typedef struct _PolKitGnomeContextClass PolKitGnomeContextClass;
-
-/**
- * PolKitGnomeContext:
- * @pk_context: for interfacing with PolicyKit; e.g. typically polkit_context_can_caller_do_action()
- * @pk_tracker: this is used for effieciently obtaining #PolKitCaller objects
- *
- * Provide access to #PolKitContext and #PolKitTracker instances
- * shared among many callers.
- */
-struct _PolKitGnomeContext
-{
- /*< private >*/
- GObject parent;
-
- PolKitGnomeContextPrivate *priv;
-
- /*< public >*/
- PolKitContext *pk_context;
- PolKitTracker *pk_tracker;
-};
-
-struct _PolKitGnomeContextClass
-{
- GObjectClass parent_class;
-
- void (* config_changed) (PolKitGnomeContext *context);
- void (* console_kit_db_changed) (PolKitGnomeContext *context);
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
-};
-
-GType polkit_gnome_context_get_type (void) G_GNUC_CONST;
-PolKitGnomeContext *polkit_gnome_context_get (GError **error);
-
-GQuark polkit_gnome_context_error_quark (void);
-
-G_END_DECLS
-
-#endif /* __POLKIT_GNOME_CONTEXT_H__ */
diff --git a/polkit-gnome/polkit-gnome-toggle-action.c b/polkit-gnome/polkit-gnome-toggle-action.c
deleted file mode 100644
index 78bc8d3..0000000
--- a/polkit-gnome/polkit-gnome-toggle-action.c
+++ /dev/null
@@ -1,929 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-/***************************************************************************
- *
- * polkit-gnome-toggle-action.c :
- *
- * Copyright (C) 2007 David Zeuthen, <david fubar dk>
- *
- * Based loosely on gtk/gtktoggleaction.c from GTK+ written by James
- * Henstridge <james daa com au>.
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- *
- **************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <fcntl.h>
-
-#include <glib.h>
-#include <glib/gi18n-lib.h>
-#include <glib-object.h>
-
-#include <gtk/gtk.h>
-#include <gdk/gdkx.h>
-
-#define DBUS_API_SUBJECT_TO_CHANGE
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include <polkit/polkit.h>
-#include <polkit-dbus/polkit-dbus.h>
-
-#include "polkit-gnome-toggle-action.h"
-
-/**
- * SECTION:polkit-gnome-toggle-action
- * @short_description: A GtkAction that can be toggled to
- * obtain and give up PolicyKit authorizations.
- *
- * For an example of how to use this class, see the documentation for
- * #PolKitGnomeAction.
- **/
-
-#define POLKIT_GNOME_TOGGLE_ACTION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), POLKIT_GNOME_TYPE_TOGGLE_ACTION, PolKitGnomeToggleActionPrivate))
-
-struct _PolKitGnomeToggleActionPrivate
-{
- gboolean active;
- gboolean am_authenticating;
-
- gboolean auth_underway_visible;
- gboolean auth_underway_sensitive;
- gchar *auth_underway_short_label;
- gchar *auth_underway_label;
- gchar *auth_underway_tooltip;
- gchar *auth_underway_icon_name;
-};
-
-enum
-{
- TOGGLED_SIGNAL,
- LAST_SIGNAL
-};
-
-enum
-{
- PROP_0,
- PROP_POLKIT_AUTH_UNDERWAY_VISIBLE,
- PROP_POLKIT_AUTH_UNDERWAY_SENSITIVE,
- PROP_POLKIT_AUTH_UNDERWAY_SHORT_LABEL,
- PROP_POLKIT_AUTH_UNDERWAY_LABEL,
- PROP_POLKIT_AUTH_UNDERWAY_TOOLTIP,
- PROP_POLKIT_AUTH_UNDERWAY_ICON_NAME,
-};
-
-G_DEFINE_TYPE (PolKitGnomeToggleAction, polkit_gnome_toggle_action, POLKIT_GNOME_TYPE_ACTION)
-
-static void set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-static GObjectClass *parent_class = NULL;
-static guint signals[LAST_SIGNAL] = { 0 };
-
-static void
-polkit_gnome_toggle_action_init (PolKitGnomeToggleAction *toggle_action)
-{
- toggle_action->priv = POLKIT_GNOME_TOGGLE_ACTION_GET_PRIVATE (toggle_action);
-
-}
-
-static void
-polkit_gnome_toggle_action_finalize (GObject *object)
-{
- PolKitGnomeToggleAction *toggle_action;
-
- toggle_action = POLKIT_GNOME_TOGGLE_ACTION (object);
-
- G_OBJECT_CLASS (polkit_gnome_toggle_action_parent_class)->finalize (object);
-}
-
-static GObject *
-polkit_gnome_toggle_action_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
-{
- PolKitGnomeToggleAction *toggle_action;
- PolKitGnomeToggleActionClass *klass;
-
- klass = POLKIT_GNOME_TOGGLE_ACTION_CLASS (g_type_class_peek (POLKIT_GNOME_TYPE_TOGGLE_ACTION));
-
- toggle_action = POLKIT_GNOME_TOGGLE_ACTION (G_OBJECT_CLASS (parent_class)->constructor (type,
- n_construct_properties,
- construct_properties));
-
- if (polkit_gnome_action_get_polkit_result (POLKIT_GNOME_ACTION (toggle_action)) == POLKIT_RESULT_YES)
- toggle_action->priv->active = TRUE;
- else
- toggle_action->priv->active = FALSE;
-
- return G_OBJECT (toggle_action);
-}
-
-static void polkit_gnome_toggle_action_auth_end (PolKitGnomeToggleAction *toggle_action, gboolean gained_privilege);
-static void polkit_gnome_toggle_polkit_result_changed (PolKitGnomeToggleAction *toggle_action, PolKitResult current_result);
-static void polkit_gnome_toggle_action_activate (PolKitGnomeToggleAction *toggle_action);
-static void polkit_gnome_toggle_action_real_toggled (PolKitGnomeToggleAction *action);
-static void connect_proxy (GtkAction *action,
- GtkWidget *proxy);
-static void disconnect_proxy (GtkAction *action,
- GtkWidget *proxy);
-
-
-static void
-polkit_gnome_toggle_action_class_init (PolKitGnomeToggleActionClass *klass)
-{
- GObjectClass *gobject_class;
- GtkActionClass *action_class;
- PolKitGnomeActionClass *polkit_gnome_action_class;
-
- parent_class = g_type_class_peek_parent (klass);
- gobject_class = G_OBJECT_CLASS (klass);
- action_class = GTK_ACTION_CLASS (klass);
- polkit_gnome_action_class = POLKIT_GNOME_ACTION_CLASS (klass);
-
- gobject_class->constructor = polkit_gnome_toggle_action_constructor;
- gobject_class->set_property = set_property;
- gobject_class->get_property = get_property;
- gobject_class->finalize = polkit_gnome_toggle_action_finalize;
-
- action_class->menu_item_type = GTK_TYPE_CHECK_MENU_ITEM;
- action_class->toolbar_item_type = GTK_TYPE_TOGGLE_TOOL_BUTTON;
-
- action_class->connect_proxy = connect_proxy;
- action_class->disconnect_proxy = disconnect_proxy;
-
- klass->toggled = polkit_gnome_toggle_action_real_toggled;
-
- action_class->activate = (void (*)(GtkAction*)) polkit_gnome_toggle_action_activate;
-
- polkit_gnome_action_class->auth_end =
- (void (*)(PolKitGnomeAction *, gboolean)) polkit_gnome_toggle_action_auth_end;
-
- polkit_gnome_action_class->polkit_result_changed =
- (void (*) (PolKitGnomeAction *, PolKitResult)) polkit_gnome_toggle_polkit_result_changed;
-
- /*------------------------------*/
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_AUTH_UNDERWAY_VISIBLE,
- g_param_spec_boolean (
- "auth-underway-visible",
- "When authentication is underway, whether the action will be visible",
- "When authentication is underway, whether the action will be visible",
- TRUE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_AUTH_UNDERWAY_SENSITIVE,
- g_param_spec_boolean (
- "auth-underway-sensitive",
- "When authentication is underway, whether the action will be sensitive",
- "When authentication is underway, whether the action will be sensitive",
- TRUE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_AUTH_UNDERWAY_SHORT_LABEL,
- g_param_spec_string (
- "auth-underway-short-label",
- "When authentication is underway, use this short-label",
- "When authentication is underway, use this short-label",
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_AUTH_UNDERWAY_LABEL,
- g_param_spec_string (
- "auth-underway-label",
- "When authentication is underway, use this label",
- "When authentication is underway, use this label",
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_AUTH_UNDERWAY_TOOLTIP,
- g_param_spec_string (
- "auth-underway-tooltip",
- "When authentication is underway, use this tooltip",
- "When authentication is underway, use this tooltip",
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_POLKIT_AUTH_UNDERWAY_ICON_NAME,
- g_param_spec_string (
- "auth-underway-icon-name",
- "When authentication is underway, use this icon-name",
- "When authentication is underway, use this icon-name",
- NULL,
- G_PARAM_READWRITE));
-
- /*------------------------------*/
-
-
- /**
- * PolKitGnomeToggleAction::toggled:
- * @toggle_action: the object
- *
- * The ::toggled signal is emitted when the button is toggled.
- **/
- signals [TOGGLED_SIGNAL] =
- g_signal_new ("toggled",
- G_TYPE_FROM_CLASS (gobject_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PolKitGnomeToggleActionClass, toggled),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- g_type_class_add_private (gobject_class, sizeof (PolKitGnomeToggleActionPrivate));
-}
-
-
-/**
- * polkit_gnome_toggle_action_new:
- * @name: A unique name for the toggle_action
- * @error: Return location for error
- *
- * Creates a new #PolKitGnomeToggleAction object. The typical use for
- * this function is for specialized use where
- * polkit_gnome_toggle_action_new_default() does not meet the needs of
- * the application.
- *
- * If the 'polkit-toggle_action' property is #NULL the behavior is similar to
- * as if a #PolKitAction returned #POLKIT_RESULT_YES.
- *
- * Returns: a new #PolKitGnomeToggleAction or #NULL if error is set
- */
-PolKitGnomeToggleAction *
-polkit_gnome_toggle_action_new (const gchar *name)
-{
- PolKitGnomeToggleAction *toggle_action = NULL;
-
- toggle_action = g_object_new (POLKIT_GNOME_TYPE_TOGGLE_ACTION,
- "name", name,
- NULL);
- return toggle_action;
-}
-
-/**
- * polkit_gnome_toggle_action_new_default:
- * @name: A unique name for the toggle_action
- * @polkit_action: the #PolKitAction to track
- * @locked_label: The label to show when the user do not possess the
- * authorization, e.g. "Click to make changes"
- * @unlocked_label: The label to show when the user does posses the
- * authorization; e.g. "Click to prevent changes"
- *
- * Creates a new #PolKitGnomeToggleAction object with the default
- * behavior for a given #PolKitAction object. The toggle represents
- * whether the user is authorized for the given #PolKitAction. If the
- * user is not authorized, clicking on a proxy widget (if it's
- * sensitive) will cause an authentication dialog to appear. If the
- * user is authorized, clicking on a proxy widget will cause all
- * authorizations to be given up (aka revoked). The ::toggled signal
- * is only emitted when such transitions occur. Thus, the user of this
- * class will never have to deal with bringing up authentication
- * dialogs; it's all handled behind the scenes.
- *
- * As such, the typical use case for this action is an UI where the
- * user is encouraged to give up authorizations.
- *
- * There's also support for the corner case where the user is
- * authorized because of implicit authorizations. In this case,
- * toggling the action will "grant" a negative authorization for the
- * user. By toggling the action again, the negative authorization will
- * be revoked.
- *
- * Default behavior is defined as having the icon_name be 'security-medium'
- * by default except for the YES PolicyKit answer where it's set to
- * 'security-low'. No tooltips are set. The label and short-label
- * will be 'locked_label' everywhere except in the YES state where
- * it's set to 'unlocked-label'. When authentication is underway, the
- * label will be "Authenticating..." and icon_name is untouched. If
- * the PolicyKit answer is NO, sensitivity is set to
- * #FALSE. Visibility is always set to #TRUE.
- *
- * The caller can always modify individual aspects of the
- * toggle_action after creation, e.g. change the tooltip for the no,
- * auth and yes states; see the parent class #PolKitGnomeAction. In
- * addition to the properties in the parent class, this subclass
- * sports six new properties, "auth-underway-*" to control the look
- * of proxy widgets when authentication is underway.
- *
- * If the given polkit_toggle_action is #NULL the behavior is similar to as
- * if a #PolKitAction returned #POLKIT_RESULT_YES.
- *
- * Returns: a new #PolKitGnomeToggleAction or #NULL if error is set
- */
-PolKitGnomeToggleAction *
-polkit_gnome_toggle_action_new_default (const gchar *name,
- PolKitAction *polkit_action,
- const gchar *locked_label,
- const gchar *unlocked_label)
-{
- PolKitGnomeToggleAction *toggle_action;
-
- toggle_action = g_object_new (POLKIT_GNOME_TYPE_TOGGLE_ACTION,
- "name", name,
- "polkit-action", polkit_action,
-
- "self-blocked-visible", TRUE,
- "self-blocked-sensitive", TRUE,
- "self-blocked-short-label", locked_label,
- "self-blocked-label", locked_label,
- "self-blocked-tooltip", NULL,
- "self-blocked-icon-name", "security-medium",
-
- "no-visible", TRUE,
- "no-sensitive", FALSE,
- "no-short-label", locked_label,
- "no-label", locked_label,
- "no-tooltip", NULL,
- "no-icon-name", "security-medium",
-
- "auth-visible", TRUE,
- "auth-sensitive", TRUE,
- "auth-short-label", locked_label,
- "auth-label", locked_label,
- "auth-tooltip", NULL,
- "auth-icon-name", "security-medium",
-
- "yes-visible", TRUE,
- "yes-sensitive", TRUE,
- "yes-short-label", unlocked_label,
- "yes-label", unlocked_label,
- "yes-tooltip", NULL,
- "yes-icon-name", "security-low",
-
- "auth-underway-visible", TRUE,
- "auth-underway-sensitive", TRUE,
- "auth-underway-short-label", _("Authenticating..."),
- "auth-underway-label", _("Authenticating..."),
- "auth-underway-tooltip", NULL,
- "auth-underway-icon-name", "security-medium",
-
- "master-visible", TRUE,
- "master-sensitive", TRUE,
- NULL);
- return toggle_action;
-}
-
-/*---------------------------------------------------------------------------------security-medium-------------------*/
-
-static void
-polkit_gnome_toggle_action_set_auth_underway_visible (PolKitGnomeToggleAction *action, gboolean visible)
-{
- action->priv->auth_underway_visible = visible;
-}
-
-static void
-polkit_gnome_toggle_action_set_auth_underway_sensitive (PolKitGnomeToggleAction *action, gboolean sensitive)
-{
- action->priv->auth_underway_sensitive = sensitive;
-}
-
-static void
-polkit_gnome_toggle_action_set_auth_underway_short_label (PolKitGnomeToggleAction *action, const gchar *short_label)
-{
- g_free (action->priv->auth_underway_short_label);
- action->priv->auth_underway_short_label = g_strdup (short_label);
-}
-
-static void
-polkit_gnome_toggle_action_set_auth_underway_label (PolKitGnomeToggleAction *action, const gchar *label)
-{
- g_free (action->priv->auth_underway_label);
- action->priv->auth_underway_label = g_strdup (label);
-}
-
-static void
-polkit_gnome_toggle_action_set_auth_underway_tooltip (PolKitGnomeToggleAction *action, const gchar *tooltip)
-{
- g_free (action->priv->auth_underway_tooltip);
- action->priv->auth_underway_tooltip = g_strdup (tooltip);
-}
-
-static void
-polkit_gnome_toggle_action_set_auth_underway_icon_name (PolKitGnomeToggleAction *action, const gchar *icon_name)
-{
- g_free (action->priv->auth_underway_icon_name);
- action->priv->auth_underway_icon_name = g_strdup (icon_name);
-}
-
-static void
-get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- PolKitGnomeToggleAction *action = POLKIT_GNOME_TOGGLE_ACTION (object);
-
- switch (prop_id)
- {
-
- case PROP_POLKIT_AUTH_UNDERWAY_VISIBLE:
- g_value_set_boolean (value, action->priv->auth_underway_visible);
- break;
- case PROP_POLKIT_AUTH_UNDERWAY_SENSITIVE:
- g_value_set_boolean (value, action->priv->auth_underway_sensitive);
- break;
- case PROP_POLKIT_AUTH_UNDERWAY_SHORT_LABEL:
- g_value_set_string (value, action->priv->auth_underway_short_label);
- break;
- case PROP_POLKIT_AUTH_UNDERWAY_LABEL:
- g_value_set_string (value, action->priv->auth_underway_label);
- break;
- case PROP_POLKIT_AUTH_UNDERWAY_TOOLTIP:
- g_value_set_string (value, action->priv->auth_underway_tooltip);
- break;
- case PROP_POLKIT_AUTH_UNDERWAY_ICON_NAME:
- g_value_set_string (value, action->priv->auth_underway_icon_name);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- PolKitGnomeToggleAction *action = POLKIT_GNOME_TOGGLE_ACTION (object);
-
- switch (prop_id)
- {
-
- case PROP_POLKIT_AUTH_UNDERWAY_VISIBLE:
- polkit_gnome_toggle_action_set_auth_underway_visible (action, g_value_get_boolean (value));
- break;
- case PROP_POLKIT_AUTH_UNDERWAY_SENSITIVE:
- polkit_gnome_toggle_action_set_auth_underway_sensitive (action, g_value_get_boolean (value));
- break;
- case PROP_POLKIT_AUTH_UNDERWAY_SHORT_LABEL:
- polkit_gnome_toggle_action_set_auth_underway_short_label (action, g_value_get_string (value));
- break;
- case PROP_POLKIT_AUTH_UNDERWAY_LABEL:
- polkit_gnome_toggle_action_set_auth_underway_label (action, g_value_get_string (value));
- break;
- case PROP_POLKIT_AUTH_UNDERWAY_TOOLTIP:
- polkit_gnome_toggle_action_set_auth_underway_tooltip (action, g_value_get_string (value));
- break;
- case PROP_POLKIT_AUTH_UNDERWAY_ICON_NAME:
- polkit_gnome_toggle_action_set_auth_underway_icon_name (action, g_value_get_string (value));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-_set_proxy_state (PolKitGnomeToggleAction *toggle_action)
-{
- GSList *i;
-
- for (i = gtk_action_get_proxies (GTK_ACTION (toggle_action)); i; i = i->next) {
- GtkWidget *proxy = i->data;
-
- gtk_action_block_activate_from (GTK_ACTION (toggle_action), proxy);
- if (GTK_IS_CHECK_MENU_ITEM (proxy))
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (proxy),
- toggle_action->priv->active);
- else if (GTK_IS_TOGGLE_TOOL_BUTTON (proxy))
- gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (proxy),
- toggle_action->priv->active);
- else if (GTK_IS_TOGGLE_BUTTON (proxy))
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (proxy),
- toggle_action->priv->active);
- else {
- g_warning ("Don't know how to toggle `%s' widgets",
- G_OBJECT_TYPE_NAME (proxy));
- }
- gtk_action_unblock_activate_from (GTK_ACTION (toggle_action), proxy);
- }
-}
-
-static void
-_update_toggled (PolKitGnomeToggleAction *toggle_action)
-{
- gboolean is_active;
-
- g_return_if_fail (POLKIT_GNOME_IS_TOGGLE_ACTION (toggle_action));
-
- if (polkit_gnome_action_get_polkit_result (POLKIT_GNOME_ACTION (toggle_action)) == POLKIT_RESULT_YES)
- is_active = TRUE;
- else
- is_active = FALSE;
-
- if (toggle_action->priv->active != is_active) {
- toggle_action->priv->active = is_active;
-
- _set_proxy_state (toggle_action);
-
- g_signal_emit (toggle_action, signals[TOGGLED_SIGNAL], 0);
- }
-}
-
-static void
-polkit_gnome_toggle_polkit_result_changed (PolKitGnomeToggleAction *toggle_action, PolKitResult current_result)
-{
- _update_toggled (toggle_action);
-}
-
-static void
-polkit_gnome_toggle_action_auth_end (PolKitGnomeToggleAction *toggle_action, gboolean gained_privilege)
-{
- _update_toggled (toggle_action);
- toggle_action->priv->am_authenticating = FALSE;
-}
-
-static polkit_bool_t
-_auth_foreach_revoke (PolKitAuthorizationDB *authdb,
- PolKitAuthorization *auth,
- void *user_data)
-{
- PolKitError *pk_error;
- int *num_auths_revoked = (int *) user_data;
-
- pk_error = NULL;
- if (!polkit_authorization_db_revoke_entry (authdb, auth, &pk_error)) {
- g_warning ("Error revoking authorization: %s: %s\n",
- polkit_error_get_error_name (pk_error),
- polkit_error_get_error_message (pk_error));
- polkit_error_free (pk_error);
- }
-
- if (num_auths_revoked != NULL)
- *num_auths_revoked += 1;
-
- return FALSE;
-}
-
-static void
-polkit_gnome_toggle_action_activate (PolKitGnomeToggleAction *toggle_action)
-{
- PolKitError *pk_error;
- PolKitAction *pk_action;
- PolKitGnomeContext *pkgc;
- PolKitAuthorizationDB *authdb;
- PolKitResult pk_result;
- polkit_bool_t do_not_grant_negative;
-
- pkgc = polkit_gnome_context_get (NULL);
- authdb = polkit_context_get_authorization_db (pkgc->pk_context);
-
- pk_action = NULL;
- g_object_get (toggle_action, "polkit-action", &pk_action, NULL);
-
- g_return_if_fail (POLKIT_GNOME_IS_TOGGLE_ACTION (toggle_action));
-
- pk_result = polkit_gnome_action_get_polkit_result (POLKIT_GNOME_ACTION (toggle_action));
-
- do_not_grant_negative = FALSE;
-reevaluate:
-
- switch (pk_result) {
- case POLKIT_RESULT_YES:
-
- if (!toggle_action->priv->am_authenticating) {
- /* If we already got the authorization.. revoke it! */
-
- if (pk_action != NULL && authdb != NULL) {
- int num_auths_revoked;
-
- pk_error = NULL;
- num_auths_revoked = 0;
- polkit_authorization_db_foreach_for_action_for_uid (authdb,
- pk_action,
- getuid (),
- _auth_foreach_revoke,
- &num_auths_revoked,
- &pk_error);
- if (pk_error != NULL) {
- g_warning ("Error removing authorizations: code=%d: %s",
- polkit_error_get_error_code (pk_error),
- polkit_error_get_error_message (pk_error));
- polkit_error_free (pk_error);
- }
-
- if (pk_error == NULL && num_auths_revoked == 0 && !do_not_grant_negative) {
- /* no authorizations, yet we are authorized.. "grant" a
- * negative authorization...
- */
-
- if (!polkit_authorization_db_grant_negative_to_uid (
- authdb,
- pk_action,
- getuid (),
- NULL, /* no constraints */
- &pk_error)) {
- g_warning ("Error granting negative auth: %s: %s\n",
- polkit_error_get_error_name (pk_error),
- polkit_error_get_error_message (pk_error));
- polkit_error_free (pk_error);
- }
- }
-
- }
-
- _update_toggled (toggle_action);
- }
- break;
-
- case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_ONE_SHOT:
- case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH:
- case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_SESSION:
- case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_ALWAYS:
- case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_ONE_SHOT:
- case POLKIT_RESULT_ONLY_VIA_SELF_AUTH:
- case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION:
- case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS:
-
- g_signal_stop_emission_by_name (toggle_action, "activate");
-
- if (pk_action != NULL) {
- toggle_action->priv->am_authenticating = TRUE;
-
- g_object_set (
- toggle_action,
- "visible", toggle_action->priv->auth_underway_visible &&
- polkit_gnome_action_get_visible (POLKIT_GNOME_ACTION (toggle_action)),
- "sensitive", toggle_action->priv->auth_underway_sensitive &&
- polkit_gnome_action_get_sensitive (POLKIT_GNOME_ACTION (toggle_action)),
- "short-label", toggle_action->priv->auth_underway_short_label,
- "label", toggle_action->priv->auth_underway_label,
- "tooltip", toggle_action->priv->auth_underway_tooltip,
- "icon-name", toggle_action->priv->auth_underway_icon_name,
- NULL);
-
- g_signal_emit_by_name (toggle_action, "auth-start", 0);
- }
- break;
-
- default:
- case POLKIT_RESULT_NO:
- if (pk_action != NULL && authdb != NULL) {
- if (polkit_authorization_db_is_uid_blocked_by_self (authdb,
- pk_action,
- getuid (),
- NULL)) {
- int num_auths_revoked;
-
- /* block granted by self.. revoke it then.. */
- pk_error = NULL;
- num_auths_revoked = 0;
- polkit_authorization_db_foreach_for_action_for_uid (authdb,
- pk_action,
- getuid (),
- _auth_foreach_revoke,
- &num_auths_revoked,
- &pk_error);
- if (pk_error != NULL) {
- g_warning ("Error removing authorizations: code=%d: %s",
- polkit_error_get_error_code (pk_error),
- polkit_error_get_error_message (pk_error));
- polkit_error_free (pk_error);
- }
-
- if (pk_error == NULL && num_auths_revoked > 0) {
- PolKitResult pk_result_new;
-
- /* we managed to revoke something... so with this change the
- * result should now change to AUTH_*... so go ahead and just
- * reevaluate the result... also remember to avoid granting
- * another negative auth!
- */
-
- polkit_context_force_reload (pkgc->pk_context);
- pk_result_new = polkit_gnome_action_get_polkit_result (POLKIT_GNOME_ACTION (toggle_action));
- if (pk_result_new != pk_result) {
- pk_result = pk_result_new;
- do_not_grant_negative = TRUE;
- goto reevaluate;
- }
-
- }
-
- }
- }
-
- /* If PolicyKit says no... and we got here.. it means
- * that the user set the property "no-sensitive" to
- * TRUE.. Otherwise we couldn't be handling this signal.
- *
- * Hence, they probably have a good reason for doing
- * this so do let the 'activate' signal propagate..
- */
- break;
- }
-
- _set_proxy_state (toggle_action);
-
- if (pk_action != NULL)
- polkit_action_unref (pk_action);
-}
-
-static void
-polkit_gnome_toggle_action_real_toggled (PolKitGnomeToggleAction *action)
-{
- GSList *i;
-
- g_return_if_fail (POLKIT_GNOME_IS_TOGGLE_ACTION (action));
-
- for (i = gtk_action_get_proxies (GTK_ACTION (action)); i; i = i->next) {
- GtkWidget *proxy = i->data;
-
- gtk_action_block_activate_from (GTK_ACTION (action), proxy);
- if (GTK_IS_CHECK_MENU_ITEM (proxy))
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (proxy),
- action->priv->active);
- else if (GTK_IS_TOGGLE_TOOL_BUTTON (proxy))
- gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (proxy),
- action->priv->active);
- else if (GTK_IS_TOGGLE_BUTTON (proxy))
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (proxy),
- action->priv->active);
- else {
- g_warning ("Don't know how to toggle `%s' widgets",
- G_OBJECT_TYPE_NAME (proxy));
- }
- gtk_action_unblock_activate_from (GTK_ACTION (action), proxy);
- }
-}
-
-static void
-connect_proxy (GtkAction *action, GtkWidget *proxy)
-{
- PolKitGnomeToggleAction *toggle_action;
-
- toggle_action = POLKIT_GNOME_TOGGLE_ACTION (action);
-
- /* do this before hand, so that we don't call the "activate" handler */
- if (GTK_IS_CHECK_MENU_ITEM (proxy))
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (proxy),
- toggle_action->priv->active);
- else if (GTK_IS_TOGGLE_TOOL_BUTTON (proxy))
- gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (proxy),
- toggle_action->priv->active);
- else if (GTK_IS_TOGGLE_BUTTON (proxy))
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (proxy),
- toggle_action->priv->active);
-
- (* GTK_ACTION_CLASS (parent_class)->connect_proxy) (action, proxy);
-}
-
-static void
-disconnect_proxy (GtkAction *action, GtkWidget *proxy)
-{
- (* GTK_ACTION_CLASS (parent_class)->disconnect_proxy) (action, proxy);
-}
-
-static void
-_update_tooltips (PolKitGnomeToggleAction *action, GParamSpec *arg1, GtkWidget *widget)
-{
- GtkTooltips *tips;
- GtkTooltipsData *ttd;
- gchar *tip_str;
-
- ttd = gtk_tooltips_data_get (widget);
-
- if (ttd == NULL) {
- tips = gtk_tooltips_new ();
- } else {
- tips = ttd->tooltips;
- }
-
- tip_str = NULL;
- g_object_get (action, "tooltip", &tip_str, NULL);
-
- /* TODO: if there is no tooltip the tip_str is NULL.
- * Unfortunately it seems that the tooltip isn't
- * cleared.. mmm.. gtk+ bug?
- */
- gtk_tooltips_set_tip (tips, widget, tip_str, tip_str);
- g_free (tip_str);
-}
-
-static void
-_update_label (PolKitGnomeToggleAction *action, GParamSpec *arg1, GtkWidget *widget)
-{
- char *label;
-
- label = NULL;
- g_object_get (action, "label", &label, NULL);
- gtk_button_set_label (GTK_BUTTON (widget), label);
- g_free (label);
-}
-
-static void
-_update_icon_name (PolKitGnomeToggleAction *action, GParamSpec *arg1, GtkWidget *widget)
-{
- gtk_button_set_image (GTK_BUTTON (widget), gtk_action_create_icon (GTK_ACTION (action), GTK_ICON_SIZE_BUTTON));
-}
-
-static void
-_button_toggled (GtkToggleButton *button, PolKitGnomeToggleAction *action)
-{
- /* g_debug ("in _button_toggled"); */
-
- switch (polkit_gnome_action_get_polkit_result (POLKIT_GNOME_ACTION (action))) {
- case POLKIT_RESULT_YES:
- break;
-
- case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_ONE_SHOT:
- case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH:
- case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_SESSION:
- case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_ALWAYS:
- case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_ONE_SHOT:
- case POLKIT_RESULT_ONLY_VIA_SELF_AUTH:
- case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION:
- case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS:
- /* g_debug ("blocking toggled"); */
- g_signal_stop_emission_by_name (button, "toggled");
- break;
-
- default:
- case POLKIT_RESULT_NO:
- break;
- }
-}
-
-/**
- * polkit_gnome_toggle_action_create_toggle_button:
- * @action: The #PolKitGnomeToggleAction object
- *
- * Create a toggle button for the given action that displays the
- * label, tooltip and icon_name corresponding to whether the state,
- * according to PolicyKit, is no, auth or yes.
- *
- * Returns: A #GtkToggleButton instance connected to the action
- */
-GtkWidget *
-polkit_gnome_toggle_action_create_toggle_button (PolKitGnomeToggleAction *action)
-{
- GtkWidget *button;
-
- button = gtk_toggle_button_new ();
-
- gtk_action_connect_proxy (GTK_ACTION (action), button);
-
- _update_label (action, NULL, button);
- _update_tooltips (action, NULL, button);
- _update_icon_name (action, NULL, button);
-
- g_signal_connect (action, "notify::tooltip", G_CALLBACK (_update_tooltips), button);
- g_signal_connect (action, "notify::label", G_CALLBACK (_update_label), button);
- g_signal_connect (action, "notify::icon-name", G_CALLBACK (_update_icon_name), button);
-
- /* hook into the ::toggled signal and block it unless
- * PolicyKit says it's good to go.
- */
- g_signal_connect (button, "toggled", G_CALLBACK (_button_toggled), action);
-
- return button;
-}
diff --git a/polkit-gnome/polkit-gnome-toggle-action.h b/polkit-gnome/polkit-gnome-toggle-action.h
deleted file mode 100644
index 26b89e0..0000000
--- a/polkit-gnome/polkit-gnome-toggle-action.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-/***************************************************************************
- *
- * polkit-gnome-action.h :
- *
- * Copyright (C) 2007 David Zeuthen, <david fubar dk>
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- *
- **************************************************************************/
-
-#if !defined (POLKIT_GNOME_COMPILATION) && !defined(_POLKIT_GNOME_INSIDE_POLKIT_GNOME_H)
-#error "Only <polkit-gnome/polkit-gnome.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef __POLKIT_GNOME_TOGGLE_ACTION_H__
-#define __POLKIT_GNOME_TOGGLE_ACTION_H__
-
-#include <gtk/gtk.h>
-#include <polkit/polkit.h>
-#include <polkit-gnome/polkit-gnome.h>
-
-G_BEGIN_DECLS
-
-#define POLKIT_GNOME_TYPE_TOGGLE_ACTION (polkit_gnome_toggle_action_get_type ())
-#define POLKIT_GNOME_TOGGLE_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), POLKIT_GNOME_TYPE_TOGGLE_ACTION, PolKitGnomeToggleAction))
-#define POLKIT_GNOME_TOGGLE_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), POLKIT_GNOME_TYPE_TOGGLE_ACTION, PolKitGnomeToggleActionClass))
-#define POLKIT_GNOME_IS_TOGGLE_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), POLKIT_GNOME_TYPE_TOGGLE_ACTION))
-#define POLKIT_GNOME_IS_TOGGLE_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), POLKIT_GNOME_TYPE_TOGGLE_ACTION))
-#define POLKIT_GNOME_TOGGLE_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), POLKIT_GNOME_TYPE_TOGGLE_ACTION, PolKitGnomeToggleActionClass))
-
-typedef struct _PolKitGnomeToggleAction PolKitGnomeToggleAction;
-typedef struct _PolKitGnomeToggleActionPrivate PolKitGnomeToggleActionPrivate;
-typedef struct _PolKitGnomeToggleActionClass PolKitGnomeToggleActionClass;
-
-/**
- * PolKitGnomeToggleAction:
- *
- * The PolKitGnomeToggleAction struct contains only private data members and should not be accessed directly.
- */
-struct _PolKitGnomeToggleAction
-{
- /*< private >*/
- PolKitGnomeAction parent;
- PolKitGnomeToggleActionPrivate *priv;
-};
-
-struct _PolKitGnomeToggleActionClass
-{
- PolKitGnomeActionClass parent_class;
-
- void (* toggled) (PolKitGnomeToggleAction *toggle_action);
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
-};
-
-GType polkit_gnome_toggle_action_get_type (void) G_GNUC_CONST;
-PolKitGnomeToggleAction *polkit_gnome_toggle_action_new (const gchar *name);
-PolKitGnomeToggleAction *polkit_gnome_toggle_action_new_default (const gchar *name,
- PolKitAction *polkit_action,
- const gchar *locked_label,
- const gchar *unlocked_label);
-
-GtkWidget *polkit_gnome_toggle_action_create_toggle_button (PolKitGnomeToggleAction *action);
-
-G_END_DECLS
-
-#endif /* __POLKIT_GNOME_TOGGLE_ACTION_H__ */
diff --git a/polkit-gnome/polkit-gnome.h b/polkit-gnome/polkit-gnome.h
deleted file mode 100644
index bc9d1e3..0000000
--- a/polkit-gnome/polkit-gnome.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-/***************************************************************************
- *
- * polkit-gnome.h : PolicyKit add-on library to make it easy to use
- * PolicyKit from GNOME and GTK+ applications.
- *
- * Copyright (C) 2007 David Zeuthen, <david fubar dk>
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- *
- **************************************************************************/
-
-#ifndef __POLKIT_GNOME_H
-#define __POLKIT_GNOME_H
-
-#define _POLKIT_GNOME_INSIDE_POLKIT_GNOME_H 1
-#include <polkit-gnome/polkit-gnome-context.h>
-#include <polkit-gnome/polkit-gnome-action.h>
-#include <polkit-gnome/polkit-gnome-toggle-action.h>
-#include <polkit-gnome/polkit-gnome-auth.h>
-#undef _POLKIT_GNOME_INSIDE_POLKIT_GNOME_H
-
-
-#endif /* __POLKIT_GNOME_H */
diff --git a/src/polkitgnomeauthenticationdialog.c b/src/polkitgnomeauthenticationdialog.c
index ca0eda9..1a26b3d 100644
--- a/src/polkitgnomeauthenticationdialog.c
+++ b/src/polkitgnomeauthenticationdialog.c
@@ -33,7 +33,6 @@
#include <stdlib.h>
#include <pwd.h>
#include <errno.h>
-#include <gconf/gconf-client.h>
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]