summaryrefslogtreecommitdiffstats
path: root/tdeioslave/smtp/transactionstate.cpp
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2020-12-07 22:58:44 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2020-12-07 22:58:44 +0900
commit145abc15d57fb29701a12e8a14dcb9c1fd72e9be (patch)
treefbb4f2f737ec6f4e8a85bea5f2ca2257d20d7e22 /tdeioslave/smtp/transactionstate.cpp
parentd95494d97233919fa0b2eebf60759537b793e05b (diff)
downloadtdebase-145abc15d57fb29701a12e8a14dcb9c1fd72e9be.tar.gz
tdebase-145abc15d57fb29701a12e8a14dcb9c1fd72e9be.zip
Renaming of files in preparation for code style tools.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'tdeioslave/smtp/transactionstate.cpp')
-rw-r--r--tdeioslave/smtp/transactionstate.cpp114
1 files changed, 114 insertions, 0 deletions
diff --git a/tdeioslave/smtp/transactionstate.cpp b/tdeioslave/smtp/transactionstate.cpp
new file mode 100644
index 000000000..1d96e44b7
--- /dev/null
+++ b/tdeioslave/smtp/transactionstate.cpp
@@ -0,0 +1,114 @@
+/*
+ transactionstate.cpp
+
+ This file is part of tdeio_smtp, the KDE SMTP tdeioslave.
+ Copyright (c) 2003 Marc Mutz <mutz@kde.org>
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License, version 2, as
+ published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+*/
+
+#include <config.h>
+
+#include "transactionstate.h"
+
+#include <tdeio/global.h>
+#include <tdelocale.h>
+
+#include <tqstringlist.h>
+
+namespace KioSMTP {
+
+ void TransactionState::setFailedFatally( int code, const TQString & msg ) {
+ mFailed = mFailedFatally = true;
+ mErrorCode = code;
+ mErrorMessage = msg;
+ }
+
+ void TransactionState::setMailFromFailed( const TQString & addr, const Response & r ) {
+ setFailed();
+ mErrorCode = TDEIO::ERR_NO_CONTENT;
+ if ( addr.isEmpty() )
+ mErrorMessage = i18n("The server did not accept a blank sender address.\n"
+ "%1").arg( r.errorMessage() );
+ else
+ mErrorMessage = i18n("The server did not accept the sender address \"%1\".\n"
+ "%2").arg( addr ).arg( r.errorMessage() );
+ }
+
+ void TransactionState::addRejectedRecipient( const RecipientRejection & r ) {
+ mRejectedRecipients.push_back( r );
+ if ( mRcptToDenyIsFailure )
+ setFailed();
+ }
+
+ void TransactionState::setDataCommandSucceeded( bool succeeded, const Response & r ) {
+ mDataCommandSucceeded = succeeded;
+ mDataResponse = r;
+ if ( !succeeded )
+ setFailed();
+ else if ( failed() )
+ // can happen with pipelining: the server accepts the DATA, but
+ // we don't want to send the data, so force a connection
+ // shutdown:
+ setFailedFatally();
+ }
+
+ int TransactionState::errorCode() const {
+ if ( !failed() )
+ return 0;
+ if ( mErrorCode )
+ return mErrorCode;
+ if ( haveRejectedRecipients() || !dataCommandSucceeded() )
+ return TDEIO::ERR_NO_CONTENT;
+ // ### what else?
+ return TDEIO::ERR_INTERNAL;
+ }
+
+ TQString TransactionState::errorMessage() const {
+ if ( !failed() )
+ return TQString::null;
+
+ if ( !mErrorMessage.isEmpty() )
+ return mErrorMessage;
+
+ if ( haveRejectedRecipients() ) {
+ TQString msg = i18n("Message sending failed since the following recipients were rejected by the server:\n"
+ "%1");
+ TQStringList recip;
+ for ( RejectedRecipientList::const_iterator it = mRejectedRecipients.begin() ;
+ it != mRejectedRecipients.end() ; ++it )
+ recip.push_back( (*it).recipient + " (" + (*it).reason + ')' );
+ return msg.arg( recip.join("\n") );
+ }
+
+ if ( !dataCommandSucceeded() )
+ return i18n("The attempt to start sending the message content failed.\n"
+ "%1").arg( mDataResponse.errorMessage() );
+
+ // ### what else?
+ return i18n("Unhandled error condition. Please send a bug report.");
+ }
+
+}