| 1 | #ifndef SRC_SQL_EPGDB_H_ |
| 2 | #define SRC_SQL_EPGDB_H_ |
| 3 | |
| 4 | #include "SQLConnection.h" |
| 5 | #include <list> |
| 6 | |
| 7 | struct EpgDBInfo |
| 8 | { |
| 9 | int programId = 0; |
| 10 | time_t recordUntil = 0; |
| 11 | time_t replayUntil = 0; |
| 12 | time_t restartUntil = 0; |
| 13 | time_t startTime = 0; |
| 14 | time_t endTime = 0; |
| 15 | bool detailsLoaded = false; |
| 16 | std::string genre; |
| 17 | std::string title; |
| 18 | std::string subtitle; |
| 19 | std::string description; |
| 20 | int season = -1; |
| 21 | int episode = -1; |
| 22 | std::string imageToken; |
| 23 | std::string cid; |
| 24 | }; |
| 25 | |
| 26 | class EpgDB : public SQLConnection |
| 27 | { |
| 28 | public: |
| 29 | EpgDB(std::string folder); |
| 30 | ~EpgDB(); |
| 31 | bool Insert(EpgDBInfo &epgDBInfo); |
| 32 | bool Update(EpgDBInfo &epgDBInfo); |
| 33 | EpgDBInfo Get(int programId); |
| 34 | std::list<EpgDBInfo> GetWithWhere(std::string where); |
| 35 | private: |
| 36 | bool MigrateDbIfRequired(); |
| 37 | bool Migrate0To1(); |
| 38 | bool Migrate1To2(); |
| 39 | bool Migrate2To3(); |
| 40 | void Cleanup(); |
| 41 | time_t m_nextCleanupDue = 0; |
| 42 | sqlite3_stmt *m_prepareInsertStatement; |
| 43 | sqlite3_stmt *m_prepareUpdateStatement; |
| 44 | }; |
| 45 | |
| 46 | #endif /* SRC_SQL_EPGDB_H_ */ |