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  friend class ::test_UpdatableFile;
30  friend class ::test_ReaderConfiguration;
31 
32  private:
33  const QString mSection;
34  const QString mName;
35  QString mDefaultPath;
36  const QString mSectionCachePath;
37  const QUrl mUpdateUrl;
38  bool mUpdateRunning;
39 
40  [[nodiscard]] const QString& getName() const;
41  [[nodiscard]] QDateTime cacheTimestamp() const;
42  [[nodiscard]] const QString& getSectionCachePath() const;
43 
44  [[nodiscard]] QString qrcPath() const;
45  [[nodiscard]] QString cachePath() const;
46  [[nodiscard]] QUrl updateUrl(const QString& pSection, const QString& pName) const;
47  [[nodiscard]] QString dirtyFilePath() const;
48  [[nodiscard]] QString sectionCachePath(const QString& pSection) const;
49  [[nodiscard]] QString makeSectionCachePath(const QString& pSection) const;
50  void cleanupAfterUpdate(const std::function<void()>& pCustomAction);
51  bool writeDataToFile(const QByteArray& pData, const QString& pFilePath, bool pOverwrite = false);
52 
53  private Q_SLOTS:
54  void onDownloadSuccess(const QUrl& pUpdateUrl, const QDateTime& pNewTimestamp, const QByteArray& pData);
55  void onDownloadFailed(const QUrl& pUpdateUrl, GlobalStatus::Code pErrorCode);
56  void onDownloadUnnecessary(const QUrl& pUpdateUrl);
57 
58  public:
59  UpdatableFile(const QString& pSection, const QString& pName, const QString& pDefaultPath = QString());
60  ~UpdatableFile() override = default;
61 
62  QUrl lookupUrl();
63  QString lookupPath();
64  bool forEachLookupPath(const std::function<bool(const QString&)>& pValidate);
65 
66  void setDefaultPath(const QString& pPath);
67  [[nodiscard]] const QString& getDefaultPath() const;
68 
69  void update();
70  [[nodiscard]] bool isDirty() const;
71  void clearDirty() const;
72  void markDirty() const;
73 
74  Q_SIGNALS:
75  void fireUpdated();
77 
78 };
79 
80 } // namespace governikus
Code
Definition: GlobalStatus.h:26
Definition: UpdatableFile.h:27
void clearDirty() const
Definition: UpdatableFile.cpp:372
bool forEachLookupPath(const std::function< bool(const QString &)> &pValidate)
Definition: UpdatableFile.cpp:294
~UpdatableFile() override=default
bool isDirty() const
Definition: UpdatableFile.cpp:361
UpdatableFile(const QString &pSection, const QString &pName, const QString &pDefaultPath=QString())
Definition: UpdatableFile.cpp:236
const QString & getDefaultPath() const
Definition: UpdatableFile.cpp:338
QUrl lookupUrl()
Definition: UpdatableFile.cpp:252
void update()
Definition: UpdatableFile.cpp:344
void setDefaultPath(const QString &pPath)
Definition: UpdatableFile.cpp:329
QString lookupPath()
Definition: UpdatableFile.cpp:266
void markDirty() const
Definition: UpdatableFile.cpp:390
Implementation of GeneralAuthenticate response APDUs.
Definition: CommandApdu.h:16