00001 #ifndef VIDEO_SCANNER_H
00002 #define VIDEO_SCANNER_H
00003
00004 #include <set>
00005 #include <map>
00006 #include <vector>
00007
00008 #include <QObject>
00009 #include <QStringList>
00010 #include <QEvent>
00011
00012 #include "mythmetaexp.h"
00013 #include "mthread.h"
00014
00015 class QStringList;
00016
00017 class MythUIProgressDialog;
00018
00019 class VideoMetadataListManager;
00020
00021 class META_PUBLIC VideoScanner : public QObject
00022 {
00023 Q_OBJECT
00024
00025 public:
00026 VideoScanner();
00027 ~VideoScanner();
00028
00029 void doScan(const QStringList &dirs);
00030 void doScanAll(void);
00031
00032 signals:
00033 void finished(bool);
00034
00035 public slots:
00036 void finishedScan();
00037
00038 private:
00039 class VideoScannerThread *m_scanThread;
00040 bool m_cancel;
00041 };
00042
00043 class META_PUBLIC VideoScanChanges : public QEvent
00044 {
00045 public:
00046 VideoScanChanges(QList<int> adds, QList<int> movs,
00047 QList<int>dels) : QEvent(kEventType),
00048 additions(adds), moved(movs),
00049 deleted(dels) {}
00050 ~VideoScanChanges() {}
00051
00052 QList<int> additions;
00053 QList<int> moved;
00054 QList<int> deleted;
00055
00056 static Type kEventType;
00057 };
00058
00059 class META_PUBLIC VideoScannerThread : public MThread
00060 {
00061 public:
00062 VideoScannerThread(QObject *parent);
00063 ~VideoScannerThread();
00064
00065 void run();
00066 void SetDirs(QStringList dirs);
00067 void SetHosts(const QStringList &hosts);
00068 void SetProgressDialog(MythUIProgressDialog *dialog) { m_dialog = dialog; };
00069 QStringList GetOfflineSGHosts(void) { return m_offlineSGHosts; };
00070 bool getDataChanged() { return m_DBDataChanged; };
00071
00072 void ResetCounts() { m_addList.clear(); m_movList.clear(); m_delList.clear(); };
00073
00074 private:
00075
00076 struct CheckStruct
00077 {
00078 bool check;
00079 QString host;
00080 };
00081
00082 typedef std::vector<std::pair<unsigned int, QString> > PurgeList;
00083 typedef std::map<QString, CheckStruct> FileCheckList;
00084
00085 void removeOrphans(unsigned int id, const QString &filename);
00086
00087 void verifyFiles(FileCheckList &files, PurgeList &remove);
00088 bool updateDB(const FileCheckList &add, const PurgeList &remove);
00089 bool buildFileList(const QString &directory,
00090 const QStringList &imageExtensions,
00091 FileCheckList &filelist);
00092
00093 void SendProgressEvent(uint progress, uint total = 0,
00094 QString messsage = QString());
00095
00096 QObject *m_parent;
00097
00098 bool m_ListUnknown;
00099 bool m_RemoveAll;
00100 bool m_KeepAll;
00101 bool m_HasGUI;
00102 QStringList m_directories;
00103 QStringList m_liveSGHosts;
00104 QStringList m_offlineSGHosts;
00105
00106 VideoMetadataListManager *m_dbmetadata;
00107 MythUIProgressDialog *m_dialog;
00108
00109 QList<int> m_addList;
00110 QList<int> m_movList;
00111 QList<int> m_delList;
00112 bool m_DBDataChanged;
00113 };
00114
00115 #endif