[Spice-devel] [PATCH v5 02/13] win-usb-dev: Track device redirection operations in progress

Dmitry Fleytman dmitry at daynix.com
Sun Feb 28 08:41:30 UTC 2016


> On 8 Feb 2016, at 19:24 PM, Jonathon Jongsma <jjongsma at redhat.com> wrote:
> 
> On Thu, 2015-10-29 at 17:27 +0200, Dmitry Fleytman wrote:
>> From: Kirill Moizik <kmoizik at redhat.com>
>> 
>> This commit introduces redirecting property of GUdevClient
>> 
>> This property indicates when a redirection operation
>> is in progress on a device. It's set back to FALSE
>> once the device is fully redirected to the guest.
>> 
>> Signed-off-by: Kirill Moizik <kmoizik at redhat.com>
>> Signed-off-by: Dmitry Fleytman <dfleytma at redhat.com>
>> ---
>> src/win-usb-dev.c | 61
>> +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 61 insertions(+)
>> 
>> diff --git a/src/win-usb-dev.c b/src/win-usb-dev.c
>> index 1e4b2d6..60bc434 100644
>> --- a/src/win-usb-dev.c
>> +++ b/src/win-usb-dev.c
>> @@ -32,11 +32,17 @@
>> #define G_UDEV_CLIENT_GET_PRIVATE(obj) \
>>     (G_TYPE_INSTANCE_GET_PRIVATE((obj), G_UDEV_TYPE_CLIENT,
>> GUdevClientPrivate))
>> 
>> +enum {
>> +    PROP_0,
>> +    PROP_REDIRECTING
>> +};
>> +
>> struct _GUdevClientPrivate {
>>     libusb_context *ctx;
>>     gssize udev_list_size;
>>     GList *udev_list;
>>     HWND hwnd;
>> +    gboolean redirecting;
>> };
>> 
>> #define G_UDEV_CLIENT_WINCLASS_NAME  TEXT("G_UDEV_CLIENT")
>> @@ -272,11 +278,52 @@ static void g_udev_client_finalize(GObject *gobject)
>>         G_OBJECT_CLASS(g_udev_client_parent_class)->finalize(gobject);
>> }
>> 
>> +static void g_udev_client_get_property(GObject     *gobject,
>> +                                       guint        prop_id,
>> +                                       GValue      *value,
>> +                                       GParamSpec  *pspec)
>> +{
>> +    GUdevClient *self = G_UDEV_CLIENT(gobject);
>> +    GUdevClientPrivate *priv = self->priv;
>> +
>> +    switch (prop_id) {
>> +    case PROP_REDIRECTING:
>> +        g_value_set_boolean(value, priv->redirecting);
>> +        break;
>> +    default:
>> +        G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
>> +        break;
>> +    }
>> +}
>> +
>> +static void handle_dev_change(GUdevClient *self);
> 
> 
> It seems this bit was accidentally included? I don't see it used anywhere within
> this patch.

Yes, this is needed later. Moving to to the proper patch...

> 
>> +
>> +static void g_udev_client_set_property(GObject       *gobject,
>> +                                       guint          prop_id,
>> +                                       const GValue  *value,
>> +                                       GParamSpec    *pspec)
>> +{
>> +    GUdevClient *self = G_UDEV_CLIENT(gobject);
>> +    GUdevClientPrivate *priv = self->priv;
>> +
>> +    switch (prop_id) {
>> +    case PROP_REDIRECTING:
>> +        priv->redirecting = g_value_get_boolean(value);
>> +        break;
>> +    default:
>> +        G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
>> +        break;
>> +    }
>> +}
>> +
>> static void g_udev_client_class_init(GUdevClientClass *klass)
>> {
>>     GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
>> +    GParamSpec *pspec;
>> 
>>     gobject_class->finalize = g_udev_client_finalize;
>> +    gobject_class->get_property = g_udev_client_get_property;
>> +    gobject_class->set_property = g_udev_client_set_property;
>> 
>>     signals[UEVENT_SIGNAL] =
>>         g_signal_new("uevent",
>> @@ -290,6 +337,20 @@ static void g_udev_client_class_init(GUdevClientClass
>> *klass)
>>                      G_TYPE_STRING,
>>                      G_UDEV_TYPE_DEVICE);
>> 
>> +    /**
>> +    * GUdevClient::redirecting:
>> +    *
>> +    * This property indicates when a redirection operation
>> +    * is in progress on a device. It's set back to FALSE
>> +    * once the device is fully redirected to the guest.
>> +    */
>> +    pspec = g_param_spec_boolean("redirecting", "Redirecting",
>> +                                 "USB redirection operation is in progress",
>> +                                 FALSE,
>> +                                 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
>> +
>> +    g_object_class_install_property(gobject_class, PROP_REDIRECTING, pspec);
>> +
>>     g_type_class_add_private(klass, sizeof(GUdevClientPrivate));
>> }
>> 
> 
> 
> Aside from the extra declaration above, the code looks fine. I can't yet tell wh
> ether this property makes sense until I get farther into the patchset and see
> how it is used.
> 
> Reviewed-by: Jonathon Jongsma <jjongsma at redhat.com <mailto:jjongsma at redhat.com>>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20160228/2beda9ae/attachment-0001.html>


More information about the Spice-devel mailing list