mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2026-05-07 13:08:06 +02:00
trivial: DkpPolkit -> UpPolkit (no ABI or API break)
This commit is contained in:
parent
25e51c9613
commit
6845dc144d
5 changed files with 74 additions and 74 deletions
|
|
@ -71,7 +71,7 @@ struct UpDaemonPrivate
|
|||
{
|
||||
DBusGConnection *connection;
|
||||
DBusGProxy *proxy;
|
||||
DkpPolkit *polkit;
|
||||
UpPolkit *polkit;
|
||||
UpBackend *backend;
|
||||
UpDeviceList *power_devices;
|
||||
gboolean on_battery;
|
||||
|
|
@ -514,11 +514,11 @@ up_daemon_suspend (UpDaemon *daemon, DBusGMethodInvocation *context)
|
|||
goto out;
|
||||
}
|
||||
|
||||
subject = dkp_polkit_get_subject (daemon->priv->polkit, context);
|
||||
subject = up_polkit_get_subject (daemon->priv->polkit, context);
|
||||
if (subject == NULL)
|
||||
goto out;
|
||||
|
||||
if (!dkp_polkit_check_auth (daemon->priv->polkit, subject, "org.freedesktop.devicekit.power.suspend", context))
|
||||
if (!up_polkit_check_auth (daemon->priv->polkit, subject, "org.freedesktop.devicekit.power.suspend", context))
|
||||
goto out;
|
||||
|
||||
ret = g_spawn_command_line_sync ("/usr/sbin/pm-suspend", &stdout, &stderr, NULL, &error_local);
|
||||
|
|
@ -582,11 +582,11 @@ up_daemon_hibernate (UpDaemon *daemon, DBusGMethodInvocation *context)
|
|||
goto out;
|
||||
}
|
||||
|
||||
subject = dkp_polkit_get_subject (daemon->priv->polkit, context);
|
||||
subject = up_polkit_get_subject (daemon->priv->polkit, context);
|
||||
if (subject == NULL)
|
||||
goto out;
|
||||
|
||||
if (!dkp_polkit_check_auth (daemon->priv->polkit, subject, "org.freedesktop.devicekit.power.hibernate", context))
|
||||
if (!up_polkit_check_auth (daemon->priv->polkit, subject, "org.freedesktop.devicekit.power.hibernate", context))
|
||||
goto out;
|
||||
|
||||
ret = g_spawn_command_line_sync ("/usr/sbin/pm-hibernate", &stdout, &stderr, NULL, &error_local);
|
||||
|
|
@ -890,7 +890,7 @@ up_daemon_init (UpDaemon *daemon)
|
|||
gfloat waterline;
|
||||
|
||||
daemon->priv = UP_DAEMON_GET_PRIVATE (daemon);
|
||||
daemon->priv->polkit = dkp_polkit_new ();
|
||||
daemon->priv->polkit = up_polkit_new ();
|
||||
daemon->priv->lid_is_present = FALSE;
|
||||
daemon->priv->lid_is_closed = FALSE;
|
||||
daemon->priv->kernel_can_suspend = FALSE;
|
||||
|
|
|
|||
|
|
@ -35,22 +35,22 @@
|
|||
#include "up-polkit.h"
|
||||
#include "up-daemon.h"
|
||||
|
||||
#define DKP_POLKIT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DKP_TYPE_POLKIT, DkpPolkitPrivate))
|
||||
#define UP_POLKIT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_POLKIT, UpPolkitPrivate))
|
||||
|
||||
struct DkpPolkitPrivate
|
||||
struct UpPolkitPrivate
|
||||
{
|
||||
DBusGConnection *connection;
|
||||
PolkitAuthority *authority;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (DkpPolkit, dkp_polkit, G_TYPE_OBJECT)
|
||||
static gpointer dkp_polkit_object = NULL;
|
||||
G_DEFINE_TYPE (UpPolkit, up_polkit, G_TYPE_OBJECT)
|
||||
static gpointer up_polkit_object = NULL;
|
||||
|
||||
/**
|
||||
* dkp_polkit_get_subject:
|
||||
* up_polkit_get_subject:
|
||||
**/
|
||||
PolkitSubject *
|
||||
dkp_polkit_get_subject (DkpPolkit *polkit, DBusGMethodInvocation *context)
|
||||
up_polkit_get_subject (UpPolkit *polkit, DBusGMethodInvocation *context)
|
||||
{
|
||||
const gchar *sender;
|
||||
PolkitSubject *subject;
|
||||
|
|
@ -62,10 +62,10 @@ dkp_polkit_get_subject (DkpPolkit *polkit, DBusGMethodInvocation *context)
|
|||
}
|
||||
|
||||
/**
|
||||
* dkp_polkit_check_auth:
|
||||
* up_polkit_check_auth:
|
||||
**/
|
||||
gboolean
|
||||
dkp_polkit_check_auth (DkpPolkit *polkit, PolkitSubject *subject, const gchar *action_id, DBusGMethodInvocation *context)
|
||||
up_polkit_check_auth (UpPolkit *polkit, PolkitSubject *subject, const gchar *action_id, DBusGMethodInvocation *context)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GError *error;
|
||||
|
|
@ -97,10 +97,10 @@ out:
|
|||
}
|
||||
|
||||
/**
|
||||
* dkp_polkit_get_uid:
|
||||
* up_polkit_get_uid:
|
||||
**/
|
||||
gboolean
|
||||
dkp_polkit_get_uid (DkpPolkit *polkit, PolkitSubject *subject, uid_t *uid)
|
||||
up_polkit_get_uid (UpPolkit *polkit, PolkitSubject *subject, uid_t *uid)
|
||||
{
|
||||
DBusConnection *connection;
|
||||
const gchar *name;
|
||||
|
|
@ -117,10 +117,10 @@ dkp_polkit_get_uid (DkpPolkit *polkit, PolkitSubject *subject, uid_t *uid)
|
|||
}
|
||||
|
||||
/**
|
||||
* dkp_polkit_get_pid:
|
||||
* up_polkit_get_pid:
|
||||
**/
|
||||
gboolean
|
||||
dkp_polkit_get_pid (DkpPolkit *polkit, PolkitSubject *subject, pid_t *pid)
|
||||
up_polkit_get_pid (UpPolkit *polkit, PolkitSubject *subject, pid_t *pid)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GError *error = NULL;
|
||||
|
|
@ -162,46 +162,46 @@ out:
|
|||
}
|
||||
|
||||
/**
|
||||
* dkp_polkit_finalize:
|
||||
* up_polkit_finalize:
|
||||
**/
|
||||
static void
|
||||
dkp_polkit_finalize (GObject *object)
|
||||
up_polkit_finalize (GObject *object)
|
||||
{
|
||||
DkpPolkit *polkit;
|
||||
g_return_if_fail (DKP_IS_POLKIT (object));
|
||||
polkit = DKP_POLKIT (object);
|
||||
UpPolkit *polkit;
|
||||
g_return_if_fail (UP_IS_POLKIT (object));
|
||||
polkit = UP_POLKIT (object);
|
||||
|
||||
if (polkit->priv->connection != NULL)
|
||||
dbus_g_connection_unref (polkit->priv->connection);
|
||||
g_object_unref (polkit->priv->authority);
|
||||
|
||||
G_OBJECT_CLASS (dkp_polkit_parent_class)->finalize (object);
|
||||
G_OBJECT_CLASS (up_polkit_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
/**
|
||||
* dkp_polkit_class_init:
|
||||
* up_polkit_class_init:
|
||||
**/
|
||||
static void
|
||||
dkp_polkit_class_init (DkpPolkitClass *klass)
|
||||
up_polkit_class_init (UpPolkitClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
object_class->finalize = dkp_polkit_finalize;
|
||||
g_type_class_add_private (klass, sizeof (DkpPolkitPrivate));
|
||||
object_class->finalize = up_polkit_finalize;
|
||||
g_type_class_add_private (klass, sizeof (UpPolkitPrivate));
|
||||
}
|
||||
|
||||
/**
|
||||
* dkp_polkit_init:
|
||||
* up_polkit_init:
|
||||
*
|
||||
* initializes the polkit class. NOTE: We expect polkit objects
|
||||
* to *NOT* be removed or added during the session.
|
||||
* We only control the first polkit object if there are more than one.
|
||||
**/
|
||||
static void
|
||||
dkp_polkit_init (DkpPolkit *polkit)
|
||||
up_polkit_init (UpPolkit *polkit)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
polkit->priv = DKP_POLKIT_GET_PRIVATE (polkit);
|
||||
polkit->priv = UP_POLKIT_GET_PRIVATE (polkit);
|
||||
|
||||
polkit->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
|
||||
if (polkit->priv->connection == NULL) {
|
||||
|
|
@ -217,19 +217,19 @@ out:
|
|||
}
|
||||
|
||||
/**
|
||||
* dkp_polkit_new:
|
||||
* up_polkit_new:
|
||||
* Return value: A new polkit class instance.
|
||||
**/
|
||||
DkpPolkit *
|
||||
dkp_polkit_new (void)
|
||||
UpPolkit *
|
||||
up_polkit_new (void)
|
||||
{
|
||||
if (dkp_polkit_object != NULL) {
|
||||
g_object_ref (dkp_polkit_object);
|
||||
if (up_polkit_object != NULL) {
|
||||
g_object_ref (up_polkit_object);
|
||||
} else {
|
||||
dkp_polkit_object = g_object_new (DKP_TYPE_POLKIT, NULL);
|
||||
g_object_add_weak_pointer (dkp_polkit_object, &dkp_polkit_object);
|
||||
up_polkit_object = g_object_new (UP_TYPE_POLKIT, NULL);
|
||||
g_object_add_weak_pointer (up_polkit_object, &up_polkit_object);
|
||||
}
|
||||
return DKP_POLKIT (dkp_polkit_object);
|
||||
return UP_POLKIT (up_polkit_object);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
|
|
@ -239,17 +239,17 @@ dkp_polkit_new (void)
|
|||
#include "egg-test.h"
|
||||
|
||||
void
|
||||
dkp_polkit_test (gpointer user_data)
|
||||
up_polkit_test (gpointer user_data)
|
||||
{
|
||||
EggTest *test = (EggTest *) user_data;
|
||||
DkpPolkit *polkit;
|
||||
UpPolkit *polkit;
|
||||
|
||||
if (!egg_test_start (test, "DkpPolkit"))
|
||||
if (!egg_test_start (test, "UpPolkit"))
|
||||
return;
|
||||
|
||||
/************************************************************/
|
||||
egg_test_title (test, "get instance");
|
||||
polkit = dkp_polkit_new ();
|
||||
polkit = up_polkit_new ();
|
||||
egg_test_assert (test, polkit != NULL);
|
||||
|
||||
/* unref */
|
||||
|
|
|
|||
|
|
@ -19,52 +19,52 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __DKP_POLKIT_H
|
||||
#define __DKP_POLKIT_H
|
||||
#ifndef __UP_POLKIT_H
|
||||
#define __UP_POLKIT_H
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <polkit/polkit.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define DKP_TYPE_POLKIT (dkp_polkit_get_type ())
|
||||
#define DKP_POLKIT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), DKP_TYPE_POLKIT, DkpPolkit))
|
||||
#define DKP_POLKIT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), DKP_TYPE_POLKIT, DkpPolkitClass))
|
||||
#define DKP_IS_POLKIT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), DKP_TYPE_POLKIT))
|
||||
#define DKP_IS_POLKIT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), DKP_TYPE_POLKIT))
|
||||
#define DKP_POLKIT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), DKP_TYPE_POLKIT, DkpPolkitClass))
|
||||
#define UP_TYPE_POLKIT (up_polkit_get_type ())
|
||||
#define UP_POLKIT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), UP_TYPE_POLKIT, UpPolkit))
|
||||
#define UP_POLKIT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), UP_TYPE_POLKIT, UpPolkitClass))
|
||||
#define UP_IS_POLKIT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), UP_TYPE_POLKIT))
|
||||
#define UP_IS_POLKIT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), UP_TYPE_POLKIT))
|
||||
#define UP_POLKIT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), UP_TYPE_POLKIT, UpPolkitClass))
|
||||
|
||||
typedef struct DkpPolkitPrivate DkpPolkitPrivate;
|
||||
typedef struct UpPolkitPrivate UpPolkitPrivate;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GObject parent;
|
||||
DkpPolkitPrivate *priv;
|
||||
} DkpPolkit;
|
||||
GObject parent;
|
||||
UpPolkitPrivate *priv;
|
||||
} UpPolkit;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
} DkpPolkitClass;
|
||||
GObjectClass parent_class;
|
||||
} UpPolkitClass;
|
||||
|
||||
GType dkp_polkit_get_type (void);
|
||||
DkpPolkit *dkp_polkit_new (void);
|
||||
void dkp_polkit_test (gpointer user_data);
|
||||
GType up_polkit_get_type (void);
|
||||
UpPolkit *up_polkit_new (void);
|
||||
void up_polkit_test (gpointer user_data);
|
||||
|
||||
PolkitSubject *dkp_polkit_get_subject (DkpPolkit *polkit,
|
||||
PolkitSubject *up_polkit_get_subject (UpPolkit *polkit,
|
||||
DBusGMethodInvocation *context);
|
||||
gboolean dkp_polkit_check_auth (DkpPolkit *polkit,
|
||||
gboolean up_polkit_check_auth (UpPolkit *polkit,
|
||||
PolkitSubject *subject,
|
||||
const gchar *action_id,
|
||||
DBusGMethodInvocation *context);
|
||||
gboolean dkp_polkit_get_uid (DkpPolkit *polkit,
|
||||
gboolean up_polkit_get_uid (UpPolkit *polkit,
|
||||
PolkitSubject *subject,
|
||||
uid_t *uid);
|
||||
gboolean dkp_polkit_get_pid (DkpPolkit *polkit,
|
||||
gboolean up_polkit_get_pid (UpPolkit *polkit,
|
||||
PolkitSubject *subject,
|
||||
pid_t *pid);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __DKP_POLKIT_H */
|
||||
#endif /* __UP_POLKIT_H */
|
||||
|
||||
|
|
|
|||
16
src/up-qos.c
16
src/up-qos.c
|
|
@ -62,7 +62,7 @@ struct DkpQosPrivate
|
|||
gint fd[DKP_QOS_TYPE_LAST];
|
||||
gint last[DKP_QOS_TYPE_LAST];
|
||||
gint minimum[DKP_QOS_TYPE_LAST];
|
||||
DkpPolkit *polkit;
|
||||
UpPolkit *polkit;
|
||||
DBusGConnection *connection;
|
||||
DBusGProxy *proxy;
|
||||
};
|
||||
|
|
@ -271,7 +271,7 @@ dkp_qos_request_latency (DkpQos *qos, const gchar *type_text, gint value, gboole
|
|||
}
|
||||
|
||||
/* get the subject */
|
||||
subject = dkp_polkit_get_subject (qos->priv->polkit, context);
|
||||
subject = up_polkit_get_subject (qos->priv->polkit, context);
|
||||
if (subject == NULL)
|
||||
goto out;
|
||||
|
||||
|
|
@ -280,11 +280,11 @@ dkp_qos_request_latency (DkpQos *qos, const gchar *type_text, gint value, gboole
|
|||
auth = "org.freedesktop.devicekit.power.qos.request-latency-persistent";
|
||||
else
|
||||
auth = "org.freedesktop.devicekit.power.qos.request-latency";
|
||||
if (!dkp_polkit_check_auth (qos->priv->polkit, subject, auth, context))
|
||||
if (!up_polkit_check_auth (qos->priv->polkit, subject, auth, context))
|
||||
goto out;
|
||||
|
||||
/* get uid */
|
||||
retval = dkp_polkit_get_uid (qos->priv->polkit, subject, &uid);
|
||||
retval = up_polkit_get_uid (qos->priv->polkit, subject, &uid);
|
||||
if (!retval) {
|
||||
error = g_error_new (UP_DAEMON_ERROR, UP_DAEMON_ERROR_GENERAL, "cannot get UID");
|
||||
dbus_g_method_return_error (context, error);
|
||||
|
|
@ -292,7 +292,7 @@ dkp_qos_request_latency (DkpQos *qos, const gchar *type_text, gint value, gboole
|
|||
}
|
||||
|
||||
/* get pid */
|
||||
retval = dkp_polkit_get_pid (qos->priv->polkit, subject, &pid);
|
||||
retval = up_polkit_get_pid (qos->priv->polkit, subject, &pid);
|
||||
if (!retval) {
|
||||
error = g_error_new (UP_DAEMON_ERROR, UP_DAEMON_ERROR_GENERAL, "cannot get PID");
|
||||
dbus_g_method_return_error (context, error);
|
||||
|
|
@ -377,10 +377,10 @@ dkp_qos_cancel_request (DkpQos *qos, guint cookie, DBusGMethodInvocation *contex
|
|||
|
||||
/* are we not the sender? */
|
||||
if (g_strcmp0 (sender, obj->sender) != 0) {
|
||||
subject = dkp_polkit_get_subject (qos->priv->polkit, context);
|
||||
subject = up_polkit_get_subject (qos->priv->polkit, context);
|
||||
if (subject == NULL)
|
||||
goto out;
|
||||
if (!dkp_polkit_check_auth (qos->priv->polkit, subject, "org.freedesktop.devicekit.power.qos.cancel-request", context))
|
||||
if (!up_polkit_check_auth (qos->priv->polkit, subject, "org.freedesktop.devicekit.power.qos.cancel-request", context))
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
@ -555,7 +555,7 @@ dkp_qos_init (DkpQos *qos)
|
|||
GError *error = NULL;
|
||||
|
||||
qos->priv = DKP_QOS_GET_PRIVATE (qos);
|
||||
qos->priv->polkit = dkp_polkit_new ();
|
||||
qos->priv->polkit = up_polkit_new ();
|
||||
qos->priv->data = g_ptr_array_new_with_free_func ((GDestroyNotify) dkp_qos_free_data_obj);
|
||||
/* TODO: need to load persistent values */
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ main (int argc, char **argv)
|
|||
up_device_list_test (test);
|
||||
dkp_history_test (test);
|
||||
dkp_native_test (test);
|
||||
dkp_polkit_test (test);
|
||||
up_polkit_test (test);
|
||||
dkp_qos_test (test);
|
||||
dkp_wakeups_test (test);
|
||||
up_daemon_test (test);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue