add better ipv6 support
This commit is contained in:
parent
5d955d09d4
commit
678ff9973b
@ -1,6 +1,7 @@
|
|||||||
#include "bluetoothservicediscovery.h"
|
#include "bluetoothservicediscovery.h"
|
||||||
|
|
||||||
#include "discoverymodel.h"
|
#include "discoverymodel.h"
|
||||||
|
#include "discoverydevice.h"
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
@ -102,14 +103,16 @@ void BluetoothServiceDiscovery::onServiceDiscovered(const QBluetoothServiceInfo
|
|||||||
if (serviceInfo.serviceClassUuids().first() == QBluetoothUuid(QUuid("997936b5-d2cd-4c57-b41b-c6048320cd2b"))) {
|
if (serviceInfo.serviceClassUuids().first() == QBluetoothUuid(QUuid("997936b5-d2cd-4c57-b41b-c6048320cd2b"))) {
|
||||||
qDebug() << "BluetoothServiceDiscovery: Found nymea rfcom service!";
|
qDebug() << "BluetoothServiceDiscovery: Found nymea rfcom service!";
|
||||||
|
|
||||||
DiscoveryDevice* device = m_discoveryModel->find(serviceInfo.device().address());
|
// DiscoveryDevice* device = m_discoveryModel->find(serviceInfo.device().address());
|
||||||
if (!device) {
|
// if (!device) {
|
||||||
device = new DiscoveryDevice(DiscoveryDevice::DeviceTypeBluetooth, this);
|
// device = new DiscoveryDevice(DiscoveryDevice::DeviceTypeBluetooth, this);
|
||||||
qDebug() << "BluetoothServiceDiscovery: Adding new bluetooth host to model";
|
// qDebug() << "BluetoothServiceDiscovery: Adding new bluetooth host to model";
|
||||||
device->setName(QString("%1 (%2)").arg(serviceInfo.serviceName()).arg(serviceInfo.device().name()));
|
// device->setName(QString("%1 (%2)").arg(serviceInfo.serviceName()).arg(serviceInfo.device().name()));
|
||||||
device->setBluetoothAddress(serviceInfo.device().address());
|
//// device->setBluetoothAddress(serviceInfo.device().address());
|
||||||
m_discoveryModel->addDevice(device);
|
// PortConfig pc;
|
||||||
}
|
|
||||||
|
// m_discoveryModel->addDevice(device);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -22,18 +22,12 @@
|
|||||||
|
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
DiscoveryDevice::DiscoveryDevice(DeviceType deviceType, QObject *parent):
|
DiscoveryDevice::DiscoveryDevice(QObject *parent):
|
||||||
QObject(parent),
|
QObject(parent)
|
||||||
m_deviceType(deviceType)
|
|
||||||
{
|
{
|
||||||
m_portConfigs = new PortConfigs(this);
|
m_portConfigs = new PortConfigs(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
DiscoveryDevice::DeviceType DiscoveryDevice::deviceType() const
|
|
||||||
{
|
|
||||||
return m_deviceType;
|
|
||||||
}
|
|
||||||
|
|
||||||
QUuid DiscoveryDevice::uuid() const
|
QUuid DiscoveryDevice::uuid() const
|
||||||
{
|
{
|
||||||
return m_uuid;
|
return m_uuid;
|
||||||
@ -44,43 +38,6 @@ void DiscoveryDevice::setUuid(const QUuid &uuid)
|
|||||||
m_uuid = uuid;
|
m_uuid = uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
QHostAddress DiscoveryDevice::hostAddress() const
|
|
||||||
{
|
|
||||||
return m_hostAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString DiscoveryDevice::hostAddressString() const
|
|
||||||
{
|
|
||||||
return m_hostAddress.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DiscoveryDevice::setHostAddress(const QHostAddress &hostAddress)
|
|
||||||
{
|
|
||||||
if (m_hostAddress != hostAddress) {
|
|
||||||
m_hostAddress = hostAddress;
|
|
||||||
emit hostAddressChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QBluetoothAddress DiscoveryDevice::bluetoothAddress() const
|
|
||||||
{
|
|
||||||
return m_bluetoothAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString DiscoveryDevice::bluetoothAddressString() const
|
|
||||||
{
|
|
||||||
return m_bluetoothAddress.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DiscoveryDevice::setBluetoothAddress(const QBluetoothAddress &bluetoothAddress)
|
|
||||||
{
|
|
||||||
if (m_bluetoothAddress == bluetoothAddress)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_bluetoothAddress = bluetoothAddress;
|
|
||||||
emit bluetoothAddressChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString DiscoveryDevice::name() const
|
QString DiscoveryDevice::name() const
|
||||||
{
|
{
|
||||||
return m_name;
|
return m_name;
|
||||||
@ -122,7 +79,11 @@ QString DiscoveryDevice::toUrl(int portConfigIndex)
|
|||||||
QString ret = pc->protocol() == PortConfig::ProtocolNymeaRpc ? "nymea" : "ws";
|
QString ret = pc->protocol() == PortConfig::ProtocolNymeaRpc ? "nymea" : "ws";
|
||||||
ret += pc->sslEnabled() ? "s" : "";
|
ret += pc->sslEnabled() ? "s" : "";
|
||||||
ret += "://";
|
ret += "://";
|
||||||
ret += m_hostAddress.toString();
|
if (pc->hostAddress().protocol() == QAbstractSocket::IPv4Protocol) {
|
||||||
|
ret += pc->hostAddress().toString();
|
||||||
|
} else if (pc->hostAddress().protocol() == QAbstractSocket::IPv6Protocol){
|
||||||
|
ret += "[" + pc->hostAddress().toString() + "]";
|
||||||
|
}
|
||||||
ret += ":";
|
ret += ":";
|
||||||
ret += QString::number(pc->port());
|
ret += QString::number(pc->port());
|
||||||
return ret;
|
return ret;
|
||||||
@ -142,6 +103,8 @@ int PortConfigs::rowCount(const QModelIndex &parent) const
|
|||||||
QVariant PortConfigs::data(const QModelIndex &index, int role) const
|
QVariant PortConfigs::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
switch (role) {
|
switch (role) {
|
||||||
|
case RoleAddress:
|
||||||
|
return m_portConfigs.at(index.row())->hostAddressString();
|
||||||
case RolePort:
|
case RolePort:
|
||||||
return m_portConfigs.at(index.row())->port();
|
return m_portConfigs.at(index.row())->port();
|
||||||
case RoleProtocol:
|
case RoleProtocol:
|
||||||
@ -182,15 +145,17 @@ PortConfig* PortConfigs::get(int index) const
|
|||||||
QHash<int, QByteArray> PortConfigs::roleNames() const
|
QHash<int, QByteArray> PortConfigs::roleNames() const
|
||||||
{
|
{
|
||||||
QHash<int, QByteArray> roles;
|
QHash<int, QByteArray> roles;
|
||||||
|
roles.insert(RoleAddress, "address");
|
||||||
roles.insert(RolePort, "port");
|
roles.insert(RolePort, "port");
|
||||||
roles.insert(RoleProtocol, "protocol");
|
roles.insert(RoleProtocol, "protocol");
|
||||||
roles.insert(RoleSSLEnabled, "sslEnabled");
|
roles.insert(RoleSSLEnabled, "sslEnabled");
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
PortConfig::PortConfig(int port, QObject *parent):
|
PortConfig::PortConfig(const QHostAddress &hostAddress, int port, QObject *parent):
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_port(port)
|
m_port(port),
|
||||||
|
m_hostAddress(hostAddress)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -213,6 +178,20 @@ void PortConfig::setProtocol(PortConfig::Protocol protocol)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QHostAddress PortConfig::hostAddress() const
|
||||||
|
{
|
||||||
|
return m_hostAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString PortConfig::hostAddressString() const
|
||||||
|
{
|
||||||
|
if (m_hostAddress.protocol() == QAbstractSocket::IPv6Protocol){
|
||||||
|
return "[" + m_hostAddress.toString() + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_hostAddress.toString();
|
||||||
|
}
|
||||||
|
|
||||||
bool PortConfig::sslEnabled() const
|
bool PortConfig::sslEnabled() const
|
||||||
{
|
{
|
||||||
return m_sslEnabled;
|
return m_sslEnabled;
|
||||||
|
|||||||
@ -34,6 +34,7 @@ class PortConfig: public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(int port READ port CONSTANT)
|
Q_PROPERTY(int port READ port CONSTANT)
|
||||||
Q_PROPERTY(Protocol protocol READ protocol NOTIFY protocolChanged)
|
Q_PROPERTY(Protocol protocol READ protocol NOTIFY protocolChanged)
|
||||||
|
Q_PROPERTY(QString hostAddress READ hostAddressString NOTIFY hostAddressChanged)
|
||||||
Q_PROPERTY(bool sslEnabled READ sslEnabled NOTIFY sslEnabledChanged)
|
Q_PROPERTY(bool sslEnabled READ sslEnabled NOTIFY sslEnabledChanged)
|
||||||
public:
|
public:
|
||||||
enum Protocol {
|
enum Protocol {
|
||||||
@ -41,22 +42,28 @@ public:
|
|||||||
ProtocolWebSocket
|
ProtocolWebSocket
|
||||||
};
|
};
|
||||||
Q_ENUM(Protocol)
|
Q_ENUM(Protocol)
|
||||||
PortConfig(int port, QObject *parent = nullptr);
|
PortConfig(const QHostAddress &hostAddress, int port, QObject *parent = nullptr);
|
||||||
|
|
||||||
int port() const;
|
int port() const;
|
||||||
|
|
||||||
Protocol protocol() const;
|
Protocol protocol() const;
|
||||||
void setProtocol(Protocol protocol);
|
void setProtocol(Protocol protocol);
|
||||||
|
|
||||||
|
QHostAddress hostAddress() const;
|
||||||
|
QString hostAddressString() const;
|
||||||
|
void setHostAddress(const QString &hostAddress);
|
||||||
|
|
||||||
bool sslEnabled() const;
|
bool sslEnabled() const;
|
||||||
void setSslEnabled(bool sslEnabled);
|
void setSslEnabled(bool sslEnabled);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void protocolChanged();
|
void protocolChanged();
|
||||||
|
void hostAddressChanged();
|
||||||
void sslEnabledChanged();
|
void sslEnabledChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_port = -1;
|
int m_port = -1;
|
||||||
|
QHostAddress m_hostAddress;
|
||||||
Protocol m_protocol = ProtocolNymeaRpc;
|
Protocol m_protocol = ProtocolNymeaRpc;
|
||||||
bool m_sslEnabled = false;
|
bool m_sslEnabled = false;
|
||||||
};
|
};
|
||||||
@ -67,6 +74,7 @@ class PortConfigs: public QAbstractListModel
|
|||||||
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
|
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
|
||||||
public:
|
public:
|
||||||
enum Roles {
|
enum Roles {
|
||||||
|
RoleAddress,
|
||||||
RolePort,
|
RolePort,
|
||||||
RoleProtocol,
|
RoleProtocol,
|
||||||
RoleSSLEnabled
|
RoleSSLEnabled
|
||||||
@ -95,36 +103,17 @@ private:
|
|||||||
class DiscoveryDevice: public QObject
|
class DiscoveryDevice: public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(DeviceType deviceType READ deviceType CONSTANT)
|
|
||||||
Q_PROPERTY(QUuid uuid READ uuid CONSTANT)
|
Q_PROPERTY(QUuid uuid READ uuid CONSTANT)
|
||||||
Q_PROPERTY(QString hostAddress READ hostAddressString NOTIFY hostAddressChanged)
|
|
||||||
Q_PROPERTY(QString bluetoothAddress READ bluetoothAddressString NOTIFY bluetoothAddressChanged)
|
|
||||||
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
|
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
|
||||||
Q_PROPERTY(QString version READ version NOTIFY versionChanged)
|
Q_PROPERTY(QString version READ version NOTIFY versionChanged)
|
||||||
Q_PROPERTY(PortConfigs* portConfigs READ portConfigs CONSTANT)
|
Q_PROPERTY(PortConfigs* portConfigs READ portConfigs CONSTANT)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum DeviceType {
|
explicit DiscoveryDevice(QObject *parent = nullptr);
|
||||||
DeviceTypeNetwork,
|
|
||||||
DeviceTypeBluetooth
|
|
||||||
};
|
|
||||||
Q_ENUM(DeviceType)
|
|
||||||
|
|
||||||
explicit DiscoveryDevice(DeviceType deviceType, QObject *parent = nullptr);
|
|
||||||
|
|
||||||
DeviceType deviceType() const;
|
|
||||||
|
|
||||||
QUuid uuid() const;
|
QUuid uuid() const;
|
||||||
void setUuid(const QUuid &uuid);
|
void setUuid(const QUuid &uuid);
|
||||||
|
|
||||||
QHostAddress hostAddress() const;
|
|
||||||
QString hostAddressString() const;
|
|
||||||
void setHostAddress(const QHostAddress &hostAddress);
|
|
||||||
|
|
||||||
QBluetoothAddress bluetoothAddress() const;
|
|
||||||
QString bluetoothAddressString() const;
|
|
||||||
void setBluetoothAddress(const QBluetoothAddress &bluetoothAddress);
|
|
||||||
|
|
||||||
QString name() const;
|
QString name() const;
|
||||||
void setName(const QString &name);
|
void setName(const QString &name);
|
||||||
|
|
||||||
@ -137,15 +126,10 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void nameChanged();
|
void nameChanged();
|
||||||
void hostAddressChanged();
|
|
||||||
void bluetoothAddressChanged();
|
|
||||||
void versionChanged();
|
void versionChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DeviceType m_deviceType = DeviceTypeNetwork;
|
|
||||||
QUuid m_uuid;
|
QUuid m_uuid;
|
||||||
QHostAddress m_hostAddress;
|
|
||||||
QBluetoothAddress m_bluetoothAddress;
|
|
||||||
QString m_name;
|
QString m_name;
|
||||||
QString m_version;
|
QString m_version;
|
||||||
PortConfigs *m_portConfigs = nullptr;
|
PortConfigs *m_portConfigs = nullptr;
|
||||||
|
|||||||
@ -19,6 +19,7 @@
|
|||||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
#include "discoverymodel.h"
|
#include "discoverymodel.h"
|
||||||
|
#include "discoverydevice.h"
|
||||||
|
|
||||||
DiscoveryModel::DiscoveryModel(QObject *parent) :
|
DiscoveryModel::DiscoveryModel(QObject *parent) :
|
||||||
QAbstractListModel(parent)
|
QAbstractListModel(parent)
|
||||||
@ -38,24 +39,12 @@ QVariant DiscoveryModel::data(const QModelIndex &index, int role) const
|
|||||||
|
|
||||||
DiscoveryDevice *device = m_devices.at(index.row());
|
DiscoveryDevice *device = m_devices.at(index.row());
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case DeviceTypeRole:
|
|
||||||
return device->deviceType();
|
|
||||||
case UuidRole:
|
case UuidRole:
|
||||||
return device->uuid();
|
return device->uuid();
|
||||||
case NameRole:
|
case NameRole:
|
||||||
return device->name();
|
return device->name();
|
||||||
case HostAddressRole:
|
|
||||||
return device->hostAddress().toString();
|
|
||||||
case BluetoothAddressRole:
|
|
||||||
return device->bluetoothAddressString();
|
|
||||||
// case WebSocketUrlRole:
|
|
||||||
// return device.webSocketUrl();
|
|
||||||
// case PortRole:
|
|
||||||
// return device.port();
|
|
||||||
case VersionRole:
|
case VersionRole:
|
||||||
return device->version();
|
return device->version();
|
||||||
// case NymeaRpcUrlRole:
|
|
||||||
// return device.nymeaRpcUrl();
|
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -90,17 +79,6 @@ DiscoveryDevice *DiscoveryModel::find(const QUuid &uuid)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
DiscoveryDevice *DiscoveryModel::find(const QBluetoothAddress &bluetoothAddress)
|
|
||||||
{
|
|
||||||
foreach (DiscoveryDevice *device, m_devices) {
|
|
||||||
if (device->bluetoothAddress() == bluetoothAddress) {
|
|
||||||
return device;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DiscoveryModel::clearModel()
|
void DiscoveryModel::clearModel()
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
@ -112,11 +90,8 @@ void DiscoveryModel::clearModel()
|
|||||||
QHash<int, QByteArray> DiscoveryModel::roleNames() const
|
QHash<int, QByteArray> DiscoveryModel::roleNames() const
|
||||||
{
|
{
|
||||||
QHash<int, QByteArray> roles;
|
QHash<int, QByteArray> roles;
|
||||||
roles[DeviceTypeRole] = "deviceType";
|
|
||||||
roles[UuidRole] = "uuid";
|
roles[UuidRole] = "uuid";
|
||||||
roles[NameRole] = "name";
|
roles[NameRole] = "name";
|
||||||
roles[HostAddressRole] = "hostAddress";
|
|
||||||
roles[BluetoothAddressRole] = "bluetoothAddress";
|
|
||||||
roles[VersionRole] = "version";
|
roles[VersionRole] = "version";
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,8 +23,9 @@
|
|||||||
|
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
#include <QBluetoothAddress>
|
||||||
|
|
||||||
#include "discoverydevice.h"
|
class DiscoveryDevice;
|
||||||
|
|
||||||
class DiscoveryModel : public QAbstractListModel
|
class DiscoveryModel : public QAbstractListModel
|
||||||
{
|
{
|
||||||
@ -35,8 +36,6 @@ public:
|
|||||||
DeviceTypeRole,
|
DeviceTypeRole,
|
||||||
UuidRole,
|
UuidRole,
|
||||||
NameRole,
|
NameRole,
|
||||||
HostAddressRole,
|
|
||||||
BluetoothAddressRole,
|
|
||||||
VersionRole
|
VersionRole
|
||||||
};
|
};
|
||||||
Q_ENUM(DeviceRole)
|
Q_ENUM(DeviceRole)
|
||||||
@ -50,7 +49,6 @@ public:
|
|||||||
|
|
||||||
Q_INVOKABLE DiscoveryDevice *get(int index) const;
|
Q_INVOKABLE DiscoveryDevice *get(int index) const;
|
||||||
Q_INVOKABLE DiscoveryDevice *find(const QUuid &uuid);
|
Q_INVOKABLE DiscoveryDevice *find(const QUuid &uuid);
|
||||||
Q_INVOKABLE DiscoveryDevice *find(const QBluetoothAddress &bluetoothAddress);
|
|
||||||
|
|
||||||
void clearModel();
|
void clearModel();
|
||||||
|
|
||||||
|
|||||||
@ -163,7 +163,7 @@ void UpnpDiscovery::readData()
|
|||||||
|
|
||||||
if (!m_foundDevices.contains(location) && isNymea) {
|
if (!m_foundDevices.contains(location) && isNymea) {
|
||||||
m_foundDevices.append(location);
|
m_foundDevices.append(location);
|
||||||
qDebug() << "Getting server data from:" << location;
|
// qDebug() << "Getting server data from:" << location;
|
||||||
QNetworkReply *reply = m_networkAccessManager->get(QNetworkRequest(location));
|
QNetworkReply *reply = m_networkAccessManager->get(QNetworkRequest(location));
|
||||||
connect(reply, &QNetworkReply::sslErrors, [reply](const QList<QSslError> &errors){
|
connect(reply, &QNetworkReply::sslErrors, [reply](const QList<QSslError> &errors){
|
||||||
reply->ignoreSslErrors(errors);
|
reply->ignoreSslErrors(errors);
|
||||||
@ -205,7 +205,7 @@ void UpnpDiscovery::networkReplyFinished(QNetworkReply *reply)
|
|||||||
// Check for old style websocketURL and nymeaRpcURL
|
// Check for old style websocketURL and nymeaRpcURL
|
||||||
if (xml.name().toString() == "websocketURL") {
|
if (xml.name().toString() == "websocketURL") {
|
||||||
QUrl u(xml.readElementText());
|
QUrl u(xml.readElementText());
|
||||||
PortConfig *pc = new PortConfig(u.port());
|
PortConfig *pc = new PortConfig(discoveredAddress, u.port());
|
||||||
pc->setProtocol(PortConfig::ProtocolWebSocket);
|
pc->setProtocol(PortConfig::ProtocolWebSocket);
|
||||||
pc->setSslEnabled(u.scheme() == "wss");
|
pc->setSslEnabled(u.scheme() == "wss");
|
||||||
portConfigList.append(pc);
|
portConfigList.append(pc);
|
||||||
@ -214,7 +214,7 @@ void UpnpDiscovery::networkReplyFinished(QNetworkReply *reply)
|
|||||||
if (xml.name().toString() == "nymeaRpcURL") {
|
if (xml.name().toString() == "nymeaRpcURL") {
|
||||||
QUrl u(xml.readElementText());
|
QUrl u(xml.readElementText());
|
||||||
qDebug() << "have url" << u << u.scheme();
|
qDebug() << "have url" << u << u.scheme();
|
||||||
PortConfig *pc = new PortConfig(u.port());
|
PortConfig *pc = new PortConfig(discoveredAddress, u.port());
|
||||||
pc->setProtocol(PortConfig::ProtocolNymeaRpc);
|
pc->setProtocol(PortConfig::ProtocolNymeaRpc);
|
||||||
pc->setSslEnabled(u.scheme() == "nymeas");
|
pc->setSslEnabled(u.scheme() == "nymeas");
|
||||||
portConfigList.append(pc);
|
portConfigList.append(pc);
|
||||||
@ -223,7 +223,7 @@ void UpnpDiscovery::networkReplyFinished(QNetworkReply *reply)
|
|||||||
if (xml.name().toString() == "guhRpcURL") {
|
if (xml.name().toString() == "guhRpcURL") {
|
||||||
QUrl u(xml.readElementText());
|
QUrl u(xml.readElementText());
|
||||||
qDebug() << "have url" << u << u.scheme();
|
qDebug() << "have url" << u << u.scheme();
|
||||||
PortConfig *pc = new PortConfig(u.port());
|
PortConfig *pc = new PortConfig(discoveredAddress, u.port());
|
||||||
pc->setProtocol(PortConfig::ProtocolNymeaRpc);
|
pc->setProtocol(PortConfig::ProtocolNymeaRpc);
|
||||||
pc->setSslEnabled(u.scheme() == "guhs");
|
pc->setSslEnabled(u.scheme() == "guhs");
|
||||||
portConfigList.append(pc);
|
portConfigList.append(pc);
|
||||||
@ -238,7 +238,7 @@ void UpnpDiscovery::networkReplyFinished(QNetworkReply *reply)
|
|||||||
xml.readNext();
|
xml.readNext();
|
||||||
if (xml.name().toString() == "SCPDURL") {
|
if (xml.name().toString() == "SCPDURL") {
|
||||||
QUrl u(xml.readElementText());
|
QUrl u(xml.readElementText());
|
||||||
PortConfig *pc = new PortConfig(u.port());
|
PortConfig *pc = new PortConfig(discoveredAddress, u.port());
|
||||||
pc->setProtocol(u.scheme().startsWith("nymea") ? PortConfig::ProtocolNymeaRpc : PortConfig::ProtocolWebSocket);
|
pc->setProtocol(u.scheme().startsWith("nymea") ? PortConfig::ProtocolNymeaRpc : PortConfig::ProtocolWebSocket);
|
||||||
pc->setSslEnabled(u.scheme() == "nymeas" || u.scheme() == "wss");
|
pc->setSslEnabled(u.scheme() == "nymeas" || u.scheme() == "wss");
|
||||||
portConfigList.append(pc);
|
portConfigList.append(pc);
|
||||||
@ -264,12 +264,11 @@ void UpnpDiscovery::networkReplyFinished(QNetworkReply *reply)
|
|||||||
|
|
||||||
DiscoveryDevice* device = m_discoveryModel->find(uuid);
|
DiscoveryDevice* device = m_discoveryModel->find(uuid);
|
||||||
if (!device) {
|
if (!device) {
|
||||||
device = new DiscoveryDevice(DiscoveryDevice::DeviceTypeNetwork, m_discoveryModel);
|
device = new DiscoveryDevice(m_discoveryModel);
|
||||||
device->setUuid(uuid);
|
device->setUuid(uuid);
|
||||||
qDebug() << "Adding new host to model";
|
qDebug() << "Adding new host to model";
|
||||||
m_discoveryModel->addDevice(device);
|
m_discoveryModel->addDevice(device);
|
||||||
}
|
}
|
||||||
device->setHostAddress(discoveredAddress);
|
|
||||||
device->setName(name);
|
device->setName(name);
|
||||||
device->setVersion(version);
|
device->setVersion(version);
|
||||||
foreach (PortConfig *pc, portConfigList) {
|
foreach (PortConfig *pc, portConfigList) {
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
|
||||||
|
#include "discoverydevice.h"
|
||||||
|
|
||||||
ZeroconfDiscovery::ZeroconfDiscovery(DiscoveryModel *discoveryModel, QObject *parent) :
|
ZeroconfDiscovery::ZeroconfDiscovery(DiscoveryModel *discoveryModel, QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
@ -11,13 +12,13 @@ ZeroconfDiscovery::ZeroconfDiscovery(DiscoveryModel *discoveryModel, QObject *pa
|
|||||||
m_zeroconfJsonRPC = new QZeroConf(this);
|
m_zeroconfJsonRPC = new QZeroConf(this);
|
||||||
connect(m_zeroconfJsonRPC, &QZeroConf::serviceAdded, this, &ZeroconfDiscovery::serviceEntryAdded);
|
connect(m_zeroconfJsonRPC, &QZeroConf::serviceAdded, this, &ZeroconfDiscovery::serviceEntryAdded);
|
||||||
connect(m_zeroconfJsonRPC, &QZeroConf::serviceUpdated, this, &ZeroconfDiscovery::serviceEntryAdded);
|
connect(m_zeroconfJsonRPC, &QZeroConf::serviceUpdated, this, &ZeroconfDiscovery::serviceEntryAdded);
|
||||||
m_zeroconfJsonRPC->startBrowser("_jsonrpc._tcp");
|
m_zeroconfJsonRPC->startBrowser("_jsonrpc._tcp", QAbstractSocket::AnyIPProtocol);
|
||||||
qDebug() << "created service browser for _jsonrpc._tcp:" << m_zeroconfJsonRPC->browserExists();
|
qDebug() << "created service browser for _jsonrpc._tcp:" << m_zeroconfJsonRPC->browserExists();
|
||||||
|
|
||||||
m_zeroconfWebSocket = new QZeroConf(this);
|
m_zeroconfWebSocket = new QZeroConf(this);
|
||||||
connect(m_zeroconfWebSocket, &QZeroConf::serviceAdded, this, &ZeroconfDiscovery::serviceEntryAdded);
|
connect(m_zeroconfWebSocket, &QZeroConf::serviceAdded, this, &ZeroconfDiscovery::serviceEntryAdded);
|
||||||
connect(m_zeroconfWebSocket, &QZeroConf::serviceUpdated, this, &ZeroconfDiscovery::serviceEntryAdded);
|
connect(m_zeroconfWebSocket, &QZeroConf::serviceUpdated, this, &ZeroconfDiscovery::serviceEntryAdded);
|
||||||
m_zeroconfWebSocket->startBrowser("_ws._tcp");
|
m_zeroconfWebSocket->startBrowser("_ws._tcp", QAbstractSocket::AnyIPProtocol);
|
||||||
qDebug() << "created service browser for _ws._tcp:" << m_zeroconfWebSocket->browserExists();
|
qDebug() << "created service browser for _ws._tcp:" << m_zeroconfWebSocket->browserExists();
|
||||||
#else
|
#else
|
||||||
qDebug() << "Zeroconf support not compiled in. Zeroconf will not be available.";
|
qDebug() << "Zeroconf support not compiled in. Zeroconf will not be available.";
|
||||||
@ -41,10 +42,10 @@ bool ZeroconfDiscovery::discovering() const
|
|||||||
#ifdef WITH_ZEROCONF
|
#ifdef WITH_ZEROCONF
|
||||||
void ZeroconfDiscovery::serviceEntryAdded(const QZeroConfService &entry)
|
void ZeroconfDiscovery::serviceEntryAdded(const QZeroConfService &entry)
|
||||||
{
|
{
|
||||||
if (!entry.name().startsWith("nymea") || entry.ip().isNull()) {
|
if (!entry.name().startsWith("nymea") || (entry.ip().isNull() && entry.ipv6().isNull())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// qDebug() << "zeroconf service discovered" << entry << entry.txt() << entry.type();
|
// qDebug() << "zeroconf service discovered" << entry << entry.ip() << entry.ipv6() << entry.txt() << entry.type();
|
||||||
|
|
||||||
QString uuid;
|
QString uuid;
|
||||||
bool sslEnabled = false;
|
bool sslEnabled = false;
|
||||||
@ -70,18 +71,17 @@ void ZeroconfDiscovery::serviceEntryAdded(const QZeroConfService &entry)
|
|||||||
|
|
||||||
DiscoveryDevice* device = m_discoveryModel->find(uuid);
|
DiscoveryDevice* device = m_discoveryModel->find(uuid);
|
||||||
if (!device) {
|
if (!device) {
|
||||||
device = new DiscoveryDevice(DiscoveryDevice::DeviceTypeNetwork, m_discoveryModel);
|
device = new DiscoveryDevice(m_discoveryModel);
|
||||||
device->setUuid(uuid);
|
device->setUuid(uuid);
|
||||||
qDebug() << "ZeroConf: Adding new host to model";
|
qDebug() << "ZeroConf: Adding new host to model";
|
||||||
m_discoveryModel->addDevice(device);
|
m_discoveryModel->addDevice(device);
|
||||||
}
|
}
|
||||||
device->setHostAddress(entry.ip());
|
|
||||||
device->setName(serverName);
|
device->setName(serverName);
|
||||||
device->setVersion(version);
|
device->setVersion(version);
|
||||||
PortConfig *portConfig = device->portConfigs()->find(entry.port());
|
PortConfig *portConfig = device->portConfigs()->find(entry.port());
|
||||||
if (!portConfig) {
|
if (!portConfig) {
|
||||||
qDebug() << "ZeroConf: Adding new port config";
|
qDebug() << "ZeroConf: Adding new port config";
|
||||||
portConfig = new PortConfig(entry.port());
|
portConfig = new PortConfig(!entry.ip().isNull() ? entry.ip() : entry.ipv6(), entry.port());
|
||||||
device->portConfigs()->insert(portConfig);
|
device->portConfigs()->insert(portConfig);
|
||||||
}
|
}
|
||||||
portConfig->setProtocol(entry.type() == "_ws._tcp" ? PortConfig::ProtocolWebSocket : PortConfig::ProtocolNymeaRpc);
|
portConfig->setProtocol(entry.type() == "_ws._tcp" ? PortConfig::ProtocolWebSocket : PortConfig::ProtocolNymeaRpc);
|
||||||
|
|||||||
@ -111,6 +111,8 @@ void Engine::onConnectedChanged()
|
|||||||
void Engine::onDeviceManagerFetchingChanged()
|
void Engine::onDeviceManagerFetchingChanged()
|
||||||
{
|
{
|
||||||
if (!m_deviceManager->fetchingData()) {
|
if (!m_deviceManager->fetchingData()) {
|
||||||
m_tagsManager->init();
|
if (m_jsonRpcClient->ensureServerVersion("1.7")) {
|
||||||
|
m_tagsManager->init();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -243,7 +243,7 @@ void JsonRpcClient::sendRequest(const QVariantMap &request)
|
|||||||
{
|
{
|
||||||
QVariantMap newRequest = request;
|
QVariantMap newRequest = request;
|
||||||
newRequest.insert("token", m_token);
|
newRequest.insert("token", m_token);
|
||||||
// qDebug() << "Sending request" << qUtf8Printable(QJsonDocument::fromVariant(newRequest).toJson());
|
qDebug() << "Sending request" << qUtf8Printable(QJsonDocument::fromVariant(newRequest).toJson());
|
||||||
m_connection->sendData(QJsonDocument::fromVariant(newRequest).toJson(QJsonDocument::Compact) + "\n");
|
m_connection->sendData(QJsonDocument::fromVariant(newRequest).toJson(QJsonDocument::Compact) + "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
#include "devicediscovery.h"
|
#include "devicediscovery.h"
|
||||||
#include "discovery/nymeadiscovery.h"
|
#include "discovery/nymeadiscovery.h"
|
||||||
#include "discovery/discoverymodel.h"
|
#include "discovery/discoverymodel.h"
|
||||||
|
#include "discovery/discoverydevice.h"
|
||||||
#include "interfacesmodel.h"
|
#include "interfacesmodel.h"
|
||||||
#include "rulemanager.h"
|
#include "rulemanager.h"
|
||||||
#include "models/rulesfiltermodel.h"
|
#include "models/rulesfiltermodel.h"
|
||||||
@ -50,6 +51,8 @@
|
|||||||
#include "ruletemplates/statedescriptortemplate.h"
|
#include "ruletemplates/statedescriptortemplate.h"
|
||||||
#include "ruletemplates/ruleactiontemplate.h"
|
#include "ruletemplates/ruleactiontemplate.h"
|
||||||
|
|
||||||
|
#include <QtQml/qqml.h>
|
||||||
|
|
||||||
static QObject* interfacesModel_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
|
static QObject* interfacesModel_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
|
||||||
{
|
{
|
||||||
Q_UNUSED(engine)
|
Q_UNUSED(engine)
|
||||||
|
|||||||
@ -61,7 +61,6 @@ SOURCES += \
|
|||||||
models/tagsproxymodel.cpp \
|
models/tagsproxymodel.cpp \
|
||||||
tagsmanager.cpp \
|
tagsmanager.cpp \
|
||||||
wifisetup/wirelessaccesspointsproxy.cpp \
|
wifisetup/wirelessaccesspointsproxy.cpp \
|
||||||
models/tagsproxymodel.cpp \
|
|
||||||
ruletemplates/ruletemplate.cpp \
|
ruletemplates/ruletemplate.cpp \
|
||||||
ruletemplates/ruletemplates.cpp \
|
ruletemplates/ruletemplates.cpp \
|
||||||
ruletemplates/eventdescriptortemplate.cpp \
|
ruletemplates/eventdescriptortemplate.cpp \
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/">
|
<qresource prefix="/">
|
||||||
<file>ui/Nymea.qml</file>
|
<file>ui/Nymea.qml</file>
|
||||||
<file>ui/ConnectPage.qml</file>
|
<file>ui/connection/ConnectPage.qml</file>
|
||||||
|
<file>ui/connection/ManualConnectPage.qml</file>
|
||||||
|
<file>ui/connection/BluetoothDiscoveryPage.qml</file>
|
||||||
|
<file>ui/connection/ConnectingPage.qml</file>
|
||||||
<file>ui/mainviews/DevicesPage.qml</file>
|
<file>ui/mainviews/DevicesPage.qml</file>
|
||||||
<file>ui/NewDeviceWizard.qml</file>
|
<file>ui/NewDeviceWizard.qml</file>
|
||||||
<file>ui/SettingsPage.qml</file>
|
<file>ui/SettingsPage.qml</file>
|
||||||
@ -212,8 +215,6 @@
|
|||||||
<file>ui/components/EmptyViewPlaceholder.qml</file>
|
<file>ui/components/EmptyViewPlaceholder.qml</file>
|
||||||
<file>ui/components/RemoveDeviceMethodDialog.qml</file>
|
<file>ui/components/RemoveDeviceMethodDialog.qml</file>
|
||||||
<file>ui/components/FancyHeader.qml</file>
|
<file>ui/components/FancyHeader.qml</file>
|
||||||
<file>ui/connection/ManualConnectPage.qml</file>
|
|
||||||
<file>ui/connection/BluetoothDiscoveryPage.qml</file>
|
|
||||||
<file>ui/images/awning/awning-100.svg</file>
|
<file>ui/images/awning/awning-100.svg</file>
|
||||||
<file>ui/devicepages/AwningDevicePage.qml</file>
|
<file>ui/devicepages/AwningDevicePage.qml</file>
|
||||||
<file>ui/images/awning/awning-000.svg</file>
|
<file>ui/images/awning/awning-000.svg</file>
|
||||||
|
|||||||
@ -42,7 +42,7 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
pageStack.push(Qt.resolvedUrl("ConnectPage.qml"))
|
pageStack.push(Qt.resolvedUrl("connection/ConnectPage.qml"))
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
@ -77,7 +77,7 @@ ApplicationWindow {
|
|||||||
print("calling init. Auth required:", Engine.jsonRpcClient.authenticationRequired, "initial setup required:", Engine.jsonRpcClient.initialSetupRequired, "jsonrpc connected:", Engine.jsonRpcClient.connected)
|
print("calling init. Auth required:", Engine.jsonRpcClient.authenticationRequired, "initial setup required:", Engine.jsonRpcClient.initialSetupRequired, "jsonrpc connected:", Engine.jsonRpcClient.connected)
|
||||||
pageStack.clear()
|
pageStack.clear()
|
||||||
if (!Engine.connection.connected) {
|
if (!Engine.connection.connected) {
|
||||||
pageStack.push(Qt.resolvedUrl("ConnectPage.qml"))
|
pageStack.push(Qt.resolvedUrl("connection/ConnectPage.qml"))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ ApplicationWindow {
|
|||||||
} else if (Engine.jsonRpcClient.connected) {
|
} else if (Engine.jsonRpcClient.connected) {
|
||||||
pageStack.push(Qt.resolvedUrl("MainPage.qml"))
|
pageStack.push(Qt.resolvedUrl("MainPage.qml"))
|
||||||
} else {
|
} else {
|
||||||
pageStack.push(Qt.resolvedUrl("ConnectPage.qml"))
|
pageStack.push(Qt.resolvedUrl("connection/ConnectPage.qml"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -30,6 +30,7 @@ Page {
|
|||||||
|
|
||||||
Label {
|
Label {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
elide: Text.ElideMiddle
|
||||||
text: Engine.connection.url
|
text: Engine.connection.url
|
||||||
}
|
}
|
||||||
Button {
|
Button {
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import QtQuick.Controls 2.2
|
|||||||
import QtQuick.Controls.Material 2.2
|
import QtQuick.Controls.Material 2.2
|
||||||
import QtQuick.Layouts 1.3
|
import QtQuick.Layouts 1.3
|
||||||
import Nymea 1.0
|
import Nymea 1.0
|
||||||
import "components"
|
import "../components"
|
||||||
|
|
||||||
Page {
|
Page {
|
||||||
id: root
|
id: root
|
||||||
@ -13,7 +13,12 @@ Page {
|
|||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
print("completed connectPage. last connected host:", settings.lastConnectedHost)
|
print("completed connectPage. last connected host:", settings.lastConnectedHost)
|
||||||
if (settings.lastConnectedHost.length > 0) {
|
if (settings.lastConnectedHost.length > 0) {
|
||||||
pageStack.push(connectingPage)
|
var page = pageStack.push(Qt.resolvedUrl("ConnectingPage.qml"))
|
||||||
|
page.cancel.connect(function() {
|
||||||
|
Engine.connection.disconnect();
|
||||||
|
pageStack.pop(root, StackView.Immediate);
|
||||||
|
pageStack.push(discoveyPage)
|
||||||
|
})
|
||||||
Engine.connection.connect(settings.lastConnectedHost)
|
Engine.connection.connect(settings.lastConnectedHost)
|
||||||
} else {
|
} else {
|
||||||
pageStack.push(discoveryPage)
|
pageStack.push(discoveryPage)
|
||||||
@ -55,17 +60,18 @@ Page {
|
|||||||
default:
|
default:
|
||||||
errorMessage = qsTr("Un unknown error happened. We're very sorry for that. (Error code: %1)").arg(error);
|
errorMessage = qsTr("Un unknown error happened. We're very sorry for that. (Error code: %1)").arg(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pageStack.pop(root, StackView.Immediate)
|
||||||
|
pageStack.push(discoveryPage)
|
||||||
|
|
||||||
print("opening ErrorDialog with message:", errorMessage, error)
|
print("opening ErrorDialog with message:", errorMessage, error)
|
||||||
var comp = Qt.createComponent(Qt.resolvedUrl("components/ErrorDialog.qml"))
|
var comp = Qt.createComponent(Qt.resolvedUrl("../components/ErrorDialog.qml"))
|
||||||
var popup = comp.createObject(app, {text: errorMessage})
|
var popup = comp.createObject(app, {text: errorMessage})
|
||||||
popup.open()
|
popup.open()
|
||||||
|
|
||||||
pageStack.pop(root)
|
|
||||||
pageStack.push(discoveryPage)
|
|
||||||
}
|
}
|
||||||
onConnectedChanged: {
|
onConnectedChanged: {
|
||||||
if (!connected) {
|
if (!connected) {
|
||||||
pageStack.pop(root)
|
pageStack.pop(root, StackView.Immediate)
|
||||||
pageStack.push(discoveryPage)
|
pageStack.push(discoveryPage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -79,8 +85,8 @@ Page {
|
|||||||
header: FancyHeader {
|
header: FancyHeader {
|
||||||
title: qsTr("Connect %1").arg(app.systemName)
|
title: qsTr("Connect %1").arg(app.systemName)
|
||||||
model: ListModel {
|
model: ListModel {
|
||||||
ListElement { iconSource: "../images/network-vpn.svg"; text: qsTr("Manual connection"); page: "connection/ManualConnectPage.qml" }
|
ListElement { iconSource: "../images/network-vpn.svg"; text: qsTr("Manual connection"); page: "ManualConnectPage.qml" }
|
||||||
ListElement { iconSource: "../images/bluetooth.svg"; text: qsTr("Wireless setup"); page: "connection/BluetoothDiscoveryPage.qml"; }
|
ListElement { iconSource: "../images/bluetooth.svg"; text: qsTr("Wireless setup"); page: "BluetoothDiscoveryPage.qml"; }
|
||||||
ListElement { iconSource: "../images/private-browsing.svg"; text: qsTr("Demo mode"); page: "" }
|
ListElement { iconSource: "../images/private-browsing.svg"; text: qsTr("Demo mode"); page: "" }
|
||||||
ListElement { iconSource: "../images/stock_application.svg"; text: qsTr("App settings"); page: "AppSettingsPage.qml" }
|
ListElement { iconSource: "../images/stock_application.svg"; text: qsTr("App settings"); page: "AppSettingsPage.qml" }
|
||||||
}
|
}
|
||||||
@ -92,8 +98,11 @@ Page {
|
|||||||
pageStack.push(model.get(index).page);
|
pageStack.push(model.get(index).page);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
var page = pageStack.push(Qt.resolvedUrl("ConnectingPage.qml"))
|
||||||
|
page.cancel.connect(function() {
|
||||||
|
Engine.connection.disconnect()
|
||||||
|
})
|
||||||
Engine.connection.connect("nymea://nymea.nymea.io:2222")
|
Engine.connection.connect("nymea://nymea.nymea.io:2222")
|
||||||
pageStack.push(connectingPage)
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,19 +209,11 @@ Page {
|
|||||||
swipe.enabled: discoveryDeviceDelegate.discoveryDevice.deviceType === DiscoveryDevice.DeviceTypeNetwork
|
swipe.enabled: discoveryDeviceDelegate.discoveryDevice.deviceType === DiscoveryDevice.DeviceTypeNetwork
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
switch (discoveryDeviceDelegate.discoveryDevice.deviceType) {
|
Engine.connection.connect(discoveryDeviceDelegate.discoveryDevice.toUrl(discoveryDeviceDelegate.defaultPortConfigIndex))
|
||||||
case DiscoveryDevice.DeviceTypeNetwork:
|
var page = pageStack.push(Qt.resolvedUrl("ConnectingPage.qml"))
|
||||||
Engine.connection.connect(discoveryDeviceDelegate.discoveryDevice.toUrl(discoveryDeviceDelegate.defaultPortConfigIndex))
|
page.cancel.connect(function() {
|
||||||
break;
|
Engine.connection.disconnect()
|
||||||
case DiscoveryDevice.DeviceTypeBluetooth:
|
})
|
||||||
Engine.connection.connect("rfcom://bluetooth.local?mac=" + model.bluetoothAddress + "&name=" + model.name)
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
console.warn("Could not connect, unknown type")
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
pageStack.push(connectingPage)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
swipe.right: MouseArea {
|
swipe.right: MouseArea {
|
||||||
@ -276,7 +277,10 @@ Page {
|
|||||||
visible: discovery.discoveryModel.count === 0
|
visible: discovery.discoveryModel.count === 0
|
||||||
text: qsTr("Demo mode (online)")
|
text: qsTr("Demo mode (online)")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
pageStack.push(connectingPage)
|
var page = pageStack.push(Qt.resolvedUrl("ConnectingPage.qml"))
|
||||||
|
page.cancel.connect(function() {
|
||||||
|
Engine.connection.disconnect()
|
||||||
|
})
|
||||||
Engine.connection.connect("nymea://nymea.nymea.io:2222")
|
Engine.connection.connect("nymea://nymea.nymea.io:2222")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,40 +303,6 @@ Page {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component {
|
|
||||||
id: connectingPage
|
|
||||||
Page {
|
|
||||||
|
|
||||||
ColumnLayout {
|
|
||||||
id: columnLayout
|
|
||||||
anchors { left: parent.left; right: parent.right; verticalCenter: parent.verticalCenter; margins: app.margins }
|
|
||||||
spacing: app.margins
|
|
||||||
BusyIndicator {
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
|
||||||
running: parent.visible
|
|
||||||
}
|
|
||||||
Label {
|
|
||||||
text: qsTr("Connecting to<br>%1").arg(Engine.connection.url)
|
|
||||||
font.pixelSize: app.largeFont
|
|
||||||
Layout.fillWidth: true
|
|
||||||
wrapMode: Text.WordWrap
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Button {
|
|
||||||
text: qsTr("Cancel")
|
|
||||||
anchors { left: parent.left; top: columnLayout.bottom; right: parent.right }
|
|
||||||
anchors.margins: app.margins
|
|
||||||
onClicked: {
|
|
||||||
Engine.connection.disconnect()
|
|
||||||
pageStack.pop(root);
|
|
||||||
pageStack.push(discoveryPage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: certDialogComponent
|
id: certDialogComponent
|
||||||
|
|
||||||
@ -511,14 +481,6 @@ Page {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
}
|
}
|
||||||
Label {
|
|
||||||
text: "IP Address:"
|
|
||||||
}
|
|
||||||
Label {
|
|
||||||
text: dialog.discoveryDevice.hostAddress
|
|
||||||
Layout.fillWidth: true
|
|
||||||
elide: Text.ElideRight
|
|
||||||
}
|
|
||||||
ThinDivider { Layout.columnSpan: 2 }
|
ThinDivider { Layout.columnSpan: 2 }
|
||||||
Label {
|
Label {
|
||||||
Layout.columnSpan: 2
|
Layout.columnSpan: 2
|
||||||
@ -542,7 +504,9 @@ Page {
|
|||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Label {
|
Label {
|
||||||
text: qsTr("Port: %1").arg(model.port)
|
Layout.fillWidth: true
|
||||||
|
elide: Text.ElideMiddle
|
||||||
|
text: "%1:%2".arg(model.address).arg(model.port)
|
||||||
}
|
}
|
||||||
Label {
|
Label {
|
||||||
text: model.protocol === PortConfig.ProtocolNymeaRpc ? "nymea-rpc" : "websocket"
|
text: model.protocol === PortConfig.ProtocolNymeaRpc ? "nymea-rpc" : "websocket"
|
||||||
37
nymea-app/ui/connection/ConnectingPage.qml
Normal file
37
nymea-app/ui/connection/ConnectingPage.qml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import QtQuick 2.9
|
||||||
|
import QtQuick.Controls 2.2
|
||||||
|
import QtQuick.Controls.Material 2.2
|
||||||
|
import QtQuick.Layouts 1.3
|
||||||
|
import Nymea 1.0
|
||||||
|
import "../components"
|
||||||
|
|
||||||
|
|
||||||
|
Page {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
signal cancel()
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
id: columnLayout
|
||||||
|
anchors { left: parent.left; right: parent.right; verticalCenter: parent.verticalCenter; margins: app.margins }
|
||||||
|
spacing: app.margins
|
||||||
|
BusyIndicator {
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
running: parent.visible
|
||||||
|
}
|
||||||
|
Label {
|
||||||
|
text: qsTr("Trying to connect...")
|
||||||
|
font.pixelSize: app.largeFont
|
||||||
|
Layout.fillWidth: true
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
text: qsTr("Cancel")
|
||||||
|
anchors { left: parent.left; top: columnLayout.bottom; right: parent.right }
|
||||||
|
anchors.margins: app.margins
|
||||||
|
onClicked: root.cancel()
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -5,6 +5,7 @@ import Nymea 1.0
|
|||||||
import "../components"
|
import "../components"
|
||||||
|
|
||||||
Page {
|
Page {
|
||||||
|
id: root
|
||||||
objectName: "manualConnectPage"
|
objectName: "manualConnectPage"
|
||||||
header: GuhHeader {
|
header: GuhHeader {
|
||||||
text: qsTr("Manual connection")
|
text: qsTr("Manual connection")
|
||||||
@ -96,7 +97,11 @@ Page {
|
|||||||
|
|
||||||
print("Try to connect ", rpcUrl)
|
print("Try to connect ", rpcUrl)
|
||||||
Engine.connection.connect(rpcUrl)
|
Engine.connection.connect(rpcUrl)
|
||||||
pageStack.push(connectingPage)
|
var page = pageStack.push(Qt.resolvedUrl("ConnectingPage.qml"))
|
||||||
|
page.cancel.connect(function() {
|
||||||
|
Engine.connection.disconnect()
|
||||||
|
pageStack.pop(root)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user