From: APTX Date: Thu, 10 Feb 2011 20:08:09 +0000 (+0100) Subject: Make debug messages conditional. X-Git-Url: https://gitweb.tyo.aptx.org/?a=commitdiff_plain;h=388e51c90971e4863a986589109f281bd1e26aa2;p=anidbudpclient.git Make debug messages conditional. --- diff --git a/proxyclient.cpp b/proxyclient.cpp index b8336b2..3ec8d7b 100644 --- a/proxyclient.cpp +++ b/proxyclient.cpp @@ -46,7 +46,9 @@ void ProxyClient::connect() { peer->connect(m_host, m_hostPort); peer->call("auth", m_user, m_pass); +#ifdef ANIDBUDPCLIENT_PROXY_DEBUG qDebug() << "[CLIENT] CALL auth" << m_user << m_pass; +#endif } void ProxyClient::disconnect(bool graceful) @@ -68,7 +70,9 @@ void ProxyClient::send(AbstractReply *reply) Command cmd = reply->command().rawCommand(); peer->call("sendCommand", reply->id(), buildCmd(cmd.first, cmd.second)); +#ifdef ANIDBUDPCLIENT_PROXY_DEBUG qDebug() << "[CLIENT] CALL sendCommand" << reply->id() << buildCmd(cmd.first, cmd.second); +#endif if (!reply->command().waitForResult()) delete reply; } @@ -76,13 +80,17 @@ qDebug() << "[CLIENT] CALL sendCommand" << reply->id() << buildCmd(cmd.first, cm void ProxyClient::cancel(AbstractReply *command) { peer->call("cancel", command->id()); +#ifdef ANIDBUDPCLIENT_PROXY_DEBUG qDebug() << "[CLIENT] CALL cancel"; +#endif } void ProxyClient::replyRecieved(const QByteArray &id, int replyCodeAsInt, const QString &reply) { ReplyCode replyCode = (ReplyCode) replyCodeAsInt; +#ifdef ANIDBUDPCLIENT_PROXY_DEBUG qDebug() << "[CLIENT] RECV replyRecieved" << id << replyCode << reply; +#endif AbstractReply *command = commands.value(id, 0); if (!command) @@ -97,7 +105,9 @@ qDebug() << "[CLIENT] RECV replyRecieved" << id << replyCode << reply; void ProxyClient::errorRecieved(int errorAsInt) { Error error = (Error) errorAsInt; +#ifdef ANIDBUDPCLIENT_PROXY_DEBUG qDebug() << "[CLIENT] RECV errorRecieved" << error; +#endif m_error = error; emit connectionError(); } diff --git a/proxyserver.cpp b/proxyserver.cpp index f57768e..b7a128b 100644 --- a/proxyserver.cpp +++ b/proxyserver.cpp @@ -68,25 +68,33 @@ void ProxyServer::diconnect() void ProxyServer::auth(quint64 client, const QString &user, const QString &pass) { +#ifdef ANIDBUDPCLIENT_PROXY_DEBUG qDebug() << "[SERVER] RECV auth" << client << user << pass; +#endif if (isAuthed(client)) return; if (m_user != user || m_pass != pass) { peer->call(client, "errorRecieved", (int) AuthenticationError); +#ifdef ANIDBUDPCLIENT_PROXY_DEBUG qDebug() << "[SERVER] CALL errorRecieved" << AuthenticationError; +#endif peer->disconnectClient(client); return; } clientInfo[client].authed = true; - qDebug() << "[SERVER] Auth successful" << client; +#ifdef ANIDBUDPCLIENT_PROXY_DEBUG +qDebug() << "[SERVER] Auth successful" << client; +#endif } void ProxyServer::sendCommand(quint64 client, const QByteArray &id, const QByteArray &rawCommand) { +#ifdef ANIDBUDPCLIENT_PROXY_DEBUG qDebug() << "[SERVER] RECV sendCommand" << client << id << rawCommand; +#endif if (!isAuthed(client)) return; @@ -116,13 +124,17 @@ void ProxyServer::cancel(quint64 client, const QByteArray &id) void ProxyServer::clientConnected(quint64 client) { +#ifdef ANIDBUDPCLIENT_PROXY_DEBUG qDebug() << "client connected" << client; clientInfo.insert(client, ClientInfo()); +#endif } void ProxyServer::clientDisconnected(quint64 client) { +#ifdef ANIDBUDPCLIENT_PROXY_DEBUG qDebug() << "[SERVER] RECV client disconnected" << client; +#endif for (QMap::iterator i = clientCommands.begin(); i != clientCommands.end(); ) { if (i.value() != client) @@ -152,7 +164,9 @@ void ProxyServer::replyReady(bool success) idMapping.remove(id); peer->call(client, "replyRecieved", id, (int) reply->replyCode(), reply->rawReply()); +#ifdef ANIDBUDPCLIENT_PROXY_DEBUG qDebug() << "[SERVER] CALL replyRecieved" << id << reply->replyCode() << reply->rawReply(); +#endif reply->deleteLater(); }