Skip to content

Commit

Permalink
use newer qt connect syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
jkarneges committed Aug 6, 2016
1 parent 6562138 commit ae2d9a6
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 55 deletions.
2 changes: 1 addition & 1 deletion src/addressresolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class AddressResolver::Private : public QObject
log_debug("resolving: [%s]", rawHost.data());

QJDnsSharedRequest *dreq = new QJDnsSharedRequest(dns, this);
connect(dreq, SIGNAL(resultsReady()), SLOT(dreq_resultsReady()));
connect(dreq, &QJDnsSharedRequest::resultsReady, this, &Private::dreq_resultsReady);
dreq->query(rawHost, QJDns::A);
}

Expand Down
16 changes: 8 additions & 8 deletions src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ class App::Private : public QObject
in_valve(0),
in_req_valve(0)
{
connect(ProcessQuit::instance(), SIGNAL(quit()), SLOT(doQuit()));
connect(ProcessQuit::instance(), SIGNAL(hup()), SLOT(reload()));
connect(ProcessQuit::instance(), &ProcessQuit::quit, this, &Private::doQuit);
connect(ProcessQuit::instance(), &ProcessQuit::hup, this, &Private::reload);
}

~Private()
Expand Down Expand Up @@ -387,7 +387,7 @@ class App::Private : public QObject
cleanStringList(&config.denyExps);

dnsDebug = new QJDnsSharedDebug(this);
connect(dnsDebug, SIGNAL(readyRead()), SLOT(dnsDebug_readyRead()));
connect(dnsDebug, &QJDnsSharedDebug::readyRead, this, &Private::dnsDebug_readyRead);

dns = new QJDnsShared(QJDnsShared::UnicastInternet, this);

Expand All @@ -407,7 +407,7 @@ class App::Private : public QObject
return;

in_valve = new QZmq::Valve(in_sock, this);
connect(in_valve, SIGNAL(readyRead(const QList<QByteArray> &)), SLOT(in_readyRead(const QList<QByteArray> &)));
connect(in_valve, &QZmq::Valve::readyRead, this, &Private::in_readyRead);
}

if(!in_stream_spec.isEmpty())
Expand All @@ -417,7 +417,7 @@ class App::Private : public QObject
in_stream_sock->setIdentity(config.clientId);
in_stream_sock->setHwm(inHwm);

connect(in_stream_sock, SIGNAL(readyRead()), SLOT(in_stream_readyRead()));
connect(in_stream_sock, &QZmq::Socket::readyRead, this, &Private::in_stream_readyRead);

if(!bindSpec(in_stream_sock, "in_stream_spec", in_stream_spec, ipcFileMode))
return;
Expand Down Expand Up @@ -445,7 +445,7 @@ class App::Private : public QObject
return;

in_req_valve = new QZmq::Valve(in_req_sock, this);
connect(in_req_valve, SIGNAL(readyRead(const QList<QByteArray> &)), SLOT(in_req_readyRead(const QList<QByteArray> &)));
connect(in_req_valve, &QZmq::Valve::readyRead, this, &Private::in_req_readyRead);
}

if(in_valve)
Expand Down Expand Up @@ -591,8 +591,8 @@ class App::Private : public QObject
}

Worker *w = new Worker(dns, &config, format, this);
connect(w, SIGNAL(readyRead(const QByteArray &, const QVariant &)), SLOT(worker_readyRead(const QByteArray &, const QVariant &)));
connect(w, SIGNAL(finished()), SLOT(worker_finished()));
connect(w, &Worker::readyRead, this, &Private::worker_readyRead);
connect(w, &Worker::finished, this, &Private::worker_finished);

workers += w;

Expand Down
14 changes: 7 additions & 7 deletions src/httprequest_curl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ class CurlConnectionManager : public QObject
pendingUpdate(false)
{
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), SLOT(timer_timeout()));
connect(timer, &QTimer::timeout, this, &CurlConnectionManager::timer_timeout);
timer->setSingleShot(true);

curl_global_init(CURL_GLOBAL_ALL);
Expand Down Expand Up @@ -692,12 +692,12 @@ class CurlConnectionManager : public QObject

si->snRead = new QSocketNotifier(s, QSocketNotifier::Read, this);
si->snRead->setEnabled(false);
connect(si->snRead, SIGNAL(activated(int)), SLOT(snRead_activated(int)));
connect(si->snRead, &QSocketNotifier::activated, this, &CurlConnectionManager::snRead_activated);
snMap.insert(si->snRead, si);

