patchinstaller.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. struct AppliedPatchesInfo {
  17. bool patched_by_old_legacy = false;
  18. bool has_no_patch_mark = false;
  19. QString texts_patch_hashsum = "";
  20. QString images_patch_hashsum = "";
  21. QString sounds_patch_hashsum = "";
  22. QString loadscreens_patch_hashsum = "";
  23. QString textures_patch_hashsum = "";
  24. QString fonts_patch_hashsum = "";
  25. QString videos_patch_hashsum = "";
  26. };
  27. public:
  28. static PatchInstaller& instance() {
  29. static PatchInstaller instance_;
  30. return instance_;
  31. }
  32. bool initialised();
  33. ~PatchInstaller();
  34. AppliedPatchesInfo getPatchesInfo(); // TODO: Implement
  35. private:
  36. Q_DISABLE_COPY(PatchInstaller)
  37. enum RESOURCE_FILE_TYPE : int {
  38. E_CLIENT_LOCAL = 0,
  39. E_CLIENT_GENERAL = 1
  40. };
  41. explicit PatchInstaller(QObject *parent = nullptr);
  42. bool datPathIsRelevant();
  43. void installPatch(QString patch_name, LOTRO_DAT::Database* database);
  44. void installLoadscreens(LOTRO_DAT::Database* database);
  45. void installVideos(LOTRO_DAT::Database* database);
  46. AppliedPatchesInfo getAppliedPatchesInfoFromDatFile();
  47. void insertPatchesInfoInDatFile(const AppliedPatchesInfo& info);
  48. public slots:
  49. void deinit();
  50. void init();
  51. void startGame(bool freeze_updates);
  52. void startPatchInstallationChain();
  53. private slots:
  54. void onDownloaderProgressChanged(Downloader* context, Downloader::Status progress);
  55. signals:
  56. void started();
  57. void progressChanged(PatchInstaller::Status status);
  58. void videosDownloadProgressChanged(int finished_videos, int total_videos, Downloader::Status status);
  59. void finished();
  60. void successfullyInitialized();
  61. void deinitialized();
  62. private:
  63. LOTRO_DAT::DatFile* client_local_file_;
  64. LOTRO_DAT::DatFile* client_general_file_;
  65. QSqlDatabase orig_files_db;
  66. const QString create_table_query = "CREATE TABLE IF NOT EXISTS `patch_data` "
  67. "(`file_id` INTEGER PRIMARY KEY,"
  68. "`binary_data` BLOB, "
  69. "`text_data` TEXT, "
  70. "`options` TEXT NOT NULL)";
  71. // const QString upset_table_value_query = "INSERT INTO `patch_data` (`file_id`, ``) VALUES (?);";
  72. AppliedPatchesInfo _current_applied_patches_info;
  73. Status current_status;
  74. const QString _patch_mark_header = "HI_FROM_ENDEVIR_V2.0";
  75. const int _applied_patches_file_id = 0x23F4F0F0;
  76. const int _patch_files_versions = 721359;
  77. int download_video_finished_videos = 0;
  78. int download_video_total_videos = 0;
  79. };
  80. Q_DECLARE_METATYPE(PatchInstaller::Status)
  81. #endif // LEGACYAPP_H