hemerausbgadgetmanager.h
1 #ifndef HEMERA_USBGADGETMANAGER_H
2 #define HEMERA_USBGADGETMANAGER_H
3 
4 #include <HemeraCore/AsyncInitObject>
5 #include <HemeraCore/Global>
6 
7 namespace Hemera {
8 
9 class Operation;
10 
11 class USBGadgetManagerPrivate;
12 
42 class HEMERA_QT5_SDK_EXPORT USBGadgetManager : public Hemera::AsyncInitObject
43 {
44  Q_OBJECT
45  Q_DISABLE_COPY(USBGadgetManager)
46  Q_DECLARE_PRIVATE_D(d_h_ptr, USBGadgetManager)
47 
48  Q_PROPERTY(Mode activeMode READ activeMode NOTIFY activeModeChanged)
49  Q_PROPERTY(Modes availableModes READ availableModes)
50  Q_PROPERTY(bool canDetectCableHotplugging READ canDetectCableHotplugging)
51  Q_PROPERTY(USBCableStatus usbCableStatus READ usbCableStatus NOTIFY usbCableStatusChanged)
52  Q_PROPERTY(bool systemWideLockActive READ isSystemWideLockActive NOTIFY systemWideLockChanged)
53  Q_PROPERTY(QString systemWideLockOwner READ systemWideLockOwner NOTIFY systemWideLockChanged)
54  Q_PROPERTY(QString systemWideLockReason READ systemWideLockReason NOTIFY systemWideLockChanged)
55 
56 public:
58  enum class Mode {
60  None = 0,
62  EthernetTethering,
64  EthernetP2P,
66  MassStorage
67  };
68  Q_ENUMS(Mode)
69  Q_DECLARE_FLAGS(Modes, Mode)
70 
72  enum class USBCableStatus {
74  Unknown = 0,
76  Unplugged,
78  Plugged
79  };
80  Q_ENUMS(USBCableStatus)
81 
82 
83  explicit USBGadgetManager(QObject* parent);
85  virtual ~USBGadgetManager();
86 
97  Modes availableModes() const;
101  Mode activeMode() const;
102 
117  bool canDetectCableHotplugging() const;
126  USBCableStatus usbCableStatus() const;
127 
131  bool isSystemWideLockActive() const;
135  QString systemWideLockOwner() const;
139  QString systemWideLockReason() const;
140 
152  Operation *acquireSystemWideLock(const QString &reason = QString());
163  Operation *releaseSystemWideLock();
164 
180  Operation *activate(Mode mode, const QVariantMap &arguments = QVariantMap());
196  Operation *deactivate();
197 
198 Q_SIGNALS:
204  void activeModeChanged(Hemera::USBGadgetManager::Mode mode);
210  void systemWideLockChanged(bool active);
211 
217  void usbCableStatusChanged(Hemera::USBGadgetManager::USBCableStatus status);
218 
219 protected:
220  virtual void initImpl() Q_DECL_OVERRIDE Q_DECL_FINAL;
221 };
222 }
223 
224 Q_DECLARE_OPERATORS_FOR_FLAGS(Hemera::USBGadgetManager::Modes)
225 
226 #endif // HEMERA_USBGADGETMANAGER_H
Mode
The various modes in which a USB Gadget can be activated.
Definition: hemerausbgadgetmanager.h:58
Definition: hemeraqmlappliance.cpp:3
A pending asynchronous operation.
Definition: hemeraoperation.h:33
An asynchronous object performing a late initialization.
Definition: hemeraasyncinitobject.h:34
Provides access to USB Gadget (OTG) support, allowing to control the USB OTG behavior on the system...
Definition: hemerausbgadgetmanager.h:42
USBCableStatus
Status of the USB Cable.
Definition: hemerausbgadgetmanager.h:72