summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2022-09-05 11:20:56 +0100
committerRichard Hughes <richard@hughsie.com>2022-09-05 12:03:22 +0100
commit7f0a5e27f5007fcc17272da7483b283f862592a4 (patch)
tree2e3968fff0da07ad84aa084aa84a7aec3e266b51
parentb82f6acf0c6c1d2f4b1afdbd2c240061344e14c7 (diff)
downloadgusb-7f0a5e27f5007fcc17272da7483b283f862592a4.tar.gz
trivial: Use @self for instance data
-rw-r--r--gusb/gusb-context-private.h6
-rw-r--r--gusb/gusb-context.c253
-rw-r--r--gusb/gusb-context.h32
-rw-r--r--gusb/gusb-device-list.c54
-rw-r--r--gusb/gusb-device-list.h12
-rw-r--r--gusb/gusb-device-private.h4
-rw-r--r--gusb/gusb-device.c490
-rw-r--r--gusb/gusb-device.h88
-rw-r--r--gusb/gusb-source.c9
-rw-r--r--gusb/gusb-source.h5
10 files changed, 471 insertions, 482 deletions
diff --git a/gusb/gusb-context-private.h b/gusb/gusb-context-private.h
index 6824308..9527055 100644
--- a/gusb/gusb-context-private.h
+++ b/gusb/gusb-context-private.h
@@ -13,11 +13,11 @@
G_BEGIN_DECLS
libusb_context *
-_g_usb_context_get_context(GUsbContext *context);
+_g_usb_context_get_context(GUsbContext *self);
const gchar *
-_g_usb_context_lookup_vendor(GUsbContext *context, guint16 vid, GError **error);
+_g_usb_context_lookup_vendor(GUsbContext *self, guint16 vid, GError **error);
const gchar *
-_g_usb_context_lookup_product(GUsbContext *context, guint16 vid, guint16 pid, GError **error);
+_g_usb_context_lookup_product(GUsbContext *self, guint16 vid, guint16 pid, GError **error);
G_END_DECLS
diff --git a/gusb/gusb-context.c b/gusb/gusb-context.c
index ee423cb..86640be 100644
--- a/gusb/gusb-context.c
+++ b/gusb/gusb-context.c
@@ -114,8 +114,8 @@ G_DEFINE_QUARK (g-usb-context-error-quark, g_usb_context_error)
static void
g_usb_context_dispose(GObject *object)
{
- GUsbContext *context = G_USB_CONTEXT(object);
- GUsbContextPrivate *priv = GET_PRIVATE(context);
+ GUsbContext *self = G_USB_CONTEXT(object);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
/* this is safe to call even when priv->hotplug_id is unset */
if (g_atomic_int_dec_and_test(&priv->thread_event_run)) {
@@ -146,8 +146,8 @@ g_usb_context_dispose(GObject *object)
static void
g_usb_context_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
- GUsbContext *context = G_USB_CONTEXT(object);
- GUsbContextPrivate *priv = GET_PRIVATE(context);
+ GUsbContext *self = G_USB_CONTEXT(object);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
switch (prop_id) {
case PROP_LIBUSB_CONTEXT:
@@ -165,8 +165,8 @@ g_usb_context_get_property(GObject *object, guint prop_id, GValue *value, GParam
static void
g_usb_context_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
- GUsbContext *context = G_USB_CONTEXT(object);
- GUsbContextPrivate *priv = GET_PRIVATE(context);
+ GUsbContext *self = G_USB_CONTEXT(object);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
switch (prop_id) {
case PROP_DEBUG_LEVEL:
@@ -208,7 +208,7 @@ g_usb_context_class_init(GUsbContextClass *klass)
/**
* GUsbContext::device-added:
- * @context: the #GUsbContext instance that emitted the signal
+ * @self: the #GUsbContext instance that emitted the signal
* @device: A #GUsbDevice
*
* This signal is emitted when a USB device is added.
@@ -226,7 +226,7 @@ g_usb_context_class_init(GUsbContextClass *klass)
/**
* GUsbContext::device-removed:
- * @context: the #GUsbContext instance that emitted the signal
+ * @self: the #GUsbContext instance that emitted the signal
* @device: A #GUsbDevice
*
* This signal is emitted when a USB device is removed.
@@ -245,33 +245,33 @@ g_usb_context_class_init(GUsbContextClass *klass)
}
static void
-g_usb_context_emit_device_add(GUsbContext *context, GUsbDevice *device)
+g_usb_context_emit_device_add(GUsbContext *self, GUsbDevice *device)
{
- GUsbContextPrivate *priv = GET_PRIVATE(context);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
/* emitted directly by g_usb_context_enumerate */
if (!priv->done_enumerate)
return;
- g_signal_emit(context, signals[DEVICE_ADDED_SIGNAL], 0, device);
+ g_signal_emit(self, signals[DEVICE_ADDED_SIGNAL], 0, device);
}
static void
-g_usb_context_emit_device_remove(GUsbContext *context, GUsbDevice *device)
+g_usb_context_emit_device_remove(GUsbContext *self, GUsbDevice *device)
{
- GUsbContextPrivate *priv = GET_PRIVATE(context);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
/* should not happen, if it does we would not fire any signal */
if (!priv->done_enumerate)
return;
- g_signal_emit(context, signals[DEVICE_REMOVED_SIGNAL], 0, device);
+ g_signal_emit(self, signals[DEVICE_REMOVED_SIGNAL], 0, device);
}
static void
-g_usb_context_add_device(GUsbContext *context, struct libusb_device *dev)
+g_usb_context_add_device(GUsbContext *self, struct libusb_device *dev)
{
- GUsbContextPrivate *priv = GET_PRIVATE(context);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
GUsbContextReplugHelper *replug_helper;
const gchar *platform_id;
guint8 bus;
@@ -284,12 +284,12 @@ g_usb_context_add_device(GUsbContext *context, struct libusb_device *dev)
address = libusb_get_device_address(dev);
if (priv->done_enumerate)
- device = g_usb_context_find_by_bus_address(context, bus, address, NULL);
+ device = g_usb_context_find_by_bus_address(self, bus, address, NULL);
if (device != NULL)
return;
/* add the device */
- device = _g_usb_device_new(context, dev, &error);
+ device = _g_usb_device_new(self, dev, &error);
if (device == NULL) {
g_debug("There was a problem creating the device: %s", error->message);
return;
@@ -318,13 +318,13 @@ g_usb_context_add_device(GUsbContext *context, struct libusb_device *dev)
}
/* emit signal */
- g_usb_context_emit_device_add(context, device);
+ g_usb_context_emit_device_add(self, device);
}
static void
-g_usb_context_remove_device(GUsbContext *context, struct libusb_device *dev)
+g_usb_context_remove_device(GUsbContext *self, struct libusb_device *dev)
{
- GUsbContextPrivate *priv = GET_PRIVATE(context);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
GUsbContextReplugHelper *replug_helper;
const gchar *platform_id;
guint8 bus;
@@ -334,7 +334,7 @@ g_usb_context_remove_device(GUsbContext *context, struct libusb_device *dev)
/* does any existing device exist */
bus = libusb_get_bus_number(dev);
address = libusb_get_device_address(dev);
- device = g_usb_context_find_by_bus_address(context, bus, address, NULL);
+ device = g_usb_context_find_by_bus_address(self, bus, address, NULL);
if (device == NULL) {
g_debug("%i:%i does not exist", bus, address);
return;
@@ -352,11 +352,11 @@ g_usb_context_remove_device(GUsbContext *context, struct libusb_device *dev)
}
/* emit signal */
- g_usb_context_emit_device_remove(context, device);
+ g_usb_context_emit_device_remove(self, device);
}
typedef struct {
- GUsbContext *context;
+ GUsbContext *self;
libusb_device *dev;
libusb_hotplug_event event;
} GUsbContextIdleHelper;
@@ -364,7 +364,7 @@ typedef struct {
static void
g_usb_context_idle_helper_free(GUsbContextIdleHelper *helper)
{
- g_object_unref(helper->context);
+ g_object_unref(helper->self);
libusb_unref_device(helper->dev);
g_free(helper);
}
@@ -372,18 +372,18 @@ g_usb_context_idle_helper_free(GUsbContextIdleHelper *helper)
static gboolean
g_usb_context_idle_hotplug_cb(gpointer user_data)
{
- GUsbContext *context = G_USB_CONTEXT(user_data);
- GUsbContextPrivate *priv = GET_PRIVATE(context);
+ GUsbContext *self = G_USB_CONTEXT(user_data);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&priv->idle_events_mutex);
for (guint i = 0; i < priv->idle_events->len; i++) {
GUsbContextIdleHelper *helper = g_ptr_array_index(priv->idle_events, i);
switch (helper->event) {
case LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED:
- g_usb_context_add_device(helper->context, helper->dev);
+ g_usb_context_add_device(helper->self, helper->dev);
break;
case LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT:
- g_usb_context_remove_device(helper->context, helper->dev);
+ g_usb_context_remove_device(helper->self, helper->dev);
break;
default:
break;
@@ -403,27 +403,27 @@ g_usb_context_hotplug_cb(struct libusb_context *ctx,
libusb_hotplug_event event,
void *user_data)
{
- GUsbContext *context = G_USB_CONTEXT(user_data);
+ GUsbContext *self = G_USB_CONTEXT(user_data);
GUsbContextIdleHelper *helper;
- GUsbContextPrivate *priv = GET_PRIVATE(context);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&priv->idle_events_mutex);
helper = g_new0(GUsbContextIdleHelper, 1);
- helper->context = g_object_ref(context);
+ helper->self = g_object_ref(self);
helper->dev = libusb_ref_device(dev);
helper->event = event;
g_ptr_array_add(priv->idle_events, helper);
if (priv->idle_events_id == 0)
- priv->idle_events_id = g_idle_add(g_usb_context_idle_hotplug_cb, context);
+ priv->idle_events_id = g_idle_add(g_usb_context_idle_hotplug_cb, self);
return 0;
}
static void
-g_usb_context_rescan(GUsbContext *context)
+g_usb_context_rescan(GUsbContext *self)
{
- GUsbContextPrivate *priv = GET_PRIVATE(context);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
libusb_device **dev_list = NULL;
g_autoptr(GList) existing_devices = NULL;
@@ -447,14 +447,14 @@ g_usb_context_rescan(GUsbContext *context)
}
}
if (!found) {
- g_usb_context_emit_device_remove(context, device);
+ g_usb_context_emit_device_remove(self, device);
g_ptr_array_remove(priv->devices, device);
}
}
/* add any devices not yet added (duplicates will be filtered */
for (guint i = 0; dev_list != NULL && dev_list[i] != NULL; i++)
- g_usb_context_add_device(context, dev_list[i]);
+ g_usb_context_add_device(self, dev_list[i]);
libusb_free_device_list(dev_list, 1);
}
@@ -462,14 +462,14 @@ g_usb_context_rescan(GUsbContext *context)
static gboolean
g_usb_context_rescan_cb(gpointer user_data)
{
- GUsbContext *context = G_USB_CONTEXT(user_data);
- g_usb_context_rescan(context);
+ GUsbContext *self = G_USB_CONTEXT(user_data);
+ g_usb_context_rescan(self);
return TRUE;
}
/**
* g_usb_context_get_main_context:
- * @context: a #GUsbContext
+ * @self: a #GUsbContext
*
* Gets the internal GMainContext to use for synchronous methods.
* By default the value is set to the value of g_main_context_default()
@@ -479,27 +479,27 @@ g_usb_context_rescan_cb(gpointer user_data)
* Since: 0.2.5
**/
GMainContext *
-g_usb_context_get_main_context(GUsbContext *context)
+g_usb_context_get_main_context(GUsbContext *self)
{
- GUsbContextPrivate *priv = GET_PRIVATE(context);
- g_return_val_if_fail(G_USB_IS_CONTEXT(context), NULL);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
+ g_return_val_if_fail(G_USB_IS_CONTEXT(self), NULL);
return priv->main_ctx;
}
/**
* g_usb_context_set_main_context:
- * @context: a #GUsbContext
+ * @self: a #GUsbContext
*
* Sets the internal GMainContext to use for synchronous methods.
*
* Since: 0.2.5
**/
void
-g_usb_context_set_main_context(GUsbContext *context, GMainContext *main_ctx)
+g_usb_context_set_main_context(GUsbContext *self, GMainContext *main_ctx)
{
- GUsbContextPrivate *priv = GET_PRIVATE(context);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
- g_return_if_fail(G_USB_IS_CONTEXT(context));
+ g_return_if_fail(G_USB_IS_CONTEXT(self));
if (main_ctx != priv->main_ctx) {
g_main_context_unref(priv->main_ctx);
@@ -508,9 +508,9 @@ g_usb_context_set_main_context(GUsbContext *context, GMainContext *main_ctx)
}
static void
-g_usb_context_ensure_rescan_timeout(GUsbContext *context)
+g_usb_context_ensure_rescan_timeout(GUsbContext *self)
{
- GUsbContextPrivate *priv = GET_PRIVATE(context);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
if (priv->hotplug_poll_id > 0) {
g_source_remove(priv->hotplug_poll_id);
@@ -518,13 +518,13 @@ g_usb_context_ensure_rescan_timeout(GUsbContext *context)
}
if (priv->hotplug_poll_interval > 0) {
priv->hotplug_poll_id =
- g_timeout_add(priv->hotplug_poll_interval, g_usb_context_rescan_cb, context);
+ g_timeout_add(priv->hotplug_poll_interval, g_usb_context_rescan_cb, self);
}
}
/**
* g_usb_context_get_hotplug_poll_interval:
- * @context: a #GUsbContext
+ * @self: a #GUsbContext
*
* Gets the poll interval for platforms like Windows that do not support `LIBUSB_CAP_HAS_HOTPLUG`.
*
@@ -533,16 +533,16 @@ g_usb_context_ensure_rescan_timeout(GUsbContext *context)
* Since: 0.3.10
**/
guint
-g_usb_context_get_hotplug_poll_interval(GUsbContext *context)
+g_usb_context_get_hotplug_poll_interval(GUsbContext *self)
{
- GUsbContextPrivate *priv = GET_PRIVATE(context);
- g_return_val_if_fail(G_USB_IS_CONTEXT(context), G_MAXUINT);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
+ g_return_val_if_fail(G_USB_IS_CONTEXT(self), G_MAXUINT);
return priv->hotplug_poll_id;
}
/**
* g_usb_context_set_hotplug_poll_interval:
- * @context: a #GUsbContext
+ * @self: a #GUsbContext
* @hotplug_poll_interval: the interval in ms
*
* Sets the poll interval for platforms like Windows that do not support `LIBUSB_CAP_HAS_HOTPLUG`.
@@ -552,11 +552,11 @@ g_usb_context_get_hotplug_poll_interval(GUsbContext *context)
* Since: 0.3.10
**/
void
-g_usb_context_set_hotplug_poll_interval(GUsbContext *context, guint hotplug_poll_interval)
+g_usb_context_set_hotplug_poll_interval(GUsbContext *self, guint hotplug_poll_interval)
{
- GUsbContextPrivate *priv = GET_PRIVATE(context);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
- g_return_if_fail(G_USB_IS_CONTEXT(context));
+ g_return_if_fail(G_USB_IS_CONTEXT(self));
/* same */
if (priv->hotplug_poll_interval == hotplug_poll_interval)
@@ -566,12 +566,12 @@ g_usb_context_set_hotplug_poll_interval(GUsbContext *context, guint hotplug_poll
/* if already running then change the existing timeout */
if (priv->hotplug_poll_id > 0)
- g_usb_context_ensure_rescan_timeout(context);
+ g_usb_context_ensure_rescan_timeout(self);
}
/**
* g_usb_context_enumerate:
- * @context: a #GUsbContext
+ * @self: a #GUsbContext
*
* Enumerates all the USB devices and adds them to the context.
*
@@ -581,24 +581,24 @@ g_usb_context_set_hotplug_poll_interval(GUsbContext *context, guint hotplug_poll
* Since: 0.2.2
**/
void
-g_usb_context_enumerate(GUsbContext *context)
+g_usb_context_enumerate(GUsbContext *self)
{
- GUsbContextPrivate *priv = GET_PRIVATE(context);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
/* only ever initially scan once, then rely on hotplug / poll */
if (priv->done_enumerate)
return;
- g_usb_context_rescan(context);
+ g_usb_context_rescan(self);
if (!libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG)) {
g_debug("platform does not do hotplug, using polling");
- g_usb_context_ensure_rescan_timeout(context);
+ g_usb_context_ensure_rescan_timeout(self);
}
priv->done_enumerate = TRUE;
/* emit device-added signals before returning */
for (guint i = 0; i < priv->devices->len; i++) {
- g_signal_emit(context,
+ g_signal_emit(self,
signals[DEVICE_ADDED_SIGNAL],
0,
g_ptr_array_index(priv->devices, i));
@@ -609,7 +609,7 @@ g_usb_context_enumerate(GUsbContext *context)
/**
* g_usb_context_set_flags:
- * @context: a #GUsbContext
+ * @self: a #GUsbContext
* @flags: some #GUsbContextFlags, e.g. %G_USB_CONTEXT_FLAGS_AUTO_OPEN_DEVICES
*
* Sets the flags to use for the context. These should be set before
@@ -618,15 +618,15 @@ g_usb_context_enumerate(GUsbContext *context)
* Since: 0.2.11
**/
void
-g_usb_context_set_flags(GUsbContext *context, GUsbContextFlags flags)
+g_usb_context_set_flags(GUsbContext *self, GUsbContextFlags flags)
{
- GUsbContextPrivate *priv = GET_PRIVATE(context);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
priv->flags = flags;
}
/**
* g_usb_context_get_flags:
- * @context: a #GUsbContext
+ * @self: a #GUsbContext
*
* Sets the flags to use for the context.
*
@@ -635,17 +635,17 @@ g_usb_context_set_flags(GUsbContext *context, GUsbContextFlags flags)
* Since: 0.2.11
**/
GUsbContextFlags
-g_usb_context_get_flags(GUsbContext *context)
+g_usb_context_get_flags(GUsbContext *self)
{
- GUsbContextPrivate *priv = GET_PRIVATE(context);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
return priv->flags;
}
static gpointer
g_usb_context_event_thread_cb(gpointer data)
{
- GUsbContext *context = G_USB_CONTEXT(data);
- GUsbContextPrivate *priv = GET_PRIVATE(context);
+ GUsbContext *self = G_USB_CONTEXT(data);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
struct timeval tv = {
.tv_usec = 0,
.tv_sec = 2,
@@ -658,9 +658,9 @@ g_usb_context_event_thread_cb(gpointer data)
}
static void
-g_usb_context_init(GUsbContext *context)
+g_usb_context_init(GUsbContext *self)
{
- GUsbContextPrivate *priv = GET_PRIVATE(context);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
priv->flags = G_USB_CONTEXT_FLAGS_NONE;
priv->hotplug_poll_interval = G_USB_CONTEXT_HOTPLUG_POLL_INTERVAL_DEFAULT;
@@ -677,8 +677,8 @@ g_usb_context_init(GUsbContext *context)
static gboolean
g_usb_context_initable_init(GInitable *initable, GCancellable *cancellable, GError **error)
{
- GUsbContext *context = G_USB_CONTEXT(initable);
- GUsbContextPrivate *priv = GET_PRIVATE(context);
+ GUsbContext *self = G_USB_CONTEXT(initable);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
gint rc;
libusb_context *ctx;
@@ -696,8 +696,7 @@ g_usb_context_initable_init(GInitable *initable, GCancellable *cancellable, GErr
priv->main_ctx = g_main_context_ref(g_main_context_default());
priv->ctx = ctx;
priv->thread_event_run = 1;
- priv->thread_event =
- g_thread_new("GUsbEventThread", g_usb_context_event_thread_cb, context);
+ priv->thread_event = g_thread_new("GUsbEventThread", g_usb_context_event_thread_cb, self);
/* watch for add/remove */
if (libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG)) {
@@ -709,7 +708,7 @@ g_usb_context_initable_init(GInitable *initable, GCancellable *cancellable, GErr
LIBUSB_HOTPLUG_MATCH_ANY,
LIBUSB_HOTPLUG_MATCH_ANY,
g_usb_context_hotplug_cb,
- context,
+ self,
&priv->hotplug_id);
if (rc != LIBUSB_SUCCESS) {
g_warning("Error creating a hotplug callback: %s", g_usb_strerror(rc));
@@ -727,7 +726,7 @@ g_usb_context_initable_iface_init(GInitableIface *iface)
/**
* _g_usb_context_get_context:
- * @context: a #GUsbContext
+ * @self: a #GUsbContext
*
* Gets the internal libusb_context.
*
@@ -736,15 +735,15 @@ g_usb_context_initable_iface_init(GInitableIface *iface)
* Since: 0.1.0
**/
libusb_context *
-_g_usb_context_get_context(GUsbContext *context)
+_g_usb_context_get_context(GUsbContext *self)
{
- GUsbContextPrivate *priv = GET_PRIVATE(context);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
return priv->ctx;
}
/**
* g_usb_context_get_source:
- * @context: a #GUsbContext
+ * @self: a #GUsbContext
* @main_ctx: a #GMainContext, or %NULL
*
* This function does nothing.
@@ -754,14 +753,14 @@ _g_usb_context_get_context(GUsbContext *context)
* Since: 0.1.0
**/
GUsbSource *
-g_usb_context_get_source(GUsbContext *context, GMainContext *main_ctx)
+g_usb_context_get_source(GUsbContext *self, GMainContext *main_ctx)
{
return NULL;
}
/**
* g_usb_context_set_debug:
- * @context: a #GUsbContext
+ * @self: a #GUsbContext
* @flags: a GLogLevelFlags such as %G_LOG_LEVEL_ERROR | %G_LOG_LEVEL_INFO, or 0
*
* Sets the debug flags which control what is logged to the console.
@@ -772,12 +771,12 @@ g_usb_context_get_source(GUsbContext *context, GMainContext *main_ctx)
* Since: 0.1.0
**/
void
-g_usb_context_set_debug(GUsbContext *context, GLogLevelFlags flags)
+g_usb_context_set_debug(GUsbContext *self, GLogLevelFlags flags)
{
- GUsbContextPrivate *priv = GET_PRIVATE(context);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
int debug_level;
- g_return_if_fail(G_USB_IS_CONTEXT(context));
+ g_return_if_fail(G_USB_IS_CONTEXT(self));
if (flags & (G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_INFO))
debug_level = 3;
@@ -796,13 +795,13 @@ g_usb_context_set_debug(GUsbContext *context, GLogLevelFlags flags)
libusb_set_debug(priv->ctx, debug_level);
#endif
- g_object_notify_by_pspec(G_OBJECT(context), pspecs[PROP_DEBUG_LEVEL]);
+ g_object_notify_by_pspec(G_OBJECT(self), pspecs[PROP_DEBUG_LEVEL]);
}
}
/**
* g_usb_context_find_by_bus_address:
- * @context: a #GUsbContext
+ * @self: a #GUsbContext
* @bus: a bus number
* @address: a bus address
* @error: A #GError or %NULL
@@ -814,14 +813,14 @@ g_usb_context_set_debug(GUsbContext *context, GLogLevelFlags flags)
* Since: 0.2.2
**/
GUsbDevice *
-g_usb_context_find_by_bus_address(GUsbContext *context, guint8 bus, guint8 address, GError **error)
+g_usb_context_find_by_bus_address(GUsbContext *self, guint8 bus, guint8 address, GError **error)
{
- GUsbContextPrivate *priv = GET_PRIVATE(context);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
- g_return_val_if_fail(G_USB_IS_CONTEXT(context), NULL);
+ g_return_val_if_fail(G_USB_IS_CONTEXT(self), NULL);
g_return_val_if_fail(error == NULL || *error == NULL, NULL);
- g_usb_context_enumerate(context);
+ g_usb_context_enumerate(self);
for (guint i = 0; i < priv->devices->len; i++) {
GUsbDevice *device = g_ptr_array_index(priv->devices, i);
if (g_usb_device_get_bus(device) == bus &&
@@ -840,7 +839,7 @@ g_usb_context_find_by_bus_address(GUsbContext *context, guint8 bus, guint8 addre
/**
* g_usb_context_find_by_platform_id:
- * @context: a #GUsbContext
+ * @self: a #GUsbContext
* @platform_id: a platform id, e.g. "usb:00:03:03:02"
* @error: A #GError or %NULL
*
@@ -851,14 +850,14 @@ g_usb_context_find_by_bus_address(GUsbContext *context, guint8 bus, guint8 addre
* Since: 0.2.4
**/
GUsbDevice *
-g_usb_context_find_by_platform_id(GUsbContext *context, const gchar *platform_id, GError **error)
+g_usb_context_find_by_platform_id(GUsbContext *self, const gchar *platform_id, GError **error)
{
- GUsbContextPrivate *priv = GET_PRIVATE(context);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
- g_return_val_if_fail(G_USB_IS_CONTEXT(context), NULL);
+ g_return_val_if_fail(G_USB_IS_CONTEXT(self), NULL);
g_return_val_if_fail(error == NULL || *error == NULL, NULL);
- g_usb_context_enumerate(context);
+ g_usb_context_enumerate(self);
for (guint i = 0; i < priv->devices->len; i++) {
GUsbDevice *device = g_ptr_array_index(priv->devices, i);
if (g_strcmp0(g_usb_device_get_platform_id(device), platform_id) == 0)
@@ -874,7 +873,7 @@ g_usb_context_find_by_platform_id(GUsbContext *context, const gchar *platform_id
/**
* g_usb_context_find_by_vid_pid:
- * @context: a #GUsbContext
+ * @self: a #GUsbContext
* @vid: a vendor ID
* @pid: a product ID
* @error: A #GError or %NULL
@@ -886,14 +885,14 @@ g_usb_context_find_by_platform_id(GUsbContext *context, const gchar *platform_id
* Since: 0.2.2
**/
GUsbDevice *
-g_usb_context_find_by_vid_pid(GUsbContext *context, guint16 vid, guint16 pid, GError **error)
+g_usb_context_find_by_vid_pid(GUsbContext *self, guint16 vid, guint16 pid, GError **error)
{
- GUsbContextPrivate *priv = GET_PRIVATE(context);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
- g_return_val_if_fail(G_USB_IS_CONTEXT(context), NULL);
+ g_return_val_if_fail(G_USB_IS_CONTEXT(self), NULL);
g_return_val_if_fail(error == NULL || *error == NULL, NULL);
- g_usb_context_enumerate(context);
+ g_usb_context_enumerate(self);
for (guint i = 0; i < priv->devices->len; i++) {
GUsbDevice *device = g_ptr_array_index(priv->devices, i);
if (g_usb_device_get_vid(device) == vid && g_usb_device_get_pid(device) == pid) {
@@ -910,9 +909,9 @@ g_usb_context_find_by_vid_pid(GUsbContext *context, guint16 vid, guint16 pid, GE
}
static gboolean
-g_usb_context_load_usb_ids(GUsbContext *context, GError **error)
+g_usb_context_load_usb_ids(GUsbContext *self, GError **error)
{
- GUsbContextPrivate *priv = GET_PRIVATE(context);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
guint16 pid;
guint16 vid = 0x0000;
g_autofree gchar *data = NULL;
@@ -961,7 +960,7 @@ g_usb_context_load_usb_ids(GUsbContext *context, GError **error)
/**
* _g_usb_context_lookup_vendor:
- * @context: a #GUsbContext
+ * @self: a #GUsbContext
* @vid: a USB vendor ID
* @error: a #GError, or %NULL
*
@@ -972,17 +971,17 @@ g_usb_context_load_usb_ids(GUsbContext *context, GError **error)
* Since: 0.1.5
**/
const gchar *
-_g_usb_context_lookup_vendor(GUsbContext *context, guint16 vid, GError **error)
+_g_usb_context_lookup_vendor(GUsbContext *self, guint16 vid, GError **error)
{
- GUsbContextPrivate *priv = GET_PRIVATE(context);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
const gchar *tmp;
g_autofree gchar *key = NULL;
- g_return_val_if_fail(G_USB_IS_CONTEXT(context), NULL);
+ g_return_val_if_fail(G_USB_IS_CONTEXT(self), NULL);
g_return_val_if_fail(error == NULL || *error == NULL, NULL);
/* load */
- if (!g_usb_context_load_usb_ids(context, error))
+ if (!g_usb_context_load_usb_ids(self, error))
return NULL;
/* find */
@@ -1002,7 +1001,7 @@ _g_usb_context_lookup_vendor(GUsbContext *context, guint16 vid, GError **error)
/**
* _g_usb_context_lookup_product:
- * @context: a #GUsbContext
+ * @self: a #GUsbContext
* @vid: a USB vendor ID
* @pid: a USB product ID
* @error: a #GError, or %NULL
@@ -1014,17 +1013,17 @@ _g_usb_context_lookup_vendor(GUsbContext *context, guint16 vid, GError **error)
* Since: 0.1.5
**/
const gchar *
-_g_usb_context_lookup_product(GUsbContext *context, guint16 vid, guint16 pid, GError **error)
+_g_usb_context_lookup_product(GUsbContext *self, guint16 vid, guint16 pid, GError **error)
{
- GUsbContextPrivate *priv = GET_PRIVATE(context);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
const gchar *tmp;
g_autofree gchar *key = NULL;
- g_return_val_if_fail(G_USB_IS_CONTEXT(context), NULL);
+ g_return_val_if_fail(G_USB_IS_CONTEXT(self), NULL);
g_return_val_if_fail(error == NULL || *error == NULL, NULL);
/* load */
- if (!g_usb_context_load_usb_ids(context, error))
+ if (!g_usb_context_load_usb_ids(self, error))
return NULL;
/* find */
@@ -1044,20 +1043,20 @@ _g_usb_context_lookup_product(GUsbContext *context, guint16 vid, guint16 pid, GE
/**
* g_usb_context_get_devices:
- * @context: a #GUsbContext
+ * @self: a #GUsbContext
*
* Return value: (transfer full) (element-type GUsbDevice): a new #GPtrArray of #GUsbDevice's.
*
* Since: 0.2.2
**/
GPtrArray *
-g_usb_context_get_devices(GUsbContext *context)
+g_usb_context_get_devices(GUsbContext *self)
{
- GUsbContextPrivate *priv = GET_PRIVATE(context);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
- g_return_val_if_fail(G_USB_IS_CONTEXT(context), NULL);
+ g_return_val_if_fail(G_USB_IS_CONTEXT(self), NULL);
- g_usb_context_enumerate(context);
+ g_usb_context_enumerate(self);
return g_ptr_array_ref(priv->devices);
}
@@ -1075,7 +1074,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GUsbContextReplugHelper, g_usb_context_replug_help
/**
* g_usb_context_wait_for_replug:
- * @context: a #GUsbContext
+ * @self: a #GUsbContext
* @device: a #GUsbDevice
* @timeout_ms: timeout to wait
* @error: A #GError or %NULL
@@ -1091,16 +1090,16 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GUsbContextReplugHelper, g_usb_context_replug_help
* Since: 0.2.9
**/
GUsbDevice *
-g_usb_context_wait_for_replug(GUsbContext *context,
+g_usb_context_wait_for_replug(GUsbContext *self,
GUsbDevice *device,
guint timeout_ms,
GError **error)
{
- GUsbContextPrivate *priv = GET_PRIVATE(context);
+ GUsbContextPrivate *priv = GET_PRIVATE(self);
const gchar *platform_id;
g_autoptr(GUsbContextReplugHelper) replug_helper = NULL;
- g_return_val_if_fail(G_USB_IS_CONTEXT(context), NULL);
+ g_return_val_if_fail(G_USB_IS_CONTEXT(self), NULL);
/* create a helper */
replug_helper = g_new0(GUsbContextReplugHelper, 1);
@@ -1121,7 +1120,7 @@ g_usb_context_wait_for_replug(GUsbContext *context,
/* so we timed out; emit the removal now */
if (replug_helper->timeout_id == 0) {
- g_usb_context_emit_device_remove(context, replug_helper->device);
+ g_usb_context_emit_device_remove(self, replug_helper->device);
g_set_error_literal(error,
G_USB_CONTEXT_ERROR,
G_USB_CONTEXT_ERROR_INTERNAL,
diff --git a/gusb/gusb-context.h b/gusb/gusb-context.h
index 7165743..31c37b3 100644
--- a/gusb/gusb-context.h
+++ b/gusb/gusb-context.h
@@ -20,8 +20,8 @@ G_DECLARE_DERIVABLE_TYPE(GUsbContext, g_usb_context, G_USB, CONTEXT, GObject)
struct _GUsbContextClass {
GObjectClass parent_class;
- void (*device_added)(GUsbContext *context, GUsbDevice *device);
- void (*device_removed)(GUsbContext *context, GUsbDevice *device);
+ void (*device_added)(GUsbContext *self, GUsbDevice *device);
+ void (*device_removed)(GUsbContext *self, GUsbDevice *device);
/*< private >*/
/*
* If adding fields to this struct, remove corresponding
@@ -51,40 +51,40 @@ GUsbContext *
g_usb_context_new(GError **error);
void
-g_usb_context_set_flags(GUsbContext *context, GUsbContextFlags flags);
+g_usb_context_set_flags(GUsbContext *self, GUsbContextFlags flags);
GUsbContextFlags
-g_usb_context_get_flags(GUsbContext *context);
+g_usb_context_get_flags(GUsbContext *self);
G_DEPRECATED
GUsbSource *
-g_usb_context_get_source(GUsbContext *context, GMainContext *main_ctx);
+g_usb_context_get_source(GUsbContext *self, GMainContext *main_ctx);
GMainContext *
-g_usb_context_get_main_context(GUsbContext *context);
+g_usb_context_get_main_context(GUsbContext *self);
void
-g_usb_context_set_main_context(GUsbContext *context, GMainContext *main_ctx);
+g_usb_context_set_main_context(GUsbContext *self, GMainContext *main_ctx);
guint
-g_usb_context_get_hotplug_poll_interval(GUsbContext *context);
+g_usb_context_get_hotplug_poll_interval(GUsbContext *self);
void
-g_usb_context_set_hotplug_poll_interval(GUsbContext *context, guint hotplug_poll_interval);
+g_usb_context_set_hotplug_poll_interval(GUsbContext *self, guint hotplug_poll_interval);
void
-g_usb_context_enumerate(GUsbContext *context);
+g_usb_context_enumerate(GUsbContext *self);
void
-g_usb_context_set_debug(GUsbContext *context, GLogLevelFlags flags);
+g_usb_context_set_debug(GUsbContext *self, GLogLevelFlags flags);
GPtrArray *
-g_usb_context_get_devices(GUsbContext *context);
+g_usb_context_get_devices(GUsbContext *self);
GUsbDevice *
-g_usb_context_find_by_bus_address(GUsbContext *context, guint8 bus, guint8 address, GError **error);
+g_usb_context_find_by_bus_address(GUsbContext *self, guint8 bus, guint8 address, GError **error);
GUsbDevice *
-g_usb_context_find_by_vid_pid(GUsbContext *context, guint16 vid, guint16 pid, GError **error);
+g_usb_context_find_by_vid_pid(GUsbContext *self, guint16 vid, guint16 pid, GError **error);
GUsbDevice *
-g_usb_context_find_by_platform_id(GUsbContext *context, const gchar *platform_id, GError **error);
+g_usb_context_find_by_platform_id(GUsbContext *self, const gchar *platform_id, GError **error);
GUsbDevice *
-g_usb_context_wait_for_replug(GUsbContext *context,
+g_usb_context_wait_for_replug(GUsbContext *self,
GUsbDevice *device,
guint timeout_ms,
GError **error);
diff --git a/gusb/gusb-device-list.c b/gusb/gusb-device-list.c
index 2b5b8ec..5c2ba59 100644
--- a/gusb/gusb-device-list.c
+++ b/gusb/gusb-device-list.c
@@ -40,8 +40,8 @@ G_DEFINE_TYPE_WITH_PRIVATE(GUsbDeviceList, g_usb_device_list, G_TYPE_OBJECT);
static void
g_usb_device_list_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
- GUsbDeviceList *list = G_USB_DEVICE_LIST(object);
- GUsbDeviceListPrivate *priv = GET_PRIVATE(list);
+ GUsbDeviceList *self = G_USB_DEVICE_LIST(object);
+ GUsbDeviceListPrivate *priv = GET_PRIVATE(self);
switch (prop_id) {
case PROP_CONTEXT:
@@ -54,15 +54,15 @@ g_usb_device_list_get_property(GObject *object, guint prop_id, GValue *value, GP
}
static void
-g_usb_device_added_cb(GUsbContext *context, GUsbDevice *device, GUsbDeviceList *list)
+g_usb_device_added_cb(GUsbContext *context, GUsbDevice *device, GUsbDeviceList *self)
{
- g_signal_emit(list, signals[DEVICE_ADDED_SIGNAL], 0, device);
+ g_signal_emit(self, signals[DEVICE_ADDED_SIGNAL], 0, device);
}
static void
-g_usb_device_removed_cb(GUsbContext *context, GUsbDevice *device, GUsbDeviceList *list)
+g_usb_device_removed_cb(GUsbContext *context, GUsbDevice *device, GUsbDeviceList *self)
{
- g_signal_emit(list, signals[DEVICE_REMOVED_SIGNAL], 0, device);
+ g_signal_emit(self, signals[DEVICE_REMOVED_SIGNAL], 0, device);
}
static void
@@ -71,8 +71,8 @@ g_usb_device_list_set_property(GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- GUsbDeviceList *list = G_USB_DEVICE_LIST(object);
- GUsbDeviceListPrivate *priv = GET_PRIVATE(list);
+ GUsbDeviceList *self = G_USB_DEVICE_LIST(object);
+ GUsbDeviceListPrivate *priv = GET_PRIVATE(self);
switch (prop_id) {
case PROP_CONTEXT:
@@ -80,11 +80,11 @@ g_usb_device_list_set_property(GObject *object,
g_signal_connect(priv->context,
"device-added",
G_CALLBACK(g_usb_device_added_cb),
- list);
+ self);
g_signal_connect(priv->context,
"device-removed",
G_CALLBACK(g_usb_device_removed_cb),
- list);
+ self);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
@@ -113,7 +113,7 @@ g_usb_device_list_class_init(GUsbDeviceListClass *klass)
/**
* GUsbDeviceList::device-added:
- * @list: the #GUsbDeviceList instance that emitted the signal
+ * @self: the #GUsbDeviceList instance that emitted the signal
* @device: A #GUsbDevice
*
* This signal is emitted when a USB device is added.
@@ -132,7 +132,7 @@ g_usb_device_list_class_init(GUsbDeviceListClass *klass)
/**
* GUsbDeviceList::device-removed:
- * @list: the #GUsbDeviceList instance that emitted the signal
+ * @self: the #GUsbDeviceList instance that emitted the signal
* @device: A #GUsbDevice
*
* This signal is emitted when a USB device is removed.
@@ -151,43 +151,43 @@ g_usb_device_list_class_init(GUsbDeviceListClass *klass)
}
static void
-g_usb_device_list_init(GUsbDeviceList *list)
+g_usb_device_list_init(GUsbDeviceList *self)
{
}
/**
* g_usb_device_list_get_devices:
- * @list: a #GUsbDeviceList
+ * @self: a #GUsbDeviceList
*
* Return value: (transfer full) (element-type GUsbDevice): a new #GPtrArray of #GUsbDevice's.
*
* Since: 0.1.0
**/
GPtrArray *
-g_usb_device_list_get_devices(GUsbDeviceList *list)
+g_usb_device_list_get_devices(GUsbDeviceList *self)
{
- GUsbDeviceListPrivate *priv = GET_PRIVATE(list);
- g_return_val_if_fail(G_USB_IS_DEVICE_LIST(list), NULL);
+ GUsbDeviceListPrivate *priv = GET_PRIVATE(self);
+ g_return_val_if_fail(G_USB_IS_DEVICE_LIST(self), NULL);
return g_usb_context_get_devices(priv->context);
}
/**
* g_usb_device_list_coldplug:
- * @list: a #GUsbDeviceList
+ * @self: a #GUsbDeviceList
*
* This function does nothing.
*
* Since: 0.1.0
**/
void
-g_usb_device_list_coldplug(GUsbDeviceList *list)
+g_usb_device_list_coldplug(GUsbDeviceList *self)
{
return;
}
/**
* g_usb_device_list_find_by_bus_address:
- * @list: a #GUsbDeviceList
+ * @self: a #GUsbDeviceList
* @bus: a bus number
* @address: a bus address
* @error: A #GError or %NULL
@@ -199,20 +199,20 @@ g_usb_device_list_coldplug(GUsbDeviceList *list)
* Since: 0.1.0
**/
GUsbDevice *
-g_usb_device_list_find_by_bus_address(GUsbDeviceList *list,
+g_usb_device_list_find_by_bus_address(GUsbDeviceList *self,
guint8 bus,
guint8 address,
GError **error)
{
- GUsbDeviceListPrivate *priv = GET_PRIVATE(list);
- g_return_val_if_fail(G_USB_IS_DEVICE_LIST(list), NULL);
+ GUsbDeviceListPrivate *priv = GET_PRIVATE(self);
+ g_return_val_if_fail(G_USB_IS_DEVICE_LIST(self), NULL);
g_return_val_if_fail(error == NULL || *error == NULL, NULL);
return g_usb_context_find_by_bus_address(priv->context, bus, address, error);
}
/**
* g_usb_device_list_find_by_vid_pid:
- * @list: a #GUsbDeviceList
+ * @self: a #GUsbDeviceList
* @vid: a vendor ID
* @pid: a product ID
* @error: A #GError or %NULL
@@ -224,10 +224,10 @@ g_usb_device_list_find_by_bus_address(GUsbDeviceList *list,
* Since: 0.1.0
**/
GUsbDevice *
-g_usb_device_list_find_by_vid_pid(GUsbDeviceList *list, guint16 vid, guint16 pid, GError **error)
+g_usb_device_list_find_by_vid_pid(GUsbDeviceList *self, guint16 vid, guint16 pid, GError **error)
{
- GUsbDeviceListPrivate *priv = GET_PRIVATE(list);
- g_return_val_if_fail(G_USB_IS_DEVICE_LIST(list), NULL);
+ GUsbDeviceListPrivate *priv = GET_PRIVATE(self);
+ g_return_val_if_fail(G_USB_IS_DEVICE_LIST(self), NULL);
g_return_val_if_fail(error == NULL || *error == NULL, NULL);
return g_usb_context_find_by_vid_pid(priv->context, vid, pid, error);
}
diff --git a/gusb/gusb-device-list.h b/gusb/gusb-device-list.h
index 95c4423..d209e9c 100644
--- a/gusb/gusb-device-list.h
+++ b/gusb/gusb-device-list.h
@@ -19,8 +19,8 @@ G_DECLARE_DERIVABLE_TYPE(GUsbDeviceList, g_usb_device_list, G_USB, DEVICE_LIST,
struct _GUsbDeviceListClass {
GObjectClass parent_class;
/* Signals */
- void (*device_added)(GUsbDeviceList *list, GUsbDevice *device);
- void (*device_removed)(GUsbDeviceList *list, GUsbDevice *device);
+ void (*device_added)(GUsbDeviceList *self, GUsbDevice *device);
+ void (*device_removed)(GUsbDeviceList *self, GUsbDevice *device);
/*< private >*/
/*
* If adding fields to this struct, remove corresponding
@@ -35,21 +35,21 @@ g_usb_device_list_new(GUsbContext *context);
G_DEPRECATED
void
-g_usb_device_list_coldplug(GUsbDeviceList *list);
+g_usb_device_list_coldplug(GUsbDeviceList *self);
G_DEPRECATED_FOR(g_usb_context_get_devices)
GPtrArray *
-g_usb_device_list_get_devices(GUsbDeviceList *list);
+g_usb_device_list_get_devices(GUsbDeviceList *self);
G_DEPRECATED_FOR(g_usb_context_find_by_bus_address)
GUsbDevice *
-g_usb_device_list_find_by_bus_address(GUsbDeviceList *list,
+g_usb_device_list_find_by_bus_address(GUsbDeviceList *self,
guint8 bus,
guint8 address,
GError **error);
G_DEPRECATED_FOR(g_usb_context_find_by_vid_pid)
GUsbDevice *
-g_usb_device_list_find_by_vid_pid(GUsbDeviceList *list, guint16 vid, guint16 pid, GError **error);
+g_usb_device_list_find_by_vid_pid(GUsbDeviceList *self, guint16 vid, guint16 pid, GError **error);
G_END_DECLS
diff --git a/gusb/gusb-device-private.h b/gusb/gusb-device-private.h
index 70cfec0..54acd83 100644
--- a/gusb/gusb-device-private.h
+++ b/gusb/gusb-device-private.h
@@ -15,8 +15,8 @@ GUsbDevice *
_g_usb_device_new(GUsbContext *context, libusb_device *device, GError **error);
libusb_device *
-_g_usb_device_get_device(GUsbDevice *device);
+_g_usb_device_get_device(GUsbDevice *self);
gboolean
-_g_usb_device_open_internal(GUsbDevice *device, GError **error);
+_g_usb_device_open_internal(GUsbDevice *self, GError **error);
G_END_DECLS
diff --git a/gusb/gusb-device.c b/gusb/gusb-device.c
index add6352..d26ea68 100644
--- a/gusb/gusb-device.c
+++ b/gusb/gusb-device.c
@@ -71,8 +71,8 @@ G_DEFINE_QUARK (g-usb-device-error-quark, g_usb_device_error)
static void
g_usb_device_finalize(GObject *object)
{
- GUsbDevice *device = G_USB_DEVICE(object);
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevice *self = G_USB_DEVICE(object);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
g_free(priv->platform_id);
@@ -82,8 +82,8 @@ g_usb_device_finalize(GObject *object)
static void
g_usb_device_dispose(GObject *object)
{
- GUsbDevice *device = G_USB_DEVICE(object);
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevice *self = G_USB_DEVICE(object);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
g_clear_pointer(&priv->device, libusb_unref_device);
g_clear_object(&priv->context);
@@ -94,8 +94,8 @@ g_usb_device_dispose(GObject *object)
static void
g_usb_device_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
- GUsbDevice *device = G_USB_DEVICE(object);
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevice *self = G_USB_DEVICE(object);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
switch (prop_id) {
case PROP_LIBUSB_DEVICE:
@@ -108,9 +108,9 @@ g_usb_device_get_property(GObject *object, guint prop_id, GValue *value, GParamS
}
static void
-set_libusb_device(GUsbDevice *device, struct libusb_device *dev)
+set_libusb_device(GUsbDevice *self, struct libusb_device *dev)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
g_clear_pointer(&priv->device, libusb_unref_device);
@@ -121,12 +121,12 @@ set_libusb_device(GUsbDevice *device, struct libusb_device *dev)
static void
g_usb_device_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
- GUsbDevice *device = G_USB_DEVICE(object);
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevice *self = G_USB_DEVICE(object);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
switch (prop_id) {
case PROP_LIBUSB_DEVICE:
- set_libusb_device(device, g_value_get_pointer(value));
+ set_libusb_device(self, g_value_get_pointer(value));
break;
case PROP_CONTEXT:
priv->context = g_value_dup_object(value);
@@ -143,11 +143,11 @@ g_usb_device_set_property(GObject *object, guint prop_id, const GValue *value, G
static void
g_usb_device_constructed(GObject *object)
{
- GUsbDevice *device = G_USB_DEVICE(object);
+ GUsbDevice *self = G_USB_DEVICE(object);
GUsbDevicePrivate *priv;
gint rc;
- priv = GET_PRIVATE(device);
+ priv = GET_PRIVATE(self);
if (!priv->device)
g_error("constructed without a libusb_device");
@@ -201,7 +201,7 @@ g_usb_device_class_init(GUsbDeviceClass *klass)
}
static void
-g_usb_device_init(GUsbDevice *device)
+g_usb_device_init(GUsbDevice *self)
{
}
@@ -248,11 +248,11 @@ g_usb_device_build_platform_id(struct libusb_device *dev)
static gboolean
g_usb_device_initable_init(GInitable *initable, GCancellable *cancellable, GError **error)
{
- GUsbDevice *device = G_USB_DEVICE(initable);
+ GUsbDevice *self = G_USB_DEVICE(initable);
GUsbDevicePrivate *priv;
gint rc;
- priv = GET_PRIVATE(device);
+ priv = GET_PRIVATE(self);
if (priv->device == NULL) {
g_set_error_literal(error,
@@ -306,21 +306,21 @@ _g_usb_device_new(GUsbContext *context, libusb_device *device, GError **error)
/**
* _g_usb_device_get_device:
- * @device: a #GUsbDevice instance
+ * @self: a #GUsbDevice instance
*
* Gets the low-level libusb_device
*
* Return value: The #libusb_device or %NULL. Do not unref this value.
**/
libusb_device *
-_g_usb_device_get_device(GUsbDevice *device)
+_g_usb_device_get_device(GUsbDevice *self)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
return priv->device;
}
static gboolean
-g_usb_device_libusb_error_to_gerror(GUsbDevice *device, gint rc, GError **error)
+g_usb_device_libusb_error_to_gerror(GUsbDevice *self, gint rc, GError **error)
{
gint error_code = G_USB_DEVICE_ERROR_INTERNAL;
/* Put the rc in libusb's error enum so that gcc warns us if we're
@@ -363,8 +363,8 @@ g_usb_device_libusb_error_to_gerror(GUsbDevice *device, gint rc, GError **error)
G_USB_DEVICE_ERROR,
error_code,
"USB error on device %04x:%04x : %s [%i]",
- g_usb_device_get_vid(device),
- g_usb_device_get_pid(device),
+ g_usb_device_get_vid(self),
+ g_usb_device_get_pid(self),
g_usb_strerror(rc),
rc);
@@ -372,38 +372,38 @@ g_usb_device_libusb_error_to_gerror(GUsbDevice *device, gint rc, GError **error)
}
static gboolean
-g_usb_device_not_open_error(GUsbDevice *device, GError **error)
+g_usb_device_not_open_error(GUsbDevice *self, GError **error)
{
g_set_error(error,
G_USB_DEVICE_ERROR,
G_USB_DEVICE_ERROR_NOT_OPEN,
"Device %04x:%04x has not been opened",
- g_usb_device_get_vid(device),
- g_usb_device_get_pid(device));
+ g_usb_device_get_vid(self),
+ g_usb_device_get_pid(self));
return FALSE;
}
static void
-g_usb_device_async_not_open_error(GUsbDevice *device,
+g_usb_device_async_not_open_error(GUsbDevice *self,
GAsyncReadyCallback callback,
gpointer user_data,
gpointer source_tag)
{
- g_task_report_new_error(device,
+ g_task_report_new_error(self,
callback,
user_data,
source_tag,
G_USB_DEVICE_ERROR,
G_USB_DEVICE_ERROR_NOT_OPEN,
"Device %04x:%04x has not been opened",
- g_usb_device_get_vid(device),
- g_usb_device_get_pid(device));
+ g_usb_device_get_vid(self),
+ g_usb_device_get_pid(self));
}
gboolean
-_g_usb_device_open_internal(GUsbDevice *device, GError **error)
+_g_usb_device_open_internal(GUsbDevice *self, GError **error)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
gint rc;
if (priv->handle != NULL) {
@@ -411,19 +411,19 @@ _g_usb_device_open_internal(GUsbDevice *device, GError **error)
G_USB_DEVICE_ERROR,
G_USB_DEVICE_ERROR_ALREADY_OPEN,
"Device %04x:%04x is already open",
- g_usb_device_get_vid(device),
- g_usb_device_get_pid(device));
+ g_usb_device_get_vid(self),
+ g_usb_device_get_pid(self));
return FALSE;
}
/* open device */
rc = libusb_open(priv->device, &priv->handle);
- return g_usb_device_libusb_error_to_gerror(device, rc, error);
+ return g_usb_device_libusb_error_to_gerror(self, rc, error);
}
/**
* g_usb_device_open:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
* @error: a #GError, or %NULL
*
* Opens the device for use.
@@ -435,11 +435,11 @@ _g_usb_device_open_internal(GUsbDevice *device, GError **error)
* Since: 0.1.0
**/
gboolean
-g_usb_device_open(GUsbDevice *device, GError **error)
+g_usb_device_open(GUsbDevice *self, GError **error)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
- g_return_val_if_fail(G_USB_IS_DEVICE(device), FALSE);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), FALSE);
g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
/* ignore */
@@ -447,12 +447,12 @@ g_usb_device_open(GUsbDevice *device, GError **error)
return TRUE;
/* open */
- return _g_usb_device_open_internal(device, error);
+ return _g_usb_device_open_internal(self, error);
}
/**
* g_usb_device_get_custom_index:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
* @class_id: a device class, e.g. 0xff for VENDOR
* @subclass_id: a device subclass
* @protocol_id: a protocol number
@@ -465,20 +465,20 @@ g_usb_device_open(GUsbDevice *device, GError **error)
* Since: 0.2.5
**/
guint8
-g_usb_device_get_custom_index(GUsbDevice *device,
+g_usb_device_get_custom_index(GUsbDevice *self,
guint8 class_id,
guint8 subclass_id,
guint8 protocol_id,
GError **error)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
const struct libusb_interface_descriptor *ifp;
gint rc;
guint8 idx = 0x00;
struct libusb_config_descriptor *config;
rc = libusb_get_active_config_descriptor(priv->device, &config);
- if (!g_usb_device_libusb_error_to_gerror(device, rc, error))
+ if (!g_usb_device_libusb_error_to_gerror(self, rc, error))
return 0x00;
/* find the right data */
@@ -512,7 +512,7 @@ g_usb_device_get_custom_index(GUsbDevice *device,
/**
* g_usb_device_get_interface:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
* @class_id: a device class, e.g. 0xff for VENDOR
* @subclass_id: a device subclass
* @protocol_id: a protocol number
@@ -528,23 +528,23 @@ g_usb_device_get_custom_index(GUsbDevice *device,
* Since: 0.2.8
**/
GUsbInterface *
-g_usb_device_get_interface(GUsbDevice *device,
+g_usb_device_get_interface(GUsbDevice *self,
guint8 class_id,
guint8 subclass_id,
guint8 protocol_id,
GError **error)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
const struct libusb_interface_descriptor *ifp;
gint rc;
GUsbInterface *interface = NULL;
struct libusb_config_descriptor *config;
- g_return_val_if_fail(G_USB_IS_DEVICE(device), NULL);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), NULL);
g_return_val_if_fail(error == NULL || *error == NULL, NULL);
rc = libusb_get_active_config_descriptor(priv->device, &config);
- if (!g_usb_device_libusb_error_to_gerror(device, rc, error))
+ if (!g_usb_device_libusb_error_to_gerror(self, rc, error))
return NULL;
/* find the right data */
@@ -578,7 +578,7 @@ g_usb_device_get_interface(GUsbDevice *device,
/**
* g_usb_device_get_interfaces:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
* @error: a #GError, or %NULL
*
* Gets all the interfaces exported by the device.
@@ -589,19 +589,19 @@ g_usb_device_get_interface(GUsbDevice *device,
* Since: 0.2.8
**/
GPtrArray *
-g_usb_device_get_interfaces(GUsbDevice *device, GError **error)
+g_usb_device_get_interfaces(GUsbDevice *self, GError **error)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
const struct libusb_interface_descriptor *ifp;
gint rc;
struct libusb_config_descriptor *config;
GPtrArray *array = NULL;
- g_return_val_if_fail(G_USB_IS_DEVICE(device), NULL);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), NULL);
g_return_val_if_fail(error == NULL || *error == NULL, NULL);
rc = libusb_get_active_config_descriptor(priv->device, &config);
- if (!g_usb_device_libusb_error_to_gerror(device, rc, error))
+ if (!g_usb_device_libusb_error_to_gerror(self, rc, error))
return NULL;
/* get all interfaces */
@@ -621,7 +621,7 @@ g_usb_device_get_interfaces(GUsbDevice *device, GError **error)
/**
* g_usb_device_get_bos_descriptor:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
* @capability: a BOS capability type
* @error: a #GError, or %NULL
*
@@ -634,19 +634,19 @@ g_usb_device_get_interfaces(GUsbDevice *device, GError **error)
* Since: 0.4.0
**/
GUsbBosDescriptor *
-g_usb_device_get_bos_descriptor(GUsbDevice *device, guint8 capability, GError **error)
+g_usb_device_get_bos_descriptor(GUsbDevice *self, guint8 capability, GError **error)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
gint rc;
guint8 num_device_caps;
GUsbBosDescriptor *bos_descriptor = NULL;
struct libusb_bos_descriptor *bos = NULL;
- g_return_val_if_fail(G_USB_IS_DEVICE(device), NULL);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), NULL);
g_return_val_if_fail(error == NULL || *error == NULL, NULL);
rc = libusb_get_bos_descriptor(priv->handle, &bos);
- if (!g_usb_device_libusb_error_to_gerror(device, rc, error))
+ if (!g_usb_device_libusb_error_to_gerror(self, rc, error))
return NULL;
/* find the right data */
@@ -678,7 +678,7 @@ g_usb_device_get_bos_descriptor(GUsbDevice *device, guint8 capability, GError **
/**
* g_usb_device_get_bos_descriptors:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
* @error: a #GError, or %NULL
*
* Gets all the BOS descriptors exported by the device.
@@ -688,19 +688,19 @@ g_usb_device_get_bos_descriptor(GUsbDevice *device, guint8 capability, GError **
* Since: 0.4.0
**/
GPtrArray *
-g_usb_device_get_bos_descriptors(GUsbDevice *device, GError **error)
+g_usb_device_get_bos_descriptors(GUsbDevice *self, GError **error)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
gint rc;
guint8 num_device_caps;
struct libusb_bos_descriptor *bos = NULL;
GPtrArray *array = NULL;
- g_return_val_if_fail(G_USB_IS_DEVICE(device), NULL);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), NULL);
g_return_val_if_fail(error == NULL || *error == NULL, NULL);
rc = libusb_get_bos_descriptor(priv->handle, &bos);
- if (!g_usb_device_libusb_error_to_gerror(device, rc, error))
+ if (!g_usb_device_libusb_error_to_gerror(self, rc, error))
return NULL;
/* get all BOS descriptors */
@@ -723,7 +723,7 @@ g_usb_device_get_bos_descriptors(GUsbDevice *device, GError **error)
/**
* g_usb_device_close:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
* @error: a #GError, or %NULL
*
* Closes the device when it is no longer required.
@@ -733,11 +733,11 @@ g_usb_device_get_bos_descriptors(GUsbDevice *device, GError **error)
* Since: 0.1.0
**/
gboolean
-g_usb_device_close(GUsbDevice *device, GError **error)
+g_usb_device_close(GUsbDevice *self, GError **error)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
- g_return_val_if_fail(G_USB_IS_DEVICE(device), FALSE);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), FALSE);
g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
/* ignore */
@@ -745,7 +745,7 @@ g_usb_device_close(GUsbDevice *device, GError **error)
return TRUE;
if (priv->handle == NULL)
- return g_usb_device_not_open_error(device, error);
+ return g_usb_device_not_open_error(self, error);
libusb_close(priv->handle);
priv->handle = NULL;
@@ -754,13 +754,13 @@ g_usb_device_close(GUsbDevice *device, GError **error)
/**
* g_usb_device_reset:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
* @error: a #GError, or %NULL
*
* Perform a USB port reset to reinitialize a device.
*
* If the reset succeeds, the device will appear to disconnected and reconnected.
- * This means the @device will no longer be valid and should be closed and
+ * This means the @self will no longer be valid and should be closed and
* rediscovered.
*
* This is a blocking function which usually incurs a noticeable delay.
@@ -770,25 +770,25 @@ g_usb_device_close(GUsbDevice *device, GError **error)
* Since: 0.1.0
**/
gboolean
-g_usb_device_reset(GUsbDevice *device, GError **error)
+g_usb_device_reset(GUsbDevice *self, GError **error)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
gint rc;
- g_return_val_if_fail(G_USB_IS_DEVICE(device), FALSE);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), FALSE);
g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
if (priv->handle == NULL)
- return g_usb_device_not_open_error(device, error);
+ return g_usb_device_not_open_error(self, error);
rc = libusb_reset_device(priv->handle);
if (rc == LIBUSB_ERROR_NOT_FOUND)
return TRUE;
- return g_usb_device_libusb_error_to_gerror(device, rc, error);
+ return g_usb_device_libusb_error_to_gerror(self, rc, error);
}
/**
* g_usb_device_get_configuration:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
* @error: a #GError, or %NULL
*
* Get the bConfigurationValue for the active configuration of the device.
@@ -800,23 +800,23 @@ g_usb_device_reset(GUsbDevice *device, GError **error)
* Since: 0.1.0
**/
gint
-g_usb_device_get_configuration(GUsbDevice *device, GError **error)
+g_usb_device_get_configuration(GUsbDevice *self, GError **error)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
gint rc;
int config;
- g_return_val_if_fail(G_USB_IS_DEVICE(device), -1);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), -1);
g_return_val_if_fail(error == NULL || *error == NULL, -1);
if (priv->handle == NULL) {
- g_usb_device_not_open_error(device, error);
+ g_usb_device_not_open_error(self, error);
return -1;
}
rc = libusb_get_configuration(priv->handle, &config);
if (rc != LIBUSB_SUCCESS) {
- g_usb_device_libusb_error_to_gerror(device, rc, error);
+ g_usb_device_libusb_error_to_gerror(self, rc, error);
return -1;
}
@@ -825,7 +825,7 @@ g_usb_device_get_configuration(GUsbDevice *device, GError **error)
/**
* g_usb_device_set_configuration:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
* @configuration: the configuration value to set
* @error: a #GError, or %NULL
*
@@ -838,34 +838,34 @@ g_usb_device_get_configuration(GUsbDevice *device, GError **error)
* Since: 0.1.0
**/
gboolean
-g_usb_device_set_configuration(GUsbDevice *device, gint configuration, GError **error)
+g_usb_device_set_configuration(GUsbDevice *self, gint configuration, GError **error)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
gint rc;
gint config_tmp = 0;
- g_return_val_if_fail(G_USB_IS_DEVICE(device), FALSE);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), FALSE);
g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
if (priv->handle == NULL)
- return g_usb_device_not_open_error(device, error);
+ return g_usb_device_not_open_error(self, error);
/* verify we've not already set the same configuration */
rc = libusb_get_configuration(priv->handle, &config_tmp);
if (rc != LIBUSB_SUCCESS) {
- return g_usb_device_libusb_error_to_gerror(device, rc, error);
+ return g_usb_device_libusb_error_to_gerror(self, rc, error);
}
if (config_tmp == configuration)
return TRUE;
/* different, so change */
rc = libusb_set_configuration(priv->handle, configuration);
- return g_usb_device_libusb_error_to_gerror(device, rc, error);
+ return g_usb_device_libusb_error_to_gerror(self, rc, error);
}
/**
* g_usb_device_claim_interface:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
* @interface: bInterfaceNumber of the interface you wish to claim
* @flags: #GUsbDeviceClaimInterfaceFlags
* @error: a #GError, or %NULL
@@ -877,35 +877,35 @@ g_usb_device_set_configuration(GUsbDevice *device, gint configuration, GError **
* Since: 0.1.0
**/
gboolean
-g_usb_device_claim_interface(GUsbDevice *device,
+g_usb_device_claim_interface(GUsbDevice *self,
gint interface,
GUsbDeviceClaimInterfaceFlags flags,
GError **error)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
gint rc;
- g_return_val_if_fail(G_USB_IS_DEVICE(device), FALSE);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), FALSE);
g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
if (priv->handle == NULL)
- return g_usb_device_not_open_error(device, error);
+ return g_usb_device_not_open_error(self, error);
if (flags & G_USB_DEVICE_CLAIM_INTERFACE_BIND_KERNEL_DRIVER) {
rc = libusb_detach_kernel_driver(priv->handle, interface);
if (rc != LIBUSB_SUCCESS && rc != LIBUSB_ERROR_NOT_FOUND && /* No driver attached */
rc != LIBUSB_ERROR_NOT_SUPPORTED && /* win32 */
rc != LIBUSB_ERROR_BUSY /* driver rebound already */)
- return g_usb_device_libusb_error_to_gerror(device, rc, error);
+ return g_usb_device_libusb_error_to_gerror(self, rc, error);
}
rc = libusb_claim_interface(priv->handle, interface);
- return g_usb_device_libusb_error_to_gerror(device, rc, error);
+ return g_usb_device_libusb_error_to_gerror(self, rc, error);
}
/**
* g_usb_device_release_interface:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
* @interface: bInterfaceNumber of the interface you wish to release
* @flags: #GUsbDeviceClaimInterfaceFlags
* @error: a #GError, or %NULL
@@ -917,30 +917,30 @@ g_usb_device_claim_interface(GUsbDevice *device,
* Since: 0.1.0
**/
gboolean
-g_usb_device_release_interface(GUsbDevice *device,
+g_usb_device_release_interface(GUsbDevice *self,
gint interface,
GUsbDeviceClaimInterfaceFlags flags,
GError **error)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
gint rc;
- g_return_val_if_fail(G_USB_IS_DEVICE(device), FALSE);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), FALSE);
g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
if (priv->handle == NULL)
- return g_usb_device_not_open_error(device, error);
+ return g_usb_device_not_open_error(self, error);
rc = libusb_release_interface(priv->handle, interface);
if (rc != LIBUSB_SUCCESS)
- return g_usb_device_libusb_error_to_gerror(device, rc, error);
+ return g_usb_device_libusb_error_to_gerror(self, rc, error);
if (flags & G_USB_DEVICE_CLAIM_INTERFACE_BIND_KERNEL_DRIVER) {
rc = libusb_attach_kernel_driver(priv->handle, interface);
if (rc != LIBUSB_SUCCESS && rc != LIBUSB_ERROR_NOT_FOUND && /* No driver attached */
rc != LIBUSB_ERROR_NOT_SUPPORTED && /* win32 */
rc != LIBUSB_ERROR_BUSY /* driver rebound already */)
- return g_usb_device_libusb_error_to_gerror(device, rc, error);
+ return g_usb_device_libusb_error_to_gerror(self, rc, error);
}
return TRUE;
@@ -948,7 +948,7 @@ g_usb_device_release_interface(GUsbDevice *device,
/**
* g_usb_device_set_interface_alt:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
* @interface: bInterfaceNumber of the interface you wish to release
* @alt: alternative setting number
* @error: a #GError, or %NULL
@@ -960,20 +960,20 @@ g_usb_device_release_interface(GUsbDevice *device,
* Since: 0.2.8
**/
gboolean
-g_usb_device_set_interface_alt(GUsbDevice *device, gint interface, guint8 alt, GError **error)
+g_usb_device_set_interface_alt(GUsbDevice *self, gint interface, guint8 alt, GError **error)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
gint rc;
- g_return_val_if_fail(G_USB_IS_DEVICE(device), FALSE);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), FALSE);
g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
if (priv->handle == NULL)
- return g_usb_device_not_open_error(device, error);
+ return g_usb_device_not_open_error(self, error);
rc = libusb_set_interface_alt_setting(priv->handle, interface, (gint)alt);
if (rc != LIBUSB_SUCCESS)
- return g_usb_device_libusb_error_to_gerror(device, rc, error);
+ return g_usb_device_libusb_error_to_gerror(self, rc, error);
return TRUE;
}
@@ -991,24 +991,24 @@ g_usb_device_set_interface_alt(GUsbDevice *device, gint interface, guint8 alt, G
* Since: 0.1.0
**/
gchar *
-g_usb_device_get_string_descriptor(GUsbDevice *device, guint8 desc_index, GError **error)
+g_usb_device_get_string_descriptor(GUsbDevice *self, guint8 desc_index, GError **error)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
gint rc;
/* libusb_get_string_descriptor_ascii returns max 128 bytes */
unsigned char buf[128];
- g_return_val_if_fail(G_USB_IS_DEVICE(device), NULL);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), NULL);
g_return_val_if_fail(error == NULL || *error == NULL, NULL);
if (priv->handle == NULL) {
- g_usb_device_not_open_error(device, error);
+ g_usb_device_not_open_error(self, error);
return NULL;
}
rc = libusb_get_string_descriptor_ascii(priv->handle, desc_index, buf, sizeof(buf));
if (rc < 0) {
- g_usb_device_libusb_error_to_gerror(device, rc, error);
+ g_usb_device_libusb_error_to_gerror(self, rc, error);
return NULL;
}
@@ -1030,27 +1030,27 @@ g_usb_device_get_string_descriptor(GUsbDevice *device, guint8 desc_index, GError
* Since: 0.3.8
**/
GBytes *
-g_usb_device_get_string_descriptor_bytes_full(GUsbDevice *device,
+g_usb_device_get_string_descriptor_bytes_full(GUsbDevice *self,
guint8 desc_index,
guint16 langid,
gsize length,
GError **error)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
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(G_USB_IS_DEVICE(self), NULL);
g_return_val_if_fail(error == NULL || *error == NULL, NULL);
if (priv->handle == NULL) {
- g_usb_device_not_open_error(device, error);
+ g_usb_device_not_open_error(self, error);
return NULL;
}
rc = libusb_get_string_descriptor(priv->handle, desc_index, langid, buf, length);
if (rc < 0) {
- g_usb_device_libusb_error_to_gerror(device, rc, error);
+ g_usb_device_libusb_error_to_gerror(self, rc, error);
return NULL;
}
@@ -1074,19 +1074,15 @@ g_usb_device_get_string_descriptor_bytes_full(GUsbDevice *device,
* Since: 0.3.6
**/
GBytes *
-g_usb_device_get_string_descriptor_bytes(GUsbDevice *device,
+g_usb_device_get_string_descriptor_bytes(GUsbDevice *self,
guint8 desc_index,
guint16 langid,
GError **error)
{
- return g_usb_device_get_string_descriptor_bytes_full(device,
- desc_index,
- langid,
- 128,
- error);
+ return g_usb_device_get_string_descriptor_bytes_full(self, desc_index, langid, 128, error);
}
-typedef gssize(GUsbDeviceTransferFinishFunc)(GUsbDevice *device, GAsyncResult *res, GError **error);
+typedef gssize(GUsbDeviceTransferFinishFunc)(GUsbDevice *self, GAsyncResult *res, GError **error);
typedef struct {
GError **error;
@@ -1097,15 +1093,15 @@ typedef struct {
} GUsbSyncHelper;
static void
-g_usb_device_sync_transfer_cb(GUsbDevice *device, GAsyncResult *res, GUsbSyncHelper *helper)
+g_usb_device_sync_transfer_cb(GUsbDevice *self, GAsyncResult *res, GUsbSyncHelper *helper)
{
- helper->ret = (*helper->finish_func)(device, res, helper->error);
+ helper->ret = (*helper->finish_func)(self, res, helper->error);
g_main_loop_quit(helper->loop);
}
/**
* g_usb_device_control_transfer:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
* @request_type: the request type field for the setup packet
* @request: the request field for the setup packet
* @value: the value field for the setup packet
@@ -1129,7 +1125,7 @@ g_usb_device_sync_transfer_cb(GUsbDevice *device, GAsyncResult *res, GUsbSyncHel
* Since: 0.1.0
**/
gboolean
-g_usb_device_control_transfer(GUsbDevice *device,
+g_usb_device_control_transfer(GUsbDevice *self,
GUsbDeviceDirection direction,
GUsbDeviceRequestType request_type,
GUsbDeviceRecipient recipient,
@@ -1143,7 +1139,7 @@ g_usb_device_control_transfer(GUsbDevice *device,
GCancellable *cancellable,
GError **error)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
GUsbSyncHelper helper;
helper.ret = -1;
@@ -1152,7 +1148,7 @@ g_usb_device_control_transfer(GUsbDevice *device,
helper.error = error;
helper.finish_func = g_usb_device_control_transfer_finish;
- g_usb_device_control_transfer_async(device,
+ g_usb_device_control_transfer_async(self,
direction,
request_type,
recipient,
@@ -1176,7 +1172,7 @@ g_usb_device_control_transfer(GUsbDevice *device,
/**
* g_usb_device_bulk_transfer:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
* @endpoint: the address of a valid endpoint to communicate with
* @data: (array length=length): a suitably-sized data buffer for
* either input or output
@@ -1197,7 +1193,7 @@ g_usb_device_control_transfer(GUsbDevice *device,
* Since: 0.1.0
**/
gboolean
-g_usb_device_bulk_transfer(GUsbDevice *device,
+g_usb_device_bulk_transfer(GUsbDevice *self,
guint8 endpoint,
guint8 *data,
gsize length,
@@ -1206,7 +1202,7 @@ g_usb_device_bulk_transfer(GUsbDevice *device,
GCancellable *cancellable,
GError **error)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
GUsbSyncHelper helper;
helper.ret = -1;
@@ -1215,7 +1211,7 @@ g_usb_device_bulk_transfer(GUsbDevice *device,
helper.error = error;
helper.finish_func = g_usb_device_bulk_transfer_finish;
- g_usb_device_bulk_transfer_async(device,
+ g_usb_device_bulk_transfer_async(self,
endpoint,
data,
length,
@@ -1234,7 +1230,7 @@ g_usb_device_bulk_transfer(GUsbDevice *device,
/**
* g_usb_device_interrupt_transfer:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
* @endpoint: the address of a valid endpoint to communicate with
* @data: (array length=length): a suitably-sized data buffer for
* either input or output
@@ -1255,7 +1251,7 @@ g_usb_device_bulk_transfer(GUsbDevice *device,
* Since: 0.1.0
**/
gboolean
-g_usb_device_interrupt_transfer(GUsbDevice *device,
+g_usb_device_interrupt_transfer(GUsbDevice *self,
guint8 endpoint,
guint8 *data,
gsize length,
@@ -1264,7 +1260,7 @@ g_usb_device_interrupt_transfer(GUsbDevice *device,
GCancellable *cancellable,
GError **error)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
GUsbSyncHelper helper;
helper.ret = -1;
@@ -1273,7 +1269,7 @@ g_usb_device_interrupt_transfer(GUsbDevice *device,
helper.error = error;
helper.finish_func = g_usb_device_interrupt_transfer_finish;
- g_usb_device_interrupt_transfer_async(device,
+ g_usb_device_interrupt_transfer_async(self,
endpoint,
data,
length,
@@ -1414,7 +1410,7 @@ g_usb_device_control_transfer_cb(struct libusb_transfer *transfer)
/**
* g_usb_device_control_transfer_async:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
* @data: (array length=length): a suitably-sized data buffer for
* either input or output
* @length: the length field for the setup packet.
@@ -1430,7 +1426,7 @@ g_usb_device_control_transfer_cb(struct libusb_transfer *transfer)
* Since: 0.1.0
**/
void
-g_usb_device_control_transfer_async(GUsbDevice *device,
+g_usb_device_control_transfer_async(GUsbDevice *self,
GUsbDeviceDirection direction,
GUsbDeviceRequestType request_type,
GUsbDeviceRecipient recipient,
@@ -1444,17 +1440,17 @@ g_usb_device_control_transfer_async(GUsbDevice *device,
GAsyncReadyCallback callback,
gpointer user_data)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
GTask *task;
GcmDeviceReq *req;
gint rc;
guint8 request_type_raw = 0;
GError *error = NULL;
- g_return_if_fail(G_USB_IS_DEVICE(device));
+ g_return_if_fail(G_USB_IS_DEVICE(self));
if (priv->handle == NULL) {
- g_usb_device_async_not_open_error(device,
+ g_usb_device_async_not_open_error(self,
callback,
user_data,
g_usb_device_control_transfer_async);
@@ -1465,7 +1461,7 @@ g_usb_device_control_transfer_async(GUsbDevice *device,
req->transfer = libusb_alloc_transfer(0);
req->data = data;
- task = g_task_new(device, cancellable, callback, user_data);
+ task = g_task_new(self, 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)) {
@@ -1496,7 +1492,7 @@ g_usb_device_control_transfer_async(GUsbDevice *device,
/* submit transfer */
rc = libusb_submit_transfer(req->transfer);
if (rc < 0) {
- g_usb_device_libusb_error_to_gerror(device, rc, &error);
+ g_usb_device_libusb_error_to_gerror(self, rc, &error);
g_task_return_error(task, error);
g_object_unref(task);
}
@@ -1513,7 +1509,7 @@ g_usb_device_control_transfer_async(GUsbDevice *device,
/**
* g_usb_device_control_transfer_finish:
- * @device: a #GUsbDevice instance.
+ * @self: a #GUsbDevice instance.
* @res: the #GAsyncResult
* @error: A #GError or %NULL
*
@@ -1524,10 +1520,10 @@ g_usb_device_control_transfer_async(GUsbDevice *device,
* Since: 0.1.0
**/
gssize
-g_usb_device_control_transfer_finish(GUsbDevice *device, GAsyncResult *res, GError **error)
+g_usb_device_control_transfer_finish(GUsbDevice *self, GAsyncResult *res, GError **error)
{
- g_return_val_if_fail(G_USB_IS_DEVICE(device), -1);
- g_return_val_if_fail(g_task_is_valid(res, device), -1);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), -1);
+ g_return_val_if_fail(g_task_is_valid(res, self), -1);
g_return_val_if_fail(error == NULL || *error == NULL, -1);
return g_task_propagate_int(G_TASK(res), error);
@@ -1535,7 +1531,7 @@ g_usb_device_control_transfer_finish(GUsbDevice *device, GAsyncResult *res, GErr
/**
* g_usb_device_bulk_transfer_async:
- * @device: a #GUsbDevice instance.
+ * @self: a #GUsbDevice instance.
* @endpoint: the address of a valid endpoint to communicate with
* @data: (array length=length): a suitably-sized data buffer for
* either input or output
@@ -1552,7 +1548,7 @@ g_usb_device_control_transfer_finish(GUsbDevice *device, GAsyncResult *res, GErr
* Since: 0.1.0
**/
void
-g_usb_device_bulk_transfer_async(GUsbDevice *device,
+g_usb_device_bulk_transfer_async(GUsbDevice *self,
guint8 endpoint,
guint8 *data,
gsize length,
@@ -1561,16 +1557,16 @@ g_usb_device_bulk_transfer_async(GUsbDevice *device,
GAsyncReadyCallback callback,
gpointer user_data)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
GTask *task;
GcmDeviceReq *req;
gint rc;
GError *error = NULL;
- g_return_if_fail(G_USB_IS_DEVICE(device));
+ g_return_if_fail(G_USB_IS_DEVICE(self));
if (priv->handle == NULL) {
- g_usb_device_async_not_open_error(device,
+ g_usb_device_async_not_open_error(self,
callback,
user_data,
g_usb_device_bulk_transfer_async);
@@ -1580,7 +1576,7 @@ g_usb_device_bulk_transfer_async(GUsbDevice *device,
req = g_slice_new0(GcmDeviceReq);
req->transfer = libusb_alloc_transfer(0);
- task = g_task_new(device, cancellable, callback, user_data);
+ task = g_task_new(self, 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)) {
@@ -1601,7 +1597,7 @@ g_usb_device_bulk_transfer_async(GUsbDevice *device,
/* submit transfer */
rc = libusb_submit_transfer(req->transfer);
if (rc < 0) {
- g_usb_device_libusb_error_to_gerror(device, rc, &error);
+ g_usb_device_libusb_error_to_gerror(self, rc, &error);
g_task_return_error(task, error);
g_object_unref(task);
}
@@ -1618,7 +1614,7 @@ g_usb_device_bulk_transfer_async(GUsbDevice *device,
/**
* g_usb_device_bulk_transfer_finish:
- * @device: a #GUsbDevice instance.
+ * @self: a #GUsbDevice instance.
* @res: the #GAsyncResult
* @error: A #GError or %NULL
*
@@ -1629,10 +1625,10 @@ g_usb_device_bulk_transfer_async(GUsbDevice *device,
* Since: 0.1.0
**/
gssize
-g_usb_device_bulk_transfer_finish(GUsbDevice *device, GAsyncResult *res, GError **error)
+g_usb_device_bulk_transfer_finish(GUsbDevice *self, GAsyncResult *res, GError **error)
{
- g_return_val_if_fail(G_USB_IS_DEVICE(device), -1);
- g_return_val_if_fail(g_task_is_valid(res, device), -1);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), -1);
+ g_return_val_if_fail(g_task_is_valid(res, self), -1);
g_return_val_if_fail(error == NULL || *error == NULL, -1);
return g_task_propagate_int(G_TASK(res), error);
@@ -1640,7 +1636,7 @@ g_usb_device_bulk_transfer_finish(GUsbDevice *device, GAsyncResult *res, GError
/**
* g_usb_device_interrupt_transfer_async:
- * @device: a #GUsbDevice instance.
+ * @self: a #GUsbDevice instance.
* @endpoint: the address of a valid endpoint to communicate with
* @data: (array length=length): a suitably-sized data buffer for
* either input or output
@@ -1657,7 +1653,7 @@ g_usb_device_bulk_transfer_finish(GUsbDevice *device, GAsyncResult *res, GError
* Since: 0.1.0
**/
void
-g_usb_device_interrupt_transfer_async(GUsbDevice *device,
+g_usb_device_interrupt_transfer_async(GUsbDevice *self,
guint8 endpoint,
guint8 *data,
gsize length,
@@ -1666,16 +1662,16 @@ g_usb_device_interrupt_transfer_async(GUsbDevice *device,
GAsyncReadyCallback callback,
gpointer user_data)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
GTask *task;
GcmDeviceReq *req;
GError *error = NULL;
gint rc;
- g_return_if_fail(G_USB_IS_DEVICE(device));
+ g_return_if_fail(G_USB_IS_DEVICE(self));
if (priv->handle == NULL) {
- g_usb_device_async_not_open_error(device,
+ g_usb_device_async_not_open_error(self,
callback,
user_data,
g_usb_device_interrupt_transfer_async);
@@ -1685,7 +1681,7 @@ g_usb_device_interrupt_transfer_async(GUsbDevice *device,
req = g_slice_new0(GcmDeviceReq);
req->transfer = libusb_alloc_transfer(0);
- task = g_task_new(device, cancellable, callback, user_data);
+ task = g_task_new(self, 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)) {
@@ -1706,7 +1702,7 @@ g_usb_device_interrupt_transfer_async(GUsbDevice *device,
/* submit transfer */
rc = libusb_submit_transfer(req->transfer);
if (rc < 0) {
- g_usb_device_libusb_error_to_gerror(device, rc, &error);
+ g_usb_device_libusb_error_to_gerror(self, rc, &error);
g_task_return_error(task, error);
g_object_unref(task);
}
@@ -1723,7 +1719,7 @@ g_usb_device_interrupt_transfer_async(GUsbDevice *device,
/**
* g_usb_device_interrupt_transfer_finish:
- * @device: a #GUsbDevice instance.
+ * @self: a #GUsbDevice instance.
* @res: the #GAsyncResult
* @error: A #GError or %NULL
*
@@ -1734,10 +1730,10 @@ g_usb_device_interrupt_transfer_async(GUsbDevice *device,
* Since: 0.1.0
**/
gssize
-g_usb_device_interrupt_transfer_finish(GUsbDevice *device, GAsyncResult *res, GError **error)
+g_usb_device_interrupt_transfer_finish(GUsbDevice *self, GAsyncResult *res, GError **error)
{
- g_return_val_if_fail(G_USB_IS_DEVICE(device), -1);
- g_return_val_if_fail(g_task_is_valid(res, device), -1);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), -1);
+ g_return_val_if_fail(g_task_is_valid(res, self), -1);
g_return_val_if_fail(error == NULL || *error == NULL, -1);
return g_task_propagate_int(G_TASK(res), error);
@@ -1745,7 +1741,7 @@ g_usb_device_interrupt_transfer_finish(GUsbDevice *device, GAsyncResult *res, GE
/**
* g_usb_device_get_platform_id:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
*
* Gets the platform identifier for the device.
*
@@ -1757,16 +1753,16 @@ g_usb_device_interrupt_transfer_finish(GUsbDevice *device, GAsyncResult *res, GE
* Since: 0.1.1
**/
const gchar *
-g_usb_device_get_platform_id(GUsbDevice *device)
+g_usb_device_get_platform_id(GUsbDevice *self)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
- g_return_val_if_fail(G_USB_IS_DEVICE(device), NULL);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), NULL);
return priv->platform_id;
}
/**
* g_usb_device_get_parent:
- * @device: a #GUsbDevice instance
+ * @self: a #GUsbDevice instance
*
* Gets the device parent if one exists.
*
@@ -1775,9 +1771,9 @@ g_usb_device_get_platform_id(GUsbDevice *device)
* Since: 0.2.4
**/
GUsbDevice *
-g_usb_device_get_parent(GUsbDevice *device)
+g_usb_device_get_parent(GUsbDevice *self)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
libusb_device *parent;
parent = libusb_get_parent(priv->device);
@@ -1792,7 +1788,7 @@ g_usb_device_get_parent(GUsbDevice *device)
/**
* g_usb_device_get_children:
- * @device: a #GUsbDevice instance
+ * @self: a #GUsbDevice instance
*
* Gets the device children if any exist.
*
@@ -1801,13 +1797,13 @@ g_usb_device_get_parent(GUsbDevice *device)
* Since: 0.2.4
**/
GPtrArray *
-g_usb_device_get_children(GUsbDevice *device)
+g_usb_device_get_children(GUsbDevice *self)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
GPtrArray *children;
g_autoptr(GPtrArray) devices = NULL;
- /* find any devices that have @device as a parent */
+ /* find any devices that have @self as a parent */
children = g_ptr_array_new_with_free_func((GDestroyNotify)g_object_unref);
devices = g_usb_context_get_devices(priv->context);
for (guint i = 0; i < devices->len; i++) {
@@ -1822,7 +1818,7 @@ g_usb_device_get_children(GUsbDevice *device)
/**
* g_usb_device_get_bus:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
*
* Gets the USB bus number for the device.
*
@@ -1831,16 +1827,16 @@ g_usb_device_get_children(GUsbDevice *device)
* Since: 0.1.0
**/
guint8
-g_usb_device_get_bus(GUsbDevice *device)
+g_usb_device_get_bus(GUsbDevice *self)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
- g_return_val_if_fail(G_USB_IS_DEVICE(device), 0);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), 0);
return libusb_get_bus_number(priv->device);
}
/**
* g_usb_device_get_address:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
*
* Gets the USB address for the device.
*
@@ -1849,16 +1845,16 @@ g_usb_device_get_bus(GUsbDevice *device)
* Since: 0.1.0
**/
guint8
-g_usb_device_get_address(GUsbDevice *device)
+g_usb_device_get_address(GUsbDevice *self)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
- g_return_val_if_fail(G_USB_IS_DEVICE(device), 0);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), 0);
return libusb_get_device_address(priv->device);
}
/**
* g_usb_device_get_port_number:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
*
* Gets the USB port number for the device.
*
@@ -1867,16 +1863,16 @@ g_usb_device_get_address(GUsbDevice *device)
* Since: 0.2.4
**/
guint8
-g_usb_device_get_port_number(GUsbDevice *device)
+g_usb_device_get_port_number(GUsbDevice *self)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
- g_return_val_if_fail(G_USB_IS_DEVICE(device), 0);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), 0);
return libusb_get_port_number(priv->device);
}
/**
* g_usb_device_get_vid:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
*
* Gets the vendor ID for the device.
*
@@ -1885,16 +1881,16 @@ g_usb_device_get_port_number(GUsbDevice *device)
* Since: 0.1.0
**/
guint16
-g_usb_device_get_vid(GUsbDevice *device)
+g_usb_device_get_vid(GUsbDevice *self)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
- g_return_val_if_fail(G_USB_IS_DEVICE(device), 0);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), 0);
return priv->desc.idVendor;
}
/**
* g_usb_device_get_pid:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
*
* Gets the product ID for the device.
*
@@ -1903,16 +1899,16 @@ g_usb_device_get_vid(GUsbDevice *device)
* Since: 0.1.0
**/
guint16
-g_usb_device_get_pid(GUsbDevice *device)
+g_usb_device_get_pid(GUsbDevice *self)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
- g_return_val_if_fail(G_USB_IS_DEVICE(device), 0);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), 0);
return priv->desc.idProduct;
}
/**
* g_usb_device_get_release:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
*
* Gets the BCD firmware version number for the device.
*
@@ -1921,16 +1917,16 @@ g_usb_device_get_pid(GUsbDevice *device)
* Since: 0.2.8
**/
guint16
-g_usb_device_get_release(GUsbDevice *device)
+g_usb_device_get_release(GUsbDevice *self)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
- g_return_val_if_fail(G_USB_IS_DEVICE(device), 0);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), 0);
return priv->desc.bcdDevice;
}
/**
* g_usb_device_get_spec:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
*
* Gets the BCD specification revision for the device. For example,
* `0x0110` indicates USB 1.1 and 0x0320 indicates USB 3.2
@@ -1940,16 +1936,16 @@ g_usb_device_get_release(GUsbDevice *device)
* Since: 0.3.1
**/
guint16
-g_usb_device_get_spec(GUsbDevice *device)
+g_usb_device_get_spec(GUsbDevice *self)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
- g_return_val_if_fail(G_USB_IS_DEVICE(device), 0);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), 0);
return priv->desc.bcdUSB;
}
/**
* g_usb_device_get_vid_as_str:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
*
* Gets the vendor ID for the device as a string.
*
@@ -1958,16 +1954,16 @@ g_usb_device_get_spec(GUsbDevice *device)
* Since: 0.2.4
**/
const gchar *
-g_usb_device_get_vid_as_str(GUsbDevice *device)
+g_usb_device_get_vid_as_str(GUsbDevice *self)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
- g_return_val_if_fail(G_USB_IS_DEVICE(device), NULL);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), NULL);
return _g_usb_context_lookup_vendor(priv->context, priv->desc.idVendor, NULL);
}
/**
* g_usb_device_get_pid_as_str:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
*
* Gets the product ID for the device as a string.
*
@@ -1976,10 +1972,10 @@ g_usb_device_get_vid_as_str(GUsbDevice *device)
* Since: 0.2.4
**/
const gchar *
-g_usb_device_get_pid_as_str(GUsbDevice *device)
+g_usb_device_get_pid_as_str(GUsbDevice *self)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
- g_return_val_if_fail(G_USB_IS_DEVICE(device), NULL);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), NULL);
return _g_usb_context_lookup_product(priv->context,
priv->desc.idVendor,
priv->desc.idProduct,
@@ -1988,7 +1984,7 @@ g_usb_device_get_pid_as_str(GUsbDevice *device)
/**
* g_usb_device_get_configuration_index
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
*
* Get the index for the active Configuration string descriptor
* ie, iConfiguration.
@@ -1998,14 +1994,14 @@ g_usb_device_get_pid_as_str(GUsbDevice *device)
* Since: 0.3.5
**/
guint8
-g_usb_device_get_configuration_index(GUsbDevice *device)
+g_usb_device_get_configuration_index(GUsbDevice *self)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
struct libusb_config_descriptor *config;
gint rc;
guint8 index;
- g_return_val_if_fail(G_USB_IS_DEVICE(device), 0);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), 0);
rc = libusb_get_active_config_descriptor(priv->device, &config);
g_return_val_if_fail(rc == 0, 0);
@@ -2018,7 +2014,7 @@ g_usb_device_get_configuration_index(GUsbDevice *device)
/**
* g_usb_device_get_manufacturer_index:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
*
* Gets the index for the Manufacturer string descriptor.
*
@@ -2027,16 +2023,16 @@ g_usb_device_get_configuration_index(GUsbDevice *device)
* Since: 0.1.0
**/
guint8
-g_usb_device_get_manufacturer_index(GUsbDevice *device)
+g_usb_device_get_manufacturer_index(GUsbDevice *self)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
- g_return_val_if_fail(G_USB_IS_DEVICE(device), 0);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), 0);
return priv->desc.iManufacturer;
}
/**
* g_usb_device_get_device_class:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
*
* Gets the device class, typically a #GUsbDeviceClassCode.
*
@@ -2045,16 +2041,16 @@ g_usb_device_get_manufacturer_index(GUsbDevice *device)
* Since: 0.1.7
**/
guint8
-g_usb_device_get_device_class(GUsbDevice *device)
+g_usb_device_get_device_class(GUsbDevice *self)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
- g_return_val_if_fail(G_USB_IS_DEVICE(device), 0);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), 0);
return priv->desc.bDeviceClass;
}
/**
* g_usb_device_get_device_subclass:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
*
* Gets the device subclass qualified by the class number.
* See g_usb_device_get_device_class().
@@ -2064,16 +2060,16 @@ g_usb_device_get_device_class(GUsbDevice *device)
* Since: 0.2.4
**/
guint8
-g_usb_device_get_device_subclass(GUsbDevice *device)
+g_usb_device_get_device_subclass(GUsbDevice *self)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
- g_return_val_if_fail(G_USB_IS_DEVICE(device), 0);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), 0);
return priv->desc.bDeviceSubClass;
}
/**
* g_usb_device_get_device_protocol:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
*
* Gets the device protocol qualified by the class and subclass numbers.
* See g_usb_device_get_device_class() and g_usb_device_get_device_subclass().
@@ -2083,16 +2079,16 @@ g_usb_device_get_device_subclass(GUsbDevice *device)
* Since: 0.2.4
**/
guint8
-g_usb_device_get_device_protocol(GUsbDevice *device)
+g_usb_device_get_device_protocol(GUsbDevice *self)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
- g_return_val_if_fail(G_USB_IS_DEVICE(device), 0);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), 0);
return priv->desc.bDeviceProtocol;
}
/**
* g_usb_device_get_product_index:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
*
* Gets the index for the Product string descriptor.
*
@@ -2101,16 +2097,16 @@ g_usb_device_get_device_protocol(GUsbDevice *device)
* Since: 0.1.0
**/
guint8
-g_usb_device_get_product_index(GUsbDevice *device)
+g_usb_device_get_product_index(GUsbDevice *self)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
- g_return_val_if_fail(G_USB_IS_DEVICE(device), 0);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), 0);
return priv->desc.iProduct;
}
/**
* g_usb_device_get_serial_number_index:
- * @device: a #GUsbDevice
+ * @self: a #GUsbDevice
*
* Gets the index for the Serial Number string descriptor.
*
@@ -2119,9 +2115,9 @@ g_usb_device_get_product_index(GUsbDevice *device)
* Since: 0.1.0
**/
guint8
-g_usb_device_get_serial_number_index(GUsbDevice *device)
+g_usb_device_get_serial_number_index(GUsbDevice *self)
{
- GUsbDevicePrivate *priv = GET_PRIVATE(device);
- g_return_val_if_fail(G_USB_IS_DEVICE(device), 0);
+ GUsbDevicePrivate *priv = GET_PRIVATE(self);
+ g_return_val_if_fail(G_USB_IS_DEVICE(self), 0);
return priv->desc.iSerialNumber;
}
diff --git a/gusb/gusb-device.h b/gusb/gusb-device.h
index 755f046..77b5c86 100644
--- a/gusb/gusb-device.h
+++ b/gusb/gusb-device.h
@@ -137,102 +137,102 @@ GQuark
g_usb_device_error_quark(void);
const gchar *
-g_usb_device_get_platform_id(GUsbDevice *device);
+g_usb_device_get_platform_id(GUsbDevice *self);
GUsbDevice *
-g_usb_device_get_parent(GUsbDevice *device);
+g_usb_device_get_parent(GUsbDevice *self);
GPtrArray *
-g_usb_device_get_children(GUsbDevice *device);
+g_usb_device_get_children(GUsbDevice *self);
guint8
-g_usb_device_get_bus(GUsbDevice *device);
+g_usb_device_get_bus(GUsbDevice *self);
guint8
-g_usb_device_get_address(GUsbDevice *device);
+g_usb_device_get_address(GUsbDevice *self);
guint8
-g_usb_device_get_port_number(GUsbDevice *device);
+g_usb_device_get_port_number(GUsbDevice *self);
guint16
-g_usb_device_get_vid(GUsbDevice *device);
+g_usb_device_get_vid(GUsbDevice *self);
guint16
-g_usb_device_get_pid(GUsbDevice *device);
+g_usb_device_get_pid(GUsbDevice *self);
guint16
-g_usb_device_get_release(GUsbDevice *device);
+g_usb_device_get_release(GUsbDevice *self);
guint16
-g_usb_device_get_spec(GUsbDevice *device);
+g_usb_device_get_spec(GUsbDevice *self);
const gchar *
-g_usb_device_get_vid_as_str(GUsbDevice *device);
+g_usb_device_get_vid_as_str(GUsbDevice *self);
const gchar *
-g_usb_device_get_pid_as_str(GUsbDevice *device);
+g_usb_device_get_pid_as_str(GUsbDevice *self);
guint8
-g_usb_device_get_device_class(GUsbDevice *device);
+g_usb_device_get_device_class(GUsbDevice *self);
guint8
-g_usb_device_get_device_subclass(GUsbDevice *device);
+g_usb_device_get_device_subclass(GUsbDevice *self);
guint8
-g_usb_device_get_device_protocol(GUsbDevice *device);
+g_usb_device_get_device_protocol(GUsbDevice *self);
guint8
-g_usb_device_get_configuration_index(GUsbDevice *device);
+g_usb_device_get_configuration_index(GUsbDevice *self);
guint8
-g_usb_device_get_manufacturer_index(GUsbDevice *device);
+g_usb_device_get_manufacturer_index(GUsbDevice *self);
guint8
-g_usb_device_get_product_index(GUsbDevice *device);
+g_usb_device_get_product_index(GUsbDevice *self);
guint8
-g_usb_device_get_serial_number_index(GUsbDevice *device);
+g_usb_device_get_serial_number_index(GUsbDevice *self);
guint8
-g_usb_device_get_custom_index(GUsbDevice *device,
+g_usb_device_get_custom_index(GUsbDevice *self,
guint8 class_id,
guint8 subclass_id,
guint8 protocol_id,
GError **error);
GUsbInterface *
-g_usb_device_get_interface(GUsbDevice *device,
+g_usb_device_get_interface(GUsbDevice *self,
guint8 class_id,
guint8 subclass_id,
guint8 protocol_id,
GError **error);
GPtrArray *
-g_usb_device_get_interfaces(GUsbDevice *device, GError **error);
+g_usb_device_get_interfaces(GUsbDevice *self, GError **error);
GPtrArray *
-g_usb_device_get_bos_descriptors(GUsbDevice *device, GError **error);
+g_usb_device_get_bos_descriptors(GUsbDevice *self, GError **error);
GUsbBosDescriptor *
-g_usb_device_get_bos_descriptor(GUsbDevice *device, guint8 capability, GError **error);
+g_usb_device_get_bos_descriptor(GUsbDevice *self, guint8 capability, GError **error);
gboolean
-g_usb_device_open(GUsbDevice *device, GError **error);
+g_usb_device_open(GUsbDevice *self, GError **error);
gboolean
-g_usb_device_close(GUsbDevice *device, GError **error);
+g_usb_device_close(GUsbDevice *self, GError **error);
gboolean
-g_usb_device_reset(GUsbDevice *device, GError **error);
+g_usb_device_reset(GUsbDevice *self, GError **error);
gint
-g_usb_device_get_configuration(GUsbDevice *device, GError **error);
+g_usb_device_get_configuration(GUsbDevice *self, GError **error);
gboolean
-g_usb_device_set_configuration(GUsbDevice *device, gint configuration, GError **error);
+g_usb_device_set_configuration(GUsbDevice *self, gint configuration, GError **error);
gboolean
-g_usb_device_claim_interface(GUsbDevice *device,
+g_usb_device_claim_interface(GUsbDevice *self,
gint interface,
GUsbDeviceClaimInterfaceFlags flags,
GError **error);
gboolean
-g_usb_device_release_interface(GUsbDevice *device,
+g_usb_device_release_interface(GUsbDevice *self,
gint interface,
GUsbDeviceClaimInterfaceFlags flags,
GError **error);
gboolean
-g_usb_device_set_interface_alt(GUsbDevice *device, gint interface, guint8 alt, GError **error);
+g_usb_device_set_interface_alt(GUsbDevice *self, gint interface, guint8 alt, GError **error);
gchar *
-g_usb_device_get_string_descriptor(GUsbDevice *device, guint8 desc_index, GError **error);
+g_usb_device_get_string_descriptor(GUsbDevice *self, guint8 desc_index, GError **error);
GBytes *
-g_usb_device_get_string_descriptor_bytes(GUsbDevice *device,
+g_usb_device_get_string_descriptor_bytes(GUsbDevice *self,
guint8 desc_index,
guint16 langid,
GError **error);
GBytes *
-g_usb_device_get_string_descriptor_bytes_full(GUsbDevice *device,
+g_usb_device_get_string_descriptor_bytes_full(GUsbDevice *self,
guint8 desc_index,
guint16 langid,
gsize length,
@@ -240,7 +240,7 @@ g_usb_device_get_string_descriptor_bytes_full(GUsbDevice *device,
/* sync -- TODO: use GCancellable and GUsbSource */
gboolean
-g_usb_device_control_transfer(GUsbDevice *device,
+g_usb_device_control_transfer(GUsbDevice *self,
GUsbDeviceDirection direction,
GUsbDeviceRequestType request_type,
GUsbDeviceRecipient recipient,
@@ -255,7 +255,7 @@ g_usb_device_control_transfer(GUsbDevice *device,
GError **error);
gboolean
-g_usb_device_bulk_transfer(GUsbDevice *device,
+g_usb_device_bulk_transfer(GUsbDevice *self,
guint8 endpoint,
guint8 *data,
gsize length,
@@ -265,7 +265,7 @@ g_usb_device_bulk_transfer(GUsbDevice *device,
GError **error);
gboolean
-g_usb_device_interrupt_transfer(GUsbDevice *device,
+g_usb_device_interrupt_transfer(GUsbDevice *self,
guint8 endpoint,
guint8 *data,
gsize length,
@@ -277,7 +277,7 @@ g_usb_device_interrupt_transfer(GUsbDevice *device,
/* async */
void
-g_usb_device_control_transfer_async(GUsbDevice *device,
+g_usb_device_control_transfer_async(GUsbDevice *self,
GUsbDeviceDirection direction,
GUsbDeviceRequestType request_type,
GUsbDeviceRecipient recipient,
@@ -291,10 +291,10 @@ g_usb_device_control_transfer_async(GUsbDevice *device,
GAsyncReadyCallback callback,
gpointer user_data);
gssize
-g_usb_device_control_transfer_finish(GUsbDevice *device, GAsyncResult *res, GError **error);
+g_usb_device_control_transfer_finish(GUsbDevice *self, GAsyncResult *res, GError **error);
void
-g_usb_device_bulk_transfer_async(GUsbDevice *device,
+g_usb_device_bulk_transfer_async(GUsbDevice *self,
guint8 endpoint,
guint8 *data,
gsize length,
@@ -303,10 +303,10 @@ g_usb_device_bulk_transfer_async(GUsbDevice *device,
GAsyncReadyCallback callback,
gpointer user_data);
gssize
-g_usb_device_bulk_transfer_finish(GUsbDevice *device, GAsyncResult *res, GError **error);
+g_usb_device_bulk_transfer_finish(GUsbDevice *self, GAsyncResult *res, GError **error);
void
-g_usb_device_interrupt_transfer_async(GUsbDevice *device,
+g_usb_device_interrupt_transfer_async(GUsbDevice *self,
guint8 endpoint,
guint8 *data,
gsize length,
@@ -315,6 +315,6 @@ g_usb_device_interrupt_transfer_async(GUsbDevice *device,
GAsyncReadyCallback callback,
gpointer user_data);
gssize
-g_usb_device_interrupt_transfer_finish(GUsbDevice *device, GAsyncResult *res, GError **error);
+g_usb_device_interrupt_transfer_finish(GUsbDevice *self, GAsyncResult *res, GError **error);
G_END_DECLS
diff --git a/gusb/gusb-source.c b/gusb/gusb-source.c
index 51502e0..becb8c8 100644
--- a/gusb/gusb-source.c
+++ b/gusb/gusb-source.c
@@ -36,7 +36,7 @@ g_usb_source_error_quark(void)
/**
* g_usb_source_set_callback:
- * @source: a #GUsbSource
+ * @self: a #GUsbSource
* @func: a function to call
* @data: data to pass to @func
* @notify: a #GDestroyNotify
@@ -46,10 +46,7 @@ g_usb_source_error_quark(void)
* Since: 0.1.0
**/
void
-g_usb_source_set_callback(GUsbSource *source,
- GSourceFunc func,
- gpointer data,
- GDestroyNotify notify)
+g_usb_source_set_callback(GUsbSource *self, GSourceFunc func, gpointer data, GDestroyNotify notify)
{
- g_source_set_callback((GSource *)source, func, data, notify);
+ g_source_set_callback((GSource *)self, func, data, notify);
}
diff --git a/gusb/gusb-source.h b/gusb/gusb-source.h
index a6a7a81..cd4bca0 100644
--- a/gusb/gusb-source.h
+++ b/gusb/gusb-source.h
@@ -29,9 +29,6 @@ g_usb_source_error_quark(void);
G_DEPRECATED
void
-g_usb_source_set_callback(GUsbSource *source,
- GSourceFunc func,
- gpointer data,
- GDestroyNotify notify);
+g_usb_source_set_callback(GUsbSource *self, GSourceFunc func, gpointer data, GDestroyNotify notify);
G_END_DECLS