start using EggDBus
authorDavid Zeuthen <davidz@redhat.com>
Wed, 3 Dec 2008 18:59:12 +0000 (13:59 -0500)
committerDavid Zeuthen <davidz@redhat.com>
Wed, 3 Dec 2008 18:59:12 +0000 (13:59 -0500)
28 files changed:
configure.ac
docs/Makefile.am
docs/polkit/Makefile.am [new file with mode: 0644]
docs/polkit/polkit-docs.xml [moved from docs/polkit-docs.xml with 94% similarity]
docs/polkitbackend/Makefile.am [new file with mode: 0644]
docs/polkitbackend/polkitbackend-docs.xml [new file with mode: 0644]
src/Makefile.am
src/polkit/Makefile.am
src/polkit/polkit.h
src/polkit/polkitactiondescription.c
src/polkit/polkitauthority.c [deleted file]
src/polkit/polkitauthority.h [deleted file]
src/polkit/polkitauthoritystub.c [new file with mode: 0644]
src/polkit/polkitauthoritystub.h [new file with mode: 0644]
src/polkit/polkitbackend.c [deleted file]
src/polkit/polkitbackend.h [deleted file]
src/polkit/polkitbackendstub.c [deleted file]
src/polkit/polkitbackendstub.h [deleted file]
src/polkit/polkitlocalbackend.c [deleted file]
src/polkit/polkitlocalbackend.h [deleted file]
src/polkit/polkitserialization.c [deleted file]
src/polkit/polkitserialization.h [deleted file]
src/polkitbackend/Makefile.am [new file with mode: 0644]
src/polkitbackend/polkitbackend.h [new file with mode: 0644]
src/polkitd/Makefile.am
src/polkitd/main.c
src/programs/Makefile.am
src/programs/polkit-verify-claim.c

index 4882377..1aaf600 100644 (file)
@@ -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
 ])
index b647ac9..a349fad 100644 (file)
@@ -1,76 +1,4 @@
 
-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
diff --git a/docs/polkit/Makefile.am b/docs/polkit/Makefile.am
new file mode 100644 (file)
index 0000000..44f7c8c
--- /dev/null
@@ -0,0 +1,74 @@
+
+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
similarity index 94%
rename from docs/polkit-docs.xml
rename to docs/polkit/polkit-docs.xml
index 565bfe0..26b5cf2 100644 (file)
@@ -1,7 +1,7 @@
 <?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>
 
diff --git a/docs/polkitbackend/Makefile.am b/docs/polkitbackend/Makefile.am
new file mode 100644 (file)
index 0000000..6ec2bce
--- /dev/null
@@ -0,0 +1,73 @@
+
+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
diff --git a/docs/polkitbackend/polkitbackend-docs.xml b/docs/polkitbackend/polkitbackend-docs.xml
new file mode 100644 (file)
index 0000000..7a56075
--- /dev/null
@@ -0,0 +1,7 @@
+<?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>
index 562a3e2..7538232 100644 (file)
@@ -1,5 +1,5 @@
 
-SUBDIRS = polkit polkitd programs
+SUBDIRS = polkit polkitbackend polkitd programs
 
 clean-local :
        rm -f *~
index 1ab8817..d3d34d9 100644 (file)
@@ -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)
index afdad46..57bc2f5 100644 (file)
 #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 */
