~xavi-garcia-mena/ubuntu/vivid/upower/percentages-power-off

« back to all changes in this revision

Viewing changes to devkit-power-gobject/dkp-wakeups-obj.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2010-02-16 10:16:24 UTC
  • Revision ID: james.westby@ubuntu.com-20100216101624-2cmwqsr1ndftdd87
Tags: upstream-0.9.0+git20100216.72bb2
ImportĀ upstreamĀ versionĀ 0.9.0+git20100216.72bb2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
 
2
 *
 
3
 * Copyright (C) 2009 Richard Hughes <richard@hughsie.com>
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or modify
 
6
 * it under the terms of the GNU General Public License as published by
 
7
 * the Free Software Foundation; either version 2 of the License, or
 
8
 * (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program; if not, write to the Free Software
 
17
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
18
 *
 
19
 */
 
20
 
 
21
#include <glib.h>
 
22
#include <glib-object.h>
 
23
#include <string.h>
 
24
#include <stdlib.h>
 
25
 
 
26
#include "dkp-enum.h"
 
27
#include "dkp-wakeups-obj.h"
 
28
 
 
29
/**
 
30
 * dkp_wakeups_obj_clear_internal:
 
31
 **/
 
32
static void
 
33
dkp_wakeups_obj_clear_internal (DkpWakeupsObj *obj)
 
34
{
 
35
        obj->id = 0;
 
36
        obj->old = 0;
 
37
        obj->value = 0.0f;
 
38
        obj->is_userspace = FALSE;
 
39
        obj->cmdline = NULL;
 
40
        obj->details = NULL;
 
41
}
 
42
 
 
43
/**
 
44
 * dkp_wakeups_obj_copy:
 
45
 **/
 
46
DkpWakeupsObj *
 
47
dkp_wakeups_obj_copy (const DkpWakeupsObj *cobj)
 
48
{
 
49
        DkpWakeupsObj *obj;
 
50
        obj = g_new0 (DkpWakeupsObj, 1);
 
51
        obj->id = cobj->id;
 
52
        obj->value = cobj->value;
 
53
        obj->is_userspace = cobj->is_userspace;
 
54
        return obj;
 
55
}
 
56
 
 
57
/**
 
58
 * dkp_wakeups_obj_equal:
 
59
 **/
 
60
gboolean
 
61
dkp_wakeups_obj_equal (const DkpWakeupsObj *obj1, const DkpWakeupsObj *obj2)
 
62
{
 
63
        if (obj1->id == obj2->id)
 
64
                return TRUE;
 
65
        return FALSE;
 
66
}
 
67
 
 
68
/**
 
69
 * dkp_wakeups_obj_print:
 
70
 **/
 
71
gboolean
 
72
dkp_wakeups_obj_print (const DkpWakeupsObj *obj)
 
73
{
 
74
        g_print ("userspace:%i id:%i, interrupts:%.1f, cmdline:%s, details:%s\n", obj->is_userspace, obj->id, obj->value, obj->cmdline, obj->details);
 
75
        return TRUE;
 
76
}
 
77
 
 
78
/**
 
79
 * dkp_wakeups_obj_new:
 
80
 **/
 
81
DkpWakeupsObj *
 
82
dkp_wakeups_obj_new (void)
 
83
{
 
84
        DkpWakeupsObj *obj;
 
85
        obj = g_new0 (DkpWakeupsObj, 1);
 
86
        dkp_wakeups_obj_clear_internal (obj);
 
87
        return obj;
 
88
}
 
89
 
 
90
/**
 
91
 * dkp_wakeups_obj_free:
 
92
 **/
 
93
void
 
94
dkp_wakeups_obj_free (DkpWakeupsObj *obj)
 
95
{
 
96
        if (obj == NULL)
 
97
                return;
 
98
        g_free (obj->cmdline);
 
99
        g_free (obj->details);
 
100
        g_free (obj);
 
101
        return;
 
102
}
 
103