/*! * * 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" #include "threads.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 QThread *_thread = nullptr; bool _init = false; // Singleton SINGLETON(USBWatcher) public slots: bool init(); bool init(QThread &vThread); private slots: void quit(); protected: void timerEvent(QTimerEvent *) override; private: void initConnections(); void initThread(QThread &vThread); void quitThread(); bool usbSeek(QString &vDevice); 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(); }; }