]> Some of my projects - anidbudpclient.git/commitdiff
Add error messages for trying to connect without user/pass/api key set.
authorAPTX <marek321@gmail.com>
Sun, 15 Jan 2012 14:00:37 +0000 (15:00 +0100)
committerAPTX <marek321@gmail.com>
Sun, 15 Jan 2012 14:00:37 +0000 (15:00 +0100)
client.cpp

index bdca6cf181097cafa54932fb3909e6a4e5522e3f..03f1e6ae45a125b58a610a01c847b4841fe16286 100644 (file)
@@ -331,17 +331,23 @@ qDebug() << "Entering Authenticating State";
        if (authenticatingStarted)
                return;
 
-       authenticatingStarted = true;
+       if (authCommand.user().isEmpty() || authCommand.pass().isEmpty())
+       {
+               m_error = AuthenticationError;
+               m_errorString = tr("You have to set your AniDB user and password in order to connect.");
+               emit connectionError();
+               return;
+       }
 
        if (m_sessionId.isEmpty())
        {
+               authenticatingStarted = true;
                if (authReply != 0) authReply->deleteLater();
                authReply = createReply(authCommand);
                QObject::connect(authReply, SIGNAL(replyReady(bool)), this, SLOT(doAuthenticate(bool)));
                enqueueControlCommand(authReply, true);
                return;
        }
-       authenticatingStarted = false;
        emit authenticated();
 }
 
@@ -375,17 +381,23 @@ qDebug() << "Entering Encryption State";
        if (encryptionStarted)
                return;
 
-       encryptionStarted = true;
+       if (apiKey().isEmpty())
+       {
+               m_error = EncryptionError;
+               m_errorString = tr("You have to set your API Key in order to use encryption.");
+               emit connectionError();
+               return;
+       }
 
        if (m_enableEncryption && !usingEncryption)
        {
+               encryptionStarted = true;
                if (encryptReply != 0) encryptReply->deleteLater();
                encryptReply = createReply(encryptCommand);
                QObject::connect(encryptReply, SIGNAL(replyReady(bool)), this, SLOT(doEncrypt(bool)));
                enqueueControlCommand(encryptReply, true);
                return;
        }
-       encryptionStarted = false;
        emit encryptionEstablished();
 }