00001 #ifndef HOUSEKEEPER_H_ 00002 #define HOUSEKEEPER_H_ 00003 00004 #include <QWaitCondition> 00005 #include <QDateTime> 00006 #include <QMutex> 00007 00008 #include "mthread.h" 00009 00010 class Scheduler; 00011 class QString; 00012 class HouseKeeper; 00013 class MythSystem; 00014 00015 class HouseKeepingThread : public MThread 00016 { 00017 public: 00018 HouseKeepingThread(HouseKeeper *p) : 00019 MThread("HouseKeeping"), m_parent(p) {} 00020 ~HouseKeepingThread() { wait(); } 00021 virtual void run(void); 00022 private: 00023 HouseKeeper *m_parent; 00024 }; 00025 00026 class MythFillDatabaseThread : public MThread 00027 { 00028 public: 00029 MythFillDatabaseThread(HouseKeeper *p) : 00030 MThread("MythFillDB"), m_parent(p) {} 00031 ~MythFillDatabaseThread() { wait(); } 00032 static void setTerminationEnabled(bool v) 00033 { MThread::setTerminationEnabled(v); } 00034 virtual void run(void); 00035 private: 00036 HouseKeeper *m_parent; 00037 }; 00038 00039 class HouseKeeper 00040 { 00041 friend class HouseKeepingThread; 00042 friend class MythFillDatabaseThread; 00043 public: 00044 HouseKeeper(bool runthread, bool master, Scheduler *lsched = NULL); 00045 ~HouseKeeper(); 00046 00047 protected: 00048 void RunHouseKeeping(void); 00049 void RunMFD(void); 00050 00051 private: 00052 00053 bool wantToRun(const QString &dbTag, int period, int minhour, int maxhour, 00054 bool nowIfPossible = false); 00055 void updateLastrun(const QString &dbTag); 00056 QDateTime getLastRun(const QString &dbTag); 00057 void flushDBLogs(); 00058 void StartMFD(void); 00059 void KillMFD(void); 00060 void CleanupMyOldRecordings(void); 00061 void CleanupAllOldInUsePrograms(void); 00062 void CleanupOrphanedLivetvChains(void); 00063 void CleanupRecordedTables(void); 00064 void CleanupProgramListings(void); 00065 void RunStartupTasks(void); 00066 void UpdateThemeChooserInfoCache(void); 00067 void UpdateRecordedArtwork(void); 00068 00069 private: 00070 bool isMaster; 00071 Scheduler *sched; 00072 00073 QMutex houseKeepingLock; 00074 QWaitCondition houseKeepingWait; // protected by houseKeepingLock 00075 bool houseKeepingRun; // protected by houseKeepingLock 00076 HouseKeepingThread *houseKeepingThread;// protected by houseKeepingLock 00077 00078 QMutex fillDBLock; 00079 QWaitCondition fillDBWait; // protected by fillDBLock 00080 MythFillDatabaseThread *fillDBThread; // Only mod in HouseKeepingThread 00081 bool fillDBStarted; // protected by fillDBLock 00082 MythSystem *fillDBMythSystem; // protected by fillDBLock 00083 }; 00084 00085 #endif
1.6.3