/*! * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * copyright * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, * IN PART OR IN WHOLE, * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * file usbwatcher.h * date 12/31/2019 * author Behrouz NematiPour * */ #pragma once // Qt #include // Project #include "main.h" // Define #define _USBWatcher Storage::USBWatcher::I() namespace Storage { class USBWatcher : public QObject { Q_OBJECT bool _mounted = false; bool _umounted = false; bool _removed = false; const char *_usbDrive = ""; const int _checkInterval = 1000; // in ms // Singleton SINGLETON(USBWatcher) public: bool init(); void quit(); protected: void timerEvent(QTimerEvent *) override; private: void initConnections(); bool usbSeek(QString &vDevice); bool isMounted () const; bool isUmounted() const; signals: void didUSBDriveMount (); void didUSBDriveUmount(); void didUSBDriveRemove(); private slots: void usbcheck (); bool usbMount (const QString &vDevice); bool usbUmount(const QString &vDevice); void usbRemove(); void usbError (const QString &vDevice); void onUSBDriveUmount(); }; }