AusweisApp2
UpdatableFile.h
gehe zur Dokumentation dieser Datei
1 
10 #pragma once
11 
12 #include "GlobalStatus.h"
13 
14 #include <QObject>
15 #include <QUrl>
16 
17 #include <functional>
18 
19 class test_UpdatableFile;
20 class test_ReaderConfiguration;
21 
22 
23 namespace governikus
24 {
26  : public QObject
27 {
28  Q_OBJECT
29 
30  private:
31  friend class ::test_UpdatableFile;
32  friend class ::test_ReaderConfiguration;
33 
34  const QString mSection;
35  const QString mName;
36  QString mDefaultPath;
37  const QString mSectionCachePath;
38  const QUrl mUpdateUrl;
39  bool mUpdateRunning;
40 
41  [[nodiscard]] const QString& getName() const;
42  [[nodiscard]] QDateTime cacheTimestamp() const;
43  [[nodiscard]] const QString& getSectionCachePath() const;
44 
45  [[nodiscard]] QString qrcPath() const;
46  [[nodiscard]] QString cachePath() const;
47  [[nodiscard]] QUrl updateUrl(const QString& pSection, const QString& pName) const;
48  [[nodiscard]] QString dirtyFilePath() const;
49  [[nodiscard]] QString sectionCachePath(const QString& pSection) const;
50  [[nodiscard]] QString makeSectionCachePath(const QString& pSection) const;
51  void cleanupAfterUpdate(const std::function<void()>& pCustomAction);
52  bool writeDataToFile(const QByteArray& pData, const QString& pFilePath, bool pOverwrite = false);
53 
54  private Q_SLOTS:
55  void onDownloadSuccess(const QUrl& pUpdateUrl, const QDateTime& pNewTimestamp, const QByteArray& pData);
56  void onDownloadFailed(const QUrl& pUpdateUrl, GlobalStatus::Code pErrorCode);
57  void onDownloadUnnecessary(const QUrl& pUpdateUrl);
58 
59  public:
60  UpdatableFile(const QString& pSection, const QString& pName, const QString& pDefaultPath = QString());
61  ~UpdatableFile() override = default;
62 
63  QUrl lookupUrl();
64  QString lookupPath();
65  bool forEachLookupPath(const std::function<bool(const QString&)>& pValidate);
66 
67  void setDefaultPath(const QString& pPath);
68  [[nodiscard]] const QString& getDefaultPath() const;
69 
70  void update();
71  [[nodiscard]] bool isDirty() const;
72  void clearDirty() const;
73  void markDirty() const;
74 
75  Q_SIGNALS:
76  void fireUpdated();
78 
79 };
80 
81 } // namespace governikus
governikus::UpdatableFile
Definition: UpdatableFile.h:27
governikus::UpdatableFile::markDirty
void markDirty() const
Definition: UpdatableFile.cpp:394
governikus::UpdatableFile::setDefaultPath
void setDefaultPath(const QString &pPath)
Definition: UpdatableFile.cpp:333
governikus::UpdatableFile::update
void update()
Definition: UpdatableFile.cpp:348
governikus::GlobalStatus::Code
Code
Definition: GlobalStatus.h:26
SecureStorage.h
UpdatableFile.h
governikus::UpdatableFile::fireNoUpdateAvailable
void fireNoUpdateAvailable()
governikus::UpdatableFile::UpdatableFile
UpdatableFile(const QString &pSection, const QString &pName, const QString &pDefaultPath=QString())
Definition: UpdatableFile.cpp:236
governikus::UpdatableFile::lookupPath
QString lookupPath()
Definition: UpdatableFile.cpp:266
governikus::Downloader::fireDownloadFailed
void fireDownloadFailed(const QUrl &pUpdateUrl, GlobalStatus::Code pErrorCode)
governikus::UpdatableFile::forEachLookupPath
bool forEachLookupPath(const std::function< bool(const QString &)> &pValidate)
Definition: UpdatableFile.cpp:294
GlobalStatus.h
governikus
Implementation of ActivationContext for Intent based activation on Android systems.
Definition: ActivationContext.h:15
governikus::UpdatableFile::clearDirty
void clearDirty() const
Definition: UpdatableFile.cpp:376
governikus::UpdatableFile::getDefaultPath
const QString & getDefaultPath() const
Definition: UpdatableFile.cpp:342
governikus::UpdatableFile::isDirty
bool isDirty() const
Definition: UpdatableFile.cpp:365
governikus::UpdatableFile::lookupUrl
QUrl lookupUrl()
Definition: UpdatableFile.cpp:252
Downloader.h
governikus::Downloader::fireDownloadUnnecessary
void fireDownloadUnnecessary(const QUrl &pUpdateUrl)
governikus::UpdatableFile::~UpdatableFile
~UpdatableFile() override=default
governikus::Downloader::fireDownloadSuccess
void fireDownloadSuccess(const QUrl &pUpdateUrl, const QDateTime &pNewTimestamp, const QByteArray &pData)
governikus::UpdatableFile::fireUpdated
void fireUpdated()