MiKTeX 23.10-next
A scalable TeX distribution
Loading...
Searching...
No Matches
PackageInstaller.h
1/* miktex/PackageManager/PackageInstaller.h: -*- C++ -*-
2
3 Copyright (C) 2001-2021 Christian Schenk
4
5 This file is part of MiKTeX Package Manager.
6
7 MiKTeX Package Manager is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2, or
10 (at your option) any later version.
11
12 MiKTeX Package Manager is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
14 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with MiKTeX Package Manager; if not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA. */
21
22#pragma once
23
24#if !defined(E22949C2ACEF4F1DB1F4008919909456)
25#define E22949C2ACEF4F1DB1F4008919909456
26
27#include "config.h"
28
29#include <cstddef>
30#include <ctime>
31
32#include <string>
33#include <vector>
34
35#include <miktex/Util/OptionSet>
36#include <miktex/Util/PathName>
37
38#include "RepositoryInfo.h"
39#include "definitions.h"
40
41MIKTEX_PACKAGES_BEGIN_NAMESPACE;
42
45{
46 FromCache,
47};
48
49typedef MiKTeX::Util::OptionSet<UpdateDbOption> UpdateDbOptionSet;
50
52enum class Notification
53{
54 None = 0,
75};
76
78class MIKTEXNOVTABLE PackageInstallerCallback
79{
83public:
84 virtual void MIKTEXTHISCALL ReportLine(const std::string& str) = 0;
85
90public:
91 virtual bool MIKTEXTHISCALL OnRetryableError(const std::string& message) = 0;
92
98public:
99 virtual bool MIKTEXTHISCALL OnProgress(Notification nf) = 0;
100};
101
102class MIKTEXNOVTABLE PackageInstaller
103{
104public:
105 virtual MIKTEXTHISCALL ~PackageInstaller() noexcept = 0;
106
108public:
109 virtual void MIKTEXTHISCALL Dispose() = 0;
110
114public:
115 virtual void MIKTEXTHISCALL SetRepository(const std::string& repository) = 0;
116
119public:
120 virtual void MIKTEXTHISCALL SetDownloadDirectory(const MiKTeX::Util::PathName& directory) = 0;
121
123public:
124 virtual void MIKTEXTHISCALL UpdateDb(UpdateDbOptionSet options) = 0;
125
128public:
129 virtual void MIKTEXTHISCALL UpdateDbAsync() = 0;
130
132public:
133 virtual void MIKTEXTHISCALL FindUpdates() = 0;
134
137public:
138 virtual void MIKTEXTHISCALL FindUpdatesAsync() = 0;
139
141public:
143 {
145 std::string packageId;
146
148 std::time_t timePackaged = InvalidTimeT;
149
151 std::string version;
152
154 enum Action {
155 None,
172 ReleaseStateChange
173 };
174
176 Action action = None;
177 };
178
181public:
182 virtual std::vector<UpdateInfo> MIKTEXTHISCALL GetUpdates() = 0;
183
186public:
187 virtual void MIKTEXTHISCALL FindUpgrades(PackageLevel packageLevel) = 0;
188
191public:
192 virtual void MIKTEXTHISCALL FindUpgradesAsync(PackageLevel packageLevel) = 0;
193
195public:
197 {
199 std::string packageId;
201 std::time_t timePackaged = InvalidTimeT;
203 std::string version;
204 };
205
208public:
209 virtual std::vector<UpgradeInfo> MIKTEXTHISCALL GetUpgrades() = 0;
210
212public:
213 enum class Role
214 {
216 Application,
218 Installer,
220 Updater
221 };
222
225public:
226 virtual void MIKTEXTHISCALL InstallRemove(Role role) = 0;
227
231public:
232 virtual void MIKTEXTHISCALL InstallRemoveAsync(Role role) = 0;
233
235public:
236 virtual void MIKTEXTHISCALL WaitForCompletion() = 0;
237
241public:
242 virtual void MIKTEXTHISCALL Download() = 0;
243
248public:
249 virtual void MIKTEXTHISCALL DownloadAsync() = 0;
250
252public:
254 {
256 std::string packageId;
257
259 std::string displayName;
260
263
265 unsigned long cFilesRemoveCompleted = 0;
266
268 unsigned long cFilesRemoveTotal = 0;
269
271 unsigned long cPackagesRemoveCompleted = 0;
272
274 unsigned long cPackagesRemoveTotal = 0;
275
277 std::size_t cbPackageDownloadCompleted = 0;
278
280 std::size_t cbPackageDownloadTotal = 0;
281
283 std::size_t cbDownloadCompleted = 0;
284
286 std::size_t cbDownloadTotal = 0;
287
289 std::size_t cFilesPackageInstallCompleted = 0;
290
292 unsigned long cFilesPackageInstallTotal = 0;
293
295 unsigned long cFilesInstallCompleted = 0;
296
298 unsigned long cFilesInstallTotal = 0;
299
301 unsigned long cPackagesInstallCompleted = 0;
302
304 unsigned long cPackagesInstallTotal = 0;
305
307 std::size_t cbPackageInstallCompleted = 0;
308
310 std::size_t cbPackageInstallTotal = 0;
311
313 std::size_t cbInstallCompleted = 0;
314
316 std::size_t cbInstallTotal = 0;
317
319 unsigned long bytesPerSecond = 0;
320
322 unsigned long timeRemaining = 0;
323
325 bool ready = false;
326
328 unsigned numErrors = 0;
329
331 bool cancelled = false;
332 };
333
336public:
337 virtual ProgressInfo MIKTEXTHISCALL GetProgressInfo() = 0;
338
341public:
342 virtual void MIKTEXTHISCALL SetCallback(PackageInstallerCallback* callback) = 0;
343
347public:
348 virtual void MIKTEXTHISCALL SetFileLists(const std::vector<std::string>& toBeInstalled, const std::vector<std::string>& toBeRemoved) = 0;
349
352public:
353 virtual void MIKTEXTHISCALL SetPackageLevel(PackageLevel packageLevel) = 0;
354
357public:
358 virtual void MIKTEXTHISCALL SetFileList(const std::vector<std::string>& toBeInstalled) = 0;
359
362public:
363 virtual bool MIKTEXTHISCALL IsRunning() const = 0;
364
367public:
368 virtual void MIKTEXTHISCALL RegisterComponents(bool postInstall) = 0;
369
371public:
372 struct InitInfo
373 {
374 InitInfo() = default;
375 InitInfo(const InitInfo& other) = default;
376 InitInfo& operator=(const InitInfo& other) = default;
377 InitInfo(InitInfo&& other) = default;
378 InitInfo& operator=(InitInfo&& other) = default;
379 ~InitInfo() = default;
381 PackageInstallerCallback* callback = nullptr;
385 bool unattended = false;
387 bool enablePostProcessing = true;
388 };
389};
390
391MIKTEX_PACKAGES_END_NAMESPACE;
392
393#endif
Callback interface.
Definition: PackageInstaller.h:79
virtual bool OnRetryableError(const std::string &message)=0
virtual void ReportLine(const std::string &str)=0
virtual bool OnProgress(Notification nf)=0
Definition: PackageInstaller.h:103
virtual void InstallRemoveAsync(Role role)=0
virtual void SetDownloadDirectory(const MiKTeX::Util::PathName &directory)=0
virtual void UpdateDb(UpdateDbOptionSet options)=0
Synchronizes the package database.
virtual void Dispose()=0
Releases all resources used by this package installer object.
virtual void FindUpgrades(PackageLevel packageLevel)=0
virtual void SetRepository(const std::string &repository)=0
virtual void SetPackageLevel(PackageLevel packageLevel)=0
virtual void RegisterComponents(bool postInstall)=0
virtual void SetCallback(PackageInstallerCallback *callback)=0
virtual void WaitForCompletion()=0
Waits for the started thread to complete.
virtual void FindUpgradesAsync(PackageLevel packageLevel)=0
virtual bool IsRunning() const =0
virtual std::vector< UpgradeInfo > GetUpgrades()=0
virtual ProgressInfo GetProgressInfo()=0
virtual void FindUpdates()=0
Checks for updates.
virtual std::vector< UpdateInfo > GetUpdates()=0
virtual void SetFileLists(const std::vector< std::string > &toBeInstalled, const std::vector< std::string > &toBeRemoved)=0
virtual void SetFileList(const std::vector< std::string > &toBeInstalled)=0
Role
Installation role.
Definition: PackageInstaller.h:214
virtual void InstallRemove(Role role)=0
Definition: OptionSet.h:37
Instances of this class can be used to store path names.
Definition: PathName.h:73
Notification
Installer notifications.
Definition: PackageInstaller.h:53
@ RemoveFileStart
File removal is about to start.
@ InstallFileStart
File installation is about to start.
@ DownloadPackageEnd
Package download has finished.
@ RemoveFileEnd
File removal has finished.
@ DownloadPackageStart
Package download is about to start.
@ RemovePackageEnd
Package removal has finished.
@ InstallPackageStart
Package installation is about to start.
@ RemovePackageStart
Package removal is about to start.
@ InstallPackageEnd
Package installation has finished.
@ InstallFileEnd
File installation has finished.
constexpr std::time_t InvalidTimeT
An invalid timestamp.
Definition: definitions.h:30
UpdateDbOption
UpdateDb options.
Definition: PackageInstaller.h:45
PackageLevel
Package level.
Definition: RepositoryInfo.h:40
Initialization options.
Definition: PackageInstaller.h:373
Progress information.
Definition: PackageInstaller.h:254
std::string packageId
ID of the current package.
Definition: PackageInstaller.h:256
MiKTeX::Util::PathName fileName
Path name of current file.
Definition: PackageInstaller.h:262
std::string displayName
Display name of package.
Definition: PackageInstaller.h:259
Update information record.
Definition: PackageInstaller.h:143
Action
Update actions.
Definition: PackageInstaller.h:154
@ KeepAdmin
No permission to remove.
Definition: PackageInstaller.h:160
@ Update
Optional update.
Definition: PackageInstaller.h:164
@ Repair
Package has been tampered with.
Definition: PackageInstaller.h:170
@ KeepObsolete
Should be removed.
Definition: PackageInstaller.h:162
@ Keep
Definition: PackageInstaller.h:158
@ ForceRemove
Required deletion.
Definition: PackageInstaller.h:168
@ ForceUpdate
Required update.
Definition: PackageInstaller.h:166
std::string packageId
Package ID.
Definition: PackageInstaller.h:145
std::string version
Informal version informtion.
Definition: PackageInstaller.h:151
Upgrade information record.
Definition: PackageInstaller.h:197
std::string packageId
ID of an upgradaeble package.
Definition: PackageInstaller.h:199
std::string version
Informal version information.
Definition: PackageInstaller.h:203