index 2a8d5b7..8bebb06 100644 (file)
@@ -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
diff --git a/src/polkit/polkitauthority.c b/src/polkit/polkitauthority.c
deleted file mode 100644 (file)
index f7c5045..0000000
+++ /dev/null
@@ -1,262 +0,0 @@
-/* -*- 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,
-                                                                 object_path,
-                                                                 "org.freedesktop.PolicyKit1.Authority");
-
-        return authority;
-}
-
-/**
- * polkit_authority_get:
- *
- * Gets the default authority for checking claims.
- *
- * Returns: A reference to a #PolkitAuthority instance. Call
- * g_object_unref() to free it.
- **/
-PolkitAuthority *
-polkit_authority_get (void)
-{
-        PolkitAuthority *authority;
-        DBusGConnection *bus;
-        GError *error;
-
-        bus = NULL;
-        authority = NULL;
-
-        error = NULL;
-        bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
-        if (bus == NULL) {
-                g_warning ("Couldn't connect to system bus: %s", error->message);
-                g_error_free (error);
-                goto out;
-        }
-
-        authority = _polkit_authority_new (bus,
-                                          "org.freedesktop.PolicyKit1",
-                                          "/authority");
-
- out:
-        if (bus != NULL)
-                dbus_g_connection_unref (bus);
-        return authority;
-}
diff --git a/src/polkit/polkitauthority.h b/src/polkit/polkitauthority.h
deleted file mode 100644 (file)
index cd2914b..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/* -*- 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>
- */
-
-#if !defined (_POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H)
-#error "Only <polkit/polkit.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef __POLKIT_AUTHORITY_H
-#define __POLKIT_AUTHORITY_H
-
-#include <glib-object.h>
-#include <gio/gio.h>
-#include <polkit/polkitauthorizationclaim.h>
-#include <polkit/polkitauthorizationresult.h>
-
-G_BEGIN_DECLS
-
-#define POLKIT_TYPE_AUTHORITY         (polkit_authority_get_type ())
-#define POLKIT_AUTHORITY(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_TYPE_AUTHORITY, PolkitAuthority))
-#define POLKIT_AUTHORITY_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST ((k), POLKIT_TYPE_AUTHORITY, PolkitAuthorityClass))
-#define POLKIT_AUTHORITY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_TYPE_AUTHORITY,PolkitAuthorityClass))
-#define POLKIT_IS_AUTHORITY(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_TYPE_AUTHORITY))
-#define POLKIT_IS_AUTHORITY_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_TYPE_AUTHORITY))
-
-typedef struct _PolkitAuthority         PolkitAuthority;
-typedef struct _PolkitAuthorityPrivate  PolkitAuthorityPrivate;
-typedef struct _PolkitAuthorityClass    PolkitAuthorityClass;
-
-struct _PolkitAuthority
-{
-        GObject parent_instance;
-
-        /*< private >*/
-        PolkitAuthorityPrivate *priv;
-};
-
-struct _PolkitAuthorityClass
-{
-        GObjectClass parent_class;
-
-        /*< public >*/
-
-        /* signals */
-        void   (* changed) (PolkitAuthority *authority);
-
-        /*< private >*/
-
-        /* Padding for future expansion */
-        void (*_polkit_reserved1) (void);
-        void (*_polkit_reserved2) (void);
-        void (*_polkit_reserved3) (void);
-        void (*_polkit_reserved4) (void);
-        void (*_polkit_reserved5) (void);
-        void (*_polkit_reserved6) (void);
-        void (*_polkit_reserved7) (void);
-        void (*_polkit_reserved8) (void);
-};
-
-GType  polkit_authority_get_type         (void) G_GNUC_CONST;
-
-void   polkit_authority_say_hello        (PolkitAuthority    *authority,
-                                          const gchar          *name,
-                                          GCancellable         *cancellable,
-                                          GAsyncReadyCallback   callback,
-                                          gpointer              user_data);
-
-gchar *polkit_authority_say_hello_finish (PolkitAuthority    *authority,
-                                          GAsyncResult        *res,
-                                          GError             **error);
-
-gchar *polkit_authority_say_hello_sync   (PolkitAuthority    *authority,
-                                          const gchar         *name,
-                                          GCancellable        *cancellable,
-                                          GError             **error);
-
-PolkitAuthorizationResult  polkit_authority_check_claims_sync (PolkitAuthority     *authority,
-                                                               GList               *claims,
-                                                               GCancellable        *cancellable,
-                                                               GError             **error);
-
-PolkitAuthority *polkit_authority_get (void);
-
-G_END_DECLS
-
-#endif /* __POLKIT_AUTHORITY_H */
-
diff --git a/src/polkit/polkitauthoritystub.c b/src/polkit/polkitauthoritystub.c
new file mode 100644 (file)
index 0000000..812997e
--- /dev/null
@@ -0,0 +1,61 @@
+/* -*- 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 "polkitauthoritystub.h"
+
+/* TODO: locking */
+
+static PolkitAuthority *the_authority = NULL;
+
+/**
+ * polkit_authority_get:
+ *
+ * Gets the default authority for checking claims.
+ *
+ * Returns: A reference to a #PolkitAuthority instance. Call g_object_unref() when done with it
+ **/
+PolkitAuthority *
+polkit_authority_get (void)
+{
+        PolkitAuthority *authority;
+
+        polkit_bindings_register_types (); /* TODO: use __attribute ((constructor)) */
+
+        if (the_authority != NULL) {
+                authority = g_object_ref (the_authority);
+        } else {
+                EggDBusConnection *connection;
+
+                connection = egg_dbus_connection_get_for_bus (EGG_DBUS_BUS_TYPE_SYSTEM);
+                authority = POLKIT_AUTHORITY (egg_dbus_connection_get_proxy (connection,
+                                                                             "org.freedesktop.PolicyKit1",
+                                                                             "/org/freedesktop/PolicyKit1/Authority"));
+
+                /* TODO: take a weak reference and set the_authority to NULL on destruction */
+
+                /* TODO: unref connection since authority holds a reference? */
+        }
+
+        return authority;
+}
diff --git a/src/polkit/polkitauthoritystub.h b/src/polkit/polkitauthoritystub.h
new file mode 100644 (file)
index 0000000..cf8296f
--- /dev/null
@@ -0,0 +1,35 @@
+/* -*- 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 <polkit/polkitbindings.h>
+
+#ifndef __POLKIT_AUTHORITY_STUB_H
+#define __POLKIT_AUTHORITY_STUB_H
+
+G_BEGIN_DECLS
+
+PolkitAuthority *polkit_authority_get (void);
+
+G_END_DECLS
+
+#endif /* __POLKIT_AUTHORITY_STUB_H */
diff --git a/src/polkit/polkitbackend.c b/src/polkit/polkitbackend.c
deleted file mode 100644 (file)
index ce34456..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/* -*- 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 "polkitbackend.h"
-
-/**
- * SECTION:polkitbackend
- * @short_description: Abstract base class for backends
- * @include: polkit/polkit.h
- *
- * The #PolkitBackend class represents a backend responding to
- * requests from instances of the #PolkitAuthority class.
- */
-
-G_DEFINE_ABSTRACT_TYPE (PolkitBackend, polkit_backend, G_TYPE_OBJECT);
-
-enum {
-        CHANGED_SIGNAL,
-        LAST_SIGNAL,
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-static void
-polkit_backend_finalize (GObject *object)
-{
-        PolkitBackend *backend;
-
-        backend = POLKIT_BACKEND (object);
-
-        G_OBJECT_CLASS (polkit_backend_parent_class)->finalize (object);
-}
-
-static void
-polkit_backend_class_init (PolkitBackendClass *klass)
-{
-        GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
-        gobject_class->finalize = polkit_backend_finalize;
-
-        /**
-         * PolkitBackend::changed:
-         * @backend: a #PolkitBackend.
-         *
-         * Emitted when something on @backend changes.
-         */
-        signals[CHANGED_SIGNAL] = g_signal_new ("changed",
-                                                POLKIT_TYPE_BACKEND,
-                                                G_SIGNAL_RUN_LAST,
-                                                G_STRUCT_OFFSET (PolkitBackendClass, changed),
-                                                NULL,
-                                                NULL,
-                                                g_cclosure_marshal_VOID__VOID,
-                                                G_TYPE_NONE,
-                                                0);
-}
-
-static void
-polkit_backend_init (PolkitBackend *backend)
-{
-}
-
-gchar *
-polkit_backend_say_hello (PolkitBackend        *backend,
-                          PolkitSubject        *inquirer,
-                          const gchar          *name,
-                          GError              **error)
-{
-        PolkitBackendClass *klass;
-
-        g_return_val_if_fail (POLKIT_IS_BACKEND (backend), NULL);
-        klass = POLKIT_BACKEND_GET_CLASS (backend);
-
-        return (* klass->say_hello) (backend,
-                                     inquirer,
-                                     name,
-                                     error);
-}
-
-PolkitAuthorizationResult
-polkit_backend_check_claims (PolkitBackend       *backend,
-                             PolkitSubject       *inquirer,
-                             GList               *claims,
-                             GError             **error)
-{
-        PolkitBackendClass *klass;
-
-        g_return_val_if_fail (POLKIT_IS_BACKEND (backend), POLKIT_AUTHORIZATION_RESULT_NOT_AUTHORIZED);
-        klass = POLKIT_BACKEND_GET_CLASS (backend);
-
-        return (* klass->check_claims) (backend,
-                                        inquirer,
-                                        claims,
-                                        error);
-}
-
diff --git a/src/polkit/polkitbackend.h b/src/polkit/polkitbackend.h
deleted file mode 100644 (file)
index 4cfd3e3..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/* -*- 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>
- */
-
-#if !defined (_POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H)
-#error "Only <polkit/polkit.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef __POLKIT_BACKEND_H
-#define __POLKIT_BACKEND_H
-
-#include <glib-object.h>
-#include <gio/gio.h>
-#include <polkit/polkitauthorizationclaim.h>
-#include <polkit/polkitauthorizationresult.h>
-
-G_BEGIN_DECLS
-
-#define POLKIT_TYPE_BACKEND         (polkit_backend_get_type ())
-#define POLKIT_BACKEND(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_TYPE_BACKEND, PolkitBackend))
-#define POLKIT_BACKEND_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST ((k), POLKIT_TYPE_BACKEND, PolkitBackendClass))
-#define POLKIT_BACKEND_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_TYPE_BACKEND,PolkitBackendClass))
-#define POLKIT_IS_BACKEND(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_TYPE_BACKEND))
-#define POLKIT_IS_BACKEND_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_TYPE_BACKEND))
-
-typedef struct _PolkitBackend        PolkitBackend;
-typedef struct _PolkitBackendClass   PolkitBackendClass;
-
-struct _PolkitBackend
-{
-        GObject parent_instance;
-};
-
-/* TODO: maybe we also want async versions that are tried before the sync ones */
-
-struct _PolkitBackendClass
-{
-        GObjectClass parent_class;
-
-        /*< public >*/
-
-        /* signals */
-        void   (* changed)           (PolkitBackend     *backend);
-
-        /* vtable */
-        gchar * (* say_hello)   (PolkitBackend       *backend,
-                                 PolkitSubject       *inquirer,
-                                 const gchar         *name,
-                                 GError             **error);
-
-        PolkitAuthorizationResult  (* check_claims) (PolkitBackend       *backend,
-                                                     PolkitSubject       *inquirer,
-                                                     GList               *claims,
-                                                     GError             **error);
-
-        /*< private >*/
-
-        /* Padding for future expansion */
-        void (*_polkit_reserved1) (void);
-        void (*_polkit_reserved2) (void);
-        void (*_polkit_reserved3) (void);
-        void (*_polkit_reserved4) (void);
-        void (*_polkit_reserved5) (void);
-        void (*_polkit_reserved6) (void);
-        void (*_polkit_reserved7) (void);
-        void (*_polkit_reserved8) (void);
-};
-
-GType  polkit_backend_get_type         (void) G_GNUC_CONST;
-
-gchar *polkit_backend_say_hello        (PolkitBackend        *backend,
-                                        PolkitSubject        *inquirer,
-                                        const gchar          *name,
-                                        GError              **error);
-
-PolkitAuthorizationResult  polkit_backend_check_claims (PolkitBackend       *backend,
-                                                        PolkitSubject       *inquirer,
-                                                        GList               *claims,
-                                                        GError             **error);
-
-G_END_DECLS
-
-#endif /* __POLKIT_BACKEND_H */
-
diff --git a/src/polkit/polkitbackendstub.c b/src/polkit/polkitbackendstub.c
deleted file mode 100644 (file)
index 04e80ef..0000000
+++ /dev/null
@@ -1,224 +0,0 @@
-/* -*- 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 <glib.h>
-#include <glib/gi18n-lib.h>
-#include <glib-object.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include "polkiterror.h"
-#include "polkitbackendstub.h"
-#include "polkituser.h"
-#include "polkitserialization.h"
-
-/**
- * SECTION:polkitbackendstub
- * @short_description: Stub for proxying backends
- * @include: polkit/polkit.h
- *
- * Used on the server side for proxying a #PolkitBackend over
- * D-Bus. On the client side, #PolkitAuthority is used.
- */
-
-/*--------------------------------------------------------------------------------------------------------------*/
-
-/* exported methods */
-
-gboolean _polkit_backend_stub_say_hello (PolkitBackendStub     *backend_stub,
-                                         const char             *name,
-                                         DBusGMethodInvocation  *context);
-
-gboolean _polkit_backend_stub_check_claims (PolkitBackendStub     *backend_stub,
-                                            GPtrArray              *_claims,
-                                            DBusGMethodInvocation  *context);
-
-#include "polkitbackendstubglue.h"
-
-/*--------------------------------------------------------------------------------------------------------------*/
-
-struct _PolkitBackendStubPrivate
-{
-        PolkitBackend *backend;
-};
-
-G_DEFINE_TYPE (PolkitBackendStub, polkit_backend_stub, G_TYPE_OBJECT)
-
-#define POLKIT_BACKEND_STUB_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), POLKIT_TYPE_BACKEND_STUB, PolkitBackendStubPrivate))
-
-static void
-polkit_backend_stub_init (PolkitBackendStub *backend_stub)
-{
-        backend_stub->priv = POLKIT_BACKEND_STUB_GET_PRIVATE (backend_stub);
-
-}
-
-static void
-polkit_backend_stub_finalize (GObject *object)
-{
-        PolkitBackendStub *backend_stub;
-
-        g_return_if_fail (object != NULL);
-        g_return_if_fail (POLKIT_IS_BACKEND_STUB (object));
-
-        backend_stub = POLKIT_BACKEND_STUB (object);
-
-        if (backend_stub->priv->backend != NULL)
-                g_object_unref (backend_stub->priv->backend);
-
-        G_OBJECT_CLASS (polkit_backend_stub_parent_class)->finalize (object);
-}
-
-static void
-polkit_backend_stub_class_init (PolkitBackendStubClass *klass)
-{
-        GObjectClass   *object_class = G_OBJECT_CLASS (klass);
-
-        object_class->finalize = polkit_backend_stub_finalize;
-
-        g_type_class_add_private (klass, sizeof (PolkitBackendStubPrivate));
-
-        dbus_g_error_domain_register (POLKIT_ERROR,
-                                      "org.freedesktop.PolicyKit.Error",
-                                      POLKIT_TYPE_ERROR);
-
-        dbus_g_object_type_install_info (POLKIT_TYPE_BACKEND_STUB, &dbus_glib__polkit_backend_stub_object_info);
-}
-
-PolkitBackendStub *
-polkit_backend_stub_new (DBusGConnection   *connection,
-                             const char        *object_path,
-                             PolkitBackend  *backend)
-{
-        PolkitBackendStub *backend_stub;
-
-        backend_stub = POLKIT_BACKEND_STUB (g_object_new (POLKIT_TYPE_BACKEND_STUB, NULL));
-
-        dbus_g_connection_register_g_object (connection,
-                                             object_path,
-                                             G_OBJECT (backend_stub));
-
-        backend_stub->priv->backend = g_object_ref (backend);
-
-        return backend_stub;
-}
-
-/*--------------------------------------------------------------------------------------------------------------*/
-
-static PolkitSubject *
-get_inquirer (DBusGMethodInvocation *context)
-{
-        PolkitSubject *subject;
-
-        /* TODO; get from context */
-        subject = polkit_user_new ("root");
-
-        return subject;
-}
-
-/*--------------------------------------------------------------------------------------------------------------*/
-/* exported methods */
-
-gboolean
-_polkit_backend_stub_say_hello (PolkitBackendStub      *backend_stub,
-                                const char             *name,
-                                DBusGMethodInvocation  *context)
-{
-        PolkitSubject *inquirer;
-        GError *error;
-        char *result;
-
-        error = NULL;
-        inquirer = get_inquirer (context);
-
-        result = polkit_backend_say_hello (backend_stub->priv->backend,
-                                           inquirer,
-                                           name,
-                                           &error);
-
-        if (error != NULL) {
-                dbus_g_method_return_error (context, error);
-                g_error_free (error);
-        } else {
-                dbus_g_method_return (context, result);
-                g_free (result);
-        }
-
-        g_object_unref (inquirer);
-
-        return TRUE;
-}
-
-/*--------------------------------------------------------------------------------------------------------------*/
-
-gboolean
-_polkit_backend_stub_check_claims (PolkitBackendStub      *backend_stub,
-                                   GPtrArray              *_claims,
-                                   DBusGMethodInvocation  *context)
-{
-        PolkitSubject *inquirer;
-        GError *error;
-        GList *claims;
-        PolkitAuthorizationResult result;
-
-        error = NULL;
-        inquirer = get_inquirer (context);
-
-        claims = _serialize_ptr_array_to_obj_list
-                (_claims,
-                 (PolkitSerializeToObjectFunc) _authorization_claim_from_data);
-
-        if (claims == NULL) {
-                dbus_g_method_return_error (context,
-                                            g_error_new (POLKIT_ERROR,
-                                                         POLKIT_ERROR_FAILED,
-                                                         "Data is malformed"));
-                goto out;
-        }
-
-        result = polkit_backend_check_claims (backend_stub->priv->backend,
-                                              inquirer,
-                                              claims,
-                                              &error);
-
-        if (error != NULL) {
-                dbus_g_method_return_error (context, error);
-                g_error_free (error);
-        } else {
-                char *result_str;
-                result_str = _authorization_result_to_string (result);
-                dbus_g_method_return (context, result_str);
-                g_free (result_str);
-        }
-
-        g_object_unref (inquirer);
-
-        g_list_foreach (claims, (GFunc) g_object_unref, NULL);
-        g_list_free (claims);
-
- out:
-        return TRUE;
-}
-
-/*--------------------------------------------------------------------------------------------------------------*/
diff --git a/src/polkit/polkitbackendstub.h b/src/polkit/polkitbackendstub.h
deleted file mode 100644 (file)
index a594909..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/* -*- 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>
- */
-
-#if !defined (_POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H)
-#error "Only <polkit/polkit.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef __POLKIT_BACKEND_STUB_H__
-#define __POLKIT_BACKEND_STUB_H__
-
-#include <glib-object.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-#include <polkit/polkitbackend.h>
-
-G_BEGIN_DECLS
-
-#define POLKIT_TYPE_BACKEND_STUB         (polkit_backend_stub_get_type ())
-#define POLKIT_BACKEND_STUB(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_TYPE_BACKEND_STUB, PolkitBackendStub))
-#define POLKIT_BACKEND_STUB_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), POLKIT_TYPE_BACKEND_STUB, PolkitBackendStubClass))
-#define POLKIT_IS_BACKEND_STUB(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_TYPE_BACKEND_STUB))
-#define POLKIT_IS_BACKEND_STUB_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_TYPE_BACKEND_STUB))
-#define POLKIT_BACKEND_STUB_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_TYPE_BACKEND_STUB, PolkitBackendStubClass))
-
-typedef struct _PolkitBackendStub        PolkitBackendStub;
-typedef struct _PolkitBackendStubClass   PolkitBackendStubClass;
-typedef struct _PolkitBackendStubPrivate PolkitBackendStubPrivate;
-
-struct _PolkitBackendStub
-{
-        GObject                   parent_instance;
-        PolkitBackendStubPrivate *priv;
-};
-
-struct _PolkitBackendStubClass
-{
-        GObjectClass parent_class;
-};
-
-GType               polkit_backend_stub_get_type (void) G_GNUC_CONST;
-PolkitBackendStub  *polkit_backend_stub_new      (DBusGConnection   *connection,
-                                                  const char        *object_path,
-                                                  PolkitBackend     *backend);
-
-G_END_DECLS
-
-#endif /* __POLKIT_BACKEND_STUB_H__ */
diff --git a/src/polkit/polkitlocalbackend.c b/src/polkit/polkitlocalbackend.c
deleted file mode 100644 (file)
index 9947a8c..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-/* -*- 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 <string.h>
-#include "polkiterror.h"
-#include "polkitlocalbackend.h"
-#include "polkitserialization.h" /* TODO: remove */
-
-/**
- * SECTION:polkitlocalbackend
- * @short_description: Backend using local files
- * @include: polkit/polkit.h
- *
- * The #PolkitLocalBackend class is an implementation of
- * #PolkitBackend that stores authorizations on the local file
- * system.
- */
-
-struct _PolkitLocalBackendPrivate
-{
-        int stuff;
-};
-
-static gchar *say_hello (PolkitBackend        *_backend,
-                         PolkitSubject        *inquirer,
-                         const gchar          *name,
-                         GError              **error);
-
-static PolkitAuthorizationResult check_claims (PolkitBackend       *_backend,
-                                               PolkitSubject       *inquirer,
-                                               GList               *claims,
-                                               GError             **error);
-
-G_DEFINE_TYPE (PolkitLocalBackend, polkit_local_backend, POLKIT_TYPE_BACKEND);
-
-#define POLKIT_LOCAL_BACKEND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), POLKIT_TYPE_LOCAL_BACKEND, PolkitLocalBackendPrivate))
-
-static void
-polkit_local_backend_finalize (GObject *object)
-{
-        PolkitLocalBackend *local_backend;
-
-        local_backend = POLKIT_LOCAL_BACKEND (object);
-
-        G_OBJECT_CLASS (polkit_local_backend_parent_class)->finalize (object);
-}
-
-static void
-polkit_local_backend_class_init (PolkitLocalBackendClass *klass)
-{
-        GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-        PolkitBackendClass *backend_class = POLKIT_BACKEND_CLASS (klass);
-
-        backend_class->say_hello        = say_hello;
-        backend_class->check_claims     = check_claims;
-
-        gobject_class->finalize = polkit_local_backend_finalize;
-
-        g_type_class_add_private (klass, sizeof (PolkitLocalBackendPrivate));
-}
-
-static void
-polkit_local_backend_init (PolkitLocalBackend *local_backend)
-{
-        local_backend->priv = POLKIT_LOCAL_BACKEND_GET_PRIVATE (local_backend);
-}
-
-PolkitBackend *
-polkit_local_backend_new (void)
-{
-        PolkitBackend *backend;
-
-        backend = POLKIT_BACKEND (g_object_new (POLKIT_TYPE_LOCAL_BACKEND, NULL));
-
-        return backend;
-}
-
-static gchar *
-say_hello (PolkitBackend        *_backend,
-           PolkitSubject        *inquirer,
-           const gchar          *name,
-           GError              **error)
-{
-        char *ret;
-
-        ret = NULL;
-
-        if (strcmp (name, "davidz") == 0) {
-                g_set_error_literal (error,
-                                     POLKIT_ERROR,
-                                     POLKIT_ERROR_NOT_SUPPORTED,
-                                     "We don't want to async greet davidz!");
-        } else {
-                ret = g_strdup_printf ("Local async greets 'Hi %s!'", name);
-        }
-
-        return ret;
-}
-
-PolkitAuthorizationResult
-check_claims (PolkitBackend       *_backend,
-              PolkitSubject       *inquirer,
-              GList               *claims,
-              GError             **error)
-{
-        PolkitLocalBackend *backend;
-        PolkitAuthorizationResult result;
-        GList *l;
-
-        backend = POLKIT_LOCAL_BACKEND (_backend);
-
-        for (l = claims; l != NULL; l = l->next) {
-                PolkitAuthorizationClaim *claim = POLKIT_AUTHORIZATION_CLAIM (l->data);
-                char *action_id;
-                PolkitSubject *subject;
-                GHashTable *attributes;
-                GHashTableIter iter;
-                const char *key;
-                const char *value;
-
-                g_object_get (claim,
-                              "subject", &subject,
-                              "action-id", &action_id,
-                              "attributes", &attributes,
-                              NULL);
-
-                g_print ("action-id: %s\n", action_id);
-                g_print ("subject:   %s\n", _subject_to_string (subject));
-
-                g_hash_table_iter_init (&iter, attributes);
-                while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &value)) {
-                        g_print ("  '%s' -> '%s'\n", key, value);
-                }
-
-                g_print ("\n");
-
-                g_object_unref (subject);
-                g_free (action_id);
-                g_hash_table_unref (attributes);
-        }
-
-        /* TODO */
-        result = POLKIT_AUTHORIZATION_RESULT_AUTHORIZED;
-
-        return result;
-}
diff --git a/src/polkit/polkitlocalbackend.h b/src/polkit/polkitlocalbackend.h
deleted file mode 100644 (file)
index ccfd815..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/* -*- 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>
- */
-
-#if !defined (_POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H)
-#error "Only <polkit/polkit.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef __POLKIT_LOCAL_BACKEND_H
-#define __POLKIT_LOCAL_BACKEND_H
-
-#include <polkit/polkitbackend.h>
-
-G_BEGIN_DECLS
-
-#define POLKIT_TYPE_LOCAL_BACKEND         (polkit_local_backend_get_type ())
-#define POLKIT_LOCAL_BACKEND(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_TYPE_LOCAL_BACKEND, PolkitLocalBackend))
-#define POLKIT_LOCAL_BACKEND_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST ((k), POLKIT_TYPE_LOCAL_BACKEND, PolkitLocalBackendClass))
-#define POLKIT_LOCAL_BACKEND_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_TYPE_LOCAL_BACKEND,PolkitLocalBackendClass))
-#define POLKIT_IS_LOCAL_BACKEND(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_TYPE_LOCAL_BACKEND))
-#define POLKIT_IS_LOCAL_BACKEND_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_TYPE_LOCAL_BACKEND))
-
-typedef struct _PolkitLocalBackend        PolkitLocalBackend;
-typedef struct _PolkitLocalBackendClass   PolkitLocalBackendClass;
-typedef struct _PolkitLocalBackendPrivate PolkitLocalBackendPrivate;
-
-struct _PolkitLocalBackend
-{
-        PolkitBackend              parent_instance;
-
-        /*< private >*/
-        PolkitLocalBackendPrivate *priv;
-};
-
-struct _PolkitLocalBackendClass
-{
-        PolkitBackendClass parent_class;
-};
-
-GType           polkit_local_backend_get_type  (void) G_GNUC_CONST;
-PolkitBackend  *polkit_local_backend_new       (void);
-
-G_END_DECLS
-
-#endif /* __POLKIT_LOCAL_BACKEND_H */
-
diff --git a/src/polkit/polkitserialization.c b/src/polkit/polkitserialization.c
deleted file mode 100644 (file)
index 1ab3043..0000000
+++ /dev/null
@@ -1,251 +0,0 @@
-/* -*- 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 <stdlib.h>
-#include <string.h>
-#include <dbus/dbus-glib.h>
-
-#include <polkit/polkitserialization.h>
-#include <polkit/polkituser.h>
-#include <polkit/polkitprocess.h>
-
-PolkitAuthorizationResult
-_authorization_result_from_string (const char *str)
-{
-        PolkitAuthorizationResult ret;
-
-        g_return_val_if_fail (str != NULL, POLKIT_AUTHORIZATION_RESULT_NOT_AUTHORIZED);
-
-        ret = POLKIT_AUTHORIZATION_RESULT_NOT_AUTHORIZED;
-
-        if (strcmp (str, "authorized") == 0) {
-                ret = POLKIT_AUTHORIZATION_RESULT_AUTHORIZED;
-        } else if (strcmp (str, "challenge") == 0) {
-                ret = POLKIT_AUTHORIZATION_RESULT_CHALLENGE;
-        } else if (strcmp (str, "notauthorized") == 0) {
-                ret = POLKIT_AUTHORIZATION_RESULT_NOT_AUTHORIZED;
-        } else {
-                g_warning ("unknown authorization result string '%s'", str);
-        }
-
-        return ret;
-}
-
-char *
-_authorization_result_to_string (PolkitAuthorizationResult result)
-{
-        char *ret;
-
-        switch (result) {
-        case POLKIT_AUTHORIZATION_RESULT_AUTHORIZED:
-                ret = g_strdup ("authorized");
-                break;
-        case POLKIT_AUTHORIZATION_RESULT_CHALLENGE:
-                ret = g_strdup ("challenge");
-                break;
-        default:
-                g_warning ("unknown authorization result with code %d", result);
-                /* explicit fallthrough */
-        case POLKIT_AUTHORIZATION_RESULT_NOT_AUTHORIZED:
-                ret = g_strdup ("notauthorized");
-                break;
-        }
-
-        return ret;
-}
-
-PolkitSubject *
-_subject_from_string (const char *str)
-{
-        PolkitSubject *subject;
-
-        g_return_val_if_fail (str != NULL, NULL);
-
-        subject = NULL;
-
-        if (g_str_has_prefix (str, "user:")) {
-                subject = polkit_user_new (str + sizeof ("user:") - 1);
-        } else if (g_str_has_prefix (str, "process:")) {
-                pid_t pid;
-                pid = (pid_t) (atoi (str + sizeof ("process:") - 1));
-                subject = polkit_process_new ((pid));
-        } else {
-                g_warning ("Please add support for deserializing strings of form '%s'", str);
-        }
-
-        return subject;
-}
-
-char *
-_subject_to_string (PolkitSubject *subject)
-{
-        char *ret;
-
-        g_return_val_if_fail (POLKIT_IS_SUBJECT (subject), NULL);
-
-        ret = NULL;
-
-        if (POLKIT_IS_USER (subject)) {
-                char *s;
-                s = polkit_user_get_user_name (POLKIT_USER (subject));
-                ret = g_strdup_printf ("user:%s", s);
-                g_free (s);
-        } else if (POLKIT_IS_PROCESS (subject)) {
-                pid_t pid;
-                pid = polkit_process_get_pid (POLKIT_PROCESS (subject));
-                ret = g_strdup_printf ("process:%d", pid);
-        } else {
-                g_warning ("Please add support for serializing type %s",
-                           g_type_name (G_TYPE_FROM_INSTANCE (subject)));
-        }
-
-        return ret;
-}
-
-
-#define CLAIM_STRUCT_TYPE (dbus_g_type_get_struct ("GValueArray",     \
-                                                   G_TYPE_STRING,     \
-                                                   G_TYPE_STRING,     \
-                                                   dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING), \
-                                                   G_TYPE_INVALID))
-
-void
-_authorization_claim_to_value (PolkitAuthorizationClaim *claim, GValue *value)
-{
-  char *action_id;
-  char *subject_str;
-  PolkitSubject *subject;
-  GHashTable *attributes;
-
-  subject = polkit_authorization_claim_get_subject (claim);
-  action_id = polkit_authorization_claim_get_action_id (claim);
-  subject_str = _subject_to_string (subject);
-
-  attributes = polkit_authorization_claim_get_attributes (claim);
-
-  g_value_init (value, CLAIM_STRUCT_TYPE);
-  g_value_take_boxed (value, dbus_g_type_specialized_construct (CLAIM_STRUCT_TYPE));
-  dbus_g_type_struct_set (value,
-                          0, subject_str,
-                          1, action_id,
-                          2, attributes,
-                          G_MAXUINT);
-
-  g_free (action_id);
-  g_free (subject_str);
-  g_object_unref (subject);
-}
-
-PolkitAuthorizationClaim *
-_authorization_claim_from_data (gpointer data)
-{
-        GValue elem0 = {0};
-        PolkitAuthorizationClaim *claim;
-        PolkitSubject *subject;
-        char *subject_str;
-        char *action_id;
-        GHashTable *attributes;
-        GHashTableIter iter;
-        const char *key;
-        const char *value;
-
-        claim = NULL;
-
-        g_value_init (&elem0, CLAIM_STRUCT_TYPE);
-        g_value_set_static_boxed (&elem0, data);
-        dbus_g_type_struct_get (&elem0,
-                                0, &subject_str,
-                                1, &action_id,
-                                2, &attributes,
-                                G_MAXUINT);
-
-        subject = _subject_from_string (subject_str);
-        if (subject == NULL)
-                goto out;
-
-        claim = polkit_authorization_claim_new (subject, action_id);
-        g_hash_table_iter_init (&iter, attributes);
-        while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &value)) {
-                polkit_authorization_claim_set_attribute (claim, key, value);
-        }
-
- out:
-        g_free (subject_str);
-        g_free (action_id);
-        if (subject != NULL)
-                g_object_unref (subject);
-        if (attributes != NULL)
-                g_hash_table_unref (attributes);
-        return claim;
-}
-
-GList *
-_serialize_ptr_array_to_obj_list (GPtrArray                   *ptr_array,
-                                  PolkitSerializeToObjectFunc  func)
-{
-        GList *ret;
-        int n;
-
-        ret = NULL;
-        for (n = 0; n < (int) ptr_array->len; n++) {
-                GObject *object;
-                object = func (ptr_array->pdata[n]);
-                if (object == NULL)
-                        goto fail;
-                ret = g_list_prepend (ret, object);
-        }
-        ret = g_list_reverse (ret);
-        return ret;
- fail:
-        g_list_foreach (ret, (GFunc) g_object_unref, NULL);
-        g_list_free (ret);
-        return NULL;
-}
-
-GPtrArray *
-_serialize_ptr_array_from_obj_list (GList                         *list,
-                                    PolkitSerializeFromObjectFunc  func)
-{
-        GPtrArray *ptr_array;
-        GList *l;
-
-        ptr_array = g_ptr_array_new ();
-        for (l = list; l != NULL; l = l->next) {
-                GObject *object = G_OBJECT (l->data);
-                GValue elem = {0};
-
-                func (object, &elem);
-
-                g_ptr_array_add (ptr_array, g_value_get_boxed (&elem));
-        }
-
-        return ptr_array;
-}
-
-void
-_free_serialized_obj_ptr_array (GPtrArray *ptr_array)
-{
-        g_ptr_array_foreach (ptr_array, (GFunc) g_value_array_free, NULL);
-        g_ptr_array_free (ptr_array, TRUE);
-}
diff --git a/src/polkit/polkitserialization.h b/src/polkit/polkitserialization.h
deleted file mode 100644 (file)
index 1ab94ed..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/* -*- 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>
- */
-
-#ifndef __POLKIT_SERIALIZATION_H
-#define __POLKIT_SERIALIZATION_H
-
-#include <polkit/polkitauthorizationclaim.h>
-#include <polkit/polkitauthorizationresult.h>
-
-typedef GObject * (*PolkitSerializeToObjectFunc) (gpointer  data);
-typedef void (*PolkitSerializeFromObjectFunc)    (GObject  *object,
-                                                  GValue   *value);
-
-
-PolkitAuthorizationResult _authorization_result_from_string   (const char                    *str);
-char *                    _authorization_result_to_string     (PolkitAuthorizationResult      result);
-PolkitSubject *           _subject_from_string                (const char                    *str);
-char *                    _subject_to_string                  (PolkitSubject                 *subject);
-void                      _authorization_claim_to_value       (PolkitAuthorizationClaim      *claim,
-                                                               GValue                        *value);
-PolkitAuthorizationClaim *_authorization_claim_from_data      (gpointer                       data);
-GList *                   _serialize_ptr_array_to_obj_list    (GPtrArray                     *ptr_array,
-                                                               PolkitSerializeToObjectFunc    func);
-GPtrArray *               _serialize_ptr_array_from_obj_list  (GList                         *list,
-                                                               PolkitSerializeFromObjectFunc  func);
-void                      _free_serialized_obj_ptr_array      (GPtrArray                     *ptr_array);
-
-
-#endif /* __POLKIT_SERIALIZATION_H */
diff --git a/src/polkitbackend/Makefile.am b/src/polkitbackend/Makefile.am
new file mode 100644 (file)
index 0000000..a08352a
--- /dev/null
@@ -0,0 +1,46 @@
+NULL =
+
+INCLUDES =                                                      \
+        -I$(top_builddir)/src                                   \
+        -I$(top_srcdir)/src                                     \
+        -DPACKAGE_LIBEXEC_DIR=\""$(libexecdir)"\"               \
+        -DPACKAGE_SYSCONF_DIR=\""$(sysconfdir)"\"               \
+        -DPACKAGE_DATA_DIR=\""$(datadir)"\"                     \
+        -DPACKAGE_BIN_DIR=\""$(bindir)"\"                       \
+        -DPACKAGE_LOCALSTATE_DIR=\""$(localstatedir)"\"         \
+        -DPACKAGE_LOCALE_DIR=\""$(localedir)"\"                 \
+        -DPACKAGE_LIB_DIR=\""$(libdir)"\"                       \
+        -D_POSIX_PTHREAD_SEMANTICS                              \
+        -D_REENTRANT                                            \
+        $(NULL)
+
+lib_LTLIBRARIES=libpolkit-backend-1.la
+
+libpolkit_backend_1includedir=$(includedir)/polkit-1/polkitbackend
+
+libpolkit_backend_1include_HEADERS =                                   \
+       polkitbackend.h                                                 \
+       polkitbackendlocal.h                                            \
+        $(NULL)
+
+libpolkit_backend_1_la_SOURCES =                                       \
+        polkitbackend.h                                                        \
+       polkitbackendlocal.h            polkitbackendlocal.c            \
+        $(NULL)
+
+libpolkit_backend_1_la_CFLAGS =                                                \
+        -D_POLKIT_BACKEND_COMPILATION                                          \
+        $(GLIB_CFLAGS)                                                 \
+        $(EGG_DBUS_CFLAGS)                                             \
+        $(NULL)
+
+libpolkit_backend_1_la_LIBADD =                                        \
+        $(GLIB_LIBS)                                                   \
+        $(EGG_DBUS_LIBS)                                               \
+       $(top_builddir)/src/polkit/libpolkit-gobject-1.la               \
+        $(NULL)
+
+CLEANFILES = $(BUILT_SOURCES)
+
+clean-local :
+       rm -f *~
diff --git a/src/polkitbackend/polkitbackend.h b/src/polkitbackend/polkitbackend.h
new file mode 100644 (file)
index 0000000..c1c3839
--- /dev/null
@@ -0,0 +1,33 @@
+/* -*- 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>
+ */
+
+#ifndef __POLKIT_BACKEND_H
+#define __POLKIT_BACKEND_H
+
+#define _POLKIT_BACKEND_INSIDE_POLKIT_BACKEND_H 1
+#include <polkitbackend/polkitbackendlocal.h>
+#undef _POLKIT_BACKEND_INSIDE_POLKIT_BACKEND_H
+
+#endif /* __POLKIT_BACKEND_H */
+
+
index 7fe92ca..f1b54dd 100644 (file)
@@ -1,36 +1,38 @@
 NULL =
 
