Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package libgusb for openSUSE:Factory checked in at 2021-12-23 17:53:30 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libgusb (Old) and /work/SRC/openSUSE:Factory/.libgusb.new.2520 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libgusb" Thu Dec 23 17:53:30 2021 rev:21 rq:942103 version:0.3.9 Changes: -------- --- /work/SRC/openSUSE:Factory/libgusb/libgusb.changes 2021-01-11 17:12:59.268316130 +0100 +++ /work/SRC/openSUSE:Factory/.libgusb.new.2520/libgusb.changes 2021-12-23 17:53:40.683716461 +0100 @@ -1,0 +2,12 @@ +Wed Dec 22 12:12:22 UTC 2021 - Callum Farmer <gm...@opensuse.org> + +- Update to version 0.3.9: + - Add g_usb_device_get_string_descriptor_bytes() + - Do not double-reference USB devices + - Fix hotplug handling and signal emission during enumerate + - Add the GUsbEndpoint methods to the docs + - Add g_usb_device_get_string_descriptor_bytes_full + - Fix hotplug after threaded device removal + - Don't hard-code the list of OS supporting --version-script + +------------------------------------------------------------------- Old: ---- libgusb-0.3.5.tar.xz New: ---- libgusb-0.3.9.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libgusb.spec ++++++ --- /var/tmp/diff_new_pack.E8idFr/_old 2021-12-23 17:53:41.055716691 +0100 +++ /var/tmp/diff_new_pack.E8idFr/_new 2021-12-23 17:53:41.059716694 +0100 @@ -17,7 +17,7 @@ Name: libgusb -Version: 0.3.5 +Version: 0.3.9 Release: 0 Summary: GObject-based library for libusb1 License: LGPL-2.1-or-later ++++++ libgusb-0.3.5.tar.xz -> libgusb-0.3.9.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libgusb-0.3.5/.github/workflows/main.yml new/libgusb-0.3.9/.github/workflows/main.yml --- old/libgusb-0.3.5/.github/workflows/main.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/libgusb-0.3.9/.github/workflows/main.yml 2021-12-07 11:37:59.371745000 +0100 @@ -0,0 +1,40 @@ +name: Build and Test + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build-linux: + runs-on: ubuntu-latest + + strategy: + matrix: + distro: + - fedora + - debian + fail-fast: false + + steps: + - uses: actions/checkout@v2 + - run: docker build -t libgusb-${{ matrix.distro }} -f contrib/ci/Dockerfile-${{ matrix.distro }} . + - run: docker run -t -v `pwd`:/build libgusb-${{ matrix.distro }} ./contrib/ci/build_and_test.sh -Dtests=false + + build-freebsd: + runs-on: macos-10.15 + + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Build + id: test + uses: vmactions/freebsd-vm@v0.1.5 + with: + usesh: true + mem: 8192 + prepare: | + pkg install -y git python3 glib meson pkgconf gobject-introspection usbids + sync: rsync + run: ./contrib/ci/build_and_test.sh -Dvapi=false -Ddocs=false -Dusb_ids=/usr/local/share/usbids/usb.ids diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libgusb-0.3.5/.travis.yml new/libgusb-0.3.9/.travis.yml --- old/libgusb-0.3.5/.travis.yml 2020-07-30 11:44:24.034256000 +0200 +++ new/libgusb-0.3.9/.travis.yml 1970-01-01 01:00:00.000000000 +0100 @@ -1,14 +0,0 @@ -language: c -sudo: required -dist: trusty - -services: - - docker - -before_script: - - docker build -t gusb-fedora -f contrib/ci/Dockerfile-fedora . -# - docker build -t gusb-debian-stretch -f contrib/ci/Dockerfile-debian-stretch . - -script: - - docker run -t -v `pwd`:/build gusb-fedora ./contrib/ci/build_and_test.sh -Dtests=false -# - docker run -t -v `pwd`:/build gusb-debian-stretch ./contrib/ci/build_and_test.sh -Dtests=false diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libgusb-0.3.5/NEWS new/libgusb-0.3.9/NEWS --- old/libgusb-0.3.5/NEWS 2020-07-30 11:44:24.034256000 +0200 +++ new/libgusb-0.3.9/NEWS 2021-12-07 11:37:59.372745000 +0100 @@ -1,3 +1,48 @@ +Version 0.3.9 +~~~~~~~~~~~~~ +Released: 2021-12-07 + +Bugfixes: + - Don't hard-code the list of OS supporting --version-script (Ting-Wei Lan) + - Fix hotplug after threaded device removal (Richard Hughes) + - Fix version script check for GNU BFD linker on FreeBSD (Ting-Wei Lan) + +Version 0.3.8 +~~~~~~~~~~~~~ +Released: 2021-10-06 + +New Features: + - Add g_usb_device_get_string_descriptor_bytes_full (Ricardo Ca??uelo) + +Bugfixes: + - Add the GUsbEndpoint methods to the docs (Richard Hughes) + - Fix hotplug handling and signal emission during enumerate (Benjamin Berg) + +Version 0.3.7 +~~~~~~~~~~~~~ +Released: 2021-05-24 + +New Features: + - Add a FreeBSD CI target (Richard Hughes) + +Bugfixes: + - Do not depend on libusb_get_parent() to fix FreeBSD compile (Richard Hughes) + - Do not depend on libusb_get_port_number() to fix DragonFlyBSD compile (Richard Hughes) + - Do not double-reference USB devices (Marco Trevisan) + - Do not run the tests on FreeBSD (Richard Hughes) + - Require *any* python3 to fix FreeBSD build (Richard Hughes) + +Version 0.3.6 +~~~~~~~~~~~~~ +Released: 2021-03-12 + +New Features: + - Add g_usb_device_get_string_descriptor_bytes() (Richard Hughes) + +Bugfixes: + - Properly set dylib versions on darwin (Caleb Xu) + - Fix cancellation if cancellable is already cancelled (Benjamin Berg) + Version 0.3.5 ~~~~~~~~~~~~~ Released: 2020-07-30 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libgusb-0.3.5/RELEASE.md new/libgusb-0.3.9/RELEASE.md --- old/libgusb-0.3.5/RELEASE.md 2020-07-30 11:44:24.035256100 +0200 +++ new/libgusb-0.3.9/RELEASE.md 2021-12-07 11:37:59.372745000 +0100 @@ -3,11 +3,11 @@ Write `NEWS` entries for GUsb in the same format as usual. - git shortlog 0.3.4.. | grep -i -v trivial | grep -v Merge > NEWS.new + git shortlog 0.3.8.. | grep -i -v trivial | grep -v Merge > NEWS.new ================================================= - Version 0.3.5 + Version 0.3.9 ~~~~~~~~~~~~~ - Released: 2020-xx-xx + Released: 2021-xx-xx Notes: @@ -19,7 +19,7 @@ Update library version if new ABI or API in `meson.build`, commit, and build tarball: # MAKE SURE THIS IS CORRECT - export release_ver="0.3.5" + export release_ver="0.3.9" git commit -a -m "Release version ${release_ver}" git tag -s -f -m "Release ${release_ver}" "${release_ver}" @@ -41,7 +41,7 @@ Send an email to devkit-de...@lists.freedesktop.org ================================================= - GUsb 0.3.5 released! + GUsb 0.3.9 released! GUsb is a GObject wrapper for libusb1 that makes it easy to do asynchronous control, bulk and interrupt transfers with proper diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libgusb-0.3.5/contrib/ci/Dockerfile-debian new/libgusb-0.3.9/contrib/ci/Dockerfile-debian --- old/libgusb-0.3.5/contrib/ci/Dockerfile-debian 1970-01-01 01:00:00.000000000 +0100 +++ new/libgusb-0.3.9/contrib/ci/Dockerfile-debian 2021-12-07 11:37:59.372745000 +0100 @@ -0,0 +1,9 @@ +FROM debian:buster + +RUN echo "deb-src http://deb.debian.org/debian/ buster main" >> /etc/apt/sources.list +RUN apt-get update -qq +RUN apt-get install -yq --no-install-recommends meson +RUN apt-get build-dep --allow-unauthenticated -yq libgusb + +RUN mkdir /build +WORKDIR /build diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libgusb-0.3.5/contrib/ci/Dockerfile-debian-stretch new/libgusb-0.3.9/contrib/ci/Dockerfile-debian-stretch --- old/libgusb-0.3.5/contrib/ci/Dockerfile-debian-stretch 2020-07-30 11:44:24.035256100 +0200 +++ new/libgusb-0.3.9/contrib/ci/Dockerfile-debian-stretch 1970-01-01 01:00:00.000000000 +0100 @@ -1,9 +0,0 @@ -FROM debian:stretch - -RUN echo "deb-src http://deb.debian.org/debian/ stretch main" >> /etc/apt/sources.list -RUN apt-get update -qq -RUN apt-get install -yq --no-install-recommends meson -RUN apt-get build-dep --allow-unauthenticated -yq libgusb - -RUN mkdir /build -WORKDIR /build diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libgusb-0.3.5/contrib/ci/Dockerfile-fedora new/libgusb-0.3.9/contrib/ci/Dockerfile-fedora --- old/libgusb-0.3.5/contrib/ci/Dockerfile-fedora 2020-07-30 11:44:24.035256100 +0200 +++ new/libgusb-0.3.9/contrib/ci/Dockerfile-fedora 2021-12-07 11:37:59.372745000 +0100 @@ -1,4 +1,4 @@ -FROM fedora:31 +FROM fedora:34 RUN dnf -y update RUN dnf -y install \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libgusb-0.3.5/contrib/ci/build_and_test.sh new/libgusb-0.3.9/contrib/ci/build_and_test.sh --- old/libgusb-0.3.5/contrib/ci/build_and_test.sh 2020-07-30 11:44:24.035256100 +0200 +++ new/libgusb-0.3.9/contrib/ci/build_and_test.sh 2021-12-07 11:37:59.372745000 +0100 @@ -2,7 +2,6 @@ set -e mkdir -p build && cd build -rm * -rf meson .. $@ ninja -v ninja test -v diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libgusb-0.3.5/contrib/libgusb.spec.in new/libgusb-0.3.9/contrib/libgusb.spec.in --- old/libgusb-0.3.5/contrib/libgusb.spec.in 2020-07-30 11:44:24.035256100 +0200 +++ new/libgusb-0.3.9/contrib/libgusb.spec.in 2021-12-07 11:37:59.373745000 +0100 @@ -13,8 +13,7 @@ BuildRequires: gtk-doc BuildRequires: libusb1-devel >= 1.0.19 BuildRequires: meson -BuildRequires: vala-devel -BuildRequires: vala-tools +BuildRequires: vala %description GUsb is a GObject wrapper for libusb1 that makes it easy to do @@ -42,14 +41,12 @@ %ldconfig_scriptlets %files -%defattr(-,root,root,-) %doc README.md AUTHORS NEWS COPYING %{_libdir}/libgusb.so.? %{_libdir}/libgusb.so.?.0.* %{_libdir}/girepository-1.0/GUsb-1.0.typelib %files devel -%defattr(-,root,root,-) %{_includedir}/gusb-1 %{_bindir}/gusbcmd %{_libdir}/libgusb.so diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libgusb-0.3.5/docs/api/gusb-docs.sgml new/libgusb-0.3.9/docs/api/gusb-docs.sgml --- old/libgusb-0.3.5/docs/api/gusb-docs.sgml 2020-07-30 11:44:24.035256100 +0200 +++ new/libgusb-0.3.9/docs/api/gusb-docs.sgml 2021-12-07 11:37:59.373745000 +0100 @@ -51,6 +51,7 @@ <xi:include href="xml/gusb-device.xml"/> <xi:include href="xml/gusb-device-list.xml"/> <xi:include href="xml/gusb-interface.xml"/> + <xi:include href="xml/gusb-endpoint.xml"/> </reference> <reference id="libgusb-helpers"> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libgusb-0.3.5/gusb/gusb-context.c new/libgusb-0.3.9/gusb/gusb-context.c --- old/libgusb-0.3.5/gusb/gusb-context.c 2020-07-30 11:44:24.035256100 +0200 +++ new/libgusb-0.3.9/gusb/gusb-context.c 2021-12-07 11:37:59.374745100 +0100 @@ -56,6 +56,11 @@ libusb_hotplug_callback_handle hotplug_id; }; +/* not defined in FreeBSD */ +#ifndef HAVE_LIBUSB_CAP_HAS_HOTPLUG +#define LIBUSB_CAP_HAS_HOTPLUG 0x0001 +#endif + typedef struct { GMainLoop *loop; GUsbDevice *device; @@ -72,6 +77,17 @@ G_IMPLEMENT_INTERFACE(G_TYPE_INITABLE, g_usb_context_initable_iface_init)) +/* not defined in FreeBSD */ +#ifndef HAVE_LIBUSB_HAS_CAPABILITY +static gboolean +libusb_has_capability (int cap) +{ + if (cap == LIBUSB_CAP_HAS_HOTPLUG) + return TRUE; + return FALSE; +} +#endif + static void g_usb_context_replug_helper_free (GUsbContextReplugHelper *replug_helper) { @@ -151,7 +167,7 @@ switch (prop_id) { case PROP_DEBUG_LEVEL: priv->debug_level = g_value_get_int (value); -#ifdef HAVE_LIBUSB_1_0_22 +#ifdef HAVE_LIBUSB_SET_OPTION libusb_set_option (priv->ctx, LIBUSB_OPTION_LOG_LEVEL, priv->debug_level); #else libusb_set_debug (priv->ctx, priv->debug_level); @@ -226,59 +242,26 @@ G_USB_TYPE_DEVICE); } -typedef struct { - GUsbContext *context; - GUsbDevice *device; - guint signal_id; -} GUsbContextIdleHelper; - -static void -g_usb_context_idle_helper_free (GUsbContextIdleHelper *helper) -{ - g_object_unref (helper->context); - g_object_unref (helper->device); - g_free (helper); -} - -static gboolean -g_usb_context_idle_signal_cb (gpointer user_data) -{ - GUsbContextIdleHelper *helper = (GUsbContextIdleHelper *) user_data; - g_signal_emit (helper->context, signals[helper->signal_id], 0, helper->device); - g_usb_context_idle_helper_free (helper); - return FALSE; -} - static void g_usb_context_emit_device_add (GUsbContext *context, GUsbDevice *device) { - GUsbContextIdleHelper *helper; - helper = g_new0 (GUsbContextIdleHelper, 1); - helper->context = g_object_ref (context); - helper->device = g_object_ref (device); - helper->signal_id = DEVICE_ADDED_SIGNAL; - if (!context->priv->done_enumerate) { - g_usb_context_idle_signal_cb (helper); + /* emitted directly by g_usb_context_enumerate */ + if (!context->priv->done_enumerate) return; - } - g_idle_add (g_usb_context_idle_signal_cb, helper); + + g_signal_emit (context, signals[DEVICE_ADDED_SIGNAL], 0, device); } static void g_usb_context_emit_device_remove (GUsbContext *context, GUsbDevice *device) { - GUsbContextIdleHelper *helper; - helper = g_new0 (GUsbContextIdleHelper, 1); - helper->context = g_object_ref (context); - helper->device = g_object_ref (device); - helper->signal_id = DEVICE_REMOVED_SIGNAL; - if (!context->priv->done_enumerate) { - g_usb_context_idle_signal_cb (helper); + /* should not happen, if it does we would not fire any signal */ + if (!context->priv->done_enumerate) return; - } - g_idle_add (g_usb_context_idle_signal_cb, helper); + + g_signal_emit (context, signals[DEVICE_REMOVED_SIGNAL], 0, device); } static void @@ -380,24 +363,56 @@ g_object_unref (device); } -static int -g_usb_context_hotplug_cb (struct libusb_context *ctx, - struct libusb_device *dev, - libusb_hotplug_event event, - void *user_data) +typedef struct { + GUsbContext *context; + libusb_device *dev; + libusb_hotplug_event event; +} GUsbContextIdleHelper; + +static void +g_usb_context_idle_helper_free (GUsbContextIdleHelper *helper) { - GUsbContext *context = G_USB_CONTEXT (user_data); + g_object_unref (helper->context); + libusb_unref_device (helper->dev); + g_free (helper); +} - switch (event) { +static gboolean +g_usb_context_idle_hotplug_cb (gpointer user_data) +{ + GUsbContextIdleHelper *helper = (GUsbContextIdleHelper *) user_data; + + switch (helper->event) { case LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED: - g_usb_context_add_device (context, dev); + g_usb_context_add_device (helper->context, helper->dev); break; case LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT: - g_usb_context_remove_device (context, dev); + g_usb_context_remove_device (helper->context, helper->dev); break; default: break; } + + g_usb_context_idle_helper_free (helper); + return FALSE; +} + +static int +g_usb_context_hotplug_cb (struct libusb_context *ctx, + struct libusb_device *dev, + libusb_hotplug_event event, + void *user_data) +{ + GUsbContext *context = G_USB_CONTEXT (user_data); + GUsbContextIdleHelper *helper; + + helper = g_new0 (GUsbContextIdleHelper, 1); + helper->context = g_object_ref (context); + helper->dev = libusb_ref_device (dev); + helper->event = event; + + g_idle_add (g_usb_context_idle_hotplug_cb, helper); + return 0; } @@ -452,7 +467,6 @@ return TRUE; } - /** * g_usb_context_get_main_context: * @context: a #GUsbContext @@ -523,6 +537,13 @@ context); } priv->done_enumerate = TRUE; + + /* emit device-added signals before returning */ + for (guint i = 0; i < priv->devices->len; i++) + g_signal_emit (context, signals[DEVICE_ADDED_SIGNAL], 0, + g_ptr_array_index (priv->devices, i)); + + /* any queued up hotplug events are queued as idle handlers */ } /** @@ -710,7 +731,7 @@ if (debug_level != priv->debug_level) { priv->debug_level = debug_level; -#ifdef HAVE_LIBUSB_1_0_22 +#ifdef HAVE_LIBUSB_SET_OPTION libusb_set_option (priv->ctx, LIBUSB_OPTION_LOG_LEVEL, debug_level); #else libusb_set_debug (priv->ctx, debug_level); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libgusb-0.3.5/gusb/gusb-device.c new/libgusb-0.3.9/gusb/gusb-device.c --- old/libgusb-0.3.5/gusb/gusb-device.c 2020-07-30 11:44:24.036256000 +0200 +++ new/libgusb-0.3.9/gusb/gusb-device.c 2021-12-07 11:37:59.375745000 +0100 @@ -110,6 +110,18 @@ } static void +set_libusb_device (GUsbDevice *device, + struct libusb_device *dev) +{ + GUsbDevicePrivate *priv = device->priv; + + g_clear_pointer (&priv->device, libusb_unref_device); + + if (dev != NULL) + priv->device = libusb_ref_device (dev); +} + +static void g_usb_device_set_property (GObject *object, guint prop_id, const GValue *value, @@ -120,7 +132,7 @@ switch (prop_id) { case PROP_LIBUSB_DEVICE: - priv->device = g_value_get_pointer (value); + set_libusb_device (device, g_value_get_pointer (value)); break; case PROP_CONTEXT: priv->context = g_value_dup_object (value); @@ -146,8 +158,6 @@ if (!priv->device) g_error("constructed without a libusb_device"); - libusb_ref_device(priv->device); - rc = libusb_get_device_descriptor (priv->device, &priv->desc); if (rc != LIBUSB_SUCCESS) g_warning ("Failed to get USB descriptor for device: %s", @@ -202,6 +212,24 @@ device->priv = g_usb_device_get_instance_private (device); } +/* not defined in FreeBSD */ +#ifndef HAVE_LIBUSB_GET_PARENT +static libusb_device * +libusb_get_parent (libusb_device *dev) +{ + return NULL; +} +#endif + +/* not defined in DragonFlyBSD */ +#ifndef HAVE_LIBUSB_GET_PORT_NUMBER +static guint8 +libusb_get_port_number (libusb_device *dev) +{ + return 0xff; +} +#endif + static void g_usb_device_build_parent_port_number (GString *str, libusb_device *dev) { @@ -241,8 +269,6 @@ return FALSE; } - libusb_ref_device (priv->device); - rc = libusb_get_device_descriptor (priv->device, &priv->desc); if (rc != LIBUSB_SUCCESS) { g_set_error (error, G_USB_DEVICE_ERROR, G_USB_DEVICE_ERROR_INTERNAL, @@ -889,6 +915,78 @@ return g_strdup ((const gchar *)buf); } +/** + * g_usb_device_get_string_descriptor_bytes_full: + * @desc_index: the index for the string descriptor to retrieve + * @langid: the language ID + * @length: size of the request data buffer + * @error: a #GError, or %NULL + * + * Get a raw string descriptor from the device. The returned string should be freed + * with g_bytes_unref() when no longer needed. + * + * Return value: (transfer full): a possibly UTF-16 string, or NULL on error. + * + * Since: 0.3.8 + **/ +GBytes * +g_usb_device_get_string_descriptor_bytes_full (GUsbDevice *device, + guint8 desc_index, + guint16 langid, + gsize length, + GError **error) +{ + gint rc; + g_autofree guint8 *buf = g_malloc0(length); + + g_return_val_if_fail (G_USB_IS_DEVICE (device), NULL); + g_return_val_if_fail (error == NULL || *error == NULL, NULL); + + if (device->priv->handle == NULL) { + g_usb_device_not_open_error (device, error); + return NULL; + } + + rc = libusb_get_string_descriptor (device->priv->handle, + desc_index, langid, + buf, length); + if (rc < 0) { + g_usb_device_libusb_error_to_gerror (device, rc, error); + return NULL; + } + + return g_bytes_new (buf, rc); +} + +/** + * g_usb_device_get_string_descriptor_bytes: + * @desc_index: the index for the string descriptor to retrieve + * @langid: the language ID + * @error: a #GError, or %NULL + * + * Get a raw string descriptor from the device. The returned string should be freed + * with g_bytes_unref() when no longer needed. + * The descriptor will be at most 128 btes in length, if you need to + * issue a request with either a smaller or larger descriptor, you can + * use g_usb_device_get_string_descriptor_bytes_full instead. + * + * Return value: (transfer full): a possibly UTF-16 string, or NULL on error. + * + * Since: 0.3.6 + **/ +GBytes * +g_usb_device_get_string_descriptor_bytes (GUsbDevice *device, + guint8 desc_index, + guint16 langid, + GError **error) +{ + return g_usb_device_get_string_descriptor_bytes_full(device, + desc_index, + langid, + 128, + error); +} + typedef gssize (GUsbDeviceTransferFinishFunc) (GUsbDevice *device, GAsyncResult *res, GError **error); typedef struct { @@ -919,7 +1017,7 @@ * either input or output * @length: the length field for the setup packet. * @actual_length: (out) (optional): the actual number of bytes sent, or %NULL - * @timeout: timeout timeout (in millseconds) that this function should wait + * @timeout: timeout timeout (in milliseconds) that this function should wait * before giving up due to no response being received. For an unlimited * timeout, use 0. * @cancellable: a #GCancellable, or %NULL @@ -986,7 +1084,7 @@ * either input or output * @length: the length field for the setup packet. * @actual_length: (out) (optional): the actual number of bytes sent, or %NULL - * @timeout: timeout timeout (in millseconds) that this function should wait + * @timeout: timeout timeout (in milliseconds) that this function should wait * before giving up due to no response being received. For an unlimited * timeout, use 0. * @cancellable: a #GCancellable, or %NULL @@ -1043,7 +1141,7 @@ * either input or output * @length: the length field for the setup packet. * @actual_length: (out) (optional): the actual number of bytes sent, or %NULL - * @timeout: timeout timeout (in millseconds) that this function should wait + * @timeout: timeout timeout (in milliseconds) that this function should wait * before giving up due to no response being received. For an unlimited * timeout, use 0. * @cancellable: a #GCancellable, or %NULL @@ -1223,7 +1321,7 @@ * @data: (array length=length): a suitably-sized data buffer for * either input or output * @length: the length field for the setup packet. - * @timeout: timeout timeout (in millseconds) that this function should wait + * @timeout: timeout timeout (in milliseconds) that this function should wait * before giving up due to no response being received. For an unlimited * timeout, use 0. * @cancellable: a #GCancellable, or %NULL @@ -1267,18 +1365,14 @@ req->transfer = libusb_alloc_transfer (0); req->data = data; - /* setup cancellation */ - if (cancellable != NULL) { - req->cancellable = g_object_ref (cancellable); - req->cancellable_id = g_cancellable_connect (req->cancellable, - G_CALLBACK (g_usb_device_cancelled_cb), - req, - NULL); - } - task = g_task_new (device, cancellable, callback, user_data); g_task_set_task_data (task, req, (GDestroyNotify)g_usb_device_req_free); + if (g_task_return_error_if_cancelled (task)) { + g_object_unref (task); + return; + } + /* munge back to flags */ if (direction == G_USB_DEVICE_DIRECTION_DEVICE_TO_HOST) request_type_raw |= 0x80; @@ -1307,6 +1401,15 @@ g_task_return_error (task, error); g_object_unref (task); } + + /* setup cancellation after submission */ + if (cancellable != NULL) { + req->cancellable = g_object_ref (cancellable); + req->cancellable_id = g_cancellable_connect (req->cancellable, + G_CALLBACK (g_usb_device_cancelled_cb), + req, + NULL); + } } /** @@ -1340,7 +1443,7 @@ * @data: (array length=length): a suitably-sized data buffer for * either input or output * @length: the length field for the setup packet. - * @timeout: timeout timeout (in millseconds) that this function should wait + * @timeout: timeout timeout (in milliseconds) that this function should wait * before giving up due to no response being received. For an unlimited * timeout, use 0. * @cancellable: a #GCancellable, or %NULL @@ -1377,18 +1480,14 @@ req = g_slice_new0 (GcmDeviceReq); req->transfer = libusb_alloc_transfer (0); - /* setup cancellation */ - if (cancellable != NULL) { - req->cancellable = g_object_ref (cancellable); - req->cancellable_id = g_cancellable_connect (req->cancellable, - G_CALLBACK (g_usb_device_cancelled_cb), - req, - NULL); - } - task = g_task_new (device, cancellable, callback, user_data); g_task_set_task_data (task, req, (GDestroyNotify)g_usb_device_req_free); + if (g_task_return_error_if_cancelled (task)) { + g_object_unref (task); + return; + } + /* fill in transfer details */ libusb_fill_bulk_transfer (req->transfer, device->priv->handle, @@ -1406,6 +1505,15 @@ g_task_return_error (task, error); g_object_unref (task); } + + /* setup cancellation after submission */ + if (cancellable != NULL) { + req->cancellable = g_object_ref (cancellable); + req->cancellable_id = g_cancellable_connect (req->cancellable, + G_CALLBACK (g_usb_device_cancelled_cb), + req, + NULL); + } } /** @@ -1439,7 +1547,7 @@ * @data: (array length=length): a suitably-sized data buffer for * either input or output * @length: the length field for the setup packet. - * @timeout: timeout timeout (in millseconds) that this function should wait + * @timeout: timeout timeout (in milliseconds) that this function should wait * before giving up due to no response being received. For an unlimited * timeout, use 0. * @cancellable: a #GCancellable, or %NULL @@ -1476,18 +1584,14 @@ req = g_slice_new0 (GcmDeviceReq); req->transfer = libusb_alloc_transfer (0); - /* setup cancellation */ - if (cancellable != NULL) { - req->cancellable = g_object_ref (cancellable); - req->cancellable_id = g_cancellable_connect (req->cancellable, - G_CALLBACK (g_usb_device_cancelled_cb), - req, - NULL); - } - task = g_task_new (device, cancellable, callback, user_data); g_task_set_task_data (task, req, (GDestroyNotify)g_usb_device_req_free); + if (g_task_return_error_if_cancelled (task)) { + g_object_unref (task); + return; + } + /* fill in transfer details */ libusb_fill_interrupt_transfer (req->transfer, device->priv->handle, @@ -1505,6 +1609,15 @@ g_task_return_error (task, error); g_object_unref (task); } + + /* setup cancellation after submission */ + if (cancellable != NULL) { + req->cancellable = g_object_ref (cancellable); + req->cancellable_id = g_cancellable_connect (req->cancellable, + G_CALLBACK (g_usb_device_cancelled_cb), + req, + NULL); + } } /** diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libgusb-0.3.5/gusb/gusb-device.h new/libgusb-0.3.9/gusb/gusb-device.h --- old/libgusb-0.3.5/gusb/gusb-device.h 2020-07-30 11:44:24.036256000 +0200 +++ new/libgusb-0.3.9/gusb/gusb-device.h 2021-12-07 11:37:59.375745000 +0100 @@ -118,6 +118,17 @@ G_USB_DEVICE_CLASS_VENDOR_SPECIFIC = 0xff } GUsbDeviceClassCode; + +/** + * GUsbDeviceLangid: + * + * The USB language ID. + **/ +typedef enum { + G_USB_DEVICE_LANGID_INVALID = 0x0000, + G_USB_DEVICE_LANGID_ENGLISH_UNITED_STATES = 0x0409, +} GUsbDeviceLangid; + struct _GUsbDevice { GObject parent; @@ -201,9 +212,18 @@ guint8 alt, GError **error); -gchar *g_usb_device_get_string_descriptor (GUsbDevice *device, - guint8 desc_index, - GError **error); +gchar *g_usb_device_get_string_descriptor (GUsbDevice *device, + guint8 desc_index, + GError **error); +GBytes *g_usb_device_get_string_descriptor_bytes (GUsbDevice *device, + guint8 desc_index, + guint16 langid, + GError **error); +GBytes *g_usb_device_get_string_descriptor_bytes_full (GUsbDevice *device, + guint8 desc_index, + guint16 langid, + gsize length, + GError **error); /* sync -- TODO: use GCancellable and GUsbSource */ gboolean g_usb_device_control_transfer (GUsbDevice *device, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libgusb-0.3.5/gusb/gusb-endpoint.c new/libgusb-0.3.9/gusb/gusb-endpoint.c --- old/libgusb-0.3.5/gusb/gusb-endpoint.c 2020-07-30 11:44:24.036256000 +0200 +++ new/libgusb-0.3.9/gusb/gusb-endpoint.c 2021-12-07 11:37:59.375745000 +0100 @@ -12,11 +12,13 @@ * This object is a thin glib wrapper around a libusb_endpoint_descriptor. * * All the data is copied when the object is created and the original - * descriptor can be destoyed any at point. + * descriptor can be destroyed any at point. */ #include "config.h" +#include <string.h> + #include "gusb-endpoint.h" #include "gusb-endpoint-private.h" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libgusb-0.3.5/gusb/gusb-interface.c new/libgusb-0.3.9/gusb/gusb-interface.c --- old/libgusb-0.3.5/gusb/gusb-interface.c 2020-07-30 11:44:24.036256000 +0200 +++ new/libgusb-0.3.9/gusb/gusb-interface.c 2021-12-07 11:37:59.376745000 +0100 @@ -13,7 +13,7 @@ * This object is a thin glib wrapper around a libusb_interface_descriptor. * * All the data is copied when the object is created and the original - * descriptor can be destoyed any at point. + * descriptor can be destroyed any at point. */ #include "config.h" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libgusb-0.3.5/gusb/gusb-self-test.c new/libgusb-0.3.9/gusb/gusb-self-test.c --- old/libgusb-0.3.5/gusb/gusb-self-test.c 2020-07-30 11:44:24.037256000 +0200 +++ new/libgusb-0.3.9/gusb/gusb-self-test.c 2021-12-07 11:37:59.376745000 +0100 @@ -21,6 +21,11 @@ GUsbContext *ctx; GUsbDevice *device; +#ifdef __FreeBSD__ + g_test_skip ("Root hubs on FreeBSD have vid and pid set to zero"); + return; +#endif + ctx = g_usb_context_new (&error); g_assert_no_error (error); g_assert (ctx != NULL); @@ -71,6 +76,11 @@ gchar *product; guint i; +#ifdef __FreeBSD__ + g_test_skip ("Root hubs on FreeBSD have vid and pid set to zero"); + return; +#endif + ctx = g_usb_context_new (&error); g_assert_no_error (error); g_assert (ctx != NULL); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libgusb-0.3.5/gusb/libgusb.ver new/libgusb-0.3.9/gusb/libgusb.ver --- old/libgusb-0.3.5/gusb/libgusb.ver 2020-07-30 11:44:24.037256000 +0200 +++ new/libgusb-0.3.9/gusb/libgusb.ver 2021-12-07 11:37:59.376745000 +0100 @@ -147,3 +147,15 @@ g_usb_device_get_configuration_index; local: *; } LIBGUSB_0.3.3; + +LIBGUSB_0.3.6 { + global: + g_usb_device_get_string_descriptor_bytes; + local: *; +} LIBGUSB_0.3.5; + +LIBGUSB_0.3.8 { + global: + g_usb_device_get_string_descriptor_bytes_full; + local: *; +} LIBGUSB_0.3.6; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libgusb-0.3.5/gusb/libgusb_meson.ver new/libgusb-0.3.9/gusb/libgusb_meson.ver --- old/libgusb-0.3.5/gusb/libgusb_meson.ver 1970-01-01 01:00:00.000000000 +0100 +++ new/libgusb-0.3.9/gusb/libgusb_meson.ver 2021-12-07 11:37:59.376745000 +0100 @@ -0,0 +1,7 @@ +LIBGUSB_0.1.0 { + global: + g_usb_*; + environ; + __progname; + local: *; +}; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libgusb-0.3.5/gusb/meson.build new/libgusb-0.3.9/gusb/meson.build --- old/libgusb-0.3.5/gusb/meson.build 2020-07-30 11:44:24.037256000 +0200 +++ new/libgusb-0.3.9/gusb/meson.build 2021-12-07 11:37:59.376745000 +0100 @@ -43,8 +43,10 @@ ) mapfile = 'libgusb.ver' +mapfile_test = 'libgusb_meson.ver' vflag = [] -if host_machine.system() not in ['darwin'] +vflag_test = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile_test) +if cc.has_link_argument(vflag_test) vflag += '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile) endif gusb = library( @@ -61,6 +63,7 @@ ], soversion : lt_current, version : lt_version, + darwin_versions: [lt_current + 1, '@0@.@1@.0'.format(lt_current + 1, lt_revision)], dependencies : [ libgio, libusb, @@ -87,8 +90,7 @@ ) pkgg = import('pkgconfig') -pkgg.generate( - libraries : gusb, +pkgg.generate(gusb, requires : [ 'gio-2.0', 'gobject-2.0', 'libusb-1.0' ], subdirs : 'gusb-1', version : meson.project_version(), @@ -146,7 +148,7 @@ libgusb_typelib = libgusb_girtarget[1] pymod = import('python') -py_installation = pymod.find_installation('python3') +py_installation = pymod.find_installation() # Verify the map file is correct -- note we can't actually use the generated # file for two reasons: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libgusb-0.3.5/meson.build new/libgusb-0.3.9/meson.build --- old/libgusb-0.3.5/meson.build 2020-07-30 11:44:24.037256000 +0200 +++ new/libgusb-0.3.9/meson.build 2021-12-07 11:37:59.376745000 +0100 @@ -1,5 +1,5 @@ project('libgusb', 'c', - version : '0.3.5', + version : '0.3.9', license : 'LGPL-2.1+', meson_version : '>=0.46.0', default_options : ['c_std=c99'] @@ -15,9 +15,9 @@ conf.set_quoted('VERSION', gusb_version) # libtool versioning - this applies to libgusb -lt_current = '2' -lt_revision = '10' -lt_age = '0' +lt_current = 2 +lt_revision = 10 +lt_age = 0 lt_version = '@0@.@1@.@2@'.format(lt_current, lt_age, lt_revision) # get supported warning flags @@ -94,9 +94,21 @@ ) libgio = dependency('gio-2.0', version : '>= 2.44.0') -libusb = dependency('libusb-1.0', version : '>= 1.0.19') -if libusb.version().version_compare ('>= 1.0.22') - conf.set('HAVE_LIBUSB_1_0_22', '1') +libusb = dependency('libusb-1.0', version : '>= 1.0.9') +if cc.has_header_symbol('libusb.h', 'LIBUSB_CAP_HAS_HOTPLUG', dependencies: libusb) + conf.set('HAVE_LIBUSB_CAP_HAS_HOTPLUG', '1') +endif +if cc.has_header_symbol('libusb.h', 'libusb_has_capability', dependencies: libusb) + conf.set('HAVE_LIBUSB_HAS_CAPABILITY', '1') +endif +if cc.has_header_symbol('libusb.h', 'libusb_set_option', dependencies: libusb) + conf.set('HAVE_LIBUSB_SET_OPTION', '1') +endif +if cc.has_header_symbol('libusb.h', 'libusb_get_parent', dependencies: libusb) + conf.set('HAVE_LIBUSB_GET_PARENT', '1') +endif +if cc.has_header_symbol('libusb.h', 'libusb_get_port_number', dependencies: libusb) + conf.set('HAVE_LIBUSB_GET_PORT_NUMBER', '1') endif gusb_deps = [ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libgusb-0.3.5/tools/gusb-main.c new/libgusb-0.3.9/tools/gusb-main.c --- old/libgusb-0.3.5/tools/gusb-main.c 2020-07-30 11:44:24.037256000 +0200 +++ new/libgusb-0.3.9/tools/gusb-main.c 2021-12-07 11:37:59.377745200 +0100 @@ -153,6 +153,7 @@ return; } g_print ("product: %s\n", product); + g_free (product); } } @@ -437,7 +438,12 @@ priv->context = g_option_context_new ("GUSB Console Program"); g_option_context_add_main_entries (priv->context, options, NULL); - g_option_context_parse (priv->context, &argc, &argv, NULL); + if (!g_option_context_parse (priv->context, &argc, &argv, &error)) { + g_printerr ("Failed to parse arguments: %s\n", error->message); + g_error_free (error); + retval = 2; + goto out; + } /* verbose? */ if (verbose) {