MiKTeX 26.5-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
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:
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;
203 std::string version;
204 };
205
208public:
209 virtual std::vector<UpgradeInfo> MIKTEXTHISCALL GetUpgrades() = 0;
210
212public:
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
278
280 std::size_t cbPackageDownloadTotal = 0;
281
283 std::size_t cbDownloadCompleted = 0;
284
286 std::size_t cbDownloadTotal = 0;
287
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
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;
385 bool unattended = false;
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
@ Updater
Updater.
Definition PackageInstaller.h:220
@ Installer
Installer (setup) program.
Definition PackageInstaller.h:218
@ Application
Regular application.
Definition PackageInstaller.h:216
virtual void InstallRemove(Role role)=0
Definition OptionSet.h:26
Instances of this class can be used to store path names.
Definition PathName.h:64
Notification
Installer notifications.
Definition PackageInstaller.h:53
@ RemoveFileStart
File removal is about to start.
Definition PackageInstaller.h:68
@ InstallFileStart
File installation is about to start.
Definition PackageInstaller.h:60
@ DownloadPackageEnd
Package download has finished.
Definition PackageInstaller.h:58
@ RemoveFileEnd
File removal has finished.
Definition PackageInstaller.h:70
@ DownloadPackageStart
Package download is about to start.
Definition PackageInstaller.h:56
@ RemovePackageEnd
Package removal has finished.
Definition PackageInstaller.h:74
@ InstallPackageStart
Package installation is about to start.
Definition PackageInstaller.h:64
@ RemovePackageStart
Package removal is about to start.
Definition PackageInstaller.h:72
@ InstallPackageEnd
Package installation has finished.
Definition PackageInstaller.h:66
@ InstallFileEnd
File installation has finished.
Definition PackageInstaller.h:62
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
bool unattended
Indicates whether to operate in unattended mode.
Definition PackageInstaller.h:385
bool enablePostProcessing
Indicates whether to enable or disable post-processing.
Definition PackageInstaller.h:387
PackageInstallerCallback * callback
Pointer to an object implementing the callback interface.
Definition PackageInstaller.h:381
Progress information.
Definition PackageInstaller.h:254
unsigned long cFilesRemoveTotal
Number of files to be removed.
Definition PackageInstaller.h:268
std::size_t cbPackageInstallTotal
Number of bytes to be written (current package).
Definition PackageInstaller.h:310
unsigned long cFilesRemoveCompleted
Number of removed files.
Definition PackageInstaller.h:265
unsigned long cFilesInstallTotal
Number of files to be installed.
Definition PackageInstaller.h:298
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
unsigned long bytesPerSecond
Current transfer speed.
Definition PackageInstaller.h:319
std::size_t cbPackageDownloadTotal
Number of bytes to be received (current package).
Definition PackageInstaller.h:280
std::size_t cbPackageInstallCompleted
Number of written bytes (current package).
Definition PackageInstaller.h:307
std::size_t cbDownloadCompleted
Number of bytes received.
Definition PackageInstaller.h:283
unsigned long cPackagesInstallTotal
Number of packages to be installed.
Definition PackageInstaller.h:304
std::size_t cbDownloadTotal
Number of bytes to be received.
Definition PackageInstaller.h:286
unsigned long cFilesInstallCompleted
Number of installed files.
Definition PackageInstaller.h:295
std::string displayName
Display name of package.
Definition PackageInstaller.h:259
std::size_t cFilesPackageInstallCompleted
Number of installed files (current package).
Definition PackageInstaller.h:289
unsigned long cPackagesRemoveCompleted
Number of removed packages.
Definition PackageInstaller.h:271
std::size_t cbPackageDownloadCompleted
Number of received bytes (current package).
Definition PackageInstaller.h:277
unsigned numErrors
Number of errors.
Definition PackageInstaller.h:328
bool cancelled
Indicates whether the current operation has been cancelled.
Definition PackageInstaller.h:331
bool ready
Ready flag.
Definition PackageInstaller.h:325
std::size_t cbInstallTotal
Number of bytes to be written.
Definition PackageInstaller.h:316
unsigned long cPackagesInstallCompleted
Number of installed packages.
Definition PackageInstaller.h:301
std::size_t cbInstallCompleted
Number of bytes written.
Definition PackageInstaller.h:313
unsigned long cFilesPackageInstallTotal
Number of files to be installed (current package).
Definition PackageInstaller.h:292
unsigned long cPackagesRemoveTotal
Number of packages to be removed.
Definition PackageInstaller.h:274
unsigned long timeRemaining
Estimated time of arrival (millisecs remaining).
Definition PackageInstaller.h:322
Update information record.
Definition PackageInstaller.h:143
Action action
The action to take.
Definition PackageInstaller.h:176
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
@ ReleaseStateChange
Release channel has changed.
Definition PackageInstaller.h:172
std::string packageId
Package ID.
Definition PackageInstaller.h:145
std::time_t timePackaged
Date/Time the package was created.
Definition PackageInstaller.h:148
std::string version
Informal version informtion.
Definition PackageInstaller.h:151
Upgrade information record.
Definition PackageInstaller.h:197
std::time_t timePackaged
Packaging timestamp.
Definition PackageInstaller.h:201
std::string packageId
ID of an upgradaeble package.
Definition PackageInstaller.h:199
std::string version
Informal version information.
Definition PackageInstaller.h:203