-INCLUDES =                                                     \
-       -I$(top_builddir)/src                                   \
-       -I$(top_srcdir)/src                                     \
-       -DPACKAGE_LIBEXEC_DIR=\""$(libexecdir)"\"               \
-       -DPACKAGE_SYSCONF_DIR=\""$(sysconfdir)"\"               \
-       -DPACKAGE_DATA_DIR=\""$(datadir)"\"                     \
-       -DPACKAGE_BIN_DIR=\""$(bindir)"\"                       \
-       -DPACKAGE_LOCALSTATE_DIR=\""$(localstatedir)"\"         \
-       -DPACKAGE_LOCALE_DIR=\""$(localedir)"\"                 \
-       -DPACKAGE_LIB_DIR=\""$(libdir)"\"                       \
-       -D_POSIX_PTHREAD_SEMANTICS                              \
-       -D_REENTRANT                                            \
+INCLUDES =                                                             \
+       -I$(top_builddir)/src                                           \
+       -I$(top_srcdir)/src                                             \
+       -DPACKAGE_LIBEXEC_DIR=\""$(libexecdir)"\"                       \
+       -DPACKAGE_SYSCONF_DIR=\""$(sysconfdir)"\"                       \
+       -DPACKAGE_DATA_DIR=\""$(datadir)"\"                             \
+       -DPACKAGE_BIN_DIR=\""$(bindir)"\"                               \
+       -DPACKAGE_LOCALSTATE_DIR=\""$(localstatedir)"\"                 \
+       -DPACKAGE_LOCALE_DIR=\""$(localedir)"\"                         \
+       -DPACKAGE_LIB_DIR=\""$(libdir)"\"                               \
+       -D_POSIX_PTHREAD_SEMANTICS                                      \
+       -D_REENTRANT                                                    \
        $(NULL)
 
 libexec_PROGRAMS = polkitd-1
 
