Skip to content

Commit

Permalink
Merge pull request emqx#95 from ejvr/emqtt
Browse files Browse the repository at this point in the history
Merged SslNetwork into Network class and minor changes
  • Loading branch information
mwallnoefer committed May 21, 2017
2 parents 835d9b3 + 2f17678 commit db987f1
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 351 deletions.
2 changes: 0 additions & 2 deletions src/mqtt/mqtt.pri
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ PRIVATE_HEADERS += \
$$PWD/qmqtt_message_p.h \
$$PWD/qmqtt_network_p.h \
$$PWD/qmqtt_socket_p.h \
$$PWD/qmqtt_ssl_network_p.h \
$$PWD/qmqtt_ssl_socket_p.h \
$$PWD/qmqtt_timer_p.h

Expand All @@ -26,7 +25,6 @@ SOURCES += \
$$PWD/qmqtt_frame.cpp \
$$PWD/qmqtt_message.cpp \
$$PWD/qmqtt_network.cpp \
$$PWD/qmqtt_ssl_network.cpp \
$$PWD/qmqtt_routesubscription.cpp \
$$PWD/qmqtt_routedmessage.cpp \
$$PWD/qmqtt_router.cpp \
Expand Down
2 changes: 1 addition & 1 deletion src/mqtt/qmqtt_client_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void QMQTT::ClientPrivate::init(const QString& hostName, const quint16 port,
{
_hostName = hostName;
_port = port;
init(new SslNetwork(config, ignoreSelfSigned));
init(new Network(config, ignoreSelfSigned));
}
#endif // QT_NO_SSL

Expand Down
1 change: 0 additions & 1 deletion src/mqtt/qmqtt_client_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include "qmqtt_client.h"
#include "qmqtt_client_p.h"
#include "qmqtt_network_p.h"
#include "qmqtt_ssl_network_p.h"
#include <QTimer>

#ifndef QT_NO_SSL
Expand Down
18 changes: 18 additions & 0 deletions src/mqtt/qmqtt_network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@
#include <QDataStream>
#include "qmqtt_network_p.h"
#include "qmqtt_socket_p.h"
#include "qmqtt_ssl_socket_p.h"
#include "qmqtt_timer_p.h"

const QString DEFAULT_HOST_NAME = QStringLiteral("localhost");
const QHostAddress DEFAULT_HOST = QHostAddress::LocalHost;
const quint16 DEFAULT_PORT = 1883;
const quint16 DEFAULT_SSL_PORT = 8883;
const bool DEFAULT_AUTORECONNECT = false;
const int DEFAULT_AUTORECONNECT_INTERVAL_MS = 5000;

Expand All @@ -52,6 +55,21 @@ QMQTT::Network::Network(QObject* parent)
initialize();
}

#ifndef QT_NO_SSL
QMQTT::Network::Network(const QSslConfiguration &config, bool ignoreSelfSigned, QObject *parent)
: NetworkInterface(parent)
, _port(DEFAULT_SSL_PORT)
, _hostName(DEFAULT_HOST_NAME)
, _autoReconnect(DEFAULT_AUTORECONNECT)
, _autoReconnectInterval(DEFAULT_AUTORECONNECT_INTERVAL_MS)
, _bytesRemaining(0)
, _socket(new QMQTT::SslSocket(config, ignoreSelfSigned))
, _autoReconnectTimer(new QMQTT::Timer)
{
initialize();
}
#endif // QT_NO_SSL

QMQTT::Network::Network(SocketInterface* socketInterface, TimerInterface* timerInterface,
QObject* parent)
: NetworkInterface(parent)
Expand Down
7 changes: 7 additions & 0 deletions src/mqtt/qmqtt_network_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
#include <QByteArray>
#include <QHostAddress>

#ifndef QT_NO_SSL
QT_FORWARD_DECLARE_CLASS(QSslConfiguration)
#endif // QT_NO_SSL

namespace QMQTT {

class SocketInterface;
Expand All @@ -52,6 +56,9 @@ class Network : public NetworkInterface

public:
Network(QObject* parent = NULL);
#ifndef QT_NO_SSL
Network(const QSslConfiguration& config, bool ignoreSelfSigned, QObject* parent = NULL);
#endif // QT_NO_SSL
Network(SocketInterface* socketInterface, TimerInterface* timerInterface,
QObject* parent = NULL);
~Network();
Expand Down
234 changes: 0 additions & 234 deletions src/mqtt/qmqtt_ssl_network.cpp

This file was deleted.

Loading

0 comments on commit db987f1

Please sign in to comment.