si->snWrite = new QSocketNotifier(s, QSocketNotifier::Write, this);
si->snWrite->setEnabled(false);
connect(si->snWrite, SIGNAL(activated(int)), SLOT(snWrite_activated(int)));
connect(si->snWrite, &QSocketNotifier::activated, this, &CurlConnectionManager::snWrite_activated);
snMap.insert(si->snWrite, si);

curl_multi_assign(multi, s, si);
Expand Down Expand Up @@ -857,8 +857,8 @@ class HttpRequest::Private : public QObject
g_man = new CurlConnectionManager(QCoreApplication::instance());

resolver = new AddressResolver(dns, this);
connect(resolver, SIGNAL(resultsReady(const QList<QHostAddress> &)), SLOT(resolver_resultsReady(const QList<QHostAddress> &)));
connect(resolver, SIGNAL(error()), SLOT(resolver_error()));
connect(resolver, &AddressResolver::resultsReady, this, &Private::resolver_resultsReady);
connect(resolver, &AddressResolver::error, this, &Private::resolver_error);
}

~Private()
Expand Down Expand Up @@ -891,7 +891,7 @@ class HttpRequest::Private : public QObject
cleanup();

conn = new CurlConnection;
connect(conn, SIGNAL(updated()), SLOT(conn_updated()));
connect(conn, &CurlConnection::updated, this, &Private::conn_updated);

conn->setupMethod(method, willWriteBody);
conn->out = out;
Expand Down Expand Up @@ -1019,7 +1019,7 @@ class HttpRequest::Private : public QObject
assert(!conn);

conn = new CurlConnection;
connect(conn, SIGNAL(updated()), SLOT(conn_updated()));
connect(conn, &CurlConnection::updated, this, &Private::conn_updated);

// eat any transport headers as they'd likely break things
headers.removeAll("Connection");
Expand Down
12 changes: 6 additions & 6 deletions src/httprequest_qnam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class HttpRequest::Private : public QObject
if(method == "POST" || method == "PUT")
{
outdev = new ReqBodyDevice(this);
connect(outdev, SIGNAL(bytesTaken(int)), SLOT(outdev_bytesTaken(int)));
connect(outdev, &ReqBodyDevice::bytesTaken, this, &Private::outdev_bytesTaken);
outdev->open(QIODevice::ReadOnly);

startConnect();
Expand Down Expand Up @@ -233,7 +233,7 @@ class HttpRequest::Private : public QObject
else
{
JDnsSharedRequest *dreq = new JDnsSharedRequest(dns);
connect(dreq, SIGNAL(resultsReady()), SLOT(dreq_resultsReady()));
connect(dreq, &JDnsSharedRequest::resultsReady, this, &Private::dreq_resultsReady);
dreq->query(QUrl::toAce(host), QJDns::A);
}
}
Expand Down Expand Up @@ -324,10 +324,10 @@ private slots:
}

reply->setParent(this);
connect(reply, SIGNAL(readyRead()), SLOT(reply_readyRead()));
connect(reply, SIGNAL(finished()), SLOT(reply_finished()));
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(reply_error(QNetworkReply::NetworkError)));
connect(reply, SIGNAL(sslErrors(const QList<QSslError> &)), SLOT(reply_sslErrors(const QList<QSslError> &)));
connect(reply, &QNetworkReply::readyRead, this, &Private::reply_readyRead);
connect(reply, &QNetworkReply::finished, this, &Private::reply_finished);
connect(reply, &QNetworkReply::error, this, &Private::reply_error);
connect(reply, &QNetworkReply::sslErrors, this, &Private::reply_sslErrors);
}

void dreq_resultsReady()
Expand Down
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public slots:
void start()
{
app = new App(this);
connect(app, SIGNAL(quit()), SLOT(app_quit()));
connect(app, &App::quit, this, &AppMain::app_quit);
app->start();
}