-polkitd_1_SOURCES =                                            \
-       main.c                                                  \
+polkitd_1_SOURCES =                                                    \
+       main.c                                                          \
        $(NULL)
 
-polkitd_1_CFLAGS =                                             \
-       -I$(top_srcdir)/src                                     \
-       -DG_LOG_DOMAIN=\"polkitd-1\"                            \
-       $(DBUS_GLIB_CFLAGS)                                     \
+polkitd_1_CFLAGS =                                                     \
+       -I$(top_srcdir)/src                                             \
+       -DG_LOG_DOMAIN=\"polkitd-1\"                                    \
+       $(GLIB_CFLAGS)                                                  \
+       $(EGG_DBUS_CFLAGS)                                              \
        $(NULL)
 
-polkitd_1_LDADD =                                              \
-       $(DBUS_GLIB_LIBS)                                       \
-       $(GLIB_LIBS)                                            \
-       $(GIO_LIBS)                                             \
-       $(top_builddir)/src/polkit/libpolkit-gobject-1.la       \
+polkitd_1_LDADD =                                                      \
+       $(DBUS_GLIB_LIBS)                                               \
+       $(GLIB_LIBS)                                                    \
+       $(EGG_DBUS_LIBS)                                                \
+       $(top_builddir)/src/polkit/libpolkit-gobject-1.la               \
+       $(top_builddir)/src/polkitbackend/libpolkit-backend-1.la        \
        $(NULL)
 
 CLEANFILES = $(BUILT_SOURCES)
