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;
24
25namespace governikus
26{
27
29{
30 friend class ::test_RemoteDeviceModel;
31
32 private:
33 QString mDeviceName;
34 QString mId;
35 bool mPaired;
36 bool mNetworkVisible;
37 bool mConnected;
38 bool mSupported;
39 QDateTime mLastConnected;
40 QSharedPointer<IfdListEntry> mRemoteDeviceListEntry;
41
42 public:
43 RemoteDeviceModelEntry(const QString& pDeviceNameEscaped,
44 const QString& mId,
45 const QSharedPointer<IfdListEntry>& pRemoteDeviceListEntry);
46 RemoteDeviceModelEntry(const QString& pDeviceNameEscaped,
47 const QString& mId,
48 bool pNetworkVisible,
49 bool pConnected,
50 bool pSupported,
51 const QDateTime& pLastConnected,
52 const QSharedPointer<IfdListEntry>& pRemoteDeviceListEntry);
53 explicit RemoteDeviceModelEntry(const QString& pDeviceNameEscaped = QStringLiteral("UnknownReader"));
54
55 [[nodiscard]] bool isPaired() const;
56 void setPaired(bool pPaired);
57 [[nodiscard]] const QString& getId() const;
58 void setId(const QString& pId);
59 [[nodiscard]] bool isNetworkVisible() const;
60 [[nodiscard]] int getLinkQuality() const;
61 [[nodiscard]] bool isSupported() const;
62 void setNetworkVisible(bool pNetworkVisible);
63 [[nodiscard]] const QDateTime& getLastConnected() const;
64 void setLastConnected(const QDateTime& pLastConnected);
65 [[nodiscard]] bool operator==(const RemoteDeviceModelEntry& pOther) const;
66
67 [[nodiscard]] const QSharedPointer<IfdListEntry>& getRemoteDeviceListEntry() const;
68 [[nodiscard]] QString getDeviceNameEscaped() const;
69
70};
71
73 : public QAbstractListModel
74{
75 Q_OBJECT
77 friend class ::test_RemoteDeviceModel;
78
79 private:
80 QMap<QString, RemoteServiceSettings::RemoteInfo> mPairedReaders;
81 QVector<RemoteDeviceModelEntry> mAllRemoteReaders;
82 const bool mShowPairedReaders;
83 const bool mShowUnpairedReaders;
84 QTimer mTimer;
85 bool mIsDetectingRemoteDevices;
86#if defined(Q_OS_IOS)
87 bool mRemoteDetectionWasRunning;
88#endif
89
90 [[nodiscard]] bool indexIsValid(const QModelIndex& pIndex) const;
91 [[nodiscard]] QString getStatus(const RemoteDeviceModelEntry& pRemoteDeviceModelEntry) const;
92 void updatePairedReaders();
93 void updateUnpairedReaders();
94 void removeVanishedReaders();
95 [[nodiscard]] QVector<RemoteDeviceModelEntry> presentReaders() const;
96 bool addOrUpdateReader(const RemoteDeviceModelEntry& pModelEntry);
97
98 private Q_SLOTS:
99 void onApplicationStateChanged(bool pIsAppInForeground);
100 void onUpdateReaderList();
101
102 public Q_SLOTS:
104
105 public:
107 {
108 REMOTE_DEVICE_NAME = Qt::UserRole + 1,
116 };
117
118 RemoteDeviceModel(QObject* pParent = nullptr, bool pShowPairedReaders = true, bool pShowUnpairedReaders = true);
119
120 [[nodiscard]] int rowCount(const QModelIndex& pParent = QModelIndex()) const override;
121 [[nodiscard]] QVariant data(const QModelIndex& pIndex, int pRole = Qt::DisplayRole) const override;
122 [[nodiscard]] QHash<int, QByteArray> roleNames() const override;
123
124 [[nodiscard]] QSharedPointer<IfdListEntry> getRemoteDeviceListEntry(const QModelIndex& pIndex) const;
125 [[nodiscard]] QSharedPointer<IfdListEntry> getRemoteDeviceListEntry(const QString& pDeviceId) const;
126 [[nodiscard]] bool isPaired(const QModelIndex& pIndex) const;
127 [[nodiscard]] bool isSupported(const QModelIndex& pIndex) const;
128 void forgetDevice(const QModelIndex& pIndex);
129 void forgetDevice(const QString& pDeviceId);
130
131 [[nodiscard]] QString getEmptyListDescriptionString() const;
132
133 public Q_SLOTS:
134 void setDetectRemoteDevices(bool pNewStatus);
136 void onDeviceDisconnected(GlobalStatus::Code pCloseCode, const QString& pId);
137
138 Q_SIGNALS:
140};
141
142
143} // namespace governikus
Code
Definition: GlobalStatus.h:28
Definition: RemoteDeviceModel.h:29
bool operator==(const RemoteDeviceModelEntry &pOther) const
Definition: RemoteDeviceModel.cpp:151
void setPaired(bool pPaired)
Definition: RemoteDeviceModel.cpp:87
bool isSupported() const
Definition: RemoteDeviceModel.cpp:127
void setLastConnected(const QDateTime &pLastConnected)
Definition: RemoteDeviceModel.cpp:145
const QSharedPointer< IfdListEntry > & getRemoteDeviceListEntry() const
Definition: RemoteDeviceModel.cpp:69
void setId(const QString &pId)
Definition: RemoteDeviceModel.cpp:99
void setNetworkVisible(bool pNetworkVisible)
Definition: RemoteDeviceModel.cpp:133
const QString & getId() const
Definition: RemoteDeviceModel.cpp:93
QString getDeviceNameEscaped() const
Definition: RemoteDeviceModel.cpp:75
const QDateTime & getLastConnected() const
Definition: RemoteDeviceModel.cpp:139
bool isPaired() const
Definition: RemoteDeviceModel.cpp:81
bool isNetworkVisible() const
Definition: RemoteDeviceModel.cpp:105
int getLinkQuality() const
Definition: RemoteDeviceModel.cpp:111
Definition: RemoteDeviceModel.h:74
void forgetDevice(const QModelIndex &pIndex)
Definition: RemoteDeviceModel.cpp:555
QString getEmptyListDescriptionString() const
Definition: RemoteDeviceModel.cpp:577
void onTranslationChanged()
Definition: RemoteDeviceModel.cpp:549
SettingsRemoteRoles
Definition: RemoteDeviceModel.h:107
@ IS_NETWORK_VISIBLE
Definition: RemoteDeviceModel.h:112
@ LAST_CONNECTED
Definition: RemoteDeviceModel.h:110
@ IS_SUPPORTED
Definition: RemoteDeviceModel.h:113
@ DEVICE_ID
Definition: RemoteDeviceModel.h:111
@ REMOTE_DEVICE_STATUS
Definition: RemoteDeviceModel.h:109
@ IS_PAIRED
Definition: RemoteDeviceModel.h:114
@ LINK_QUALITY
Definition: RemoteDeviceModel.h:115
@ REMOTE_DEVICE_NAME
Definition: RemoteDeviceModel.h:108
QHash< int, QByteArray > roleNames() const override
Definition: RemoteDeviceModel.cpp:184
bool isPaired(const QModelIndex &pIndex) const
Definition: RemoteDeviceModel.cpp:443
void onDeviceDisconnected(GlobalStatus::Code pCloseCode, const QString &pId)
Definition: RemoteDeviceModel.cpp:588
int rowCount(const QModelIndex &pParent=QModelIndex()) const override
Definition: RemoteDeviceModel.cpp:369
void onKnownRemoteReadersChanged()
Definition: RemoteDeviceModel.cpp:489
friend class ::test_RemoteDeviceModel
Definition: RemoteDeviceModel.h:77
void setDetectRemoteDevices(bool pNewStatus)
Definition: RemoteDeviceModel.cpp:465
QVariant data(const QModelIndex &pIndex, int pRole=Qt::DisplayRole) const override
Definition: RemoteDeviceModel.cpp:375
bool isSupported(const QModelIndex &pIndex) const
Definition: RemoteDeviceModel.cpp:454
QSharedPointer< IfdListEntry > getRemoteDeviceListEntry(const QModelIndex &pIndex) const
Definition: RemoteDeviceModel.cpp:418
QString emptyListDescriptionString
Definition: RemoteDeviceModel.h:76
Definition: RemoteServiceSettings.h:31
Implementation of GeneralAuthenticate response APDUs.
Definition: CommandApdu.h:16