Expand All @@ -60,7 +60,7 @@ int main(int argc, char **argv)
#endif
QCoreApplication qapp(argc, argv);
AppMain appMain;
QObject::connect(&appMain, SIGNAL(quit()), &qapp, SLOT(quit()));
QObject::connect(&appMain, &AppMain::quit, &qapp, &QCoreApplication::quit);
QTimer::singleShot(0, &appMain, SLOT(start()));
return qapp.exec();
}
Expand Down
16 changes: 8 additions & 8 deletions src/websocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,8 @@ class WebSocket::Private : public QObject
followedRedirects(0)
{
resolver = new AddressResolver(dns, this);
connect(resolver, SIGNAL(resultsReady(const QList<QHostAddress> &)), SLOT(resolver_resultsReady(const QList<QHostAddress> &)));
connect(resolver, SIGNAL(error()), SLOT(resolver_error()));
connect(resolver, &AddressResolver::resultsReady, this, &Private::resolver_resultsReady);
connect(resolver, &AddressResolver::error, this, &Private::resolver_error);
}

~Private()
Expand Down Expand Up @@ -862,12 +862,12 @@ private slots:
return;

sock = new QSslSocket(this);
connect(sock, SIGNAL(connected()), SLOT(sock_connected()));
connect(sock, SIGNAL(readyRead()), SLOT(sock_readyRead()));
connect(sock, SIGNAL(bytesWritten(qint64)), SLOT(sock_bytesWritten(qint64)));
connect(sock, SIGNAL(disconnected()), SLOT(sock_disconnected()));
connect(sock, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(sock_error(QAbstractSocket::SocketError)));
connect(sock, SIGNAL(sslErrors(const QList<QSslError> &)), SLOT(sock_sslErrors(const QList<QSslError> &)));
connect(sock, &QSslSocket::connected, this, &Private::sock_connected);
connect(sock, &QSslSocket::readyRead, this, &Private::sock_readyRead);
connect(sock, &QSslSocket::bytesWritten, this, &Private::sock_bytesWritten);
connect(sock, &QSslSocket::disconnected, this, &Private::sock_disconnected);
connect(sock, static_cast<void (QSslSocket::*)(QAbstractSocket::SocketError)>(&QSslSocket::error), this, &Private::sock_error);
connect(sock, static_cast<void (QSslSocket::*)(const QList<QSslError> &)>(&QSslSocket::sslErrors), this, &Private::sock_sslErrors);

bool useSsl = (requestUri.scheme() == "wss");
int port = requestUri.port(useSsl ? 443 : 80);
Expand Down
30 changes: 15 additions & 15 deletions src/worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,10 @@ class Worker::Private : public QObject
}

hreq = new HttpRequest(dns, this);
connect(hreq, SIGNAL(nextAddress(const QHostAddress &)), SLOT(req_nextAddress(const QHostAddress &)));
connect(hreq, SIGNAL(readyRead()), SLOT(req_readyRead()));
connect(hreq, SIGNAL(bytesWritten(int)), SLOT(req_bytesWritten(int)));
connect(hreq, SIGNAL(error()), SLOT(req_error()));
connect(hreq, &HttpRequest::nextAddress, this, &Private::req_nextAddress);
connect(hreq, &HttpRequest::readyRead, this, &Private::req_readyRead);
connect(hreq, &HttpRequest::bytesWritten, this, &Private::req_bytesWritten);
connect(hreq, &HttpRequest::error, this, &Private::req_error);

maxResponseSize = request.maxSize;
sessionTimeout = request.timeout;
Expand Down Expand Up @@ -346,13 +346,13 @@ class Worker::Private : public QObject
}

ws = new WebSocket(dns, this);
connect(ws, SIGNAL(nextAddress(const QHostAddress &)), SLOT(req_nextAddress(const QHostAddress &)));
connect(ws, SIGNAL(connected()), SLOT(ws_connected()));
connect(ws, SIGNAL(readyRead()), SLOT(ws_readyRead()));
connect(ws, SIGNAL(framesWritten(int)), SLOT(ws_framesWritten(int)));
connect(ws, SIGNAL(peerClosing()), SLOT(ws_peerClosing()));
connect(ws, SIGNAL(closed()), SLOT(ws_closed()));
connect(ws, SIGNAL(error()), SLOT(ws_error()));
connect(ws, &WebSocket::nextAddress, this, &Private::req_nextAddress);
connect(ws, &WebSocket::connected, this, &Private::ws_connected);
connect(ws, &WebSocket::readyRead, this, &Private::ws_readyRead);
connect(ws, &WebSocket::framesWritten, this, &Private::ws_framesWritten);
connect(ws, &WebSocket::peerClosing, this, &Private::ws_peerClosing);
connect(ws, &WebSocket::closed, this, &Private::ws_closed);
connect(ws, &WebSocket::error, this, &Private::ws_error);

