MCPcopy Create free account
hub / github.com/cutelyst/simple-mail / parseResponseCode

Method parseResponseCode

src/server.cpp:576–615  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

574}
575
576bool ServerPrivate::parseResponseCode(int expectedCode,
577 Server::SmtpError defaultError,
578 QByteArray *responseMessage)
579{
580 // Save the server's response
581 const QByteArray responseText = socket->readLine().trimmed();
582 qCDebug(SIMPLEMAIL_SERVER) << "Got response" << responseText << "expected" << expectedCode;
583
584 // Extract the respose code from the server's responce (first 3 digits)
585 const int responseCode = responseText.left(3).toInt();
586
587 if (responseCode / 100 == 4) {
588 failConnection(Server::ServerError, responseCode, QString::fromLatin1(responseText));
589 return false;
590 }
591
592 if (responseCode / 100 == 5) {
593 failConnection(Server::ClientError, responseCode, QString::fromLatin1(responseText));
594 return false;
595 }
596
597 if (responseText[3] == ' ') {
598 if (responseCode != expectedCode) {
599 const QString lastError = QString::fromLatin1(responseText);
600 qCWarning(SIMPLEMAIL_SERVER)
601 << "Unexpected server response" << lastError << expectedCode;
602 failConnection(defaultError, responseCode, lastError);
603 return false;
604 }
605 if (responseMessage) {
606 *responseMessage = responseText.mid(4);
607 }
608 return true;
609 }
610
611 const QString lastError = QString::fromLatin1(responseText);
612 qCWarning(SIMPLEMAIL_SERVER) << "Unexpected server response" << lastError << expectedCode;
613 failConnection(defaultError, responseCode, lastError);
614 return false;
615}
616
617int ServerPrivate::parseResponseCode(QByteArray *responseMessage)
618{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected