patchinstaller.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. private:
  48. LOTRO_DAT::DatFile* client_local_file_;
  49. LOTRO_DAT::DatFile* client_general_file_;
  50. QSqlDatabase orig_files_db;
  51. const QString create_table_query = "CREATE TABLE IF NOT EXISTS `patch_data` "
  52. "(`file_id` INTEGER PRIMARY KEY,"
  53. "`binary_data` BLOB, "
  54. "`text_data` TEXT, "
  55. "`options` TEXT NOT NULL)";
  56. // const QString upset_table_value_query = "INSERT INTO `patch_data` (`file_id`, ``) VALUES (?);";
  57. Status current_status;
  58. int download_video_finished_videos = 0;
  59. int download_video_total_videos = 0;
  60. };
  61. Q_DECLARE_METATYPE(PatchInstaller::Status)
  62. #endif // LEGACYAPP_H