Commit a18f3dcb authored by David Zeuthen's avatar David Zeuthen

rework backend API

parent 1581cff1
......@@ -54,7 +54,6 @@ libpolkit_backend_1include_HEADERS = \
polkitbackendauthority.h \
polkitbackendlocalauthority.h \
polkitbackendactionpool.h \
polkitbackendpendingcall.h \
polkitbackendsessionmonitor.h \
$(NULL)
......@@ -65,7 +64,6 @@ libpolkit_backend_1_la_SOURCES = \
polkitbackendauthority.h polkitbackendauthority.c \
polkitbackendlocalauthority.h polkitbackendlocalauthority.c \
polkitbackendactionpool.h polkitbackendactionpool.c \
polkitbackendpendingcall.h polkitbackendpendingcall.c \
polkitbackendsessionmonitor.h polkitbackendsessionmonitor.c \
$(BUILT_SOURCES) \
$(NULL)
......
......@@ -24,7 +24,6 @@
#define _POLKIT_BACKEND_INSIDE_POLKIT_BACKEND_H 1
#include <polkitbackend/polkitbackendtypes.h>
#include <polkitbackend/polkitbackendpendingcall.h>
#include <polkitbackend/polkitbackendauthority.h>
#include <polkitbackend/polkitbackendlocalauthority.h>
#include <polkitbackend/polkitbackendactionpool.h>
......
This diff is collapsed.
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>
*/
#include "config.h"
#include <polkit/polkit.h>
#include "polkitbackendpendingcall.h"
#include "polkitbackendprivate.h"
typedef struct
{
EggDBusMethodInvocation *method_invocation;
PolkitSubject *inquirer;
} PolkitBackendPendingCallPrivate;
G_DEFINE_TYPE (PolkitBackendPendingCall, polkit_backend_pending_call, G_TYPE_OBJECT);
#define POLKIT_BACKEND_PENDING_CALL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), POLKIT_BACKEND_TYPE_PENDING_CALL, PolkitBackendPendingCallPrivate))
static void
polkit_backend_pending_call_init (PolkitBackendPendingCall *pending_call)
{
PolkitBackendPendingCallPrivate *priv;
priv = POLKIT_BACKEND_PENDING_CALL_GET_PRIVATE (pending_call);
}
static void
polkit_backend_pending_call_finalize (GObject *object)
{
PolkitBackendPendingCall *pending_call;
PolkitBackendPendingCallPrivate *priv;
pending_call = POLKIT_BACKEND_PENDING_CALL (object);
priv = POLKIT_BACKEND_PENDING_CALL_GET_PRIVATE (pending_call);
g_object_unref (priv->method_invocation);
if (priv->inquirer != NULL)
g_object_unref (priv->inquirer);
G_OBJECT_CLASS (polkit_backend_pending_call_parent_class)->finalize (object);
}
static void
polkit_backend_pending_call_class_init (PolkitBackendPendingCallClass *klass)
{
GObjectClass *gobject_class;
gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = polkit_backend_pending_call_finalize;
g_type_class_add_private (klass, sizeof (PolkitBackendPendingCallPrivate));
}
PolkitBackendPendingCall *
_polkit_backend_pending_call_new (EggDBusMethodInvocation *method_invocation)
{
PolkitBackendPendingCall *pending_call;
PolkitBackendPendingCallPrivate *priv;
pending_call = POLKIT_BACKEND_PENDING_CALL (g_object_new (POLKIT_BACKEND_TYPE_PENDING_CALL,
NULL));
priv = POLKIT_BACKEND_PENDING_CALL_GET_PRIVATE (pending_call);
priv->method_invocation = g_object_ref (method_invocation);
return pending_call;
}
EggDBusMethodInvocation *
_polkit_backend_pending_call_get_method_invocation (PolkitBackendPendingCall *pending_call)
{
PolkitBackendPendingCallPrivate *priv;
priv = POLKIT_BACKEND_PENDING_CALL_GET_PRIVATE (pending_call);
return priv->method_invocation;
}
PolkitSubject *
polkit_backend_pending_call_get_caller (PolkitBackendPendingCall *pending_call)
{
PolkitBackendPendingCallPrivate *priv;
priv = POLKIT_BACKEND_PENDING_CALL_GET_PRIVATE (pending_call);
if (priv->inquirer != NULL)
goto out;
priv->inquirer = polkit_system_bus_name_new (egg_dbus_method_invocation_get_caller (priv->method_invocation));
out:
return priv->inquirer;
}
void
polkit_backend_pending_call_return_gerror (PolkitBackendPendingCall *pending_call,
GError *error)
{
PolkitBackendPendingCallPrivate *priv;
priv = POLKIT_BACKEND_PENDING_CALL_GET_PRIVATE (pending_call);
egg_dbus_method_invocation_return_gerror (priv->method_invocation,
error);
g_object_unref (pending_call);
}
void
polkit_backend_pending_call_return_error (PolkitBackendPendingCall *pending_call,
GQuark domain,
gint code,
const gchar *format,
...)
{
GError *error;
va_list va_args;
gchar *literal_message;
va_start (va_args, format);
literal_message = g_strdup_vprintf (format, va_args);
error = g_error_new_literal (domain,
code,
literal_message);
polkit_backend_pending_call_return_gerror (pending_call, error);
g_error_free (error);
g_free (literal_message);
va_end (va_args);
}
/*
* 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_PENDING_CALL_H
#define __POLKIT_BACKEND_PENDING_CALL_H
#include <glib-object.h>
#include "polkitbackendtypes.h"
G_BEGIN_DECLS
#define POLKIT_BACKEND_TYPE_PENDING_CALL (polkit_backend_pending_call_get_type ())
#define POLKIT_BACKEND_PENDING_CALL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_BACKEND_TYPE_PENDING_CALL, PolkitBackendPendingCall))
#define POLKIT_BACKEND_PENDING_CALL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), POLKIT_BACKEND_TYPE_PENDING_CALL, PolkitBackendPendingCallClass))
#define POLKIT_BACKEND_PENDING_CALL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_BACKEND_TYPE_PENDING_CALL,PolkitBackendPendingCallClass))
#define POLKIT_BACKEND_IS_PENDING_CALL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_BACKEND_TYPE_PENDING_CALL))
#define POLKIT_BACKEND_IS_PENDING_CALL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_BACKEND_TYPE_PENDING_CALL))
#if 0
typedef struct _PolkitBackendPendingCall PolkitBackendPendingCall;
#endif
typedef struct _PolkitBackendPendingCallClass PolkitBackendPendingCallClass;
struct _PolkitBackendPendingCall
{
GObject parent_instance;
};
struct _PolkitBackendPendingCallClass
{
GObjectClass parent_class;
/*< public >*/
/*< 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_pending_call_get_type (void) G_GNUC_CONST;
PolkitSubject *polkit_backend_pending_call_get_caller (PolkitBackendPendingCall *pending_call);
void polkit_backend_pending_call_return_error (PolkitBackendPendingCall *pending_call,
GQuark domain,
gint code,
const gchar *format,
...);
void polkit_backend_pending_call_return_gerror (PolkitBackendPendingCall *pending_call,
GError *error);
G_END_DECLS
#endif /* __POLKIT_BACKEND_PENDING_CALL_H */
......@@ -23,10 +23,5 @@
#define __POLKIT_BACKEND_PRIVATE_H
#include <polkit/_polkitbindings.h>
#include "polkitbackendpendingcall.h"
PolkitBackendPendingCall *_polkit_backend_pending_call_new (EggDBusMethodInvocation *method_invocation);
EggDBusMethodInvocation *_polkit_backend_pending_call_get_method_invocation (PolkitBackendPendingCall *pending_call);
#endif /* __POLKIT_BACKEND_PRIVATE_H */
......@@ -30,9 +30,6 @@ typedef struct _PolkitBackendAuthority PolkitBackendAuthority;
struct _PolkitBackendLocalAuthority;
typedef struct _PolkitBackendLocalAuthority PolkitBackendLocalAuthority;
struct _PolkitBackendPendingCall;
typedef struct _PolkitBackendPendingCall PolkitBackendPendingCall;
struct _PolkitBackendSessionMonitor;
typedef struct _PolkitBackendSessionMonitor PolkitBackendSessionMonitor;
......
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