From: APTX Date: Sun, 15 Jan 2012 14:00:37 +0000 (+0100) Subject: Add error messages for trying to connect without user/pass/api key set. X-Git-Url: https://gitweb.aptx.org/?a=commitdiff_plain;h=673a416cf7adb1f8d98563106c2237fd27a88743;p=anidbudpclient.git Add error messages for trying to connect without user/pass/api key set. --- diff --git a/client.cpp b/client.cpp index bdca6cf..03f1e6a 100644 --- a/client.cpp +++ b/client.cpp @@ -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(); }