AusweisApp2
ApplicationModel.h
gehe zur Dokumentation dieser Datei
1 
7 #pragma once
8 
10 #include "Env.h"
11 #include "ReaderInfo.h"
13 #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 packageName READ getPackageName CONSTANT)
35  Q_PROPERTY(QUrl releaseNotesUrl READ getReleaseNotesUrl CONSTANT)
36 
37  Q_PROPERTY(bool nfcEnabled READ isNfcEnabled NOTIFY fireNfcEnabledChanged)
38  Q_PROPERTY(bool nfcAvailable READ isNfcAvailable CONSTANT)
39  Q_PROPERTY(bool nfcRunning READ isNfcRunning WRITE setNfcRunning NOTIFY fireNfcRunningChanged)
41 
44  Q_PROPERTY(bool bluetoothAvailable READ isBluetoothAvailable CONSTANT)
46 
48  Q_PROPERTY(bool wifiEnabled READ isWifiEnabled NOTIFY fireWifiEnabledChanged)
49 
52 
53  Q_PROPERTY(QString feedback READ getFeedback NOTIFY fireFeedbackChanged)
54 
55  QSharedPointer<WorkflowContext> mContext;
56 
57  void onStatusChanged(const ReaderManagerPlugInInfo& pInfo);
58  ReaderManagerPlugInInfo getFirstPlugInInfo(ReaderManagerPlugInType pType) const;
59 
60  private:
61  constexpr static qreal DEFAULT_SCALE_FACTOR = 0.6;
62  qreal mScaleFactor;
63  WifiInfo mWifiInfo;
64  bool mWifiEnabled;
65  bool mBluetoothResponding;
66  QStringList mFeedback;
67  QTimer mFeedbackTimer;
68  const int mFeedbackDisplayLength;
69 #ifdef Q_OS_IOS
70  struct Private
71  {
72  Private();
73  ~Private();
74  VoiceOverObserver* const mObserver;
75  };
76  const QScopedPointer<Private> mPrivate;
77 #endif
78 
79  private Q_SLOTS:
80  void onWifiEnabledChanged();
81 
82  protected:
84  ~ApplicationModel() override = default;
85  static ApplicationModel& getInstance();
86 
87  public:
88  enum class Settings
89  {
94  };
95  Q_ENUM(Settings)
96 
97  void resetContext(const QSharedPointer<WorkflowContext>& pContext = QSharedPointer<WorkflowContext>());
98 
99  QString getPackageName() const;
100  QUrl getReleaseNotesUrl() const;
101 
102  bool isNfcAvailable() const;
103  bool isNfcEnabled() const;
104  bool isNfcRunning() const;
105  void setNfcRunning(bool pRunning);
107 
108  bool isBluetoothAvailable() const;
109  bool isBluetoothResponding() const;
110  bool isBluetoothEnabled() const;
111  void setBluetoothEnabled(bool pEnabled);
112  bool locationPermissionRequired() const;
113 
114  bool isWifiEnabled() const;
115  qreal getScaleFactor() const;
116  void setScaleFactor(qreal pScaleFactor);
117 
118  QString getCurrentWorkflow() const;
119  int getAvailableReader() const;
120 
121  QString getFeedback() const;
122 
123  Q_INVOKABLE bool isScreenReaderRunning() const;
124 
125  Q_INVOKABLE void stopNfcScanWithError(const QString& pError) const;
126 
127  Q_INVOKABLE bool isReaderTypeAvailable(ReaderManagerPlugInType pPlugInType) const;
128 
129  Q_INVOKABLE void enableWifi();
130 
131  Q_INVOKABLE void showSettings(const Settings& pAction);
132  Q_INVOKABLE void showSettings(const QString& pAction);
133  Q_INVOKABLE void showFeedback(const QString& pMessage, bool pReplaceExisting = false);
134  Q_INVOKABLE void keepScreenOn(bool pActive);
135 #if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
136  Q_INVOKABLE QString onlineHelpUrl(const QString& pHelpSectionName);
137  Q_INVOKABLE void openOnlineHelp(const QString& pHelpSectionName);
138 #endif
139  Q_INVOKABLE QString stripHtmlTags(QString pString) const;
140 #ifdef Q_OS_IOS
141  Q_INVOKABLE void showAppStoreRatingDialog();
142 #endif
143 
144  public Q_SLOTS:
145  Q_INVOKABLE void onShowNextFeedback();
146 
147  Q_SIGNALS:
148  void fireNfcEnabledChanged();
149  void fireNfcRunningChanged();
151 
155 
158 
159  void fireScaleFactorChanged();
160  void fireWifiEnabledChanged();
161  void fireCertificateRemoved(const QString& pDeviceName);
162 
163  void fireFeedbackChanged();
164 };
165 
166 
167 } // namespace governikus
bool bluetoothEnabled
Definition: ApplicationModel.h:42
void setBluetoothEnabled(bool pEnabled)
Definition: ApplicationModel.cpp:235
Q_INVOKABLE QString onlineHelpUrl(const QString &pHelpSectionName)
Definition: ApplicationModel.cpp:528
void fireCertificateRemoved(const QString &pDeviceName)
Definition: moc_ApplicationModel.cpp:527
Q_INVOKABLE bool isScreenReaderRunning() const
Definition: ApplicationModel.cpp:417
bool isWifiEnabled() const
Definition: ApplicationModel.cpp:268
bool wifiEnabled
Definition: ApplicationModel.h:48
bool isBluetoothResponding() const
Definition: ApplicationModel.cpp:223
Q_INVOKABLE void openOnlineHelp(const QString &pHelpSectionName)
Definition: ApplicationModel.cpp:534
QString getCurrentWorkflow() const
Definition: ApplicationModel.cpp:292
void fireBluetoothReaderChanged()
Definition: moc_ApplicationModel.cpp:497
bool isNfcEnabled() const
Definition: ApplicationModel.cpp:160
QString currentWorkflow
Definition: ApplicationModel.h:50
void fireCurrentWorkflowChanged()
Definition: moc_ApplicationModel.cpp:503
int getAvailableReader() const
Definition: ApplicationModel.cpp:310
QUrl getReleaseNotesUrl() const
Definition: ApplicationModel.cpp:126
Q_INVOKABLE QString stripHtmlTags(QString pString) const
Definition: ApplicationModel.cpp:566
void setScaleFactor(qreal pScaleFactor)
Definition: ApplicationModel.cpp:280
void setNfcRunning(bool pRunning)
Definition: ApplicationModel.cpp:178
qreal getScaleFactor() const
Definition: ApplicationModel.cpp:274
Q_INVOKABLE void keepScreenOn(bool pActive)
Definition: ApplicationModel.cpp:504
void fireBluetoothEnabledChanged()
Definition: moc_ApplicationModel.cpp:485
qreal scaleFactor
Definition: ApplicationModel.h:47
Q_INVOKABLE void showFeedback(const QString &pMessage, bool pReplaceExisting=false)
Definition: ApplicationModel.cpp:451
QString feedback
Definition: ApplicationModel.h:53
bool nfcAvailable
Definition: ApplicationModel.h:38
Implementation of ActivationContext for Intent based activation on Android systems.
Definition: ActivationContext.h:14
bool isNfcRunning() const
Definition: ApplicationModel.cpp:172
ApplicationModel()
Definition: ApplicationModel.cpp:63
void fireScaleFactorChanged()
Definition: moc_ApplicationModel.cpp:515
void fireReaderPropertiesUpdated()
Definition: moc_ApplicationModel.cpp:479
Definition: WorkflowContext.h:21
void fireNfcEnabledChanged()
Definition: moc_ApplicationModel.cpp:467
int availableReader
Definition: ApplicationModel.h:51
static ApplicationModel & getInstance()
Definition: ApplicationModel.cpp:560
void resetContext(const QSharedPointer< WorkflowContext > &pContext=QSharedPointer< WorkflowContext >())
Definition: ApplicationModel.cpp:96
void fireAvailableReaderChanged()
Definition: moc_ApplicationModel.cpp:509
Settings
Definition: ApplicationModel.h:88
bool isExtendedLengthApdusUnsupported() const
Definition: ApplicationModel.cpp:191
Q_INVOKABLE void enableWifi()
Definition: ApplicationModel.cpp:550
Q_INVOKABLE void onShowNextFeedback()
Definition: ApplicationModel.cpp:439
~ApplicationModel() override=default
void fireFeedbackChanged()
Definition: moc_ApplicationModel.cpp:534
QString getPackageName() const
Definition: ApplicationModel.cpp:114
Definition: Env.h:38
bool bluetoothAvailable
Definition: ApplicationModel.h:44
Q_INVOKABLE void showSettings(const Settings &pAction)
Definition: ApplicationModel.cpp:337
Q_INVOKABLE void stopNfcScanWithError(const QString &pError) const
Definition: ApplicationModel.cpp:210
void fireBluetoothRespondingChanged()
Definition: moc_ApplicationModel.cpp:491
bool isNfcAvailable() const
Definition: ApplicationModel.cpp:148
bool locationPermissionRequired() const
Definition: ApplicationModel.h:28
Q_INVOKABLE bool isReaderTypeAvailable(ReaderManagerPlugInType pPlugInType) const
Definition: ApplicationModel.cpp:321
bool bluetoothResponding
Definition: ApplicationModel.h:43
bool nfcRunning
Definition: ApplicationModel.h:39
Definition: WifiInfo.h:22
QUrl releaseNotesUrl
Definition: ApplicationModel.h:35
bool nfcEnabled
Definition: ApplicationModel.h:37
QString getFeedback() const
Definition: ApplicationModel.cpp:433
bool isBluetoothAvailable() const
Definition: ApplicationModel.cpp:217
bool isBluetoothEnabled() const
Definition: ApplicationModel.cpp:229
void fireNfcRunningChanged()
Definition: moc_ApplicationModel.cpp:473
bool extendedLengthApdusUnsupported
Definition: ApplicationModel.h:40
void fireWifiEnabledChanged()
Definition: moc_ApplicationModel.cpp:521
QString packageName
Definition: ApplicationModel.h:34