Commit 071c3d76 authored by David Zeuthen's avatar David Zeuthen

start using EggDBus

parent 7c565ab1
......@@ -118,21 +118,13 @@ if test "x$GCC" = "xyes"; then
changequote([,])dnl
fi
PKG_CHECK_MODULES(GLIB, [gio-2.0 >= 2.14.0])
AC_SUBST(GIO_CFLAGS)
AC_SUBST(GIO_LIBS)
PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.14.0 gio-2.0 >= 2.14.0])
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
PKG_CHECK_MODULES(DBUS, [dbus-1 >= 1.0])
AC_SUBST(DBUS_CFLAGS)
AC_SUBST(DBUS_LIBS)
PKG_CHECK_MODULES(DBUS_GLIB, [dbus-glib-1 >= 0.73])
AC_SUBST(DBUS_GLIB_CFLAGS)
AC_SUBST(DBUS_GLIB_LIBS)
PKG_CHECK_MODULES(EGG_DBUS, [eggdbus-1 >= 0.1])
AC_SUBST(EGG_DBUS_CFLAGS)
AC_SUBST(EGG_DBUS_LIBS)
EXPAT_LIB=""
AC_ARG_WITH(expat, [ --with-expat=<dir> Use expat from here],
......@@ -167,10 +159,13 @@ Makefile
data/Makefile
src/Makefile
src/polkit/Makefile
src/polkitbackend/Makefile
src/polkitd/Makefile
src/programs/Makefile
docs/version.xml
docs/Makefile
docs/polkit/Makefile
docs/polkitbackend/Makefile
docs/man/Makefile
po/Makefile.in
])
......
SUBDIRS = man
SUBDIRS = man polkitbackend polkit
NULL =
AUTOMAKE_OPTIONS = 1.7
# The name of the module.
DOC_MODULE=polkit
# The top-level SGML file.
DOC_MAIN_SGML_FILE=polkit-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=../src/polkit
# Used for dependencies
HFILE_GLOB=$(top_srcdir)/src/polkit/*.h
CFILE_GLOB=$(top_srcdir)/src/polkit/*.c
# Headers to ignore
IGNORE_HFILES= \
$(NULL)
# CFLAGS and LDFLAGS for compiling scan program. Only needed
# if $(DOC_MODULE).types is non-empty.
INCLUDES = \
$(DBUS_GLIB_CFLAGS) \
$(GLIB_CFLAGS) \
$(GIO_CFLAGS) \
-I$(top_srcdir)/src/polkit \
-I$(top_builddir)/src/polkit \
$(NULL)
GTKDOC_LIBS = \
$(DBUS_GLIB_LIBS) \
$(GLIB_LIBS) \
$(GIO_LIBS) \
$(top_builddir)/src/polkit/libpolkit-gobject-1.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 = \
$(NULL)
# Extra options to supply to gtkdoc-fixref
FIXXREF_OPTIONS=
MAINTAINERCLEANFILES = \
*~ \
Makefile.in \
polkit.types \
polkit-*.txt \
$(NULL)
if ENABLE_GTK_DOC
include $(top_srcdir)/gtk-doc.make
else
EXTRA_DIST =
endif
EXTRA_DIST += version.xml.in
EXTRA_DIST = version.xml.in
NULL =
AUTOMAKE_OPTIONS = 1.7
# The name of the module.
DOC_MODULE=polkit
# The top-level SGML file.
DOC_MAIN_SGML_FILE=polkit-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=../../src/polkit
# Used for dependencies
HFILE_GLOB=$(top_srcdir)/src/polkit/*.h
CFILE_GLOB=$(top_srcdir)/src/polkit/*.c
# Headers to ignore
IGNORE_HFILES= \
$(NULL)
# CFLAGS and LDFLAGS for compiling scan program. Only needed
# if $(DOC_MODULE).types is non-empty.
INCLUDES = \
$(DBUS_GLIB_CFLAGS) \
$(GLIB_CFLAGS) \
$(GIO_CFLAGS) \
-I$(top_srcdir)/src/polkit \
-I$(top_builddir)/src/polkit \
$(NULL)
GTKDOC_LIBS = \
$(DBUS_GLIB_LIBS) \
$(GLIB_LIBS) \
$(GIO_LIBS) \
$(top_builddir)/src/polkit/libpolkit-gobject-1.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 = \
$(NULL)
# Extra options to supply to gtkdoc-fixref
FIXXREF_OPTIONS=
MAINTAINERCLEANFILES = \
*~ \
Makefile.in \
polkit.types \
polkit-*.txt \
$(NULL)
if ENABLE_GTK_DOC
include $(top_srcdir)/gtk-doc.make
else
EXTRA_DIST =
endif
EXTRA_DIST += version.xml.in
<?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">
<!ENTITY version SYSTEM "../version.xml">
]>
<book id="index" xmlns:xi="http://www.w3.org/2003/XInclude">
<bookinfo>
......@@ -73,9 +73,7 @@
<xi:include href="xml/polkitprocess.xml"/>
<chapter id="extending">
<title>Extending PolicyKit</title>
<xi:include href="xml/polkitbackend.xml"/>
<xi:include href="xml/polkitlocalbackend.xml"/>
<xi:include href="xml/polkitbackendstub.xml"/>
<xi:include href="../polkitbackend/xml/polkitbackendlocal.xml"/>
</chapter>
</reference>
......
NULL =
AUTOMAKE_OPTIONS = 1.7
# The name of the module.
DOC_MODULE=polkitbackend
# The top-level SGML file.
DOC_MAIN_SGML_FILE=polkitbackend-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=../../src/polkitbackend
# Used for dependencies
HFILE_GLOB=$(top_srcdir)/src/polkitbackend/*.h
CFILE_GLOB=$(top_srcdir)/src/polkitbackend/*.c
# Headers to ignore
IGNORE_HFILES= \
$(NULL)
# CFLAGS and LDFLAGS for compiling scan program. Only needed
# if $(DOC_MODULE).types is non-empty.
INCLUDES = \
$(DBUS_GLIB_CFLAGS) \
$(GLIB_CFLAGS) \
$(GIO_CFLAGS) \
-I$(top_srcdir)/src/polkitbackend \
-I$(top_builddir)/src/polkitbackend \
$(NULL)
GTKDOC_LIBS = \
$(DBUS_GLIB_LIBS) \
$(GLIB_LIBS) \
$(GIO_LIBS) \
$(top_builddir)/src/polkit/libpolkit-gobject-1.la \
$(top_builddir)/src/polkitbackend/libpolkit-backend-1.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 = \
$(NULL)
# Extra options to supply to gtkdoc-fixref
FIXXREF_OPTIONS=
MAINTAINERCLEANFILES = \
*~ \
Makefile.in \
polkitbackend.types \
polkit-*.txt \
$(NULL)
if ENABLE_GTK_DOC
include $(top_srcdir)/gtk-doc.make
else
EXTRA_DIST =
endif
<?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">
</book>
SUBDIRS = polkit polkitd programs
SUBDIRS = polkit polkitbackend polkitd programs
clean-local :
rm -f *~
......@@ -14,16 +14,20 @@ INCLUDES = \
-D_REENTRANT \
$(NULL)
BUILT_SOURCES = \
polkitbackendstubglue.h \
polkitauthorityglue.h \
BUILT_SOURCES = \
polkitbindings.h polkitbindings.c \
polkitbindingstypes.h \
polkitauthority.h polkitauthority.c \
polkitbindingsmarshal.h polkitbindingsmarshal.c \
polkitbindingsmarshal.list \
$(NULL)
polkitbackendstubglue.h: $(top_srcdir)/data/org.freedesktop.PolicyKit1.Authority.xml Makefile.am
dbus-binding-tool --prefix=_polkit_backend_stub --mode=glib-server --output=polkitbackendstubglue.h $(top_srcdir)/data/org.freedesktop.PolicyKit1.Authority.xml
polkitauthorityglue.h: $(top_srcdir)/data/org.freedesktop.PolicyKit1.Authority.xml Makefile.am
dbus-binding-tool --mode=glib-client --output=polkitauthorityglue.h $(top_srcdir)/data/org.freedesktop.PolicyKit1.Authority.xml
$(BUILT_SOURCES) : Makefile.am $(top_srcdir)/data/org.freedesktop.PolicyKit1.Authority.xml
dbus2gobject \
--namespace "Polkit" \
--dbus-namespace "org.freedesktop.PolicyKit1" \
--introspection-xml $(top_srcdir)/data/org.freedesktop.PolicyKit1.Authority.xml \
$(NULL)
lib_LTLIBRARIES=libpolkit-gobject-1.la
......@@ -31,45 +35,42 @@ libpolkit_gobject_1includedir=$(includedir)/polkit-1/polkit
libpolkit_gobject_1include_HEADERS = \
polkit.h \
polkitauthoritystub.h \
polkitactiondescription.h \
polkitauthority.h \
polkitauthorizationclaim.h \
polkitauthorizationresult.h \
polkitbackend.h \
polkiterror.h \
polkitsubject.h \
polkituser.h \
polkitprocess.h \
polkitbindings.h \
polkitbindingstypes.h \
polkitauthority.h \
$(NULL)
libpolkit_gobject_1_la_SOURCES = \
polkit.h \
polkitauthority.h polkitauthority.c \
polkitauthoritystub.h polkitauthoritystub.c \
polkitactiondescription.h polkitactiondescription.c \
polkitauthorizationclaim.h polkitauthorizationclaim.c \
polkitauthorizationresult.h polkitauthorizationresult.c \
polkitbackend.h polkitbackend.c \
polkitbackendstub.h polkitbackendstub.c \
polkiterror.h polkiterror.c \
polkitsubject.h polkitsubject.c \
polkitlocalbackend.h polkitlocalbackend.c \
polkituser.h polkituser.c \
polkitprocess.h polkitprocess.c \
polkitserialization.h polkitserialization.c \
$(BUILT_SOURCES) \
$(NULL)
libpolkit_gobject_1_la_CFLAGS = \
-D_POLKIT_COMPILATION \
$(GLIB_CFLAGS) \
$(GIO_CFLAGS) \
$(DBUS_GLIB_CFLAGS) \
$(EGG_DBUS_CFLAGS) \
$(NULL)
libpolkit_gobject_1_la_LIBADD = \
$(GLIB_LIBS) \
$(GIO_LIBS) \
$(DBUS_GLIB_LIBS) \
$(EGG_DBUS_LIBS) \
$(NULL)
CLEANFILES = $(BUILT_SOURCES)
......
......@@ -25,17 +25,17 @@
#define __POLKIT_H
#define _POLKIT_INSIDE_POLKIT_H 1
#include <polkit/polkitbindings.h>
#include <polkit/polkitauthoritystub.h>
#include <polkit/polkiterror.h>
#include <polkit/polkitsubject.h>
#include <polkit/polkitauthority.h>
#include <polkit/polkitbackendstub.h>
#include <polkit/polkitbackend.h>
#include <polkit/polkitlocalbackend.h>
#include <polkit/polkitauthorizationclaim.h>
#include <polkit/polkitauthorizationresult.h>
#include <polkit/polkituser.h>
#include <polkit/polkitprocess.h>
#include <polkit/polkitactiondescription.h>
#undef _POLKIT_INSIDE_POLKIT_H
#endif /* __POLKIT_H */
......
......@@ -314,6 +314,7 @@ polkit_action_description_get_annotations (PolkitActionDescription *action_desc
/* ---------------------------------------------------------------------------------------------------- */
#if 0
#include <expat.h> /* TODO: move to separate file */
enum {
......@@ -818,7 +819,6 @@ error:
XML_StopParser (pd->parser, FALSE);
}
/**
* polkit_action_description_get_from_file:
* @path: path to file, e.g. <literal>/usr/share/polkit-1/actions/org.freedesktop.policykit.policy</literal>
......@@ -876,12 +876,9 @@ polkit_action_description_get_from_file (const char *pat
/* #ifdef POLKIT_BUILD_TESTS
TODO: expat appears to leak on certain OOM paths
*/
#if 0
XML_Memory_Handling_Suite memsuite = {p_malloc, p_realloc, kit_free};
pd.parser = XML_ParserCreate_MM (NULL, &memsuite, NULL);
#else
pd.parser = XML_ParserCreate (NULL);
#endif
pd.stack_depth = 0;
if (pd.parser == NULL) {
polkit_error_set_error (error, POLKIT_ERROR_OUT_OF_MEMORY,
......@@ -1109,4 +1106,4 @@ polkit_action_description_new_from_directory (GFile *directory,
g_object_unref (e);
return ret;
}
#endif
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author: David Zeuthen <davidz@redhat.com>
*/
#include "config.h"
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
#include "polkitauthority.h"
#include "polkitauthorityglue.h"
#include "polkitserialization.h"
/**
* SECTION:polkitauthority
* @short_description: Authorization checking and management
* @include: polkit/polkit.h
*
* The #PolkitAuthority class represents an authority that can check
* claims made by third parties. Some implementations allow managing
* authorizations.
*/
struct _PolkitAuthorityPrivate
{
DBusGProxy *dbus_proxy;
};
G_DEFINE_TYPE (PolkitAuthority, polkit_authority, G_TYPE_OBJECT);
#define POLKIT_AUTHORITY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), POLKIT_TYPE_AUTHORITY, PolkitAuthorityPrivate))
enum {
CHANGED_SIGNAL,
LAST_SIGNAL,
};
static guint signals[LAST_SIGNAL] = { 0 };
static void
polkit_authority_finalize (GObject *object)
{
PolkitAuthority *authority;
authority = POLKIT_AUTHORITY (object);
if (authority->priv->dbus_proxy != NULL)
g_object_unref (authority->priv->dbus_proxy);
G_OBJECT_CLASS (polkit_authority_parent_class)->finalize (object);
}
static void
polkit_authority_class_init (PolkitAuthorityClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = polkit_authority_finalize;
/**
* PolkitAuthority::changed:
* @authority: a #PolkitAuthority.
*
* Emitted when something on @authority changes.
*/
signals[CHANGED_SIGNAL] = g_signal_new ("changed",
POLKIT_TYPE_AUTHORITY,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (PolkitAuthorityClass, changed),
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
g_type_class_add_private (klass, sizeof (PolkitAuthorityPrivate));
}
static void
polkit_authority_init (PolkitAuthority *authority)
{
authority->priv = POLKIT_AUTHORITY_GET_PRIVATE (authority);
}
/* ---------------------------------------------------------------------------------------------------- */
static void
say_hello_cb (DBusGProxy *dbus_proxy,
char *result,
GError *error,
gpointer user_data)
{
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (user_data);
if (error != NULL)
g_simple_async_result_set_from_error (simple, error);
else
g_simple_async_result_set_op_res_gpointer (simple, result, NULL);
g_simple_async_result_complete (simple);
}
void
polkit_authority_say_hello (PolkitAuthority *authority,
const gchar *name,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *simple;
simple = g_simple_async_result_new (G_OBJECT (authority),
callback,
user_data,
polkit_authority_say_hello);
org_freedesktop_PolicyKit1_Authority_say_hello_async (authority->priv->dbus_proxy,
name,
say_hello_cb,
simple);
}
gchar *
polkit_authority_say_hello_finish (PolkitAuthority *authority,
GAsyncResult *res,
GError **error)
{
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == polkit_authority_say_hello);
g_simple_async_result_propagate_error (simple, error);
return g_simple_async_result_get_op_res_gpointer (simple);
}
/**
* polkit_authority_say_hello_sync:
* @authority: A #PolkitAuthority.
* @name: A name to say hello to.
* @cancellable: A #GCancellable or %NULL.
* @error: Return location for error.
*
* Says hello to @name.
*
* Returns: %NULL if @error is set, otherwise a newly allocated string
* containing the greeting, free with g_free().
**/
gchar *
polkit_authority_say_hello_sync (PolkitAuthority *authority,
const gchar *name,
GCancellable *cancellable,
GError **error)
{
gchar *result;
if (org_freedesktop_PolicyKit1_Authority_say_hello (authority->priv->dbus_proxy,
name,
&result,
error)) {
return result;
} else {
return NULL;
}
}
/* ---------------------------------------------------------------------------------------------------- */
PolkitAuthorizationResult
polkit_authority_check_claims_sync (PolkitAuthority *authority,
GList *claims,
GCancellable *cancellable,
GError **error)
{
PolkitAuthorizationResult result;
char *result_str;
GPtrArray *p;
result = POLKIT_AUTHORIZATION_RESULT_NOT_AUTHORIZED;
p = _serialize_ptr_array_from_obj_list
(claims,
(PolkitSerializeFromObjectFunc) _authorization_claim_to_value);
if (org_freedesktop_PolicyKit1_Authority_check_claims (authority->priv->dbus_proxy,
p,
&result_str,
error)) {
result = _authorization_result_from_string (result_str);
}
_free_serialized_obj_ptr_array (p);
return result;
}
/* ---------------------------------------------------------------------------------------------------- */
static PolkitAuthority *
_polkit_authority_new (DBusGConnection *connection,
const gchar *service_name,
const gchar *object_path)
{
PolkitAuthority *authority;
authority = POLKIT_AUTHORITY (g_object_new (POLKIT_TYPE_AUTHORITY, NULL));
authority->priv->dbus_proxy = dbus_g_proxy_new_for_name (connection,
service_name,