From b6d455a02bd338e9dc0faa09d4d8177ecd8d569a Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Sun, 10 Apr 2016 15:53:05 +0200 Subject: NOISSUE reorganize and document libraries --- api/logic/AbstractCommonModel.cpp | 133 +++++ api/logic/AbstractCommonModel.h | 462 ++++++++++++++++ api/logic/BaseConfigObject.cpp | 103 ++++ api/logic/BaseConfigObject.h | 50 ++ api/logic/BaseInstaller.cpp | 61 ++ api/logic/BaseInstaller.h | 46 ++ api/logic/BaseInstance.cpp | 270 +++++++++ api/logic/BaseInstance.h | 243 ++++++++ api/logic/BaseVersion.h | 59 ++ api/logic/BaseVersionList.cpp | 104 ++++ api/logic/BaseVersionList.h | 126 +++++ api/logic/CMakeLists.txt | 344 ++++++++++++ api/logic/Commandline.cpp | 483 ++++++++++++++++ api/logic/Commandline.h | 252 +++++++++ api/logic/DefaultVariable.h | 35 ++ api/logic/Env.cpp | 222 ++++++++ api/logic/Env.h | 60 ++ api/logic/Exception.h | 34 ++ api/logic/FileSystem.cpp | 436 +++++++++++++++ api/logic/FileSystem.h | 123 ++++ api/logic/GZip.cpp | 115 ++++ api/logic/GZip.h | 12 + api/logic/InstanceList.cpp | 580 +++++++++++++++++++ api/logic/InstanceList.h | 187 +++++++ api/logic/Json.cpp | 272 +++++++++ api/logic/Json.h | 249 +++++++++ api/logic/MMCStrings.cpp | 76 +++ api/logic/MMCStrings.h | 10 + api/logic/MMCZip.cpp | 491 ++++++++++++++++ api/logic/MMCZip.h | 88 +++ api/logic/NullInstance.h | 90 +++ api/logic/QObjectPtr.h | 78 +++ api/logic/RWStorage.h | 60 ++ api/logic/RecursiveFileSystemWatcher.cpp | 111 ++++ api/logic/RecursiveFileSystemWatcher.h | 63 +++ api/logic/SeparatorPrefixTree.h | 298 ++++++++++ api/logic/TypeMagic.h | 37 ++ api/logic/Version.cpp | 140 +++++ api/logic/Version.h | 110 ++++ api/logic/java/JavaChecker.cpp | 159 ++++++ api/logic/java/JavaChecker.h | 54 ++ api/logic/java/JavaCheckerJob.cpp | 45 ++ api/logic/java/JavaCheckerJob.h | 84 +++ api/logic/java/JavaInstall.cpp | 28 + api/logic/java/JavaInstall.h | 38 ++ api/logic/java/JavaInstallList.cpp | 186 +++++++ api/logic/java/JavaInstallList.h | 71 +++ api/logic/java/JavaUtils.cpp | 219 ++++++++ api/logic/java/JavaUtils.h | 43 ++ api/logic/java/JavaVersion.cpp | 112 ++++ api/logic/java/JavaVersion.h | 30 + api/logic/launch/LaunchStep.cpp | 27 + api/logic/launch/LaunchStep.h | 48 ++ api/logic/launch/LaunchTask.cpp | 228 ++++++++ api/logic/launch/LaunchTask.h | 122 ++++ api/logic/launch/LoggedProcess.cpp | 163 ++++++ api/logic/launch/LoggedProcess.h | 76 +++ api/logic/launch/MessageLevel.cpp | 36 ++ api/logic/launch/MessageLevel.h | 28 + api/logic/launch/steps/CheckJava.cpp | 92 +++ api/logic/launch/steps/CheckJava.h | 41 ++ api/logic/launch/steps/LaunchMinecraft.cpp | 155 ++++++ api/logic/launch/steps/LaunchMinecraft.h | 48 ++ api/logic/launch/steps/ModMinecraftJar.cpp | 44 ++ api/logic/launch/steps/ModMinecraftJar.h | 39 ++ api/logic/launch/steps/PostLaunchCommand.cpp | 84 +++ api/logic/launch/steps/PostLaunchCommand.h | 39 ++ api/logic/launch/steps/PreLaunchCommand.cpp | 85 +++ api/logic/launch/steps/PreLaunchCommand.h | 39 ++ api/logic/launch/steps/TextPrint.cpp | 29 + api/logic/launch/steps/TextPrint.h | 43 ++ api/logic/launch/steps/Update.cpp | 50 ++ api/logic/launch/steps/Update.h | 41 ++ api/logic/minecraft/AssetsUtils.cpp | 230 ++++++++ api/logic/minecraft/AssetsUtils.h | 48 ++ api/logic/minecraft/GradleSpecifier.h | 129 +++++ api/logic/minecraft/JarMod.h | 12 + api/logic/minecraft/Library.cpp | 239 ++++++++ api/logic/minecraft/Library.h | 184 ++++++ api/logic/minecraft/MinecraftInstance.cpp | 369 ++++++++++++ api/logic/minecraft/MinecraftInstance.h | 69 +++ api/logic/minecraft/MinecraftProfile.cpp | 610 ++++++++++++++++++++ api/logic/minecraft/MinecraftProfile.h | 200 +++++++ api/logic/minecraft/MinecraftVersion.cpp | 215 +++++++ api/logic/minecraft/MinecraftVersion.h | 119 ++++ api/logic/minecraft/MinecraftVersionList.cpp | 591 ++++++++++++++++++++ api/logic/minecraft/MinecraftVersionList.h | 72 +++ api/logic/minecraft/Mod.cpp | 377 +++++++++++++ api/logic/minecraft/Mod.h | 134 +++++ api/logic/minecraft/ModList.cpp | 616 +++++++++++++++++++++ api/logic/minecraft/ModList.h | 160 ++++++ api/logic/minecraft/MojangDownloadInfo.h | 71 +++ api/logic/minecraft/MojangVersionFormat.cpp | 381 +++++++++++++ api/logic/minecraft/MojangVersionFormat.h | 25 + api/logic/minecraft/OpSys.cpp | 42 ++ api/logic/minecraft/OpSys.h | 37 ++ api/logic/minecraft/ParseUtils.cpp | 34 ++ api/logic/minecraft/ParseUtils.h | 11 + api/logic/minecraft/ProfilePatch.h | 104 ++++ api/logic/minecraft/ProfileStrategy.h | 35 ++ api/logic/minecraft/ProfileUtils.cpp | 191 +++++++ api/logic/minecraft/ProfileUtils.h | 25 + api/logic/minecraft/Rule.cpp | 93 ++++ api/logic/minecraft/Rule.h | 101 ++++ api/logic/minecraft/VersionBuildError.h | 58 ++ api/logic/minecraft/VersionFile.cpp | 60 ++ api/logic/minecraft/VersionFile.h | 195 +++++++ api/logic/minecraft/VersionFilterData.cpp | 75 +++ api/logic/minecraft/VersionFilterData.h | 32 ++ api/logic/minecraft/World.cpp | 385 +++++++++++++ api/logic/minecraft/World.h | 83 +++ api/logic/minecraft/WorldList.cpp | 355 ++++++++++++ api/logic/minecraft/WorldList.h | 125 +++++ api/logic/minecraft/auth/AuthSession.cpp | 30 + api/logic/minecraft/auth/AuthSession.h | 51 ++ api/logic/minecraft/auth/MojangAccount.cpp | 278 ++++++++++ api/logic/minecraft/auth/MojangAccount.h | 173 ++++++ api/logic/minecraft/auth/MojangAccountList.cpp | 427 ++++++++++++++ api/logic/minecraft/auth/MojangAccountList.h | 201 +++++++ api/logic/minecraft/auth/YggdrasilTask.cpp | 255 +++++++++ api/logic/minecraft/auth/YggdrasilTask.h | 150 +++++ .../minecraft/auth/flows/AuthenticateTask.cpp | 202 +++++++ api/logic/minecraft/auth/flows/AuthenticateTask.h | 46 ++ api/logic/minecraft/auth/flows/RefreshTask.cpp | 144 +++++ api/logic/minecraft/auth/flows/RefreshTask.h | 44 ++ api/logic/minecraft/auth/flows/ValidateTask.cpp | 61 ++ api/logic/minecraft/auth/flows/ValidateTask.h | 47 ++ api/logic/minecraft/forge/ForgeInstaller.cpp | 458 +++++++++++++++ api/logic/minecraft/forge/ForgeInstaller.h | 52 ++ api/logic/minecraft/forge/ForgeVersion.cpp | 55 ++ api/logic/minecraft/forge/ForgeVersion.h | 42 ++ api/logic/minecraft/forge/ForgeVersionList.cpp | 450 +++++++++++++++ api/logic/minecraft/forge/ForgeVersionList.h | 90 +++ api/logic/minecraft/forge/ForgeXzDownload.cpp | 358 ++++++++++++ api/logic/minecraft/forge/ForgeXzDownload.h | 59 ++ api/logic/minecraft/forge/LegacyForge.cpp | 56 ++ api/logic/minecraft/forge/LegacyForge.h | 25 + api/logic/minecraft/ftb/FTBPlugin.cpp | 395 +++++++++++++ api/logic/minecraft/ftb/FTBPlugin.h | 13 + api/logic/minecraft/ftb/FTBProfileStrategy.cpp | 128 +++++ api/logic/minecraft/ftb/FTBProfileStrategy.h | 21 + api/logic/minecraft/ftb/FTBVersion.h | 32 ++ api/logic/minecraft/ftb/LegacyFTBInstance.cpp | 27 + api/logic/minecraft/ftb/LegacyFTBInstance.h | 17 + api/logic/minecraft/ftb/OneSixFTBInstance.cpp | 138 +++++ api/logic/minecraft/ftb/OneSixFTBInstance.h | 30 + api/logic/minecraft/legacy/LegacyInstance.cpp | 453 +++++++++++++++ api/logic/minecraft/legacy/LegacyInstance.h | 142 +++++ api/logic/minecraft/legacy/LegacyUpdate.cpp | 393 +++++++++++++ api/logic/minecraft/legacy/LegacyUpdate.h | 70 +++ api/logic/minecraft/legacy/LwjglVersionList.cpp | 189 +++++++ api/logic/minecraft/legacy/LwjglVersionList.h | 156 ++++++ .../minecraft/liteloader/LiteLoaderInstaller.cpp | 142 +++++ .../minecraft/liteloader/LiteLoaderInstaller.h | 39 ++ .../minecraft/liteloader/LiteLoaderVersionList.cpp | 276 +++++++++ .../minecraft/liteloader/LiteLoaderVersionList.h | 119 ++++ api/logic/minecraft/onesix/OneSixInstance.cpp | 597 ++++++++++++++++++++ api/logic/minecraft/onesix/OneSixInstance.h | 117 ++++ .../minecraft/onesix/OneSixProfileStrategy.cpp | 418 ++++++++++++++ api/logic/minecraft/onesix/OneSixProfileStrategy.h | 26 + api/logic/minecraft/onesix/OneSixUpdate.cpp | 342 ++++++++++++ api/logic/minecraft/onesix/OneSixUpdate.h | 67 +++ api/logic/minecraft/onesix/OneSixVersionFormat.cpp | 225 ++++++++ api/logic/minecraft/onesix/OneSixVersionFormat.h | 22 + api/logic/net/ByteArrayDownload.cpp | 105 ++++ api/logic/net/ByteArrayDownload.h | 48 ++ api/logic/net/CacheDownload.cpp | 192 +++++++ api/logic/net/CacheDownload.h | 63 +++ api/logic/net/HttpMetaCache.cpp | 273 +++++++++ api/logic/net/HttpMetaCache.h | 125 +++++ api/logic/net/MD5EtagDownload.cpp | 155 ++++++ api/logic/net/MD5EtagDownload.h | 52 ++ api/logic/net/NetAction.h | 96 ++++ api/logic/net/NetJob.cpp | 125 +++++ api/logic/net/NetJob.h | 117 ++++ api/logic/net/PasteUpload.cpp | 99 ++++ api/logic/net/PasteUpload.h | 50 ++ api/logic/net/URLConstants.cpp | 16 + api/logic/net/URLConstants.h | 40 ++ api/logic/news/NewsChecker.cpp | 135 +++++ api/logic/news/NewsChecker.h | 107 ++++ api/logic/news/NewsEntry.cpp | 77 +++ api/logic/news/NewsEntry.h | 65 +++ api/logic/notifications/NotificationChecker.cpp | 130 +++++ api/logic/notifications/NotificationChecker.h | 63 +++ api/logic/pathmatcher/FSTreeMatcher.h | 21 + api/logic/pathmatcher/IPathMatcher.h | 12 + api/logic/pathmatcher/MultiMatcher.h | 31 ++ api/logic/pathmatcher/RegexpMatcher.h | 42 ++ api/logic/resources/Resource.cpp | 155 ++++++ api/logic/resources/Resource.h | 132 +++++ api/logic/resources/ResourceHandler.cpp | 28 + api/logic/resources/ResourceHandler.h | 36 ++ api/logic/resources/ResourceObserver.cpp | 55 ++ api/logic/resources/ResourceObserver.h | 73 +++ api/logic/resources/ResourceProxyModel.cpp | 89 +++ api/logic/resources/ResourceProxyModel.h | 39 ++ api/logic/screenshots/ImgurAlbumCreation.cpp | 90 +++ api/logic/screenshots/ImgurAlbumCreation.h | 44 ++ api/logic/screenshots/ImgurUpload.cpp | 114 ++++ api/logic/screenshots/ImgurUpload.h | 33 ++ api/logic/screenshots/Screenshot.h | 19 + api/logic/settings/INIFile.cpp | 151 +++++ api/logic/settings/INIFile.h | 38 ++ api/logic/settings/INISettingsObject.cpp | 107 ++++ api/logic/settings/INISettingsObject.h | 66 +++ api/logic/settings/OverrideSetting.cpp | 54 ++ api/logic/settings/OverrideSetting.h | 46 ++ api/logic/settings/PassthroughSetting.cpp | 66 +++ api/logic/settings/PassthroughSetting.h | 45 ++ api/logic/settings/Setting.cpp | 53 ++ api/logic/settings/Setting.h | 119 ++++ api/logic/settings/SettingsObject.cpp | 142 +++++ api/logic/settings/SettingsObject.h | 214 +++++++ api/logic/status/StatusChecker.cpp | 153 +++++ api/logic/status/StatusChecker.h | 60 ++ api/logic/tasks/SequentialTask.cpp | 55 ++ api/logic/tasks/SequentialTask.h | 31 ++ api/logic/tasks/Task.cpp | 88 +++ api/logic/tasks/Task.h | 96 ++++ api/logic/tasks/ThreadTask.cpp | 41 ++ api/logic/tasks/ThreadTask.h | 25 + api/logic/tools/BaseExternalTool.cpp | 41 ++ api/logic/tools/BaseExternalTool.h | 60 ++ api/logic/tools/BaseProfiler.cpp | 35 ++ api/logic/tools/BaseProfiler.h | 38 ++ api/logic/tools/JProfiler.cpp | 116 ++++ api/logic/tools/JProfiler.h | 15 + api/logic/tools/JVisualVM.cpp | 103 ++++ api/logic/tools/JVisualVM.h | 15 + api/logic/tools/MCEditTool.cpp | 124 +++++ api/logic/tools/MCEditTool.h | 26 + api/logic/trans/TranslationDownloader.cpp | 53 ++ api/logic/trans/TranslationDownloader.h | 32 ++ api/logic/updater/DownloadTask.cpp | 169 ++++++ api/logic/updater/DownloadTask.h | 95 ++++ api/logic/updater/GoUpdate.cpp | 215 +++++++ api/logic/updater/GoUpdate.h | 133 +++++ api/logic/updater/UpdateChecker.cpp | 269 +++++++++ api/logic/updater/UpdateChecker.h | 121 ++++ api/logic/wonko/BaseWonkoEntity.cpp | 39 ++ api/logic/wonko/BaseWonkoEntity.h | 51 ++ api/logic/wonko/WonkoIndex.cpp | 147 +++++ api/logic/wonko/WonkoIndex.h | 68 +++ api/logic/wonko/WonkoReference.cpp | 44 ++ api/logic/wonko/WonkoReference.h | 41 ++ api/logic/wonko/WonkoUtil.cpp | 47 ++ api/logic/wonko/WonkoUtil.h | 31 ++ api/logic/wonko/WonkoVersion.cpp | 102 ++++ api/logic/wonko/WonkoVersion.h | 83 +++ api/logic/wonko/WonkoVersionList.cpp | 283 ++++++++++ api/logic/wonko/WonkoVersionList.h | 92 +++ api/logic/wonko/format/WonkoFormat.cpp | 80 +++ api/logic/wonko/format/WonkoFormat.h | 54 ++ api/logic/wonko/format/WonkoFormatV1.cpp | 156 ++++++ api/logic/wonko/format/WonkoFormatV1.h | 30 + .../wonko/tasks/BaseWonkoEntityLocalLoadTask.cpp | 117 ++++ .../wonko/tasks/BaseWonkoEntityLocalLoadTask.h | 81 +++ .../wonko/tasks/BaseWonkoEntityRemoteLoadTask.cpp | 126 +++++ .../wonko/tasks/BaseWonkoEntityRemoteLoadTask.h | 85 +++ 260 files changed, 32792 insertions(+) create mode 100644 api/logic/AbstractCommonModel.cpp create mode 100644 api/logic/AbstractCommonModel.h create mode 100644 api/logic/BaseConfigObject.cpp create mode 100644 api/logic/BaseConfigObject.h create mode 100644 api/logic/BaseInstaller.cpp create mode 100644 api/logic/BaseInstaller.h create mode 100644 api/logic/BaseInstance.cpp create mode 100644 api/logic/BaseInstance.h create mode 100644 api/logic/BaseVersion.h create mode 100644 api/logic/BaseVersionList.cpp create mode 100644 api/logic/BaseVersionList.h create mode 100644 api/logic/CMakeLists.txt create mode 100644 api/logic/Commandline.cpp create mode 100644 api/logic/Commandline.h create mode 100644 api/logic/DefaultVariable.h create mode 100644 api/logic/Env.cpp create mode 100644 api/logic/Env.h create mode 100644 api/logic/Exception.h create mode 100644 api/logic/FileSystem.cpp create mode 100644 api/logic/FileSystem.h create mode 100644 api/logic/GZip.cpp create mode 100644 api/logic/GZip.h create mode 100644 api/logic/InstanceList.cpp create mode 100644 api/logic/InstanceList.h create mode 100644 api/logic/Json.cpp create mode 100644 api/logic/Json.h create mode 100644 api/logic/MMCStrings.cpp create mode 100644 api/logic/MMCStrings.h create mode 100644 api/logic/MMCZip.cpp create mode 100644 api/logic/MMCZip.h create mode 100644 api/logic/NullInstance.h create mode 100644 api/logic/QObjectPtr.h create mode 100644 api/logic/RWStorage.h create mode 100644 api/logic/RecursiveFileSystemWatcher.cpp create mode 100644 api/logic/RecursiveFileSystemWatcher.h create mode 100644 api/logic/SeparatorPrefixTree.h create mode 100644 api/logic/TypeMagic.h create mode 100644 api/logic/Version.cpp create mode 100644 api/logic/Version.h create mode 100644 api/logic/java/JavaChecker.cpp create mode 100644 api/logic/java/JavaChecker.h create mode 100644 api/logic/java/JavaCheckerJob.cpp create mode 100644 api/logic/java/JavaCheckerJob.h create mode 100644 api/logic/java/JavaInstall.cpp create mode 100644 api/logic/java/JavaInstall.h create mode 100644 api/logic/java/JavaInstallList.cpp create mode 100644 api/logic/java/JavaInstallList.h create mode 100644 api/logic/java/JavaUtils.cpp create mode 100644 api/logic/java/JavaUtils.h create mode 100644 api/logic/java/JavaVersion.cpp create mode 100644 api/logic/java/JavaVersion.h create mode 100644 api/logic/launch/LaunchStep.cpp create mode 100644 api/logic/launch/LaunchStep.h create mode 100644 api/logic/launch/LaunchTask.cpp create mode 100644 api/logic/launch/LaunchTask.h create mode 100644 api/logic/launch/LoggedProcess.cpp create mode 100644 api/logic/launch/LoggedProcess.h create mode 100644 api/logic/launch/MessageLevel.cpp create mode 100644 api/logic/launch/MessageLevel.h create mode 100644 api/logic/launch/steps/CheckJava.cpp create mode 100644 api/logic/launch/steps/CheckJava.h create mode 100644 api/logic/launch/steps/LaunchMinecraft.cpp create mode 100644 api/logic/launch/steps/LaunchMinecraft.h create mode 100644 api/logic/launch/steps/ModMinecraftJar.cpp create mode 100644 api/logic/launch/steps/ModMinecraftJar.h create mode 100644 api/logic/launch/steps/PostLaunchCommand.cpp create mode 100644 api/logic/launch/steps/PostLaunchCommand.h create mode 100644 api/logic/launch/steps/PreLaunchCommand.cpp create mode 100644 api/logic/launch/steps/PreLaunchCommand.h create mode 100644 api/logic/launch/steps/TextPrint.cpp create mode 100644 api/logic/launch/steps/TextPrint.h create mode 100644 api/logic/launch/steps/Update.cpp create mode 100644 api/logic/launch/steps/Update.h create mode 100644 api/logic/minecraft/AssetsUtils.cpp create mode 100644 api/logic/minecraft/AssetsUtils.h create mode 100644 api/logic/minecraft/GradleSpecifier.h create mode 100644 api/logic/minecraft/JarMod.h create mode 100644 api/logic/minecraft/Library.cpp create mode 100644 api/logic/minecraft/Library.h create mode 100644 api/logic/minecraft/MinecraftInstance.cpp create mode 100644 api/logic/minecraft/MinecraftInstance.h create mode 100644 api/logic/minecraft/MinecraftProfile.cpp create mode 100644 api/logic/minecraft/MinecraftProfile.h create mode 100644 api/logic/minecraft/MinecraftVersion.cpp create mode 100644 api/logic/minecraft/MinecraftVersion.h create mode 100644 api/logic/minecraft/MinecraftVersionList.cpp create mode 100644 api/logic/minecraft/MinecraftVersionList.h create mode 100644 api/logic/minecraft/Mod.cpp create mode 100644 api/logic/minecraft/Mod.h create mode 100644 api/logic/minecraft/ModList.cpp create mode 100644 api/logic/minecraft/ModList.h create mode 100644 api/logic/minecraft/MojangDownloadInfo.h create mode 100644 api/logic/minecraft/MojangVersionFormat.cpp create mode 100644 api/logic/minecraft/MojangVersionFormat.h create mode 100644 api/logic/minecraft/OpSys.cpp create mode 100644 api/logic/minecraft/OpSys.h create mode 100644 api/logic/minecraft/ParseUtils.cpp create mode 100644 api/logic/minecraft/ParseUtils.h create mode 100644 api/logic/minecraft/ProfilePatch.h create mode 100644 api/logic/minecraft/ProfileStrategy.h create mode 100644 api/logic/minecraft/ProfileUtils.cpp create mode 100644 api/logic/minecraft/ProfileUtils.h create mode 100644 api/logic/minecraft/Rule.cpp create mode 100644 api/logic/minecraft/Rule.h create mode 100644 api/logic/minecraft/VersionBuildError.h create mode 100644 api/logic/minecraft/VersionFile.cpp create mode 100644 api/logic/minecraft/VersionFile.h create mode 100644 api/logic/minecraft/VersionFilterData.cpp create mode 100644 api/logic/minecraft/VersionFilterData.h create mode 100644 api/logic/minecraft/World.cpp create mode 100644 api/logic/minecraft/World.h create mode 100644 api/logic/minecraft/WorldList.cpp create mode 100644 api/logic/minecraft/WorldList.h create mode 100644 api/logic/minecraft/auth/AuthSession.cpp create mode 100644 api/logic/minecraft/auth/AuthSession.h create mode 100644 api/logic/minecraft/auth/MojangAccount.cpp create mode 100644 api/logic/minecraft/auth/MojangAccount.h create mode 100644 api/logic/minecraft/auth/MojangAccountList.cpp create mode 100644 api/logic/minecraft/auth/MojangAccountList.h create mode 100644 api/logic/minecraft/auth/YggdrasilTask.cpp create mode 100644 api/logic/minecraft/auth/YggdrasilTask.h create mode 100644 api/logic/minecraft/auth/flows/AuthenticateTask.cpp create mode 100644 api/logic/minecraft/auth/flows/AuthenticateTask.h create mode 100644 api/logic/minecraft/auth/flows/RefreshTask.cpp create mode 100644 api/logic/minecraft/auth/flows/RefreshTask.h create mode 100644 api/logic/minecraft/auth/flows/ValidateTask.cpp create mode 100644 api/logic/minecraft/auth/flows/ValidateTask.h create mode 100644 api/logic/minecraft/forge/ForgeInstaller.cpp create mode 100644 api/logic/minecraft/forge/ForgeInstaller.h create mode 100644 api/logic/minecraft/forge/ForgeVersion.cpp create mode 100644 api/logic/minecraft/forge/ForgeVersion.h create mode 100644 api/logic/minecraft/forge/ForgeVersionList.cpp create mode 100644 api/logic/minecraft/forge/ForgeVersionList.h create mode 100644 api/logic/minecraft/forge/ForgeXzDownload.cpp create mode 100644 api/logic/minecraft/forge/ForgeXzDownload.h create mode 100644 api/logic/minecraft/forge/LegacyForge.cpp create mode 100644 api/logic/minecraft/forge/LegacyForge.h create mode 100644 api/logic/minecraft/ftb/FTBPlugin.cpp create mode 100644 api/logic/minecraft/ftb/FTBPlugin.h create mode 100644 api/logic/minecraft/ftb/FTBProfileStrategy.cpp create mode 100644 api/logic/minecraft/ftb/FTBProfileStrategy.h create mode 100644 api/logic/minecraft/ftb/FTBVersion.h create mode 100644 api/logic/minecraft/ftb/LegacyFTBInstance.cpp create mode 100644 api/logic/minecraft/ftb/LegacyFTBInstance.h create mode 100644 api/logic/minecraft/ftb/OneSixFTBInstance.cpp create mode 100644 api/logic/minecraft/ftb/OneSixFTBInstance.h create mode 100644 api/logic/minecraft/legacy/LegacyInstance.cpp create mode 100644 api/logic/minecraft/legacy/LegacyInstance.h create mode 100644 api/logic/minecraft/legacy/LegacyUpdate.cpp create mode 100644 api/logic/minecraft/legacy/LegacyUpdate.h create mode 100644 api/logic/minecraft/legacy/LwjglVersionList.cpp create mode 100644 api/logic/minecraft/legacy/LwjglVersionList.h create mode 100644 api/logic/minecraft/liteloader/LiteLoaderInstaller.cpp create mode 100644 api/logic/minecraft/liteloader/LiteLoaderInstaller.h create mode 100644 api/logic/minecraft/liteloader/LiteLoaderVersionList.cpp create mode 100644 api/logic/minecraft/liteloader/LiteLoaderVersionList.h create mode 100644 api/logic/minecraft/onesix/OneSixInstance.cpp create mode 100644 api/logic/minecraft/onesix/OneSixInstance.h create mode 100644 api/logic/minecraft/onesix/OneSixProfileStrategy.cpp create mode 100644 api/logic/minecraft/onesix/OneSixProfileStrategy.h create mode 100644 api/logic/minecraft/onesix/OneSixUpdate.cpp create mode 100644 api/logic/minecraft/onesix/OneSixUpdate.h create mode 100644 api/logic/minecraft/onesix/OneSixVersionFormat.cpp create mode 100644 api/logic/minecraft/onesix/OneSixVersionFormat.h create mode 100644 api/logic/net/ByteArrayDownload.cpp create mode 100644 api/logic/net/ByteArrayDownload.h create mode 100644 api/logic/net/CacheDownload.cpp create mode 100644 api/logic/net/CacheDownload.h create mode 100644 api/logic/net/HttpMetaCache.cpp create mode 100644 api/logic/net/HttpMetaCache.h create mode 100644 api/logic/net/MD5EtagDownload.cpp create mode 100644 api/logic/net/MD5EtagDownload.h create mode 100644 api/logic/net/NetAction.h create mode 100644 api/logic/net/NetJob.cpp create mode 100644 api/logic/net/NetJob.h create mode 100644 api/logic/net/PasteUpload.cpp create mode 100644 api/logic/net/PasteUpload.h create mode 100644 api/logic/net/URLConstants.cpp create mode 100644 api/logic/net/URLConstants.h create mode 100644 api/logic/news/NewsChecker.cpp create mode 100644 api/logic/news/NewsChecker.h create mode 100644 api/logic/news/NewsEntry.cpp create mode 100644 api/logic/news/NewsEntry.h create mode 100644 api/logic/notifications/NotificationChecker.cpp create mode 100644 api/logic/notifications/NotificationChecker.h create mode 100644 api/logic/pathmatcher/FSTreeMatcher.h create mode 100644 api/logic/pathmatcher/IPathMatcher.h create mode 100644 api/logic/pathmatcher/MultiMatcher.h create mode 100644 api/logic/pathmatcher/RegexpMatcher.h create mode 100644 api/logic/resources/Resource.cpp create mode 100644 api/logic/resources/Resource.h create mode 100644 api/logic/resources/ResourceHandler.cpp create mode 100644 api/logic/resources/ResourceHandler.h create mode 100644 api/logic/resources/ResourceObserver.cpp create mode 100644 api/logic/resources/ResourceObserver.h create mode 100644 api/logic/resources/ResourceProxyModel.cpp create mode 100644 api/logic/resources/ResourceProxyModel.h create mode 100644 api/logic/screenshots/ImgurAlbumCreation.cpp create mode 100644 api/logic/screenshots/ImgurAlbumCreation.h create mode 100644 api/logic/screenshots/ImgurUpload.cpp create mode 100644 api/logic/screenshots/ImgurUpload.h create mode 100644 api/logic/screenshots/Screenshot.h create mode 100644 api/logic/settings/INIFile.cpp create mode 100644 api/logic/settings/INIFile.h create mode 100644 api/logic/settings/INISettingsObject.cpp create mode 100644 api/logic/settings/INISettingsObject.h create mode 100644 api/logic/settings/OverrideSetting.cpp create mode 100644 api/logic/settings/OverrideSetting.h create mode 100644 api/logic/settings/PassthroughSetting.cpp create mode 100644 api/logic/settings/PassthroughSetting.h create mode 100644 api/logic/settings/Setting.cpp create mode 100644 api/logic/settings/Setting.h create mode 100644 api/logic/settings/SettingsObject.cpp create mode 100644 api/logic/settings/SettingsObject.h create mode 100644 api/logic/status/StatusChecker.cpp create mode 100644 api/logic/status/StatusChecker.h create mode 100644 api/logic/tasks/SequentialTask.cpp create mode 100644 api/logic/tasks/SequentialTask.h create mode 100644 api/logic/tasks/Task.cpp create mode 100644 api/logic/tasks/Task.h create mode 100644 api/logic/tasks/ThreadTask.cpp create mode 100644 api/logic/tasks/ThreadTask.h create mode 100644 api/logic/tools/BaseExternalTool.cpp create mode 100644 api/logic/tools/BaseExternalTool.h create mode 100644 api/logic/tools/BaseProfiler.cpp create mode 100644 api/logic/tools/BaseProfiler.h create mode 100644 api/logic/tools/JProfiler.cpp create mode 100644 api/logic/tools/JProfiler.h create mode 100644 api/logic/tools/JVisualVM.cpp create mode 100644 api/logic/tools/JVisualVM.h create mode 100644 api/logic/tools/MCEditTool.cpp create mode 100644 api/logic/tools/MCEditTool.h create mode 100644 api/logic/trans/TranslationDownloader.cpp create mode 100644 api/logic/trans/TranslationDownloader.h create mode 100644 api/logic/updater/DownloadTask.cpp create mode 100644 api/logic/updater/DownloadTask.h create mode 100644 api/logic/updater/GoUpdate.cpp create mode 100644 api/logic/updater/GoUpdate.h create mode 100644 api/logic/updater/UpdateChecker.cpp create mode 100644 api/logic/updater/UpdateChecker.h create mode 100644 api/logic/wonko/BaseWonkoEntity.cpp create mode 100644 api/logic/wonko/BaseWonkoEntity.h create mode 100644 api/logic/wonko/WonkoIndex.cpp create mode 100644 api/logic/wonko/WonkoIndex.h create mode 100644 api/logic/wonko/WonkoReference.cpp create mode 100644 api/logic/wonko/WonkoReference.h create mode 100644 api/logic/wonko/WonkoUtil.cpp create mode 100644 api/logic/wonko/WonkoUtil.h create mode 100644 api/logic/wonko/WonkoVersion.cpp create mode 100644 api/logic/wonko/WonkoVersion.h create mode 100644 api/logic/wonko/WonkoVersionList.cpp create mode 100644 api/logic/wonko/WonkoVersionList.h create mode 100644 api/logic/wonko/format/WonkoFormat.cpp create mode 100644 api/logic/wonko/format/WonkoFormat.h create mode 100644 api/logic/wonko/format/WonkoFormatV1.cpp create mode 100644 api/logic/wonko/format/WonkoFormatV1.h create mode 100644 api/logic/wonko/tasks/BaseWonkoEntityLocalLoadTask.cpp create mode 100644 api/logic/wonko/tasks/BaseWonkoEntityLocalLoadTask.h create mode 100644 api/logic/wonko/tasks/BaseWonkoEntityRemoteLoadTask.cpp create mode 100644 api/logic/wonko/tasks/BaseWonkoEntityRemoteLoadTask.h (limited to 'api/logic') diff --git a/api/logic/AbstractCommonModel.cpp b/api/logic/AbstractCommonModel.cpp new file mode 100644 index 00000000..71d75829 --- /dev/null +++ b/api/logic/AbstractCommonModel.cpp @@ -0,0 +1,133 @@ +/* Copyright 2015 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "AbstractCommonModel.h" + +BaseAbstractCommonModel::BaseAbstractCommonModel(const Qt::Orientation orientation, QObject *parent) + : QAbstractListModel(parent), m_orientation(orientation) +{ +} + +int BaseAbstractCommonModel::rowCount(const QModelIndex &parent) const +{ + return m_orientation == Qt::Horizontal ? entryCount() : size(); +} +int BaseAbstractCommonModel::columnCount(const QModelIndex &parent) const +{ + return m_orientation == Qt::Horizontal ? size() : entryCount(); +} +QVariant BaseAbstractCommonModel::data(const QModelIndex &index, int role) const +{ + if (!hasIndex(index.row(), index.column(), index.parent())) + { + return QVariant(); + } + const int i = m_orientation == Qt::Horizontal ? index.column() : index.row(); + const int entry = m_orientation == Qt::Horizontal ? index.row() : index.column(); + return formatData(i, role, get(i, entry, role)); +} +QVariant BaseAbstractCommonModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if (orientation != m_orientation && role == Qt::DisplayRole) + { + return entryTitle(section); + } + else + { + return QVariant(); + } +} +bool BaseAbstractCommonModel::setData(const QModelIndex &index, const QVariant &value, int role) +{ + const int i = m_orientation == Qt::Horizontal ? index.column() : index.row(); + const int entry = m_orientation == Qt::Horizontal ? index.row() : index.column(); + const bool result = set(i, entry, role, sanetizeData(i, role, value)); + if (result) + { + emit dataChanged(index, index, QVector() << role); + } + return result; +} +Qt::ItemFlags BaseAbstractCommonModel::flags(const QModelIndex &index) const +{ + if (!hasIndex(index.row(), index.column(), index.parent())) + { + return Qt::NoItemFlags; + } + + const int entry = m_orientation == Qt::Horizontal ? index.row() : index.column(); + if (canSet(entry)) + { + return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEnabled; + } + else + { + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; + } +} + +void BaseAbstractCommonModel::notifyAboutToAddObject(const int at) +{ + if (m_orientation == Qt::Horizontal) + { + beginInsertColumns(QModelIndex(), at, at); + } + else + { + beginInsertRows(QModelIndex(), at, at); + } +} +void BaseAbstractCommonModel::notifyObjectAdded() +{ + if (m_orientation == Qt::Horizontal) + { + endInsertColumns(); + } + else + { + endInsertRows(); + } +} +void BaseAbstractCommonModel::notifyAboutToRemoveObject(const int at) +{ + if (m_orientation == Qt::Horizontal) + { + beginRemoveColumns(QModelIndex(), at, at); + } + else + { + beginRemoveRows(QModelIndex(), at, at); + } +} +void BaseAbstractCommonModel::notifyObjectRemoved() +{ + if (m_orientation == Qt::Horizontal) + { + endRemoveColumns(); + } + else + { + endRemoveRows(); + } +} + +void BaseAbstractCommonModel::notifyBeginReset() +{ + beginResetModel(); +} +void BaseAbstractCommonModel::notifyEndReset() +{ + endResetModel(); +} diff --git a/api/logic/AbstractCommonModel.h b/api/logic/AbstractCommonModel.h new file mode 100644 index 00000000..31b86a23 --- /dev/null +++ b/api/logic/AbstractCommonModel.h @@ -0,0 +1,462 @@ +/* Copyright 2015 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include +#include + +class BaseAbstractCommonModel : public QAbstractListModel +{ + Q_OBJECT +public: + explicit BaseAbstractCommonModel(const Qt::Orientation orientation, QObject *parent = nullptr); + + // begin QAbstractItemModel interface + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; + QVariant data(const QModelIndex &index, int role) const override; + QVariant headerData(int section, Qt::Orientation orientation, int role) const override; + bool setData(const QModelIndex &index, const QVariant &value, int role) override; + Qt::ItemFlags flags(const QModelIndex &index) const override; + // end QAbstractItemModel interface + + virtual int size() const = 0; + virtual int entryCount() const = 0; + + virtual QVariant formatData(const int index, int role, const QVariant &data) const { return data; } + virtual QVariant sanetizeData(const int index, int role, const QVariant &data) const { return data; } + +protected: + virtual QVariant get(const int index, const int entry, const int role) const = 0; + virtual bool set(const int index, const int entry, const int role, const QVariant &value) = 0; + virtual bool canSet(const int entry) const = 0; + virtual QString entryTitle(const int entry) const = 0; + + void notifyAboutToAddObject(const int at); + void notifyObjectAdded(); + void notifyAboutToRemoveObject(const int at); + void notifyObjectRemoved(); + void notifyBeginReset(); + void notifyEndReset(); + + const Qt::Orientation m_orientation; +}; + +template +class AbstractCommonModel : public BaseAbstractCommonModel +{ +public: + explicit AbstractCommonModel(const Qt::Orientation orientation) + : BaseAbstractCommonModel(orientation) {} + virtual ~AbstractCommonModel() {} + + int size() const override { return m_objects.size(); } + int entryCount() const override { return m_entries.size(); } + + void append(const Object &object) + { + notifyAboutToAddObject(size()); + m_objects.append(object); + notifyObjectAdded(); + } + void prepend(const Object &object) + { + notifyAboutToAddObject(0); + m_objects.prepend(object); + notifyObjectAdded(); + } + void insert(const Object &object, const int index) + { + if (index >= size()) + { + prepend(object); + } + else if (index <= 0) + { + append(object); + } + else + { + notifyAboutToAddObject(index); + m_objects.insert(index, object); + notifyObjectAdded(); + } + } + void remove(const int index) + { + notifyAboutToRemoveObject(index); + m_objects.removeAt(index); + notifyObjectRemoved(); + } + Object get(const int index) const + { + return m_objects.at(index); + } + +private: + friend class CommonModel; + QVariant get(const int index, const int entry, const int role) const override + { + if (m_entries.size() < entry || !m_entries[entry].second.contains(role)) + { + return QVariant(); + } + return m_entries[entry].second.value(role)->get(m_objects.at(index)); + } + bool set(const int index, const int entry, const int role, const QVariant &value) override + { + if (m_entries.size() < entry || !m_entries[entry].second.contains(role)) + { + return false; + } + IEntry *e = m_entries[entry].second.value(role); + if (!e->canSet()) + { + return false; + } + e->set(m_objects[index], value); + return true; + } + bool canSet(const int entry) const override + { + if (m_entries.size() < entry || !m_entries[entry].second.contains(Qt::EditRole)) + { + return false; + } + IEntry *e = m_entries[entry].second.value(Qt::EditRole); + return e->canSet(); + } + + QString entryTitle(const int entry) const override + { + return m_entries.at(entry).first; + } + +private: + struct IEntry + { + virtual ~IEntry() {} + virtual void set(Object &object, const QVariant &value) = 0; + virtual QVariant get(const Object &object) const = 0; + virtual bool canSet() const = 0; + }; + template + struct VariableEntry : public IEntry + { + typedef T (Object::*Member); + + explicit VariableEntry(Member member) + : m_member(member) {} + + void set(Object &object, const QVariant &value) override + { + object.*m_member = value.value(); + } + QVariant get(const Object &object) const override + { + return QVariant::fromValue(object.*m_member); + } + bool canSet() const override { return true; } + + private: + Member m_member; + }; + template + struct FunctionEntry : public IEntry + { + typedef T (Object::*Getter)() const; + typedef void (Object::*Setter)(T); + + explicit FunctionEntry(Getter getter, Setter setter) + : m_getter(m_getter), m_setter(m_setter) {} + + void set(Object &object, const QVariant &value) override + { + object.*m_setter(value.value()); + } + QVariant get(const Object &object) const override + { + return QVariant::fromValue(object.*m_getter()); + } + bool canSet() const override { return !!m_setter; } + + private: + Getter m_getter; + Setter m_setter; + }; + + QList m_objects; + QVector>> m_entries; + + void addEntryInternal(IEntry *e, const int entry, const int role) + { + if (m_entries.size() <= entry) + { + m_entries.resize(entry + 1); + } + m_entries[entry].second.insert(role, e); + } + +protected: + template + typename std::enable_if::value && std::is_member_function_pointer::value, void>::type + addEntry(Getter getter, Setter setter, const int entry, const int role) + { + addEntryInternal(new FunctionEntry::type>(getter, setter), entry, role); + } + template + typename std::enable_if::value, void>::type + addEntry(Getter getter, const int entry, const int role) + { + addEntryInternal(new FunctionEntry::type>(getter, nullptr), entry, role); + } + template + typename std::enable_if::value, void>::type + addEntry(T (Object::*member), const int entry, const int role) + { + addEntryInternal(new VariableEntry(member), entry, role); + } + + void setEntryTitle(const int entry, const QString &title) + { + m_entries[entry].first = title; + } +}; +template +class AbstractCommonModel : public BaseAbstractCommonModel +{ +public: + explicit AbstractCommonModel(const Qt::Orientation orientation) + : BaseAbstractCommonModel(orientation) {} + virtual ~AbstractCommonModel() + { + qDeleteAll(m_objects); + } + + int size() const override { return m_objects.size(); } + int entryCount() const override { return m_entries.size(); } + + void append(Object *object) + { + notifyAboutToAddObject(size()); + m_objects.append(object); + notifyObjectAdded(); + } + void prepend(Object *object) + { + notifyAboutToAddObject(0); + m_objects.prepend(object); + notifyObjectAdded(); + } + void insert(Object *object, const int index) + { + if (index >= size()) + { + prepend(object); + } + else if (index <= 0) + { + append(object); + } + else + { + notifyAboutToAddObject(index); + m_objects.insert(index, object); + notifyObjectAdded(); + } + } + void remove(const int index) + { + notifyAboutToRemoveObject(index); + m_objects.removeAt(index); + notifyObjectRemoved(); + } + Object *get(const int index) const + { + return m_objects.at(index); + } + int find(Object * const obj) const + { + return m_objects.indexOf(obj); + } + + QList getAll() const + { + return m_objects; + } + +private: + friend class CommonModel; + QVariant get(const int index, const int entry, const int role) const override + { + if (m_entries.size() < entry || !m_entries[entry].second.contains(role)) + { + return QVariant(); + } + return m_entries[entry].second.value(role)->get(m_objects.at(index)); + } + bool set(const int index, const int entry, const int role, const QVariant &value) override + { + if (m_entries.size() < entry || !m_entries[entry].second.contains(role)) + { + return false; + } + IEntry *e = m_entries[entry].second.value(role); + if (!e->canSet()) + { + return false; + } + e->set(m_objects[index], value); + return true; + } + bool canSet(const int entry) const override + { + if (m_entries.size() < entry || !m_entries[entry].second.contains(Qt::EditRole)) + { + return false; + } + IEntry *e = m_entries[entry].second.value(Qt::EditRole); + return e->canSet(); + } + + QString entryTitle(const int entry) const override + { + return m_entries.at(entry).first; + } + +private: + struct IEntry + { + virtual ~IEntry() {} + virtual void set(Object *object, const QVariant &value) = 0; + virtual QVariant get(Object *object) const = 0; + virtual bool canSet() const = 0; + }; + template + struct VariableEntry : public IEntry + { + typedef T (Object::*Member); + + explicit VariableEntry(Member member) + : m_member(member) {} + + void set(Object *object, const QVariant &value) override + { + object->*m_member = value.value(); + } + QVariant get(Object *object) const override + { + return QVariant::fromValue(object->*m_member); + } + bool canSet() const override { return true; } + + private: + Member m_member; + }; + template + struct FunctionEntry : public IEntry + { + typedef T (Object::*Getter)() const; + typedef void (Object::*Setter)(T); + + explicit FunctionEntry(Getter getter, Setter setter) + : m_getter(getter), m_setter(setter) {} + + void set(Object *object, const QVariant &value) override + { + (object->*m_setter)(value.value()); + } + QVariant get(Object *object) const override + { + return QVariant::fromValue((object->*m_getter)()); + } + bool canSet() const override { return !!m_setter; } + + private: + Getter m_getter; + Setter m_setter; + }; + template + struct LambdaEntry : public IEntry + { + using Getter = std::function; + + explicit LambdaEntry(Getter getter) + : m_getter(getter) {} + + void set(Object *object, const QVariant &value) override {} + QVariant get(Object *object) const override + { + return QVariant::fromValue(m_getter(object)); + } + bool canSet() const override { return false; } + + private: + Getter m_getter; + }; + + QList m_objects; + QVector>> m_entries; + + void addEntryInternal(IEntry *e, const int entry, const int role) + { + if (m_entries.size() <= entry) + { + m_entries.resize(entry + 1); + } + m_entries[entry].second.insert(role, e); + } + +protected: + template + typename std::enable_if::value && std::is_member_function_pointer::value, void>::type + addEntry(const int entry, const int role, Getter getter, Setter setter) + { + addEntryInternal(new FunctionEntry::type>(getter, setter), entry, role); + } + template + typename std::enable_if::Getter>::value, void>::type + addEntry(const int entry, const int role, typename FunctionEntry::Getter getter) + { + addEntryInternal(new FunctionEntry(getter, nullptr), entry, role); + } + template + typename std::enable_if::value, void>::type + addEntry(const int entry, const int role, T (Object::*member)) + { + addEntryInternal(new VariableEntry(member), entry, role); + } + template + void addEntry(const int entry, const int role, typename LambdaEntry::Getter lambda) + { + addEntryInternal(new LambdaEntry(lambda), entry, role); + } + + void setEntryTitle(const int entry, const QString &title) + { + m_entries[entry].first = title; + } + + void setAll(const QList objects) + { + notifyBeginReset(); + qDeleteAll(m_objects); + m_objects = objects; + notifyEndReset(); + } +}; diff --git a/api/logic/BaseConfigObject.cpp b/api/logic/BaseConfigObject.cpp new file mode 100644 index 00000000..3040ac2e --- /dev/null +++ b/api/logic/BaseConfigObject.cpp @@ -0,0 +1,103 @@ +/* Copyright 2015 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "BaseConfigObject.h" + +#include +#include +#include +#include + +#include "Exception.h" +#include "FileSystem.h" + +BaseConfigObject::BaseConfigObject(const QString &filename) + : m_filename(filename) +{ + m_saveTimer = new QTimer; + m_saveTimer->setSingleShot(true); + // cppcheck-suppress pureVirtualCall + QObject::connect(m_saveTimer, &QTimer::timeout, [this](){saveNow();}); + setSaveTimeout(250); + + m_initialReadTimer = new QTimer; + m_initialReadTimer->setSingleShot(true); + QObject::connect(m_initialReadTimer, &QTimer::timeout, [this]() + { + loadNow(); + m_initialReadTimer->deleteLater(); + m_initialReadTimer = 0; + }); + m_initialReadTimer->start(0); + + // cppcheck-suppress pureVirtualCall + m_appQuitConnection = QObject::connect(qApp, &QCoreApplication::aboutToQuit, [this](){saveNow();}); +} +BaseConfigObject::~BaseConfigObject() +{ + delete m_saveTimer; + if (m_initialReadTimer) + { + delete m_initialReadTimer; + } + QObject::disconnect(m_appQuitConnection); +} + +void BaseConfigObject::setSaveTimeout(int msec) +{ + m_saveTimer->setInterval(msec); +} + +void BaseConfigObject::scheduleSave() +{ + m_saveTimer->stop(); + m_saveTimer->start(); +} +void BaseConfigObject::saveNow() +{ + if (m_saveTimer->isActive()) + { + m_saveTimer->stop(); + } + if (m_disableSaving) + { + return; + } + + try + { + FS::write(m_filename, doSave()); + } + catch (Exception & e) + { + qCritical() << e.cause(); + } +} +void BaseConfigObject::loadNow() +{ + if (m_saveTimer->isActive()) + { + saveNow(); + } + + try + { + doLoad(FS::read(m_filename)); + } + catch (Exception & e) + { + qWarning() << "Error loading" << m_filename << ":" << e.cause(); + } +} diff --git a/api/logic/BaseConfigObject.h b/api/logic/BaseConfigObject.h new file mode 100644 index 00000000..1c96b3d1 --- /dev/null +++ b/api/logic/BaseConfigObject.h @@ -0,0 +1,50 @@ +/* Copyright 2015 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +class QTimer; + +class BaseConfigObject +{ +public: + void setSaveTimeout(int msec); + +protected: + explicit BaseConfigObject(const QString &filename); + virtual ~BaseConfigObject(); + + // cppcheck-suppress pureVirtualCall + virtual QByteArray doSave() const = 0; + virtual void doLoad(const QByteArray &data) = 0; + + void setSavingDisabled(bool savingDisabled) { m_disableSaving = savingDisabled; } + + QString fileName() const { return m_filename; } + +public: + void scheduleSave(); + void saveNow(); + void loadNow(); + +private: + QTimer *m_saveTimer; + QTimer *m_initialReadTimer; + QString m_filename; + QMetaObject::Connection m_appQuitConnection; + bool m_disableSaving = false; +}; diff --git a/api/logic/BaseInstaller.cpp b/api/logic/BaseInstaller.cpp new file mode 100644 index 00000000..cb762ebd --- /dev/null +++ b/api/logic/BaseInstaller.cpp @@ -0,0 +1,61 @@ +/* Copyright 2013-2015 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "BaseInstaller.h" +#include "minecraft/onesix/OneSixInstance.h" + +BaseInstaller::BaseInstaller() +{ + +} + +bool BaseInstaller::isApplied(OneSixInstance *on) +{ + return QFile::exists(filename(on->instanceRoot())); +} + +bool BaseInstaller::add(OneSixInstance *to) +{ + if (!patchesDir(to->instanceRoot()).exists()) + { + QDir(to->instanceRoot()).mkdir("patches"); + } + + if (isApplied(to)) + { + if (!remove(to)) + { + return false; + } + } + + return true; +} + +bool BaseInstaller::remove(OneSixInstance *from) +{ + return QFile::remove(filename(from->instanceRoot())); +} + +QString BaseInstaller::filename(const QString &root) const +{ + return patchesDir(root).absoluteFilePath(id() + ".json"); +} +QDir BaseInstaller::patchesDir(const QString &root) const +{ + return QDir(root + "/patches/"); +} diff --git a/api/logic/BaseInstaller.h b/api/logic/BaseInstaller.h new file mode 100644 index 00000000..a50c8cb1 --- /dev/null +++ b/api/logic/BaseInstaller.h @@ -0,0 +1,46 @@ +/* Copyright 2013-2015 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#include "multimc_logic_export.h" + +class OneSixInstance; +class QDir; +class QString; +class QObject; +class Task; +class BaseVersion; +typedef std::shared_ptr BaseVersionPtr; + +class MULTIMC_LOGIC_EXPORT BaseInstaller +{ +public: + BaseInstaller(); + virtual ~BaseInstaller(){}; + bool isApplied(OneSixInstance *on); + + virtual bool add(OneSixInstance *to); + virtual bool remove(OneSixInstance *from); + + virtual Task *createInstallTask(OneSixInstance *instance, BaseVersionPtr version, QObject *parent) = 0; + +protected: + virtual QString id() const = 0; + QString filename(const QString &root) const; + QDir patchesDir(const QString &root) const; +}; diff --git a/api/logic/BaseInstance.cpp b/api/logic/BaseInstance.cpp new file mode 100644 index 00000000..ce55d5e4 --- /dev/null +++ b/api/logic/BaseInstance.cpp @@ -0,0 +1,270 @@ +/* Copyright 2013-2015 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "BaseInstance.h" + +#include +#include + +#include "settings/INISettingsObject.h" +#include "settings/Setting.h" +#include "settings/OverrideSetting.h" + +#include "minecraft/MinecraftVersionList.h" +#include "FileSystem.h" +#include "Commandline.h" + +BaseInstance::BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir) + : QObject() +{ + m_settings = settings; + m_rootDir = rootDir; + + m_settings->registerSetting("name", "Unnamed Instance"); + m_settings->registerSetting("iconKey", "default"); + m_settings->registerSetting("notes", ""); + m_settings->registerSetting("lastLaunchTime", 0); + m_settings->registerSetting("totalTimePlayed", 0); + + // Custom Commands + auto commandSetting = m_settings->registerSetting({"OverrideCommands","OverrideLaunchCmd"}, false); + m_settings->registerOverride(globalSettings->getSetting("PreLaunchCommand"), commandSetting); + m_settings->registerOverride(globalSettings->getSetting("WrapperCommand"), commandSetting); + m_settings->registerOverride(globalSettings->getSetting("PostExitCommand"), commandSetting); + + // Console + auto consoleSetting = m_settings->registerSetting("OverrideConsole", false); + m_settings->registerOverride(globalSettings->getSetting("ShowConsole"), consoleSetting); + m_settings->registerOverride(globalSettings->getSetting("AutoCloseConsole"), consoleSetting); + m_settings->registerOverride(globalSettings->getSetting("LogPrePostOutput"), consoleSetting); +} + +QString BaseInstance::getPreLaunchCommand() +{ + return settings()->get("PreLaunchCommand").toString(); +} + +QString BaseInstance::getWrapperCommand() +{ + return settings()->get("WrapperCommand").toString(); +} + +QString BaseInstance::getPostExitCommand() +{ + return settings()->get("PostExitCommand").toString(); +} + +void BaseInstance::iconUpdated(QString key) +{ + if(iconKey() == key) + { + emit propertiesChanged(this); + } +} + +void BaseInstance::nuke() +{ + FS::deletePath(instanceRoot()); + emit nuked(this); +} + +QString BaseInstance::id() const +{ + return QFileInfo(instanceRoot()).fileName(); +} + +bool BaseInstance::isRunning() const +{ + return m_isRunning; +} + +void BaseInstance::setRunning(bool running) +{ + if(running && !m_isRunning) + { + m_timeStarted = QDateTime::currentDateTime(); + } + else if(!running && m_isRunning) + { + qint64 current = settings()->get("totalTimePlayed").toLongLong(); + QDateTime timeEnded = QDateTime::currentDateTime(); + settings()->set("totalTimePlayed", current + m_timeStarted.secsTo(timeEnded)); + emit propertiesChanged(this); + } + m_isRunning = running; +} + +int64_t BaseInstance::totalTimePlayed() const +{ + qint64 current = settings()->get("totalTimePlayed").toLongLong(); + if(m_isRunning) + { + QDateTime timeNow = QDateTime::currentDateTime(); + return current + m_timeStarted.secsTo(timeNow); + } + return current; +} + +void BaseInstance::resetTimePlayed() +{ + settings()->reset("totalTimePlayed"); +} + +QString BaseInstance::instanceType() const +{ + return m_settings->get("InstanceType").toString(); +} + +QString BaseInstance::instanceRoot() const +{ + return m_rootDir; +} + +InstancePtr BaseInstance::getSharedPtr() +{ + return shared_from_this(); +} + +SettingsObjectPtr BaseInstance::settings() const +{ + return m_settings; +} + +BaseInstance::InstanceFlags BaseInstance::flags() const +{ + return m_flags; +} + +void BaseInstance::setFlags(const InstanceFlags &flags) +{ + if (flags != m_flags) + { + m_flags = flags; + emit flagsChanged(); + emit propertiesChanged(this); + } +} + +void BaseInstance::setFlag(const BaseInstance::InstanceFlag flag) +{ + // nothing to set? + if(flag & m_flags) + return; + m_flags |= flag; + emit flagsChanged(); + emit propertiesChanged(this); +} + +void BaseInstance::unsetFlag(const BaseInstance::InstanceFlag flag) +{ + // nothing to unset? + if(!(flag & m_flags)) + return; + m_flags &= ~flag; + emit flagsChanged(); + emit propertiesChanged(this); +} + +bool BaseInstance::canLaunch() const +{ + return !(flags() & VersionBrokenFlag); +} + +bool BaseInstance::reload() +{ + return m_settings->reload(); +} + +qint64 BaseInstance::lastLaunch() const +{ + return m_settings->get("lastLaunchTime").value(); +} + +void BaseInstance::setLastLaunch(qint64 val) +{ + //FIXME: if no change, do not set. setting involves saving a file. + m_settings->set("lastLaunchTime", val); + emit propertiesChanged(this); +} + +void BaseInstance::setGroupInitial(QString val) +{ + if(m_group == val) + { + return; + } + m_group = val; + emit propertiesChanged(this); +} + +void BaseInstance::setGroupPost(QString val) +{ + if(m_group == val) + { + return; + } + setGroupInitial(val); + emit groupChanged(); +} + +QString BaseInstance::group() const +{ + return m_group; +} + +void BaseInstance::setNotes(QString val) +{ + //FIXME: if no change, do not set. setting involves saving a file. + m_settings->set("notes", val); +} + +QString BaseInstance::notes() const +{ + return m_settings->get("notes").toString(); +} + +void BaseInstance::setIconKey(QString val) +{ + //FIXME: if no change, do not set. setting involves saving a file. + m_settings->set("iconKey", val); + emit propertiesChanged(this); +} + +QString BaseInstance::iconKey() const +{ + return m_settings->get("iconKey").toString(); +} + +void BaseInstance::setName(QString val) +{ + //FIXME: if no change, do not set. setting involves saving a file. + m_settings->set("name", val); + emit propertiesChanged(this); +} + +QString BaseInstance::name() const +{ + return m_settings->get("name").toString(); +} + +QString BaseInstance::windowTitle() const +{ + return "MultiMC: " + name(); +} + +QStringList BaseInstance::extraArguments() const +{ + return Commandline::splitArgs(settings()->get("JvmArgs").toString()); +} diff --git a/api/logic/BaseInstance.h b/api/logic/BaseInstance.h new file mode 100644 index 00000000..5e587c48 --- /dev/null +++ b/api/logic/BaseInstance.h @@ -0,0 +1,243 @@ +/* Copyright 2013-2015 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include +#include + +#include "settings/SettingsObject.h" + +#include "settings/INIFile.h" +#include "BaseVersionList.h" +#include "minecraft/auth/MojangAccount.h" +#include "launch/MessageLevel.h" +#include "pathmatcher/IPathMatcher.h" + +#include "multimc_logic_export.h" + +class QDir; +class Task; +class LaunchTask; +class BaseInstance; + +// pointer for lazy people +typedef std::shared_ptr InstancePtr; + +/*! + * \brief Base class for instances. + * This class implements many functions that are common between instances and + * provides a standard interface for all instances. + * + * To create a new instance type, create a new class inheriting from this class + * and implement the pure virtual functions. + */ +class MULTIMC_LOGIC_EXPORT BaseInstance : public QObject, public std::enable_shared_from_this +{ + Q_OBJECT +protected: + /// no-touchy! + BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir); + +public: + /// virtual destructor to make sure the destruction is COMPLETE + virtual ~BaseInstance() {}; + + virtual void copy(const QDir &newDir) {} + + virtual void init() = 0; + + /// nuke thoroughly - deletes the instance contents, notifies the list/model which is + /// responsible of cleaning up the husk + void nuke(); + + /// The instance's ID. The ID SHALL be determined by MMC internally. The ID IS guaranteed to + /// be unique. + virtual QString id() const; + + void setRunning(bool running); + bool isRunning() const; + int64_t totalTimePlayed() const; + void resetTimePlayed(); + + /// get the type of this instance + QString instanceType() const; + + /// Path to the instance's root directory. + QString instanceRoot() const; + + QString name() const; + void setName(QString val); + + /// Value used for instance window titles + QString windowTitle() const; + + QString iconKey() const; + void setIconKey(QString val); + + QString notes() const; + void setNotes(QString val); + + QString group() const; + void setGroupInitial(QString val); + void setGroupPost(QString val); + + QString getPreLaunchCommand(); + QString getPostExitCommand(); + QString getWrapperCommand(); + + /// guess log level from a line of game log + virtual MessageLevel::Enum guessLevel(const QString &line, MessageLevel::Enum level) + { + return level; + }; + + virtual QStringList extraArguments() const; + + virtual QString intendedVersionId() const = 0; + virtual bool setIntendedVersionId(QString version) = 0; + + /*! + * The ins