AusweisApp2
Lade ...
Suche ...
Keine Treffer
RemoteDeviceModel.h
gehe zur Dokumentation dieser Datei
1
7#pragma once
8
9#include "GlobalStatus.h"
12#include "RemoteDeviceList.h"
13#include "RemoteDispatcher.h"
15
16#include <QAbstractTableModel>
17#include <QSet>
18#include <QSslCertificate>
19#include <QVector>
20
21class test_RemoteDeviceModel;
22
23namespace governikus
24{
25
27{
28 private:
29 friend class ::test_RemoteDeviceModel;
30 QString mDeviceName;
31 QString mId;
32 bool mPaired;
33 bool mNetworkVisible;
34 bool mConnected;
35 bool mSupported;
36 QDateTime mLastConnected;
37 QSharedPointer<RemoteDeviceListEntry> mRemoteDeviceListEntry;
38
39 public:
40 RemoteDeviceModelEntry(const QString& pDeviceNameEscaped, const QString& mId, QSharedPointer<RemoteDeviceListEntry>& pRemoteDeviceListEntry);
41 RemoteDeviceModelEntry(const QString& pDeviceNameEscaped, const QString& mId, bool pNetworkVisible, bool pConnected, bool pSupported, const QDateTime& pLastConnected, QSharedPointer<RemoteDeviceListEntry>& pRemoteDeviceListEntry);
42 explicit RemoteDeviceModelEntry(const QString& pDeviceNameEscaped = QStringLiteral("UnknownReader"));
43
44 [[nodiscard]] bool isPaired() const;
45 void setPaired(bool pPaired);
46 [[nodiscard]] const QString& getId() const;
47 void setId(const QString& pId);
48 [[nodiscard]] bool isNetworkVisible() const;
49 [[nodiscard]] int getLinkQuality() const;
50 [[nodiscard]] bool isSupported() const;
51 void setNetworkVisible(bool pNetworkVisible);
52 [[nodiscard]] const QDateTime& getLastConnected() const;
53 void setLastConnected(const QDateTime& pLastConnected);
54 bool operator==(const RemoteDeviceModelEntry& pOther) const;
55
56 [[nodiscard]] const QSharedPointer<RemoteDeviceListEntry> getRemoteDeviceListEntry() const;
57 [[nodiscard]] QString getDeviceNameEscaped() const;
58
59};
60
62 : public QAbstractTableModel
63{
64 Q_OBJECT
65
67
68 private:
69 friend class ::test_RemoteDeviceModel;
70
71 const int NUMBER_OF_COLUMNS = 2;
72
73 QMap<QString, RemoteServiceSettings::RemoteInfo> mPairedReaders;
74 QVector<RemoteDeviceModelEntry> mAllRemoteReaders;
75 const bool mShowPairedReaders;
76 const bool mShowUnpairedReaders;
77 QTimer mTimer;
78
79 [[nodiscard]] bool indexIsValid(const QModelIndex& pIndex) const;
80 [[nodiscard]] QString getStatus(const RemoteDeviceModelEntry& pRemoteDeviceModelEntry) const;
81 void updatePairedReaders();
82 void updateUnpairedReaders();
83 void removeVanishedReaders();
84 [[nodiscard]] QVector<RemoteDeviceModelEntry> presentReaders() const;
85 bool addOrUpdateReader(const RemoteDeviceModelEntry& pModelEntry);
86
87 private Q_SLOTS:
88 void onUpdateReaderList();
89
90 public:
92 {
93 REMOTE_DEVICE_NAME = Qt::UserRole + 1,
101 };
102
103 enum ColumnId : int
104 {
106 ReaderStatus = 1
107 };
108
109 RemoteDeviceModel(QObject* pParent = nullptr, bool pShowPairedReaders = true, bool pShowUnpairedReaders = true);
110
111 [[nodiscard]] QVariant headerData(int pSection, Qt::Orientation pOrientation, int pRole) const override;
112 [[nodiscard]] int rowCount(const QModelIndex& pParent = QModelIndex()) const override;
113 [[nodiscard]] int columnCount(const QModelIndex& pParent = QModelIndex()) const override;
114 [[nodiscard]] QVariant data(const QModelIndex& pIndex, int pRole = Qt::DisplayRole) const override;
115 [[nodiscard]] QHash<int, QByteArray> roleNames() const override;
116
117 [[nodiscard]] const QSharedPointer<RemoteDeviceListEntry> getRemoteDeviceListEntry(const QModelIndex& pIndex) const;
118 [[nodiscard]] const QSharedPointer<RemoteDeviceListEntry> getRemoteDeviceListEntry(const QString& pDeviceId) const;
119 [[nodiscard]] bool isPaired(const QModelIndex& pIndex) const;
120 [[nodiscard]] bool isSupported(const QModelIndex& pIndex) const;
121 void forgetDevice(const QModelIndex& pIndex);
122 void forgetDevice(const QString& pDeviceId);
123
124 [[nodiscard]] QString getEmptyListDescriptionString() const;
125
126 public Q_SLOTS:
127 void onUiShown();
128 void onUiHidden();
130 void onDeviceDisconnected(GlobalStatus::Code pCloseCode, const QString& pId);
131
132 Q_SIGNALS:
135};
136
137
138} // namespace governikus
Code
Definition: GlobalStatus.h:26
Definition: RemoteDeviceModel.h:27
bool operator==(const RemoteDeviceModelEntry &pOther) const
Definition: RemoteDeviceModel.cpp:143
void setPaired(bool pPaired)
Definition: RemoteDeviceModel.cpp:79
bool isSupported() const
Definition: RemoteDeviceModel.cpp:119
void setLastConnected(const QDateTime &pLastConnected)
Definition: RemoteDeviceModel.cpp:137
void setId(const QString &pId)
Definition: RemoteDeviceModel.cpp:91
void setNetworkVisible(bool pNetworkVisible)
Definition: RemoteDeviceModel.cpp:125
const QString & getId() const
Definition: RemoteDeviceModel.cpp:85
const QSharedPointer< RemoteDeviceListEntry > getRemoteDeviceListEntry() const
Definition: RemoteDeviceModel.cpp:61
QString getDeviceNameEscaped() const
Definition: RemoteDeviceModel.cpp:67
const QDateTime & getLastConnected() const
Definition: RemoteDeviceModel.cpp:131
bool isPaired() const
Definition: RemoteDeviceModel.cpp:73
bool isNetworkVisible() const
Definition: RemoteDeviceModel.cpp:97
int getLinkQuality() const
Definition: RemoteDeviceModel.cpp:103
Definition: RemoteDeviceModel.h:63
void forgetDevice(const QModelIndex &pIndex)
Definition: RemoteDeviceModel.cpp:553
QString getEmptyListDescriptionString() const
Definition: RemoteDeviceModel.cpp:575
int columnCount(const QModelIndex &pParent=QModelIndex()) const override
Definition: RemoteDeviceModel.cpp:388
SettingsRemoteRoles
Definition: RemoteDeviceModel.h:92
@ IS_NETWORK_VISIBLE
Definition: RemoteDeviceModel.h:97
@ LAST_CONNECTED
Definition: RemoteDeviceModel.h:95
@ IS_SUPPORTED
Definition: RemoteDeviceModel.h:98
@ DEVICE_ID
Definition: RemoteDeviceModel.h:96
@ REMOTE_DEVICE_STATUS
Definition: RemoteDeviceModel.h:94
@ IS_PAIRED
Definition: RemoteDeviceModel.h:99
@ LINK_QUALITY
Definition: RemoteDeviceModel.h:100
@ REMOTE_DEVICE_NAME
Definition: RemoteDeviceModel.h:93
QHash< int, QByteArray > roleNames() const override
Definition: RemoteDeviceModel.cpp:175
bool isPaired(const QModelIndex &pIndex) const
Definition: RemoteDeviceModel.cpp:472
void onDeviceDisconnected(GlobalStatus::Code pCloseCode, const QString &pId)
Definition: RemoteDeviceModel.cpp:586
int rowCount(const QModelIndex &pParent=QModelIndex()) const override
Definition: RemoteDeviceModel.cpp:382
void onKnownRemoteReadersChanged()
Definition: RemoteDeviceModel.cpp:520
const QSharedPointer< RemoteDeviceListEntry > getRemoteDeviceListEntry(const QModelIndex &pIndex) const
Definition: RemoteDeviceModel.cpp:447
QVariant data(const QModelIndex &pIndex, int pRole=Qt::DisplayRole) const override
Definition: RemoteDeviceModel.cpp:394
bool isSupported(const QModelIndex &pIndex) const
Definition: RemoteDeviceModel.cpp:483
QVariant headerData(int pSection, Qt::Orientation pOrientation, int pRole) const override
Definition: RemoteDeviceModel.cpp:360
ColumnId
Definition: RemoteDeviceModel.h:104
@ ReaderName
Definition: RemoteDeviceModel.h:105
@ ReaderStatus
Definition: RemoteDeviceModel.h:106
QString emptyListDescriptionString
Definition: RemoteDeviceModel.h:66
void onUiShown()
Definition: RemoteDeviceModel.cpp:494
void onUiHidden()
Definition: RemoteDeviceModel.cpp:507
Implementation of ActivationContext for Intent based activation on Android systems.
Definition: ActivationContext.h:15