AusweisApp2
RemoteServiceModel.h
gehe zur Dokumentation dieser Datei
1 
7 #pragma once
8 
9 #include "Env.h"
10 #include "ReaderManager.h"
11 #include "RemoteDeviceModel.h"
12 #include "WorkflowModel.h"
13 #include "WorkflowRequest.h"
15 
16 #include <QObject>
17 #include <QQmlEngine>
18 
19 namespace governikus
20 {
21 
23  : public WorkflowModel
24 {
25  Q_OBJECT
26  friend class Env;
27 
28  Q_PROPERTY(bool running READ isRunning NOTIFY fireIsRunningChanged)
29  Q_PROPERTY(bool isStarting READ isStarting NOTIFY fireIsStartingChanged)
30  Q_PROPERTY(bool runnable READ isRunnable NOTIFY fireEnvironmentChanged)
31  Q_PROPERTY(bool canEnableNfc READ isCanEnableNfc NOTIFY fireEnvironmentChanged)
32  Q_PROPERTY(QString errorMessage READ getErrorMessage NOTIFY fireEnvironmentChanged)
33  Q_PROPERTY(bool isPairing READ isPairing NOTIFY firePskChanged)
34  Q_PROPERTY(QByteArray psk READ getPsk NOTIFY firePskChanged)
36  Q_PROPERTY(QString connectionInfo READ getConnectionInfo NOTIFY fireConnectionInfoChanged)
39  Q_PROPERTY(RemoteDeviceModel * knownDevices READ getKnownDevices CONSTANT)
43  Q_PROPERTY(bool requiresLocalNetworkPermission MEMBER mRequiresLocalNetworkPermission CONSTANT)
44 
45  private:
46  QSharedPointer<IfdServiceContext> mContext;
47  bool mRunnable;
48  bool mIsStarting;
49  bool mCanEnableNfc;
50  bool mPairingRequested;
51  QString mErrorMessage;
52  QByteArray mPsk;
53  RemoteDeviceModel mAvailableRemoteDevices;
54  RemoteDeviceModel mKnownDevices;
55  QString mConnectionInfo;
56  QString mConnectedServerDeviceNames;
57  QSharedPointer<IfdListEntry> mRememberedServerEntry;
58  const bool mRequiresLocalNetworkPermission;
59 #if defined(Q_OS_IOS)
60  bool mWasRunning;
61  bool mWasPairing;
62 #endif
63 
65  ~RemoteServiceModel() override = default;
66 
67  QString getErrorMessage(bool pNfcPluginAvailable, bool pNfcPluginEnabled, bool pWifiEnabled) const;
68 
69  void setStarting(bool pStarting);
70 
71  private Q_SLOTS:
72  void onEstablishConnectionDone(const QSharedPointer<IfdListEntry>& pEntry, const GlobalStatus& pStatus);
73  void onConnectionInfoChanged(bool pConnected);
74  void onCardConnected(const QSharedPointer<CardConnection>& pConnection);
75  void onCardDisconnected(const QSharedPointer<CardConnection>& pConnection);
76  void onConnectedDevicesChanged();
77  void onEnvironmentChanged();
78  void onApplicationStateChanged(const bool pIsAppInForeground);
79 
80  public Q_SLOTS:
81  void onTranslationChanged();
82 
83  public:
84  bool isRunning() const;
85  Q_INVOKABLE void setRunning(bool pState, bool pEnablePairing = false);
86  bool isStarting() const;
87 
90  void setDetectRemoteDevices(bool pNewStatus);
91  bool detectRemoteDevices() const;
92  Q_INVOKABLE bool rememberServer(const QString& pDeviceId);
93  Q_INVOKABLE void connectToRememberedServer(const QString& pServerPsk);
94 
95  void resetRemoteServiceContext(const QSharedPointer<IfdServiceContext>& pContext = QSharedPointer<IfdServiceContext>());
96  void setPairing(bool pEnabled);
97  bool isPairing();
98  bool isConnectedToPairedDevice() const;
99  bool enableTransportPinLink() const;
100  bool isRunnable() const;
101  bool isCanEnableNfc() const;
102  QString getErrorMessage() const;
103  QByteArray getPsk() const;
104  QString getConnectionInfo() const;
105  QString getConnectedServerDeviceNames() const;
106  bool getRemoteReaderVisible() const;
107 
108  Q_INVOKABLE bool pinPadModeOn() const;
109  Q_INVOKABLE void forgetDevice(const QString& pId);
110  Q_INVOKABLE void cancelPasswordRequest();
111  Q_INVOKABLE void changePinLength();
112 
113  Q_SIGNALS:
114  void fireStartWorkflow(const QSharedPointer<WorkflowRequest>& pRequest);
118  void firePskChanged(const QByteArray& pPsk);
122  void firePairingFailed(const QString& pDeviceName, const QString& pErrorMessage);
123  void firePairingSuccess(const QString& pDeviceName);
129  void fireCertificateRemoved(const QString& pDeviceName);
130 };
131 
132 
133 } // namespace governikus
Definition: Env.h:44
Definition: GlobalStatus.h:20
Definition: RemoteDeviceModel.h:72
Definition: RemoteServiceModel.h:24
QByteArray psk
Definition: RemoteServiceModel.h:34
Q_INVOKABLE void connectToRememberedServer(const QString &pServerPsk)
Definition: RemoteServiceModel.cpp:209
Q_INVOKABLE void changePinLength()
Definition: RemoteServiceModel.cpp:432
bool running
Definition: RemoteServiceModel.h:28
bool remoteReaderVisible
Definition: RemoteServiceModel.h:42
void setDetectRemoteDevices(bool pNewStatus)
Definition: RemoteServiceModel.cpp:196
bool connectedToPairedDevice
Definition: RemoteServiceModel.h:35
bool isRunnable() const
Definition: RemoteServiceModel.cpp:347
void fireStartWorkflow(const QSharedPointer< WorkflowRequest > &pRequest)
void firePairingFailed(const QString &pDeviceName, const QString &pErrorMessage)
Q_INVOKABLE void forgetDevice(const QString &pId)
Definition: RemoteServiceModel.cpp:417
bool canEnableNfc
Definition: RemoteServiceModel.h:31
void onTranslationChanged()
Definition: RemoteServiceModel.cpp:128
QString connectionInfo
Definition: RemoteServiceModel.h:36
QString getErrorMessage() const
Definition: RemoteServiceModel.cpp:359
Q_INVOKABLE bool pinPadModeOn() const
Definition: RemoteServiceModel.cpp:389
RemoteDeviceModel * knownDevices
Definition: RemoteServiceModel.h:39
bool isConnectedToPairedDevice() const
Definition: RemoteServiceModel.cpp:330
QString connectedServerDeviceNames
Definition: RemoteServiceModel.h:37
RemoteDeviceModel * getAvailableRemoteDevices()
Definition: RemoteServiceModel.cpp:184
RemoteDeviceModel * availableRemoteDevices
Definition: RemoteServiceModel.h:38
bool runnable
Definition: RemoteServiceModel.h:30
void firePskChanged(const QByteArray &pPsk)
QString getConnectionInfo() const
Definition: RemoteServiceModel.cpp:371
bool getRemoteReaderVisible() const
Definition: RemoteServiceModel.cpp:383
void fireCertificateRemoved(const QString &pDeviceName)
bool isStarting
Definition: RemoteServiceModel.h:29
Q_INVOKABLE bool rememberServer(const QString &pDeviceId)
Definition: RemoteServiceModel.cpp:222
void firePairingSuccess(const QString &pDeviceName)
QString getConnectedServerDeviceNames() const
Definition: RemoteServiceModel.cpp:377
bool requiresLocalNetworkPermission
Definition: RemoteServiceModel.h:43
void resetRemoteServiceContext(const QSharedPointer< IfdServiceContext > &pContext=QSharedPointer< IfdServiceContext >())
Definition: RemoteServiceModel.cpp:272
Q_INVOKABLE void cancelPasswordRequest()
Definition: RemoteServiceModel.cpp:423
QByteArray getPsk() const
Definition: RemoteServiceModel.cpp:365
bool isPairing
Definition: RemoteServiceModel.h:33
bool detectRemoteDevices
Definition: RemoteServiceModel.h:40
QString errorMessage
Definition: RemoteServiceModel.h:32
bool isCanEnableNfc() const
Definition: RemoteServiceModel.cpp:353
RemoteDeviceModel * getKnownDevices()
Definition: RemoteServiceModel.cpp:190
Q_INVOKABLE void setRunning(bool pState, bool pEnablePairing=false)
Definition: RemoteServiceModel.cpp:140
void setPairing(bool pEnabled)
Definition: RemoteServiceModel.cpp:310
bool enableTransportPinLink
Definition: RemoteServiceModel.h:41
bool isRunning() const
Definition: RemoteServiceModel.cpp:134
Definition: WorkflowModel.h:23
A simple template renderer.
Definition: ActivationContext.h:15