AusweisApp2
Lade ...
Suche ...
Keine Treffer
RemoteDeviceModel.h
gehe zur Dokumentation dieser Datei
1
9#pragma once
10
11#include "GlobalStatus.h"
12#include "IfdDescriptor.h"
13#include "IfdDispatcher.h"
14#include "IfdList.h"
17
18#include <QAbstractTableModel>
19#include <QSet>
20#include <QSslCertificate>
21#include <QVector>
22
23class test_RemoteDeviceModel;
24class test_RemoteDeviceFilterModel;
25
26namespace governikus
27{
28
30{
31 friend class ::test_RemoteDeviceModel;
32
33 private:
34 QString mDeviceName;
35 QString mId;
36 bool mPaired;
37 bool mIsPairing;
38 bool mNetworkVisible;
39 bool mConnected;
40 bool mSupported;
41 QDateTime mLastConnected;
42 QSharedPointer<IfdListEntry> mRemoteDeviceListEntry;
43
44 public:
45 explicit RemoteDeviceModelEntry(const QSharedPointer<IfdListEntry>& pListEntry);
46 RemoteDeviceModelEntry(const QString& pDeviceNameEscaped,
47 const QString& mId,
48 bool pNetworkVisible,
49 bool pConnected,
50 bool pSupported,
51 bool pIsPairing,
52 const QDateTime& pLastConnected,
53 const QSharedPointer<IfdListEntry>& pRemoteDeviceListEntry);
54 explicit RemoteDeviceModelEntry(const QString& pDeviceNameEscaped = QStringLiteral("UnknownReader"));
55
56 [[nodiscard]] bool isPaired() const;
57 void setPaired(bool pPaired);
58 [[nodiscard]] bool isPairing() const;
59 void setIsPairing(bool pIsPairing);
60 [[nodiscard]] const QString& getId() const;
61 void setId(const QString& pId);
62 [[nodiscard]] bool isNetworkVisible() const;
63 [[nodiscard]] int getLinkQuality() const;
64 [[nodiscard]] bool isSupported() const;
65 void setNetworkVisible(bool pNetworkVisible);
66 [[nodiscard]] const QDateTime& getLastConnected() const;
67 void setLastConnected(const QDateTime& pLastConnected);
68 [[nodiscard]] bool operator==(const RemoteDeviceModelEntry& pOther) const;
69
70 [[nodiscard]] const QSharedPointer<IfdListEntry>& getRemoteDeviceListEntry() const;
71 [[nodiscard]] QString getDeviceNameEscaped() const;
72
73};
74
76 : public QAbstractListModel
77{
78 Q_OBJECT
80 friend class ::test_RemoteDeviceModel;
82
83 private:
84 QMap<QString, RemoteServiceSettings::RemoteInfo> mPairedReaders;
85 QVector<RemoteDeviceModelEntry> mAllRemoteReaders;
86 RemoteServiceSettings::RemoteInfo mLastPairedDevice;
87 const bool mShowPairedReaders;
88 const bool mShowUnpairedReaders;
89 QTimer mTimer;
90 bool mIsDetectingRemoteDevices;
91#if defined(Q_OS_IOS)
92 bool mRemoteDetectionWasRunning;
93#endif
94
95 [[nodiscard]] bool indexIsValid(const QModelIndex& pIndex) const;
96 [[nodiscard]] QString getStatus(const RemoteDeviceModelEntry& pRemoteDeviceModelEntry) const;
97 void updatePairedReaders();
98 void updateUnpairedReaders();
99 void removeVanishedReaders();
100 [[nodiscard]] QVector<RemoteDeviceModelEntry> presentReaders() const;
101 bool addOrUpdateReader(const RemoteDeviceModelEntry& pModelEntry);
102
103 private Q_SLOTS:
104 void onApplicationStateChanged(bool pIsAppInForeground);
105 void onUpdateReaderList();
106
107 public Q_SLOTS:
109
110 public:
112 {
113 REMOTE_DEVICE_NAME = Qt::UserRole + 1,
123 };
124
125 RemoteDeviceModel(QObject* pParent = nullptr, bool pShowPairedReaders = true, bool pShowUnpairedReaders = true);
126
127 [[nodiscard]] int rowCount(const QModelIndex& pParent = QModelIndex()) const override;
128 [[nodiscard]] QVariant data(const QModelIndex& pIndex, int pRole = Qt::DisplayRole) const override;
129 [[nodiscard]] QHash<int, QByteArray> roleNames() const override;
130
131 [[nodiscard]] QSharedPointer<IfdListEntry> getRemoteDeviceListEntry(const QModelIndex& pIndex) const;
132 [[nodiscard]] QSharedPointer<IfdListEntry> getRemoteDeviceListEntry(const QString& pDeviceId) const;
133 [[nodiscard]] bool isPaired(const QModelIndex& pIndex) const;
134 [[nodiscard]] bool isPairing(const QModelIndex& pIndex) const;
135 [[nodiscard]] bool isSupported(const QModelIndex& pIndex) const;
136 void forgetDevice(const QModelIndex& pIndex);
137 void forgetDevice(const QString& pDeviceId);
138
139 [[nodiscard]] QString getEmptyListDescriptionString() const;
140
141 void setLastPairedReader(const QSslCertificate& pCert);
142
143 public Q_SLOTS:
144 void setDetectRemoteDevices(bool pNewStatus);
146 void onDeviceDisconnected(GlobalStatus::Code pCloseCode, const QString& pId);
147
148 Q_SIGNALS:
150};
151
152
153} // namespace governikus
Code
Definition GlobalStatus.h:28
Definition RemoteDeviceModel.h:30
bool operator==(const RemoteDeviceModelEntry &pOther) const
Definition RemoteDeviceModel.cpp:165
void setPaired(bool pPaired)
Definition RemoteDeviceModel.cpp:89
bool isSupported() const
Definition RemoteDeviceModel.cpp:141
void setLastConnected(const QDateTime &pLastConnected)
Definition RemoteDeviceModel.cpp:159
const QSharedPointer< IfdListEntry > & getRemoteDeviceListEntry() const
Definition RemoteDeviceModel.cpp:71
void setId(const QString &pId)
Definition RemoteDeviceModel.cpp:113
void setNetworkVisible(bool pNetworkVisible)
Definition RemoteDeviceModel.cpp:147
const QString & getId() const
Definition RemoteDeviceModel.cpp:107
void setIsPairing(bool pIsPairing)
Definition RemoteDeviceModel.cpp:101
QString getDeviceNameEscaped() const
Definition RemoteDeviceModel.cpp:77
const QDateTime & getLastConnected() const
Definition RemoteDeviceModel.cpp:153
bool isPaired() const
Definition RemoteDeviceModel.cpp:83
bool isNetworkVisible() const
Definition RemoteDeviceModel.cpp:119
int getLinkQuality() const
Definition RemoteDeviceModel.cpp:125
bool isPairing() const
Definition RemoteDeviceModel.cpp:95
Definition RemoteDeviceModel.h:77
void forgetDevice(const QModelIndex &pIndex)
Definition RemoteDeviceModel.cpp:599
QString getEmptyListDescriptionString() const
Definition RemoteDeviceModel.cpp:621
void onTranslationChanged()
Definition RemoteDeviceModel.cpp:593
SettingsRemoteRoles
Definition RemoteDeviceModel.h:112
@ IS_NETWORK_VISIBLE
Definition RemoteDeviceModel.h:117
@ LAST_CONNECTED
Definition RemoteDeviceModel.h:115
@ IS_SUPPORTED
Definition RemoteDeviceModel.h:118
@ DEVICE_ID
Definition RemoteDeviceModel.h:116
@ REMOTE_DEVICE_STATUS
Definition RemoteDeviceModel.h:114
@ IS_PAIRED
Definition RemoteDeviceModel.h:119
@ IS_PAIRING
Definition RemoteDeviceModel.h:120
@ LINK_QUALITY
Definition RemoteDeviceModel.h:121
@ IS_LAST_ADDED_DEVICE
Definition RemoteDeviceModel.h:122
@ REMOTE_DEVICE_NAME
Definition RemoteDeviceModel.h:113
QHash< int, QByteArray > roleNames() const override
Definition RemoteDeviceModel.cpp:198
bool isPairing(const QModelIndex &pIndex) const
Definition RemoteDeviceModel.cpp:487
bool isPaired(const QModelIndex &pIndex) const
Definition RemoteDeviceModel.cpp:476
friend class ::test_RemoteDeviceFilterModel
Definition RemoteDeviceModel.h:81
void onDeviceDisconnected(GlobalStatus::Code pCloseCode, const QString &pId)
Definition RemoteDeviceModel.cpp:640
int rowCount(const QModelIndex &pParent=QModelIndex()) const override
Definition RemoteDeviceModel.cpp:393
void setLastPairedReader(const QSslCertificate &pCert)
Definition RemoteDeviceModel.cpp:632
void onKnownRemoteReadersChanged()
Definition RemoteDeviceModel.cpp:533
friend class ::test_RemoteDeviceModel
Definition RemoteDeviceModel.h:80
void setDetectRemoteDevices(bool pNewStatus)
Definition RemoteDeviceModel.cpp:509
QVariant data(const QModelIndex &pIndex, int pRole=Qt::DisplayRole) const override
Definition RemoteDeviceModel.cpp:399
bool isSupported(const QModelIndex &pIndex) const
Definition RemoteDeviceModel.cpp:498
QSharedPointer< IfdListEntry > getRemoteDeviceListEntry(const QModelIndex &pIndex) const
Definition RemoteDeviceModel.cpp:451
QString emptyListDescriptionString
Definition RemoteDeviceModel.h:79
Definition RemoteServiceSettings.h:31
Implementation of GeneralAuthenticate response APDUs.
Definition CommandApdu.h:16