index ab3e24f..878bb45 100644 (file)
 #  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 <fcntl.h>
-#include <pwd.h>
-#include <grp.h>
-
-#include <glib.h>
-#include <glib/gi18n-lib.h>
-#include <glib-object.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
 #include <polkit/polkit.h>
+#include <polkitbackend/polkitbackend.h>
 
-#define NAME_TO_CLAIM "org.freedesktop.PolicyKit1"
-
-static PolkitBackend *
-get_backend (void)
+static PolkitAuthority *
+get_authority_backend (void)
 {
-        return polkit_local_backend_new ();
-}
-
-static gboolean
-acquire_name_on_proxy (DBusGProxy *bus_proxy)
-{
-        GError     *error;
-        guint       result;
-        gboolean    res;
-        gboolean    ret;
-
-        ret = FALSE;
-
-        if (bus_proxy == NULL) {
-                goto out;
-        }
-
-        error = NULL;
-       res = dbus_g_proxy_call (bus_proxy,
-                                 "RequestName",
-                                 &error,
-                                 G_TYPE_STRING, NAME_TO_CLAIM,
-                                 G_TYPE_UINT, 0,
-                                 G_TYPE_INVALID,
-                                 G_TYPE_UINT, &result,
-                                 G_TYPE_INVALID);
-        if (! res) {
-                if (error != NULL) {
-                        g_warning ("Failed to acquire %s: %s", NAME_TO_CLAIM, error->message);
-                        g_error_free (error);
-                } else {
-                        g_warning ("Failed to acquire %s", NAME_TO_CLAIM);
-                }
-                goto out;
-       }
-
-       if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
-                if (error != NULL) {
-                        g_warning ("Failed to acquire %s: %s", NAME_TO_CLAIM, error->message);
-                        g_error_free (error);
-                } else {
-                        g_warning ("Failed to acquire %s", NAME_TO_CLAIM);
-                }
-                goto out;
-        }
-
-        ret = TRUE;
-
- out:
-        return ret;
+        /* TODO: use extension points etc. */
+        return POLKIT_AUTHORITY (polkit_backend_local_new ());
 }
 
 int
 main (int argc, char **argv)
 {
-        GError                *error;
-        GMainLoop             *loop;
-        GOptionContext        *context;
-        DBusGProxy            *bus_proxy;
-        DBusGConnection       *bus;
-        int                    ret;
-        PolkitBackend         *backend;
-        PolkitBackendStub     *stub;
-        static GOptionEntry    entries[] = {
-                { NULL }
-        };
+        int ret;
+        guint rn_ret;
+        GError *error;
+        GMainLoop *loop;
+        EggDBusConnection *connection;
+        PolkitAuthority *authority;
 
         ret = 1;
-        backend = NULL;
-        stub = NULL;
-        loop = NULL;
-        bus = NULL;
 
         g_type_init ();
+        polkit_bindings_register_types (); /* TODO: use __attribute ((constructor)) */
 
-        context = g_option_context_new ("PolicyKit daemon");
-        g_option_context_add_main_entries (context, entries, NULL);
-        g_option_context_parse (context, &argc, &argv, NULL);
-        g_option_context_free (context);
+        loop = g_main_loop_new (NULL, FALSE);
+        connection = egg_dbus_connection_get_for_bus (EGG_DBUS_BUS_TYPE_SYSTEM);
 
         error = NULL;
-        bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
-        if (bus == NULL) {
-                g_warning ("Couldn't connect to system bus: %s", error->message);
+        if (!egg_dbus_bus_invoke_request_name (egg_dbus_connection_get_bus_proxy (connection),
+                                               0, /* call flags */
+                                               "org.freedesktop.PolicyKit1",
+                                               0, /* flags */
+                                               &rn_ret,
+                                               NULL,
+                                               &error)) {
+                g_warning ("error: %s", error->message);
                 g_error_free (error);
                 goto out;
         }
 
-       bus_proxy = dbus_g_proxy_new_for_name (bus,
-                                               DBUS_SERVICE_DBUS,
-                                               DBUS_PATH_DBUS,
-                                               DBUS_INTERFACE_DBUS);
-        if (bus_proxy == NULL) {
-                g_warning ("Could not construct bus_proxy object; bailing out");
-                goto out;
-        }
-
-        if (!acquire_name_on_proxy (bus_proxy) ) {
-                g_warning ("Could not acquire name; bailing out");
-                goto out;
-        }
-
-        g_debug ("Starting polkitd-1 version %s", VERSION);
-
-        backend = get_backend ();
-        if (backend == NULL) {
-                g_warning ("Couldn't find suitable backend to use");
+        if (rn_ret != 1) {
+                g_warning ("could not become primary name owner");
                 goto out;
         }
 
-        stub = polkit_backend_stub_new (bus,
-                                        "/authority",
-                                        backend);
+        authority = get_authority_backend ();
 
-        if (stub == NULL) {
-                goto out;
-        }
-
-        loop = g_main_loop_new (NULL, FALSE);
+        egg_dbus_connection_export_object (connection,
+                                           G_OBJECT (authority),
+                                           "/org/freedesktop/PolicyKit1/Authority");
 
         g_main_loop_run (loop);
+        g_object_unref (authority);
+        g_object_unref (connection);
 
         ret = 0;
 
-out:
-        if (backend != NULL)
-                g_object_unref (backend);
-
-        if (stub != NULL)
-                g_object_unref (stub);
-
-        if (loop != NULL)
-                g_main_loop_unref (loop);
-
-        if (bus != NULL)
-                dbus_g_connection_unref (bus);
-
+ out:
         return ret;
 }
index 8ba3fe5..b6a83cb 100644 (file)
@@ -21,14 +21,12 @@ polkit_verify_claim_1_SOURCES = polkit-verify-claim.c
 
 polkit_verify_claim_1_CFLAGS =                                 \
        $(GLIB_CFLAGS)                                          \
-       $(GIO_CFLAGS)                                           \
-       $(DBUS_GLIB_CFLAGS)                                     \
+       $(EGG_DBUS_CFLAGS)                                      \
        $(NULL)
 
 polkit_verify_claim_1_LDADD =                                          \
        $(GLIB_LDADD)                                           \
-       $(GIO_LDADD)                                            \
-       $(DBUS_GLIB_LDADD)                                      \
+       $(EGG_DBUS_LDADD)                                       \
        $(top_builddir)/src/polkit/libpolkit-gobject-1.la       \
        $(NULL)
 
index 36ad439..2c07fb3 100644 (file)
 int
 main (int argc, char *argv[])
 {
-        GList *ret;
         GError *error;
-        GFile *dir;
+        PolkitAuthority *authority;
+        gchar *result;
 
         g_type_init ();
 
-        dir = g_file_new_for_commandline_arg (argv[1]);
+        authority = polkit_authority_get ();
 
         error = NULL;
-        ret = polkit_action_description_new_from_directory (dir,
-                                                            NULL,
-                                                            &error);
-        if (error != NULL) {
-                g_print ("Got error: %s\n", error->message);
-                g_error_free (error);
-                goto out;
-        }
-
-        g_debug ("rock'n'roll!");
+        polkit_authority_invoke_say_hello (authority,
+                                           0, /* call_flags */
+                                           "Hi there!",
+                                           &result,
+                                           NULL,
+                                           &error);
+        g_print ("Authority replied: %s\n", result);
+        g_free (result);
 
-        g_list_foreach (ret, (GFunc) g_object_unref, NULL);
-        g_list_free (ret);
+        g_object_unref (authority);
 
- out:
         return 0;
+}
 
-#if 0
-        PolkitAuthorizationResult result;
-        GError *error;
-        PolkitAuthority *authority;
-
-        g_type_init ();
-
-        authority = polkit_authority_get ();
 
+#if 0
         PolkitSubject *subject1;
         PolkitSubject *subject2;
         PolkitSubject *subject3;
@@ -94,8 +84,4 @@ main (int argc, char *argv[])
                 g_print ("Got result: %d\n", result);
         }
 
-        g_object_unref (authority);
-
-         return 0;
 #endif
-}