summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dkp-hid.c16
-rw-r--r--src/dkp-supply.c27
2 files changed, 41 insertions, 2 deletions
diff --git a/src/dkp-hid.c b/src/dkp-hid.c
index 69dfa95..90320fc 100644
--- a/src/dkp-hid.c
+++ b/src/dkp-hid.c
@@ -169,6 +169,20 @@ dkp_hid_get_string (DkpHid *hid, int sindex)
}
/**
+ * dkp_hid_convert_device_technology:
+ **/
+static DkpDeviceTechnology
+dkp_hid_convert_device_technology (const gchar *type)
+{
+ if (type == NULL)
+ return DKP_DEVICE_TECHNOLGY_UNKNOWN;
+ if (strcasecmp (type, "pb") == 0 ||
+ strcasecmp (type, "pbac") == 0)
+ return DKP_DEVICE_TECHNOLGY_LEAD_ACID;
+ return DKP_DEVICE_TECHNOLGY_UNKNOWN;
+}
+
+/**
* dkp_hid_set_obj:
**/
static gboolean
@@ -202,7 +216,7 @@ dkp_hid_set_obj (DkpHid *hid, int code, int value)
break;
case DKP_HID_CHEMISTRY:
type = dkp_hid_get_string (hid, value);
- obj->technology = dkp_acpi_to_device_technology (type);
+ obj->technology = dkp_hid_convert_device_technology (type);
break;
case DKP_HID_RECHARGEABLE:
obj->is_rechargeable = (value != 0);
diff --git a/src/dkp-supply.c b/src/dkp-supply.c
index 588631d..80ec755 100644
--- a/src/dkp-supply.c
+++ b/src/dkp-supply.c
@@ -190,6 +190,31 @@ dkp_supply_calculate_rate (DkpSupply *supply)
}
/**
+ * dkp_supply_convert_device_technology:
+ **/
+static DkpDeviceTechnology
+dkp_supply_convert_device_technology (const gchar *type)
+{
+ if (type == NULL)
+ return DKP_DEVICE_TECHNOLGY_UNKNOWN;
+ /* every case combination of Li-Ion is commonly used.. */
+ if (strcasecmp (type, "li-ion") == 0 ||
+ strcasecmp (type, "lion") == 0)
+ return DKP_DEVICE_TECHNOLGY_LITHIUM_ION;
+ if (strcasecmp (type, "pb") == 0 ||
+ strcasecmp (type, "pbac") == 0)
+ return DKP_DEVICE_TECHNOLGY_LEAD_ACID;
+ if (strcasecmp (type, "lip") == 0 ||
+ strcasecmp (type, "lipo") == 0)
+ return DKP_DEVICE_TECHNOLGY_LITHIUM_POLYMER;
+ if (strcasecmp (type, "nimh") == 0)
+ return DKP_DEVICE_TECHNOLGY_NICKEL_METAL_HYDRIDE;
+ if (strcasecmp (type, "lifo") == 0)
+ return DKP_DEVICE_TECHNOLGY_LITHIUM_IRON_PHOSPHATE;
+ return DKP_DEVICE_TECHNOLGY_UNKNOWN;
+}
+
+/**
* dkp_supply_refresh_battery:
*
* Return value: TRUE if we changed
@@ -220,7 +245,7 @@ dkp_supply_refresh_battery (DkpSupply *supply)
/* the ACPI spec is bad at defining battery type constants */
technology_native = g_strstrip (sysfs_get_string (obj->native_path, "technology"));
- obj->technology = dkp_acpi_to_device_technology (technology_native);
+ obj->technology = dkp_supply_convert_device_technology (technology_native);
g_free (technology_native);
obj->vendor = g_strstrip (sysfs_get_string (obj->native_path, "manufacturer"));