]> Some of my projects - anidbudpclient.git/commitdiff
Add detection incorrect API Key.
authorAPTX <marek321@gmail.com>
Tue, 3 Jan 2012 01:30:02 +0000 (02:30 +0100)
committerAPTX <marek321@gmail.com>
Tue, 3 Jan 2012 01:30:02 +0000 (02:30 +0100)
client.cpp

index 078db26b2877f556bcb54eed8c2fe94b1969ee3f..142255d4e430137965502017da44b6676ea872c9 100644 (file)
@@ -266,6 +266,8 @@ qDebug() << "Entering Disconnected State";
 #endif
        if (socket->state() == QAbstractSocket::BoundState)
                socket->disconnectFromHost();
+       m_salt.clear();
+       usingEncryption = false;
 }
 
 void Client::enterConnectingState()
@@ -576,7 +578,7 @@ qDebug() << QString("Recieved datagram from [%1]:%2\nRaw datagram contents:%3")
 
                // Check if it is a 6xx error.
                {
-                       QRegExp rx("(?:50[34]|555|6[0-9]{2}) ");
+                       QRegExp rx("(?:50[34]|555|598|6[0-9]{2}) ");
                        if (rx.exactMatch(tmp.mid(0, 4)))
                        {
                                int replyCode = tmp.mid(0, 3).toInt();
@@ -599,6 +601,15 @@ qDebug() << QString("Recieved datagram from [%1]:%2\nRaw datagram contents:%3")
                                                m_errorString = tr("Server busy. Try again later. Wait at least 30 minutes.");
                                                emit connectionError();
                                                goto endLoop;
+                                       case UNKNOWN_COMMAND:
+                                               if (usingEncryption)
+                                               {
+                                                       m_error = EncryptionError;
+                                                       m_errorString = tr("Server did not recognize encrypted command. Make sure the API Key is correct.");
+                                                       emit connectionError();
+                                                       goto endLoop;
+                                               }
+                                       break;
                                        default:
                                                if (replyCode > 601 && replyCode < 700)
                                                {