Commit 5977ce75 authored by David Zeuthen's avatar David Zeuthen

replace PolkitBackendServer with polkit_backend_register_authority()

This is consistent with how the PolkitAgentListener API works.
parent 5326cc0a
......@@ -83,7 +83,6 @@
<xi:include href="../polkitbackend/xml/polkitbackendauthority.xml"/>
<xi:include href="../polkitbackend/xml/polkitbackendlocalauthority.xml"/>
<xi:include href="../polkitbackend/xml/polkitbackendactionpool.xml"/>
<xi:include href="../polkitbackend/xml/polkitbackendserver.xml"/>
<xi:include href="../polkitbackend/xml/polkitbackendsessionmonitor.xml"/>
</reference>
......
......@@ -55,7 +55,6 @@ libpolkit_backend_1include_HEADERS = \
polkitbackendlocalauthority.h \
polkitbackendactionpool.h \
polkitbackendpendingcall.h \
polkitbackendserver.h \
polkitbackendsessionmonitor.h \
$(NULL)
......@@ -67,7 +66,6 @@ libpolkit_backend_1_la_SOURCES = \
polkitbackendlocalauthority.h polkitbackendlocalauthority.c \
polkitbackendactionpool.h polkitbackendactionpool.c \
polkitbackendpendingcall.h polkitbackendpendingcall.c \
polkitbackendserver.h polkitbackendserver.c \
polkitbackendsessionmonitor.h polkitbackendsessionmonitor.c \
$(BUILT_SOURCES) \
$(NULL)
......
......@@ -28,7 +28,6 @@
#include <polkitbackend/polkitbackendauthority.h>
#include <polkitbackend/polkitbackendlocalauthority.h>
#include <polkitbackend/polkitbackendactionpool.h>
#include <polkitbackend/polkitbackendserver.h>
#include <polkitbackend/polkitbackendsessionmonitor.h>
#undef _POLKIT_BACKEND_INSIDE_POLKIT_BACKEND_H
......
This diff is collapsed.
......@@ -196,6 +196,11 @@ void polkit_backend_authority_unregister_authentication_agent_finish (Polkit
void polkit_backend_authority_authentication_agent_response_finish (PolkitBackendPendingCall *pending_call);
gboolean polkit_backend_register_authority (PolkitBackendAuthority *authority,
const gchar *well_known_name,
const gchar *object_path,
GError **error);
G_END_DECLS
#endif /* __POLKIT_BACKEND_AUTHORITY_H */
......
......@@ -28,7 +28,6 @@
typedef struct
{
EggDBusMethodInvocation *method_invocation;
PolkitBackendServer *server;
PolkitSubject *inquirer;
} PolkitBackendPendingCallPrivate;
......@@ -55,7 +54,6 @@ polkit_backend_pending_call_finalize (GObject *object)
priv = POLKIT_BACKEND_PENDING_CALL_GET_PRIVATE (pending_call);
g_object_unref (priv->method_invocation);
g_object_unref (priv->server);
if (priv->inquirer != NULL)
g_object_unref (priv->inquirer);
......@@ -76,8 +74,7 @@ polkit_backend_pending_call_class_init (PolkitBackendPendingCallClass *klass)
}
PolkitBackendPendingCall *
_polkit_backend_pending_call_new (EggDBusMethodInvocation *method_invocation,
PolkitBackendServer *server)
_polkit_backend_pending_call_new (EggDBusMethodInvocation *method_invocation)
{
PolkitBackendPendingCall *pending_call;
PolkitBackendPendingCallPrivate *priv;
......@@ -88,19 +85,10 @@ _polkit_backend_pending_call_new (EggDBusMethodInvocation *method_invocation,
priv = POLKIT_BACKEND_PENDING_CALL_GET_PRIVATE (pending_call);
priv->method_invocation = g_object_ref (method_invocation);
priv->server = g_object_ref (server);
return pending_call;
}
PolkitBackendServer *
polkit_backend_pending_call_get_server (PolkitBackendPendingCall *pending_call)
{
PolkitBackendPendingCallPrivate *priv;
priv = POLKIT_BACKEND_PENDING_CALL_GET_PRIVATE (pending_call);
return priv->server;
}
EggDBusMethodInvocation *
_polkit_backend_pending_call_get_method_invocation (PolkitBackendPendingCall *pending_call)
{
......
......@@ -68,7 +68,6 @@ struct _PolkitBackendPendingCallClass
GType polkit_backend_pending_call_get_type (void) G_GNUC_CONST;
PolkitSubject *polkit_backend_pending_call_get_caller (PolkitBackendPendingCall *pending_call);
PolkitBackendServer *polkit_backend_pending_call_get_server (PolkitBackendPendingCall *pending_call);
void polkit_backend_pending_call_return_error (PolkitBackendPendingCall *pending_call,
GQuark domain,
gint code,
......
......@@ -24,10 +24,8 @@
#include <polkit/_polkitbindings.h>
#include "polkitbackendpendingcall.h"
#include "polkitbackendserver.h"
PolkitBackendPendingCall *_polkit_backend_pending_call_new (EggDBusMethodInvocation *method_invocation,
PolkitBackendServer *server);
PolkitBackendPendingCall *_polkit_backend_pending_call_new (EggDBusMethodInvocation *method_invocation);
EggDBusMethodInvocation *_polkit_backend_pending_call_get_method_invocation (PolkitBackendPendingCall *pending_call);
......
This diff is collapsed.
/*
* 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_BACKEND_COMPILATION) && !defined(_POLKIT_BACKEND_INSIDE_POLKIT_BACKEND_H)
#error "Only <polkitbackend/polkitbackend.h> can be included directly, this file may disappear or change contents."
#endif
#ifndef __POLKIT_BACKEND_SERVER_H
#define __POLKIT_BACKEND_SERVER_H
#include <glib-object.h>
#include "polkitbackendtypes.h"
G_BEGIN_DECLS
#define POLKIT_BACKEND_TYPE_SERVER (polkit_backend_server_get_type ())
#define POLKIT_BACKEND_SERVER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_BACKEND_TYPE_SERVER, PolkitBackendServer))
#define POLKIT_BACKEND_SERVER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), POLKIT_BACKEND_TYPE_SERVER, PolkitBackendServerClass))
#define POLKIT_BACKEND_SERVER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_BACKEND_TYPE_SERVER,PolkitBackendServerClass))
#define POLKIT_BACKEND_IS_SERVER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_BACKEND_TYPE_SERVER))
#define POLKIT_BACKEND_IS_SERVER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_BACKEND_TYPE_SERVER))
#if 0
typedef struct _PolkitBackendServer PolkitBackendServer;
#endif
typedef struct _PolkitBackendServerClass PolkitBackendServerClass;
GType polkit_backend_server_get_type (void) G_GNUC_CONST;
PolkitBackendServer *polkit_backend_server_new (PolkitBackendAuthority *authority);
G_END_DECLS
#endif /* __POLKIT_BACKEND_SERVER_H */
......@@ -33,9 +33,6 @@ typedef struct _PolkitBackendLocalAuthority PolkitBackendLocalAuthority;
struct _PolkitBackendPendingCall;
typedef struct _PolkitBackendPendingCall PolkitBackendPendingCall;
struct _PolkitBackendServer;
typedef struct _PolkitBackendServer PolkitBackendServer;
struct _PolkitBackendSessionMonitor;
typedef struct _PolkitBackendSessionMonitor PolkitBackendSessionMonitor;
......
......@@ -12,7 +12,6 @@ INCLUDES = \
-DPACKAGE_LIB_DIR=\""$(libdir)"\" \
-D_POSIX_PTHREAD_SEMANTICS \
-D_REENTRANT \
-DEGG_DBUS_I_KNOW_API_IS_SUBJECT_TO_CHANGE \
$(NULL)
libexec_PROGRAMS = polkitd-1
......@@ -25,13 +24,11 @@ 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) \
$(EGG_DBUS_LIBS) \
$(top_builddir)/src/polkit/libpolkit-gobject-1.la \
$(top_builddir)/src/polkitbackend/libpolkit-backend-1.la \
$(NULL)
......
......@@ -24,75 +24,47 @@
#endif
#include <polkit/polkit.h>
#include <polkit/polkitprivate.h>
#include <polkitbackend/polkitbackend.h>
static _PolkitAuthority *
static PolkitBackendAuthority *
get_authority_backend (void)
{
PolkitBackendAuthority *authority;
PolkitBackendServer *server;
/* TODO: use extension points etc. */
authority = polkit_backend_local_authority_new ();
server = polkit_backend_server_new (authority);
g_object_unref (authority);
return _POLKIT_AUTHORITY (server);
return authority;
}
int
main (int argc, char **argv)
{
int ret;
guint rn_ret;
GError *error;
GMainLoop *loop;
EggDBusConnection *connection;
_PolkitAuthority *authority;
PolkitBackendAuthority *authority;
ret = 1;
error = NULL;
authority = NULL;
connection = NULL;
g_type_init ();
loop = g_main_loop_new (NULL, FALSE);
connection = egg_dbus_connection_get_for_bus (EGG_DBUS_BUS_TYPE_SYSTEM);
error = NULL;
if (!egg_dbus_bus_request_name_sync (egg_dbus_connection_get_bus (connection),
EGG_DBUS_CALL_FLAGS_NONE,
"org.freedesktop.PolicyKit1",
EGG_DBUS_REQUEST_NAME_FLAGS_NONE,
&rn_ret,
NULL,
&error))
{
g_warning ("error: %s", error->message);
g_error_free (error);
goto out;
}
authority = get_authority_backend ();
if (rn_ret != 1)
if (!polkit_backend_register_authority (authority,
"org.freedesktop.PolicyKit1",
"/org/freedesktop/PolicyKit1/Authority",
&error))
{
g_warning ("could not become primary name owner");
g_printerr ("Error registering authority: %s", error->message);
g_error_free (error);
goto out;
}
authority = get_authority_backend ();
egg_dbus_connection_register_interface (connection,
"/org/freedesktop/PolicyKit1/Authority",
_POLKIT_TYPE_AUTHORITY,
G_OBJECT (authority),
_POLKIT_TYPE_AUTHORITY_MANAGER,
G_OBJECT (authority),
G_TYPE_INVALID);
g_main_loop_run (loop);
ret = 0;
......@@ -100,7 +72,5 @@ main (int argc, char **argv)
out:
if (authority != NULL)
g_object_unref (authority);
if (connection != NULL)
g_object_unref (connection);
return ret;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment