1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
3
* Copyright (C) 2008 David Zeuthen <davidz@redhat.com>
4
* Copyright (C) 2008 Richard Hughes <richard@hughsie.com>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28
* dkp_device_type_to_text:
31
dkp_device_type_to_text (DkpDeviceType type_enum)
33
const gchar *type = NULL;
35
case DKP_DEVICE_TYPE_LINE_POWER:
38
case DKP_DEVICE_TYPE_BATTERY:
41
case DKP_DEVICE_TYPE_UPS:
44
case DKP_DEVICE_TYPE_MONITOR:
47
case DKP_DEVICE_TYPE_MOUSE:
50
case DKP_DEVICE_TYPE_KEYBOARD:
53
case DKP_DEVICE_TYPE_PDA:
56
case DKP_DEVICE_TYPE_PHONE:
67
* dkp_device_type_from_text:
70
dkp_device_type_from_text (const gchar *type)
73
return DKP_DEVICE_TYPE_UNKNOWN;
74
if (g_strcmp0 (type, "line-power") == 0)
75
return DKP_DEVICE_TYPE_LINE_POWER;
76
if (g_strcmp0 (type, "battery") == 0)
77
return DKP_DEVICE_TYPE_BATTERY;
78
if (g_strcmp0 (type, "ups") == 0)
79
return DKP_DEVICE_TYPE_UPS;
80
if (g_strcmp0 (type, "monitor") == 0)
81
return DKP_DEVICE_TYPE_MONITOR;
82
if (g_strcmp0 (type, "mouse") == 0)
83
return DKP_DEVICE_TYPE_MOUSE;
84
if (g_strcmp0 (type, "keyboard") == 0)
85
return DKP_DEVICE_TYPE_KEYBOARD;
86
if (g_strcmp0 (type, "pda") == 0)
87
return DKP_DEVICE_TYPE_PDA;
88
if (g_strcmp0 (type, "phone") == 0)
89
return DKP_DEVICE_TYPE_PHONE;
90
return DKP_DEVICE_TYPE_UNKNOWN;
94
* dkp_device_state_to_text:
97
dkp_device_state_to_text (DkpDeviceState state_enum)
99
const gchar *state = NULL;
100
switch (state_enum) {
101
case DKP_DEVICE_STATE_CHARGING:
104
case DKP_DEVICE_STATE_DISCHARGING:
105
state = "discharging";
107
case DKP_DEVICE_STATE_EMPTY:
110
case DKP_DEVICE_STATE_FULLY_CHARGED:
111
state = "fully-charged";
113
case DKP_DEVICE_STATE_PENDING_CHARGE:
114
state = "pending-charge";
116
case DKP_DEVICE_STATE_PENDING_DISCHARGE:
117
state = "pending-discharge";
127
* dkp_device_state_from_text:
130
dkp_device_state_from_text (const gchar *state)
133
return DKP_DEVICE_STATE_UNKNOWN;
134
if (g_strcmp0 (state, "charging") == 0)
135
return DKP_DEVICE_STATE_CHARGING;
136
if (g_strcmp0 (state, "discharging") == 0)
137
return DKP_DEVICE_STATE_DISCHARGING;
138
if (g_strcmp0 (state, "empty") == 0)
139
return DKP_DEVICE_STATE_EMPTY;
140
if (g_strcmp0 (state, "fully-charged") == 0)
141
return DKP_DEVICE_STATE_FULLY_CHARGED;
142
if (g_strcmp0 (state, "pending-charge") == 0)
143
return DKP_DEVICE_STATE_PENDING_CHARGE;
144
if (g_strcmp0 (state, "pending-discharge") == 0)
145
return DKP_DEVICE_STATE_PENDING_DISCHARGE;
146
return DKP_DEVICE_STATE_UNKNOWN;
150
* dkp_device_technology_to_text:
153
dkp_device_technology_to_text (DkpDeviceTechnology technology_enum)
155
const gchar *technology = NULL;
156
switch (technology_enum) {
157
case DKP_DEVICE_TECHNOLOGY_LITHIUM_ION:
158
technology = "lithium-ion";
160
case DKP_DEVICE_TECHNOLOGY_LITHIUM_POLYMER:
161
technology = "lithium-polymer";
163
case DKP_DEVICE_TECHNOLOGY_LITHIUM_IRON_PHOSPHATE:
164
technology = "lithium-iron-phosphate";
166
case DKP_DEVICE_TECHNOLOGY_LEAD_ACID:
167
technology = "lead-acid";
169
case DKP_DEVICE_TECHNOLOGY_NICKEL_CADMIUM:
170
technology = "nickel-cadmium";
172
case DKP_DEVICE_TECHNOLOGY_NICKEL_METAL_HYDRIDE:
173
technology = "nickel-metal-hydride";
176
technology = "unknown";
183
* dkp_device_technology_from_text:
186
dkp_device_technology_from_text (const gchar *technology)
188
if (technology == NULL)
189
return DKP_DEVICE_TECHNOLOGY_UNKNOWN;
190
if (g_strcmp0 (technology, "lithium-ion") == 0)
191
return DKP_DEVICE_TECHNOLOGY_LITHIUM_ION;
192
if (g_strcmp0 (technology, "lithium-polymer") == 0)
193
return DKP_DEVICE_TECHNOLOGY_LITHIUM_POLYMER;
194
if (g_strcmp0 (technology, "lithium-iron-phosphate") == 0)
195
return DKP_DEVICE_TECHNOLOGY_LITHIUM_IRON_PHOSPHATE;
196
if (g_strcmp0 (technology, "lead-acid") == 0)
197
return DKP_DEVICE_TECHNOLOGY_LEAD_ACID;
198
if (g_strcmp0 (technology, "nickel-cadmium") == 0)
199
return DKP_DEVICE_TECHNOLOGY_NICKEL_CADMIUM;
200
if (g_strcmp0 (technology, "nickel-metal-hydride") == 0)
201
return DKP_DEVICE_TECHNOLOGY_NICKEL_METAL_HYDRIDE;
202
return DKP_DEVICE_TECHNOLOGY_UNKNOWN;
206
* dkp_qos_type_to_text:
209
dkp_qos_type_to_text (DkpQosType type)
211
if (type == DKP_QOS_TYPE_NETWORK)
213
if (type == DKP_QOS_TYPE_CPU_DMA)
219
* dkp_qos_type_from_text:
222
dkp_qos_type_from_text (const gchar *type)
224
if (g_strcmp0 (type, "network") == 0)
225
return DKP_QOS_TYPE_NETWORK;
226
if (g_strcmp0 (type, "cpu_dma") == 0)
227
return DKP_QOS_TYPE_CPU_DMA;
228
return DKP_QOS_TYPE_UNKNOWN;