DeviceWatcher.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef DEVICEWATCHER_H
  2. #define DEVICEWATCHER_H
  3. #include "MultimediaService.h"
  4. #include <QCoreApplication>
  5. #include "DiskDeviceWatcher/DiskDeviceWatcher.h"
  6. #include "DiskScanner/DiskScanner.h"
  7. #include <QObject>
  8. #include <QProcess>
  9. #include <QScopedPointer>
  10. class DeviceWatcherPrivate;
  11. class DeviceWatcher : public QObject
  12. {
  13. Q_OBJECT
  14. Q_DISABLE_COPY(DeviceWatcher)
  15. #ifdef g_DeviceWatcher
  16. #undef g_DeviceWatcher
  17. #endif
  18. #define g_DeviceWatcher (DeviceWatcher::instance())
  19. public:
  20. inline static DeviceWatcher* instance() {
  21. static DeviceWatcher* deviceWatcher(new DeviceWatcher(qApp));
  22. return deviceWatcher;
  23. }
  24. void synchronize();
  25. void deviceWatcherCheckStatus(const int type);
  26. void stopUsbScanner();
  27. void stopSdScanner();
  28. void multimediaServiceStart();
  29. void onDiskDeviceChangeHandler(const QString &device, const DiskDeviceWatcher::Action action);
  30. QString getUsbDiskPath();
  31. signals:
  32. void onDeviceWatcherStatus(const int type, const int status);
  33. void onMusicFilePath(const QString &path, const int type);
  34. void onImageFilePath(const QString &path, const int type);
  35. void onVideoFilePath(const QString &path, const int type);
  36. protected:
  37. void timerEvent(QTimerEvent* event);
  38. private slots:
  39. void onDiskDeviceChange(const QString &device, const DiskDeviceWatcher::Action action);
  40. void onUSBFilePath(const QString &path, const int index);
  41. void onSDFilePath(const QString &path, const int index);
  42. void onFinish();
  43. private:
  44. explicit DeviceWatcher(QObject *parent = NULL);
  45. ~DeviceWatcher();
  46. friend class DeviceWatcherPrivate;
  47. QScopedPointer<DeviceWatcherPrivate> m_Private;
  48. };
  49. #endif // DEVICEWATCHER_H