trivial: Add some useful GObjects for client and server use

This commit is contained in:
Richard Hughes 2010-01-26 11:39:14 +00:00
parent 5e8ba54573
commit af56b08795
15 changed files with 1963 additions and 16 deletions

View file

@ -41,8 +41,8 @@ typedef struct
} DkpWakeupsObj;
typedef DkpWakeupsObj UpWakeupsObj;
#define up_wakeups_obj_free dkp_wakeups_obj_free
#define up_wakeups_obj_new dkp_wakeups_obj_new
#define up_wakeup_item_free dkp_wakeups_obj_free
#define up_wakeup_item_new dkp_wakeups_obj_new
DkpWakeupsObj *dkp_wakeups_obj_new (void);
void dkp_wakeups_obj_free (DkpWakeupsObj *obj);

View file

@ -1 +0,0 @@
dkp-wakeups-obj.h

View file

@ -0,0 +1,57 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2009 Richard Hughes <richard@hughsie.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#if !defined (__UPOWER_H_INSIDE__) && !defined (UP_COMPILATION)
#error "Only <devicekit-power.h> can be included directly."
#endif
#ifndef __DKP_WAKEUPS_OBJ_H__
#define __DKP_WAKEUPS_OBJ_H__
#include <glib.h>
#include <devkit-power-gobject/dkp-enum.h>
G_BEGIN_DECLS
typedef struct
{
gboolean is_userspace;
guint id;
guint old;
gfloat value;
gchar *cmdline;
gchar *details;
} DkpWakeupsObj;
typedef DkpWakeupsObj UpWakeupsObj;
#define up_wakeups_obj_free dkp_wakeups_obj_free
#define up_wakeups_obj_new dkp_wakeups_obj_new
DkpWakeupsObj *dkp_wakeups_obj_new (void);
void dkp_wakeups_obj_free (DkpWakeupsObj *obj);
DkpWakeupsObj *dkp_wakeups_obj_copy (const DkpWakeupsObj *cobj);
gboolean dkp_wakeups_obj_print (const DkpWakeupsObj *obj);
gboolean dkp_wakeups_obj_equal (const DkpWakeupsObj *obj1,
const DkpWakeupsObj *obj2);
G_END_DECLS
#endif /* __DKP_WAKEUPS_OBJ_H__ */

View file

@ -78,6 +78,10 @@
</partintro>
<xi:include href="xml/up-client.xml"/>
<xi:include href="xml/up-device.xml"/>
<xi:include href="xml/up-history-item.xml"/>
<xi:include href="xml/up-qos-item.xml"/>
<xi:include href="xml/up-stats-item.xml"/>
<xi:include href="xml/up-wakeup-item.xml"/>
</reference>
<reference id="libupower-glib-helpers">

View file

@ -22,11 +22,19 @@ libupower_glib_include_HEADERS = \
up-version.h \
up-types.h \
up-device.h \
up-qos-item.h \
up-wakeup-item.h \
up-stats-item.h \
up-history-item.h \
up-client.h
libupower_glib_la_SOURCES = \
up-types.c \
up-client.c \
up-qos-item.c \
up-wakeup-item.c \
up-stats-item.c \
up-history-item.c \
up-device.c
libupower_glib_la_LIBADD = \
@ -45,8 +53,6 @@ libupower_glib_la_CFLAGS = \
$(NULL)
EXTRA_DIST = \
up-client.h \
up-device.h \
up-version.h.in
CLEANFILES = $(BUILT_SOURCES)

View file

