AusweisApp2
 Alle Klassen Namensbereiche Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Propertys Freundbeziehungen Makrodefinitionen
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  const QString& getName();
42  QDateTime cacheTimestamp() const;
43  const QString& getSectionCachePath() const;
44 
45  QString qrcPath() const;
46  QString cachePath() const;
47  QUrl updateUrl(const QString& pSection, const QString& pName);
48  QString dirtyFilePath() const;
49  QString sectionCachePath(const QString& pSection) const;
50  QString makeSectionCachePath(const QString& pSection);
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  virtual ~UpdatableFile() = default;
62 
63  QUrl lookupUrl();
64  QString lookupPath();
65  void setDefaultPath(const QString& pPath);
66  const QString& getDefaultPath() const;
67 
68  void update();
69  bool isDirty() const;
70  void clearDirty() const;
71  void markDirty() const;
72 
73  Q_SIGNALS:
74  void fireUpdated();
75 
76 };
77 
78 } // namespace governikus
Definition: UpdatableFile.h:25
Code
Definition: GlobalStatus.h:24
QUrl lookupUrl()
Definition: UpdatableFile.cpp:245
const QString & getDefaultPath() const
Definition: UpdatableFile.cpp:296
bool isDirty() const
Definition: UpdatableFile.cpp:327
void markDirty() const
Definition: UpdatableFile.cpp:356
QString lookupPath()
Definition: UpdatableFile.cpp:259
void update()
Definition: UpdatableFile.cpp:302
void clearDirty() const
Definition: UpdatableFile.cpp:338
virtual ~UpdatableFile()=default
UpdatableFile(const QString &pSection, const QString &pName, const QString &pDefaultPath=QString())
Definition: UpdatableFile.cpp:234
void setDefaultPath(const QString &pPath)
Definition: UpdatableFile.cpp:287