AusweisApp2
ApplicationModel.h
gehe zur Dokumentation dieser Datei
1 
7 #pragma once
8 
9 #include "Env.h"
10 #include "ReaderInfo.h"
12 #include "WifiInfo.h"
14 
15 #include <QObject>
16 #include <QQmlEngine>
17 #include <QSharedPointer>
18 #include <QStringList>
19 #include <QTimer>
20 
21 #ifdef Q_OS_IOS
22 Q_FORWARD_DECLARE_OBJC_CLASS(VoiceOverObserver);
23 #endif
24 
25 namespace governikus
26 {
27 
29  : public QObject
30 {
31  Q_OBJECT
32  friend class Env;
33 
34  Q_PROPERTY(QString storeUrl READ getStoreUrl NOTIFY fireStoreUrlChanged)
35  Q_PROPERTY(QUrl releaseNotesUrl READ getReleaseNotesUrl CONSTANT)
36 
37  Q_PROPERTY(QmlNfcState nfcState READ getNfcState NOTIFY fireNfcStateChanged)
39 
40  Q_PROPERTY(qreal scaleFactor READ getScaleFactor WRITE setScaleFactor NOTIFY fireScaleFactorChanged)
41  Q_PROPERTY(bool wifiEnabled READ isWifiEnabled NOTIFY fireWifiEnabledChanged)
42 
45 
46  Q_PROPERTY(QString feedback READ getFeedback NOTIFY fireFeedbackChanged)
47 
48 #if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
49  Q_PROPERTY(QUrl customConfigPath READ getCustomConfigPath CONSTANT)
50 #endif
51 
52  private:
53  QSharedPointer<WorkflowContext> mContext;
54  constexpr static qreal DEFAULT_SCALE_FACTOR = 0.6;
55  qreal mScaleFactor;
56  WifiInfo mWifiInfo;
57  bool mWifiEnabled;
58  QStringList mFeedback;
59  QTimer mFeedbackTimer;
60  const int mFeedbackDisplayLength;
61  bool mIsAppInForeground;
62 #ifdef Q_OS_IOS
63  struct Private
64  {
65  Private();
66  ~Private();
67  VoiceOverObserver* const mObserver;
68  };
69  const QScopedPointer<Private> mPrivate;
70 #endif
71 
73  ~ApplicationModel() override = default;
74  void onStatusChanged(const ReaderManagerPlugInInfo& pInfo);
75  ReaderManagerPlugInInfo getFirstPlugInInfo(ReaderManagerPlugInType pType) const;
76 
77  private Q_SLOTS:
78  void onApplicationStateChanged(Qt::ApplicationState pState);
79  void onWifiEnabledChanged();
80 
81  public Q_SLOTS:
82  void onTranslationChanged();
83 
84  public:
85  enum class Settings
86  {
91  };
92  Q_ENUM(Settings)
93 
94  enum class Workflow
95  {
96  WORKFLOW_CHANGE_PIN,
97  WORKFLOW_SELF_AUTHENTICATION,
98  WORKFLOW_AUTHENTICATION,
99  WORKFLOW_SMART,
100  WORKFLOW_NONE
101  };
102  Q_ENUM(Workflow)
103 
104  enum class QmlNfcState
105  {
106  NFC_UNAVAILABLE,
107  NFC_DISABLED,
108  NFC_INACTIVE,
109  NFC_READY
110  };
111  Q_ENUM(QmlNfcState)
112 
113  void resetContext(const QSharedPointer<WorkflowContext>& pContext = QSharedPointer<WorkflowContext>());
114 
115  Q_INVOKABLE int randomInt(int pLowerBound, int pUpperBound) const;
116 
117  QString getStoreUrl() const;
118  QUrl getReleaseNotesUrl() const;
119 
120  QmlNfcState getNfcState() const;
122 
123  bool isWifiEnabled() const;
124  qreal getScaleFactor() const;
125  void setScaleFactor(qreal pScaleFactor);
126 
128  int getAvailableReader() const;
129 
130  QString getFeedback() const;
131 
132  Q_INVOKABLE bool isScreenReaderRunning() const;
133 
134  Q_INVOKABLE bool isReaderTypeAvailable(ReaderManagerPlugInType pPlugInType) const;
135 
136  Q_INVOKABLE void enableWifi();
137 
138  Q_INVOKABLE void setClipboardText(const QString& pText) const;
139  Q_INVOKABLE void showSettings(const Settings& pAction);
140  Q_INVOKABLE void showFeedback(const QString& pMessage, bool pReplaceExisting = false);
141  Q_INVOKABLE void keepScreenOn(bool pActive);
142  Q_INVOKABLE QStringList getLicenseText() const;
143 #if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
144  Q_INVOKABLE QString onlineHelpUrl(const QString& pHelpSectionName);
145  Q_INVOKABLE void openOnlineHelp(const QString& pHelpSectionName);
146  Q_INVOKABLE QUrl getCustomConfigPath();
147  Q_INVOKABLE void saveEmbeddedConfig(const QUrl& pFilename);
148 #endif
149  Q_INVOKABLE QString stripHtmlTags(QString pString) const;
150 #ifdef Q_OS_IOS
151  Q_INVOKABLE void showAppStoreRatingDialog();
152 #endif
153 
154  public Q_SLOTS:
155  Q_INVOKABLE void onShowNextFeedback();
156 
157  Q_SIGNALS:
159 
162 
165 
168 
170 
171  void fireApplicationStateChanged(bool pIsAppInForeground);
172 };
173 
174 
175 } // namespace governikus
Definition: ApplicationModel.h:30
Q_INVOKABLE void showFeedback(const QString &pMessage, bool pReplaceExisting=false)
Definition: ApplicationModel.cpp:319
Q_INVOKABLE void openOnlineHelp(const QString &pHelpSectionName)
Definition: ApplicationModel.cpp:429
QString storeUrl
Definition: ApplicationModel.h:34
Q_INVOKABLE QStringList getLicenseText() const
Definition: ApplicationModel.cpp:396
qreal getScaleFactor() const
Definition: ApplicationModel.cpp:208
bool isWifiEnabled() const
Definition: ApplicationModel.cpp:202
Q_INVOKABLE QString stripHtmlTags(QString pString) const
Definition: ApplicationModel.cpp:495
QUrl customConfigPath
Definition: ApplicationModel.h:49
Q_INVOKABLE bool isReaderTypeAvailable(ReaderManagerPlugInType pPlugInType) const
Definition: ApplicationModel.cpp:261
Q_INVOKABLE void saveEmbeddedConfig(const QUrl &pFilename)
Definition: ApplicationModel.cpp:444
Q_INVOKABLE int randomInt(int pLowerBound, int pUpperBound) const
Definition: ApplicationModel.cpp:105
Q_INVOKABLE QUrl getCustomConfigPath()
Definition: ApplicationModel.cpp:435
Settings
Definition: ApplicationModel.h:86
QString feedback
Definition: ApplicationModel.h:46
void fireApplicationStateChanged(bool pIsAppInForeground)
qreal scaleFactor
Definition: ApplicationModel.h:40
QmlNfcState
Definition: ApplicationModel.h:105
QmlNfcState nfcState
Definition: ApplicationModel.h:37
Workflow
Definition: ApplicationModel.h:95
Q_INVOKABLE void keepScreenOn(bool pActive)
Definition: ApplicationModel.cpp:373
bool wifiEnabled
Definition: ApplicationModel.h:41
void resetContext(const QSharedPointer< WorkflowContext > &pContext=QSharedPointer< WorkflowContext >())
Definition: ApplicationModel.cpp:87
QUrl getReleaseNotesUrl() const
Definition: ApplicationModel.cpp:133
QUrl releaseNotesUrl
Definition: ApplicationModel.h:35
Workflow getCurrentWorkflow() const
Definition: ApplicationModel.cpp:226
Q_INVOKABLE void enableWifi()
Definition: ApplicationModel.cpp:487
void onTranslationChanged()
Definition: ApplicationModel.cpp:481
Q_INVOKABLE QString onlineHelpUrl(const QString &pHelpSectionName)
Definition: ApplicationModel.cpp:423
int availableReader
Definition: ApplicationModel.h:44
Q_INVOKABLE void showSettings(const Settings &pAction)
Definition: ApplicationModel_android.cpp:40
Workflow currentWorkflow
Definition: ApplicationModel.h:43
Q_INVOKABLE void onShowNextFeedback()
Definition: ApplicationModel.cpp:301
int getAvailableReader() const
Definition: ApplicationModel.cpp:250
bool isExtendedLengthApdusUnsupported() const
Definition: ApplicationModel.cpp:184
bool extendedLengthApdusUnsupported
Definition: ApplicationModel.h:38
Q_INVOKABLE void setClipboardText(const QString &pText) const
Definition: ApplicationModel.cpp:313
void setScaleFactor(qreal pScaleFactor)
Definition: ApplicationModel.cpp:214
QmlNfcState getNfcState() const
Definition: ApplicationModel.cpp:155
QString getStoreUrl() const
Definition: ApplicationModel.cpp:112
Q_INVOKABLE bool isScreenReaderRunning() const
Definition: ApplicationModel.cpp:278
QString getFeedback() const
Definition: ApplicationModel.cpp:295
Definition: Env.h:44
Definition: WifiInfo.h:20
A simple template renderer.
Definition: ActivationContext.h:15