@ -0,0 +1,278 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2008 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU General Public License Version 2
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <glib.h>
#include "up-history-item.h"
static void up_history_item_class_init (UpHistoryItemClass *klass);
static void up_history_item_init (UpHistoryItem *history_item);
static void up_history_item_finalize (GObject *object);
#define UP_HISTORY_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_HISTORY_ITEM, UpHistoryItemPrivate))
struct UpHistoryItemPrivate
{
gdouble value;
guint time;
UpDeviceState state;
};
enum {
PROP_0,
PROP_VALUE,
PROP_TIME,
PROP_STATE,
PROP_LAST
};
G_DEFINE_TYPE (UpHistoryItem, up_history_item, G_TYPE_OBJECT)
/**
* up_history_item_set_value:
* @history_item: #UpHistoryItem
* @value: the new value
*
* Sets the item value.
*
* Since: 0.9.0
**/
void
up_history_item_set_value (UpHistoryItem *history_item, gdouble value)
{
g_return_if_fail (UP_IS_HISTORY_ITEM (history_item));
history_item->priv->value = value;
g_object_notify (G_OBJECT(history_item), "value");
}
/**
* up_history_item_get_value:
* @history_item: #UpHistoryItem
*
* Gets the item value.
*
* Since: 0.9.0
**/
gdouble
up_history_item_get_value (UpHistoryItem *history_item)
{
g_return_val_if_fail (UP_IS_HISTORY_ITEM (history_item), G_MAXDOUBLE);
return history_item->priv->value;
}
/**
* up_history_item_set_time:
* @history_item: #UpHistoryItem
* @time: the new value
*
* Sets the item time.
*
* Since: 0.9.0
**/
void
up_history_item_set_time (UpHistoryItem *history_item, guint time)
{
g_return_if_fail (UP_IS_HISTORY_ITEM (history_item));
history_item->priv->time = time;
g_object_notify (G_OBJECT(history_item), "time");
}
/**
* up_history_item_get_time:
* @history_item: #UpHistoryItem
*
* Gets the item time.
*
* Since: 0.9.0
**/
guint
up_history_item_get_time (UpHistoryItem *history_item)
{
g_return_val_if_fail (UP_IS_HISTORY_ITEM (history_item), G_MAXUINT);
return history_item->priv->time;
}
/**
* up_history_item_set_state:
* @history_item: #UpHistoryItem
* @state: the new value
*
* Sets the item state.
*
* Since: 0.9.0
**/
void
up_history_item_set_state (UpHistoryItem *history_item, UpDeviceState state)
{
g_return_if_fail (UP_IS_HISTORY_ITEM (history_item));
history_item->priv->state = state;
g_object_notify (G_OBJECT(history_item), "state");
}
/**
* up_history_item_get_state:
* @history_item: #UpHistoryItem
*
* Gets the item state.
*
* Since: 0.9.0
**/
UpDeviceState
up_history_item_get_state (UpHistoryItem *history_item)
{
g_return_val_if_fail (UP_IS_HISTORY_ITEM (history_item), G_MAXUINT);
return history_item->priv->state;
}
/**
* up_history_item_set_property:
**/
static void
up_history_item_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
UpHistoryItem *history_item = UP_HISTORY_ITEM (object);
switch (prop_id) {
case PROP_VALUE:
history_item->priv->value = g_value_get_double (value);
break;
case PROP_TIME:
history_item->priv->time = g_value_get_uint (value);
break;
case PROP_STATE:
history_item->priv->state = g_value_get_uint (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
/**
* up_history_item_get_property:
**/
static void
up_history_item_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
UpHistoryItem *history_item = UP_HISTORY_ITEM (object);
switch (prop_id) {
case PROP_VALUE:
g_value_set_double (value, history_item->priv->value);
break;
case PROP_TIME:
g_value_set_uint (value, history_item->priv->time);
break;
case PROP_STATE:
g_value_set_uint (value, history_item->priv->state);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
/**
* up_history_item_class_init:
**/
static void
up_history_item_class_init (UpHistoryItemClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = up_history_item_finalize;
object_class->set_property = up_history_item_set_property;
object_class->get_property = up_history_item_get_property;
/**
* UpHistoryItem:value:
*
* Since: 0.9.0
**/
g_object_class_install_property (object_class,
PROP_VALUE,
g_param_spec_double ("value", NULL, NULL,
0.0, G_MAXDOUBLE, 0.0,
G_PARAM_READWRITE));
/**
* UpHistoryItem:time:
*
* Since: 0.9.0
**/
g_object_class_install_property (object_class,
PROP_TIME,
g_param_spec_uint ("time", NULL, NULL,
0, G_MAXUINT, 0,
G_PARAM_READWRITE));
/**
* UpHistoryItem:state:
*
* Since: 0.9.0
**/
g_object_class_install_property (object_class,
PROP_STATE,
g_param_spec_uint ("state", NULL, NULL,
0, G_MAXUINT,
UP_DEVICE_STATE_UNKNOWN,
G_PARAM_READWRITE));
g_type_class_add_private (klass, sizeof (UpHistoryItemPrivate));
}
/**
* up_history_item_init:
**/
static void
up_history_item_init (UpHistoryItem *history_item)
{
history_item->priv = UP_HISTORY_ITEM_GET_PRIVATE (history_item);
history_item->priv->value = 0.0f;
history_item->priv->time = 0;
history_item->priv->state = UP_DEVICE_STATE_UNKNOWN;
}
/**
* up_history_item_finalize:
**/
static void
up_history_item_finalize (GObject *object)
{
g_return_if_fail (UP_IS_HISTORY_ITEM (object));
G_OBJECT_CLASS (up_history_item_parent_class)->finalize (object);
}
/**
* up_history_item_new:
*
* Return value: a new UpHistoryItem object.
*
* Since: 0.9.0
**/
UpHistoryItem *
up_history_item_new (void)
{
UpHistoryItem *history_item;
history_item = g_object_new (UP_TYPE_HISTORY_ITEM, NULL);
return UP_HISTORY_ITEM (history_item);
}

View file

@ -0,0 +1,70 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2008 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU General Public License Version 2
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#if !defined (__UPOWER_H_INSIDE__) && !defined (UP_COMPILATION)
#error "Only <upower.h> can be included directly."
#endif
#ifndef __UP_HISTORY_ITEM_H
#define __UP_HISTORY_ITEM_H
#include <glib-object.h>
#include <libupower-glib/up-types.h>
G_BEGIN_DECLS
#define UP_TYPE_HISTORY_ITEM (up_history_item_get_type ())
#define UP_HISTORY_ITEM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), UP_TYPE_HISTORY_ITEM, UpHistoryItem))
#define UP_HISTORY_ITEM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), UP_TYPE_HISTORY_ITEM, UpHistoryItemClass))
#define UP_IS_HISTORY_ITEM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), UP_TYPE_HISTORY_ITEM))
#define UP_IS_HISTORY_ITEM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), UP_TYPE_HISTORY_ITEM))
#define UP_HISTORY_ITEM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), UP_TYPE_HISTORY_ITEM, UpHistoryItemClass))
typedef struct UpHistoryItemPrivate UpHistoryItemPrivate;
typedef struct
{
GObject parent;
UpHistoryItemPrivate *priv;
} UpHistoryItem;
typedef struct
{
GObjectClass parent_class;
} UpHistoryItemClass;
GType up_history_item_get_type (void);
UpHistoryItem *up_history_item_new (void);
gdouble up_history_item_get_value (UpHistoryItem *history_item);
void up_history_item_set_value (UpHistoryItem *history_item,
gdouble value);
guint up_history_item_get_time (UpHistoryItem *history_item);
void up_history_item_set_time (UpHistoryItem *history_item,
guint time);
UpDeviceState up_history_item_get_state (UpHistoryItem *history_item);
void up_history_item_set_state (UpHistoryItem *history_item,
UpDeviceState state);
G_END_DECLS
#endif /* __UP_HISTORY_ITEM_H */

View file

@ -0,0 +1,617 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2008-2010 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU General Public License Version 2
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <glib.h>
#include "up-qos-item.h"
static void up_qos_item_class_init (UpQosItemClass *klass);
static void up_qos_item_init (UpQosItem *qos_item);
static void up_qos_item_finalize (GObject *object);
#define UP_QOS_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_QOS_ITEM, UpQosItemPrivate))
struct UpQosItemPrivate
{
guint uid;
guint pid;
gchar *sender;
gchar *cmdline;
guint cookie;
guint64 timespec;
gboolean persistent;
UpQosKind type;
gint value;
};
enum {
PROP_0,
PROP_UID,
PROP_PID,
PROP_SENDER,
PROP_CMDLINE,
PROP_COOKIE,
PROP_TIMESPEC,
PROP_PERSISTENT,
PROP_TYPE,
PROP_VALUE,
PROP_LAST
};
G_DEFINE_TYPE (UpQosItem, up_qos_item, G_TYPE_OBJECT)
/**
* up_qos_item_get_uid:
* @qos_item: #UpQosItem
*
* Gets the item uid.
*
* Return value: the value
*
* Since: 0.9.0
**/
guint
up_qos_item_get_uid (UpQosItem *qos_item)
{
g_return_val_if_fail (UP_IS_QOS_ITEM (qos_item), G_MAXUINT);
return qos_item->priv->uid;
}
/**
* up_qos_item_set_uid:
* @qos_item: #UpQosItem
* @uid: the new value
*
* Sets the item uid.
*
* Since: 0.9.0
**/
void
up_qos_item_set_uid (UpQosItem *qos_item, guint uid)
{
g_return_if_fail (UP_IS_QOS_ITEM (qos_item));
qos_item->priv->uid = uid;
g_object_notify (G_OBJECT(qos_item), "uid");
}
/**
* up_qos_item_get_pid:
* @qos_item: #UpQosItem
*
* Gets the item pid.
*
* Return value: the value
*
* Since: 0.9.0
**/
guint
up_qos_item_get_pid (UpQosItem *qos_item)
{
g_return_val_if_fail (UP_IS_QOS_ITEM (qos_item), G_MAXUINT);
return qos_item->priv->pid;
}
/**
* up_qos_item_set_pid:
* @qos_item: #UpQosItem
* @pid: the new value
*
* Sets the item pid.
*
* Since: 0.9.0
**/
void
up_qos_item_set_pid (UpQosItem *qos_item, guint pid)
{
g_return_if_fail (UP_IS_QOS_ITEM (qos_item));
qos_item->priv->pid = pid;
g_object_notify (G_OBJECT(qos_item), "pid");
}
/**
* up_qos_item_get_sender:
* @qos_item: #UpQosItem
*
* Gets the item sender.
*
* Return value: the value
*
* Since: 0.9.0
**/
const gchar *
up_qos_item_get_sender (UpQosItem *qos_item)
{
g_return_val_if_fail (UP_IS_QOS_ITEM (qos_item), NULL);
return qos_item->priv->sender;
}
/**
* up_qos_item_set_sender:
* @qos_item: #UpQosItem
* @sender: the new value
*
* Sets the item sender.
*
* Since: 0.9.0
**/
void
up_qos_item_set_sender (UpQosItem *qos_item, const gchar *sender)
{
g_return_if_fail (UP_IS_QOS_ITEM (qos_item));
g_free (qos_item->priv->sender);
qos_item->priv->sender = g_strdup (sender);
g_object_notify (G_OBJECT(qos_item), "sender");
}
/**
* up_qos_item_get_cmdline:
* @qos_item: #UpQosItem
*
* Gets the item cmdline.
*
* Return value: the value
*
* Since: 0.9.0
**/
const gchar *
up_qos_item_get_cmdline (UpQosItem *qos_item)
{
g_return_val_if_fail (UP_IS_QOS_ITEM (qos_item), NULL);
return qos_item->priv->cmdline;
}
/**
* up_qos_item_set_cmdline:
* @qos_item: #UpQosItem
* @cmdline: the new value
*
* Sets the item cmdline.
*
* Since: 0.9.0
**/
void
up_qos_item_set_cmdline (UpQosItem *qos_item, const gchar *cmdline)
{
g_return_if_fail (UP_IS_QOS_ITEM (qos_item));
g_free (qos_item->priv->cmdline);
qos_item->priv->cmdline = g_strdup (cmdline);
g_object_notify (G_OBJECT(qos_item), "cmdline");
}
/**
* up_qos_item_get_cookie:
* @qos_item: #UpQosItem
*
* Gets the item cookie.
*
* Return value: the value
*
* Since: 0.9.0
**/
guint
up_qos_item_get_cookie (UpQosItem *qos_item)
{
g_return_val_if_fail (UP_IS_QOS_ITEM (qos_item), G_MAXUINT);
return qos_item->priv->cookie;
}
/**
* up_qos_item_set_cookie:
* @qos_item: #UpQosItem
* @cookie: the new value
*
* Sets the item cookie.
*
* Since: 0.9.0
**/
void
up_qos_item_set_cookie (UpQosItem *qos_item, guint cookie)
{
g_return_if_fail (UP_IS_QOS_ITEM (qos_item));
qos_item->priv->cookie = cookie;
g_object_notify (G_OBJECT(qos_item), "cookie");
}
/**
* up_qos_item_get_timespec:
* @qos_item: #UpQosItem
*
* Gets the item timespec.
*
* Return value: the value
*
* Since: 0.9.0
**/
guint64
up_qos_item_get_timespec (UpQosItem *qos_item)
{
g_return_val_if_fail (UP_IS_QOS_ITEM (qos_item), G_MAXUINT64);
return qos_item->priv->timespec;
}
/**
* up_qos_item_set_timespec:
* @qos_item: #UpQosItem
* @timespec: the new value
*
* Sets the item timespec.
*
* Since: 0.9.0
**/
void
up_qos_item_set_timespec (UpQosItem *qos_item, guint64 timespec)
{
g_return_if_fail (UP_IS_QOS_ITEM (qos_item));
qos_item->priv->timespec = timespec;
g_object_notify (G_OBJECT(qos_item), "timespec");
}
/**
* up_qos_item_get_persistent:
* @qos_item: #UpQosItem
*
* Gets the item persistent.
*
* Return value: the value
*
* Since: 0.9.0
**/
gboolean
up_qos_item_get_persistent (UpQosItem *qos_item)
{
g_return_val_if_fail (UP_IS_QOS_ITEM (qos_item), G_MAXUINT);
return qos_item->priv->persistent;
}
/**
* up_qos_item_set_persistent:
* @qos_item: #UpQosItem
* @persistent: the new value
*
* Sets the item persistent.
*
* Since: 0.9.0
**/
void
up_qos_item_set_persistent (UpQosItem *qos_item, gboolean persistent)
{
g_return_if_fail (UP_IS_QOS_ITEM (qos_item));
qos_item->priv->persistent = persistent;
g_object_notify (G_OBJECT(qos_item), "persistent");
}
/**
* up_qos_item_get_kind:
* @qos_item: #UpQosItem
*
* Gets the item type.
*
* Return value: the value
*
* Since: 0.9.0
**/
UpQosKind
up_qos_item_get_kind (UpQosItem *qos_item)
{
g_return_val_if_fail (UP_IS_QOS_ITEM (qos_item), G_MAXUINT);
return qos_item->priv->type;
}
/**
* up_qos_item_set_kind:
* @qos_item: #UpQosItem
* @type: the new value
*
* Sets the item type.
*
* Since: 0.9.0
**/
void
up_qos_item_set_kind (UpQosItem *qos_item, UpQosKind type)
{
g_return_if_fail (UP_IS_QOS_ITEM (qos_item));
qos_item->priv->type = type;
g_object_notify (G_OBJECT(qos_item), "type");
}
/**
* up_qos_item_get_value:
* @qos_item: #UpQosItem
*
* Gets the item value.
*
* Return value: the value
*
* Since: 0.9.0
**/
gint
up_qos_item_get_value (UpQosItem *qos_item)
{
g_return_val_if_fail (UP_IS_QOS_ITEM (qos_item), G_MAXINT);
return qos_item->priv->value;
}
/**
* up_qos_item_set_value:
* @qos_item: #UpQosItem
* @value: the new value
*
* Sets the item value.
*
* Since: 0.9.0
**/
void
up_qos_item_set_value (UpQosItem *qos_item, gint value)
{
g_return_if_fail (UP_IS_QOS_ITEM (qos_item));
qos_item->priv->value = value;
g_object_notify (G_OBJECT(qos_item), "value");
}
/**
* up_qos_item_set_property:
**/
static void
up_qos_item_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
UpQosItem *qos_item = UP_QOS_ITEM (object);
switch (prop_id) {
case PROP_UID:
qos_item->priv->uid = g_value_get_uint (value);
break;
case PROP_PID:
qos_item->priv->pid = g_value_get_uint (value);
break;
case PROP_SENDER:
g_free (qos_item->priv->sender);
qos_item->priv->sender = g_strdup (g_value_get_string (value));
break;
case PROP_CMDLINE:
g_free (qos_item->priv->cmdline);
qos_item->priv->cmdline = g_strdup (g_value_get_string (value));
break;
case PROP_COOKIE:
qos_item->priv->cookie = g_value_get_uint (value);
break;
case PROP_TIMESPEC:
qos_item->priv->timespec = g_value_get_uint64 (value);
break;
case PROP_PERSISTENT:
qos_item->priv->persistent = g_value_get_boolean (value);
break;
case PROP_TYPE:
qos_item->priv->type = g_value_get_uint (value);
break;
case PROP_VALUE:
qos_item->priv->value = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
/**
* up_qos_item_get_property:
**/
static void
up_qos_item_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
UpQosItem *qos_item = UP_QOS_ITEM (object);
switch (prop_id) {
case PROP_UID:
g_value_set_uint (value, qos_item->priv->uid);
break;
case PROP_PID:
g_value_set_uint (value, qos_item->priv->pid);
break;
case PROP_SENDER:
g_value_set_string (value, qos_item->priv->sender);
break;
case PROP_CMDLINE:
g_value_set_string (value, qos_item->priv->cmdline);
break;
case PROP_COOKIE:
g_value_set_uint (value, qos_item->priv->cookie);
break;
case PROP_TIMESPEC:
g_value_set_uint64 (value, qos_item->priv->timespec);
break;
case PROP_PERSISTENT:
g_value_set_boolean (value, qos_item->priv->persistent);
break;
case PROP_TYPE:
g_value_set_uint (value, qos_item->priv->type);
break;
case PROP_VALUE:
g_value_set_int (value, qos_item->priv->value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
/**
* up_qos_item_class_init:
* @klass: The UpQosItemClass
**/
static void
up_qos_item_class_init (UpQosItemClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = up_qos_item_finalize;
object_class->set_property = up_qos_item_set_property;
object_class->get_property = up_qos_item_get_property;
/**
* UpQosItem:uid:
*
* Since: 0.9.0
**/
g_object_class_install_property (object_class,
PROP_UID,
g_param_spec_uint ("uid", NULL, NULL,
0, G_MAXUINT, 0,
G_PARAM_READWRITE));
/**
* UpQosItem:pid:
*
* Since: 0.9.0
**/
g_object_class_install_property (object_class,
PROP_PID,
g_param_spec_uint ("pid", NULL, NULL,
0, G_MAXUINT, 0,
G_PARAM_READWRITE));
/**
* UpQosItem:sender:
*
* Since: 0.9.0
**/
g_object_class_install_property (object_class,
PROP_SENDER,
g_param_spec_string ("sender", NULL, NULL,
NULL,
G_PARAM_READWRITE));
/**
* UpQosItem:cmdline:
*
* Since: 0.9.0
**/
g_object_class_install_property (object_class,
PROP_CMDLINE,
g_param_spec_string ("cmdline", NULL, NULL,
NULL,
G_PARAM_READWRITE));
/**
* UpQosItem:cookie:
*
* Since: 0.9.0
**/
g_object_class_install_property (object_class,
PROP_COOKIE,
g_param_spec_uint ("cookie", NULL, NULL,
0, G_MAXUINT, 0,
G_PARAM_READWRITE));
/**
* UpQosItem:timespec:
*
* Since: 0.9.0
**/
g_object_class_install_property (object_class,
PROP_TIMESPEC,
g_param_spec_uint64 ("timespec", NULL, NULL,
0, G_MAXUINT64, 0,
G_PARAM_READWRITE));
/**
* UpQosItem:persistent:
*
* Since: 0.9.0
**/
g_object_class_install_property (object_class,
PROP_PERSISTENT,
g_param_spec_boolean ("persistent", NULL, NULL,
FALSE,
G_PARAM_READWRITE));
/**
* UpQosItem:type:
*
* Since: 0.9.0
**/
g_object_class_install_property (object_class,
PROP_TYPE,
g_param_spec_uint ("type", NULL, NULL,
0, G_MAXUINT, UP_QOS_TYPE_UNKNOWN,
G_PARAM_READWRITE));
/**
* UpQosItem:value:
*
* Since: 0.9.0
**/
g_object_class_install_property (object_class,
PROP_VALUE,
g_param_spec_int ("value", NULL, NULL,
0, G_MAXINT, 0,
G_PARAM_READWRITE));
g_type_class_add_private (klass, sizeof (UpQosItemPrivate));
}
/**
* up_qos_item_init:
* @qos_item: This class instance
**/
static void
up_qos_item_init (UpQosItem *qos_item)
{
qos_item->priv = UP_QOS_ITEM_GET_PRIVATE (qos_item);
qos_item->priv->value = 0.0f;
qos_item->priv->uid = 0;
qos_item->priv->pid = 0;
qos_item->priv->sender = NULL;
qos_item->priv->cmdline = NULL;
qos_item->priv->cookie = 0;
qos_item->priv->timespec = 0;
qos_item->priv->persistent = FALSE;
qos_item->priv->type = UP_QOS_TYPE_UNKNOWN;
qos_item->priv->value = 0;
}
/**
* up_qos_item_finalize:
* @object: The object to finalize
**/
static void
up_qos_item_finalize (GObject *object)
{
UpQosItem *qos_item;
g_return_if_fail (UP_IS_QOS_ITEM (object));
qos_item = UP_QOS_ITEM (object);
g_free (qos_item->priv->sender);
g_free (qos_item->priv->cmdline);
G_OBJECT_CLASS (up_qos_item_parent_class)->finalize (object);
}
/**
* up_qos_item_new:
*
* Return value: a new UpQosItem object.
*
* Since: 0.9.0
**/
UpQosItem *
up_qos_item_new (void)
{
UpQosItem *qos_item;
qos_item = g_object_new (UP_TYPE_QOS_ITEM, NULL);
return UP_QOS_ITEM (qos_item);
}

View file

@ -0,0 +1,89 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2008-2010 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU General Public License Version 2
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#if !defined (__UPOWER_H_INSIDE__) && !defined (UP_COMPILATION)
#error "Only <upower.h> can be included directly."
#endif
#ifndef __UP_QOS_ITEM_H
#define __UP_QOS_ITEM_H
#include <glib-object.h>
#include <libupower-glib/up-types.h>
G_BEGIN_DECLS
#define UP_TYPE_QOS_ITEM (up_qos_item_get_type ())
#define UP_QOS_ITEM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), UP_TYPE_QOS_ITEM, UpQosItem))
#define UP_QOS_ITEM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), UP_TYPE_QOS_ITEM, UpQosItemClass))
#define UP_IS_QOS_ITEM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), UP_TYPE_QOS_ITEM))
#define UP_IS_QOS_ITEM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), UP_TYPE_QOS_ITEM))
#define UP_QOS_ITEM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), UP_TYPE_QOS_ITEM, UpQosItemClass))
typedef struct UpQosItemPrivate UpQosItemPrivate;
typedef struct
{
GObject parent;
UpQosItemPrivate *priv;
} UpQosItem;
typedef struct
{
GObjectClass parent_class;
} UpQosItemClass;
GType up_qos_item_get_type (void);
UpQosItem *up_qos_item_new (void);
/* accessors */
guint up_qos_item_get_uid (UpQosItem *qos_item);
void up_qos_item_set_uid (UpQosItem *qos_item,
guint uid);
guint up_qos_item_get_pid (UpQosItem *qos_item);
void up_qos_item_set_pid (UpQosItem *qos_item,
guint pid);
const gchar *up_qos_item_get_sender (UpQosItem *qos_item);
void up_qos_item_set_sender (UpQosItem *qos_item,
const gchar *sender);
const gchar *up_qos_item_get_cmdline (UpQosItem *qos_item);
void up_qos_item_set_cmdline (UpQosItem *qos_item,
const gchar *cmdline);
guint up_qos_item_get_cookie (UpQosItem *qos_item);
void up_qos_item_set_cookie (UpQosItem *qos_item,
guint cookie);
guint64 up_qos_item_get_timespec (UpQosItem *qos_item);
void up_qos_item_set_timespec (UpQosItem *qos_item,
guint64 timespec);
gboolean up_qos_item_get_persistent (UpQosItem *qos_item);
void up_qos_item_set_persistent (UpQosItem *qos_item,
gboolean persistent);
UpQosKind up_qos_item_get_kind (UpQosItem *qos_item);
void up_qos_item_set_kind (UpQosItem *qos_item,
UpQosKind type);
gint up_qos_item_get_value (UpQosItem *qos_item);
void up_qos_item_set_value (UpQosItem *qos_item,
gint value);
G_END_DECLS
#endif /* __UP_QOS_ITEM_H */

View file

@ -0,0 +1,222 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2008 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU General Public License Version 2
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <glib.h>
#include "up-stats-item.h"
static void up_stats_item_class_init (UpStatsItemClass *klass);
static void up_stats_item_init (UpStatsItem *stats_item);
static void up_stats_item_finalize (GObject *object);
#define UP_STATS_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_STATS_ITEM, UpStatsItemPrivate))
struct UpStatsItemPrivate
{
gdouble value;
gdouble accuracy;
};
enum {
PROP_0,
PROP_VALUE,
PROP_ACCURACY,
PROP_LAST
};
G_DEFINE_TYPE (UpStatsItem, up_stats_item, G_TYPE_OBJECT)
/**
* up_stats_item_set_value:
*
* Sets the item value.
*
* Since: 0.9.0
**/
void
up_stats_item_set_value (UpStatsItem *stats_item, gdouble value)
{
g_return_if_fail (UP_IS_STATS_ITEM (stats_item));
stats_item->priv->value = value;
g_object_notify (G_OBJECT(stats_item), "value");
}
/**
* up_stats_item_get_value:
*
* Gets the item value.
*
* Since: 0.9.0
**/
gdouble
up_stats_item_get_value (UpStatsItem *stats_item)
{
g_return_val_if_fail (UP_IS_STATS_ITEM (stats_item), G_MAXDOUBLE);
return stats_item->priv->value;
}
/**
* up_stats_item_set_accuracy:
*
* Sets the item accuracy.
*
* Since: 0.9.0
**/
void
up_stats_item_set_accuracy (UpStatsItem *stats_item, gdouble accuracy)
{
g_return_if_fail (UP_IS_STATS_ITEM (stats_item));
stats_item->priv->accuracy = accuracy;
g_object_notify (G_OBJECT(stats_item), "accuracy");
}
/**
* up_stats_item_get_accuracy:
*
* Gets the item accuracy.
*
* Since: 0.9.0
**/
gdouble
up_stats_item_get_accuracy (UpStatsItem *stats_item)
{
g_return_val_if_fail (UP_IS_STATS_ITEM (stats_item), G_MAXDOUBLE);
return stats_item->priv->accuracy;
}
/**
* up_stats_item_set_property:
**/
static void
up_stats_item_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
UpStatsItem *stats_item = UP_STATS_ITEM (object);
switch (prop_id) {
case PROP_VALUE:
stats_item->priv->value = g_value_get_double (value);
break;
case PROP_ACCURACY:
stats_item->priv->accuracy = g_value_get_double (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
/**
* up_stats_item_get_property:
**/
static void
up_stats_item_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
UpStatsItem *stats_item = UP_STATS_ITEM (object);
switch (prop_id) {
case PROP_VALUE:
g_value_set_double (value, stats_item->priv->value);
break;
case PROP_ACCURACY:
g_value_set_double (value, stats_item->priv->accuracy);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
/**
* up_stats_item_class_init:
* @klass: The UpStatsItemClass
**/
static void
up_stats_item_class_init (UpStatsItemClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = up_stats_item_finalize;
object_class->set_property = up_stats_item_set_property;
object_class->get_property = up_stats_item_get_property;
/**
* UpStatsItem:value:
*
* Since: 0.9.0
**/
g_object_class_install_property (object_class,
PROP_VALUE,
g_param_spec_double ("value", NULL, NULL,
0.0, G_MAXDOUBLE, 0.0,
G_PARAM_READWRITE));
/**
* UpStatsItem:accuracy:
*
* Since: 0.9.0
**/
g_object_class_install_property (object_class,
PROP_ACCURACY,
g_param_spec_double ("accuracy", NULL, NULL,
0.0, G_MAXDOUBLE, 0.0,
G_PARAM_READWRITE));
g_type_class_add_private (klass, sizeof (UpStatsItemPrivate));
}
/**
* up_stats_item_init:
* @stats_item: This class instance
**/
static void
up_stats_item_init (UpStatsItem *stats_item)
{
stats_item->priv = UP_STATS_ITEM_GET_PRIVATE (stats_item);
stats_item->priv->value = 0.0f;
stats_item->priv->accuracy = 0.0f;
}
/**
* up_stats_item_finalize:
* @object: The object to finalize
**/
static void
up_stats_item_finalize (GObject *object)
{
g_return_if_fail (UP_IS_STATS_ITEM (object));
G_OBJECT_CLASS (up_stats_item_parent_class)->finalize (object);
}
/**
* up_stats_item_new:
*
* Return value: a new UpStatsItem object.
*
* Since: 0.9.0
**/
UpStatsItem *
up_stats_item_new (void)
{
UpStatsItem *stats_item;
stats_item = g_object_new (UP_TYPE_STATS_ITEM, NULL);
return UP_STATS_ITEM (stats_item);
}

View file

@ -0,0 +1,66 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2008 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU General Public License Version 2
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#if !defined (__UPOWER_H_INSIDE__) && !defined (UP_COMPILATION)
#error "Only <upower.h> can be included directly."
#endif
#ifndef __UP_STATS_ITEM_H
#define __UP_STATS_ITEM_H
#include <glib-object.h>
G_BEGIN_DECLS
#define UP_TYPE_STATS_ITEM (up_stats_item_get_type ())
#define UP_STATS_ITEM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), UP_TYPE_STATS_ITEM, UpStatsItem))
#define UP_STATS_ITEM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), UP_TYPE_STATS_ITEM, UpStatsItemClass))
#define UP_IS_STATS_ITEM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), UP_TYPE_STATS_ITEM))
#define UP_IS_STATS_ITEM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), UP_TYPE_STATS_ITEM))
#define UP_STATS_ITEM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), UP_TYPE_STATS_ITEM, UpStatsItemClass))
typedef struct UpStatsItemPrivate UpStatsItemPrivate;
typedef struct
{
GObject parent;
UpStatsItemPrivate *priv;
} UpStatsItem;
typedef struct
{
GObjectClass parent_class;
} UpStatsItemClass;
GType up_stats_item_get_type (void);
UpStatsItem *up_stats_item_new (void);
gdouble up_stats_item_get_value (UpStatsItem *stats_item);
void up_stats_item_set_value (UpStatsItem *stats_item,
gdouble value);
gdouble up_stats_item_get_accuracy (UpStatsItem *stats_item);
void up_stats_item_set_accuracy (UpStatsItem *stats_item,
gdouble accuracy);
G_END_DECLS
#endif /* __UP_STATS_ITEM_H */

View file

@ -250,16 +250,16 @@ up_device_technology_from_string (const gchar *technology)
}
/**
* up_qos_type_to_string:
* up_qos_kind_to_string:
*
* Converts a #UpQosType to a string.
* Converts a #UpQosKind to a string.
*
* Return value: identifier string
*
* Since: 0.9.0
**/
const gchar *
up_qos_type_to_string (UpQosType type)
up_qos_kind_to_string (UpQosKind type)
{
if (type == UP_QOS_TYPE_NETWORK)
return "network";
@ -269,16 +269,16 @@ up_qos_type_to_string (UpQosType type)
}
/**
* up_qos_type_from_string:
* up_qos_kind_from_string:
*
* Converts a string to a #UpQosType.
* Converts a string to a #UpQosKind.
*
* Return value: enumerated value
*
* Since: 0.9.0
**/
UpQosType
up_qos_type_from_string (const gchar *type)
UpQosKind
up_qos_kind_from_string (const gchar *type)
{
if (g_strcmp0 (type, "network") == 0)
return UP_QOS_TYPE_NETWORK;

View file

@ -81,7 +81,7 @@ typedef enum {
} UpDeviceTechnology;
/**
* UpQosType:
* UpQosKind:
*
* The type of QOS request.
**/
@ -90,7 +90,7 @@ typedef enum {
UP_QOS_TYPE_NETWORK,
UP_QOS_TYPE_CPU_DMA,
UP_QOS_TYPE_LAST
} UpQosType;
} UpQosKind;
const gchar *up_device_kind_to_string (UpDeviceKind type_enum);
const gchar *up_device_state_to_string (UpDeviceState state_enum);
@ -98,8 +98,8 @@ const gchar *up_device_technology_to_string (UpDeviceTechnology technology_enu
UpDeviceKind up_device_kind_from_string (const gchar *type);
UpDeviceState up_device_state_from_string (const gchar *state);
UpDeviceTechnology up_device_technology_from_string (const gchar *technology);
const gchar *up_qos_type_to_string (UpQosType type);
UpQosType up_qos_type_from_string (const gchar *type);
const gchar *up_qos_kind_to_string (UpQosKind type);
UpQosKind up_qos_kind_from_string (const gchar *type);
G_END_DECLS

View file

@ -0,0 +1,455 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2008-2010 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU General Public License Version 2
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <glib.h>
#include "up-wakeup-item.h"
static void up_wakeup_item_class_init (UpWakeupItemClass *klass);
static void up_wakeup_item_init (UpWakeupItem *wakeup_item);
static void up_wakeup_item_finalize (GObject *object);
#define UP_WAKEUP_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_WAKEUP_ITEM, UpWakeupItemPrivate))
struct UpWakeupItemPrivate
{
gboolean is_userspace;
guint id;
guint old;
gdouble value;
gchar *cmdline;
gchar *details;
};
enum {
PROP_0,
PROP_IS_USERSPACE,
PROP_ID,
PROP_OLD,
PROP_VALUE,
PROP_CMDLINE,
PROP_DETAILS,
PROP_LAST
};
G_DEFINE_TYPE (UpWakeupItem, up_wakeup_item, G_TYPE_OBJECT)
/**
* up_wakeup_item_get_is_userspace:
* @history_item: #UpWakeupItem
*
* Gets if the item is userspace.
*
* Return value: the value
*
* Since: 0.9.0
**/
gboolean
up_wakeup_item_get_is_userspace (UpWakeupItem *wakeup_item)
{
g_return_val_if_fail (UP_IS_WAKEUP_ITEM (wakeup_item), FALSE);
return wakeup_item->priv->is_userspace;
}
/**
* up_wakeup_item_set_is_userspace:
* @history_item: #UpWakeupItem
* @is_userspace: the new value
*
* Sets if the item is userspace.
*
* Since: 0.9.0
**/
void
up_wakeup_item_set_is_userspace (UpWakeupItem *wakeup_item, gboolean is_userspace)
{
g_return_if_fail (UP_IS_WAKEUP_ITEM (wakeup_item));
wakeup_item->priv->is_userspace = is_userspace;
g_object_notify (G_OBJECT(wakeup_item), "is-userspace");
}
/**
* up_wakeup_item_get_id:
* @history_item: #UpWakeupItem
*
* Gets the item id.
*
* Return value: the value
*
* Since: 0.9.0
**/
guint
up_wakeup_item_get_id (UpWakeupItem *wakeup_item)
{
g_return_val_if_fail (UP_IS_WAKEUP_ITEM (wakeup_item), G_MAXUINT);
return wakeup_item->priv->id;
}
/**
* up_wakeup_item_set_id:
* @history_item: #UpWakeupItem
* @id: the new value
*
* Sets the item id.
*
* Since: 0.9.0
**/
void
up_wakeup_item_set_id (UpWakeupItem *wakeup_item, guint id)
{
g_return_if_fail (UP_IS_WAKEUP_ITEM (wakeup_item));
wakeup_item->priv->id = id;
g_object_notify (G_OBJECT(wakeup_item), "id");
}
/**
* up_wakeup_item_get_old:
* @history_item: #UpWakeupItem
*
* Gets the item old.
*
* Return value: the value
*
* Since: 0.9.0
**/
guint
up_wakeup_item_get_old (UpWakeupItem *wakeup_item)
{
g_return_val_if_fail (UP_IS_WAKEUP_ITEM (wakeup_item), G_MAXUINT);
return wakeup_item->priv->old;
}
/**
* up_wakeup_item_set_old:
* @history_item: #UpWakeupItem
* @old: the new value
*
* Sets the item old.
*
* Since: 0.9.0
**/
void
up_wakeup_item_set_old (UpWakeupItem *wakeup_item, guint old)
{
g_return_if_fail (UP_IS_WAKEUP_ITEM (wakeup_item));
wakeup_item->priv->old = old;
g_object_notify (G_OBJECT(wakeup_item), "old");
}
/**
* up_wakeup_item_get_value:
* @history_item: #UpWakeupItem
*
* Gets the item value.
*
* Return value: the value
*
* Since: 0.9.0
**/
gdouble
up_wakeup_item_get_value (UpWakeupItem *wakeup_item)
{
g_return_val_if_fail (UP_IS_WAKEUP_ITEM (wakeup_item), G_MAXDOUBLE);
return wakeup_item->priv->value;
}
/**
* up_wakeup_item_set_value:
* @history_item: #UpWakeupItem
* @value: the new value
*
* Sets the item value.
*
* Since: 0.9.0
**/
void
up_wakeup_item_set_value (UpWakeupItem *wakeup_item, gdouble value)
{
g_return_if_fail (UP_IS_WAKEUP_ITEM (wakeup_item));
wakeup_item->priv->value = value;
g_object_notify (G_OBJECT(wakeup_item), "value");
}
/**
* up_wakeup_item_get_cmdline:
* @history_item: #UpWakeupItem
*
* Gets the item cmdline.
*
* Return value: the value
*
* Since: 0.9.0
**/
const gchar *
up_wakeup_item_get_cmdline (UpWakeupItem *wakeup_item)
{
g_return_val_if_fail (UP_IS_WAKEUP_ITEM (wakeup_item), NULL);
return wakeup_item->priv->cmdline;
}
/**
* up_wakeup_item_set_cmdline:
* @history_item: #UpWakeupItem
* @cmdline: the new value
*
* Sets the item cmdline.
*
* Since: 0.9.0
**/
void
up_wakeup_item_set_cmdline (UpWakeupItem *wakeup_item, const gchar *cmdline)
{
g_return_if_fail (UP_IS_WAKEUP_ITEM (wakeup_item));
g_free (wakeup_item->priv->cmdline);
wakeup_item->priv->cmdline = g_strdup (cmdline);
g_object_notify (G_OBJECT(wakeup_item), "cmdline");
}
/**
* up_wakeup_item_get_details:
* @history_item: #UpWakeupItem
*
* Gets the item details.
*
* Return value: the value
*
* Since: 0.9.0
**/
const gchar *
up_wakeup_item_get_details (UpWakeupItem *wakeup_item)
{
g_return_val_if_fail (UP_IS_WAKEUP_ITEM (wakeup_item), NULL);
return wakeup_item->priv->details;
}
/**
* up_wakeup_item_set_details:
* @history_item: #UpWakeupItem
* @details: the new value
*
* Sets the item details.
*
* Since: 0.9.0
**/
void
up_wakeup_item_set_details (UpWakeupItem *wakeup_item, const gchar *details)
{
g_return_if_fail (UP_IS_WAKEUP_ITEM (wakeup_item));
g_free (wakeup_item->priv->details);
wakeup_item->priv->details = g_strdup (details);
g_object_notify (G_OBJECT(wakeup_item), "details");
}
/**
* up_wakeup_item_set_property:
**/
static void
up_wakeup_item_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
UpWakeupItem *wakeup_item = UP_WAKEUP_ITEM (object);
switch (prop_id) {
case PROP_IS_USERSPACE:
wakeup_item->priv->is_userspace = g_value_get_boolean (value);
break;
case PROP_ID:
wakeup_item->priv->id = g_value_get_uint (value);
break;
case PROP_OLD:
wakeup_item->priv->old = g_value_get_uint (value);
break;
case PROP_VALUE:
wakeup_item->priv->value = g_value_get_double (value);
break;
case PROP_CMDLINE:
g_free (wakeup_item->priv->cmdline);
wakeup_item->priv->cmdline = g_strdup (g_value_get_string (value));
break;
case PROP_DETAILS:
g_free (wakeup_item->priv->details);
wakeup_item->priv->details = g_strdup (g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
/**
* up_wakeup_item_get_property:
**/
static void
up_wakeup_item_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
UpWakeupItem *wakeup_item = UP_WAKEUP_ITEM (object);
switch (prop_id) {
case PROP_IS_USERSPACE:
g_value_set_boolean (value, wakeup_item->priv->is_userspace);
break;
case PROP_ID:
g_value_set_uint (value, wakeup_item->priv->id);
break;
case PROP_OLD:
g_value_set_uint (value, wakeup_item->priv->old);
break;
case PROP_VALUE:
g_value_set_double (value, wakeup_item->priv->value);
break;
case PROP_CMDLINE:
g_value_set_string (value, wakeup_item->priv->cmdline);
break;
case PROP_DETAILS:
g_value_set_string (value, wakeup_item->priv->details);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
/**
* up_wakeup_item_class_init:
* @klass: The UpWakeupItemClass
**/
static void
up_wakeup_item_class_init (UpWakeupItemClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = up_wakeup_item_finalize;
object_class->set_property = up_wakeup_item_set_property;
object_class->get_property = up_wakeup_item_get_property;
/**
* UpWakeupItem:is-userspace:
*
* Since: 0.9.0
**/
g_object_class_install_property (object_class,
PROP_IS_USERSPACE,
g_param_spec_boolean ("is-userspace", NULL, NULL,
FALSE,
G_PARAM_READWRITE));
/**
* UpWakeupItem:id:
*
* Since: 0.9.0
**/
g_object_class_install_property (object_class,
PROP_ID,
g_param_spec_uint ("id", NULL, NULL,
0, G_MAXUINT, 0,
G_PARAM_READWRITE));
/**
* UpWakeupItem:old:
*
* Since: 0.9.0
**/
g_object_class_install_property (object_class,
PROP_OLD,
g_param_spec_uint ("old", NULL, NULL,
0, G_MAXUINT, 0,
G_PARAM_READWRITE));
/**
* UpWakeupItem:value:
*
* Since: 0.9.0
**/
g_object_class_install_property (object_class,
PROP_VALUE,
g_param_spec_double ("value", NULL, NULL,
0.0, G_MAXDOUBLE, 0.0,
G_PARAM_READWRITE));
/**
* UpWakeupItem:cmdline:
*
* Since: 0.9.0
**/
g_object_class_install_property (object_class,
PROP_CMDLINE,
g_param_spec_string ("cmdline", NULL, NULL,
NULL,
G_PARAM_READWRITE));
/**
* UpWakeupItem:details:
*
* Since: 0.9.0
**/
g_object_class_install_property (object_class,
PROP_DETAILS,
g_param_spec_string ("details", NULL, NULL,
NULL,
G_PARAM_READWRITE));
g_type_class_add_private (klass, sizeof (UpWakeupItemPrivate));
}
/**
* up_wakeup_item_init:
* @wakeup_item: This class instance
**/
static void
up_wakeup_item_init (UpWakeupItem *wakeup_item)
{
wakeup_item->priv = UP_WAKEUP_ITEM_GET_PRIVATE (wakeup_item);
wakeup_item->priv->is_userspace = FALSE;
wakeup_item->priv->id = 0;
wakeup_item->priv->old = 0;
wakeup_item->priv->value = 0.0f;
wakeup_item->priv->cmdline = NULL;
wakeup_item->priv->details = NULL;
}
/**
* up_wakeup_item_finalize:
* @object: The object to finalize
**/
static void
up_wakeup_item_finalize (GObject *object)
{
UpWakeupItem *wakeup_item;
g_return_if_fail (UP_IS_WAKEUP_ITEM (object));
wakeup_item = UP_WAKEUP_ITEM (object);
g_free (wakeup_item->priv->cmdline);
g_free (wakeup_item->priv->details);
G_OBJECT_CLASS (up_wakeup_item_parent_class)->finalize (object);
}
/**
* up_wakeup_item_new:
*
* Return value: a new UpWakeupItem object.
*
* Since: 0.9.0
**/
UpWakeupItem *
up_wakeup_item_new (void)
{
UpWakeupItem *wakeup_item;
wakeup_item = g_object_new (UP_TYPE_WAKEUP_ITEM, NULL);
return UP_WAKEUP_ITEM (wakeup_item);
}

View file

@ -0,0 +1,80 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2008 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU General Public License Version 2
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#if !defined (__UPOWER_H_INSIDE__) && !defined (UP_COMPILATION)
#error "Only <upower.h> can be included directly."
#endif
#ifndef __UP_WAKEUP_ITEM_H
#define __UP_WAKEUP_ITEM_H
#include <glib-object.h>
#include <libupower-glib/up-types.h>
G_BEGIN_DECLS
#define UP_TYPE_WAKEUP_ITEM (up_wakeup_item_get_type ())
#define UP_WAKEUP_ITEM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), UP_TYPE_WAKEUP_ITEM, UpWakeupItem))
#define UP_WAKEUP_ITEM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), UP_TYPE_WAKEUP_ITEM, UpWakeupItemClass))
#define UP_IS_WAKEUP_ITEM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), UP_TYPE_WAKEUP_ITEM))
#define UP_IS_WAKEUP_ITEM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), UP_TYPE_WAKEUP_ITEM))
#define UP_WAKEUP_ITEM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), UP_TYPE_WAKEUP_ITEM, UpWakeupItemClass))
typedef struct UpWakeupItemPrivate UpWakeupItemPrivate;
typedef struct
{
GObject parent;
UpWakeupItemPrivate *priv;
} UpWakeupItem;
typedef struct
{
GObjectClass parent_class;
} UpWakeupItemClass;
GType up_wakeup_item_get_type (void);
UpWakeupItem *up_wakeup_item_new (void);
/* accessors */
gboolean up_wakeup_item_get_is_userspace (UpWakeupItem *wakeup_item);
void up_wakeup_item_set_is_userspace (UpWakeupItem *wakeup_item,
gboolean is_userspace);
guint up_wakeup_item_get_id (UpWakeupItem *wakeup_item);
void up_wakeup_item_set_id (UpWakeupItem *wakeup_item,
guint id);
guint up_wakeup_item_get_old (UpWakeupItem *wakeup_item);
void up_wakeup_item_set_old (UpWakeupItem *wakeup_item,
guint old);
gdouble up_wakeup_item_get_value (UpWakeupItem *wakeup_item);
void up_wakeup_item_set_value (UpWakeupItem *wakeup_item,
gdouble value);
const gchar *up_wakeup_item_get_cmdline (UpWakeupItem *wakeup_item);
void up_wakeup_item_set_cmdline (UpWakeupItem *wakeup_item,
const gchar *cmdline);
const gchar *up_wakeup_item_get_details (UpWakeupItem *wakeup_item);
void up_wakeup_item_set_details (UpWakeupItem *wakeup_item,
const gchar *details);
G_END_DECLS
#endif /* __UP_WAKEUP_ITEM_H */

View file

@ -38,6 +38,10 @@
#include <libupower-glib/up-types.h>
#include <libupower-glib/up-client.h>
#include <libupower-glib/up-device.h>
#include <libupower-glib/up-qos-item.h>
#include <libupower-glib/up-history-item.h>
#include <libupower-glib/up-stats-item.h>
#include <libupower-glib/up-wakeup-item.h>
#undef __UPOWER_H_INSIDE__