patchinstaller.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #ifndef LEGACYAPP_H
  2. #define LEGACYAPP_H
  3. #include <QObject>
  4. #include <QSqlDatabase>
  5. #include "models/downloader.h"
  6. #include <LotroDat/datfile.h>
  7. #include <LotroDat/database.h>
  8. class PatchInstaller : public QObject
  9. {
  10. Q_OBJECT
  11. public:
  12. struct Status {
  13. size_t total_parts = 0;
  14. size_t finished_parts = 0;
  15. };
  16. public:
  17. static PatchInstaller& instance() {
  18. static PatchInstaller instance_;
  19. return instance_;
  20. }
  21. bool initialised();
  22. ~PatchInstaller();
  23. // TODO: bool NotPatched();
  24. private:
  25. Q_DISABLE_COPY(PatchInstaller)
  26. enum RESOURCE_FILE_TYPE : int {
  27. E_CLIENT_LOCAL = 0,
  28. E_CLIENT_GENERAL = 1
  29. };
  30. explicit PatchInstaller(QObject *parent = nullptr);
  31. bool datPathIsRelevant();
  32. void deinit();
  33. void installPatch(QString patch_name, LOTRO_DAT::Database* database);
  34. void installLoadscreens(LOTRO_DAT::Database* database);
  35. void installVideos(LOTRO_DAT::Database* database);
  36. public slots:
  37. void init();
  38. void startGame(bool freeze_updates);
  39. void startPatchInstallationChain();
  40. private slots:
  41. void onDownloaderProgressChanged(Downloader* context, Downloader::Status progress);
  42. signals:
  43. void started();
  44. void progressChanged(PatchInstaller::Status status);
  45. void videosDownloadProgressChanged(int finished_videos, int total_videos, Downloader::Status status);
  46. void finished();
  47. void successfullyInitialized();
  48. void deinitialized();
  49. private:
  50. LOTRO_DAT::DatFile* client_local_file_;
  51. LOTRO_DAT::DatFile* client_general_file_;
  52. QSqlDatabase orig_files_db;
  53. const QString create_table_query = "CREATE TABLE IF NOT EXISTS `patch_data` "
  54. "(`file_id` INTEGER PRIMARY KEY,"
  55. "`binary_data` BLOB, "
  56. "`text_data` TEXT, "
  57. "`options` TEXT NOT NULL)";
  58. // const QString upset_table_value_query = "INSERT INTO `patch_data` (`file_id`, ``) VALUES (?);";
  59. Status current_status;
  60. int download_video_finished_videos = 0;
  61. int download_video_total_videos = 0;
  62. };
  63. Q_DECLARE_METATYPE(PatchInstaller::Status)
  64. #endif // LEGACYAPP_H