]> Some of my projects - anidbudpclient.git/commitdiff
Make debug messages conditional.
authorAPTX <marek321@gmail.com>
Thu, 10 Feb 2011 20:08:09 +0000 (21:08 +0100)
committerAPTX <marek321@gmail.com>
Thu, 10 Feb 2011 20:08:09 +0000 (21:08 +0100)
proxyclient.cpp
proxyserver.cpp

index b8336b22040678df3c3d2af3194518787cede645..3ec8d7b81a22b71cb7bcb6a1a79d7ac2615ec44e 100644 (file)
@@ -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();
 }
index f57768e90135c55315b225db1f98a772c13db6b1..b7a128b42d21794337c6a96dd939e41b2692c48f 100644 (file)
@@ -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<QByteArray, quint64>::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();
 }