intermediate commit
This commit is contained in:
parent
64f9ff490d
commit
5a6c809ed1
@ -152,6 +152,7 @@ void NymeaDiscovery::cacheHost(NymeaHost *host)
|
|||||||
QList<Connection*> connections;
|
QList<Connection*> connections;
|
||||||
Connection *remoteConnection = host->connections()->bestMatch(Connection::BearerTypeCloud);
|
Connection *remoteConnection = host->connections()->bestMatch(Connection::BearerTypeCloud);
|
||||||
if (remoteConnection) {
|
if (remoteConnection) {
|
||||||
|
qCritical() << "*********** caching" << remoteConnection->url();
|
||||||
connections.append(remoteConnection);
|
connections.append(remoteConnection);
|
||||||
}
|
}
|
||||||
Connection *loopbackConnection = host->connections()->bestMatch(Connection::BearerTypeLoopback);
|
Connection *loopbackConnection = host->connections()->bestMatch(Connection::BearerTypeLoopback);
|
||||||
|
|||||||
@ -101,6 +101,21 @@ bool NymeaHost::online() const
|
|||||||
return m_online;
|
return m_online;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NymeaHost::addTunnelConnection()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < m_connections->rowCount(); i++) {
|
||||||
|
if (m_connections->get(i)->url().scheme() == "tunnel") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QUrl url;
|
||||||
|
url.setScheme("tunnel");
|
||||||
|
url.setHost(m_uuid.toString().remove(QRegExp("[{}]")));
|
||||||
|
qCritical() << "Adding tunnel connection" << url << m_uuid;
|
||||||
|
Connection *connection = new Connection(url, Connection::BearerTypeCloud, true, "foooobaaaar", this);
|
||||||
|
m_connections->addConnection(connection);
|
||||||
|
}
|
||||||
|
|
||||||
void NymeaHost::syncOnlineState()
|
void NymeaHost::syncOnlineState()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_connections->rowCount(); i++) {
|
for (int i = 0; i < m_connections->rowCount(); i++) {
|
||||||
@ -217,7 +232,7 @@ Connection *Connections::bestMatch(Connection::BearerTypes bearerTypes) const
|
|||||||
{
|
{
|
||||||
Connection *best = nullptr;
|
Connection *best = nullptr;
|
||||||
foreach (Connection *c, m_connections) {
|
foreach (Connection *c, m_connections) {
|
||||||
// qDebug() << "have connection:" << bearerTypes << c->url() << c->bearerType() << bearerTypes.testFlag(c->bearerType());
|
// qWarning() << "have connection:" << bearerTypes << c->url() << c->bearerType() << bearerTypes.testFlag(c->bearerType());
|
||||||
if ((bearerTypes & c->bearerType()) == Connection::BearerTypeNone) {
|
if ((bearerTypes & c->bearerType()) == Connection::BearerTypeNone) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -320,6 +335,9 @@ int Connection::priority() const
|
|||||||
break;
|
break;
|
||||||
case BearerTypeCloud:
|
case BearerTypeCloud:
|
||||||
prio += 200;
|
prio += 200;
|
||||||
|
if (m_url.scheme().startsWith("tunnel")) {
|
||||||
|
prio += 1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case BearerTypeBluetooth:
|
case BearerTypeBluetooth:
|
||||||
prio += 100;
|
prio += 100;
|
||||||
|
|||||||
@ -156,6 +156,8 @@ public:
|
|||||||
|
|
||||||
bool online() const;
|
bool online() const;
|
||||||
|
|
||||||
|
Q_INVOKABLE void addTunnelConnection();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void nameChanged();
|
void nameChanged();
|
||||||
void versionChanged();
|
void versionChanged();
|
||||||
|
|||||||
@ -32,6 +32,8 @@
|
|||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
using namespace remoteproxyclient;
|
||||||
|
|
||||||
TunnelProxyTransport::TunnelProxyTransport(QObject *parent) :
|
TunnelProxyTransport::TunnelProxyTransport(QObject *parent) :
|
||||||
NymeaTransportInterface(parent)
|
NymeaTransportInterface(parent)
|
||||||
{
|
{
|
||||||
@ -112,6 +114,11 @@ QSslCertificate TunnelProxyTransport::serverCertificate() const
|
|||||||
return QSslCertificate();
|
return QSslCertificate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TunnelProxyTransport::onRemoteConnectionStateChanged(remoteproxyclient::TunnelProxyRemoteConnection::State state)
|
||||||
|
{
|
||||||
|
qCritical() << "FIXME TODO! remoteConnectionStateChanged";
|
||||||
|
}
|
||||||
|
|
||||||
void TunnelProxyTransport::onRemoteConnectedChanged(bool remoteConnected)
|
void TunnelProxyTransport::onRemoteConnectedChanged(bool remoteConnected)
|
||||||
{
|
{
|
||||||
qDebug() << "Tunnel proxy remote connection" << (remoteConnected ? "connected" : "disconnected");
|
qDebug() << "Tunnel proxy remote connection" << (remoteConnected ? "connected" : "disconnected");
|
||||||
|
|||||||
@ -44,7 +44,6 @@ public:
|
|||||||
QStringList supportedSchemes() const override;
|
QStringList supportedSchemes() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
using namespace remoteproxyclient;
|
|
||||||
|
|
||||||
class TunnelProxyTransport : public NymeaTransportInterface
|
class TunnelProxyTransport : public NymeaTransportInterface
|
||||||
{
|
{
|
||||||
@ -63,13 +62,13 @@ public:
|
|||||||
QSslCertificate serverCertificate() const override;
|
QSslCertificate serverCertificate() const override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onRemoteConnectionStateChanged(TunnelProxyRemoteConnection::State state);
|
void onRemoteConnectionStateChanged(remoteproxyclient::TunnelProxyRemoteConnection::State state);
|
||||||
void onRemoteConnectedChanged(bool remoteConnected);
|
void onRemoteConnectedChanged(bool remoteConnected);
|
||||||
void onRemoteConnectionErrorOccurred(QAbstractSocket::SocketError error);
|
void onRemoteConnectionErrorOccurred(QAbstractSocket::SocketError error);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QUrl m_url;
|
QUrl m_url;
|
||||||
TunnelProxyRemoteConnection *m_remoteConnection = nullptr;
|
remoteproxyclient::TunnelProxyRemoteConnection *m_remoteConnection = nullptr;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -37,6 +37,7 @@
|
|||||||
#include "connection/websockettransport.h"
|
#include "connection/websockettransport.h"
|
||||||
#include "connection/bluetoothtransport.h"
|
#include "connection/bluetoothtransport.h"
|
||||||
#include "connection/cloudtransport.h"
|
#include "connection/cloudtransport.h"
|
||||||
|
#include "connection/tunnelproxytransport.h"
|
||||||
|
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
@ -57,10 +58,11 @@ JsonRpcClient::JsonRpcClient(QObject *parent) :
|
|||||||
m_id(0)
|
m_id(0)
|
||||||
{
|
{
|
||||||
m_connection = new NymeaConnection(this);
|
m_connection = new NymeaConnection(this);
|
||||||
m_connection->registerTransport(new TcpSocketTransportFactory());
|
// m_connection->registerTransport(new TcpSocketTransportFactory());
|
||||||
m_connection->registerTransport(new WebsocketTransportFactory());
|
// m_connection->registerTransport(new WebsocketTransportFactory());
|
||||||
m_connection->registerTransport(new BluetoothTransportFactoy());
|
// m_connection->registerTransport(new BluetoothTransportFactoy());
|
||||||
m_connection->registerTransport(new CloudTransportFactory());
|
// m_connection->registerTransport(new CloudTransportFactory());
|
||||||
|
m_connection->registerTransport(new TunnelProxyTransportFactory());
|
||||||
|
|
||||||
connect(m_connection, &NymeaConnection::availableBearerTypesChanged, this, &JsonRpcClient::availableBearerTypesChanged);
|
connect(m_connection, &NymeaConnection::availableBearerTypesChanged, this, &JsonRpcClient::availableBearerTypesChanged);
|
||||||
connect(m_connection, &NymeaConnection::connectionStatusChanged, this, &JsonRpcClient::connectionStatusChanged);
|
connect(m_connection, &NymeaConnection::connectionStatusChanged, this, &JsonRpcClient::connectionStatusChanged);
|
||||||
|
|||||||
@ -312,6 +312,7 @@ Item {
|
|||||||
onConnectedChanged: {
|
onConnectedChanged: {
|
||||||
print("json client connected changed", engine.jsonRpcClient.connected, engine.jsonRpcClient.serverUuid)
|
print("json client connected changed", engine.jsonRpcClient.connected, engine.jsonRpcClient.serverUuid)
|
||||||
if (engine.jsonRpcClient.connected) {
|
if (engine.jsonRpcClient.connected) {
|
||||||
|
engine.jsonRpcClient.currentHost.addTunnelConnection();
|
||||||
nymeaDiscovery.cacheHost(engine.jsonRpcClient.currentHost)
|
nymeaDiscovery.cacheHost(engine.jsonRpcClient.currentHost)
|
||||||
configuredHost.uuid = engine.jsonRpcClient.serverUuid
|
configuredHost.uuid = engine.jsonRpcClient.serverUuid
|
||||||
// tabSettings.lastConnectedHost = engine.jsonRpcClient.serverUuid
|
// tabSettings.lastConnectedHost = engine.jsonRpcClient.serverUuid
|
||||||
|
|||||||
Reference in New Issue
Block a user