if(!request.connectHost.isEmpty())
ws->setConnectHost(request.connectHost);
Expand All @@ -369,27 +369,27 @@ class Worker::Private : public QObject
}

httpActivityTimer = new QTimer(this);
connect(httpActivityTimer, SIGNAL(timeout()), SLOT(httpActivity_timeout()));
connect(httpActivityTimer, &QTimer::timeout, this, &Private::httpActivity_timeout);
httpActivityTimer->setSingleShot(true);
httpActivityTimer->start(config->activityTimeout * 1000);

if(sessionTimeout != -1)
{
httpSessionTimer = new QTimer(this);
connect(httpSessionTimer, SIGNAL(timeout()), SLOT(httpSession_timeout()));
connect(httpSessionTimer, &QTimer::timeout, this, &Private::httpSession_timeout);
httpSessionTimer->setSingleShot(true);
httpSessionTimer->start(sessionTimeout);
}

if(transport == WebSocketTransport || (transport == HttpTransport && mode == Worker::Stream))
{
expireTimer = new QTimer(this);
connect(expireTimer, SIGNAL(timeout()), SLOT(expire_timeout()));
connect(expireTimer, &QTimer::timeout, this, &Private::expire_timeout);
expireTimer->setSingleShot(true);
expireTimer->start(SESSION_EXPIRE);

keepAliveTimer = new QTimer(this);
connect(keepAliveTimer, SIGNAL(timeout()), SLOT(keepAlive_timeout()));
connect(keepAliveTimer, &QTimer::timeout, this, &Private::keepAlive_timeout);
keepAliveTimer->start(SESSION_EXPIRE / 2);
}

Expand Down
10 changes: 5 additions & 5 deletions tests/httprequesttest/httprequesttest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class HttpServer : public QObject
bool listen()
{
server = new QTcpServer(this);
connect(server, SIGNAL(newConnection()), SLOT(server_newConnection()));
connect(server, &QTcpServer::newConnection, this, &HttpServer::server_newConnection);
if(server->listen(QHostAddress::Any, 0))
return true;

Expand Down Expand Up @@ -112,8 +112,8 @@ private slots:

sock = server->nextPendingConnection();
assert(sock);
connect(sock, SIGNAL(readyRead()), SLOT(sock_readyRead()));
connect(sock, SIGNAL(disconnected()), SLOT(sock_disconnected()));
connect(sock, &QTcpSocket::readyRead, this, &HttpServer::sock_readyRead);
connect(sock, &QTcpSocket::disconnected, this, &HttpServer::sock_disconnected);
}

void sock_readyRead()
Expand Down Expand Up @@ -173,7 +173,7 @@ private slots:
}
};

class DnsDebug : QObject
class DnsDebug : public QObject
{
Q_OBJECT

Expand All @@ -185,7 +185,7 @@ class DnsDebug : QObject
QObject(parent)
{
dnsDebug_ = new QJDnsSharedDebug(this);
connect(dnsDebug_, SIGNAL(readyRead()), SLOT(flush()));
connect(dnsDebug_, &QJDnsSharedDebug::readyRead, this, &DnsDebug::flush);
}

void applyTo(QJDnsShared *dns)
Expand Down
6 changes: 3 additions & 3 deletions tests/websockettest/websockettest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class WebSocketServer : public QObject
bool listen()
{
server = new QTcpServer(this);
connect(server, SIGNAL(newConnection()), SLOT(server_newConnection()));
connect(server, &QTcpServer::newConnection, this, &WebSocketServer::server_newConnection);
if(server->listen(QHostAddress::Any, 0))
return true;

Expand Down Expand Up @@ -98,8 +98,8 @@ private slots:
void server_newConnection()
{
sock = server->nextPendingConnection();
connect(sock, SIGNAL(readyRead()), SLOT(sock_readyRead()));
connect(sock, SIGNAL(disconnected()), SLOT(sock_disconnected()));
connect(sock, &QTcpSocket::readyRead, this, &WebSocketServer::sock_readyRead);
connect(sock, &QTcpSocket::disconnected, this, &WebSocketServer::sock_disconnected);
}

void sock_readyRead()
Expand Down

0 comments on commit ae2d9a6

Please sign in to comment.