summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2022-09-05 18:06:09 +0100
committerRichard Hughes <richard@hughsie.com>2022-09-05 18:07:29 +0100
commitf38f99eb7e02cfedf94eccbd853842253261c8ca (patch)
treea426703163f6ad174a8a78856bac6109c34cfe5c
parent88e7c32dea37a8db19256745a0b334ec2b1b80a6 (diff)
downloadgusb-f38f99eb7e02cfedf94eccbd853842253261c8ca.tar.gz
Include the platform ID in the JSON file
-rw-r--r--gusb/gusb-device.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/gusb/gusb-device.c b/gusb/gusb-device.c
index 10422a9..6102f27 100644
--- a/gusb/gusb-device.c
+++ b/gusb/gusb-device.c
@@ -225,6 +225,7 @@ gboolean
_g_usb_device_load(GUsbDevice *self, JsonObject *json_object, GError **error)
{
GUsbDevicePrivate *priv = GET_PRIVATE(self);
+ const gchar *tmp;
g_return_val_if_fail(G_USB_IS_DEVICE(self), FALSE);
g_return_val_if_fail(json_object != NULL, FALSE);
@@ -232,6 +233,11 @@ _g_usb_device_load(GUsbDevice *self, JsonObject *json_object, GError **error)
#if JSON_CHECK_VERSION(1, 6, 0)
/* optional properties */
+ tmp = json_object_get_string_member_with_default(json_object, "PlatformId", NULL);
+ if (tmp != NULL) {
+ g_free(priv->platform_id);
+ priv->platform_id = g_strdup(tmp);
+ }
priv->desc.idVendor = json_object_get_int_member_with_default(json_object, "Vendor", 0x0);
priv->desc.idProduct = json_object_get_int_member_with_default(json_object, "Product", 0x0);
priv->desc.bcdDevice = json_object_get_int_member_with_default(json_object, "Device", 0x0);
@@ -317,6 +323,10 @@ _g_usb_device_save(GUsbDevice *self, JsonBuilder *json_builder, GError **error)
json_builder_begin_object(json_builder);
/* optional properties */
+ if (priv->platform_id != NULL) {
+ json_builder_set_member_name(json_builder, "PlatformId");
+ json_builder_add_string_value(json_builder, priv->platform_id);
+ }
if (priv->desc.idVendor != 0) {
json_builder_set_member_name(json_builder, "Vendor");
json_builder_add_int_value(json_builder, priv->desc.idVendor);