summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrédéric Danis <frederic.danis@collabora.com>2023-01-16 10:08:22 +0100
committerRichard Hughes <richard@hughsie.com>2023-01-19 17:17:02 +0000
commit8fa1305a46a1e8403dfdabd56be9fdad5fa65161 (patch)
treebb5a8c7bbde58d8e49d1f6b274c808d7cdf811dc
parent50d2a3fd563bc89f567d42f952789ba793181cec (diff)
downloadgusb-8fa1305a46a1e8403dfdabd56be9fdad5fa65161.tar.gz
Load GUsb endpoints when loading interface
-rw-r--r--gusb/gusb-interface.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/gusb/gusb-interface.c b/gusb/gusb-interface.c
index c0fe7d4..fc5ccc4 100644
--- a/gusb/gusb-interface.c
+++ b/gusb/gusb-interface.c
@@ -86,6 +86,21 @@ _g_usb_interface_load(GUsbInterface *self, JsonObject *json_object, GError **err
self->iface.iInterface =
json_object_get_int_member_with_default(json_object, "Interface", 0x0);
+ /* array of endpoints */
+ if (json_object_has_member(json_object, "UsbEndpoints")) {
+ self->endpoints = g_ptr_array_new_with_free_func(g_object_unref);
+ JsonArray *json_array = json_object_get_array_member(json_object, "UsbEndpoints");
+ for (guint i = 0; i < json_array_get_length(json_array); i++) {
+ JsonNode *node_tmp = json_array_get_element(json_array, i);
+ JsonObject *obj_tmp = json_node_get_object(node_tmp);
+ g_autoptr(GUsbEndpoint) endpoint =
+ g_object_new(G_USB_TYPE_ENDPOINT, NULL);
+ if (!_g_usb_endpoint_load(endpoint, obj_tmp, error))
+ return FALSE;
+ g_ptr_array_add(self->endpoints, g_object_ref(endpoint));
+ }
+ }
+
/* extra data */
str = json_object_get_string_member_with_default(json_object, "ExtraData", NULL);
if (str != NULL) {