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