1 /* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /*
3    Copyright (C) 2011 Red Hat, Inc.
4 
5    Red Hat Authors:
6    Hans de Goede <hdegoede@redhat.com>
7 
8    This library is free software; you can redistribute it and/or
9    modify it under the terms of the GNU Lesser General Public
10    License as published by the Free Software Foundation; either
11    version 2.1 of the License, or (at your option) any later version.
12 
13    This library is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16    Lesser General Public License for more details.
17 
18    You should have received a copy of the GNU Lesser General Public
19    License along with this library; if not, see <http://www.gnu.org/licenses/>.
20 */
21 #ifndef __SPICE_CLIENT_USBREDIR_CHANNEL_PRIV_H__
22 #define __SPICE_CLIENT_USBREDIR_CHANNEL_PRIV_H__
23 
24 #ifdef USE_USBREDIR
25 
26 #include <libusb.h>
27 #include <usbredirfilter.h>
28 #include "spice-client.h"
29 
30 G_BEGIN_DECLS
31 
32 /* Note: this must be called before calling any other functions, and the
33    context should not be destroyed before the last device has been
34    disconnected */
35 void spice_usbredir_channel_set_context(SpiceUsbredirChannel *channel,
36                                         libusb_context       *context);
37 
38 void spice_usbredir_channel_disconnect_device_async(SpiceUsbredirChannel *channel,
39                                                     GCancellable *cancellable,
40                                                     GAsyncReadyCallback callback,
41                                                     gpointer user_data);
42 
43 gboolean spice_usbredir_channel_disconnect_device_finish(SpiceUsbredirChannel *channel,
44                                                          GAsyncResult         *res,
45                                                          GError              **err);
46 
47 /* Note the context must be set, and the channel must be brought up
48    (through spice_channel_connect()), before calling this. */
49 void spice_usbredir_channel_connect_device_async(
50                                         SpiceUsbredirChannel *channel,
51                                         libusb_device        *device,
52                                         SpiceUsbDevice       *spice_device,
53                                         GCancellable         *cancellable,
54                                         GAsyncReadyCallback   callback,
55                                         gpointer              user_data);
56 gboolean spice_usbredir_channel_connect_device_finish(
57                                         SpiceUsbredirChannel *channel,
58                                         GAsyncResult         *res,
59                                         GError              **err);
60 
61 void spice_usbredir_channel_disconnect_device(SpiceUsbredirChannel *channel);
62 
63 libusb_device *spice_usbredir_channel_get_device(SpiceUsbredirChannel *channel);
64 
65 void spice_usbredir_channel_lock(SpiceUsbredirChannel *channel);
66 
67 void spice_usbredir_channel_unlock(SpiceUsbredirChannel *channel);
68 
69 void spice_usbredir_channel_get_guest_filter(
70                           SpiceUsbredirChannel               *channel,
71                           const struct usbredirfilter_rule  **rules_ret,
72                           int                                *rules_count_ret);
73 
74 G_END_DECLS
75 
76 #endif /* USE_USBREDIR */
77 
78 #endif /* __SPICE_CLIENT_USBREDIR_CHANNEL_PRIV_H__ */
79