Make a reset interface for discovery
..WifiChecker still isn't triggering as i'd like still
This commit is contained in:
parent
fb46694ab8
commit
1b5caf301d
3 changed files with 23 additions and 7 deletions
|
@ -31,6 +31,9 @@ Page {
|
|||
}
|
||||
|
||||
}
|
||||
onSsidChanged: {
|
||||
discovery.reset()
|
||||
}
|
||||
}
|
||||
|
||||
signal refreshed()
|
||||
|
|
|
@ -57,11 +57,22 @@ IppDiscovery::~IppDiscovery() {
|
|||
delete socket;
|
||||
}
|
||||
|
||||
|
||||
void IppDiscovery::discover() {
|
||||
sendQuery(PTR, {"_ipp","_tcp","local"});
|
||||
}
|
||||
|
||||
void IppDiscovery::reset() {
|
||||
_ipp = QStringList();
|
||||
_rps = QMap<QString,QString>();
|
||||
_ports = QMap<QString,quint16>();
|
||||
_targets = QMap<QString,QString>();
|
||||
|
||||
_AAs = QMultiMap<QString,QString>();
|
||||
_AAAAs = QMultiMap<QString,QString>();
|
||||
|
||||
discover();
|
||||
}
|
||||
|
||||
void IppDiscovery::sendQuery(quint16 qtype, QStringList addr) {
|
||||
qDebug() << "discovering" << qtype << addr;
|
||||
|
||||
|
@ -82,6 +93,8 @@ void IppDiscovery::sendQuery(quint16 qtype, QStringList addr) {
|
|||
|
||||
void IppDiscovery::update()
|
||||
{
|
||||
QStringList found;
|
||||
|
||||
for(QStringList::Iterator it = _ipp.begin(); it != _ipp.end(); it++)
|
||||
{
|
||||
quint16 port = _ports[*it];
|
||||
|
@ -94,17 +107,17 @@ void IppDiscovery::update()
|
|||
{
|
||||
QString ip = ait.value();
|
||||
QString addr = ip+":"+QString::number(port)+"/"+rp;
|
||||
if(!_found.contains(addr))
|
||||
if(!found.contains(addr))
|
||||
{
|
||||
_found.append(addr);
|
||||
_found.sort(Qt::CaseInsensitive);
|
||||
found.append(addr);
|
||||
found.sort(Qt::CaseInsensitive);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
qDebug() << _favourites << _found;
|
||||
this->setStringList(_favourites+_found);
|
||||
qDebug() << _favourites << found;
|
||||
this->setStringList(_favourites+found);
|
||||
}
|
||||
|
||||
void IppDiscovery::readPendingDatagrams()
|
||||
|
|
|
@ -12,6 +12,7 @@ public:
|
|||
~IppDiscovery();
|
||||
Q_PROPERTY(QStringList favourites MEMBER _favourites NOTIFY favouritesChanged)
|
||||
Q_INVOKABLE void discover();
|
||||
Q_INVOKABLE void reset();
|
||||
|
||||
signals:
|
||||
void favouritesChanged();
|
||||
|
@ -33,7 +34,6 @@ private:
|
|||
QMultiMap<QString,QString> _AAAAs;
|
||||
|
||||
QStringList _favourites;
|
||||
QStringList _found;
|
||||
QUdpSocket* socket;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue