23.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
23.2 +++ b/debian/patches/fix-imap-lockups.patch Sat Mar 01 15:21:12 2014 +0100
23.3 @@ -0,0 +1,7107 @@
23.4 +commit 9b09d89342ea522cf356d90649465e93ec743ba4
23.5 +Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>
23.6 +Date: Mon Oct 14 17:45:31 2013 +0200
23.7 +
23.8 + Fix imap lockups.patch
23.9 +
23.10 +diff --git a/kdecore/CMakeLists.txt b/kdecore/CMakeLists.txt
23.11 +index f543f0e..7cdff03 100644
23.12 +--- a/kdecore/CMakeLists.txt
23.13 ++++ b/kdecore/CMakeLists.txt
23.14 +@@ -721,3 +721,5 @@ install(FILES
23.15 + # DESTINATION ${SERVICETYPES_INSTALL_DIR}
23.16 + # )
23.17 +
23.18 ++add_subdirectory(includes)
23.19 ++
23.20 +diff --git a/kdecore/includes/CMakeLists.txt b/kdecore/includes/CMakeLists.txt
23.21 +new file mode 100644
23.22 +index 0000000..2a10c50
23.23 +--- /dev/null
23.24 ++++ b/kdecore/includes/CMakeLists.txt
23.25 +@@ -0,0 +1,34 @@
23.26 ++
23.27 ++macro(install_headers _dir)
23.28 ++ install( DIRECTORY ${_dir} DESTINATION ${INCLUDE_INSTALL_DIR} )
23.29 ++endmacro()
23.30 ++
23.31 ++macro(create_header _file _path _header)
23.32 ++ #For installation
23.33 ++ set(CAMELCASE_INCLUDE_PATH "../${_header}")
23.34 ++ configure_file(config-CamelCaseInclude.cmake ${CMAKE_CURRENT_BINARY_DIR}/KDE/${_file})
23.35 ++ #For including from the kdepimlibs stuff
23.36 ++ set(CAMELCASE_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../${_path}/${_header}")
23.37 ++ configure_file(config-CamelCaseInclude.cmake ${CMAKE_CURRENT_BINARY_DIR}/includes/KDE/${_file})
23.38 ++endmacro()
23.39 ++
23.40 ++create_header(KCalendarSystem date kcalendarsystem.h)
23.41 ++create_header(KConfig config kconfig.h)
23.42 ++create_header(KCodecs text kcodecs.h)
23.43 ++create_header(KConfigGroup config kconfiggroup.h)
23.44 ++create_header(KDateTime date kdatetime.h)
23.45 ++create_header(KDebug io kdebug.h)
23.46 ++create_header(KGlobal kernel kglobal.h)
23.47 ++create_header(KJob jobs kjob.h)
23.48 ++create_header(KLocale localization klocale.h)
23.49 ++create_header(KMimeType services kmimetype.h)
23.50 ++create_header(KRandom util krandom.h)
23.51 ++create_header(KSaveFile io ksavefile.h)
23.52 ++create_header(KStandardDirs kernel kstandarddirs.h)
23.53 ++create_header(KSystemTimeZone date ksystemtimezone.h)
23.54 ++create_header(KTemporaryFile io ktemporaryfile.h)
23.55 ++create_header(KTimeZone date ktimezone.h)
23.56 ++create_header(KUrl io kurl.h)
23.57 ++create_header(KLocalizedString localization klocalizedstring.h)
23.58 ++
23.59 ++install_headers(${CMAKE_CURRENT_BINARY_DIR}/KDE)
23.60 +diff --git a/kdecore/includes/config-CamelCaseInclude.cmake b/kdecore/includes/config-CamelCaseInclude.cmake
23.61 +new file mode 100644
23.62 +index 0000000..b6bb3e9
23.63 +--- /dev/null
23.64 ++++ b/kdecore/includes/config-CamelCaseInclude.cmake
23.65 +@@ -0,0 +1,2 @@
23.66 ++#include "${CAMELCASE_INCLUDE_PATH}"
23.67 ++
23.68 +diff --git a/kdecore/network/ktcpsocket.cpp b/kdecore/network/ktcpsocket.cpp
23.69 +index 17b84d1..cdffccf 100644
23.70 +--- a/kdecore/network/ktcpsocket.cpp
23.71 ++++ b/kdecore/network/ktcpsocket.cpp
23.72 +@@ -63,7 +63,12 @@ static QSsl::SslProtocol qSslProtocolFromK(KTcpSocket::SslVersion sslVersion)
23.73 + return QSsl::AnyProtocol;
23.74 + }
23.75 + //does it contain any valid protocol?
23.76 +- if (!(sslVersion & (KTcpSocket::SslV2 | KTcpSocket::SslV3 | KTcpSocket::TlsV1))) {
23.77 ++ KTcpSocket::SslVersions validVersions (KTcpSocket::SslV2 | KTcpSocket::SslV3 | KTcpSocket::TlsV1);
23.78 ++#if QT_VERSION >= 0x040800
23.79 ++ validVersions |= KTcpSocket::TlsV1SslV3;
23.80 ++ validVersions |= KTcpSocket::SecureProtocols;
23.81 ++#endif
23.82 ++ if (!(sslVersion & validVersions)) {
23.83 + return QSsl::UnknownProtocol;
23.84 + }
23.85 +
23.86 +@@ -316,6 +321,8 @@ public:
23.87 + return KTcpSocket::NetworkError;
23.88 + case QAbstractSocket::UnsupportedSocketOperationError:
23.89 + return KTcpSocket::UnsupportedSocketOperationError;
23.90 ++ case QAbstractSocket::SslHandshakeFailedError:
23.91 ++ return KTcpSocket::SslHandshakeFailedError;
23.92 + case QAbstractSocket::DatagramTooLargeError:
23.93 + //we don't do UDP
23.94 + case QAbstractSocket::AddressInUseError:
23.95 +diff --git a/kdecore/network/ktcpsocket.h b/kdecore/network/ktcpsocket.h
23.96 +index 58dfa2c..c281b3e 100644
23.97 +--- a/kdecore/network/ktcpsocket.h
23.98 ++++ b/kdecore/network/ktcpsocket.h
23.99 +@@ -175,7 +175,8 @@ public:
23.100 + SocketResourceError,
23.101 + SocketTimeoutError,
23.102 + NetworkError,
23.103 +- UnsupportedSocketOperationError
23.104 ++ UnsupportedSocketOperationError,
23.105 ++ SslHandshakeFailedError
23.106 + };
23.107 + /*
23.108 + The following is based on reading the OpenSSL interface code of both QSslSocket
23.109 +diff --git a/kimap/CMakeLists.txt b/kimap/CMakeLists.txt
23.110 +index e8a7b79..978c5ac 100644
23.111 +--- a/kimap/CMakeLists.txt
23.112 ++++ b/kimap/CMakeLists.txt
23.113 +@@ -41,7 +41,12 @@ include_directories(${QT_INCLUDES})
23.114 + #include(GenerateExportHeader)
23.115 +
23.116 +
23.117 +-include_directories( ../kdecore ../ ${CMAKE_CURRENT_BINARY_DIR})
23.118 ++include_directories( ../kdecore
23.119 ++ ${CMAKE_CURRENT_BINARY_DIR}/../kdecore/includes/includes
23.120 ++ ${CMAKE_CURRENT_BINARY_DIR}/../kdecore/includes/includes/KDE
23.121 ++ ../
23.122 ++ ${CMAKE_CURRENT_BINARY_DIR}
23.123 ++)
23.124 +
23.125 +
23.126 +
23.127 +diff --git a/kimap/acl.cpp b/kimap/acl.cpp
23.128 +index 980538b..d0bf3e2 100644
23.129 +--- a/kimap/acl.cpp
23.130 ++++ b/kimap/acl.cpp
23.131 +@@ -21,7 +21,7 @@
23.132 +
23.133 + #include <QtCore/QByteArray>
23.134 + #include <QtCore/QMap>
23.135 +-#include <kglobal.h>
23.136 ++#include <KDE/KGlobal>
23.137 +
23.138 + namespace KIMAP {
23.139 + namespace Acl {
23.140 +@@ -29,8 +29,7 @@ namespace Acl {
23.141 + class RightsMap
23.142 + {
23.143 + public:
23.144 +- RightsMap()
23.145 +- {
23.146 ++ RightsMap() {
23.147 + map['l'] = Lookup;
23.148 + map['r'] = Read;
23.149 + map['s'] = KeepSeen;
23.150 +@@ -60,7 +59,7 @@ class RightsMap
23.151 + QMap<char, Right> map;
23.152 + };
23.153 +
23.154 +-Q_GLOBAL_STATIC(RightsMap, globalRights)
23.155 ++K_GLOBAL_STATIC( RightsMap, globalRights )
23.156 +
23.157 + }
23.158 + }
23.159 +@@ -69,17 +68,18 @@ KIMAP::Acl::Rights KIMAP::Acl::rightsFromString( const QByteArray &string )
23.160 + {
23.161 + Rights result;
23.162 +
23.163 +- if ( string.isEmpty() )
23.164 ++ if ( string.isEmpty() ) {
23.165 + return result;
23.166 ++ }
23.167 +
23.168 + int pos = 0;
23.169 +- if ( string[0] == '+' || string[0]== '-') { // Skip modifier if any
23.170 ++ if ( string[0] == '+' || string[0] == '-' ) { // Skip modifier if any
23.171 + pos++;
23.172 + }
23.173 +
23.174 + for ( int i = pos; i < string.size(); i++ ) {
23.175 +- if ( globalRights()->map.contains( string[i] ) ) {
23.176 +- result|= globalRights()->map[string[i]];
23.177 ++ if ( globalRights->map.contains( string[i] ) ) {
23.178 ++ result|= globalRights->map[string[i]];
23.179 + }
23.180 + }
23.181 +
23.182 +@@ -90,9 +90,9 @@ QByteArray KIMAP::Acl::rightsToString( Rights rights )
23.183 + {
23.184 + QByteArray result;
23.185 +
23.186 +- for ( int right = Lookup; right<=Custom9; right<<=1 ) {
23.187 ++ for ( int right = Lookup; right <= Custom9; right <<= 1 ) {
23.188 + if ( rights & right ) {
23.189 +- result+= globalRights()->map.key( (Right)right );
23.190 ++ result += globalRights->map.key( (Right)right );
23.191 + }
23.192 + }
23.193 +
23.194 +@@ -125,3 +125,5 @@ KIMAP::Acl::Rights KIMAP::Acl::denormalizedRights( KIMAP::Acl::Rights rights )
23.195 + return denormalized;
23.196 + }
23.197 +
23.198 ++#include "acl.moc"
23.199 ++
23.200 +diff --git a/kimap/acl.h b/kimap/acl.h
23.201 +index 40e738f..2df610c 100644
23.202 +--- a/kimap/acl.h
23.203 ++++ b/kimap/acl.h
23.204 +@@ -89,17 +89,19 @@ enum Right {
23.205 + Custom9 = 0x800000 /**< Server-specific right 9 */
23.206 + };
23.207 +
23.208 +-Q_DECLARE_FLAGS(Rights, Right)
23.209 ++Q_DECLARE_FLAGS( Rights, Right )
23.210 +
23.211 + /**
23.212 + * Returns a rights mask that has no obsolete members anymore, i.e. obsolete flags are removed and
23.213 + * replaced by their successors.
23.214 ++ * @param rights set of #Rights flags to normalize
23.215 + * @since 4.6
23.216 + */
23.217 + KIMAP_EXPORT Rights normalizedRights( Rights rights );
23.218 +
23.219 + /**
23.220 + * Returns a rights mask that contains both obsolete and new flags if one of them is set.
23.221 ++ * @param rights set of #Rights flags to augment
23.222 + * @since 4.6
23.223 + */
23.224 + KIMAP_EXPORT Rights denormalizedRights( Rights rights );
23.225 +diff --git a/kimap/acljobbase.cpp b/kimap/acljobbase.cpp
23.226 +index 9bfe29a..5df4420 100644
23.227 +--- a/kimap/acljobbase.cpp
23.228 ++++ b/kimap/acljobbase.cpp
23.229 +@@ -22,8 +22,8 @@
23.230 + #include "message_p.h"
23.231 + #include "session_p.h"
23.232 +
23.233 +-#include <klocale.h>
23.234 +-#include <kdebug.h>
23.235 ++#include <KDE/KLocalizedString>
23.236 ++#include <KDE/KDebug>
23.237 +
23.238 + using namespace KIMAP;
23.239 +
23.240 +@@ -56,7 +56,7 @@ void AclJobBasePrivate::setRights(const QByteArray& rights)
23.241 + break;
23.242 + }
23.243 +
23.244 +- rightList = Acl::rightsFromString(rights);
23.245 ++ rightList = Acl::rightsFromString( rights );
23.246 + }
23.247 +
23.248 + void AclJobBasePrivate::setRights(AclJobBase::AclModifier _modifier, Acl::Rights rights)
23.249 +@@ -66,16 +66,13 @@ void AclJobBasePrivate::setRights(AclJobBase::AclModifier _modifier, Acl::Rights
23.250 + rightList|= rights;
23.251 + }
23.252 +
23.253 +-
23.254 +-
23.255 + AclJobBase::AclJobBase( Session *session )
23.256 +- : Job( *new AclJobBasePrivate(session, i18n("AclJobBase")) )
23.257 ++ : Job( *new AclJobBasePrivate( session, i18n( "AclJobBase" ) ) )
23.258 + {
23.259 + }
23.260 +
23.261 +-
23.262 + AclJobBase::AclJobBase( JobPrivate &dd )
23.263 +- : Job(dd)
23.264 ++ : Job( dd )
23.265 + {
23.266 +
23.267 + }
23.268 +@@ -84,17 +81,17 @@ AclJobBase::~AclJobBase()
23.269 + {
23.270 + }
23.271 +
23.272 +-
23.273 + void AclJobBase::setMailBox( const QString &mailBox )
23.274 + {
23.275 +- Q_D(AclJobBase);
23.276 ++ Q_D( AclJobBase );
23.277 + d->mailBox = mailBox;
23.278 + }
23.279 +
23.280 + QString AclJobBase::mailBox() const
23.281 + {
23.282 +- Q_D(const AclJobBase);
23.283 ++ Q_D( const AclJobBase );
23.284 + return d->mailBox;
23.285 + }
23.286 +
23.287 +-#include "acljobbase.moc"
23.288 +\ No newline at end of file
23.289 ++#include "acljobbase.moc"
23.290 ++
23.291 +diff --git a/kimap/acljobbase.h b/kimap/acljobbase.h
23.292 +index 39616a2..fe67319 100644
23.293 +--- a/kimap/acljobbase.h
23.294 ++++ b/kimap/acljobbase.h
23.295 +@@ -43,7 +43,7 @@ class AclJobBasePrivate;
23.296 + class KIMAP_EXPORT AclJobBase : public Job
23.297 + {
23.298 + Q_OBJECT
23.299 +- Q_DECLARE_PRIVATE(AclJobBase)
23.300 ++ Q_DECLARE_PRIVATE( AclJobBase )
23.301 +
23.302 + friend class SessionPrivate;
23.303 +
23.304 +diff --git a/kimap/acljobbase_p.h b/kimap/acljobbase_p.h
23.305 +index 7550489..45345bd 100644
23.306 +--- a/kimap/acljobbase_p.h
23.307 ++++ b/kimap/acljobbase_p.h
23.308 +@@ -23,14 +23,14 @@
23.309 + #include "acljobbase.h"
23.310 + #include "job_p.h"
23.311 + #include "session.h"
23.312 +-#include <klocale.h>
23.313 ++#include <KDE/KLocalizedString>
23.314 +
23.315 + namespace KIMAP
23.316 + {
23.317 + class AclJobBasePrivate : public JobPrivate
23.318 + {
23.319 + public:
23.320 +- AclJobBasePrivate( Session *session, const QString& name ) : JobPrivate(session, name), rightList(Acl::None), modifier(AclJobBase::Change)
23.321 ++ AclJobBasePrivate( Session *session, const QString& name ) : JobPrivate( session, name ), rightList( Acl::None ), modifier( AclJobBase::Change )
23.322 + {
23.323 + }
23.324 + ~AclJobBasePrivate() { }
23.325 +diff --git a/kimap/appendjob.cpp b/kimap/appendjob.cpp
23.326 +index b0e5c83..bda3904 100644
23.327 +--- a/kimap/appendjob.cpp
23.328 ++++ b/kimap/appendjob.cpp
23.329 +@@ -19,7 +19,7 @@
23.330 +
23.331 + #include "appendjob.h"
23.332 +
23.333 +-#include <klocale.h>
23.334 ++#include <KDE/KLocalizedString>
23.335 +
23.336 + #include "job_p.h"
23.337 + #include "message_p.h"
23.338 +@@ -44,7 +44,7 @@ namespace KIMAP
23.339 + using namespace KIMAP;
23.340 +
23.341 + AppendJob::AppendJob( Session *session )
23.342 +- : Job( *new AppendJobPrivate(session, i18n("Append")) )
23.343 ++ : Job( *new AppendJobPrivate( session, i18n( "Append" ) ) )
23.344 + {
23.345 + }
23.346 +
23.347 +@@ -54,73 +54,73 @@ AppendJob::~AppendJob()
23.348 +
23.349 + void AppendJob::setMailBox( const QString &mailBox )
23.350 + {
23.351 +- Q_D(AppendJob);
23.352 ++ Q_D( AppendJob );
23.353 + d->mailBox = mailBox;
23.354 + }
23.355 +
23.356 + QString AppendJob::mailBox() const
23.357 + {
23.358 +- Q_D(const AppendJob);
23.359 ++ Q_D( const AppendJob );
23.360 + return d->mailBox;
23.361 + }
23.362 +
23.363 + void AppendJob::setFlags( const QList<QByteArray> &flags)
23.364 + {
23.365 +- Q_D(AppendJob);
23.366 ++ Q_D( AppendJob );
23.367 + d->flags = flags;
23.368 + }
23.369 +
23.370 + QList<QByteArray> AppendJob::flags() const
23.371 + {
23.372 +- Q_D(const AppendJob);
23.373 ++ Q_D( const AppendJob );
23.374 + return d->flags;
23.375 + }
23.376 +
23.377 + void AppendJob::setContent( const QByteArray &content )
23.378 + {
23.379 +- Q_D(AppendJob);
23.380 ++ Q_D( AppendJob );
23.381 + d->content = content;
23.382 + }
23.383 +
23.384 + QByteArray AppendJob::content() const
23.385 + {
23.386 +- Q_D(const AppendJob);
23.387 ++ Q_D( const AppendJob );
23.388 + return d->content;
23.389 + }
23.390 +
23.391 + qint64 AppendJob::uid() const
23.392 + {
23.393 +- Q_D(const AppendJob);
23.394 ++ Q_D( const AppendJob );
23.395 + return d->uid;
23.396 + }
23.397 +
23.398 + void AppendJob::doStart()
23.399 + {
23.400 +- Q_D(AppendJob);
23.401 ++ Q_D( AppendJob );
23.402 +
23.403 +- QByteArray parameters = '\"'+KIMAP::encodeImapFolderName( d->mailBox.toUtf8() )+'\"';
23.404 ++ QByteArray parameters = '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"';
23.405 +
23.406 + if ( !d->flags.isEmpty() ) {
23.407 +- parameters+=" (";
23.408 ++ parameters += " (";
23.409 + foreach ( const QByteArray &flag, d->flags ) {
23.410 +- parameters+= flag+' ';
23.411 ++ parameters+= flag + ' ';
23.412 + }
23.413 +- parameters.chop(1);
23.414 +- parameters+=')';
23.415 ++ parameters.chop( 1 );
23.416 ++ parameters += ')';
23.417 + }
23.418 +
23.419 +- parameters+=" {"+QByteArray::number(d->content.size())+'}';
23.420 ++ parameters += " {" + QByteArray::number( d->content.size() ) + '}';
23.421 +
23.422 + d->tags << d->sessionInternal()->sendCommand( "APPEND", parameters );
23.423 + }
23.424 +
23.425 + void AppendJob::handleResponse( const Message &response )
23.426 + {
23.427 +- Q_D(AppendJob);
23.428 ++ Q_D( AppendJob );
23.429 +
23.430 + for ( QList<Message::Part>::ConstIterator it = response.responseCode.begin();
23.431 + it != response.responseCode.end(); ++it ) {
23.432 +- if ( it->toString()=="APPENDUID" ) {
23.433 ++ if ( it->toString() == "APPENDUID" ) {
23.434 + it = it + 2;
23.435 + if ( it != response.responseCode.end() ) {
23.436 + d->uid = it->toString().toLongLong();
23.437 +@@ -129,7 +129,7 @@ void AppendJob::handleResponse( const Message &response )
23.438 + }
23.439 + }
23.440 +
23.441 +- if (handleErrorReplies(response) == NotHandled ) {
23.442 ++ if ( handleErrorReplies( response ) == NotHandled ) {
23.443 + if ( response.content[0].toString() == "+" ) {
23.444 + d->sessionInternal()->sendData( d->content );
23.445 + }
23.446 +@@ -137,3 +137,4 @@ void AppendJob::handleResponse( const Message &response )
23.447 + }
23.448 +
23.449 + #include "appendjob.moc"
23.450 ++
23.451 +diff --git a/kimap/appendjob.h b/kimap/appendjob.h
23.452 +index 9fdc2bd..d01f4f2 100644
23.453 +--- a/kimap/appendjob.h
23.454 ++++ b/kimap/appendjob.h
23.455 +@@ -42,7 +42,7 @@ class AppendJobPrivate;
23.456 + class KIMAP_EXPORT AppendJob : public Job
23.457 + {
23.458 + Q_OBJECT
23.459 +- Q_DECLARE_PRIVATE(AppendJob)
23.460 ++ Q_DECLARE_PRIVATE( AppendJob )
23.461 +
23.462 + friend class SessionPrivate;
23.463 +
23.464 +diff --git a/kimap/capabilitiesjob.cpp b/kimap/capabilitiesjob.cpp
23.465 +index b07e1b9..a9b52dc 100644
23.466 +--- a/kimap/capabilitiesjob.cpp
23.467 ++++ b/kimap/capabilitiesjob.cpp
23.468 +@@ -19,7 +19,7 @@
23.469 +
23.470 + #include "capabilitiesjob.h"
23.471 +
23.472 +-#include <klocale.h>
23.473 ++#include <KDE/KLocalizedString>
23.474 +
23.475 + #include "job_p.h"
23.476 + #include "message_p.h"
23.477 +@@ -30,7 +30,7 @@ namespace KIMAP
23.478 + class CapabilitiesJobPrivate : public JobPrivate
23.479 + {
23.480 + public:
23.481 +- CapabilitiesJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { }
23.482 ++ CapabilitiesJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { }
23.483 + ~CapabilitiesJobPrivate() { }
23.484 +
23.485 + QStringList capabilities;
23.486 +@@ -40,7 +40,7 @@ namespace KIMAP
23.487 + using namespace KIMAP;
23.488 +
23.489 + CapabilitiesJob::CapabilitiesJob( Session *session )
23.490 +- : Job( *new CapabilitiesJobPrivate(session, i18n("Capabilities")) )
23.491 ++ : Job( *new CapabilitiesJobPrivate( session, i18n( "Capabilities" ) ) )
23.492 + {
23.493 + }
23.494 +
23.495 +@@ -50,29 +50,30 @@ CapabilitiesJob::~CapabilitiesJob()
23.496 +
23.497 + QStringList CapabilitiesJob::capabilities() const
23.498 + {
23.499 +- Q_D(const CapabilitiesJob);
23.500 ++ Q_D( const CapabilitiesJob );
23.501 + return d->capabilities;
23.502 + }
23.503 +
23.504 + void CapabilitiesJob::doStart()
23.505 + {
23.506 +- Q_D(CapabilitiesJob);
23.507 ++ Q_D( CapabilitiesJob );
23.508 + d->tags << d->sessionInternal()->sendCommand( "CAPABILITY" );
23.509 + }
23.510 +
23.511 + void CapabilitiesJob::handleResponse( const Message &response )
23.512 + {
23.513 +
23.514 +- Q_D(CapabilitiesJob);
23.515 +- if (handleErrorReplies(response) == NotHandled) {
23.516 +- if ( response.content.size() >= 2
23.517 +- && response.content[1].toString()=="CAPABILITY" ) {
23.518 +- for (int i=2; i<response.content.size(); ++i) {
23.519 ++ Q_D( CapabilitiesJob );
23.520 ++ if ( handleErrorReplies( response ) == NotHandled ) {
23.521 ++ if ( response.content.size() >= 2 &&
23.522 ++ response.content[1].toString() == "CAPABILITY" ) {
23.523 ++ for ( int i = 2; i < response.content.size(); ++i ) {
23.524 + d->capabilities << response.content[i].toString().toUpper();
23.525 + }
23.526 +- emit capabilitiesReceived(d->capabilities);
23.527 ++ emit capabilitiesReceived( d->capabilities );
23.528 + }
23.529 + }
23.530 + }
23.531 +
23.532 + #include "capabilitiesjob.moc"
23.533 ++
23.534 +diff --git a/kimap/capabilitiesjob.h b/kimap/capabilitiesjob.h
23.535 +index 0306f26..42ab3b1 100644
23.536 +--- a/kimap/capabilitiesjob.h
23.537 ++++ b/kimap/capabilitiesjob.h
23.538 +@@ -45,7 +45,7 @@ class CapabilitiesJobPrivate;
23.539 + class KIMAP_EXPORT CapabilitiesJob : public Job
23.540 + {
23.541 + Q_OBJECT
23.542 +- Q_DECLARE_PRIVATE(CapabilitiesJob)
23.543 ++ Q_DECLARE_PRIVATE( CapabilitiesJob )
23.544 +
23.545 + friend class SessionPrivate;
23.546 +
23.547 +diff --git a/kimap/closejob.cpp b/kimap/closejob.cpp
23.548 +index ea6416f..a59f386 100644
23.549 +--- a/kimap/closejob.cpp
23.550 ++++ b/kimap/closejob.cpp
23.551 +@@ -19,7 +19,7 @@
23.552 +
23.553 + #include "closejob.h"
23.554 +
23.555 +-#include <klocale.h>
23.556 ++#include <KDE/KLocalizedString>
23.557 +
23.558 + #include "job_p.h"
23.559 + #include "message_p.h"
23.560 +@@ -30,7 +30,7 @@ namespace KIMAP
23.561 + class CloseJobPrivate : public JobPrivate
23.562 + {
23.563 + public:
23.564 +- CloseJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { }
23.565 ++ CloseJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { }
23.566 + ~CloseJobPrivate() { }
23.567 + };
23.568 + }
23.569 +@@ -38,7 +38,7 @@ namespace KIMAP
23.570 + using namespace KIMAP;
23.571 +
23.572 + CloseJob::CloseJob( Session *session )
23.573 +- : Job( *new CloseJobPrivate(session, i18n("Close")) )
23.574 ++ : Job( *new CloseJobPrivate( session, i18n( "Close" ) ) )
23.575 + {
23.576 + }
23.577 +
23.578 +@@ -48,8 +48,9 @@ CloseJob::~CloseJob()
23.579 +
23.580 + void CloseJob::doStart()
23.581 + {
23.582 +- Q_D(CloseJob);
23.583 ++ Q_D( CloseJob );
23.584 + d->tags << d->sessionInternal()->sendCommand( "CLOSE" );
23.585 + }
23.586 +
23.587 + #include "closejob.moc"
23.588 ++
23.589 +diff --git a/kimap/closejob.h b/kimap/closejob.h
23.590 +index 3cadc72..35d64bd 100644
23.591 +--- a/kimap/closejob.h
23.592 ++++ b/kimap/closejob.h
23.593 +@@ -52,7 +52,7 @@ class CloseJobPrivate;
23.594 + class KIMAP_EXPORT CloseJob : public Job
23.595 + {
23.596 + Q_OBJECT
23.597 +- Q_DECLARE_PRIVATE(CloseJob)
23.598 ++ Q_DECLARE_PRIVATE( CloseJob )
23.599 +
23.600 + friend class SessionPrivate;
23.601 +
23.602 +diff --git a/kimap/copyjob.cpp b/kimap/copyjob.cpp
23.603 +index 05f2efb..a07d509 100644
23.604 +--- a/kimap/copyjob.cpp
23.605 ++++ b/kimap/copyjob.cpp
23.606 +@@ -19,8 +19,8 @@
23.607 +
23.608 + #include "copyjob.h"
23.609 +
23.610 +-#include <klocale.h>
23.611 +-#include <kdebug.h>
23.612 ++#include <KDE/KLocalizedString>
23.613 ++#include <KDE/KDebug>
23.614 +
23.615 + #include "job_p.h"
23.616 + #include "message_p.h"
23.617 +@@ -34,7 +34,7 @@ namespace KIMAP
23.618 + class CopyJobPrivate : public JobPrivate
23.619 + {
23.620 + public:
23.621 +- CopyJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { }
23.622 ++ CopyJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { }
23.623 + ~CopyJobPrivate() { }
23.624 +
23.625 + QString mailBox;
23.626 +@@ -47,9 +47,9 @@ namespace KIMAP
23.627 + using namespace KIMAP;
23.628 +
23.629 + CopyJob::CopyJob( Session *session )
23.630 +- : Job( *new CopyJobPrivate(session, i18n("Copy")) )
23.631 ++ : Job( *new CopyJobPrivate( session, i18n( "Copy" ) ) )
23.632 + {
23.633 +- Q_D(CopyJob);
23.634 ++ Q_D( CopyJob );
23.635 + d->uidBased = false;
23.636 + }
23.637 +
23.638 +@@ -59,53 +59,52 @@ CopyJob::~CopyJob()
23.639 +
23.640 + void CopyJob::setMailBox( const QString &mailBox )
23.641 + {
23.642 +- Q_D(CopyJob);
23.643 ++ Q_D( CopyJob );
23.644 + d->mailBox = mailBox;
23.645 + }
23.646 +
23.647 + QString CopyJob::mailBox() const
23.648 + {
23.649 +- Q_D(const CopyJob);
23.650 ++ Q_D( const CopyJob );
23.651 + return d->mailBox;
23.652 + }
23.653 +
23.654 + void CopyJob::setSequenceSet( const ImapSet &set )
23.655 + {
23.656 +- Q_D(CopyJob);
23.657 ++ Q_D( CopyJob );
23.658 + d->set = set;
23.659 + }
23.660 +
23.661 + ImapSet CopyJob::sequenceSet() const
23.662 + {
23.663 +- Q_D(const CopyJob);
23.664 ++ Q_D( const CopyJob );
23.665 + return d->set;
23.666 + }
23.667 +
23.668 +-
23.669 + void CopyJob::setUidBased( bool uidBased )
23.670 + {
23.671 +- Q_D(CopyJob);
23.672 ++ Q_D( CopyJob );
23.673 + d->uidBased = uidBased;
23.674 + }
23.675 +
23.676 + bool CopyJob::isUidBased() const
23.677 + {
23.678 +- Q_D(const CopyJob);
23.679 ++ Q_D( const CopyJob );
23.680 + return d->uidBased;
23.681 + }
23.682 +
23.683 + ImapSet CopyJob::resultingUids() const
23.684 + {
23.685 +- Q_D(const CopyJob);
23.686 ++ Q_D( const CopyJob );
23.687 + return d->resultingUids;
23.688 + }
23.689 +
23.690 + void CopyJob::doStart()
23.691 + {
23.692 +- Q_D(CopyJob);
23.693 ++ Q_D( CopyJob );
23.694 +
23.695 + QByteArray parameters = d->set.toImapSequenceSet()+' ';
23.696 +- parameters+= '\"'+KIMAP::encodeImapFolderName( d->mailBox.toUtf8() )+'\"';
23.697 ++ parameters += '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"';
23.698 +
23.699 + QByteArray command = "COPY";
23.700 + if ( d->uidBased ) {
23.701 +@@ -117,11 +116,11 @@ void CopyJob::doStart()
23.702 +
23.703 + void CopyJob::handleResponse( const Message &response )
23.704 + {
23.705 +- Q_D(CopyJob);
23.706 ++ Q_D( CopyJob );
23.707 +
23.708 + for ( QList<Message::Part>::ConstIterator it = response.responseCode.begin();
23.709 + it != response.responseCode.end(); ++it ) {
23.710 +- if ( it->toString()=="COPYUID" ) {
23.711 ++ if ( it->toString() == "COPYUID" ) {
23.712 + it = it + 3;
23.713 + if ( it < response.responseCode.end() ) {
23.714 + d->resultingUids = ImapSet::fromImapSequenceSet( it->toString() );
23.715 +@@ -134,3 +133,4 @@ void CopyJob::handleResponse( const Message &response )
23.716 + }
23.717 +
23.718 + #include "copyjob.moc"
23.719 ++
23.720 +diff --git a/kimap/copyjob.h b/kimap/copyjob.h
23.721 +index 5e75fdc..c64bcbf 100644
23.722 +--- a/kimap/copyjob.h
23.723 ++++ b/kimap/copyjob.h
23.724 +@@ -46,7 +46,7 @@ class CopyJobPrivate;
23.725 + class KIMAP_EXPORT CopyJob : public Job
23.726 + {
23.727 + Q_OBJECT
23.728 +- Q_DECLARE_PRIVATE(CopyJob)
23.729 ++ Q_DECLARE_PRIVATE( CopyJob )
23.730 +
23.731 + friend class SessionPrivate;
23.732 +
23.733 +diff --git a/kimap/createjob.cpp b/kimap/createjob.cpp
23.734 +index 6f25e0a..b6d486f 100644
23.735 +--- a/kimap/createjob.cpp
23.736 ++++ b/kimap/createjob.cpp
23.737 +@@ -19,8 +19,8 @@
23.738 +
23.739 + #include "createjob.h"
23.740 +
23.741 +-#include <klocale.h>
23.742 +-#include <kdebug.h>
23.743 ++#include <KDE/KLocalizedString>
23.744 ++#include <KDE/KDebug>
23.745 +
23.746 + #include "job_p.h"
23.747 + #include "message_p.h"
23.748 +@@ -32,7 +32,7 @@ namespace KIMAP
23.749 + class CreateJobPrivate : public JobPrivate
23.750 + {
23.751 + public:
23.752 +- CreateJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { }
23.753 ++ CreateJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { }
23.754 + ~CreateJobPrivate() { }
23.755 +
23.756 + QString mailBox;
23.757 +@@ -42,7 +42,7 @@ namespace KIMAP
23.758 + using namespace KIMAP;
23.759 +
23.760 + CreateJob::CreateJob( Session *session )
23.761 +- : Job( *new CreateJobPrivate(session, i18n("Create")) )
23.762 ++ : Job( *new CreateJobPrivate( session, i18n( "Create" ) ) )
23.763 + {
23.764 + }
23.765 +
23.766 +@@ -52,20 +52,21 @@ CreateJob::~CreateJob()
23.767 +
23.768 + void CreateJob::doStart()
23.769 + {
23.770 +- Q_D(CreateJob);
23.771 +- d->tags << d->sessionInternal()->sendCommand( "CREATE", '\"'+KIMAP::encodeImapFolderName( d->mailBox.toUtf8() )+'\"' );
23.772 ++ Q_D( CreateJob );
23.773 ++ d->tags << d->sessionInternal()->sendCommand( "CREATE", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"' );
23.774 + }
23.775 +
23.776 + void CreateJob::setMailBox( const QString &mailBox )
23.777 + {
23.778 +- Q_D(CreateJob);
23.779 ++ Q_D( CreateJob );
23.780 + d->mailBox = mailBox;
23.781 + }
23.782 +
23.783 + QString CreateJob::mailBox() const
23.784 + {
23.785 +- Q_D(const CreateJob);
23.786 ++ Q_D( const CreateJob );
23.787 + return d->mailBox;
23.788 + }
23.789 +
23.790 + #include "createjob.moc"
23.791 ++
23.792 +diff --git a/kimap/createjob.h b/kimap/createjob.h
23.793 +index daab478..9977898 100644
23.794 +--- a/kimap/createjob.h
23.795 ++++ b/kimap/createjob.h
23.796 +@@ -47,7 +47,7 @@ class CreateJobPrivate;
23.797 + class KIMAP_EXPORT CreateJob : public Job
23.798 + {
23.799 + Q_OBJECT
23.800 +- Q_DECLARE_PRIVATE(CreateJob)
23.801 ++ Q_DECLARE_PRIVATE( CreateJob )
23.802 +
23.803 + friend class SessionPrivate;
23.804 +
23.805 +diff --git a/kimap/deleteacljob.cpp b/kimap/deleteacljob.cpp
23.806 +index b5ea9a9..ca3a206 100644
23.807 +--- a/kimap/deleteacljob.cpp
23.808 ++++ b/kimap/deleteacljob.cpp
23.809 +@@ -19,8 +19,8 @@
23.810 +
23.811 + #include "deleteacljob.h"
23.812 +
23.813 +-#include <klocale.h>
23.814 +-#include <kdebug.h>
23.815 ++#include <KDE/KLocalizedString>
23.816 ++#include <KDE/KDebug>
23.817 +
23.818 + #include "acljobbase_p.h"
23.819 + #include "message_p.h"
23.820 +@@ -32,7 +32,7 @@ namespace KIMAP
23.821 + class DeleteAclJobPrivate : public AclJobBasePrivate
23.822 + {
23.823 + public:
23.824 +- DeleteAclJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate(session, name) {}
23.825 ++ DeleteAclJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate( session, name ) {}
23.826 + ~DeleteAclJobPrivate() { }
23.827 + };
23.828 + }
23.829 +@@ -42,8 +42,8 @@ using namespace KIMAP;
23.830 + DeleteAclJob::DeleteAclJob( Session *session )
23.831 + : AclJobBase( session )
23.832 + {
23.833 +- Q_D(DeleteAclJob);
23.834 +- d->m_name = i18n("DeleteAclJob");
23.835 ++ Q_D( DeleteAclJob );
23.836 ++ d->m_name = i18n( "DeleteAclJob" );
23.837 + }
23.838 +
23.839 + DeleteAclJob::~DeleteAclJob()
23.840 +@@ -52,21 +52,22 @@ DeleteAclJob::~DeleteAclJob()
23.841 +
23.842 + void DeleteAclJob::doStart()
23.843 + {
23.844 +- Q_D(DeleteAclJob);
23.845 ++ Q_D( DeleteAclJob );
23.846 +
23.847 +- d->tags << d->sessionInternal()->sendCommand( "DELETEACL", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + "\" \"" + d->id);
23.848 ++ d->tags << d->sessionInternal()->sendCommand( "DELETEACL", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + "\" \"" + d->id );
23.849 + }
23.850 +
23.851 + void DeleteAclJob::setIdentifier( const QByteArray &identifier )
23.852 + {
23.853 +- Q_D(DeleteAclJob);
23.854 +- d->setIdentifier(identifier);
23.855 ++ Q_D( DeleteAclJob );
23.856 ++ d->setIdentifier( identifier );
23.857 + }
23.858 +
23.859 + QByteArray DeleteAclJob::identifier()
23.860 + {
23.861 +- Q_D(DeleteAclJob);
23.862 ++ Q_D( DeleteAclJob );
23.863 + return d->identifier();
23.864 + }
23.865 +
23.866 + #include "deleteacljob.moc"
23.867 ++
23.868 +diff --git a/kimap/deleteacljob.h b/kimap/deleteacljob.h
23.869 +index 0f06055..7beed89 100644
23.870 +--- a/kimap/deleteacljob.h
23.871 ++++ b/kimap/deleteacljob.h
23.872 +@@ -47,7 +47,7 @@ class DeleteAclJobPrivate;
23.873 + class KIMAP_EXPORT DeleteAclJob : public AclJobBase
23.874 + {
23.875 + Q_OBJECT
23.876 +- Q_DECLARE_PRIVATE(DeleteAclJob)
23.877 ++ Q_DECLARE_PRIVATE( DeleteAclJob )
23.878 +
23.879 + friend class SessionPrivate;
23.880 +
23.881 +diff --git a/kimap/deletejob.cpp b/kimap/deletejob.cpp
23.882 +index 59201ff..c1149ca 100644
23.883 +--- a/kimap/deletejob.cpp
23.884 ++++ b/kimap/deletejob.cpp
23.885 +@@ -19,8 +19,8 @@
23.886 +
23.887 + #include "deletejob.h"
23.888 +
23.889 +-#include <klocale.h>
23.890 +-#include <kdebug.h>
23.891 ++#include <KDE/KLocalizedString>
23.892 ++#include <KDE/KDebug>
23.893 +
23.894 + #include "job_p.h"
23.895 + #include "message_p.h"
23.896 +@@ -32,7 +32,7 @@ namespace KIMAP
23.897 + class DeleteJobPrivate : public JobPrivate
23.898 + {
23.899 + public:
23.900 +- DeleteJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { }
23.901 ++ DeleteJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { }
23.902 + ~DeleteJobPrivate() { }
23.903 +
23.904 + QString mailBox;
23.905 +@@ -42,7 +42,7 @@ namespace KIMAP
23.906 + using namespace KIMAP;
23.907 +
23.908 + DeleteJob::DeleteJob( Session *session )
23.909 +- : Job( *new DeleteJobPrivate(session, i18n("Delete")) )
23.910 ++ : Job( *new DeleteJobPrivate( session, i18n( "Delete" ) ) )
23.911 + {
23.912 + }
23.913 +
23.914 +@@ -52,20 +52,21 @@ DeleteJob::~DeleteJob()
23.915 +
23.916 + void DeleteJob::doStart()
23.917 + {
23.918 +- Q_D(DeleteJob);
23.919 +- d->tags << d->sessionInternal()->sendCommand( "DELETE", '\"'+KIMAP::encodeImapFolderName( d->mailBox.toUtf8() )+'\"' );
23.920 ++ Q_D( DeleteJob );
23.921 ++ d->tags << d->sessionInternal()->sendCommand( "DELETE", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"' );
23.922 + }
23.923 +
23.924 + void DeleteJob::setMailBox( const QString &mailBox )
23.925 + {
23.926 +- Q_D(DeleteJob);
23.927 ++ Q_D( DeleteJob );
23.928 + d->mailBox = mailBox;
23.929 + }
23.930 +
23.931 + QString DeleteJob::mailBox() const
23.932 + {
23.933 +- Q_D(const DeleteJob);
23.934 ++ Q_D( const DeleteJob );
23.935 + return d->mailBox;
23.936 + }
23.937 +
23.938 +-#include "deletejob.moc"
23.939 +\ No newline at end of file
23.940 ++#include "deletejob.moc"
23.941 ++
23.942 +diff --git a/kimap/deletejob.h b/kimap/deletejob.h
23.943 +index 2876a90..926ee3c 100644
23.944 +--- a/kimap/deletejob.h
23.945 ++++ b/kimap/deletejob.h
23.946 +@@ -46,7 +46,7 @@ class DeleteJobPrivate;
23.947 + class KIMAP_EXPORT DeleteJob : public Job
23.948 + {
23.949 + Q_OBJECT
23.950 +- Q_DECLARE_PRIVATE(DeleteJob)
23.951 ++ Q_DECLARE_PRIVATE( DeleteJob )
23.952 +
23.953 + friend class SessionPrivate;
23.954 +
23.955 +diff --git a/kimap/expungejob.cpp b/kimap/expungejob.cpp
23.956 +index 8da8285..63bed80 100644
23.957 +--- a/kimap/expungejob.cpp
23.958 ++++ b/kimap/expungejob.cpp
23.959 +@@ -19,8 +19,8 @@
23.960 +
23.961 + #include "expungejob.h"
23.962 +
23.963 +-#include <klocale.h>
23.964 +-#include <kdebug.h>
23.965 ++#include <KDE/KLocalizedString>
23.966 ++#include <KDE/KDebug>
23.967 +
23.968 + #include "job_p.h"
23.969 + #include "message_p.h"
23.970 +@@ -31,7 +31,7 @@ namespace KIMAP
23.971 + class ExpungeJobPrivate : public JobPrivate
23.972 + {
23.973 + public:
23.974 +- ExpungeJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { }
23.975 ++ ExpungeJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { }
23.976 + ~ExpungeJobPrivate() { }
23.977 + #if 0
23.978 + QList< int > items;
23.979 +@@ -42,7 +42,7 @@ namespace KIMAP
23.980 + using namespace KIMAP;
23.981 +
23.982 + ExpungeJob::ExpungeJob( Session *session )
23.983 +- : Job( *new ExpungeJobPrivate(session, i18n("Expunge")) )
23.984 ++ : Job( *new ExpungeJobPrivate( session, i18n( "Expunge" ) ) )
23.985 + {
23.986 + }
23.987 +
23.988 +@@ -52,7 +52,7 @@ ExpungeJob::~ExpungeJob()
23.989 +
23.990 + void ExpungeJob::doStart()
23.991 + {
23.992 +- Q_D(ExpungeJob);
23.993 ++ Q_D( ExpungeJob );
23.994 + d->tags << d->sessionInternal()->sendCommand( "EXPUNGE" );
23.995 + }
23.996 +
23.997 +@@ -60,25 +60,26 @@ void ExpungeJob::handleResponse( const Message &response )
23.998 + {
23.999 + // Q_D(ExpungeJob);
23.1000 +
23.1001 +- if (handleErrorReplies(response) == NotHandled) {
23.1002 ++ if ( handleErrorReplies( response ) == NotHandled ) {
23.1003 + if ( response.content.size() >= 2 ) {
23.1004 + QByteArray code = response.content[2].toString();
23.1005 +- if (code == "EXPUNGE") {
23.1006 ++ if ( code == "EXPUNGE" ) {
23.1007 + #if 0
23.1008 + QByteArray s = response.content[1].toString();
23.1009 + bool ok = true;
23.1010 +- int id = s.toInt(&ok);
23.1011 +- if (ok) {
23.1012 +- d->items.append(id);
23.1013 ++ int id = s.toInt( &ok );
23.1014 ++ if ( ok ) {
23.1015 ++ d->items.append( id );
23.1016 + }
23.1017 + //TODO error handling
23.1018 + #endif
23.1019 + return;
23.1020 + }
23.1021 + }
23.1022 +- qDebug() << "Unhandled response: " << response.toString().constData();
23.1023 ++ kDebug() << "Unhandled response: " << response.toString().constData();
23.1024 +
23.1025 + }
23.1026 + }
23.1027 +
23.1028 + #include "expungejob.moc"
23.1029 ++
23.1030 +diff --git a/kimap/expungejob.h b/kimap/expungejob.h
23.1031 +index 9862f59..7e2918b 100644
23.1032 +--- a/kimap/expungejob.h
23.1033 ++++ b/kimap/expungejob.h
23.1034 +@@ -45,7 +45,7 @@ class ExpungeJobPrivate;
23.1035 + class KIMAP_EXPORT ExpungeJob : public Job
23.1036 + {
23.1037 + Q_OBJECT
23.1038 +- Q_DECLARE_PRIVATE(ExpungeJob)
23.1039 ++ Q_DECLARE_PRIVATE( ExpungeJob )
23.1040 +
23.1041 + friend class SessionPrivate;
23.1042 +
23.1043 +diff --git a/kimap/fetchjob.cpp b/kimap/fetchjob.cpp
23.1044 +index 32582b2..bbb12a4 100644
23.1045 +--- a/kimap/fetchjob.cpp
23.1046 ++++ b/kimap/fetchjob.cpp
23.1047 +@@ -20,8 +20,8 @@
23.1048 + #include "fetchjob.h"
23.1049 +
23.1050 + #include <QtCore/QTimer>
23.1051 +-#include <kdebug.h>
23.1052 +-#include <klocale.h>
23.1053 ++#include <KDE/KDebug>
23.1054 ++#include <KDE/KLocalizedString>
23.1055 +
23.1056 + #include "job_p.h"
23.1057 + #include "message_p.h"
23.1058 +@@ -32,7 +32,7 @@ namespace KIMAP
23.1059 + class FetchJobPrivate : public JobPrivate
23.1060 + {
23.1061 + public:
23.1062 +- FetchJobPrivate( FetchJob *job, Session *session, const QString& name ) : JobPrivate( session, name ), q(job), uidBased(false) { }
23.1063 ++ FetchJobPrivate( FetchJob *job, Session *session, const QString& name ) : JobPrivate( session, name ), q( job ), uidBased( false ) { }
23.1064 + ~FetchJobPrivate() { }
23.1065 +
23.1066 + void parseBodyStructure( const QByteArray &structure, int &pos, KMime::Content *content );
23.1067 +@@ -87,9 +87,9 @@ namespace KIMAP
23.1068 + using namespace KIMAP;
23.1069 +
23.1070 + FetchJob::FetchJob( Session *session )
23.1071 +- : Job( *new FetchJobPrivate(this, session, i18n("Fetch")) )
23.1072 ++ : Job( *new FetchJobPrivate( this, session, i18n( "Fetch" ) ) )
23.1073 + {
23.1074 +- Q_D(FetchJob);
23.1075 ++ Q_D( FetchJob );
23.1076 + d->scope.mode = FetchScope::Content;
23.1077 + connect( &d->emitPendingsTimer, SIGNAL(timeout()),
23.1078 + this, SLOT(emitPendings()) );
23.1079 +@@ -101,38 +101,38 @@ FetchJob::~FetchJob()
23.1080 +
23.1081 + void FetchJob::setSequenceSet( const ImapSet &set )
23.1082 + {
23.1083 +- Q_D(FetchJob);
23.1084 ++ Q_D( FetchJob );
23.1085 + Q_ASSERT( !set.toImapSequenceSet().trimmed().isEmpty() );
23.1086 + d->set = set;
23.1087 + }
23.1088 +
23.1089 + ImapSet FetchJob::sequenceSet() const
23.1090 + {
23.1091 +- Q_D(const FetchJob);
23.1092 ++ Q_D( const FetchJob );
23.1093 + return d->set;
23.1094 + }
23.1095 +
23.1096 + void FetchJob::setUidBased(bool uidBased)
23.1097 + {
23.1098 +- Q_D(FetchJob);
23.1099 ++ Q_D( FetchJob );
23.1100 + d->uidBased = uidBased;
23.1101 + }
23.1102 +
23.1103 + bool FetchJob::isUidBased() const
23.1104 + {
23.1105 +- Q_D(const FetchJob);
23.1106 ++ Q_D( const FetchJob );
23.1107 + return d->uidBased;
23.1108 + }
23.1109 +
23.1110 + void FetchJob::setScope( const FetchScope &scope )
23.1111 + {
23.1112 +- Q_D(FetchJob);
23.1113 ++ Q_D( FetchJob );
23.1114 + d->scope = scope;
23.1115 + }
23.1116 +
23.1117 + FetchJob::FetchScope FetchJob::scope() const
23.1118 + {
23.1119 +- Q_D(const FetchJob);
23.1120 ++ Q_D( const FetchJob );
23.1121 + return d->scope;
23.1122 + }
23.1123 +
23.1124 +@@ -163,7 +163,7 @@ QMap<qint64, qint64> FetchJob::uids() const
23.1125 +
23.1126 + void FetchJob::doStart()
23.1127 + {
23.1128 +- Q_D(FetchJob);
23.1129 ++ Q_D( FetchJob );
23.1130 +
23.1131 + QByteArray parameters = d->set.toImapSequenceSet()+' ';
23.1132 + Q_ASSERT( !parameters.trimmed().isEmpty() );
23.1133 +@@ -171,51 +171,51 @@ void FetchJob::doStart()
23.1134 + switch ( d->scope.mode ) {
23.1135 + case FetchScope::Headers:
23.1136 + if ( d->scope.parts.isEmpty() ) {
23.1137 +- parameters+="(RFC822.SIZE INTERNALDATE BODY.PEEK[HEADER.FIELDS (TO FROM MESSAGE-ID REFERENCES IN-REPLY-TO SUBJECT DATE)] FLAGS UID)";
23.1138 ++ parameters += "(RFC822.SIZE INTERNALDATE BODY.PEEK[HEADER.FIELDS (TO FROM MESSAGE-ID REFERENCES IN-REPLY-TO SUBJECT DATE)] FLAGS UID)";
23.1139 + } else {
23.1140 +- parameters+='(';
23.1141 ++ parameters += '(';
23.1142 + foreach ( const QByteArray &part, d->scope.parts ) {
23.1143 +- parameters+="BODY.PEEK["+part+".MIME] ";
23.1144 ++ parameters += "BODY.PEEK[" + part + ".MIME] ";
23.1145 + }
23.1146 +- parameters+="UID)";
23.1147 ++ parameters += "UID)";
23.1148 + }
23.1149 + break;
23.1150 + case FetchScope::Flags:
23.1151 +- parameters+="(FLAGS UID)";
23.1152 ++ parameters += "(FLAGS UID)";
23.1153 + break;
23.1154 + case FetchScope::Structure:
23.1155 +- parameters+="(BODYSTRUCTURE UID)";
23.1156 ++ parameters += "(BODYSTRUCTURE UID)";
23.1157 + break;
23.1158 + case FetchScope::Content:
23.1159 + if ( d->scope.parts.isEmpty() ) {
23.1160 +- parameters+="(BODY.PEEK[] UID)";
23.1161 ++ parameters += "(BODY.PEEK[] UID)";
23.1162 + } else {
23.1163 +- parameters+='(';
23.1164 ++ parameters += '(';
23.1165 + foreach ( const QByteArray &part, d->scope.parts ) {
23.1166 +- parameters+="BODY.PEEK["+part+"] ";
23.1167 ++ parameters += "BODY.PEEK[" + part + "] ";
23.1168 + }
23.1169 +- parameters+="UID)";
23.1170 ++ parameters += "UID)";
23.1171 + }
23.1172 + break;
23.1173 + case FetchScope::Full:
23.1174 +- parameters+="(RFC822.SIZE INTERNALDATE BODY.PEEK[] FLAGS UID)";
23.1175 ++ parameters += "(RFC822.SIZE INTERNALDATE BODY.PEEK[] FLAGS UID)";
23.1176 + break;
23.1177 + case FetchScope::HeaderAndContent:
23.1178 + if ( d->scope.parts.isEmpty() ) {
23.1179 +- parameters+="(BODY.PEEK[] FLAGS UID)";
23.1180 ++ parameters += "(BODY.PEEK[] FLAGS UID)";
23.1181 + } else {
23.1182 +- parameters+="(BODY.PEEK[HEADER.FIELDS (TO FROM MESSAGE-ID REFERENCES IN-REPLY-TO SUBJECT DATE)]";
23.1183 ++ parameters += "(BODY.PEEK[HEADER.FIELDS (TO FROM MESSAGE-ID REFERENCES IN-REPLY-TO SUBJECT DATE)]";
23.1184 + foreach ( const QByteArray &part, d->scope.parts ) {
23.1185 +- parameters+=" BODY.PEEK["+part+".MIME] BODY.PEEK["+part+"]"; //krazy:exclude=doublequote_chars
23.1186 ++ parameters += " BODY.PEEK[" + part + ".MIME] BODY.PEEK[" + part + "]"; //krazy:exclude=doublequote_chars
23.1187 + }
23.1188 +- parameters+=" FLAGS UID)";
23.1189 ++ parameters += " FLAGS UID)";
23.1190 + }
23.1191 + break;
23.1192 + }
23.1193 +
23.1194 + QByteArray command = "FETCH";
23.1195 + if ( d->uidBased ) {
23.1196 +- command = "UID "+command;
23.1197 ++ command = "UID " + command;
23.1198 + }
23.1199 +
23.1200 + d->emitPendingsTimer.start( 100 );
23.1201 +@@ -225,21 +225,21 @@ void FetchJob::doStart()
23.1202 +
23.1203 + void FetchJob::handleResponse( const Message &response )
23.1204 + {
23.1205 +- Q_D(FetchJob);
23.1206 ++ Q_D( FetchJob );
23.1207 +
23.1208 + // We can predict it'll be handled by handleErrorReplies() so stop
23.1209 + // the timer now so that result() will really be the last emitted signal.
23.1210 +- if ( !response.content.isEmpty()
23.1211 +- && d->tags.size() == 1
23.1212 +- && d->tags.contains( response.content.first().toString() ) ) {
23.1213 ++ if ( !response.content.isEmpty() &&
23.1214 ++ d->tags.size() == 1 &&
23.1215 ++ d->tags.contains( response.content.first().toString() ) ) {
23.1216 + d->emitPendingsTimer.stop();
23.1217 + d->emitPendings();
23.1218 + }
23.1219 +
23.1220 +- if (handleErrorReplies(response) == NotHandled ) {
23.1221 +- if ( response.content.size() == 4
23.1222 +- && response.content[2].toString()=="FETCH"
23.1223 +- && response.content[3].type()==Message::Part::List ) {
23.1224 ++ if ( handleErrorReplies( response ) == NotHandled ) {
23.1225 ++ if ( response.content.size() == 4 &&
23.1226 ++ response.content[2].toString() == "FETCH" &&
23.1227 ++ response.content[3].type() == Message::Part::List ) {
23.1228 +
23.1229 + qint64 id = response.content[1].toString().toLongLong();
23.1230 + QList<QByteArray> content = response.content[3].toList();
23.1231 +@@ -249,67 +249,69 @@ void FetchJob::handleResponse( const Message &response )
23.1232 + MessageParts parts;
23.1233 +
23.1234 + for ( QList<QByteArray>::ConstIterator it = content.constBegin();
23.1235 +- it!=content.constEnd(); ++it ) {
23.1236 ++ it != content.constEnd(); ++it ) {
23.1237 + QByteArray str = *it;
23.1238 + ++it;
23.1239 +
23.1240 +- if ( it==content.constEnd() ) { // Uh oh, message was truncated?
23.1241 ++ if ( it == content.constEnd() ) { // Uh oh, message was truncated?
23.1242 + kWarning() << "FETCH reply got truncated, skipping.";
23.1243 + break;
23.1244 + }
23.1245 +
23.1246 +- if ( str=="UID" ) {
23.1247 ++ if ( str == "UID" ) {
23.1248 + d->pendingUids[id] = it->toLongLong();
23.1249 +- } else if ( str=="RFC822.SIZE" ) {
23.1250 ++ } else if ( str == "RFC822.SIZE" ) {
23.1251 + d->pendingSizes[id] = it->toLongLong();
23.1252 +- } else if ( str=="INTERNALDATE" ) {
23.1253 ++ } else if ( str == "INTERNALDATE" ) {
23.1254 + message->date()->setDateTime( KDateTime::fromString( *it, KDateTime::RFCDate ) );
23.1255 +- } else if ( str=="FLAGS" ) {
23.1256 +- if ( (*it).startsWith('(') && (*it).endsWith(')') ) {
23.1257 ++ } else if ( str == "FLAGS" ) {
23.1258 ++ if ( ( *it ).startsWith( '(' ) && ( *it ).endsWith( ')' ) ) {
23.1259 + QByteArray str = *it;
23.1260 +- str.chop(1);
23.1261 +- str.remove(0, 1);
23.1262 +- d->pendingFlags[id] = str.split(' ');
23.1263 ++ str.chop( 1 );
23.1264 ++ str.remove( 0, 1 );
23.1265 ++ d->pendingFlags[id] = str.split( ' ' );
23.1266 + } else {
23.1267 + d->pendingFlags[id] << *it;
23.1268 + }
23.1269 +- } else if ( str=="BODYSTRUCTURE" ) {
23.1270 ++ } else if ( str == "BODYSTRUCTURE" ) {
23.1271 + int pos = 0;
23.1272 +- d->parseBodyStructure(*it, pos, message.get());
23.1273 ++ d->parseBodyStructure( *it, pos, message.get() );
23.1274 + message->assemble();
23.1275 + d->pendingMessages[id] = message;
23.1276 +- } else if ( str.startsWith( "BODY[") ) { //krazy:exclude=strings
23.1277 +- if ( !str.endsWith(']') ) { // BODY[ ... ] might have been split, skip until we find the ]
23.1278 +- while ( !(*it).endsWith(']') ) ++it;
23.1279 ++ } else if ( str.startsWith( "BODY[" ) ) { //krazy:exclude=strings
23.1280 ++ if ( !str.endsWith( ']' ) ) { // BODY[ ... ] might have been split, skip until we find the ]
23.1281 ++ while ( !( *it ).endsWith( ']' ) ) {
23.1282 ++ ++it;
23.1283 ++ }
23.1284 + ++it;
23.1285 + }
23.1286 +
23.1287 + int index;
23.1288 +- if ( (index=str.indexOf("HEADER"))>0 || (index=str.indexOf("MIME"))>0 ) { // headers
23.1289 +- if ( str[index-1]=='.' ) {
23.1290 +- QByteArray partId = str.mid( 5, index-6 );
23.1291 ++ if ( ( index = str.indexOf( "HEADER" ) ) > 0 || ( index = str.indexOf( "MIME" ) ) > 0 ) { // headers
23.1292 ++ if ( str[index-1] == '.' ) {
23.1293 ++ QByteArray partId = str.mid( 5, index - 6 );
23.1294 + if ( !parts.contains( partId ) ) {
23.1295 + parts[partId] = ContentPtr( new KMime::Content );
23.1296 + }
23.1297 +- parts[partId]->setHead(*it);
23.1298 ++ parts[partId]->setHead( *it );
23.1299 + parts[partId]->parse();
23.1300 + d->pendingParts[id] = parts;
23.1301 + } else {
23.1302 +- message->setHead(*it);
23.1303 ++ message->setHead( *it );
23.1304 + shouldParseMessage = true;
23.1305 + }
23.1306 + } else { // full payload
23.1307 +- if ( str=="BODY[]" ) {
23.1308 +- message->setContent( KMime::CRLFtoLF(*it) );
23.1309 ++ if ( str == "BODY[]" ) {
23.1310 ++ message->setContent( KMime::CRLFtoLF( *it ) );
23.1311 + shouldParseMessage = true;
23.1312 +
23.1313 + d->pendingMessages[id] = message;
23.1314 + } else {
23.1315 +- QByteArray partId = str.mid( 5, str.size()-6 );
23.1316 ++ QByteArray partId = str.mid( 5, str.size() - 6 );
23.1317 + if ( !parts.contains( partId ) ) {
23.1318 + parts[partId] = ContentPtr( new KMime::Content );
23.1319 + }
23.1320 +- parts[partId]->setBody(*it);
23.1321 ++ parts[partId]->setBody( *it );
23.1322 + parts[partId]->parse();
23.1323 +
23.1324 + d->pendingParts[id] = parts;
23.1325 +@@ -334,21 +336,20 @@ void FetchJob::handleResponse( const Message &response )
23.1326 +
23.1327 + void FetchJobPrivate::parseBodyStructure(const QByteArray &structure, int &pos, KMime::Content *content)
23.1328 + {
23.1329 +- skipLeadingSpaces(structure, pos);
23.1330 ++ skipLeadingSpaces( structure, pos );
23.1331 +
23.1332 +- if ( structure[pos]!='(' ) {
23.1333 ++ if ( structure[pos] != '(' ) {
23.1334 + return;
23.1335 + }
23.1336 +
23.1337 + pos++;
23.1338 +
23.1339 +-
23.1340 +- if ( structure[pos]!='(' ) { // simple part
23.1341 ++ if ( structure[pos] != '(' ) { // simple part
23.1342 + pos--;
23.1343 + parsePart( structure, pos, content );
23.1344 + } else { // multi part
23.1345 +- content->contentType()->setMimeType("MULTIPART/MIXED");
23.1346 +- while ( pos<structure.size() && structure[pos]=='(' ) {
23.1347 ++ content->contentType()->setMimeType( "MULTIPART/MIXED" );
23.1348 ++ while ( pos < structure.size() && structure[pos] == '(' ) {
23.1349 + KMime::Content *child = new KMime::Content;
23.1350 + content->addContent( child );
23.1351 + parseBodyStructure( structure, pos, child );
23.1352 +@@ -356,17 +357,17 @@ void FetchJobPrivate::parseBodyStructure(const QByteArray &structure, int &pos,
23.1353 + }
23.1354 +
23.1355 + QByteArray subType = parseString( structure, pos );
23.1356 +- content->contentType()->setMimeType( "MULTIPART/"+subType );
23.1357 ++ content->contentType()->setMimeType( "MULTIPART/" + subType );
23.1358 +
23.1359 + QByteArray parameters = parseSentence( structure, pos ); // FIXME: Read the charset
23.1360 +- if (parameters.contains("BOUNDARY") ) {
23.1361 +- content->contentType()->setBoundary(parameters.remove(0, parameters.indexOf("BOUNDARY") + 11).split('\"')[0]);
23.1362 ++ if ( parameters.contains( "BOUNDARY" ) ) {
23.1363 ++ content->contentType()->setBoundary( parameters.remove( 0, parameters.indexOf( "BOUNDARY" ) + 11 ).split( '\"' )[0] );
23.1364 + }
23.1365 +
23.1366 + QByteArray disposition = parseSentence( structure, pos );
23.1367 +- if ( disposition.contains("INLINE") ) {
23.1368 ++ if ( disposition.contains( "INLINE" ) ) {
23.1369 + content->contentDisposition()->setDisposition( KMime::Headers::CDinline );
23.1370 +- } else if ( disposition.contains("ATTACHMENT") ) {
23.1371 ++ } else if ( disposition.contains( "ATTACHMENT" ) ) {
23.1372 + content->contentDisposition()->setDisposition( KMime::Headers::CDattachment );
23.1373 + }
23.1374 +
23.1375 +@@ -374,7 +375,7 @@ void FetchJobPrivate::parseBodyStructure(const QByteArray &structure, int &pos,
23.1376 + }
23.1377 +
23.1378 + // Consume what's left
23.1379 +- while ( pos<structure.size() && structure[pos]!=')' ) {
23.1380 ++ while ( pos < structure.size() && structure[pos] != ')' ) {
23.1381 + skipLeadingSpaces( structure, pos );
23.1382 + parseSentence( structure, pos );
23.1383 + skipLeadingSpaces( structure, pos );
23.1384 +@@ -385,7 +386,7 @@ void FetchJobPrivate::parseBodyStructure(const QByteArray &structure, int &pos,
23.1385 +
23.1386 + void FetchJobPrivate::parsePart( const QByteArray &structure, int &pos, KMime::Content *content )
23.1387 + {
23.1388 +- if ( structure[pos]!='(' ) {
23.1389 ++ if ( structure[pos] != '(' ) {
23.1390 + return;
23.1391 + }
23.1392 +
23.1393 +@@ -394,7 +395,7 @@ void FetchJobPrivate::parsePart( const QByteArray &structure, int &pos, KMime::C
23.1394 + QByteArray mainType = parseString( structure, pos );
23.1395 + QByteArray subType = parseString( structure, pos );
23.1396 +
23.1397 +- content->contentType()->setMimeType( mainType+'/'+subType );
23.1398 ++ content->contentType()->setMimeType( mainType + '/' + subType );
23.1399 +
23.1400 + parseSentence( structure, pos ); // Ditch the parameters... FIXME: Read it to get charset and name
23.1401 + parseString( structure, pos ); // ... and the id
23.1402 +@@ -406,20 +407,20 @@ void FetchJobPrivate::parsePart( const QByteArray &structure, int &pos, KMime::C
23.1403 + parseString( structure, pos ); // ... and the line count
23.1404 +
23.1405 + QByteArray disposition = parseSentence( structure, pos );
23.1406 +- if ( disposition.contains("INLINE") ) {
23.1407 ++ if ( disposition.contains( "INLINE" ) ) {
23.1408 + content->contentDisposition()->setDisposition( KMime::Headers::CDinline );
23.1409 +- } else if ( disposition.contains("ATTACHMENT") ) {
23.1410 ++ } else if ( disposition.contains( "ATTACHMENT" ) ) {
23.1411 + content->contentDisposition()->setDisposition( KMime::Headers::CDattachment );
23.1412 + }
23.1413 +- if ( (content->contentDisposition()->disposition() == KMime::Headers::CDattachment
23.1414 +- || content->contentDisposition()->disposition() == KMime::Headers::CDinline)
23.1415 +- && disposition.contains("FILENAME") ) {
23.1416 +- QByteArray filename = disposition.remove(0, disposition.indexOf("FILENAME") + 11).split('\"')[0];
23.1417 ++ if ( ( content->contentDisposition()->disposition() == KMime::Headers::CDattachment ||
23.1418 ++ content->contentDisposition()->disposition() == KMime::Headers::CDinline ) &&
23.1419 ++ disposition.contains( "FILENAME" ) ) {
23.1420 ++ QByteArray filename = disposition.remove( 0, disposition.indexOf( "FILENAME" ) + 11 ).split( '\"' )[0];
23.1421 + content->contentDisposition()->setFilename( filename );
23.1422 + }
23.1423 +
23.1424 + // Consume what's left
23.1425 +- while ( pos<structure.size() && structure[pos]!=')' ) {
23.1426 ++ while ( pos < structure.size() && structure[pos] != ')' ) {
23.1427 + skipLeadingSpaces( structure, pos );
23.1428 + parseSentence( structure, pos );
23.1429 + skipLeadingSpaces( structure, pos );
23.1430 +@@ -433,7 +434,7 @@ QByteArray FetchJobPrivate::parseSentence( const QByteArray &structure, int &pos
23.1431 +
23.1432 + skipLeadingSpaces( structure, pos );
23.1433 +
23.1434 +- if ( structure[pos]!='(' ) {
23.1435 ++ if ( structure[pos] != '(' ) {
23.1436 + return parseString( structure, pos );
23.1437 + }
23.1438 +
23.1439 +@@ -458,12 +459,12 @@ QByteArray FetchJobPrivate::parseSentence( const QByteArray &structure, int &pos
23.1440 + stack--;
23.1441 + break;
23.1442 + default:
23.1443 +- skipLeadingSpaces(structure, pos);
23.1444 +- parseString(structure, pos);
23.1445 +- skipLeadingSpaces(structure, pos);
23.1446 ++ skipLeadingSpaces( structure, pos );
23.1447 ++ parseString( structure, pos );
23.1448 ++ skipLeadingSpaces( structure, pos );
23.1449 + break;
23.1450 + }
23.1451 +- } while ( pos<structure.size() && stack!=0 );
23.1452 ++ } while ( pos < structure.size() && stack != 0 );
23.1453 +
23.1454 + result = structure.mid( start, pos - start );
23.1455 +
23.1456 +@@ -484,12 +485,12 @@ QByteArray FetchJobPrivate::parseString( const QByteArray &structure, int &pos )
23.1457 + pos++;
23.1458 + Q_FOREVER {
23.1459 + if ( structure[pos] == '\\' ) {
23.1460 +- pos+= 2;
23.1461 ++ pos += 2;
23.1462 + foundSlash = true;
23.1463 + continue;
23.1464 + }
23.1465 + if ( structure[pos] == '"' ) {
23.1466 +- result = structure.mid( start+1, pos - start - 1);
23.1467 ++ result = structure.mid( start + 1, pos - start - 1 );
23.1468 + pos++;
23.1469 + break;
23.1470 + }
23.1471 +@@ -497,27 +498,38 @@ QByteArray FetchJobPrivate::parseString( const QByteArray &structure, int &pos )
23.1472 + }
23.1473 + } else { // unquoted string
23.1474 + Q_FOREVER {
23.1475 +- if ( structure[pos] == ' ' || structure[pos] == '(' || structure[pos] == ')' || structure[pos] == '[' || structure[pos] == ']' || structure[pos] == '\n' || structure[pos] == '\r' || structure[pos] == '"') {
23.1476 ++ if ( structure[pos] == ' ' ||
23.1477 ++ structure[pos] == '(' ||
23.1478 ++ structure[pos] == ')' ||
23.1479 ++ structure[pos] == '[' ||
23.1480 ++ structure[pos] == ']' ||
23.1481 ++ structure[pos] == '\n' ||
23.1482 ++ structure[pos] == '\r' ||
23.1483 ++ structure[pos] == '"' ) {
23.1484 + break;
23.1485 + }
23.1486 +- if (structure[pos] == '\\')
23.1487 ++ if ( structure[pos] == '\\' ) {
23.1488 + foundSlash = true;
23.1489 ++ }
23.1490 + pos++;
23.1491 + }
23.1492 +
23.1493 + result = structure.mid( start, pos - start );
23.1494 +
23.1495 + // transform unquoted NIL
23.1496 +- if ( result == "NIL" )
23.1497 ++ if ( result == "NIL" ) {
23.1498 + result.clear();
23.1499 ++ }
23.1500 + }
23.1501 +
23.1502 + // simplify slashes
23.1503 + if ( foundSlash ) {
23.1504 +- while ( result.contains( "\\\"" ) )
23.1505 ++ while ( result.contains( "\\\"" ) ) {
23.1506 + result.replace( "\\\"", "\"" );
23.1507 +- while ( result.contains( "\\\\" ) )
23.1508 ++ }
23.1509 ++ while ( result.contains( "\\\\" ) ) {
23.1510 + result.replace( "\\\\", "\\" );
23.1511 ++ }
23.1512 + }
23.1513 +
23.1514 + return result;
23.1515 +@@ -525,7 +537,10 @@ QByteArray FetchJobPrivate::parseString( const QByteArray &structure, int &pos )
23.1516 +
23.1517 + void FetchJobPrivate::skipLeadingSpaces( const QByteArray &structure, int &pos )
23.1518 + {
23.1519 +- while ( structure[pos]==' ' && pos<structure.size() ) pos++;
23.1520 ++ while ( pos < structure.size() && structure[pos] == ' ' ) {
23.1521 ++ pos++;
23.1522 ++ }
23.1523 + }
23.1524 +
23.1525 + #include "fetchjob.moc"
23.1526 ++
23.1527 +diff --git a/kimap/fetchjob.h b/kimap/fetchjob.h
23.1528 +index aa31d2d..75fe6b6 100644
23.1529 +--- a/kimap/fetchjob.h
23.1530 ++++ b/kimap/fetchjob.h
23.1531 +@@ -56,7 +56,7 @@ typedef QList<QByteArray> MessageFlags;
23.1532 + class KIMAP_EXPORT FetchJob : public Job
23.1533 + {
23.1534 + Q_OBJECT
23.1535 +- Q_DECLARE_PRIVATE(FetchJob)
23.1536 ++ Q_DECLARE_PRIVATE( FetchJob )
23.1537 +
23.1538 + friend class SessionPrivate;
23.1539 +
23.1540 +diff --git a/kimap/getacljob.cpp b/kimap/getacljob.cpp
23.1541 +index fbe8d80..b218776 100644
23.1542 +--- a/kimap/getacljob.cpp
23.1543 ++++ b/kimap/getacljob.cpp
23.1544 +@@ -19,8 +19,8 @@
23.1545 +
23.1546 + #include "getacljob.h"
23.1547 +
23.1548 +-#include <klocale.h>
23.1549 +-#include <kdebug.h>
23.1550 ++#include <KDE/KLocalizedString>
23.1551 ++#include <KDE/KDebug>
23.1552 +
23.1553 + #include "acljobbase_p.h"
23.1554 + #include "message_p.h"
23.1555 +@@ -32,7 +32,7 @@ namespace KIMAP
23.1556 + class GetAclJobPrivate : public AclJobBasePrivate
23.1557 + {
23.1558 + public:
23.1559 +- GetAclJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate(session, name) {}
23.1560 ++ GetAclJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate( session, name ) {}
23.1561 + ~GetAclJobPrivate() { }
23.1562 +
23.1563 + QMap<QByteArray, Acl::Rights> userRights;
23.1564 +@@ -42,7 +42,7 @@ namespace KIMAP
23.1565 + using namespace KIMAP;
23.1566 +
23.1567 + GetAclJob::GetAclJob( Session *session )
23.1568 +- : AclJobBase( *new GetAclJobPrivate(session, i18n("GetAcl") ))
23.1569 ++ : AclJobBase( *new GetAclJobPrivate( session, i18n( "GetAcl" ) ) )
23.1570 + {
23.1571 + }
23.1572 +
23.1573 +@@ -52,24 +52,24 @@ GetAclJob::~GetAclJob()
23.1574 +
23.1575 + void GetAclJob::doStart()
23.1576 + {
23.1577 +- Q_D(GetAclJob);
23.1578 ++ Q_D( GetAclJob );
23.1579 +
23.1580 +- d->tags << d->sessionInternal()->sendCommand( "GETACL", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"');
23.1581 ++ d->tags << d->sessionInternal()->sendCommand( "GETACL", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"' );
23.1582 + }
23.1583 +
23.1584 + void GetAclJob::handleResponse( const Message &response )
23.1585 + {
23.1586 +- Q_D(GetAclJob);
23.1587 +-// qDebug() << response.toString();
23.1588 ++ Q_D( GetAclJob );
23.1589 ++// kDebug() << response.toString();
23.1590 +
23.1591 +- if (handleErrorReplies(response) == NotHandled) {
23.1592 +- if ( response.content.size() >= 4
23.1593 +- && response.content[1].toString() == "ACL" ) {
23.1594 ++ if ( handleErrorReplies( response ) == NotHandled ) {
23.1595 ++ if ( response.content.size() >= 4 &&
23.1596 ++ response.content[1].toString() == "ACL" ) {
23.1597 + int i = 3;
23.1598 + while ( i < response.content.size() - 1 ) {
23.1599 + QByteArray id = response.content[i].toString();
23.1600 + QByteArray rights = response.content[i + 1].toString();
23.1601 +- d->userRights[id] = Acl::rightsFromString(rights);
23.1602 ++ d->userRights[id] = Acl::rightsFromString( rights );
23.1603 + i += 2;
23.1604 + }
23.1605 + }
23.1606 +@@ -78,15 +78,14 @@ void GetAclJob::handleResponse( const Message &response )
23.1607 +
23.1608 + QList<QByteArray> GetAclJob::identifiers() const
23.1609 + {
23.1610 +- Q_D(const GetAclJob);
23.1611 ++ Q_D( const GetAclJob );
23.1612 + return d->userRights.keys();
23.1613 + }
23.1614 +
23.1615 + bool GetAclJob::hasRightEnabled(const QByteArray &identifier, Acl::Right right) const
23.1616 + {
23.1617 +- Q_D(const GetAclJob);
23.1618 +- if (d->userRights.contains(identifier))
23.1619 +- {
23.1620 ++ Q_D( const GetAclJob );
23.1621 ++ if ( d->userRights.contains( identifier ) ) {
23.1622 + Acl::Rights rights = d->userRights[identifier];
23.1623 + return rights & right;
23.1624 + }
23.1625 +@@ -96,10 +95,9 @@ bool GetAclJob::hasRightEnabled(const QByteArray &identifier, Acl::Right right)
23.1626 +
23.1627 + Acl::Rights GetAclJob::rights(const QByteArray &identifier) const
23.1628 + {
23.1629 +- Q_D(const GetAclJob);
23.1630 ++ Q_D( const GetAclJob );
23.1631 + Acl::Rights result;
23.1632 +- if (d->userRights.contains(identifier))
23.1633 +- {
23.1634 ++ if ( d->userRights.contains( identifier ) ) {
23.1635 + result = d->userRights[identifier];
23.1636 + }
23.1637 + return result;
23.1638 +@@ -107,8 +105,9 @@ Acl::Rights GetAclJob::rights(const QByteArray &identifier) const
23.1639 +
23.1640 + QMap<QByteArray, Acl::Rights> GetAclJob::allRights() const
23.1641 + {
23.1642 +- Q_D(const GetAclJob);
23.1643 ++ Q_D( const GetAclJob );
23.1644 + return d->userRights;
23.1645 + }
23.1646 +
23.1647 +-#include "getacljob.moc"
23.1648 +\ No newline at end of file
23.1649 ++#include "getacljob.moc"
23.1650 ++
23.1651 +diff --git a/kimap/getacljob.h b/kimap/getacljob.h
23.1652 +index dd652d2..77a6648 100644
23.1653 +--- a/kimap/getacljob.h
23.1654 ++++ b/kimap/getacljob.h
23.1655 +@@ -30,7 +30,6 @@ class Session;
23.1656 + struct Message;
23.1657 + class GetAclJobPrivate;
23.1658 +
23.1659 +-
23.1660 + /**
23.1661 + * Gets the ACL for a mailbox
23.1662 + *
23.1663 +@@ -63,7 +62,7 @@ class GetAclJobPrivate;
23.1664 + class KIMAP_EXPORT GetAclJob : public AclJobBase
23.1665 + {
23.1666 + Q_OBJECT
23.1667 +- Q_DECLARE_PRIVATE(GetAclJob)
23.1668 ++ Q_DECLARE_PRIVATE( GetAclJob )
23.1669 +
23.1670 + friend class SessionPrivate;
23.1671 +
23.1672 +diff --git a/kimap/getmetadatajob.cpp b/kimap/getmetadatajob.cpp
23.1673 +index 69be41d..4dddce3 100644
23.1674 +--- a/kimap/getmetadatajob.cpp
23.1675 ++++ b/kimap/getmetadatajob.cpp
23.1676 +@@ -19,8 +19,8 @@
23.1677 +
23.1678 + #include "getmetadatajob.h"
23.1679 +
23.1680 +-#include <klocale.h>
23.1681 +-#include <kdebug.h>
23.1682 ++#include <KDE/KLocalizedString>
23.1683 ++#include <KDE/KDebug>
23.1684 +
23.1685 + #include "metadatajobbase_p.h"
23.1686 + #include "message_p.h"
23.1687 +@@ -32,7 +32,7 @@ namespace KIMAP
23.1688 + class GetMetaDataJobPrivate : public MetaDataJobBasePrivate
23.1689 + {
23.1690 + public:
23.1691 +- GetMetaDataJobPrivate( Session *session, const QString& name ) : MetaDataJobBasePrivate(session, name), maxSize(-1), depth("0") { }
23.1692 ++ GetMetaDataJobPrivate( Session *session, const QString& name ) : MetaDataJobBasePrivate( session, name ), maxSize( -1 ), depth( "0" ) { }
23.1693 + ~GetMetaDataJobPrivate() { }
23.1694 +
23.1695 + qint64 maxSize;
23.1696 +@@ -47,7 +47,7 @@ namespace KIMAP
23.1697 + using namespace KIMAP;
23.1698 +
23.1699 + GetMetaDataJob::GetMetaDataJob( Session *session )
23.1700 +- : MetaDataJobBase( *new GetMetaDataJobPrivate(session, i18n("GetMetaData")) )
23.1701 ++ : MetaDataJobBase( *new GetMetaDataJobPrivate( session, i18n( "GetMetaData" ) ) )
23.1702 + {
23.1703 + }
23.1704 +
23.1705 +@@ -57,94 +57,100 @@ GetMetaDataJob::~GetMetaDataJob()
23.1706 +
23.1707 + void GetMetaDataJob::doStart()
23.1708 + {
23.1709 +- Q_D(GetMetaDataJob);
23.1710 ++ Q_D( GetMetaDataJob );
23.1711 + QByteArray parameters;
23.1712 + parameters = '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + "\" ";
23.1713 +
23.1714 + QByteArray command = "GETMETADATA";
23.1715 +- if (d->serverCapability == Annotatemore) {
23.1716 +- d->m_name = i18n("GetAnnotation");
23.1717 ++ if ( d->serverCapability == Annotatemore ) {
23.1718 ++ d->m_name = i18n( "GetAnnotation" );
23.1719 + command = "GETANNOTATION";
23.1720 +- if (d->entries.size() > 1)
23.1721 ++ if ( d->entries.size() > 1 ) {
23.1722 + parameters += '(';
23.1723 +- Q_FOREACH(const QByteArray &entry, d->entries) {
23.1724 ++ }
23.1725 ++ Q_FOREACH ( const QByteArray &entry, d->entries ) {
23.1726 + parameters += '\"' + entry + "\" ";
23.1727 + }
23.1728 +- if (d->entries.size() > 1)
23.1729 +- parameters[parameters.length() -1 ] = ')';
23.1730 +- else
23.1731 +- parameters.truncate(parameters.length() -1);
23.1732 ++ if ( d->entries.size() > 1 ) {
23.1733 ++ parameters[parameters.length() - 1 ] = ')';
23.1734 ++ } else {
23.1735 ++ parameters.truncate( parameters.length() - 1 );
23.1736 ++ }
23.1737 +
23.1738 + parameters += ' ';
23.1739 +
23.1740 +- if (d->attributes.size() > 1)
23.1741 ++ if ( d->attributes.size() > 1 ) {
23.1742 + parameters += '(';
23.1743 +- Q_FOREACH(const QByteArray &attribute, d->attributes) {
23.1744 ++ }
23.1745 ++ Q_FOREACH ( const QByteArray &attribute, d->attributes ) {
23.1746 + parameters += '\"' + attribute + "\" ";
23.1747 + }
23.1748 +- if (d->attributes.size() > 1)
23.1749 +- parameters[parameters.length() -1 ] = ')';
23.1750 +- else
23.1751 +- parameters.truncate(parameters.length() -1);
23.1752 ++ if ( d->attributes.size() > 1 ) {
23.1753 ++ parameters[parameters.length() - 1 ] = ')';
23.1754 ++ } else {
23.1755 ++ parameters.truncate( parameters.length() - 1 );
23.1756 ++ }
23.1757 +
23.1758 + } else {
23.1759 +- if (d->depth != "0") {
23.1760 ++ if ( d->depth != "0" ) {
23.1761 + parameters += "(DEPTH " + d->depth;
23.1762 + }
23.1763 +- if (d->maxSize != -1) {
23.1764 +- parameters += "(MAXSIZE " + QByteArray::number(d->maxSize) + ')';
23.1765 ++ if ( d->maxSize != -1 ) {
23.1766 ++ parameters += "(MAXSIZE " + QByteArray::number( d->maxSize ) + ')';
23.1767 + }
23.1768 +- if (d->depth != "0") {
23.1769 ++ if ( d->depth != "0" ) {
23.1770 + parameters += " )";
23.1771 + }
23.1772 +
23.1773 +- if (d->entries.size() > 1)
23.1774 ++ if ( d->entries.size() > 1 ) {
23.1775 + parameters += '(';
23.1776 +- Q_FOREACH(const QByteArray &entry, d->entries) {
23.1777 ++ }
23.1778 ++ Q_FOREACH ( const QByteArray &entry, d->entries ) {
23.1779 + parameters += '\"' + entry + "\" ";
23.1780 + }
23.1781 +- if (d->entries.size() > 1)
23.1782 +- parameters[parameters.length() -1 ] = ')';
23.1783 ++ if ( d->entries.size() > 1 ) {
23.1784 ++ parameters[parameters.length() - 1 ] = ')';
23.1785 ++ }
23.1786 + }
23.1787 +
23.1788 +- if (d->entries.isEmpty()) {
23.1789 ++ if ( d->entries.isEmpty() ) { {
23.1790 + parameters += ')';
23.1791 + }
23.1792 ++ }
23.1793 +
23.1794 + d->tags << d->sessionInternal()->sendCommand( command, parameters );
23.1795 +-// qDebug() << "SENT: " << command << " " << parameters;
23.1796 ++// kDebug() << "SENT: " << command << " " << parameters;
23.1797 + }
23.1798 +
23.1799 + void GetMetaDataJob::handleResponse( const Message &response )
23.1800 + {
23.1801 +- Q_D(GetMetaDataJob);
23.1802 +-// qDebug() << "GOT: " << response.toString();
23.1803 ++ Q_D( GetMetaDataJob );
23.1804 ++// kDebug() << "GOT: " << response.toString();
23.1805 +
23.1806 + //TODO: handle NO error messages having [METADATA MAXSIZE NNN], [METADATA TOOMANY], [METADATA NOPRIVATE] (see rfc5464)
23.1807 + // or [ANNOTATEMORE TOOBIG], [ANNOTATEMORE TOOMANY] respectively
23.1808 +- if (handleErrorReplies(response) == NotHandled ) {
23.1809 ++ if ( handleErrorReplies( response ) == NotHandled ) {
23.1810 + if ( response.content.size() >= 4 ) {
23.1811 +- if (d->serverCapability == Annotatemore && response.content[1].toString() == "ANNOTATION" ) {
23.1812 ++ if ( d->serverCapability == Annotatemore && response.content[1].toString() == "ANNOTATION" ) {
23.1813 + QString mailBox = QString::fromUtf8( KIMAP::decodeImapFolderName( response.content[2].toString() ) );
23.1814 +
23.1815 + int i = 3;
23.1816 +- while (i < response.content.size() - 1) {
23.1817 ++ while ( i < response.content.size() - 1 ) {
23.1818 + QByteArray entry = response.content[i].toString();
23.1819 + QList<QByteArray> attributes = response.content[i + 1].toList();
23.1820 + int j = 0;
23.1821 +- while ( j < attributes.size() - 1) {
23.1822 ++ while ( j < attributes.size() - 1 ) {
23.1823 + d->metadata[mailBox][entry][attributes[j]] = attributes[j + 1];
23.1824 + j += 2;
23.1825 + }
23.1826 + i += 2;
23.1827 + }
23.1828 +- } else
23.1829 +- if (d->serverCapability == Metadata && response.content[1].toString() == "METADATA" ) {
23.1830 ++ } else if ( d->serverCapability == Metadata && response.content[1].toString() == "METADATA" ) {
23.1831 + QString mailBox = QString::fromUtf8( KIMAP::decodeImapFolderName( response.content[2].toString() ) );
23.1832 +
23.1833 + QList<QByteArray> entries = response.content[3].toList();
23.1834 + int i = 0;
23.1835 +- while ( i < entries.size() - 1) {
23.1836 ++ while ( i < entries.size() - 1 ) {
23.1837 + d->metadata[mailBox][entries[i]][""] = entries[i + 1];
23.1838 + i += 2;
23.1839 + }
23.1840 +@@ -155,25 +161,25 @@ void GetMetaDataJob::handleResponse( const Message &response )
23.1841 +
23.1842 + void GetMetaDataJob::addEntry(const QByteArray &entry, const QByteArray &attribute)
23.1843 + {
23.1844 +- Q_D(GetMetaDataJob);
23.1845 +- if (d->serverCapability == Annotatemore && attribute.isNull())
23.1846 ++ Q_D( GetMetaDataJob );
23.1847 ++ if ( d->serverCapability == Annotatemore && attribute.isNull() ) {
23.1848 + qWarning() << "In ANNOTATEMORE mode an attribute must be specified with addEntry!";
23.1849 +- d->entries.append(entry);
23.1850 +- d->attributes.append(attribute);
23.1851 ++ }
23.1852 ++ d->entries.append( entry );
23.1853 ++ d->attributes.append( attribute );
23.1854 + }
23.1855 +
23.1856 + void GetMetaDataJob::setMaximumSize(qint64 size)
23.1857 + {
23.1858 +- Q_D(GetMetaDataJob);
23.1859 ++ Q_D( GetMetaDataJob );
23.1860 + d->maxSize = size;
23.1861 + }
23.1862 +
23.1863 + void GetMetaDataJob::setDepth(Depth depth)
23.1864 + {
23.1865 +- Q_D(GetMetaDataJob);
23.1866 ++ Q_D( GetMetaDataJob );
23.1867 +
23.1868 +- switch (depth)
23.1869 +- {
23.1870 ++ switch ( depth ) {
23.1871 + case OneLevel:
23.1872 + d->depth = "1"; //krazy:exclude=doublequote_chars
23.1873 + break;
23.1874 +@@ -187,26 +193,27 @@ void GetMetaDataJob::setDepth(Depth depth)
23.1875 +
23.1876 + QByteArray GetMetaDataJob::metaData(const QString &mailBox, const QByteArray &entry, const QByteArray &attribute) const
23.1877 + {
23.1878 +- Q_D(const GetMetaDataJob);
23.1879 ++ Q_D( const GetMetaDataJob );
23.1880 + QByteArray attr = attribute;
23.1881 +
23.1882 +- if (d->serverCapability == Metadata)
23.1883 ++ if ( d->serverCapability == Metadata ) {
23.1884 + attr = "";
23.1885 ++ }
23.1886 +
23.1887 + QByteArray result;
23.1888 +- if (d->metadata.contains(mailBox)) {
23.1889 +- if (d->metadata[mailBox].contains(entry)) {
23.1890 +- result = d->metadata[mailBox][entry].value(attr);
23.1891 ++ if ( d->metadata.contains( mailBox ) ) {
23.1892 ++ if ( d->metadata[mailBox].contains( entry ) ) {
23.1893 ++ result = d->metadata[mailBox][entry].value( attr );
23.1894 + }
23.1895 + }
23.1896 +-
23.1897 + return result;
23.1898 + }
23.1899 +
23.1900 + QMap<QByteArray, QMap<QByteArray, QByteArray> > GetMetaDataJob::allMetaData(const QString &mailBox) const
23.1901 + {
23.1902 +- Q_D(const GetMetaDataJob);
23.1903 ++ Q_D( const GetMetaDataJob );
23.1904 + return d->metadata[mailBox];
23.1905 + }
23.1906 +
23.1907 +-#include "getmetadatajob.moc"
23.1908 +\ No newline at end of file
23.1909 ++#include "getmetadatajob.moc"
23.1910 ++
23.1911 +diff --git a/kimap/getquotajob.cpp b/kimap/getquotajob.cpp
23.1912 +index 9d1efb0..35d901e 100644
23.1913 +--- a/kimap/getquotajob.cpp
23.1914 ++++ b/kimap/getquotajob.cpp
23.1915 +@@ -19,8 +19,8 @@
23.1916 +
23.1917 + #include "getquotajob.h"
23.1918 +
23.1919 +-#include <klocale.h>
23.1920 +-#include <kdebug.h>
23.1921 ++#include <KDE/KLocalizedString>
23.1922 ++#include <KDE/KDebug>
23.1923 +
23.1924 + #include "quotajobbase_p.h"
23.1925 + #include "message_p.h"
23.1926 +@@ -31,7 +31,7 @@ namespace KIMAP
23.1927 + class GetQuotaJobPrivate : public QuotaJobBasePrivate
23.1928 + {
23.1929 + public:
23.1930 +- GetQuotaJobPrivate( Session *session, const QString& name ) : QuotaJobBasePrivate(session, name) { }
23.1931 ++ GetQuotaJobPrivate( Session *session, const QString& name ) : QuotaJobBasePrivate( session, name ) { }
23.1932 + ~GetQuotaJobPrivate() { }
23.1933 +
23.1934 + QByteArray root;
23.1935 +@@ -41,7 +41,7 @@ namespace KIMAP
23.1936 + using namespace KIMAP;
23.1937 +
23.1938 + GetQuotaJob::GetQuotaJob( Session *session )
23.1939 +- : QuotaJobBase( *new GetQuotaJobPrivate(session, i18n("GetQuota")) )
23.1940 ++ : QuotaJobBase( *new GetQuotaJobPrivate( session, i18n( "GetQuota" ) ) )
23.1941 + {
23.1942 + }
23.1943 +
23.1944 +@@ -51,34 +51,33 @@ GetQuotaJob::~GetQuotaJob()
23.1945 +
23.1946 + void GetQuotaJob::doStart()
23.1947 + {
23.1948 +- Q_D(GetQuotaJob);
23.1949 ++ Q_D( GetQuotaJob );
23.1950 + //XXX: [alexmerry, 2010-07-24]: should d->root be quoted properly?
23.1951 +- d->tags << d->sessionInternal()->sendCommand( "GETQUOTA", '\"' + d->root + '\"');
23.1952 ++ d->tags << d->sessionInternal()->sendCommand( "GETQUOTA", '\"' + d->root + '\"' );
23.1953 + }
23.1954 +
23.1955 + void GetQuotaJob::handleResponse(const Message &response)
23.1956 + {
23.1957 +- Q_D(GetQuotaJob);
23.1958 +- if (handleErrorReplies(response) == NotHandled) {
23.1959 +- if ( response.content.size() >= 4
23.1960 +- && response.content[1].toString() == "QUOTA" ) {
23.1961 +- d->quota = d->readQuota(response.content[3]);
23.1962 ++ Q_D( GetQuotaJob );
23.1963 ++ if ( handleErrorReplies( response ) == NotHandled ) {
23.1964 ++ if ( response.content.size() >= 4 &&
23.1965 ++ response.content[1].toString() == "QUOTA" ) {
23.1966 ++ d->quota = d->readQuota( response.content[3] );
23.1967 + }
23.1968 + }
23.1969 + }
23.1970 +
23.1971 + void GetQuotaJob::setRoot(const QByteArray& root)
23.1972 + {
23.1973 +- Q_D(GetQuotaJob);
23.1974 +-
23.1975 ++ Q_D( GetQuotaJob );
23.1976 + d->root = root;
23.1977 + }
23.1978 +
23.1979 + QByteArray GetQuotaJob::root() const
23.1980 + {
23.1981 +- Q_D(const GetQuotaJob);
23.1982 +-
23.1983 ++ Q_D( const GetQuotaJob );
23.1984 + return d->root;
23.1985 + }
23.1986 +
23.1987 +-#include "getquotajob.moc"
23.1988 +\ No newline at end of file
23.1989 ++#include "getquotajob.moc"
23.1990 ++
23.1991 +diff --git a/kimap/getquotajob.h b/kimap/getquotajob.h
23.1992 +index 01231ea..698450a 100644
23.1993 +--- a/kimap/getquotajob.h
23.1994 ++++ b/kimap/getquotajob.h
23.1995 +@@ -50,7 +50,7 @@ class GetQuotaJobPrivate;
23.1996 + class KIMAP_EXPORT GetQuotaJob : public QuotaJobBase
23.1997 + {
23.1998 + Q_OBJECT
23.1999 +- Q_DECLARE_PRIVATE(GetQuotaJob)
23.2000 ++ Q_DECLARE_PRIVATE( GetQuotaJob )
23.2001 +
23.2002 + friend class SessionPrivate;
23.2003 +
23.2004 +@@ -60,7 +60,7 @@ class KIMAP_EXPORT GetQuotaJob : public QuotaJobBase
23.2005 +
23.2006 + /**
23.2007 + * Set the quota root to get the resource limits for.
23.2008 +- *
23.2009 ++ * @param root the quota root to set
23.2010 + * @see GetQuotaRootJob
23.2011 + */
23.2012 + void setRoot(const QByteArray &root);
23.2013 +diff --git a/kimap/getquotarootjob.cpp b/kimap/getquotarootjob.cpp
23.2014 +index ee438a3..49e7bef 100644
23.2015 +--- a/kimap/getquotarootjob.cpp
23.2016 ++++ b/kimap/getquotarootjob.cpp
23.2017 +@@ -19,8 +19,8 @@
23.2018 +
23.2019 + #include "getquotarootjob.h"
23.2020 +
23.2021 +-#include <klocale.h>
23.2022 +-#include <kdebug.h>
23.2023 ++#include <KDE/KLocalizedString>
23.2024 ++#include <KDE/KDebug>
23.2025 +
23.2026 + #include "quotajobbase_p.h"
23.2027 + #include "message_p.h"
23.2028 +@@ -32,7 +32,7 @@ namespace KIMAP
23.2029 + class GetQuotaRootJobPrivate : public QuotaJobBasePrivate
23.2030 + {
23.2031 + public:
23.2032 +- GetQuotaRootJobPrivate( Session *session, const QString& name ) : QuotaJobBasePrivate(session, name) { }
23.2033 ++ GetQuotaRootJobPrivate( Session *session, const QString& name ) : QuotaJobBasePrivate( session, name ) { }
23.2034 + ~GetQuotaRootJobPrivate() { }
23.2035 +
23.2036 + QString mailBox;
23.2037 +@@ -44,7 +44,7 @@ namespace KIMAP
23.2038 + using namespace KIMAP;
23.2039 +
23.2040 + GetQuotaRootJob::GetQuotaRootJob( Session *session )
23.2041 +- : QuotaJobBase( *new GetQuotaRootJobPrivate(session, i18n("GetQuotaRoot")) )
23.2042 ++ : QuotaJobBase( *new GetQuotaRootJobPrivate( session, i18n( "GetQuotaRoot" ) ) )
23.2043 + {
23.2044 + }
23.2045 +
23.2046 +@@ -54,43 +54,41 @@ GetQuotaRootJob::~GetQuotaRootJob()
23.2047 +
23.2048 + void GetQuotaRootJob::doStart()
23.2049 + {
23.2050 +- Q_D(GetQuotaRootJob);
23.2051 +- d->tags << d->sessionInternal()->sendCommand( "GETQUOTAROOT", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"');
23.2052 ++ Q_D( GetQuotaRootJob );
23.2053 ++ d->tags << d->sessionInternal()->sendCommand( "GETQUOTAROOT", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"' );
23.2054 + }
23.2055 +
23.2056 + void GetQuotaRootJob::handleResponse(const Message &response)
23.2057 + {
23.2058 +- Q_D(GetQuotaRootJob);
23.2059 +- if (handleErrorReplies(response) == NotHandled) {
23.2060 ++ Q_D( GetQuotaRootJob );
23.2061 ++ if ( handleErrorReplies( response ) == NotHandled ) {
23.2062 + if ( response.content.size() >= 3 ) {
23.2063 +- if (response.content[1].toString() == "QUOTAROOT" ) {
23.2064 ++ if ( response.content[1].toString() == "QUOTAROOT" ) {
23.2065 + d->rootList.clear();
23.2066 + //some impls don't give the root a name which for us seems as if
23.2067 + //there were no message part
23.2068 + if ( response.content.size() == 3 ) {
23.2069 +- d->rootList.append("");
23.2070 ++ d->rootList.append( "" );
23.2071 + } else {
23.2072 + int i = 3;
23.2073 +- while ( i < response.content.size())
23.2074 +- {
23.2075 +- d->rootList.append(response.content[i].toString());
23.2076 ++ while ( i < response.content.size() ) {
23.2077 ++ d->rootList.append( response.content[i].toString() );
23.2078 + i++;
23.2079 + }
23.2080 + }
23.2081 +- } else
23.2082 +- if (response.content[1].toString() == "QUOTA" ) {
23.2083 ++ } else if ( response.content[1].toString() == "QUOTA" ) {
23.2084 + QByteArray rootName;
23.2085 + int quotaContentIndex = 3;
23.2086 + //some impls don't give the root a name in the response
23.2087 +- if (response.content.size() == 3 ) {
23.2088 ++ if ( response.content.size() == 3 ) {
23.2089 + quotaContentIndex = 2;
23.2090 + } else {
23.2091 + rootName = response.content[2].toString();
23.2092 +- }
23.2093 ++ }
23.2094 +
23.2095 + const QMap<QByteArray, QPair<qint64, qint64> >& quota = d->readQuota(response.content[quotaContentIndex]);
23.2096 +- if (d->quotas.contains(rootName)) {
23.2097 +- d->quotas[ rootName ].unite(quota);
23.2098 ++ if ( d->quotas.contains( rootName ) ) {
23.2099 ++ d->quotas[ rootName ].unite( quota );
23.2100 + } else {
23.2101 + d->quotas[ rootName ] = quota;
23.2102 + }
23.2103 +@@ -99,61 +97,54 @@ void GetQuotaRootJob::handleResponse(const Message &response)
23.2104 + }
23.2105 + }
23.2106 +
23.2107 +-
23.2108 + void GetQuotaRootJob::setMailBox(const QString& mailBox)
23.2109 + {
23.2110 +- Q_D(GetQuotaRootJob);
23.2111 +-
23.2112 ++ Q_D( GetQuotaRootJob );
23.2113 + d->mailBox = mailBox;
23.2114 + }
23.2115 +
23.2116 + QString GetQuotaRootJob::mailBox() const
23.2117 + {
23.2118 +- Q_D(const GetQuotaRootJob);
23.2119 +-
23.2120 ++ Q_D( const GetQuotaRootJob );
23.2121 + return d->mailBox;
23.2122 + }
23.2123 +
23.2124 + QList<QByteArray> GetQuotaRootJob::roots() const
23.2125 + {
23.2126 +- Q_D(const GetQuotaRootJob);
23.2127 +-
23.2128 ++ Q_D( const GetQuotaRootJob );
23.2129 + return d->rootList;
23.2130 + }
23.2131 +
23.2132 + qint64 GetQuotaRootJob::usage(const QByteArray &root, const QByteArray &resource) const
23.2133 + {
23.2134 +- Q_D(const GetQuotaRootJob);
23.2135 +-
23.2136 ++ Q_D( const GetQuotaRootJob );
23.2137 + QByteArray r = resource.toUpper();
23.2138 +
23.2139 +- if (d->quotas.contains(root) && d->quotas[root].contains(r)) {
23.2140 ++ if ( d->quotas.contains( root ) && d->quotas[root].contains( r ) ) {
23.2141 + return d->quotas[root][r].first;
23.2142 + }
23.2143 +-
23.2144 + return -1;
23.2145 + }
23.2146 +
23.2147 + qint64 GetQuotaRootJob::limit(const QByteArray &root, const QByteArray &resource) const
23.2148 + {
23.2149 +- Q_D(const GetQuotaRootJob);
23.2150 ++ Q_D( const GetQuotaRootJob );
23.2151 +
23.2152 + QByteArray r = resource.toUpper();
23.2153 +
23.2154 +- if (d->quotas.contains(root) && d->quotas[root].contains(r)) {
23.2155 ++ if ( d->quotas.contains( root ) && d->quotas[root].contains( r ) ) {
23.2156 + return d->quotas[root][r].second;
23.2157 + }
23.2158 +-
23.2159 + return -1;
23.2160 + }
23.2161 +
23.2162 + QMap<QByteArray, qint64> GetQuotaRootJob::allUsages(const QByteArray &root) const
23.2163 + {
23.2164 +- Q_D(const GetQuotaRootJob);
23.2165 ++ Q_D( const GetQuotaRootJob );
23.2166 +
23.2167 + QMap<QByteArray, qint64> result;
23.2168 +
23.2169 +- if (d->quotas.contains(root)) {
23.2170 ++ if ( d->quotas.contains( root ) ) {
23.2171 + const QMap< QByteArray, QPair<qint64, qint64> > quota = d->quotas[root];
23.2172 + QMapIterator<QByteArray, QPair<qint64, qint64> > it( quota );
23.2173 + while ( it.hasNext() ) {
23.2174 +@@ -161,17 +152,16 @@ QMap<QByteArray, qint64> GetQuotaRootJob::allUsages(const QByteArray &root) cons
23.2175 + result[it.key()] = it.value().first;
23.2176 + }
23.2177 + }
23.2178 +-
23.2179 + return result;
23.2180 + }
23.2181 +
23.2182 + QMap<QByteArray, qint64> GetQuotaRootJob::allLimits(const QByteArray &root) const
23.2183 + {
23.2184 +- Q_D(const GetQuotaRootJob);
23.2185 ++ Q_D( const GetQuotaRootJob );
23.2186 +
23.2187 + QMap<QByteArray, qint64> result;
23.2188 +
23.2189 +- if (d->quotas.contains(root)) {
23.2190 ++ if ( d->quotas.contains( root ) ) {
23.2191 + const QMap< QByteArray, QPair<qint64, qint64> > quota = d->quotas[root];
23.2192 + QMapIterator<QByteArray, QPair<qint64, qint64> > it( quota );
23.2193 + while ( it.hasNext() ) {
23.2194 +@@ -179,8 +169,8 @@ QMap<QByteArray, qint64> GetQuotaRootJob::allLimits(const QByteArray &root) cons
23.2195 + result[it.key()] = it.value().second;
23.2196 + }
23.2197 + }
23.2198 +-
23.2199 + return result;
23.2200 + }
23.2201 +
23.2202 + #include "getquotarootjob.moc"
23.2203 ++
23.2204 +diff --git a/kimap/getquotarootjob.h b/kimap/getquotarootjob.h
23.2205 +index b1fa49e..3541e18 100644
23.2206 +--- a/kimap/getquotarootjob.h
23.2207 ++++ b/kimap/getquotarootjob.h
23.2208 +@@ -50,7 +50,7 @@ class GetQuotaRootJobPrivate;
23.2209 + class KIMAP_EXPORT GetQuotaRootJob : public QuotaJobBase
23.2210 + {
23.2211 + Q_OBJECT
23.2212 +- Q_DECLARE_PRIVATE(GetQuotaRootJob)
23.2213 ++ Q_DECLARE_PRIVATE( GetQuotaRootJob )
23.2214 +
23.2215 + friend class SessionPrivate;
23.2216 +
23.2217 +diff --git a/kimap/idlejob.cpp b/kimap/idlejob.cpp
23.2218 +index 0248697..5f75429 100644
23.2219 +--- a/kimap/idlejob.cpp
23.2220 ++++ b/kimap/idlejob.cpp
23.2221 +@@ -20,7 +20,7 @@
23.2222 + #include "idlejob.h"
23.2223 +
23.2224 + #include <QtCore/QTimer>
23.2225 +-#include <klocale.h>
23.2226 ++#include <KDE/KLocalizedString>
23.2227 +
23.2228 + #include "job_p.h"
23.2229 + #include "message_p.h"
23.2230 +@@ -32,7 +32,7 @@ namespace KIMAP
23.2231 + {
23.2232 + public:
23.2233 + IdleJobPrivate( IdleJob *job, Session *session, const QString& name )
23.2234 +- : JobPrivate( session, name ), q(job),
23.2235 ++ : JobPrivate( session, name ), q( job ),
23.2236 + messageCount( -1 ), recentCount( -1 ),
23.2237 + lastMessageCount( -1 ), lastRecentCount( -1 ),
23.2238 + originalSocketTimeout( -1 ) { }
23.2239 +@@ -42,8 +42,8 @@ namespace KIMAP
23.2240 + {
23.2241 + emitStatsTimer.stop();
23.2242 +
23.2243 +- emit q->mailBoxStats(q, m_session->selectedMailBox(),
23.2244 +- messageCount, recentCount);
23.2245 ++ emit q->mailBoxStats( q, m_session->selectedMailBox(),
23.2246 ++ messageCount, recentCount );
23.2247 +
23.2248 + lastMessageCount = messageCount;
23.2249 + lastRecentCount = recentCount;
23.2250 +@@ -69,9 +69,9 @@ namespace KIMAP
23.2251 + using namespace KIMAP;
23.2252 +
23.2253 + IdleJob::IdleJob( Session *session )
23.2254 +- : Job( *new IdleJobPrivate(this, session, i18nc("name of the idle job", "Idle")) )
23.2255 ++ : Job( *new IdleJobPrivate( this, session, i18nc( "name of the idle job", "Idle" ) ) )
23.2256 + {
23.2257 +- Q_D(IdleJob);
23.2258 ++ Q_D( IdleJob );
23.2259 + connect( &d->emitStatsTimer, SIGNAL(timeout()),
23.2260 + this, SLOT(emitStats()) );
23.2261 + }
23.2262 +@@ -82,14 +82,14 @@ IdleJob::~IdleJob()
23.2263 +
23.2264 + void KIMAP::IdleJob::stop()
23.2265 + {
23.2266 +- Q_D(IdleJob);
23.2267 ++ Q_D( IdleJob );
23.2268 + d->sessionInternal()->setSocketTimeout( d->originalSocketTimeout );
23.2269 + d->sessionInternal()->sendData( "DONE" );
23.2270 + }
23.2271 +
23.2272 + void IdleJob::doStart()
23.2273 + {
23.2274 +- Q_D(IdleJob);
23.2275 ++ Q_D( IdleJob );
23.2276 + d->originalSocketTimeout = d->sessionInternal()->socketTimeout();
23.2277 + d->sessionInternal()->setSocketTimeout( -1 );
23.2278 + d->tags << d->sessionInternal()->sendCommand( "IDLE" );
23.2279 +@@ -97,33 +97,32 @@ void IdleJob::doStart()
23.2280 +
23.2281 + void IdleJob::handleResponse( const Message &response )
23.2282 + {
23.2283 +- Q_D(IdleJob);
23.2284 ++ Q_D( IdleJob );
23.2285 +
23.2286 + // We can predict it'll be handled by handleErrorReplies() so emit
23.2287 + // pending signals now (if needed) so that result() will really be
23.2288 + // the last emitted signal.
23.2289 +- if ( !response.content.isEmpty()
23.2290 +- && d->tags.size() == 1
23.2291 +- && d->tags.contains( response.content.first().toString() )
23.2292 +- && ( d->messageCount>=0 || d->recentCount>=0 ) ) {
23.2293 ++ if ( !response.content.isEmpty() &&
23.2294 ++ d->tags.size() == 1 &&
23.2295 ++ d->tags.contains( response.content.first().toString() ) &&
23.2296 ++ ( d->messageCount >= 0 || d->recentCount >= 0 ) ) {
23.2297 + d->emitStats();
23.2298 + }
23.2299 +
23.2300 +-
23.2301 +- if (handleErrorReplies(response) == NotHandled ) {
23.2302 +- if ( response.content.size() > 0 && response.content[0].toString()=="+" ) {
23.2303 ++ if ( handleErrorReplies( response ) == NotHandled ) {
23.2304 ++ if ( response.content.size() > 0 && response.content[0].toString() == "+" ) {
23.2305 + // Got the continuation all is fine
23.2306 + return;
23.2307 +
23.2308 + } else if ( response.content.size() > 2 ) {
23.2309 +- if ( response.content[2].toString()=="EXISTS" ) {
23.2310 +- if ( d->messageCount>=0 ) {
23.2311 ++ if ( response.content[2].toString() == "EXISTS" ) {
23.2312 ++ if ( d->messageCount >= 0 ) {
23.2313 + d->emitStats();
23.2314 + }
23.2315 +
23.2316 + d->messageCount = response.content[1].toString().toInt();
23.2317 +- } else if ( response.content[2].toString()=="RECENT" ) {
23.2318 +- if ( d->recentCount>=0 ) {
23.2319 ++ } else if ( response.content[2].toString() == "RECENT" ) {
23.2320 ++ if ( d->recentCount >= 0 ) {
23.2321 + d->emitStats();
23.2322 + }
23.2323 +
23.2324 +@@ -141,20 +140,21 @@ void IdleJob::handleResponse( const Message &response )
23.2325 +
23.2326 + QString KIMAP::IdleJob::lastMailBox() const
23.2327 + {
23.2328 +- Q_D(const IdleJob);
23.2329 ++ Q_D( const IdleJob );
23.2330 + return d->m_session->selectedMailBox();
23.2331 + }
23.2332 +
23.2333 + int KIMAP::IdleJob::lastMessageCount() const
23.2334 + {
23.2335 +- Q_D(const IdleJob);
23.2336 ++ Q_D( const IdleJob );
23.2337 + return d->lastMessageCount;
23.2338 + }
23.2339 +
23.2340 + int KIMAP::IdleJob::lastRecentCount() const
23.2341 + {
23.2342 +- Q_D(const IdleJob);
23.2343 ++ Q_D( const IdleJob );
23.2344 + return d->lastRecentCount;
23.2345 + }
23.2346 +
23.2347 + #include "idlejob.moc"
23.2348 ++
23.2349 +diff --git a/kimap/idlejob.h b/kimap/idlejob.h
23.2350 +index 3a0917b..784155a 100644
23.2351 +--- a/kimap/idlejob.h
23.2352 ++++ b/kimap/idlejob.h
23.2353 +@@ -63,7 +63,7 @@ class IdleJobPrivate;
23.2354 + class KIMAP_EXPORT IdleJob : public Job
23.2355 + {
23.2356 + Q_OBJECT
23.2357 +- Q_DECLARE_PRIVATE(IdleJob)
23.2358 ++ Q_DECLARE_PRIVATE( IdleJob )
23.2359 +
23.2360 + public:
23.2361 + explicit IdleJob( Session *session );
23.2362 +diff --git a/kimap/imapset.cpp b/kimap/imapset.cpp
23.2363 +index 8588452..6c4e9ea 100644
23.2364 +--- a/kimap/imapset.cpp
23.2365 ++++ b/kimap/imapset.cpp
23.2366 +@@ -56,7 +56,6 @@ class ImapSet::Private : public QSharedData
23.2367 + ImapInterval::List intervals;
23.2368 + };
23.2369 +
23.2370 +-
23.2371 + ImapInterval::ImapInterval() :
23.2372 + d( new Private )
23.2373 + {
23.2374 +@@ -80,8 +79,9 @@ ImapInterval::~ ImapInterval()
23.2375 +
23.2376 + ImapInterval& ImapInterval::operator =(const ImapInterval & other)
23.2377 + {
23.2378 +- if ( this != & other )
23.2379 ++ if ( this != &other ) {
23.2380 + d = other.d;
23.2381 ++ }
23.2382 + return *this;
23.2383 + }
23.2384 +
23.2385 +@@ -92,10 +92,12 @@ bool ImapInterval::operator ==(const ImapInterval & other) const
23.2386 +
23.2387 + ImapInterval::Id ImapInterval::size() const
23.2388 + {
23.2389 +- if ( !d->begin && !d->end )
23.2390 ++ if ( !d->begin && !d->end ) {
23.2391 + return 0;
23.2392 +- if ( d->begin && !d->end )
23.2393 ++ }
23.2394 ++ if ( d->begin && !d->end ) {
23.2395 + return Q_INT64_C( 0x7FFFFFFFFFFFFFFF ) - d->begin + 1;
23.2396 ++ }
23.2397 + return d->end - d->begin + 1;
23.2398 + }
23.2399 +
23.2400 +@@ -116,8 +118,9 @@ bool ImapInterval::hasDefinedEnd() const
23.2401 +
23.2402 + ImapInterval::Id ImapInterval::end() const
23.2403 + {
23.2404 +- if ( hasDefinedEnd() )
23.2405 ++ if ( hasDefinedEnd() ) {
23.2406 + return d->end;
23.2407 ++ }
23.2408 + return 0xFFFFFFFF; // should be INT_MAX, but where is that defined again?
23.2409 + }
23.2410 +
23.2411 +@@ -137,16 +140,19 @@ void ImapInterval::setEnd(Id value)
23.2412 +
23.2413 + QByteArray ImapInterval::toImapSequence() const
23.2414 + {
23.2415 +- if ( size() == 0 )
23.2416 ++ if ( size() == 0 ) {
23.2417 + return QByteArray();
23.2418 +- if ( size() == 1 )
23.2419 ++ }
23.2420 ++ if ( size() == 1 ) {
23.2421 + return QByteArray::number( d->begin );
23.2422 ++ }
23.2423 + QByteArray rv;
23.2424 + rv += QByteArray::number( d->begin ) + ':';
23.2425 +- if ( hasDefinedEnd() )
23.2426 ++ if ( hasDefinedEnd() ) {
23.2427 + rv += QByteArray::number( d->end );
23.2428 +- else
23.2429 ++ } else {
23.2430 + rv += '*';
23.2431 ++ }
23.2432 + return rv;
23.2433 + }
23.2434 +
23.2435 +@@ -158,7 +164,7 @@ ImapInterval ImapInterval::fromImapSequence( const QByteArray &sequence )
23.2436 + }
23.2437 +
23.2438 + bool ok = false;
23.2439 +- Id begin = values[0].toLongLong(&ok);
23.2440 ++ Id begin = values[0].toLongLong( &ok );
23.2441 +
23.2442 + if ( !ok ) {
23.2443 + return ImapInterval();
23.2444 +@@ -172,7 +178,7 @@ ImapInterval ImapInterval::fromImapSequence( const QByteArray &sequence )
23.2445 + end = 0;
23.2446 + } else {
23.2447 + ok = false;
23.2448 +- end = values[1].toLongLong(&ok);
23.2449 ++ end = values[1].toLongLong( &ok );
23.2450 + if ( !ok ) {
23.2451 + return ImapInterval();
23.2452 + }
23.2453 +@@ -209,8 +215,9 @@ ImapSet::~ImapSet()
23.2454 +
23.2455 + ImapSet & ImapSet::operator =(const ImapSet & other)
23.2456 + {
23.2457 +- if ( this != &other )
23.2458 ++ if ( this != &other ) {
23.2459 + d = other.d;
23.2460 ++ }
23.2461 + return *this;
23.2462 + }
23.2463 +
23.2464 +@@ -238,7 +245,7 @@ void ImapSet::add(const QList<Id> & values)
23.2465 + {
23.2466 + QList<Id> vals = values;
23.2467 + qSort( vals );
23.2468 +- for( int i = 0; i < vals.count(); ++i ) {
23.2469 ++ for ( int i = 0; i < vals.count(); ++i ) {
23.2470 + const int begin = vals[i];
23.2471 + Q_ASSERT( begin >= 0 );
23.2472 + if ( i == vals.count() - 1 ) {
23.2473 +@@ -248,7 +255,7 @@ void ImapSet::add(const QList<Id> & values)
23.2474 + do {
23.2475 + ++i;
23.2476 + Q_ASSERT( vals[i] >= 0 );
23.2477 +- if ( vals[i] != (vals[i - 1] + 1) ) {
23.2478 ++ if ( vals[i] != ( vals[i - 1] + 1 ) ) {
23.2479 + --i;
23.2480 + break;
23.2481 + }
23.2482 +@@ -276,7 +283,7 @@ QByteArray ImapSet::toImapSequenceSet() const
23.2483 + QList<QByteArray>::ConstIterator it = rv.constBegin();
23.2484 + ++it;
23.2485 + for ( ; it != rv.constEnd(); ++it ) {
23.2486 +- result += ',' + (*it);
23.2487 ++ result += ',' + ( *it );
23.2488 + }
23.2489 + }
23.2490 +
23.2491 +@@ -289,7 +296,7 @@ ImapSet ImapSet::fromImapSequenceSet( const QByteArray &sequence )
23.2492 +
23.2493 + QList<QByteArray> intervals = sequence.split( ',' );
23.2494 +
23.2495 +- foreach( const QByteArray &interval, intervals ) {
23.2496 ++ foreach ( const QByteArray &interval, intervals ) {
23.2497 + if ( !interval.isEmpty() ) {
23.2498 + result.add( ImapInterval::fromImapSequence( interval ) );
23.2499 + }
23.2500 +@@ -319,4 +326,3 @@ QDebug& operator<<( QDebug &d, const ImapSet &set )
23.2501 + d << set.toImapSequenceSet();
23.2502 + return d;
23.2503 + }
23.2504 +-
23.2505 +diff --git a/kimap/imapset.h b/kimap/imapset.h
23.2506 +index a3417ac..a217251 100644
23.2507 +--- a/kimap/imapset.h
23.2508 ++++ b/kimap/imapset.h
23.2509 +@@ -199,6 +199,7 @@ class KIMAP_EXPORT ImapSet
23.2510 + /**
23.2511 + Adds the given ImapInterval to this set.
23.2512 + No interval merging is performed.
23.2513 ++ @param interval the interval to add
23.2514 + */
23.2515 + void add( const ImapInterval &interval );
23.2516 +
23.2517 +diff --git a/kimap/imapstreamparser.cpp b/kimap/imapstreamparser.cpp
23.2518 +index 50a8552..37bf691 100644
23.2519 +--- a/kimap/imapstreamparser.cpp
23.2520 ++++ b/kimap/imapstreamparser.cpp
23.2521 +@@ -48,20 +48,21 @@ QString ImapStreamParser::readUtf8String()
23.2522 + return result;
23.2523 + }
23.2524 +
23.2525 +-
23.2526 + QByteArray ImapStreamParser::readString()
23.2527 + {
23.2528 + QByteArray result;
23.2529 +- if ( !waitForMoreData( m_data.length() == 0 ) )
23.2530 +- throw ImapParserException("Unable to read more data");
23.2531 ++ if ( !waitForMoreData( m_data.length() == 0 ) ) {
23.2532 ++ throw ImapParserException( "Unable to read more data" );
23.2533 ++ }
23.2534 + stripLeadingSpaces();
23.2535 +- if ( !waitForMoreData( m_position >= m_data.length() ) )
23.2536 +- throw ImapParserException("Unable to read more data");
23.2537 ++ if ( !waitForMoreData( m_position >= m_data.length() ) ) {
23.2538 ++ throw ImapParserException( "Unable to read more data" );
23.2539 ++ }
23.2540 +
23.2541 + // literal string
23.2542 + // TODO: error handling
23.2543 + if ( hasLiteral() ) {
23.2544 +- while (!atLiteralEnd()) {
23.2545 ++ while ( !atLiteralEnd() ) {
23.2546 + result += readLiteralPart();
23.2547 + }
23.2548 + return result;
23.2549 +@@ -73,58 +74,65 @@ QByteArray ImapStreamParser::readString()
23.2550 +
23.2551 + bool ImapStreamParser::hasString()
23.2552 + {
23.2553 +- if ( !waitForMoreData( m_position >= m_data.length() ) )
23.2554 +- throw ImapParserException("Unable to read more data");
23.2555 ++ if ( !waitForMoreData( m_position >= m_data.length() ) ) {
23.2556 ++ throw ImapParserException( "Unable to read more data" );
23.2557 ++ }
23.2558 + int savedPos = m_position;
23.2559 + stripLeadingSpaces();
23.2560 + int pos = m_position;
23.2561 + m_position = savedPos;
23.2562 +- if ( m_data.at(pos) == '{' )
23.2563 ++ if ( m_data.at( pos ) == '{' ) {
23.2564 + return true; //literal string
23.2565 +- if (m_data.at(pos) == '"' )
23.2566 ++ }
23.2567 ++ if ( m_data.at( pos ) == '"' ) {
23.2568 + return true; //quoted string
23.2569 +- if ( m_data.at(pos) != ' ' &&
23.2570 +- m_data.at(pos) != '(' &&
23.2571 +- m_data.at(pos) != ')' &&
23.2572 +- m_data.at(pos) != '[' &&
23.2573 +- m_data.at(pos) != ']' &&
23.2574 +- m_data.at(pos) != '\n' &&
23.2575 +- m_data.at(pos) != '\r' )
23.2576 ++ }
23.2577 ++ if ( m_data.at( pos ) != ' ' &&
23.2578 ++ m_data.at( pos ) != '(' &&
23.2579 ++ m_data.at( pos ) != ')' &&
23.2580 ++ m_data.at( pos ) != '[' &&
23.2581 ++ m_data.at( pos ) != ']' &&
23.2582 ++ m_data.at( pos ) != '\n' &&
23.2583 ++ m_data.at( pos ) != '\r' ) {
23.2584 + return true; //unquoted string
23.2585 ++ }
23.2586 +
23.2587 + return false; //something else, not a string
23.2588 + }
23.2589 +
23.2590 + bool ImapStreamParser::hasLiteral()
23.2591 + {
23.2592 +- if ( !waitForMoreData( m_position >= m_data.length() ) )
23.2593 +- throw ImapParserException("Unable to read more data");
23.2594 ++ if ( !waitForMoreData( m_position >= m_data.length() ) ) {
23.2595 ++ throw ImapParserException( "Unable to read more data" );
23.2596 ++ }
23.2597 + int savedPos = m_position;
23.2598 + stripLeadingSpaces();
23.2599 +- if ( m_data.at(m_position) == '{' )
23.2600 +- {
23.2601 ++ if ( m_data.at( m_position ) == '{' ) {
23.2602 + int end = -1;
23.2603 + do {
23.2604 + end = m_data.indexOf( '}', m_position );
23.2605 +- if ( !waitForMoreData( end == -1 ) )
23.2606 +- throw ImapParserException("Unable to read more data");
23.2607 +- } while (end == -1);
23.2608 ++ if ( !waitForMoreData( end == -1 ) ) {
23.2609 ++ throw ImapParserException( "Unable to read more data" );
23.2610 ++ }
23.2611 ++ } while ( end == -1 );
23.2612 + Q_ASSERT( end > m_position );
23.2613 + m_literalSize = m_data.mid( m_position + 1, end - m_position - 1 ).toInt();
23.2614 + // strip CRLF
23.2615 + m_position = end + 1;
23.2616 +
23.2617 +- if ( m_position < m_data.length() && m_data.at(m_position) == '\r' )
23.2618 ++ if ( m_position < m_data.length() && m_data.at( m_position ) == '\r' ) {
23.2619 + ++m_position;
23.2620 +- if ( m_position < m_data.length() && m_data.at(m_position) == '\n' )
23.2621 ++ }
23.2622 ++ if ( m_position < m_data.length() && m_data.at( m_position ) == '\n' ) {
23.2623 + ++m_position;
23.2624 ++ }
23.2625 +
23.2626 + //FIXME: Makes sense only on the server side?
23.2627 +- if (m_isServerModeEnabled && m_literalSize > 0)
23.2628 ++ if ( m_isServerModeEnabled && m_literalSize > 0 ) {
23.2629 + sendContinuationResponse( m_literalSize );
23.2630 ++ }
23.2631 + return true;
23.2632 +- } else
23.2633 +- {
23.2634 ++ } else {
23.2635 + m_position = savedPos;
23.2636 + return false;
23.2637 + }
23.2638 +@@ -132,7 +140,7 @@ bool ImapStreamParser::hasLiteral()
23.2639 +
23.2640 + bool ImapStreamParser::atLiteralEnd() const
23.2641 + {
23.2642 +- return (m_literalSize == 0);
23.2643 ++ return ( m_literalSize == 0 );
23.2644 + }
23.2645 +
23.2646 + QByteArray ImapStreamParser::readLiteralPart()
23.2647 +@@ -140,18 +148,19 @@ QByteArray ImapStreamParser::readLiteralPart()
23.2648 + static qint64 maxLiteralPartSize = 4096;
23.2649 + int size = qMin(maxLiteralPartSize, m_literalSize);
23.2650 +
23.2651 +- if ( !waitForMoreData( m_data.length() < m_position + size ) )
23.2652 +- throw ImapParserException("Unable to read more data");
23.2653 ++ if ( !waitForMoreData( m_data.length() < m_position + size ) ) {
23.2654 ++ throw ImapParserException( "Unable to read more data" );
23.2655 ++ }
23.2656 +
23.2657 + if ( m_data.length() < m_position + size ) { // Still not enough data
23.2658 + // Take what's already there
23.2659 + size = m_data.length() - m_position;
23.2660 + }
23.2661 +
23.2662 +- QByteArray result = m_data.mid(m_position, size);
23.2663 ++ QByteArray result = m_data.mid( m_position, size );
23.2664 + m_position += size;
23.2665 + m_literalSize -= size;
23.2666 +- Q_ASSERT(m_literalSize >= 0);
23.2667 ++ Q_ASSERT( m_literalSize >= 0 );
23.2668 + trimBuffer();
23.2669 +
23.2670 + return result;
23.2671 +@@ -159,80 +168,81 @@ QByteArray ImapStreamParser::readLiteralPart()
23.2672 +
23.2673 + bool ImapStreamParser::hasList()
23.2674 + {
23.2675 +- if ( !waitForMoreData( m_position >= m_data.length() ) )
23.2676 +- throw ImapParserException("Unable to read more data");
23.2677 ++ if ( !waitForMoreData( m_position >= m_data.length() ) ) {
23.2678 ++ throw ImapParserException( "Unable to read more data" );
23.2679 ++ }
23.2680 + int savedPos = m_position;
23.2681 + stripLeadingSpaces();
23.2682 + int pos = m_position;
23.2683 + m_position = savedPos;
23.2684 +- if ( m_data.at(pos) == '(' )
23.2685 +- {
23.2686 ++ if ( m_data.at( pos ) == '(' ) {
23.2687 + return true;
23.2688 + }
23.2689 +-
23.2690 + return false;
23.2691 + }
23.2692 +
23.2693 + bool ImapStreamParser::atListEnd()
23.2694 + {
23.2695 +- if ( !waitForMoreData( m_position >= m_data.length() ) )
23.2696 +- throw ImapParserException("Unable to read more data");
23.2697 ++ if ( !waitForMoreData( m_position >= m_data.length() ) ) {
23.2698 ++ throw ImapParserException( "Unable to read more data" );
23.2699 ++ }
23.2700 + int savedPos = m_position;
23.2701 + stripLeadingSpaces();
23.2702 + int pos = m_position;
23.2703 + m_position = savedPos;
23.2704 +- if ( m_data.at(pos) == ')' )
23.2705 +- {
23.2706 ++ if ( m_data.at( pos ) == ')' ) {
23.2707 + m_position = pos + 1;
23.2708 + return true;
23.2709 + }
23.2710 +-
23.2711 + return false;
23.2712 + }
23.2713 +
23.2714 + QList<QByteArray> ImapStreamParser::readParenthesizedList()
23.2715 + {
23.2716 + QList<QByteArray> result;
23.2717 +- if (! waitForMoreData( m_data.length() <= m_position ) )
23.2718 +- throw ImapParserException("Unable to read more data");
23.2719 ++ if ( !waitForMoreData( m_data.length() <= m_position ) ) {
23.2720 ++ throw ImapParserException( "Unable to read more data" );
23.2721 ++ }
23.2722 +
23.2723 + stripLeadingSpaces();
23.2724 +- if ( m_data.at(m_position) != '(' )
23.2725 ++ if ( m_data.at( m_position ) != '(' ) {
23.2726 + return result; //no list found
23.2727 ++ }
23.2728 +
23.2729 + bool concatToLast = false;
23.2730 + int count = 0;
23.2731 + int sublistbegin = m_position;
23.2732 + int i = m_position + 1;
23.2733 + Q_FOREVER {
23.2734 +- if ( !waitForMoreData( m_data.length() <= i ) )
23.2735 +- {
23.2736 ++ if ( !waitForMoreData( m_data.length() <= i ) ) {
23.2737 + m_position = i;
23.2738 +- throw ImapParserException("Unable to read more data");
23.2739 ++ throw ImapParserException( "Unable to read more data" );
23.2740 + }
23.2741 +- if ( m_data.at(i) == '(' ) {
23.2742 ++ if ( m_data.at( i ) == '(' ) {
23.2743 + ++count;
23.2744 +- if ( count == 1 )
23.2745 ++ if ( count == 1 ) {
23.2746 + sublistbegin = i;
23.2747 ++ }
23.2748 + ++i;
23.2749 + continue;
23.2750 + }
23.2751 +- if ( m_data.at(i) == ')' ) {
23.2752 ++ if ( m_data.at( i ) == ')' ) {
23.2753 + if ( count <= 0 ) {
23.2754 + m_position = i + 1;
23.2755 + return result;
23.2756 + }
23.2757 +- if ( count == 1 )
23.2758 ++ if ( count == 1 ) {
23.2759 + result.append( m_data.mid( sublistbegin, i - sublistbegin + 1 ) );
23.2760 ++ }
23.2761 + --count;
23.2762 + ++i;
23.2763 + continue;
23.2764 + }
23.2765 +- if ( m_data.at(i) == ' ' ) {
23.2766 ++ if ( m_data.at( i ) == ' ' ) {
23.2767 + ++i;
23.2768 + continue;
23.2769 + }
23.2770 +- if ( m_data.at(i) == '"' ) {
23.2771 ++ if ( m_data.at( i ) == '"' ) {
23.2772 + if ( count > 0 ) {
23.2773 + m_position = i;
23.2774 + parseQuotedString();
23.2775 +@@ -240,27 +250,27 @@ QList<QByteArray> ImapStreamParser::readParenthesizedList()
23.2776 + continue;
23.2777 + }
23.2778 + }
23.2779 +- if ( m_data.at(i) == '[' ) {
23.2780 ++ if ( m_data.at( i ) == '[' ) {
23.2781 + concatToLast = true;
23.2782 + if ( result.isEmpty() ) {
23.2783 + result.append( QByteArray() );
23.2784 + }
23.2785 +- result.last()+='[';
23.2786 ++ result.last() += '[';
23.2787 + ++i;
23.2788 + continue;
23.2789 + }
23.2790 +- if ( m_data.at(i) == ']' ) {
23.2791 ++ if ( m_data.at( i ) == ']' ) {
23.2792 + concatToLast = false;
23.2793 +- result.last()+=']';
23.2794 ++ result.last() += ']';
23.2795 + ++i;
23.2796 + continue;
23.2797 + }
23.2798 + if ( count == 0 ) {
23.2799 + m_position = i;
23.2800 + QByteArray ba;
23.2801 +- if (hasLiteral()) {
23.2802 +- while (!atLiteralEnd()) {
23.2803 +- ba+=readLiteralPart();
23.2804 ++ if ( hasLiteral() ) {
23.2805 ++ while ( !atLiteralEnd() ) {
23.2806 ++ ba += readLiteralPart();
23.2807 + }
23.2808 + } else {
23.2809 + ba = readString();
23.2810 +@@ -268,13 +278,14 @@ QList<QByteArray> ImapStreamParser::readParenthesizedList()
23.2811 +
23.2812 + // We might sometime get some unwanted CRLF, but we're still not at the end
23.2813 + // of the list, would make further string reads fail so eat the CRLFs.
23.2814 +- while ( ( m_position < m_data.size() ) && ( m_data.at(m_position) == '\r' || m_data.at(m_position) == '\n' ) ) {
23.2815 ++ while ( ( m_position < m_data.size() ) &&
23.2816 ++ ( m_data.at( m_position ) == '\r' || m_data.at( m_position ) == '\n' ) ) {
23.2817 + m_position++;
23.2818 + }
23.2819 +
23.2820 + i = m_position - 1;
23.2821 +- if (concatToLast) {
23.2822 +- result.last()+=ba;
23.2823 ++ if ( concatToLast ) {
23.2824 ++ result.last() += ba;
23.2825 + } else {
23.2826 + result.append( ba );
23.2827 + }
23.2828 +@@ -287,68 +298,68 @@ QList<QByteArray> ImapStreamParser::readParenthesizedList()
23.2829 +
23.2830 + bool ImapStreamParser::hasResponseCode()
23.2831 + {
23.2832 +- if ( !waitForMoreData( m_position >= m_data.length() ) )
23.2833 +- throw ImapParserException("Unable to read more data");
23.2834 ++ if ( !waitForMoreData( m_position >= m_data.length() ) ) {
23.2835 ++ throw ImapParserException( "Unable to read more data" );
23.2836 ++ }
23.2837 + int savedPos = m_position;
23.2838 + stripLeadingSpaces();
23.2839 + int pos = m_position;
23.2840 + m_position = savedPos;
23.2841 +- if ( m_data.at(pos) == '[' )
23.2842 +- {
23.2843 ++ if ( m_data.at( pos ) == '[' ) {
23.2844 + m_position = pos + 1;
23.2845 + return true;
23.2846 + }
23.2847 +-
23.2848 + return false;
23.2849 + }
23.2850 +
23.2851 + bool ImapStreamParser::atResponseCodeEnd()
23.2852 + {
23.2853 +- if ( !waitForMoreData( m_position >= m_data.length() ) )
23.2854 +- throw ImapParserException("Unable to read more data");
23.2855 ++ if ( !waitForMoreData( m_position >= m_data.length() ) ) {
23.2856 ++ throw ImapParserException( "Unable to read more data" );
23.2857 ++ }
23.2858 + int savedPos = m_position;
23.2859 + stripLeadingSpaces();
23.2860 + int pos = m_position;
23.2861 + m_position = savedPos;
23.2862 +- if ( m_data.at(pos) == ']' )
23.2863 +- {
23.2864 ++ if ( m_data.at( pos ) == ']' ) {
23.2865 + m_position = pos + 1;
23.2866 + return true;
23.2867 + }
23.2868 +-
23.2869 + return false;
23.2870 + }
23.2871 +
23.2872 + QByteArray ImapStreamParser::parseQuotedString()
23.2873 + {
23.2874 + QByteArray result;
23.2875 +- if (! waitForMoreData( m_data.length() == 0 ) )
23.2876 +- throw ImapParserException("Unable to read more data");
23.2877 ++ if ( !waitForMoreData( m_data.length() == 0 ) ) {
23.2878 ++ throw ImapParserException( "Unable to read more data" );
23.2879 ++ }
23.2880 + stripLeadingSpaces();
23.2881 + int end = m_position;
23.2882 + result.clear();
23.2883 +- if ( !waitForMoreData( m_position >= m_data.length() ) )
23.2884 +- throw ImapParserException("Unable to read more data");
23.2885 +- if ( !waitForMoreData( m_position >= m_data.length() ) )
23.2886 +- throw ImapParserException("Unable to read more data");
23.2887 ++ if ( !waitForMoreData( m_position >= m_data.length() ) ) {
23.2888 ++ throw ImapParserException( "Unable to read more data" );
23.2889 ++ }
23.2890 ++ if ( !waitForMoreData( m_position >= m_data.length() ) ) {
23.2891 ++ throw ImapParserException( "Unable to read more data" );
23.2892 ++ }
23.2893 +
23.2894 + bool foundSlash = false;
23.2895 + // quoted string
23.2896 +- if ( m_data.at(m_position) == '"' ) {
23.2897 ++ if ( m_data.at( m_position ) == '"' ) {
23.2898 + ++m_position;
23.2899 + int i = m_position;
23.2900 + Q_FOREVER {
23.2901 +- if ( !waitForMoreData( m_data.length() <= i ) )
23.2902 +- {
23.2903 ++ if ( !waitForMoreData( m_data.length() <= i ) ) {
23.2904 + m_position = i;
23.2905 +- throw ImapParserException("Unable to read more data");
23.2906 ++ throw ImapParserException( "Unable to read more data" );
23.2907 + }
23.2908 +- if ( m_data.at(i) == '\\' ) {
23.2909 ++ if ( m_data.at( i ) == '\\' ) {
23.2910 + i += 2;
23.2911 + foundSlash = true;
23.2912 + continue;
23.2913 + }
23.2914 +- if ( m_data.at(i) == '"' ) {
23.2915 ++ if ( m_data.at( i ) == '"' ) {
23.2916 + result = m_data.mid( m_position, i - m_position );
23.2917 + end = i + 1; // skip the '"'
23.2918 + break;
23.2919 +@@ -362,32 +373,42 @@ QByteArray ImapStreamParser::parseQuotedString()
23.2920 + bool reachedInputEnd = true;
23.2921 + int i = m_position;
23.2922 + Q_FOREVER {
23.2923 +- if ( !waitForMoreData( m_data.length() <= i ) )
23.2924 +- {
23.2925 ++ if ( !waitForMoreData( m_data.length() <= i ) ) {
23.2926 + m_position = i;
23.2927 +- throw ImapParserException("Unable to read more data");
23.2928 ++ throw ImapParserException( "Unable to read more data" );
23.2929 + }
23.2930 +- if ( m_data.at(i) == ' ' || m_data.at(i) == '(' || m_data.at(i) == ')' || m_data.at(i) == '[' || m_data.at(i) == ']' || m_data.at(i) == '\n' || m_data.at(i) == '\r' || m_data.at(i) == '"') {
23.2931 ++ if ( m_data.at( i ) == ' ' ||
23.2932 ++ m_data.at( i ) == '(' ||
23.2933 ++ m_data.at( i ) == ')' ||
23.2934 ++ m_data.at( i ) == '[' ||
23.2935 ++ m_data.at( i ) == ']' ||
23.2936 ++ m_data.at( i ) == '\n' ||
23.2937 ++ m_data.at( i ) == '\r' ||
23.2938 ++ m_data.at( i ) == '"' ) {
23.2939 + end = i;
23.2940 + reachedInputEnd = false;
23.2941 + break;
23.2942 + }
23.2943 +- if (m_data.at(i) == '\\')
23.2944 ++ if ( m_data.at( i ) == '\\' ) {
23.2945 + foundSlash = true;
23.2946 ++ }
23.2947 + i++;
23.2948 + }
23.2949 +- if ( reachedInputEnd ) //FIXME: how can it get here?
23.2950 ++ if ( reachedInputEnd ) { //FIXME: how can it get here?
23.2951 + end = m_data.length();
23.2952 ++ }
23.2953 +
23.2954 + result = m_data.mid( m_position, end - m_position );
23.2955 + }
23.2956 +
23.2957 + // strip quotes
23.2958 + if ( foundSlash ) {
23.2959 +- while ( result.contains( "\\\"" ) )
23.2960 ++ while ( result.contains( "\\\"" ) ) {
23.2961 + result.replace( "\\\"", "\"" );
23.2962 +- while ( result.contains( "\\\\" ) )
23.2963 ++ }
23.2964 ++ while ( result.contains( "\\\\" ) ) {
23.2965 + result.replace( "\\\\", "\\" );
23.2966 ++ }
23.2967 + }
23.2968 + m_position = end;
23.2969 + return result;
23.2970 +@@ -396,24 +417,28 @@ QByteArray ImapStreamParser::parseQuotedString()
23.2971 + qint64 ImapStreamParser::readNumber( bool * ok )
23.2972 + {
23.2973 + qint64 result;
23.2974 +- if ( ok )
23.2975 ++ if ( ok ) {
23.2976 + *ok = false;
23.2977 +- if (! waitForMoreData( m_data.length() == 0 ) )
23.2978 +- throw ImapParserException("Unable to read more data");
23.2979 ++ }
23.2980 ++ if ( !waitForMoreData( m_data.length() == 0 ) ) {
23.2981 ++ throw ImapParserException( "Unable to read more data" );
23.2982 ++ }
23.2983 + stripLeadingSpaces();
23.2984 +- if ( !waitForMoreData( m_position >= m_data.length() ) )
23.2985 +- throw ImapParserException("Unable to read more data");
23.2986 +- if ( m_position >= m_data.length() )
23.2987 +- throw ImapParserException("Unable to read more data");
23.2988 ++ if ( !waitForMoreData( m_position >= m_data.length() ) ) {
23.2989 ++ throw ImapParserException( "Unable to read more data" );
23.2990 ++ }
23.2991 ++ if ( m_position >= m_data.length() ) {
23.2992 ++ throw ImapParserException( "Unable to read more data" );
23.2993 ++ }
23.2994 + int i = m_position;
23.2995 + Q_FOREVER {
23.2996 +- if ( !waitForMoreData( m_data.length() <= i ) )
23.2997 +- {
23.2998 ++ if ( !waitForMoreData( m_data.length() <= i ) ) {
23.2999 + m_position = i;
23.3000 +- throw ImapParserException("Unable to read more data");
23.3001 ++ throw ImapParserException( "Unable to read more data" );
23.3002 + }
23.3003 +- if ( !isdigit( m_data.at( i ) ) )
23.3004 ++ if ( !isdigit( m_data.at( i ) ) ) {
23.3005 + break;
23.3006 ++ }
23.3007 + ++i;
23.3008 + }
23.3009 + const QByteArray tmp = m_data.mid( m_position, i - m_position );
23.3010 +@@ -425,8 +450,7 @@ qint64 ImapStreamParser::readNumber( bool * ok )
23.3011 + void ImapStreamParser::stripLeadingSpaces()
23.3012 + {
23.3013 + for ( int i = m_position; i < m_data.length(); ++i ) {
23.3014 +- if ( m_data.at(i) != ' ' )
23.3015 +- {
23.3016 ++ if ( m_data.at( i ) != ' ' ) {
23.3017 + m_position = i;
23.3018 + return;
23.3019 + }
23.3020 +@@ -438,10 +462,9 @@ bool ImapStreamParser::waitForMoreData( bool wait )
23.3021 + {
23.3022 + if ( wait ) {
23.3023 + if ( m_socket->bytesAvailable() > 0 ||
23.3024 +- m_socket->waitForReadyRead(30000) ) {
23.3025 ++ m_socket->waitForReadyRead( 30000 ) ) {
23.3026 + m_data.append( m_socket->readAll() );
23.3027 +- } else
23.3028 +- {
23.3029 ++ } else {
23.3030 + return false;
23.3031 + }
23.3032 + }
23.3033 +@@ -455,28 +478,31 @@ void ImapStreamParser::setData( const QByteArray &data )
23.3034 +
23.3035 + QByteArray ImapStreamParser::readRemainingData()
23.3036 + {
23.3037 +- return m_data.mid(m_position);
23.3038 ++ return m_data.mid( m_position );
23.3039 + }
23.3040 +
23.3041 + int ImapStreamParser::availableDataSize() const
23.3042 + {
23.3043 +- return m_socket->bytesAvailable()+m_data.size()-m_position;
23.3044 ++ return m_socket->bytesAvailable() + m_data.size() - m_position;
23.3045 + }
23.3046 +
23.3047 + bool ImapStreamParser::atCommandEnd()
23.3048 + {
23.3049 + int savedPos = m_position;
23.3050 + do {
23.3051 +- if ( !waitForMoreData( m_position >= m_data.length() ) )
23.3052 +- throw ImapParserException("Unable to read more data");
23.3053 ++ if ( !waitForMoreData( m_position >= m_data.length() ) ) {
23.3054 ++ throw ImapParserException( "Unable to read more data" );
23.3055 ++ }
23.3056 + stripLeadingSpaces();
23.3057 + } while ( m_position >= m_data.size() );
23.3058 +
23.3059 +- if ( m_data.at(m_position) == '\n' || m_data.at(m_position) == '\r') {
23.3060 +- if ( m_data.at(m_position) == '\r' )
23.3061 ++ if ( m_data.at( m_position ) == '\n' || m_data.at( m_position ) == '\r' ) {
23.3062 ++ if ( m_data.at( m_position ) == '\r' ) {
23.3063 + ++m_position;
23.3064 +- if ( m_position < m_data.length() && m_data.at(m_position) == '\n' )
23.3065 ++ }
23.3066 ++ if ( m_position < m_data.length() && m_data.at( m_position ) == '\n' ) {
23.3067 + ++m_position;
23.3068 ++ }
23.3069 +
23.3070 + // We'd better empty m_data from time to time before it grows out of control
23.3071 + trimBuffer();
23.3072 +@@ -493,29 +519,30 @@ QByteArray ImapStreamParser::readUntilCommandEnd()
23.3073 + int i = m_position;
23.3074 + int paranthesisBalance = 0;
23.3075 + Q_FOREVER {
23.3076 +- if ( !waitForMoreData( m_data.length() <= i ) )
23.3077 +- {
23.3078 ++ if ( !waitForMoreData( m_data.length() <= i ) ) {
23.3079 + m_position = i;
23.3080 +- throw ImapParserException("Unable to read more data");
23.3081 ++ throw ImapParserException( "Unable to read more data" );
23.3082 + }
23.3083 +- if ( m_data.at(i) == '{' )
23.3084 +- {
23.3085 ++ if ( m_data.at( i ) == '{' ) {
23.3086 + m_position = i - 1;
23.3087 + hasLiteral(); //init literal size
23.3088 +- result.append(m_data.mid(i-1, m_position - i +1));
23.3089 +- while (!atLiteralEnd())
23.3090 +- {
23.3091 ++ result.append( m_data.mid( i - 1, m_position - i + 1 ) );
23.3092 ++ while ( !atLiteralEnd() ) {
23.3093 + result.append( readLiteralPart() );
23.3094 + }
23.3095 + i = m_position;
23.3096 + }
23.3097 +- if ( m_data.at(i) == '(' )
23.3098 ++ if ( m_data.at( i ) == '(' ) {
23.3099 + paranthesisBalance++;
23.3100 +- if ( m_data.at(i) == ')' )
23.3101 ++ }
23.3102 ++ if ( m_data.at( i ) == ')' ) {
23.3103 + paranthesisBalance--;
23.3104 +- if ( ( i == m_data.length() && paranthesisBalance == 0 ) || m_data.at(i) == '\n' || m_data.at(i) == '\r')
23.3105 ++ }
23.3106 ++ if ( ( i == m_data.length() && paranthesisBalance == 0 ) ||
23.3107 ++ m_data.at( i ) == '\n' || m_data.at( i ) == '\r') {
23.3108 + break; //command end
23.3109 +- result.append( m_data.at(i) );
23.3110 ++ }
23.3111 ++ result.append( m_data.at( i ) );
23.3112 + ++i;
23.3113 + }
23.3114 + m_position = i;
23.3115 +@@ -525,16 +552,17 @@ QByteArray ImapStreamParser::readUntilCommandEnd()
23.3116 +
23.3117 + void ImapStreamParser::sendContinuationResponse( qint64 size )
23.3118 + {
23.3119 +- QByteArray block = "+ Ready for literal data (expecting "
23.3120 +- + QByteArray::number( size ) + " bytes)\r\n";
23.3121 +- m_socket->write(block);
23.3122 +- m_socket->waitForBytesWritten(30000);
23.3123 ++ QByteArray block = "+ Ready for literal data (expecting " +
23.3124 ++ QByteArray::number( size ) + " bytes)\r\n";
23.3125 ++ m_socket->write( block );
23.3126 ++ m_socket->waitForBytesWritten( 30000 );
23.3127 + }
23.3128 +
23.3129 + void ImapStreamParser::trimBuffer()
23.3130 + {
23.3131 +- if ( m_position < 4096 ) // right() is expensive, so don't do it for every line
23.3132 ++ if ( m_position < 4096 ) { // right() is expensive, so don't do it for every line
23.3133 + return;
23.3134 +- m_data = m_data.right(m_data.size()-m_position);
23.3135 ++ }
23.3136 ++ m_data = m_data.right( m_data.size() - m_position );
23.3137 + m_position = 0;
23.3138 + }
23.3139 +diff --git a/kimap/imapstreamparser.h b/kimap/imapstreamparser.h
23.3140 +index 7c43d1d..12e97b0 100644
23.3141 +--- a/kimap/imapstreamparser.h
23.3142 ++++ b/kimap/imapstreamparser.h
23.3143 +@@ -36,9 +36,9 @@ namespace KIMAP {
23.3144 + class ImapParserException : public std::exception
23.3145 + {
23.3146 + public:
23.3147 +- ImapParserException( const char *what ) throw() : mWhat( what ) {}
23.3148 +- ImapParserException( const QByteArray &what ) throw() : mWhat( what ) {}
23.3149 +- ImapParserException( const QString &what ) throw() : mWhat( what.toUtf8() ) {}
23.3150 ++ explicit ImapParserException( const char *what ) throw() : mWhat( what ) {}
23.3151 ++ explicit ImapParserException( const QByteArray &what ) throw() : mWhat( what ) {}
23.3152 ++ explicit ImapParserException( const QString &what ) throw() : mWhat( what.toUtf8() ) {}
23.3153 + ImapParserException( const ImapParserException &other ) throw() : std::exception( other ), mWhat( other.what() ) {}
23.3154 + virtual ~ImapParserException() throw() {}
23.3155 + const char *what() const throw() { return mWhat.constData(); }
23.3156 +@@ -86,7 +86,6 @@ class KIMAP_EXPORT ImapStreamParser
23.3157 + */
23.3158 + QList<QByteArray> readParenthesizedList();
23.3159 +
23.3160 +-
23.3161 + /**
23.3162 + * Get the next data as a number. This call might block.
23.3163 + * @param ok true if the data found was a number
23.3164 +@@ -181,7 +180,6 @@ class KIMAP_EXPORT ImapStreamParser
23.3165 +
23.3166 + void setData( const QByteArray &data );
23.3167 +
23.3168 +-
23.3169 + private:
23.3170 + void stripLeadingSpaces();
23.3171 + QByteArray parseQuotedString();
23.3172 +diff --git a/kimap/job.cpp b/kimap/job.cpp
23.3173 +index cd30eec..938c941 100644
23.3174 +--- a/kimap/job.cpp
23.3175 ++++ b/kimap/job.cpp
23.3176 +@@ -22,21 +22,19 @@
23.3177 + #include "message_p.h"
23.3178 + #include "session_p.h"
23.3179 +
23.3180 +-#include <klocale.h>
23.3181 +-#include <kdebug.h>
23.3182 ++#include <KDE/KLocalizedString>
23.3183 ++#include <KDE/KDebug>
23.3184 +
23.3185 + using namespace KIMAP;
23.3186 +
23.3187 + Job::Job( Session *session )
23.3188 +- : KJob( session ), d_ptr(new JobPrivate(session, i18n("Job")))
23.3189 ++ : KJob( session ), d_ptr( new JobPrivate( session, i18n( "Job" ) ) )
23.3190 + {
23.3191 +-
23.3192 + }
23.3193 +
23.3194 + Job::Job( JobPrivate &dd )
23.3195 +- : KJob( dd.m_session ), d_ptr(&dd)
23.3196 ++ : KJob( dd.m_session ), d_ptr( &dd )
23.3197 + {
23.3198 +-
23.3199 + }
23.3200 +
23.3201 + Job::~Job()
23.3202 +@@ -46,40 +44,40 @@ Job::~Job()
23.3203 +
23.3204 + Session *Job::session() const
23.3205 + {
23.3206 +- Q_D(const Job);
23.3207 ++ Q_D( const Job );
23.3208 + return d->m_session;
23.3209 + }
23.3210 +
23.3211 + void Job::start()
23.3212 + {
23.3213 +- Q_D(Job);
23.3214 +- d->sessionInternal()->addJob(this);
23.3215 ++ Q_D( Job );
23.3216 ++ d->sessionInternal()->addJob( this );
23.3217 + }
23.3218 +
23.3219 + void Job::handleResponse(const Message &response)
23.3220 + {
23.3221 +- handleErrorReplies(response);
23.3222 ++ handleErrorReplies( response );
23.3223 + }
23.3224 +
23.3225 + void Job::connectionLost()
23.3226 + {
23.3227 + setError( KJob::UserDefinedError );
23.3228 +- setErrorText( i18n("Connection to server lost.") );
23.3229 ++ setErrorText( i18n( "Connection to server lost." ) );
23.3230 + emitResult();
23.3231 + }
23.3232 +
23.3233 + Job::HandlerResponse Job::handleErrorReplies(const Message &response)
23.3234 + {
23.3235 +- Q_D(Job);
23.3236 +-// qDebug() << response.toString();
23.3237 ++ Q_D( Job );
23.3238 ++// kDebug() << response.toString();
23.3239 +
23.3240 +- if ( !response.content.isEmpty()
23.3241 +- && d->tags.contains( response.content.first().toString() ) ) {
23.3242 ++ if ( !response.content.isEmpty() &&
23.3243 ++ d->tags.contains( response.content.first().toString() ) ) {
23.3244 + if ( response.content.size() < 2 ) {
23.3245 +- setErrorText( i18n("%1 failed, malformed reply from the server.", d->m_name) );
23.3246 ++ setErrorText( i18n( "%1 failed, malformed reply from the server.", d->m_name ) );
23.3247 + } else if ( response.content[1].toString() != "OK" ) {
23.3248 + setError( UserDefinedError );
23.3249 +- setErrorText( i18n("%1 failed, server replied: %2", d->m_name, response.toString().constData()) );
23.3250 ++ setErrorText( i18n( "%1 failed, server replied: %2", d->m_name, response.toString().constData() ) );
23.3251 + }
23.3252 + d->tags.removeAll( response.content.first().toString() );
23.3253 + if ( d->tags.isEmpty() ) { // Only emit result when the last command returned
23.3254 +@@ -92,3 +90,4 @@ Job::HandlerResponse Job::handleErrorReplies(const Message &response)
23.3255 + }
23.3256 +
23.3257 + #include "job.moc"
23.3258 ++
23.3259 +diff --git a/kimap/job.h b/kimap/job.h
23.3260 +index 79dd9a6..6bb5670 100644
23.3261 +--- a/kimap/job.h
23.3262 ++++ b/kimap/job.h
23.3263 +@@ -22,7 +22,7 @@
23.3264 +
23.3265 + #include "kimap_export.h"
23.3266 +
23.3267 +-#include <kjob.h>
23.3268 ++#include <KDE/KJob>
23.3269 +
23.3270 + namespace KIMAP {
23.3271 +
23.3272 +@@ -34,7 +34,7 @@ struct Message;
23.3273 + class KIMAP_EXPORT Job : public KJob
23.3274 + {
23.3275 + Q_OBJECT
23.3276 +- Q_DECLARE_PRIVATE(Job)
23.3277 ++ Q_DECLARE_PRIVATE( Job )
23.3278 +
23.3279 + friend class SessionPrivate;
23.3280 +
23.3281 +diff --git a/kimap/job_p.h b/kimap/job_p.h
23.3282 +index b04cf9c..6e4b717 100644
23.3283 +--- a/kimap/job_p.h
23.3284 ++++ b/kimap/job_p.h
23.3285 +@@ -21,7 +21,7 @@
23.3286 + #define KIMAP_JOB_P_H
23.3287 +
23.3288 + #include "session.h"
23.3289 +-#include <klocale.h>
23.3290 ++#include <KDE/KLocalizedString>
23.3291 +
23.3292 + namespace KIMAP {
23.3293 +
23.3294 +@@ -30,7 +30,7 @@ class SessionPrivate;
23.3295 + class JobPrivate
23.3296 + {
23.3297 + public:
23.3298 +- JobPrivate( Session *session, const QString& name ) : m_session(session) {
23.3299 ++ JobPrivate( Session *session, const QString& name ) : m_session( session ) {
23.3300 + m_name = name;
23.3301 + }
23.3302 + virtual ~JobPrivate() { }
23.3303 +diff --git a/kimap/listjob.cpp b/kimap/listjob.cpp
23.3304 +index 60f8071..322fc37 100644
23.3305 +--- a/kimap/listjob.cpp
23.3306 ++++ b/kimap/listjob.cpp
23.3307 +@@ -21,7 +21,7 @@
23.3308 +
23.3309 + #include <boost/bind.hpp>
23.3310 + #include <QtCore/QTimer>
23.3311 +-#include <klocale.h>
23.3312 ++#include <KDE/KLocalizedString>
23.3313 +
23.3314 + #include "job_p.h"
23.3315 + #include "message_p.h"
23.3316 +@@ -33,7 +33,7 @@ namespace KIMAP
23.3317 + class ListJobPrivate : public JobPrivate
23.3318 + {
23.3319 + public:
23.3320 +- ListJobPrivate( ListJob *job, Session *session, const QString& name ) : JobPrivate(session, name), q(job), option(ListJob::NoOption) { }
23.3321 ++ ListJobPrivate( ListJob *job, Session *session, const QString& name ) : JobPrivate( session, name ), q( job ), option( ListJob::NoOption ) { }
23.3322 + ~ListJobPrivate() { }
23.3323 +
23.3324 + void emitPendings()
23.3325 +@@ -63,9 +63,9 @@ namespace KIMAP
23.3326 + using namespace KIMAP;
23.3327 +
23.3328 + ListJob::ListJob( Session *session )
23.3329 +- : Job( *new ListJobPrivate(this, session, i18n("List")) )
23.3330 ++ : Job( *new ListJobPrivate( this, session, i18n( "List" ) ) )
23.3331 + {
23.3332 +- Q_D(ListJob);
23.3333 ++ Q_D( ListJob );
23.3334 + connect( &d->emitPendingsTimer, SIGNAL(timeout()),
23.3335 + this, SLOT(emitPendings()) );
23.3336 + }
23.3337 +@@ -76,8 +76,8 @@ ListJob::~ListJob()
23.3338 +
23.3339 + void ListJob::setIncludeUnsubscribed( bool include )
23.3340 + {
23.3341 +- Q_D(ListJob);
23.3342 +- if (include) {
23.3343 ++ Q_D( ListJob );
23.3344 ++ if ( include ) {
23.3345 + d->option = ListJob::IncludeUnsubscribed;
23.3346 + } else {
23.3347 + d->option = ListJob::NoOption;
23.3348 +@@ -86,31 +86,31 @@ void ListJob::setIncludeUnsubscribed( bool include )
23.3349 +
23.3350 + bool ListJob::isIncludeUnsubscribed() const
23.3351 + {
23.3352 +- Q_D(const ListJob);
23.3353 ++ Q_D( const ListJob );
23.3354 + return ( d->option == ListJob::IncludeUnsubscribed );
23.3355 + }
23.3356 +
23.3357 + void ListJob::setOption( Option option )
23.3358 + {
23.3359 +- Q_D(ListJob);
23.3360 ++ Q_D( ListJob );
23.3361 + d->option = option;
23.3362 + }
23.3363 +
23.3364 + ListJob::Option ListJob::option() const
23.3365 + {
23.3366 +- Q_D(const ListJob);
23.3367 ++ Q_D( const ListJob );
23.3368 + return d->option;
23.3369 + }
23.3370 +
23.3371 + void ListJob::setQueriedNamespaces( const QList<MailBoxDescriptor> &namespaces )
23.3372 + {
23.3373 +- Q_D(ListJob);
23.3374 ++ Q_D( ListJob );
23.3375 + d->namespaces = namespaces;
23.3376 + }
23.3377 +
23.3378 + QList<MailBoxDescriptor> ListJob::queriedNamespaces() const
23.3379 + {
23.3380 +- Q_D(const ListJob);
23.3381 ++ Q_D( const ListJob );
23.3382 + return d->namespaces;
23.3383 + }
23.3384 +
23.3385 +@@ -126,9 +126,9 @@ QMap< MailBoxDescriptor, QList<QByteArray> > ListJob::flags() const
23.3386 +
23.3387 + void ListJob::doStart()
23.3388 + {
23.3389 +- Q_D(ListJob);
23.3390 ++ Q_D( ListJob );
23.3391 +
23.3392 +- switch (d->option) {
23.3393 ++ switch ( d->option ) {
23.3394 + break;
23.3395 + case IncludeUnsubscribed:
23.3396 + d->command = "LIST";
23.3397 +@@ -157,20 +157,20 @@ void ListJob::doStart()
23.3398 + }
23.3399 +
23.3400 + d->tags << d->sessionInternal()->sendCommand( d->command,
23.3401 +- parameters.arg( descriptor.name+'*' ).toUtf8() );
23.3402 ++ parameters.arg( descriptor.name + '*' ).toUtf8() );
23.3403 + }
23.3404 + }
23.3405 + }
23.3406 +
23.3407 + void ListJob::handleResponse( const Message &response )
23.3408 + {
23.3409 +- Q_D(ListJob);
23.3410 ++ Q_D( ListJob );
23.3411 +
23.3412 + // We can predict it'll be handled by handleErrorReplies() so stop
23.3413 + // the timer now so that result() will really be the last emitted signal.
23.3414 +- if ( !response.content.isEmpty()
23.3415 +- && d->tags.size() == 1
23.3416 +- && d->tags.contains( response.content.first().toString() ) ) {
23.3417 ++ if ( !response.content.isEmpty() &&
23.3418 ++ d->tags.size() == 1 &&
23.3419 ++ d->tags.contains( response.content.first().toString() ) ) {
23.3420 + d->emitPendingsTimer.stop();
23.3421 + d->emitPendings();
23.3422 + }
23.3423 +@@ -178,7 +178,7 @@ void ListJob::handleResponse( const Message &response )
23.3424 + if ( handleErrorReplies( response ) == NotHandled ) {
23.3425 + if ( response.content.size() >= 5 && response.content[1].toString() == d->command ) {
23.3426 + QList<QByteArray> flags = response.content[2].toList();
23.3427 +- std::transform( flags.begin(), flags.end(), flags.begin(), boost::bind(&QByteArray::toLower, _1) );
23.3428 ++ std::transform( flags.begin(), flags.end(), flags.begin(), boost::bind( &QByteArray::toLower, _1 ) );
23.3429 + QByteArray separator = response.content[3].toString();
23.3430 + if ( separator.isEmpty() ) {
23.3431 + // Defaults to / for servers reporting an empty list
23.3432 +@@ -186,7 +186,7 @@ void ListJob::handleResponse( const Message &response )
23.3433 + // only do it for mailboxes with no child.
23.3434 + separator = "/"; //krazy:exclude=doublequote_chars since a QByteArray
23.3435 + }
23.3436 +- Q_ASSERT(separator.size()==1);
23.3437 ++ Q_ASSERT( separator.size() == 1 );
23.3438 + QByteArray fullName;
23.3439 + for ( int i=4; i<response.content.size(); i++ ) {
23.3440 + fullName += response.content[i].toString() + ' ';
23.3441 +@@ -209,12 +209,16 @@ void ListJob::handleResponse( const Message &response )
23.3442 + void ListJob::convertInboxName(KIMAP::MailBoxDescriptor& descriptor)
23.3443 + {
23.3444 + //Inbox must be case sensitive, according to the RFC, so make it always uppercase
23.3445 +- QStringList pathParts = descriptor.name.split(descriptor.separator);
23.3446 +- if ( !pathParts.isEmpty() && pathParts[0].compare( QLatin1String("INBOX"), Qt::CaseInsensitive ) == 0 ) {
23.3447 +- pathParts.removeAt(0);
23.3448 +- descriptor.name = QLatin1String("INBOX");
23.3449 +- if ( !pathParts.isEmpty() )
23.3450 ++ QStringList pathParts = descriptor.name.split( descriptor.separator );
23.3451 ++ if ( !pathParts.isEmpty() &&
23.3452 ++ pathParts[0].compare( QLatin1String( "INBOX" ), Qt::CaseInsensitive ) == 0 ) {
23.3453 ++ pathParts.removeAt( 0 );
23.3454 ++ descriptor.name = QLatin1String( "INBOX" );
23.3455 ++ if ( !pathParts.isEmpty() ) {
23.3456 + descriptor.name += descriptor.separator + pathParts.join( descriptor.separator );
23.3457 ++ }
23.3458 + }
23.3459 + }
23.3460 ++
23.3461 + #include "listjob.moc"
23.3462 ++
23.3463 +diff --git a/kimap/listjob.h b/kimap/listjob.h
23.3464 +index c90cea6..4d87018 100644
23.3465 +--- a/kimap/listjob.h
23.3466 ++++ b/kimap/listjob.h
23.3467 +@@ -37,19 +37,19 @@ struct KIMAP_EXPORT MailBoxDescriptor
23.3468 +
23.3469 + inline bool operator==(const MailBoxDescriptor &other) const
23.3470 + {
23.3471 +- return other.name==name && other.separator==separator;
23.3472 ++ return other.name == name && other.separator == separator;
23.3473 + }
23.3474 +
23.3475 + inline bool operator<(const MailBoxDescriptor &other) const
23.3476 + {
23.3477 +- return other.name<name || (other.name==name && other.separator<separator);
23.3478 ++ return other.name < name || ( other.name == name && other.separator < separator );
23.3479 + }
23.3480 + };
23.3481 +
23.3482 + class KIMAP_EXPORT ListJob : public Job
23.3483 + {
23.3484 + Q_OBJECT
23.3485 +- Q_DECLARE_PRIVATE(ListJob)
23.3486 ++ Q_DECLARE_PRIVATE( ListJob )
23.3487 +
23.3488 + friend class SessionPrivate;
23.3489 +
23.3490 +diff --git a/kimap/listrightsjob.cpp b/kimap/listrightsjob.cpp
23.3491 +index 4e79aec..bde9ff0 100644
23.3492 +--- a/kimap/listrightsjob.cpp
23.3493 ++++ b/kimap/listrightsjob.cpp
23.3494 +@@ -19,8 +19,8 @@
23.3495 +
23.3496 + #include "listrightsjob.h"
23.3497 +
23.3498 +-#include <klocale.h>
23.3499 +-#include <kdebug.h>
23.3500 ++#include <KDE/KLocalizedString>
23.3501 ++#include <KDE/KDebug>
23.3502 +
23.3503 + #include "acljobbase_p.h"
23.3504 + #include "message_p.h"
23.3505 +@@ -32,7 +32,7 @@ namespace KIMAP
23.3506 + class ListRightsJobPrivate : public AclJobBasePrivate
23.3507 + {
23.3508 + public:
23.3509 +- ListRightsJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate(session, name), defaultRights(Acl::None) {}
23.3510 ++ ListRightsJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate( session, name ), defaultRights( Acl::None ) {}
23.3511 + ~ListRightsJobPrivate() { }
23.3512 +
23.3513 + Acl::Rights defaultRights;
23.3514 +@@ -44,7 +44,7 @@ namespace KIMAP
23.3515 + using namespace KIMAP;
23.3516 +
23.3517 + ListRightsJob::ListRightsJob( Session *session )
23.3518 +- : AclJobBase(*new ListRightsJobPrivate(session, i18n("ListRights")))
23.3519 ++ : AclJobBase( *new ListRightsJobPrivate( session, i18n( "ListRights" ) ) )
23.3520 + {
23.3521 +
23.3522 + }
23.3523 +@@ -55,53 +55,53 @@ ListRightsJob::~ListRightsJob()
23.3524 +
23.3525 + void ListRightsJob::doStart()
23.3526 + {
23.3527 +- Q_D(ListRightsJob);
23.3528 ++ Q_D( ListRightsJob );
23.3529 +
23.3530 + d->tags << d->sessionInternal()->sendCommand( "LISTRIGHTS", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + "\" \"" + d->id + "\"" );
23.3531 + }
23.3532 +
23.3533 + void ListRightsJob::handleResponse( const Message &response )
23.3534 + {
23.3535 +- Q_D(ListRightsJob);
23.3536 ++ Q_D( ListRightsJob );
23.3537 +
23.3538 +- if (handleErrorReplies(response) == NotHandled) {
23.3539 +- if ( response.content.size() >= 4
23.3540 +- && response.content[1].toString() == "LISTRIGHTS" ) {
23.3541 ++ if ( handleErrorReplies( response ) == NotHandled ) {
23.3542 ++ if ( response.content.size() >= 4 &&
23.3543 ++ response.content[1].toString() == "LISTRIGHTS" ) {
23.3544 + QByteArray s = response.content[4].toString();
23.3545 +- d->defaultRights = Acl::rightsFromString(s);
23.3546 ++ d->defaultRights = Acl::rightsFromString( s );
23.3547 + int i = 5;
23.3548 +- while ( i < response.content.size()) {
23.3549 ++ while ( i < response.content.size() ) {
23.3550 + s = response.content[i].toString();
23.3551 +- d->possibleRights.append(Acl::rightsFromString(s));
23.3552 ++ d->possibleRights.append( Acl::rightsFromString( s ) );
23.3553 + i++;
23.3554 + }
23.3555 + }
23.3556 + }
23.3557 + }
23.3558 +
23.3559 +-
23.3560 + void ListRightsJob::setIdentifier( const QByteArray &identifier )
23.3561 + {
23.3562 +- Q_D(ListRightsJob);
23.3563 +- d->setIdentifier(identifier);
23.3564 ++ Q_D( ListRightsJob );
23.3565 ++ d->setIdentifier( identifier );
23.3566 + }
23.3567 +
23.3568 + QByteArray ListRightsJob::identifier()
23.3569 + {
23.3570 +- Q_D(ListRightsJob);
23.3571 ++ Q_D( ListRightsJob );
23.3572 + return d->identifier();
23.3573 + }
23.3574 +
23.3575 + Acl::Rights ListRightsJob::defaultRights()
23.3576 + {
23.3577 +- Q_D(ListRightsJob);
23.3578 ++ Q_D( ListRightsJob );
23.3579 + return d->defaultRights;
23.3580 + }
23.3581 +
23.3582 + QList<Acl::Rights> ListRightsJob::possibleRights()
23.3583 + {
23.3584 +- Q_D(ListRightsJob);
23.3585 ++ Q_D( ListRightsJob );
23.3586 + return d->possibleRights;
23.3587 + }
23.3588 +
23.3589 + #include "listrightsjob.moc"
23.3590 ++
23.3591 +diff --git a/kimap/listrightsjob.h b/kimap/listrightsjob.h
23.3592 +index ed4850d..edff595 100644
23.3593 +--- a/kimap/listrightsjob.h
23.3594 ++++ b/kimap/listrightsjob.h
23.3595 +@@ -30,7 +30,6 @@ class Session;
23.3596 + struct Message;
23.3597 + class ListRightsJobPrivate;
23.3598 +
23.3599 +-
23.3600 + /**
23.3601 + * Lists the possible and automatic rights for
23.3602 + * an identifier on a mailbox
23.3603 +@@ -49,7 +48,7 @@ class ListRightsJobPrivate;
23.3604 + class KIMAP_EXPORT ListRightsJob : public AclJobBase
23.3605 + {
23.3606 + Q_OBJECT
23.3607 +- Q_DECLARE_PRIVATE(ListRightsJob)
23.3608 ++ Q_DECLARE_PRIVATE( ListRightsJob )
23.3609 +
23.3610 + friend class SessionPrivate;
23.3611 +
23.3612 +diff --git a/kimap/loginjob.cpp b/kimap/loginjob.cpp
23.3613 +index da869be..02634b0 100644
23.3614 +--- a/kimap/loginjob.cpp
23.3615 ++++ b/kimap/loginjob.cpp
23.3616 +@@ -2,7 +2,6 @@
23.3617 + Copyright (c) 2009 Kevin Ottens <ervin@kde.org>
23.3618 + Copyright (c) 2009 Andras Mantia <amantia@kde.org>
23.3619 +
23.3620 +-
23.3621 + This library is free software; you can redistribute it and/or modify it
23.3622 + under the terms of the GNU Library General Public License as published by
23.3623 + the Free Software Foundation; either version 2 of the License, or (at your
23.3624 +@@ -21,8 +20,8 @@
23.3625 +
23.3626 + #include "loginjob.h"
23.3627 +
23.3628 +-#include <klocale.h>
23.3629 +-#include <kdebug.h>
23.3630 ++#include <KDE/KLocalizedString>
23.3631 ++#include <KDE/KDebug>
23.3632 + #include <ktcpsocket.h>
23.3633 +
23.3634 + #include "job_p.h"
23.3635 +@@ -59,7 +58,7 @@ namespace KIMAP
23.3636 + Authenticate
23.3637 + };
23.3638 +
23.3639 +- LoginJobPrivate( LoginJob *job, Session *session, const QString& name ) : JobPrivate(session, name), q(job), encryptionMode(LoginJob::Unencrypted), authState(Login), plainLoginDisabled(false) {
23.3640 ++ LoginJobPrivate( LoginJob *job, Session *session, const QString& name ) : JobPrivate( session, name ), q( job ), encryptionMode( LoginJob::Unencrypted ), authState( Login ), plainLoginDisabled( false ) {
23.3641 + conn = 0;
23.3642 + client_interact = 0;
23.3643 + }
23.3644 +@@ -93,7 +92,7 @@ using namespace KIMAP;
23.3645 +
23.3646 + bool LoginJobPrivate::sasl_interact()
23.3647 + {
23.3648 +- kDebug() <<"sasl_interact";
23.3649 ++ kDebug() << "sasl_interact";
23.3650 + sasl_interact_t *interact = client_interact;
23.3651 +
23.3652 + //some mechanisms do not require username && pass, so it doesn't need a popup
23.3653 +@@ -107,23 +106,23 @@ bool LoginJobPrivate::sasl_interact()
23.3654 + }
23.3655 +
23.3656 + interact = client_interact;
23.3657 +- while( interact->id != SASL_CB_LIST_END ) {
23.3658 +- kDebug() <<"SASL_INTERACT id:" << interact->id;
23.3659 +- switch( interact->id ) {
23.3660 ++ while ( interact->id != SASL_CB_LIST_END ) {
23.3661 ++ kDebug() << "SASL_INTERACT id:" << interact->id;
23.3662 ++ switch ( interact->id ) {
23.3663 + case SASL_CB_AUTHNAME:
23.3664 + if ( !authorizationName.isEmpty() ) {
23.3665 +- kDebug() <<"SASL_CB_[AUTHNAME]: '" << authorizationName <<"'";
23.3666 ++ kDebug() << "SASL_CB_[AUTHNAME]: '" << authorizationName << "'";
23.3667 + interact->result = strdup( authorizationName.toUtf8() );
23.3668 + interact->len = strlen( (const char *) interact->result );
23.3669 + break;
23.3670 + }
23.3671 + case SASL_CB_USER:
23.3672 +- kDebug() <<"SASL_CB_[USER|AUTHNAME]: '" << userName <<"'";
23.3673 ++ kDebug() << "SASL_CB_[USER|AUTHNAME]: '" << userName << "'";
23.3674 + interact->result = strdup( userName.toUtf8() );
23.3675 + interact->len = strlen( (const char *) interact->result );
23.3676 + break;
23.3677 + case SASL_CB_PASS:
23.3678 +- kDebug() <<"SASL_CB_PASS: [hidden]";
23.3679 ++ kDebug() << "SASL_CB_PASS: [hidden]";
23.3680 + interact->result = strdup( password.toUtf8() );
23.3681 + interact->len = strlen( (const char *) interact->result );
23.3682 + break;
23.3683 +@@ -137,62 +136,64 @@ bool LoginJobPrivate::sasl_interact()
23.3684 + return true;
23.3685 + }
23.3686 +
23.3687 +-
23.3688 + LoginJob::LoginJob( Session *session )
23.3689 +- : Job( *new LoginJobPrivate(this, session, i18n("Login")) )
23.3690 ++ : Job( *new LoginJobPrivate( this, session, i18n( "Login" ) ) )
23.3691 + {
23.3692 +- Q_D(LoginJob);
23.3693 +- connect(d->sessionInternal(), SIGNAL(encryptionNegotiationResult(bool)), this, SLOT(sslResponse(bool)));
23.3694 ++ Q_D( LoginJob );
23.3695 ++ connect( d->sessionInternal(), SIGNAL(encryptionNegotiationResult(bool)), this, SLOT(sslResponse(bool)) );
23.3696 ++ kDebug() << this;
23.3697 + }
23.3698 +
23.3699 + LoginJob::~LoginJob()
23.3700 + {
23.3701 ++ kDebug() << this;
23.3702 + }
23.3703 +
23.3704 + QString LoginJob::userName() const
23.3705 + {
23.3706 +- Q_D(const LoginJob);
23.3707 ++ Q_D( const LoginJob );
23.3708 + return d->userName;
23.3709 + }
23.3710 +
23.3711 + void LoginJob::setUserName( const QString &userName )
23.3712 + {
23.3713 +- Q_D(LoginJob);
23.3714 ++ Q_D( LoginJob );
23.3715 + d->userName = userName;
23.3716 + }
23.3717 +
23.3718 + QString LoginJob::authorizationName() const
23.3719 + {
23.3720 +- Q_D(const LoginJob);
23.3721 ++ Q_D( const LoginJob );
23.3722 + return d->authorizationName;
23.3723 + }
23.3724 +
23.3725 + void LoginJob::setAuthorizationName( const QString& authorizationName )
23.3726 + {
23.3727 +- Q_D(LoginJob);
23.3728 ++ Q_D( LoginJob );
23.3729 + d->authorizationName = authorizationName;
23.3730 + }
23.3731 +
23.3732 + QString LoginJob::password() const
23.3733 + {
23.3734 +- Q_D(const LoginJob);
23.3735 ++ Q_D( const LoginJob );
23.3736 + return d->password;
23.3737 + }
23.3738 +
23.3739 + void LoginJob::setPassword( const QString &password )
23.3740 + {
23.3741 +- Q_D(LoginJob);
23.3742 ++ Q_D( LoginJob );
23.3743 + d->password = password;
23.3744 + }
23.3745 +
23.3746 + void LoginJob::doStart()
23.3747 + {
23.3748 +- Q_D(LoginJob);
23.3749 ++ Q_D( LoginJob );
23.3750 +
23.3751 ++ kDebug() << this;
23.3752 + // Don't authenticate on a session in the authenticated state
23.3753 + if ( session()->state() == Session::Authenticated || session()->state() == Session::Selected ) {
23.3754 + setError( UserDefinedError );
23.3755 +- setErrorText( i18n("IMAP session in the wrong state for authentication") );
23.3756 ++ setErrorText( i18n( "IMAP session in the wrong state for authentication" ) );
23.3757 + emitResult();
23.3758 + return;
23.3759 + }
23.3760 +@@ -209,53 +210,57 @@ void LoginJob::doStart()
23.3761 + // (so for instance we won't issue another STARTTLS for nothing if that's
23.3762 + // not needed)
23.3763 + case KTcpSocket::SslV2:
23.3764 +- if ( encryptionMode==SslV2 ) {
23.3765 ++ if ( encryptionMode == SslV2 ) {
23.3766 + encryptionMode = Unencrypted;
23.3767 + }
23.3768 + break;
23.3769 + case KTcpSocket::SslV3:
23.3770 +- if ( encryptionMode==SslV3 ) {
23.3771 ++ if ( encryptionMode == SslV3 ) {
23.3772 + encryptionMode = Unencrypted;
23.3773 + }
23.3774 + break;
23.3775 + case KTcpSocket::TlsV1:
23.3776 +- if ( encryptionMode==TlsV1 ) {
23.3777 ++ if ( encryptionMode == TlsV1 ) {
23.3778 + encryptionMode = Unencrypted;
23.3779 + }
23.3780 + break;
23.3781 + case KTcpSocket::AnySslVersion:
23.3782 +- if ( encryptionMode==AnySslVersion ) {
23.3783 ++ if ( encryptionMode == AnySslVersion ) {
23.3784 + encryptionMode = Unencrypted;
23.3785 + }
23.3786 + break;
23.3787 + }
23.3788 +
23.3789 +- if (encryptionMode == SslV2
23.3790 +- || encryptionMode == SslV3
23.3791 +- || encryptionMode == SslV3_1
23.3792 +- || encryptionMode == AnySslVersion) {
23.3793 ++ if ( encryptionMode == SslV2 ||
23.3794 ++ encryptionMode == SslV3 ||
23.3795 ++ encryptionMode == SslV3_1 ||
23.3796 ++ encryptionMode == AnySslVersion ) {
23.3797 + KTcpSocket::SslVersion version = KTcpSocket::SslV2;
23.3798 +- if (encryptionMode == SslV3)
23.3799 ++ if ( encryptionMode == SslV3 ) {
23.3800 + version = KTcpSocket::SslV3;
23.3801 +- if (encryptionMode == SslV3_1)
23.3802 ++ }
23.3803 ++ if ( encryptionMode == SslV3_1 ) {
23.3804 + version = KTcpSocket::SslV3_1;
23.3805 +- if (encryptionMode == AnySslVersion)
23.3806 ++ }
23.3807 ++ if ( encryptionMode == AnySslVersion ) {
23.3808 + version = KTcpSocket::AnySslVersion;
23.3809 +- d->sessionInternal()->startSsl(version);
23.3810 ++ }
23.3811 ++ d->sessionInternal()->startSsl( version );
23.3812 +
23.3813 +- } else if (encryptionMode == TlsV1) {
23.3814 ++ } else if ( encryptionMode == TlsV1 ) {
23.3815 + d->authState = LoginJobPrivate::StartTls;
23.3816 + d->tags << d->sessionInternal()->sendCommand( "STARTTLS" );
23.3817 +
23.3818 +- } else if (encryptionMode == Unencrypted ) {
23.3819 +- if (d->authMode.isEmpty()) {
23.3820 ++ } else if ( encryptionMode == Unencrypted ) {
23.3821 ++ if ( d->authMode.isEmpty() ) {
23.3822 + d->authState = LoginJobPrivate::Login;
23.3823 ++ kDebug() << "sending LOGIN";
23.3824 + d->tags << d->sessionInternal()->sendCommand( "LOGIN",
23.3825 +- '"'+quoteIMAP( d->userName ).toUtf8()+'"'
23.3826 +- +' '
23.3827 +- +'"'+quoteIMAP(d->password ).toUtf8()+'"' );
23.3828 ++ '"' + quoteIMAP( d->userName ).toUtf8() + '"' +
23.3829 ++ ' ' +
23.3830 ++ '"' + quoteIMAP( d->password ).toUtf8() + '"' );
23.3831 + } else {
23.3832 +- if (!d->startAuthentication()) {
23.3833 ++ if ( !d->startAuthentication() ) {
23.3834 + emitResult();
23.3835 + }
23.3836 + }
23.3837 +@@ -264,17 +269,18 @@ void LoginJob::doStart()
23.3838 +
23.3839 + void LoginJob::handleResponse( const Message &response )
23.3840 + {
23.3841 +- Q_D(LoginJob);
23.3842 ++ Q_D( LoginJob );
23.3843 +
23.3844 +- if ( response.content.isEmpty() )
23.3845 ++ if ( response.content.isEmpty() ) {
23.3846 + return;
23.3847 ++ }
23.3848 +
23.3849 + //set the actual command name for standard responses
23.3850 +- QString commandName = i18n("Login");
23.3851 +- if (d->authState == LoginJobPrivate::Capability) {
23.3852 +- commandName = i18n("Capability");
23.3853 +- } else if (d->authState == LoginJobPrivate::StartTls) {
23.3854 +- commandName = i18n("StartTls");
23.3855 ++ QString commandName = i18n( "Login" );
23.3856 ++ if ( d->authState == LoginJobPrivate::Capability ) {
23.3857 ++ commandName = i18n( "Capability" );
23.3858 ++ } else if ( d->authState == LoginJobPrivate::StartTls ) {
23.3859 ++ commandName = i18n( "StartTls" );
23.3860 + }
23.3861 +
23.3862 + enum ResponseCode {
23.3863 +@@ -286,36 +292,41 @@ void LoginJob::handleResponse( const Message &response )
23.3864 + };
23.3865 +
23.3866 + QByteArray tag = response.content.first().toString();
23.3867 +- ResponseCode code;
23.3868 ++ ResponseCode code = OK;
23.3869 ++
23.3870 ++ kDebug() << commandName << tag;
23.3871 +
23.3872 + if ( tag == "+" ) {
23.3873 + code = CONTINUATION;
23.3874 + } else if ( tag == "*" ) {
23.3875 +- if ( response.content.size() < 2 )
23.3876 ++ if ( response.content.size() < 2 ) {
23.3877 + code = MALFORMED; // Received empty untagged response
23.3878 +- else
23.3879 ++ } else {
23.3880 + code = UNTAGGED;
23.3881 +- } else if ( d->tags.contains(tag) ) {
23.3882 +- if ( response.content.size() < 2 )
23.3883 ++ }
23.3884 ++ } else if ( d->tags.contains( tag ) ) {
23.3885 ++ if ( response.content.size() < 2 ) {
23.3886 + code = MALFORMED;
23.3887 +- else if ( response.content[1].toString() == "OK" )
23.3888 ++ } else if ( response.content[1].toString() == "OK" ) {
23.3889 + code = OK;
23.3890 +- else
23.3891 ++ } else {
23.3892 + code = ERR;
23.3893 ++ }
23.3894 + }
23.3895 +
23.3896 +- switch (code) {
23.3897 ++ switch ( code ) {
23.3898 + case MALFORMED:
23.3899 + // We'll handle it later
23.3900 + break;
23.3901 +
23.3902 + case ERR:
23.3903 + //server replied with NO or BAD for SASL authentication
23.3904 +- if (d->authState == LoginJobPrivate::Authenticate)
23.3905 ++ if ( d->authState == LoginJobPrivate::Authenticate ) {
23.3906 + sasl_dispose( &d->conn );
23.3907 ++ }
23.3908 +
23.3909 + setError( UserDefinedError );
23.3910 +- setErrorText( i18n("%1 failed, server replied: %2", commandName, response.toString().constData()) );
23.3911 ++ setErrorText( i18n( "%1 failed, server replied: %2", commandName, response.toString().constData() ) );
23.3912 + emitResult();
23.3913 + return;
23.3914 +
23.3915 +@@ -323,11 +334,12 @@ void LoginJob::handleResponse( const Message &response )
23.3916 + // The only untagged response interesting for us here is CAPABILITY
23.3917 + if ( response.content[1].toString() == "CAPABILITY" ) {
23.3918 + QList<Message::Part>::const_iterator p = response.content.begin() + 2;
23.3919 +- while (p != response.content.end()) {
23.3920 ++ while ( p != response.content.end() ) {
23.3921 + QString capability = p->toString();
23.3922 + d->capabilities << capability;
23.3923 +- if (capability == "LOGINDISABLED")
23.3924 ++ if ( capability == "LOGINDISABLED" ) {
23.3925 + d->plainLoginDisabled = true;
23.3926 ++ }
23.3927 + ++p;
23.3928 + }
23.3929 + kDebug() << "Capabilities updated: " << d->capabilities;
23.3930 +@@ -335,7 +347,7 @@ void LoginJob::handleResponse( const Message &response )
23.3931 + break;
23.3932 +
23.3933 + case CONTINUATION:
23.3934 +- if (d->authState != LoginJobPrivate::Authenticate) {
23.3935 ++ if ( d->authState != LoginJobPrivate::Authenticate ) {
23.3936 + // Received unexpected continuation response for something
23.3937 + // other than AUTHENTICATE command
23.3938 + code = MALFORMED;
23.3939 +@@ -343,7 +355,7 @@ void LoginJob::handleResponse( const Message &response )
23.3940 + }
23.3941 +
23.3942 + if ( d->authMode == QLatin1String( "PLAIN" ) ) {
23.3943 +- if ( response.content.size()>1 && response.content.at( 1 ).toString()=="OK" ) {
23.3944 ++ if ( response.content.size()>1 && response.content.at( 1 ).toString() == "OK" ) {
23.3945 + return;
23.3946 + }
23.3947 + QByteArray challengeResponse;
23.3948 +@@ -357,7 +369,7 @@ void LoginJob::handleResponse( const Message &response )
23.3949 + challengeResponse = challengeResponse.toBase64();
23.3950 + d->sessionInternal()->sendData( challengeResponse );
23.3951 + } else if ( response.content.size() >= 2 ) {
23.3952 +- if (!d->answerChallenge(QByteArray::fromBase64(response.content[1].toString()))) {
23.3953 ++ if ( !d->answerChallenge( QByteArray::fromBase64( response.content[1].toString() ) ) ) {
23.3954 + emitResult(); //error, we're done
23.3955 + }
23.3956 + } else {
23.3957 +@@ -368,41 +380,41 @@ void LoginJob::handleResponse( const Message &response )
23.3958 +
23.3959 + case OK:
23.3960 +
23.3961 +- switch (d->authState) {
23.3962 ++ switch ( d->authState ) {
23.3963 + case LoginJobPrivate::StartTls:
23.3964 +- d->sessionInternal()->startSsl(KTcpSocket::TlsV1);
23.3965 ++ d->sessionInternal()->startSsl( KTcpSocket::TlsV1 );
23.3966 + break;
23.3967 +
23.3968 + case LoginJobPrivate::Capability:
23.3969 + //cleartext login, if enabled
23.3970 +- if (d->authMode.isEmpty()) {
23.3971 +- if (d->plainLoginDisabled) {
23.3972 ++ if ( d->authMode.isEmpty() ) {
23.3973 ++ if ( d->plainLoginDisabled ) {
23.3974 + setError( UserDefinedError );
23.3975 +- setErrorText( i18n("Login failed, plain login is disabled by the server.") );
23.3976 ++ setErrorText( i18n( "Login failed, plain login is disabled by the server." ) );
23.3977 + emitResult();
23.3978 + } else {
23.3979 + d->authState = LoginJobPrivate::Login;
23.3980 + d->tags << d->sessionInternal()->sendCommand( "LOGIN",
23.3981 +- '"'+quoteIMAP( d->userName ).toUtf8()+'"'
23.3982 +- +' '
23.3983 +- +'"'+quoteIMAP( d->password ).toUtf8()+'"');
23.3984 ++ '"' + quoteIMAP( d->userName ).toUtf8() + '"' +
23.3985 ++ ' ' +
23.3986 ++ '"' + quoteIMAP( d->password ).toUtf8() + '"' );
23.3987 + }
23.3988 + } else {
23.3989 + bool authModeSupported = false;
23.3990 + //find the selected SASL authentication method
23.3991 +- Q_FOREACH(const QString &capability, d->capabilities) {
23.3992 +- if (capability.startsWith(QLatin1String("AUTH="))) {
23.3993 +- if (capability.mid(5) == d->authMode) {
23.3994 ++ Q_FOREACH ( const QString &capability, d->capabilities ) {
23.3995 ++ if ( capability.startsWith( QLatin1String( "AUTH=" ) ) ) {
23.3996 ++ if ( capability.mid( 5 ) == d->authMode ) {
23.3997 + authModeSupported = true;
23.3998 + break;
23.3999 + }
23.4000 + }
23.4001 + }
23.4002 +- if (!authModeSupported) {
23.4003 ++ if ( !authModeSupported ) {
23.4004 + setError( UserDefinedError );
23.4005 +- setErrorText( i18n("Login failed, authentication mode %1 is not supported by the server.", d->authMode) );
23.4006 ++ setErrorText( i18n( "Login failed, authentication mode %1 is not supported by the server.", d->authMode ) );
23.4007 + emitResult();
23.4008 +- } else if (!d->startAuthentication()) {
23.4009 ++ } else if ( !d->startAuthentication() ) {
23.4010 + emitResult(); //problem, we're done
23.4011 + }
23.4012 + }
23.4013 +@@ -421,7 +433,7 @@ void LoginJob::handleResponse( const Message &response )
23.4014 + }
23.4015 +
23.4016 + if ( code == MALFORMED ) {
23.4017 +- setErrorText( i18n("%1 failed, malformed reply from the server.", commandName) );
23.4018 ++ setErrorText( i18n( "%1 failed, malformed reply from the server.", commandName ) );
23.4019 + emitResult();
23.4020 + }
23.4021 + }
23.4022 +@@ -429,9 +441,9 @@ void LoginJob::handleResponse( const Message &response )
23.4023 + bool LoginJobPrivate::startAuthentication()
23.4024 + {
23.4025 + //SASL authentication
23.4026 +- if (!initSASL()) {
23.4027 ++ if ( !initSASL() ) {
23.4028 + q->setError( LoginJob::UserDefinedError );
23.4029 +- q->setErrorText( i18n("Login failed, client cannot initialize the SASL library.") );
23.4030 ++ q->setErrorText( i18n( "Login failed, client cannot initialize the SASL library." ) );
23.4031 + return false;
23.4032 + }
23.4033 +
23.4034 +@@ -442,14 +454,14 @@ bool LoginJobPrivate::startAuthentication()
23.4035 +
23.4036 + int result = sasl_client_new( "imap", m_session->hostName().toLatin1(), 0, 0, callbacks, 0, &conn );
23.4037 + if ( result != SASL_OK ) {
23.4038 +- kDebug() <<"sasl_client_new failed with:" << result;
23.4039 ++ kDebug() << "sasl_client_new failed with:" << result;
23.4040 + q->setError( LoginJob::UserDefinedError );
23.4041 + q->setErrorText( QString::fromUtf8( sasl_errdetail( conn ) ) );
23.4042 + return false;
23.4043 + }
23.4044 +
23.4045 + do {
23.4046 +- result = sasl_client_start(conn, authMode.toLatin1(), &client_interact, capabilities.contains("SASL-IR") ? &out : 0, &outlen, &mechusing);
23.4047 ++ result = sasl_client_start( conn, authMode.toLatin1(), &client_interact, capabilities.contains( "SASL-IR" ) ? &out : 0, &outlen, &mechusing );
23.4048 +
23.4049 + if ( result == SASL_INTERACT ) {
23.4050 + if ( !sasl_interact() ) {
23.4051 +@@ -461,7 +473,7 @@ bool LoginJobPrivate::startAuthentication()
23.4052 + } while ( result == SASL_INTERACT );
23.4053 +
23.4054 + if ( result != SASL_CONTINUE && result != SASL_OK ) {
23.4055 +- kDebug() <<"sasl_client_start failed with:" << result;
23.4056 ++ kDebug() << "sasl_client_start failed with:" << result;
23.4057 + q->setError( LoginJob::UserDefinedError );
23.4058 + q->setErrorText( QString::fromUtf8( sasl_errdetail( conn ) ) );
23.4059 + sasl_dispose( &conn );
23.4060 +@@ -487,12 +499,12 @@ bool LoginJobPrivate::answerChallenge(const QByteArray &data)
23.4061 + const char *out = 0;
23.4062 + uint outlen = 0;
23.4063 + do {
23.4064 +- result = sasl_client_step(conn, challenge.isEmpty() ? 0 : challenge.data(),
23.4065 +- challenge.size(),
23.4066 +- &client_interact,
23.4067 +- &out, &outlen);
23.4068 ++ result = sasl_client_step( conn, challenge.isEmpty() ? 0 : challenge.data(),
23.4069 ++ challenge.size(),
23.4070 ++ &client_interact,
23.4071 ++ &out, &outlen );
23.4072 +
23.4073 +- if (result == SASL_INTERACT) {
23.4074 ++ if ( result == SASL_INTERACT ) {
23.4075 + if ( !sasl_interact() ) {
23.4076 + q->setError( LoginJob::UserDefinedError ); //TODO: check up the actual error
23.4077 + sasl_dispose( &conn );
23.4078 +@@ -502,7 +514,7 @@ bool LoginJobPrivate::answerChallenge(const QByteArray &data)
23.4079 + } while ( result == SASL_INTERACT );
23.4080 +
23.4081 + if ( result != SASL_CONTINUE && result != SASL_OK ) {
23.4082 +- kDebug() <<"sasl_client_step failed with:" << result;
23.4083 ++ kDebug() << "sasl_client_step failed with:" << result;
23.4084 + q->setError( LoginJob::UserDefinedError ); //TODO: check up the actual error
23.4085 + q->setErrorText( QString::fromUtf8( sasl_errdetail( conn ) ) );
23.4086 + sasl_dispose( &conn );
23.4087 +@@ -519,12 +531,12 @@ bool LoginJobPrivate::answerChallenge(const QByteArray &data)
23.4088 +
23.4089 + void LoginJobPrivate::sslResponse(bool response)
23.4090 + {
23.4091 +- if (response) {
23.4092 ++ if ( response ) {
23.4093 + authState = LoginJobPrivate::Capability;
23.4094 + tags << sessionInternal()->sendCommand( "CAPABILITY" );
23.4095 + } else {
23.4096 + q->setError( LoginJob::UserDefinedError );
23.4097 +- q->setErrorText( i18n("Login failed, TLS negotiation failed." ));
23.4098 ++ q->setErrorText( i18n( "Login failed, TLS negotiation failed." ) );
23.4099 + encryptionMode = LoginJob::Unencrypted;
23.4100 + q->emitResult();
23.4101 + }
23.4102 +@@ -532,21 +544,20 @@ void LoginJobPrivate::sslResponse(bool response)
23.4103 +
23.4104 + void LoginJob::setEncryptionMode(EncryptionMode mode)
23.4105 + {
23.4106 +- Q_D(LoginJob);
23.4107 ++ Q_D( LoginJob );
23.4108 + d->encryptionMode = mode;
23.4109 + }
23.4110 +
23.4111 + LoginJob::EncryptionMode LoginJob::encryptionMode()
23.4112 + {
23.4113 +- Q_D(LoginJob);
23.4114 ++ Q_D( LoginJob );
23.4115 + return d->encryptionMode;
23.4116 + }
23.4117 +
23.4118 + void LoginJob::setAuthenticationMode(AuthenticationMode mode)
23.4119 + {
23.4120 +- Q_D(LoginJob);
23.4121 +- switch (mode)
23.4122 +- {
23.4123 ++ Q_D( LoginJob );
23.4124 ++ switch ( mode ) {
23.4125 + case ClearText: d->authMode = "";
23.4126 + break;
23.4127 + case Login: d->authMode = "LOGIN";
23.4128 +@@ -568,13 +579,13 @@ void LoginJob::setAuthenticationMode(AuthenticationMode mode)
23.4129 +
23.4130 + void LoginJob::connectionLost()
23.4131 + {
23.4132 +- Q_D(LoginJob);
23.4133 ++ Q_D( LoginJob );
23.4134 +
23.4135 + //don't emit the result if the connection was lost before getting the tls result, as it can mean
23.4136 + //the TLS handshake failed and the socket was reconnected in normal mode
23.4137 +- if (d->authState != LoginJobPrivate::StartTls) {
23.4138 ++ if ( d->authState != LoginJobPrivate::StartTls ) {
23.4139 + setError( ERR_COULD_NOT_CONNECT );
23.4140 +- setErrorText( i18n("Connection to server lost.") );
23.4141 ++ setErrorText( i18n( "Connection to server lost." ) );
23.4142 + emitResult();
23.4143 + }
23.4144 +
23.4145 +@@ -585,25 +596,26 @@ void LoginJobPrivate::saveServerGreeting(const Message &response)
23.4146 + // Concatenate the parts of the server response into a string, while dropping the first two parts
23.4147 + // (the response tag and the "OK" code), and being careful not to add useless extra whitespace.
23.4148 +
23.4149 +- for ( int i=2; i<response.content.size(); i++) {
23.4150 +- if ( response.content.at(i).type()==Message::Part::List ) {
23.4151 +- serverGreeting+='(';
23.4152 +- foreach ( const QByteArray &item, response.content.at(i).toList() ) {
23.4153 +- serverGreeting+=item+' ';
23.4154 ++ for ( int i = 2; i < response.content.size(); i++ ) {
23.4155 ++ if ( response.content.at( i ).type() == Message::Part::List ) {
23.4156 ++ serverGreeting += '(';
23.4157 ++ foreach ( const QByteArray &item, response.content.at( i ).toList() ) {
23.4158 ++ serverGreeting += item + ' ';
23.4159 + }
23.4160 +- serverGreeting.chop(1);
23.4161 +- serverGreeting+=") ";
23.4162 ++ serverGreeting.chop( 1 );
23.4163 ++ serverGreeting += ") ";
23.4164 + } else {
23.4165 +- serverGreeting+=response.content.at(i).toString()+' ';
23.4166 ++ serverGreeting+=response.content.at( i ).toString() + ' ';
23.4167 + }
23.4168 + }
23.4169 +- serverGreeting.chop(1);
23.4170 ++ serverGreeting.chop( 1 );
23.4171 + }
23.4172 +
23.4173 + QString LoginJob::serverGreeting() const
23.4174 + {
23.4175 +- Q_D(const LoginJob);
23.4176 ++ Q_D( const LoginJob );
23.4177 + return d->serverGreeting;
23.4178 + }
23.4179 +
23.4180 + #include "loginjob.moc"
23.4181 ++
23.4182 +diff --git a/kimap/loginjob.h b/kimap/loginjob.h
23.4183 +index 6064214..2c6040a 100644
23.4184 +--- a/kimap/loginjob.h
23.4185 ++++ b/kimap/loginjob.h
23.4186 +@@ -34,7 +34,7 @@ class LoginJobPrivate;
23.4187 + class KIMAP_EXPORT LoginJob : public Job
23.4188 + {
23.4189 + Q_OBJECT
23.4190 +- Q_DECLARE_PRIVATE(LoginJob)
23.4191 ++ Q_DECLARE_PRIVATE( LoginJob )
23.4192 +
23.4193 + friend class SessionPrivate;
23.4194 +
23.4195 +diff --git a/kimap/logoutjob.cpp b/kimap/logoutjob.cpp
23.4196 +index 9f191dd..5c9bc19 100644
23.4197 +--- a/kimap/logoutjob.cpp
23.4198 ++++ b/kimap/logoutjob.cpp
23.4199 +@@ -19,7 +19,7 @@
23.4200 +
23.4201 + #include "logoutjob.h"
23.4202 +
23.4203 +-#include <klocale.h>
23.4204 ++#include <KDE/KLocalizedString>
23.4205 +
23.4206 + #include "job_p.h"
23.4207 + #include "message_p.h"
23.4208 +@@ -30,7 +30,7 @@ namespace KIMAP
23.4209 + class LogoutJobPrivate : public JobPrivate
23.4210 + {
23.4211 + public:
23.4212 +- LogoutJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { }
23.4213 ++ LogoutJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { }
23.4214 + ~LogoutJobPrivate() { }
23.4215 + };
23.4216 + }
23.4217 +@@ -38,7 +38,7 @@ namespace KIMAP
23.4218 + using namespace KIMAP;
23.4219 +
23.4220 + LogoutJob::LogoutJob( Session *session )
23.4221 +- : Job( *new LogoutJobPrivate(session, i18n("Logout")) )
23.4222 ++ : Job( *new LogoutJobPrivate( session, i18n( "Logout" ) ) )
23.4223 + {
23.4224 + }
23.4225 +
23.4226 +@@ -48,7 +48,7 @@ LogoutJob::~LogoutJob()
23.4227 +
23.4228 + void LogoutJob::doStart()
23.4229 + {
23.4230 +- Q_D(LogoutJob);
23.4231 ++ Q_D( LogoutJob );
23.4232 + d->tags << d->sessionInternal()->sendCommand( "LOGOUT" );
23.4233 + }
23.4234 +
23.4235 +@@ -58,3 +58,4 @@ void LogoutJob::connectionLost()
23.4236 + }
23.4237 +
23.4238 + #include "logoutjob.moc"
23.4239 ++
23.4240 +diff --git a/kimap/logoutjob.h b/kimap/logoutjob.h
23.4241 +index e3f6553..288400f 100644
23.4242 +--- a/kimap/logoutjob.h
23.4243 ++++ b/kimap/logoutjob.h
23.4244 +@@ -32,7 +32,7 @@ class LogoutJobPrivate;
23.4245 + class KIMAP_EXPORT LogoutJob : public Job
23.4246 + {
23.4247 + Q_OBJECT
23.4248 +- Q_DECLARE_PRIVATE(LogoutJob)
23.4249 ++ Q_DECLARE_PRIVATE( LogoutJob )
23.4250 +
23.4251 + friend class SessionPrivate;
23.4252 +
23.4253 +diff --git a/kimap/message_p.h b/kimap/message_p.h
23.4254 +index 9d703bf..e6dd502 100644
23.4255 +--- a/kimap/message_p.h
23.4256 ++++ b/kimap/message_p.h
23.4257 +@@ -34,9 +34,9 @@ struct Message
23.4258 + enum Type { String = 0, List };
23.4259 +
23.4260 + explicit Part(const QByteArray &string)
23.4261 +- : m_type(String), m_string(string) { }
23.4262 ++ : m_type( String ), m_string( string ) { }
23.4263 + explicit Part(const QList<QByteArray> &list)
23.4264 +- : m_type(List), m_list(list) { }
23.4265 ++ : m_type( List ), m_list( list ) { }
23.4266 +
23.4267 + inline Type type() const { return m_type; }
23.4268 + inline QByteArray toString() const { return m_string; }
23.4269 +@@ -53,22 +53,22 @@ struct Message
23.4270 + QByteArray result;
23.4271 +
23.4272 + foreach ( const Part &part, content ) {
23.4273 +- if ( part.type()==Part::List ) {
23.4274 +- result+='(';
23.4275 ++ if ( part.type() == Part::List ) {
23.4276 ++ result += '(';
23.4277 + foreach ( const QByteArray &item, part.toList() ) {
23.4278 +- result+= ' ';
23.4279 +- result+= item;
23.4280 ++ result += ' ';
23.4281 ++ result += item;
23.4282 + }
23.4283 +- result+=" ) ";
23.4284 ++ result += " ) ";
23.4285 + } else {
23.4286 +- result+= part.toString()+' ';
23.4287 ++ result += part.toString() + ' ';
23.4288 + }
23.4289 + }
23.4290 +
23.4291 + if ( !responseCode.isEmpty() ) {
23.4292 + result+="[ ";
23.4293 + foreach ( const Part &part, responseCode ) {
23.4294 +- if ( part.type()==Part::List ) {
23.4295 ++ if ( part.type() == Part::List ) {
23.4296 + result+='(';
23.4297 + foreach ( const QByteArray &item, part.toList() ) {
23.4298 + result+= ' ';
23.4299 +@@ -76,7 +76,7 @@ struct Message
23.4300 + }
23.4301 + result+=" ) ";
23.4302 + } else {
23.4303 +- result+= part.toString()+' ';
23.4304 ++ result+= part.toString() + ' ';
23.4305 + }
23.4306 + }
23.4307 + result+=" ]";
23.4308 +@@ -91,7 +91,7 @@ struct Message
23.4309 +
23.4310 + }
23.4311 +
23.4312 +-Q_DECLARE_METATYPE(KIMAP::Message)
23.4313 ++Q_DECLARE_METATYPE( KIMAP::Message )
23.4314 + static const int _kimap_messageTypeId = qRegisterMetaType<KIMAP::Message>();
23.4315 +
23.4316 + #endif
23.4317 +diff --git a/kimap/metadatajobbase.cpp b/kimap/metadatajobbase.cpp
23.4318 +index fa9dc53..bc7a8d5 100644
23.4319 +--- a/kimap/metadatajobbase.cpp
23.4320 ++++ b/kimap/metadatajobbase.cpp
23.4321 +@@ -22,50 +22,48 @@
23.4322 + #include "message_p.h"
23.4323 + #include "session_p.h"
23.4324 +
23.4325 +-#include <klocale.h>
23.4326 +-#include <kdebug.h>
23.4327 ++#include <KDE/KLocalizedString>
23.4328 ++#include <KDE/KDebug>
23.4329 +
23.4330 + using namespace KIMAP;
23.4331 +
23.4332 + MetaDataJobBase::MetaDataJobBase( Session *session )
23.4333 +- : Job( *new MetaDataJobBasePrivate(session, i18n("MetaDataJobBase")) )
23.4334 ++ : Job( *new MetaDataJobBasePrivate( session, i18n( "MetaDataJobBase" ) ) )
23.4335 + {
23.4336 + }
23.4337 +
23.4338 +-
23.4339 + MetaDataJobBase::MetaDataJobBase( JobPrivate &dd )
23.4340 +- : Job(dd)
23.4341 ++ : Job( dd )
23.4342 + {
23.4343 +-
23.4344 + }
23.4345 +
23.4346 + MetaDataJobBase::~MetaDataJobBase()
23.4347 + {
23.4348 + }
23.4349 +
23.4350 +-
23.4351 + void MetaDataJobBase::setMailBox( const QString &mailBox )
23.4352 + {
23.4353 +- Q_D(MetaDataJobBase);
23.4354 ++ Q_D( MetaDataJobBase );
23.4355 + d->mailBox = mailBox;
23.4356 + }
23.4357 +
23.4358 + QString MetaDataJobBase::mailBox() const
23.4359 + {
23.4360 +- Q_D(const MetaDataJobBase);
23.4361 ++ Q_D( const MetaDataJobBase );
23.4362 + return d->mailBox;
23.4363 + }
23.4364 +
23.4365 + void MetaDataJobBase::setServerCapability(const ServerCapability& capability)
23.4366 + {
23.4367 +- Q_D(MetaDataJobBase);
23.4368 ++ Q_D( MetaDataJobBase );
23.4369 + d->serverCapability = capability;
23.4370 + }
23.4371 +
23.4372 + MetaDataJobBase::ServerCapability MetaDataJobBase::serverCapability() const
23.4373 + {
23.4374 +- Q_D(const MetaDataJobBase);
23.4375 ++ Q_D( const MetaDataJobBase );
23.4376 + return d->serverCapability;
23.4377 + }
23.4378 +
23.4379 + #include "metadatajobbase.moc"
23.4380 ++
23.4381 +diff --git a/kimap/metadatajobbase.h b/kimap/metadatajobbase.h
23.4382 +index f7ad6e2..de46736 100644
23.4383 +--- a/kimap/metadatajobbase.h
23.4384 ++++ b/kimap/metadatajobbase.h
23.4385 +@@ -47,7 +47,7 @@ class MetaDataJobBasePrivate;
23.4386 + class KIMAP_EXPORT MetaDataJobBase : public Job
23.4387 + {
23.4388 + Q_OBJECT
23.4389 +- Q_DECLARE_PRIVATE(MetaDataJobBase)
23.4390 ++ Q_DECLARE_PRIVATE( MetaDataJobBase )
23.4391 +
23.4392 + friend class SessionPrivate;
23.4393 +
23.4394 +diff --git a/kimap/metadatajobbase_p.h b/kimap/metadatajobbase_p.h
23.4395 +index 983a344..140ef20 100644
23.4396 +--- a/kimap/metadatajobbase_p.h
23.4397 ++++ b/kimap/metadatajobbase_p.h
23.4398 +@@ -30,7 +30,7 @@ namespace KIMAP
23.4399 + class MetaDataJobBasePrivate : public JobPrivate
23.4400 + {
23.4401 + public:
23.4402 +- MetaDataJobBasePrivate( Session *session, const QString& name ) : JobPrivate(session, name), serverCapability(MetaDataJobBase::Metadata)
23.4403 ++ MetaDataJobBasePrivate( Session *session, const QString& name ) : JobPrivate( session, name ), serverCapability( MetaDataJobBase::Metadata )
23.4404 + {}
23.4405 +
23.4406 + ~MetaDataJobBasePrivate() { }
23.4407 +diff --git a/kimap/myrightsjob.cpp b/kimap/myrightsjob.cpp
23.4408 +index 46354ae..49790b3 100644
23.4409 +--- a/kimap/myrightsjob.cpp
23.4410 ++++ b/kimap/myrightsjob.cpp
23.4411 +@@ -19,8 +19,8 @@
23.4412 +
23.4413 + #include "myrightsjob.h"
23.4414 +
23.4415 +-#include <klocale.h>
23.4416 +-#include <kdebug.h>
23.4417 ++#include <KDE/KLocalizedString>
23.4418 ++#include <KDE/KDebug>
23.4419 +
23.4420 + #include "acljobbase_p.h"
23.4421 + #include "message_p.h"
23.4422 +@@ -32,7 +32,7 @@ namespace KIMAP
23.4423 + class MyRightsJobPrivate : public AclJobBasePrivate
23.4424 + {
23.4425 + public:
23.4426 +- MyRightsJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate(session, name), myRights(Acl::None) {}
23.4427 ++ MyRightsJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate( session, name ), myRights( Acl::None ) {}
23.4428 + ~MyRightsJobPrivate() { }
23.4429 +
23.4430 + Acl::Rights myRights;
23.4431 +@@ -42,7 +42,7 @@ namespace KIMAP
23.4432 + using namespace KIMAP;
23.4433 +
23.4434 + MyRightsJob::MyRightsJob( Session *session )
23.4435 +- : AclJobBase( *new MyRightsJobPrivate(session, i18n("MyRights") ))
23.4436 ++ : AclJobBase( *new MyRightsJobPrivate( session, i18n( "MyRights" ) ) )
23.4437 + {
23.4438 + }
23.4439 +
23.4440 +@@ -52,18 +52,18 @@ MyRightsJob::~MyRightsJob()
23.4441 +
23.4442 + void MyRightsJob::doStart()
23.4443 + {
23.4444 +- Q_D(MyRightsJob);
23.4445 ++ Q_D( MyRightsJob );
23.4446 +
23.4447 +- d->tags << d->sessionInternal()->sendCommand( "MYRIGHTS", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"');
23.4448 ++ d->tags << d->sessionInternal()->sendCommand( "MYRIGHTS", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"' );
23.4449 + }
23.4450 +
23.4451 + void MyRightsJob::handleResponse( const Message &response )
23.4452 + {
23.4453 +- Q_D(MyRightsJob);
23.4454 ++ Q_D( MyRightsJob );
23.4455 +
23.4456 +- if (handleErrorReplies(response) == NotHandled) {
23.4457 +- if ( response.content.size() == 4
23.4458 +- && response.content[1].toString() == "MYRIGHTS" ) {
23.4459 ++ if ( handleErrorReplies( response ) == NotHandled ) {
23.4460 ++ if ( response.content.size() == 4 &&
23.4461 ++ response.content[1].toString() == "MYRIGHTS" ) {
23.4462 + d->myRights = Acl::rightsFromString( response.content[3].toString() );
23.4463 + }
23.4464 + }
23.4465 +@@ -71,14 +71,15 @@ void MyRightsJob::handleResponse( const Message &response )
23.4466 +
23.4467 + bool MyRightsJob::hasRightEnabled(Acl::Right right)
23.4468 + {
23.4469 +- Q_D(MyRightsJob);
23.4470 ++ Q_D( MyRightsJob );
23.4471 + return d->myRights & right;
23.4472 + }
23.4473 +
23.4474 + Acl::Rights MyRightsJob::rights()
23.4475 + {
23.4476 +- Q_D(MyRightsJob);
23.4477 ++ Q_D( MyRightsJob );
23.4478 + return d->myRights;
23.4479 + }
23.4480 +
23.4481 + #include "myrightsjob.moc"
23.4482 ++
23.4483 +diff --git a/kimap/myrightsjob.h b/kimap/myrightsjob.h
23.4484 +index 4e57d0e..24973d5 100644
23.4485 +--- a/kimap/myrightsjob.h
23.4486 ++++ b/kimap/myrightsjob.h
23.4487 +@@ -56,7 +56,7 @@ class MyRightsJobPrivate;
23.4488 + class KIMAP_EXPORT MyRightsJob : public AclJobBase
23.4489 + {
23.4490 + Q_OBJECT
23.4491 +- Q_DECLARE_PRIVATE(MyRightsJob)
23.4492 ++ Q_DECLARE_PRIVATE( MyRightsJob )
23.4493 +
23.4494 + friend class SessionPrivate;
23.4495 +
23.4496 +diff --git a/kimap/namespacejob.cpp b/kimap/namespacejob.cpp
23.4497 +index 639e55d..47b3930 100644
23.4498 +--- a/kimap/namespacejob.cpp
23.4499 ++++ b/kimap/namespacejob.cpp
23.4500 +@@ -19,8 +19,8 @@
23.4501 +
23.4502 + #include "namespacejob.h"
23.4503 +
23.4504 +-#include <kdebug.h>
23.4505 +-#include <klocale.h>
23.4506 ++#include <KDE/KDebug>
23.4507 ++#include <KDE/KLocalizedString>
23.4508 +
23.4509 + #include "job_p.h"
23.4510 + #include "listjob.h"
23.4511 +@@ -34,7 +34,7 @@ namespace KIMAP
23.4512 + class NamespaceJobPrivate : public JobPrivate
23.4513 + {
23.4514 + public:
23.4515 +- NamespaceJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { }
23.4516 ++ NamespaceJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { }
23.4517 + ~NamespaceJobPrivate() { }
23.4518 +
23.4519 + QList<MailBoxDescriptor> processNamespaceList( const QList<QByteArray> &namespaceList )
23.4520 +@@ -55,7 +55,7 @@ namespace KIMAP
23.4521 + descriptor.separator = QChar( parts[1][0] );
23.4522 +
23.4523 + result << descriptor;
23.4524 +- } catch (KIMAP::ImapParserException e) {
23.4525 ++ } catch ( KIMAP::ImapParserException e ) {
23.4526 + qWarning() << "The stream parser raised an exception during namespace list parsing:" << e.what();
23.4527 + qWarning() << "namespacelist:" << namespaceList;
23.4528 + }
23.4529 +@@ -74,7 +74,7 @@ namespace KIMAP
23.4530 + using namespace KIMAP;
23.4531 +
23.4532 + NamespaceJob::NamespaceJob( Session *session )
23.4533 +- : Job( *new NamespaceJobPrivate(session, i18n("Namespace")) )
23.4534 ++ : Job( *new NamespaceJobPrivate( session, i18n( "Namespace" ) ) )
23.4535 + {
23.4536 + }
23.4537 +
23.4538 +@@ -84,25 +84,25 @@ NamespaceJob::~NamespaceJob()
23.4539 +
23.4540 + QList<MailBoxDescriptor> NamespaceJob::personalNamespaces() const
23.4541 + {
23.4542 +- Q_D(const NamespaceJob);
23.4543 ++ Q_D( const NamespaceJob );
23.4544 + return d->personalNamespaces;
23.4545 + }
23.4546 +
23.4547 + QList<MailBoxDescriptor> NamespaceJob::userNamespaces() const
23.4548 + {
23.4549 +- Q_D(const NamespaceJob);
23.4550 ++ Q_D( const NamespaceJob );
23.4551 + return d->userNamespaces;
23.4552 + }
23.4553 +
23.4554 + QList<MailBoxDescriptor> NamespaceJob::sharedNamespaces() const
23.4555 + {
23.4556 +- Q_D(const NamespaceJob);
23.4557 ++ Q_D( const NamespaceJob );
23.4558 + return d->sharedNamespaces;
23.4559 + }
23.4560 +
23.4561 + bool NamespaceJob::containsEmptyNamespace() const
23.4562 + {
23.4563 +- Q_D(const NamespaceJob);
23.4564 ++ Q_D( const NamespaceJob );
23.4565 + QList<MailBoxDescriptor> completeList = d->personalNamespaces
23.4566 + + d->userNamespaces
23.4567 + + d->sharedNamespaces;
23.4568 +@@ -118,16 +118,16 @@ bool NamespaceJob::containsEmptyNamespace() const
23.4569 +
23.4570 + void NamespaceJob::doStart()
23.4571 + {
23.4572 +- Q_D(NamespaceJob);
23.4573 ++ Q_D( NamespaceJob );
23.4574 + d->tags << d->sessionInternal()->sendCommand( "NAMESPACE" );
23.4575 + }
23.4576 +
23.4577 + void NamespaceJob::handleResponse( const Message &response )
23.4578 + {
23.4579 +- Q_D(NamespaceJob);
23.4580 +- if (handleErrorReplies(response) == NotHandled) {
23.4581 +- if ( response.content.size() >= 5
23.4582 +- && response.content[1].toString()=="NAMESPACE" ) {
23.4583 ++ Q_D( NamespaceJob );
23.4584 ++ if ( handleErrorReplies( response ) == NotHandled ) {
23.4585 ++ if ( response.content.size() >= 5 &&
23.4586 ++ response.content[1].toString() == "NAMESPACE" ) {
23.4587 + // Personal namespaces
23.4588 + d->personalNamespaces = d->processNamespaceList( response.content[2].toList() );
23.4589 +
23.4590 +@@ -141,3 +141,4 @@ void NamespaceJob::handleResponse( const Message &response )
23.4591 + }
23.4592 +
23.4593 + #include "namespacejob.moc"
23.4594 ++
23.4595 +diff --git a/kimap/namespacejob.h b/kimap/namespacejob.h
23.4596 +index 130c788..429d1d8 100644
23.4597 +--- a/kimap/namespacejob.h
23.4598 ++++ b/kimap/namespacejob.h
23.4599 +@@ -34,7 +34,7 @@ class NamespaceJobPrivate;
23.4600 + class KIMAP_EXPORT NamespaceJob : public Job
23.4601 + {
23.4602 + Q_OBJECT
23.4603 +- Q_DECLARE_PRIVATE(NamespaceJob)
23.4604 ++ Q_DECLARE_PRIVATE( NamespaceJob )
23.4605 +
23.4606 + friend class SessionPrivate;
23.4607 +
23.4608 +diff --git a/kimap/quotajobbase.cpp b/kimap/quotajobbase.cpp
23.4609 +index 16737ce..5ae6d56 100644
23.4610 +--- a/kimap/quotajobbase.cpp
23.4611 ++++ b/kimap/quotajobbase.cpp
23.4612 +@@ -22,8 +22,8 @@
23.4613 + #include "message_p.h"
23.4614 + #include "session_p.h"
23.4615 +
23.4616 +-#include <klocale.h>
23.4617 +-#include <kdebug.h>
23.4618 ++#include <KDE/KLocalizedString>
23.4619 ++#include <KDE/KDebug>
23.4620 +
23.4621 + using namespace KIMAP;
23.4622 +
23.4623 +@@ -37,7 +37,7 @@ QMap<QByteArray, QPair<qint64, qint64> > QuotaJobBasePrivate::readQuota( const M
23.4624 + QByteArray resource = quotas[i].toUpper();
23.4625 + qint64 usage = quotas[i+1].toInt();
23.4626 + qint64 limit = quotas[i+2].toInt();
23.4627 +- quotaMap[resource] = qMakePair(usage, limit);
23.4628 ++ quotaMap[resource] = qMakePair( usage, limit );
23.4629 + i += 3;
23.4630 + }
23.4631 +
23.4632 +@@ -45,45 +45,40 @@ QMap<QByteArray, QPair<qint64, qint64> > QuotaJobBasePrivate::readQuota( const M
23.4633 + }
23.4634 +
23.4635 + QuotaJobBase::QuotaJobBase( Session *session )
23.4636 +- : Job( *new QuotaJobBasePrivate(session, i18n("QuotaJobBase")) )
23.4637 ++ : Job( *new QuotaJobBasePrivate( session, i18n( "QuotaJobBase" ) ) )
23.4638 + {
23.4639 + }
23.4640 +
23.4641 +-
23.4642 + QuotaJobBase::QuotaJobBase( JobPrivate &dd )
23.4643 +- : Job(dd)
23.4644 ++ : Job( dd )
23.4645 + {
23.4646 +-
23.4647 + }
23.4648 +
23.4649 + QuotaJobBase::~QuotaJobBase()
23.4650 + {
23.4651 + }
23.4652 +
23.4653 +-
23.4654 + qint64 QuotaJobBase::usage(const QByteArray& resource)
23.4655 + {
23.4656 +- Q_D(QuotaJobBase);
23.4657 ++ Q_D( QuotaJobBase );
23.4658 +
23.4659 + QByteArray r = resource.toUpper();
23.4660 +
23.4661 +- if (d->quota.contains(r)) {
23.4662 ++ if ( d->quota.contains( r ) ) {
23.4663 + return d->quota[r].first;
23.4664 + }
23.4665 +-
23.4666 + return -1;
23.4667 + }
23.4668 +
23.4669 + qint64 QuotaJobBase::limit(const QByteArray& resource)
23.4670 + {
23.4671 +- Q_D(QuotaJobBase);
23.4672 ++ Q_D( QuotaJobBase );
23.4673 +
23.4674 + QByteArray r = resource.toUpper();
23.4675 +
23.4676 +- if (d->quota.contains(r)) {
23.4677 ++ if ( d->quota.contains( r ) ) {
23.4678 + return d->quota[r].second;
23.4679 + }
23.4680 +-
23.4681 + return -1;
23.4682 + }
23.4683 +
23.4684 +diff --git a/kimap/quotajobbase.h b/kimap/quotajobbase.h
23.4685 +index 640ca0d..29b06bb 100644
23.4686 +--- a/kimap/quotajobbase.h
23.4687 ++++ b/kimap/quotajobbase.h
23.4688 +@@ -42,7 +42,7 @@ class QuotaJobBasePrivate;
23.4689 + class KIMAP_EXPORT QuotaJobBase : public Job
23.4690 + {
23.4691 + Q_OBJECT
23.4692 +- Q_DECLARE_PRIVATE(QuotaJobBase)
23.4693 ++ Q_DECLARE_PRIVATE( QuotaJobBase )
23.4694 +
23.4695 + friend class SessionPrivate;
23.4696 +
23.4697 +diff --git a/kimap/quotajobbase_p.h b/kimap/quotajobbase_p.h
23.4698 +index aedc752..dc4313b 100644
23.4699 +--- a/kimap/quotajobbase_p.h
23.4700 ++++ b/kimap/quotajobbase_p.h
23.4701 +@@ -24,12 +24,14 @@
23.4702 + #include "message_p.h"
23.4703 + #include "session.h"
23.4704 +
23.4705 ++#include <QMap>
23.4706 ++
23.4707 + namespace KIMAP
23.4708 + {
23.4709 + class QuotaJobBasePrivate : public JobPrivate
23.4710 + {
23.4711 + public:
23.4712 +- QuotaJobBasePrivate( Session *session, const QString& name ) : JobPrivate(session, name)
23.4713 ++ QuotaJobBasePrivate( Session *session, const QString& name ) : JobPrivate( session, name )
23.4714 + {}
23.4715 +
23.4716 + ~QuotaJobBasePrivate() { }
23.4717 +diff --git a/kimap/renamejob.cpp b/kimap/renamejob.cpp
23.4718 +index 1ec357d..a8c8505 100644
23.4719 +--- a/kimap/renamejob.cpp
23.4720 ++++ b/kimap/renamejob.cpp
23.4721 +@@ -19,8 +19,8 @@
23.4722 +
23.4723 + #include "renamejob.h"
23.4724 +
23.4725 +-#include <klocale.h>
23.4726 +-#include <kdebug.h>
23.4727 ++#include <KDE/KLocalizedString>
23.4728 ++#include <KDE/KDebug>
23.4729 +
23.4730 + #include "job_p.h"
23.4731 + #include "message_p.h"
23.4732 +@@ -32,7 +32,7 @@ namespace KIMAP
23.4733 + class RenameJobPrivate : public JobPrivate
23.4734 + {
23.4735 + public:
23.4736 +- RenameJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { }
23.4737 ++ RenameJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { }
23.4738 + ~RenameJobPrivate() { }
23.4739 +
23.4740 + QString sourceMailBox;
23.4741 +@@ -43,7 +43,7 @@ namespace KIMAP
23.4742 + using namespace KIMAP;
23.4743 +
23.4744 + RenameJob::RenameJob( Session *session )
23.4745 +- : Job( *new RenameJobPrivate(session, i18n("Rename")) )
23.4746 ++ : Job( *new RenameJobPrivate( session, i18n( "Rename" ) ) )
23.4747 + {
23.4748 + }
23.4749 +
23.4750 +@@ -53,33 +53,34 @@ RenameJob::~RenameJob()
23.4751 +
23.4752 + void RenameJob::doStart()
23.4753 + {
23.4754 +- Q_D(RenameJob);
23.4755 +- d->tags << d->sessionInternal()->sendCommand( "RENAME", '\"' + KIMAP::encodeImapFolderName( d->sourceMailBox.toUtf8() ) + "\" \""
23.4756 +- + KIMAP::encodeImapFolderName( d->destinationMailBox.toUtf8() )+ '\"' );
23.4757 ++ Q_D( RenameJob );
23.4758 ++ d->tags << d->sessionInternal()->sendCommand( "RENAME", '\"' + KIMAP::encodeImapFolderName( d->sourceMailBox.toUtf8() ) +
23.4759 ++ "\" \"" + KIMAP::encodeImapFolderName( d->destinationMailBox.toUtf8() ) + '\"' );
23.4760 + }
23.4761 +
23.4762 + void RenameJob::setSourceMailBox( const QString &mailBox )
23.4763 + {
23.4764 +- Q_D(RenameJob);
23.4765 ++ Q_D( RenameJob );
23.4766 + d->sourceMailBox = mailBox;
23.4767 + }
23.4768 +
23.4769 + QString RenameJob::sourceMailBox() const
23.4770 + {
23.4771 +- Q_D(const RenameJob);
23.4772 ++ Q_D( const RenameJob );
23.4773 + return d->sourceMailBox;
23.4774 + }
23.4775 +
23.4776 + void RenameJob::setDestinationMailBox( const QString &mailBox )
23.4777 + {
23.4778 +- Q_D(RenameJob);
23.4779 ++ Q_D( RenameJob );
23.4780 + d->destinationMailBox = mailBox;
23.4781 + }
23.4782 +
23.4783 + QString RenameJob::destinationMailBox() const
23.4784 + {
23.4785 +- Q_D(const RenameJob);
23.4786 ++ Q_D( const RenameJob );
23.4787 + return d->destinationMailBox;
23.4788 + }
23.4789 +
23.4790 + #include "renamejob.moc"
23.4791 ++
23.4792 +diff --git a/kimap/renamejob.h b/kimap/renamejob.h
23.4793 +index 84ae96a..28949f5 100644
23.4794 +--- a/kimap/renamejob.h
23.4795 ++++ b/kimap/renamejob.h
23.4796 +@@ -32,7 +32,7 @@ class RenameJobPrivate;
23.4797 + class KIMAP_EXPORT RenameJob : public Job
23.4798 + {
23.4799 + Q_OBJECT
23.4800 +- Q_DECLARE_PRIVATE(RenameJob)
23.4801 ++ Q_DECLARE_PRIVATE( RenameJob )
23.4802 +
23.4803 + friend class SessionPrivate;
23.4804 +
23.4805 +diff --git a/kimap/rfccodecs.cpp b/kimap/rfccodecs.cpp
23.4806 +index f102514..04cc886 100644
23.4807 +--- a/kimap/rfccodecs.cpp
23.4808 ++++ b/kimap/rfccodecs.cpp
23.4809 +@@ -331,7 +331,7 @@ const QString KIMAP::decodeRFC2047String( const QString &str,
23.4810 + }
23.4811 +
23.4812 + // FIXME get rid of the conversion?
23.4813 +- QByteArray aStr = str.toAscii (); // QString.length() means Unicode chars
23.4814 ++ QByteArray aStr = str.toLatin1 (); // QString.length() means Unicode chars
23.4815 + QByteArray result;
23.4816 + char *pos, *beg, *end, *mid = 0;
23.4817 + QByteArray cstr;
23.4818 +@@ -353,8 +353,9 @@ const QString KIMAP::decodeRFC2047String( const QString &str,
23.4819 + for ( i = 2, pos += 2;
23.4820 + i < maxLen &&
23.4821 + ( *pos != '?' && ( ispunct( *pos ) || isalnum ( *pos ) ) );
23.4822 +- i++ )
23.4823 ++ i++ ) {
23.4824 + pos++;
23.4825 ++ }
23.4826 + if ( *pos != '?' || i < 4 || i >= maxLen ) {
23.4827 + valid = false;
23.4828 + } else {
23.4829 +@@ -376,7 +377,7 @@ const QString KIMAP::decodeRFC2047String( const QString &str,
23.4830 + }
23.4831 + pos += 3;
23.4832 + i += 3;
23.4833 +-// qDebug() << "Charset:" << charset << "- Language:" << language << "-'" << pos << "'";
23.4834 ++// kDebug() << "Charset:" << charset << "- Language:" << language << "-'" << pos << "'";
23.4835 + }
23.4836 + if ( valid ) {
23.4837 + mid = pos;
23.4838 +@@ -401,10 +402,10 @@ const QString KIMAP::decodeRFC2047String( const QString &str,
23.4839 + cstr[i] = ' ';
23.4840 + }
23.4841 + }
23.4842 +-// qDebug() << "before QP '"
23.4843 ++// kDebug() << "before QP '"
23.4844 + // << cstr << "'";
23.4845 + cstr = KCodecs::quotedPrintableDecode( cstr );
23.4846 +-// qDebug() << "after QP '"
23.4847 ++// kDebug() << "after QP '"
23.4848 + // << cstr << "'";
23.4849 + } else {
23.4850 + // decode base64 text
23.4851 +@@ -418,7 +419,7 @@ const QString KIMAP::decodeRFC2047String( const QString &str,
23.4852 +
23.4853 + pos = end - 1;
23.4854 + } else {
23.4855 +-// qDebug() << "invalid";
23.4856 ++// kDebug() << "invalid";
23.4857 + //result += "=?";
23.4858 + //pos = beg -1; // because pos gets increased shortly afterwards
23.4859 + pos = beg - 2;
23.4860 +@@ -427,9 +428,9 @@ const QString KIMAP::decodeRFC2047String( const QString &str,
23.4861 + }
23.4862 + }
23.4863 + if ( !charset.isEmpty () ) {
23.4864 +- QTextCodec *aCodec = codecForName( charset.toAscii () );
23.4865 ++ QTextCodec *aCodec = codecForName( charset.toLatin1 () );
23.4866 + if ( aCodec ) {
23.4867 +-// qDebug() << "Codec is" << aCodec->name();
23.4868 ++// kDebug() << "Codec is" << aCodec->name();
23.4869 + return aCodec->toUnicode( result );
23.4870 + }
23.4871 + }
23.4872 +@@ -636,7 +637,7 @@ const QString KIMAP::decodeRFC2231String( const QString &str )
23.4873 + QString st = str.mid ( l + 1 );
23.4874 + QString language = str.mid ( p + 1, l - p - 1 );
23.4875 +
23.4876 +- //qDebug() << "Charset:" << charset << "Language:" << language;
23.4877 ++ //kDebug() << "Charset:" << charset << "Language:" << language;
23.4878 +
23.4879 + char ch, ch2;
23.4880 + p = 0;
23.4881 +diff --git a/kimap/searchjob.cpp b/kimap/searchjob.cpp
23.4882 +index ede53a3..0e91010 100644
23.4883 +--- a/kimap/searchjob.cpp
23.4884 ++++ b/kimap/searchjob.cpp
23.4885 +@@ -19,8 +19,8 @@
23.4886 +
23.4887 + #include "searchjob.h"
23.4888 +
23.4889 +-#include <klocale.h>
23.4890 +-#include <kdebug.h>
23.4891 ++#include <KDE/KLocalizedString>
23.4892 ++#include <KDE/KDebug>
23.4893 +
23.4894 + #include <QtCore/QDate>
23.4895 +
23.4896 +@@ -35,7 +35,7 @@ namespace KIMAP
23.4897 + class SearchJobPrivate : public JobPrivate
23.4898 + {
23.4899 + public:
23.4900 +- SearchJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name), logic(SearchJob::And) {
23.4901 ++ SearchJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ), logic( SearchJob::And ) {
23.4902 + criteriaMap[SearchJob::All] = "ALL";
23.4903 + criteriaMap[SearchJob::Answered] = "ANSWERED";
23.4904 + criteriaMap[SearchJob::BCC] = "BCC";
23.4905 +@@ -89,7 +89,6 @@ namespace KIMAP
23.4906 + }
23.4907 + ~SearchJobPrivate() { }
23.4908 +
23.4909 +-
23.4910 + QByteArray charset;
23.4911 + QList<QByteArray> criterias;
23.4912 + QMap<SearchJob::SearchCriteria, QByteArray > criteriaMap;
23.4913 +@@ -105,7 +104,7 @@ namespace KIMAP
23.4914 + using namespace KIMAP;
23.4915 +
23.4916 + SearchJob::SearchJob( Session *session )
23.4917 +- : Job( *new SearchJobPrivate(session, i18nc("Name of the search job", "Search")) )
23.4918 ++ : Job( *new SearchJobPrivate( session, i18nc( "Name of the search job", "Search" ) ) )
23.4919 + {
23.4920 + }
23.4921 +
23.4922 +@@ -115,37 +114,41 @@ SearchJob::~SearchJob()
23.4923 +
23.4924 + void SearchJob::doStart()
23.4925 + {
23.4926 +- Q_D(SearchJob);
23.4927 ++ Q_D( SearchJob );
23.4928 +
23.4929 + QByteArray searchKey;
23.4930 +
23.4931 +- if (!d->charset.isEmpty()) {
23.4932 ++ if ( !d->charset.isEmpty() ) {
23.4933 + searchKey = "CHARSET " + d->charset;
23.4934 + }
23.4935 +
23.4936 +- if (d->logic == SearchJob::Not) {
23.4937 +- searchKey += "NOT";
23.4938 +- } else if (d->logic == SearchJob::Or) {
23.4939 +- searchKey += "OR";
23.4940 ++ if ( d->logic == SearchJob::Not ) {
23.4941 ++ searchKey += "NOT ";
23.4942 ++ } else if ( d->logic == SearchJob::Or && d->criterias.size() > 1 ) {
23.4943 ++ searchKey += "OR ";
23.4944 + }
23.4945 +
23.4946 + if ( d->logic == SearchJob::And ) {
23.4947 +- for ( int i = 0; i<d->criterias.size(); i++ ) {
23.4948 ++ for ( int i = 0; i < d->criterias.size(); i++ ) {
23.4949 + const QByteArray key = d->criterias.at( i );
23.4950 +- if ( i>0 ) searchKey+= ' ';
23.4951 ++ if ( i > 0 ) {
23.4952 ++ searchKey += ' ';
23.4953 ++ }
23.4954 + searchKey += key;
23.4955 + }
23.4956 + } else {
23.4957 +- for ( int i = 0; i<d->criterias.size(); i++ ) {
23.4958 ++ for ( int i = 0; i < d->criterias.size(); i++ ) {
23.4959 + const QByteArray key = d->criterias.at( i );
23.4960 +- if ( i>0 ) searchKey+= ' ';
23.4961 ++ if ( i > 0 ) {
23.4962 ++ searchKey += ' ';
23.4963 ++ }
23.4964 + searchKey += '(' + key + ')';
23.4965 + }
23.4966 + }
23.4967 +
23.4968 + QByteArray command = "SEARCH";
23.4969 + if ( d->uidBased ) {
23.4970 +- command = "UID "+ command;
23.4971 ++ command = "UID " + command;
23.4972 + }
23.4973 +
23.4974 + d->tags << d->sessionInternal()->sendCommand( command, searchKey );
23.4975 +@@ -153,44 +156,43 @@ void SearchJob::doStart()
23.4976 +
23.4977 + void SearchJob::handleResponse( const Message &response )
23.4978 + {
23.4979 +- Q_D(SearchJob);
23.4980 ++ Q_D( SearchJob );
23.4981 +
23.4982 +- if (handleErrorReplies(response) == NotHandled ) {
23.4983 ++ if ( handleErrorReplies( response ) == NotHandled ) {
23.4984 + if ( response.content[0].toString() == "+" ) {
23.4985 + d->sessionInternal()->sendData( d->contents[d->nextContent] );
23.4986 + d->nextContent++;
23.4987 + } else if ( response.content[1].toString() == "SEARCH" ) {
23.4988 +- for(int i = 2; i < response.content.size(); i++) {
23.4989 +- d->results.append(response.content[i].toString().toInt());
23.4990 ++ for ( int i = 2; i < response.content.size(); i++ ) {
23.4991 ++ d->results.append( response.content[i].toString().toInt() );
23.4992 + }
23.4993 + }
23.4994 + }
23.4995 + }
23.4996 +
23.4997 +-
23.4998 + void SearchJob::setCharset( const QByteArray &charset )
23.4999 + {
23.5000 +- Q_D(SearchJob);
23.5001 ++ Q_D( SearchJob );
23.5002 + d->charset = charset;
23.5003 + }
23.5004 +
23.5005 + QByteArray SearchJob::charset() const
23.5006 + {
23.5007 +- Q_D(const SearchJob);
23.5008 ++ Q_D( const SearchJob );
23.5009 + return d->charset;
23.5010 + }
23.5011 +
23.5012 + void SearchJob::setSearchLogic( SearchLogic logic )
23.5013 + {
23.5014 +- Q_D(SearchJob);
23.5015 ++ Q_D( SearchJob );
23.5016 + d->logic = logic;
23.5017 + }
23.5018 +
23.5019 + void SearchJob::addSearchCriteria( SearchCriteria criteria )
23.5020 + {
23.5021 +- Q_D(SearchJob);
23.5022 ++ Q_D( SearchJob );
23.5023 +
23.5024 +- switch (criteria) {
23.5025 ++ switch ( criteria ) {
23.5026 + case All:
23.5027 + case Answered:
23.5028 + case Deleted:
23.5029 +@@ -205,36 +207,34 @@ void SearchJob::addSearchCriteria( SearchCriteria criteria )
23.5030 + case Undraft:
23.5031 + case Unflagged:
23.5032 + case Unseen:
23.5033 +- d->criterias.append(d->criteriaMap[criteria]);
23.5034 ++ d->criterias.append( d->criteriaMap[criteria] );
23.5035 + break;
23.5036 + default:
23.5037 + //TODO Discuss if we keep error checking here, or accept anything, even if it is wrong
23.5038 +- qDebug() << "Criteria " << d->criteriaMap[criteria] << " needs an argument, but none was specified.";
23.5039 ++ kDebug() << "Criteria " << d->criteriaMap[criteria] << " needs an argument, but none was specified.";
23.5040 + break;
23.5041 + }
23.5042 + }
23.5043 +
23.5044 +-
23.5045 + void SearchJob::addSearchCriteria( SearchCriteria criteria, int argument )
23.5046 + {
23.5047 +- Q_D(SearchJob);
23.5048 +- switch (criteria) {
23.5049 ++ Q_D( SearchJob );
23.5050 ++ switch ( criteria ) {
23.5051 + case Larger:
23.5052 + case Smaller:
23.5053 +- d->criterias.append(d->criteriaMap[criteria] + ' ' + QByteArray::number(argument));
23.5054 ++ d->criterias.append( d->criteriaMap[criteria] + ' ' + QByteArray::number( argument ) );
23.5055 + break;
23.5056 + default:
23.5057 + //TODO Discuss if we keep error checking here, or accept anything, even if it is wrong
23.5058 +- qDebug() << "Criteria " << d->criteriaMap[criteria] << " doesn't accept an integer as an argument.";
23.5059 ++ kDebug() << "Criteria " << d->criteriaMap[criteria] << " doesn't accept an integer as an argument.";
23.5060 + break;
23.5061 + }
23.5062 + }
23.5063 +
23.5064 +-
23.5065 + void SearchJob::addSearchCriteria( SearchCriteria criteria, const QByteArray &argument )
23.5066 + {
23.5067 +- Q_D(SearchJob);
23.5068 +- switch (criteria) {
23.5069 ++ Q_D( SearchJob );
23.5070 ++ switch ( criteria ) {
23.5071 + case BCC:
23.5072 + case Body:
23.5073 + case CC:
23.5074 +@@ -242,71 +242,71 @@ void SearchJob::addSearchCriteria( SearchCriteria criteria, const QByteArray &ar
23.5075 + case Subject:
23.5076 + case Text:
23.5077 + case To:
23.5078 +- d->contents.append(argument);
23.5079 +- d->criterias.append(d->criteriaMap[criteria] + " {" + QByteArray::number(argument.size()) + '}');
23.5080 ++ d->contents.append( argument );
23.5081 ++ d->criterias.append( d->criteriaMap[criteria] + " {" + QByteArray::number( argument.size() ) + '}' );
23.5082 + break;
23.5083 + case Keyword:
23.5084 + case Unkeyword:
23.5085 + case Header:
23.5086 + case Uid:
23.5087 +- d->criterias.append(d->criteriaMap[criteria] + ' ' + argument);
23.5088 ++ d->criterias.append( d->criteriaMap[criteria] + ' ' + argument );
23.5089 + break;
23.5090 + default:
23.5091 + //TODO Discuss if we keep error checking here, or accept anything, even if it is wrong
23.5092 +- qDebug() << "Criteria " << d->criteriaMap[criteria] << " doesn't accept any argument.";
23.5093 ++ kDebug() << "Criteria " << d->criteriaMap[criteria] << " doesn't accept any argument.";
23.5094 + break;
23.5095 + }
23.5096 + }
23.5097 +
23.5098 + void SearchJob::addSearchCriteria( SearchCriteria criteria, const QDate &argument )
23.5099 + {
23.5100 +- Q_D(SearchJob);
23.5101 +- switch (criteria) {
23.5102 ++ Q_D( SearchJob );
23.5103 ++ switch ( criteria ) {
23.5104 + case Before:
23.5105 + case On:
23.5106 + case SentBefore:
23.5107 + case SentSince:
23.5108 + case Since: {
23.5109 +- QByteArray date = QByteArray::number(argument.day()) + '-';
23.5110 ++ QByteArray date = QByteArray::number( argument.day() ) + '-';
23.5111 + date += d->months[argument.month()] + '-';
23.5112 +- date += QByteArray::number(argument.year());
23.5113 +- d->criterias.append(d->criteriaMap[criteria] + " \"" + date + '\"');
23.5114 ++ date += QByteArray::number( argument.year() );
23.5115 ++ d->criterias.append( d->criteriaMap[criteria] + " \"" + date + '\"' );
23.5116 + break;
23.5117 + }
23.5118 + default:
23.5119 + //TODO Discuss if we keep error checking here, or accept anything, even if it is wrong
23.5120 +- qDebug() << "Criteria " << d->criteriaMap[criteria] << " doesn't accept a date as argument.";
23.5121 ++ kDebug() << "Criteria " << d->criteriaMap[criteria] << " doesn't accept a date as argument.";
23.5122 + break;
23.5123 + }
23.5124 + }
23.5125 +
23.5126 + void SearchJob::addSearchCriteria( const QByteArray &searchCriteria )
23.5127 + {
23.5128 +- Q_D(SearchJob);
23.5129 +- d->criterias.append(searchCriteria);
23.5130 ++ Q_D( SearchJob );
23.5131 ++ d->criterias.append( searchCriteria );
23.5132 + }
23.5133 +
23.5134 + void SearchJob::setUidBased(bool uidBased)
23.5135 + {
23.5136 +- Q_D(SearchJob);
23.5137 ++ Q_D( SearchJob );
23.5138 + d->uidBased = uidBased;
23.5139 + }
23.5140 +
23.5141 + bool SearchJob::isUidBased() const
23.5142 + {
23.5143 +- Q_D(const SearchJob);
23.5144 ++ Q_D( const SearchJob );
23.5145 + return d->uidBased;
23.5146 + }
23.5147 +
23.5148 + QList<qint64> SearchJob::results() const
23.5149 + {
23.5150 +- Q_D(const SearchJob);
23.5151 ++ Q_D( const SearchJob );
23.5152 + return d->results;
23.5153 + }
23.5154 +
23.5155 + QList<int> SearchJob::foundItems()
23.5156 + {
23.5157 +- Q_D(const SearchJob);
23.5158 ++ Q_D( const SearchJob );
23.5159 +
23.5160 + QList<int> results;
23.5161 + qCopy( d->results.begin(), d->results.end(), results.begin() );
23.5162 +@@ -314,4 +314,5 @@ QList<int> SearchJob::foundItems()
23.5163 + return results;
23.5164 + }
23.5165 +
23.5166 +-#include "searchjob.moc"
23.5167 +\ No newline at end of file
23.5168 ++#include "searchjob.moc"
23.5169 ++
23.5170 +diff --git a/kimap/searchjob.h b/kimap/searchjob.h
23.5171 +index 077e8d4..1b53c1e 100644
23.5172 +--- a/kimap/searchjob.h
23.5173 ++++ b/kimap/searchjob.h
23.5174 +@@ -35,7 +35,7 @@ class SearchJobPrivate;
23.5175 + class KIMAP_EXPORT SearchJob : public Job
23.5176 + {
23.5177 + Q_OBJECT
23.5178 +- Q_DECLARE_PRIVATE(SearchJob)
23.5179 ++ Q_DECLARE_PRIVATE( SearchJob )
23.5180 +
23.5181 + friend class SessionPrivate;
23.5182 +
23.5183 +diff --git a/kimap/selectjob.cpp b/kimap/selectjob.cpp
23.5184 +index b18130d..bcc65c6 100644
23.5185 +--- a/kimap/selectjob.cpp
23.5186 ++++ b/kimap/selectjob.cpp
23.5187 +@@ -19,7 +19,8 @@
23.5188 +
23.5189 + #include "selectjob.h"
23.5190 +
23.5191 +-#include <klocale.h>
23.5192 ++#include <KDE/KLocalizedString>
23.5193 ++#include <kdebug.h>
23.5194 +
23.5195 + #include "job_p.h"
23.5196 + #include "message_p.h"
23.5197 +@@ -32,8 +33,8 @@ namespace KIMAP
23.5198 + {
23.5199 + public:
23.5200 + SelectJobPrivate( Session *session, const QString& name )
23.5201 +- : JobPrivate(session, name), readOnly(false), messageCount(-1), recentCount(-1),
23.5202 +- firstUnseenIndex(-1), uidValidity(-1), nextUid(-1) { }
23.5203 ++ : JobPrivate( session, name ), readOnly( false ), messageCount( -1 ), recentCount( -1 ),
23.5204 ++ firstUnseenIndex( -1 ), uidValidity( -1 ), nextUid( -1 ) { }
23.5205 + ~SelectJobPrivate() { }
23.5206 +
23.5207 + QString mailBox;
23.5208 +@@ -52,7 +53,7 @@ namespace KIMAP
23.5209 + using namespace KIMAP;
23.5210 +
23.5211 + SelectJob::SelectJob( Session *session )
23.5212 +- : Job( *new SelectJobPrivate(session, i18nc("name of the select job", "Select")) )
23.5213 ++ : Job( *new SelectJobPrivate( session, i18nc( "name of the select job", "Select" ) ) )
23.5214 + {
23.5215 + }
23.5216 +
23.5217 +@@ -62,73 +63,73 @@ SelectJob::~SelectJob()
23.5218 +
23.5219 + void SelectJob::setMailBox( const QString &mailBox )
23.5220 + {
23.5221 +- Q_D(SelectJob);
23.5222 ++ Q_D( SelectJob );
23.5223 + d->mailBox = mailBox;
23.5224 + }
23.5225 +
23.5226 + QString SelectJob::mailBox() const
23.5227 + {
23.5228 +- Q_D(const SelectJob);
23.5229 ++ Q_D( const SelectJob );
23.5230 + return d->mailBox;
23.5231 + }
23.5232 +
23.5233 + void SelectJob::setOpenReadOnly( bool readOnly )
23.5234 + {
23.5235 +- Q_D(SelectJob);
23.5236 ++ Q_D( SelectJob );
23.5237 + d->readOnly = readOnly;
23.5238 + }
23.5239 +
23.5240 + bool SelectJob::isOpenReadOnly() const
23.5241 + {
23.5242 +- Q_D(const SelectJob);
23.5243 ++ Q_D( const SelectJob );
23.5244 + return d->readOnly;
23.5245 + }
23.5246 +
23.5247 + QList<QByteArray> SelectJob::flags() const
23.5248 + {
23.5249 +- Q_D(const SelectJob);
23.5250 ++ Q_D( const SelectJob );
23.5251 + return d->flags;
23.5252 + }
23.5253 +
23.5254 + QList<QByteArray> SelectJob::permanentFlags() const
23.5255 + {
23.5256 +- Q_D(const SelectJob);
23.5257 ++ Q_D( const SelectJob );
23.5258 + return d->permanentFlags;
23.5259 + }
23.5260 +
23.5261 + int SelectJob::messageCount() const
23.5262 + {
23.5263 +- Q_D(const SelectJob);
23.5264 ++ Q_D( const SelectJob );
23.5265 + return d->messageCount;
23.5266 + }
23.5267 +
23.5268 + int SelectJob::recentCount() const
23.5269 + {
23.5270 +- Q_D(const SelectJob);
23.5271 ++ Q_D( const SelectJob );
23.5272 + return d->recentCount;
23.5273 + }
23.5274 +
23.5275 + int SelectJob::firstUnseenIndex() const
23.5276 + {
23.5277 +- Q_D(const SelectJob);
23.5278 ++ Q_D( const SelectJob );
23.5279 + return d->firstUnseenIndex;
23.5280 + }
23.5281 +
23.5282 + qint64 SelectJob::uidValidity() const
23.5283 + {
23.5284 +- Q_D(const SelectJob);
23.5285 ++ Q_D( const SelectJob );
23.5286 + return d->uidValidity;
23.5287 + }
23.5288 +
23.5289 + qint64 SelectJob::nextUid() const
23.5290 + {
23.5291 +- Q_D(const SelectJob);
23.5292 ++ Q_D( const SelectJob );
23.5293 + return d->nextUid;
23.5294 + }
23.5295 +
23.5296 + void SelectJob::doStart()
23.5297 + {
23.5298 +- Q_D(SelectJob);
23.5299 ++ Q_D( SelectJob );
23.5300 +
23.5301 + QByteArray command = "SELECT";
23.5302 + if ( d->readOnly ) {
23.5303 +@@ -140,56 +141,65 @@ void SelectJob::doStart()
23.5304 +
23.5305 + void SelectJob::handleResponse( const Message &response )
23.5306 + {
23.5307 +- Q_D(SelectJob);
23.5308 ++ Q_D( SelectJob );
23.5309 +
23.5310 +- if ( handleErrorReplies(response) == NotHandled) {
23.5311 ++ if ( handleErrorReplies( response ) == NotHandled ) {
23.5312 + if ( response.content.size() >= 2 ) {
23.5313 + QByteArray code = response.content[1].toString();
23.5314 +
23.5315 +- if ( code=="OK" ) {
23.5316 +- if ( response.responseCode.size() < 2 ) return;
23.5317 ++ if ( code == "OK" ) {
23.5318 ++ if ( response.responseCode.size() < 2 ) {
23.5319 ++ return;
23.5320 ++ }
23.5321 +
23.5322 + code = response.responseCode[0].toString();
23.5323 +
23.5324 +- if ( code=="PERMANENTFLAGS" ) {
23.5325 ++ if ( code == "PERMANENTFLAGS" ) {
23.5326 + d->permanentFlags = response.responseCode[1].toList();
23.5327 + } else {
23.5328 + bool isInt;
23.5329 +
23.5330 +- if ( code=="UIDVALIDITY" ) {
23.5331 +- qint64 value = response.responseCode[1].toString().toLongLong(&isInt);
23.5332 +- if ( !isInt ) return;
23.5333 ++ if ( code == "UIDVALIDITY" ) {
23.5334 ++ qint64 value = response.responseCode[1].toString().toLongLong( &isInt );
23.5335 ++ if ( !isInt ) {
23.5336 ++ return;
23.5337 ++ }
23.5338 + d->uidValidity = value;
23.5339 + } else {
23.5340 +- qint64 value = response.responseCode[1].toString().toLongLong(&isInt);
23.5341 +- if ( !isInt ) return;
23.5342 +- if ( code=="UNSEEN" ) {
23.5343 ++ qint64 value = response.responseCode[1].toString().toLongLong( &isInt );
23.5344 ++ if ( !isInt ) {
23.5345 ++ return;
23.5346 ++ }
23.5347 ++ if ( code == "UNSEEN" ) {
23.5348 + d->firstUnseenIndex = value;
23.5349 +- } else if ( code=="UIDNEXT" ) {
23.5350 ++ } else if ( code == "UIDNEXT" ) {
23.5351 + d->nextUid = value;
23.5352 + }
23.5353 + }
23.5354 + }
23.5355 +- } else if ( code=="FLAGS" ) {
23.5356 ++ } else if ( code == "FLAGS" ) {
23.5357 + d->flags = response.content[2].toList();
23.5358 + } else {
23.5359 + bool isInt;
23.5360 +- int value = response.content[1].toString().toInt(&isInt);
23.5361 +- if ( !isInt || response.content.size()<3 ) return;
23.5362 ++ int value = response.content[1].toString().toInt( &isInt );
23.5363 ++ if ( !isInt || response.content.size() < 3 ) {
23.5364 ++ return;
23.5365 ++ }
23.5366 +
23.5367 + code = response.content[2].toString();
23.5368 +- if ( code=="EXISTS" ) {
23.5369 ++ if ( code == "EXISTS" ) {
23.5370 + d->messageCount = value;
23.5371 +- } else if ( code=="RECENT" ) {
23.5372 ++ } else if ( code == "RECENT" ) {
23.5373 + d->recentCount = value;
23.5374 + }
23.5375 + }
23.5376 + } else {
23.5377 +- qDebug("%s", response.toString().constData());
23.5378 ++ kDebug() << response.toString();
23.5379 + }
23.5380 + } else {
23.5381 + Q_ASSERT( error() || d->m_session->selectedMailBox() == d->mailBox );
23.5382 + }
23.5383 + }
23.5384 +
23.5385 +-#include "selectjob.moc"
23.5386 +\ No newline at end of file
23.5387 ++#include "selectjob.moc"
23.5388 ++
23.5389 +diff --git a/kimap/selectjob.h b/kimap/selectjob.h
23.5390 +index c67d28c..87157b5 100644
23.5391 +--- a/kimap/selectjob.h
23.5392 ++++ b/kimap/selectjob.h
23.5393 +@@ -33,7 +33,7 @@ class SelectJobPrivate;
23.5394 + class KIMAP_EXPORT SelectJob : public Job
23.5395 + {
23.5396 + Q_OBJECT
23.5397 +- Q_DECLARE_PRIVATE(SelectJob)
23.5398 ++ Q_DECLARE_PRIVATE( SelectJob )
23.5399 +
23.5400 + friend class SessionPrivate;
23.5401 +
23.5402 +diff --git a/kimap/session.cpp b/kimap/session.cpp
23.5403 +index 031508b..2b23adc 100644
23.5404 +--- a/kimap/session.cpp
23.5405 ++++ b/kimap/session.cpp
23.5406 +@@ -27,7 +27,8 @@
23.5407 + #include <QtCore/QDebug>
23.5408 + #include <QtCore/QTimer>
23.5409 +
23.5410 +-#include <klocale.h>
23.5411 ++#include <KDebug>
23.5412 ++#include <KDE/KLocalizedString>
23.5413 +
23.5414 + #include "job.h"
23.5415 + #include "loginjob.h"
23.5416 +@@ -36,14 +37,14 @@
23.5417 + #include "sessionthread_p.h"
23.5418 + #include "rfccodecs.h"
23.5419 +
23.5420 +-Q_DECLARE_METATYPE(KTcpSocket::SslVersion)
23.5421 +-Q_DECLARE_METATYPE(QSslSocket::SslMode)
23.5422 ++Q_DECLARE_METATYPE( KTcpSocket::SslVersion )
23.5423 ++Q_DECLARE_METATYPE( QSslSocket::SslMode )
23.5424 + static const int _kimap_sslVersionId = qRegisterMetaType<KTcpSocket::SslVersion>();
23.5425 +
23.5426 + using namespace KIMAP;
23.5427 +
23.5428 + Session::Session( const QString &hostName, quint16 port, QObject *parent)
23.5429 +- : QObject(parent), d(new SessionPrivate(this))
23.5430 ++ : QObject( parent ), d( new SessionPrivate( this ) )
23.5431 + {
23.5432 + if ( !qgetenv( "KIMAP_LOGFILE" ).isEmpty() ) {
23.5433 + d->logger = new SessionLogger;
23.5434 +@@ -53,13 +54,23 @@ Session::Session( const QString &hostName, quint16 port, QObject *parent)
23.5435 + d->state = Disconnected;
23.5436 + d->jobRunning = false;
23.5437 +
23.5438 +- d->thread = new SessionThread(hostName, port, this);
23.5439 +- connect(d->thread, SIGNAL(encryptionNegotiationResult(bool,KTcpSocket::SslVersion)),
23.5440 +- d, SLOT(onEncryptionNegotiationResult(bool,KTcpSocket::SslVersion)));
23.5441 +- connect(d->thread, SIGNAL(sslError(KSslErrorUiData)), this, SLOT(handleSslError(KSslErrorUiData)));
23.5442 ++ d->thread = new SessionThread( hostName, port );
23.5443 ++ connect( d->thread, SIGNAL(encryptionNegotiationResult(bool,KTcpSocket::SslVersion)),
23.5444 ++ d, SLOT(onEncryptionNegotiationResult(bool,KTcpSocket::SslVersion)) );
23.5445 ++ connect( d->thread, SIGNAL(sslError(KSslErrorUiData)),
23.5446 ++ d, SLOT(handleSslError(KSslErrorUiData)) );
23.5447 ++ connect( d->thread, SIGNAL(socketDisconnected()),
23.5448 ++ d, SLOT(socketDisconnected()) );
23.5449 ++ connect( d->thread, SIGNAL(responseReceived(KIMAP::Message)),
23.5450 ++ d, SLOT(responseReceived(KIMAP::Message)) );
23.5451 ++ connect( d->thread, SIGNAL(socketConnected()),
23.5452 ++ d, SLOT(socketConnected()) );
23.5453 ++ connect( d->thread, SIGNAL(socketActivity()),
23.5454 ++ d, SLOT(socketActivity()) );
23.5455 ++ connect( d->thread, SIGNAL(socketError()),
23.5456 ++ d, SLOT(socketError()) );
23.5457 +
23.5458 + d->startSocketTimer();
23.5459 +- d->thread->start();
23.5460 + }
23.5461 +
23.5462 + Session::~Session()
23.5463 +@@ -114,22 +125,19 @@ void KIMAP::Session::close()
23.5464 +
23.5465 + void SessionPrivate::handleSslError(const KSslErrorUiData& errorData)
23.5466 + {
23.5467 +- if (uiProxy && uiProxy->ignoreSslError(errorData)) {
23.5468 +- QMetaObject::invokeMethod( thread, "sslErrorHandlerResponse", Q_ARG(bool, true) );
23.5469 +- } else {
23.5470 +- QMetaObject::invokeMethod( thread, "sslErrorHandlerResponse", Q_ARG(bool, false) );
23.5471 +- }
23.5472 ++ const bool ignoreSslError = uiProxy && uiProxy->ignoreSslError( errorData );
23.5473 ++ thread->sslErrorHandlerResponse(ignoreSslError);
23.5474 + }
23.5475 +
23.5476 + SessionPrivate::SessionPrivate( Session *session )
23.5477 + : QObject( session ),
23.5478 +- q(session),
23.5479 +- state(Session::Disconnected),
23.5480 +- logger(0),
23.5481 +- currentJob(0),
23.5482 +- tagCount(0),
23.5483 +- sslVersion(KTcpSocket::UnknownSslVersion),
23.5484 +- socketTimerInterval(30000) // By default timeouts on 30s
23.5485 ++ q( session ),
23.5486 ++ state( Session::Disconnected ),
23.5487 ++ logger( 0 ),
23.5488 ++ currentJob( 0 ),
23.5489 ++ tagCount( 0 ),
23.5490 ++ sslVersion( KTcpSocket::UnknownSslVersion ),
23.5491 ++ socketTimerInterval( 30000 ) // By default timeouts on 30s
23.5492 + {
23.5493 + }
23.5494 +
23.5495 +@@ -140,20 +148,20 @@ SessionPrivate::~SessionPrivate()
23.5496 +
23.5497 + void SessionPrivate::addJob(Job *job)
23.5498 + {
23.5499 +- queue.append(job);
23.5500 ++ queue.append( job );
23.5501 + emit q->jobQueueSizeChanged( q->jobQueueSize() );
23.5502 +
23.5503 +- QObject::connect( job, SIGNAL(result(KJob*)), q, SLOT(jobDone(KJob*)) );
23.5504 +- QObject::connect( job, SIGNAL(destroyed(QObject*)), q, SLOT(jobDestroyed(QObject*)) );
23.5505 ++ QObject::connect( job, SIGNAL(result(KJob*)), this, SLOT(jobDone(KJob*)) );
23.5506 ++ QObject::connect( job, SIGNAL(destroyed(QObject*)), this, SLOT(jobDestroyed(QObject*)) );
23.5507 +
23.5508 +- if ( state!=Session::Disconnected ) {
23.5509 ++ if ( state != Session::Disconnected ) {
23.5510 + startNext();
23.5511 + }
23.5512 + }
23.5513 +
23.5514 + void SessionPrivate::startNext()
23.5515 + {
23.5516 +- QTimer::singleShot( 0, q, SLOT(doStartNext()) );
23.5517 ++ QMetaObject::invokeMethod( this, "doStartNext" );
23.5518 + }
23.5519 +
23.5520 + void SessionPrivate::doStartNext()
23.5521 +@@ -190,13 +198,14 @@ void SessionPrivate::jobDone( KJob *job )
23.5522 + void SessionPrivate::jobDestroyed( QObject *job )
23.5523 + {
23.5524 + queue.removeAll( static_cast<KIMAP::Job*>( job ) );
23.5525 +- if ( currentJob == job )
23.5526 ++ if ( currentJob == job ) {
23.5527 + currentJob = 0;
23.5528 ++ }
23.5529 + }
23.5530 +
23.5531 + void SessionPrivate::responseReceived( const Message &response )
23.5532 + {
23.5533 +- if ( logger && ( state==Session::Authenticated || state==Session::Selected ) ) {
23.5534 ++ if ( logger && ( state == Session::Authenticated || state == Session::Selected ) ) {
23.5535 + logger->dataReceived( response.toString() );
23.5536 + }
23.5537 +
23.5538 +@@ -213,11 +222,11 @@ void SessionPrivate::responseReceived( const Message &response )
23.5539 +
23.5540 + switch ( state ) {
23.5541 + case Session::Disconnected:
23.5542 +- if (socketTimer.isActive()) {
23.5543 ++ if ( socketTimer.isActive() ) {
23.5544 + stopSocketTimer();
23.5545 + }
23.5546 +- if ( code=="OK" ) {
23.5547 +- setState(Session::NotAuthenticated);
23.5548 ++ if ( code == "OK" ) {
23.5549 ++ setState( Session::NotAuthenticated );
23.5550 +
23.5551 + Message simplified = response;
23.5552 + simplified.content.removeFirst(); // Strip the tag
23.5553 +@@ -225,8 +234,8 @@ void SessionPrivate::responseReceived( const Message &response )
23.5554 + greeting = simplified.toString().trimmed(); // Save the server greeting
23.5555 +
23.5556 + startNext();
23.5557 +- } else if ( code=="PREAUTH" ) {
23.5558 +- setState(Session::Authenticated);
23.5559 ++ } else if ( code == "PREAUTH" ) {
23.5560 ++ setState( Session::Authenticated );
23.5561 +
23.5562 + Message simplified = response;
23.5563 + simplified.content.removeFirst(); // Strip the tag
23.5564 +@@ -239,74 +248,79 @@ void SessionPrivate::responseReceived( const Message &response )
23.5565 + }
23.5566 + return;
23.5567 + case Session::NotAuthenticated:
23.5568 +- if ( code=="OK" && tag==authTag ) {
23.5569 +- setState(Session::Authenticated);
23.5570 ++ if ( code == "OK" && tag == authTag ) {
23.5571 ++ setState( Session::Authenticated );
23.5572 + }
23.5573 + break;
23.5574 + case Session::Authenticated:
23.5575 +- if ( code=="OK" && tag==selectTag ) {
23.5576 +- setState(Session::Selected);
23.5577 ++ if ( code == "OK" && tag == selectTag ) {
23.5578 ++ setState( Session::Selected );
23.5579 + currentMailBox = upcomingMailBox;
23.5580 + }
23.5581 + break;
23.5582 + case Session::Selected:
23.5583 +- if ( ( code=="OK" && tag==closeTag )
23.5584 +- || ( code!="OK" && tag==selectTag) ) {
23.5585 +- setState(Session::Authenticated);
23.5586 ++ if ( ( code == "OK" && tag == closeTag ) ||
23.5587 ++ ( code != "OK" && tag == selectTag ) ) {
23.5588 ++ setState( Session::Authenticated );
23.5589 + currentMailBox = QByteArray();
23.5590 +- } else if ( code=="OK" && tag==selectTag ) {
23.5591 ++ } else if ( code == "OK" && tag == selectTag ) {
23.5592 + currentMailBox = upcomingMailBox;
23.5593 + }
23.5594 + break;
23.5595 + }
23.5596 +
23.5597 +- if (tag==authTag) authTag.clear();
23.5598 +- if (tag==selectTag) selectTag.clear();
23.5599 +- if (tag==closeTag) closeTag.clear();
23.5600 ++ if ( tag == authTag ) {
23.5601 ++ authTag.clear();
23.5602 ++ }
23.5603 ++ if ( tag == selectTag ) {
23.5604 ++ selectTag.clear();
23.5605 ++ }
23.5606 ++ if ( tag == closeTag ) {
23.5607 ++ closeTag.clear();
23.5608 ++ }
23.5609 +
23.5610 + // If a job is running forward it the response
23.5611 +- if ( currentJob!=0 ) {
23.5612 ++ if ( currentJob != 0 ) {
23.5613 + restartSocketTimer();
23.5614 + currentJob->handleResponse( response );
23.5615 + } else {
23.5616 + qWarning() << "A message was received from the server with no job to handle it:"
23.5617 + << response.toString()
23.5618 +- << '('+response.toString().toHex()+')';
23.5619 ++ << '(' + response.toString().toHex() + ')';
23.5620 + }
23.5621 + }
23.5622 +
23.5623 + void SessionPrivate::setState(Session::State s)
23.5624 + {
23.5625 +- if (s != state) {
23.5626 ++ if ( s != state ) {
23.5627 + Session::State oldState = state;
23.5628 + state = s;
23.5629 +- emit q->stateChanged(state, oldState);
23.5630 ++ emit q->stateChanged( state, oldState );
23.5631 + }
23.5632 + }
23.5633 +
23.5634 + QByteArray SessionPrivate::sendCommand( const QByteArray &command, const QByteArray &args )
23.5635 + {
23.5636 +- QByteArray tag = 'A' + QByteArray::number(++tagCount).rightJustified(6, '0');
23.5637 ++ QByteArray tag = 'A' + QByteArray::number( ++tagCount ).rightJustified( 6, '0' );
23.5638 +
23.5639 +- QByteArray payload = tag+' '+command;
23.5640 ++ QByteArray payload = tag + ' ' + command;
23.5641 + if ( !args.isEmpty() ) {
23.5642 +- payload+= ' '+args;
23.5643 ++ payload += ' ' + args;
23.5644 + }
23.5645 +
23.5646 + sendData( payload );
23.5647 +
23.5648 +- if ( command=="LOGIN" || command=="AUTHENTICATE" ) {
23.5649 ++ if ( command == "LOGIN" || command == "AUTHENTICATE" ) {
23.5650 + authTag = tag;
23.5651 +- } else if ( command=="SELECT" || command=="EXAMINE" ) {
23.5652 ++ } else if ( command == "SELECT" || command == "EXAMINE" ) {
23.5653 + selectTag = tag;
23.5654 + upcomingMailBox = args;
23.5655 + upcomingMailBox.remove( 0, 1 );
23.5656 + upcomingMailBox.chop( 1 );
23.5657 + upcomingMailBox = KIMAP::decodeImapFolderName( upcomingMailBox );
23.5658 +- } else if ( command=="CLOSE" ) {
23.5659 ++ } else if ( command == "CLOSE" ) {
23.5660 + closeTag = tag;
23.5661 + }
23.5662 +-
23.5663 + return tag;
23.5664 + }
23.5665 +
23.5666 +@@ -314,11 +328,11 @@ void SessionPrivate::sendData( const QByteArray &data )
23.5667 + {
23.5668 + restartSocketTimer();
23.5669 +
23.5670 +- if ( logger && ( state==Session::Authenticated || state==Session::Selected ) ) {
23.5671 ++ if ( logger && ( state == Session::Authenticated || state == Session::Selected ) ) {
23.5672 + logger->dataSent( data );
23.5673 + }
23.5674 +
23.5675 +- thread->sendData(data+"\r\n");
23.5676 ++ thread->sendData( data + "\r\n" );
23.5677 + }
23.5678 +
23.5679 + void SessionPrivate::socketConnected()
23.5680 +@@ -330,10 +344,10 @@ void SessionPrivate::socketConnected()
23.5681 + if ( !queue.isEmpty() ) {
23.5682 + KIMAP::LoginJob *login = qobject_cast<KIMAP::LoginJob*>( queue.first() );
23.5683 + if ( login ) {
23.5684 +- willUseSsl = ( login->encryptionMode() == KIMAP::LoginJob::SslV2 )
23.5685 +- || ( login->encryptionMode() == KIMAP::LoginJob::SslV3 )
23.5686 +- || ( login->encryptionMode() == KIMAP::LoginJob::SslV3_1 )
23.5687 +- || ( login->encryptionMode() == KIMAP::LoginJob::AnySslVersion );
23.5688 ++ willUseSsl = ( login->encryptionMode() == KIMAP::LoginJob::SslV2 ) ||
23.5689 ++ ( login->encryptionMode() == KIMAP::LoginJob::SslV3 ) ||
23.5690 ++ ( login->encryptionMode() == KIMAP::LoginJob::SslV3_1 ) ||
23.5691 ++ ( login->encryptionMode() == KIMAP::LoginJob::AnySslVersion );
23.5692 +
23.5693 + userName = login->userName();
23.5694 + }
23.5695 +@@ -348,16 +362,16 @@ void SessionPrivate::socketConnected()
23.5696 +
23.5697 + void SessionPrivate::socketDisconnected()
23.5698 + {
23.5699 +- if (socketTimer.isActive()) {
23.5700 ++ if ( socketTimer.isActive() ) {
23.5701 + stopSocketTimer();
23.5702 + }
23.5703 +
23.5704 +- if ( logger && ( state==Session::Authenticated || state==Session::Selected ) ) {
23.5705 ++ if ( logger && ( state == Session::Authenticated || state == Session::Selected ) ) {
23.5706 + logger->disconnectionOccured();
23.5707 + }
23.5708 +
23.5709 + if ( state != Session::Disconnected ) {
23.5710 +- setState(Session::Disconnected);
23.5711 ++ setState( Session::Disconnected );
23.5712 + emit q->connectionLost();
23.5713 + } else {
23.5714 + emit q->connectionFailed();
23.5715 +@@ -375,7 +389,7 @@ void SessionPrivate::socketActivity()
23.5716 +
23.5717 + void SessionPrivate::socketError()
23.5718 + {
23.5719 +- if (socketTimer.isActive()) {
23.5720 ++ if ( socketTimer.isActive() ) {
23.5721 + stopSocketTimer();
23.5722 + }
23.5723 +
23.5724 +@@ -397,14 +411,15 @@ void SessionPrivate::clearJobQueue()
23.5725 + currentJob->connectionLost();
23.5726 + }
23.5727 +
23.5728 +- qDeleteAll(queue);
23.5729 ++ QQueue<Job*> queueCopy = queue; // copy because jobDestroyed calls removeAll
23.5730 ++ qDeleteAll(queueCopy);
23.5731 + queue.clear();
23.5732 + emit q->jobQueueSizeChanged( 0 );
23.5733 + }
23.5734 +
23.5735 + void SessionPrivate::startSsl(const KTcpSocket::SslVersion &version)
23.5736 + {
23.5737 +- QMetaObject::invokeMethod( thread, "startSsl", Qt::QueuedConnection, Q_ARG(KTcpSocket::SslVersion, version) );
23.5738 ++ thread->startSsl( version );
23.5739 + }
23.5740 +
23.5741 + QString Session::selectedMailBox() const
23.5742 +@@ -449,7 +464,7 @@ int SessionPrivate::socketTimeout() const
23.5743 +
23.5744 + void SessionPrivate::startSocketTimer()
23.5745 + {
23.5746 +- if ( socketTimerInterval<0 ) {
23.5747 ++ if ( socketTimerInterval < 0 ) {
23.5748 + return;
23.5749 + }
23.5750 + Q_ASSERT( !socketTimer.isActive() );
23.5751 +@@ -463,7 +478,7 @@ void SessionPrivate::startSocketTimer()
23.5752 +
23.5753 + void SessionPrivate::stopSocketTimer()
23.5754 + {
23.5755 +- if ( socketTimerInterval<0 ) {
23.5756 ++ if ( socketTimerInterval < 0 ) {
23.5757 + return;
23.5758 + }
23.5759 +
23.5760 +@@ -483,7 +498,7 @@ void SessionPrivate::restartSocketTimer()
23.5761 +
23.5762 + void SessionPrivate::onSocketTimeout()
23.5763 + {
23.5764 +- qDebug() << "Socket timeout!";
23.5765 ++ kDebug() << "Socket timeout!";
23.5766 + thread->closeSocket();
23.5767 + }
23.5768 +
23.5769 +@@ -494,3 +509,4 @@ void Session::setTimeout( int timeout )
23.5770 +
23.5771 + #include "session.moc"
23.5772 + #include "session_p.moc"
23.5773 ++
23.5774 +diff --git a/kimap/session.h b/kimap/session.h
23.5775 +index e23fbc4..b745246 100644
23.5776 +--- a/kimap/session.h
23.5777 ++++ b/kimap/session.h
23.5778 +@@ -37,7 +37,7 @@ struct Message;
23.5779 + class KIMAP_EXPORT Session : public QObject
23.5780 + {
23.5781 + Q_OBJECT
23.5782 +- Q_ENUMS(State)
23.5783 ++ Q_ENUMS( State )
23.5784 +
23.5785 + friend class JobPrivate;
23.5786 +
23.5787 +@@ -135,18 +135,6 @@ class KIMAP_EXPORT Session : public QObject
23.5788 + void stateChanged(KIMAP::Session::State newState, KIMAP::Session::State oldState);
23.5789 +
23.5790 + private:
23.5791 +- Q_PRIVATE_SLOT( d, void doStartNext() )
23.5792 +- Q_PRIVATE_SLOT( d, void jobDone( KJob* ) )
23.5793 +- Q_PRIVATE_SLOT( d, void jobDestroyed( QObject* ) )
23.5794 +- Q_PRIVATE_SLOT( d, void responseReceived( const KIMAP::Message& ) )
23.5795 +-
23.5796 +- Q_PRIVATE_SLOT( d, void socketConnected() )
23.5797 +- Q_PRIVATE_SLOT( d, void socketDisconnected() )
23.5798 +- Q_PRIVATE_SLOT( d, void socketError() )
23.5799 +- Q_PRIVATE_SLOT( d, void socketActivity() )
23.5800 +-
23.5801 +- Q_PRIVATE_SLOT( d, void handleSslError( const KSslErrorUiData &errorData ) )
23.5802 +-
23.5803 + friend class SessionPrivate;
23.5804 + SessionPrivate *const d;
23.5805 + };
23.5806 +diff --git a/kimap/session_p.h b/kimap/session_p.h
23.5807 +index 37bfd57..fd5101b 100644
23.5808 +--- a/kimap/session_p.h
23.5809 ++++ b/kimap/session_p.h
23.5810 +@@ -46,7 +46,7 @@ class KIMAP_EXPORT SessionPrivate : public QObject
23.5811 + friend class Session;
23.5812 +
23.5813 + public:
23.5814 +- SessionPrivate( Session *session );
23.5815 ++ explicit SessionPrivate( Session *session );
23.5816 + virtual ~SessionPrivate();
23.5817 +
23.5818 + void addJob(Job *job);
23.5819 +@@ -54,8 +54,6 @@ class KIMAP_EXPORT SessionPrivate : public QObject
23.5820 + void startSsl(const KTcpSocket::SslVersion &version);
23.5821 + void sendData( const QByteArray &data );
23.5822 +
23.5823 +- void handleSslError( const KSslErrorUiData &errorData );
23.5824 +-
23.5825 + KTcpSocket::SslVersion negotiatedEncryption() const;
23.5826 +
23.5827 + void setSocketTimeout( int ms );
23.5828 +@@ -68,20 +66,23 @@ class KIMAP_EXPORT SessionPrivate : public QObject
23.5829 + void onEncryptionNegotiationResult(bool isEncrypted, KTcpSocket::SslVersion sslVersion);
23.5830 + void onSocketTimeout();
23.5831 +
23.5832 +- private:
23.5833 +- void startNext();
23.5834 + void doStartNext();
23.5835 +- void jobDone( KJob *job );
23.5836 +- void jobDestroyed( QObject *job );
23.5837 +- void clearJobQueue();
23.5838 +- void responseReceived( const KIMAP::Message &response );
23.5839 +- void setState(Session::State state);
23.5840 ++ void jobDone( KJob* );
23.5841 ++ void jobDestroyed( QObject* );
23.5842 ++ void responseReceived( const KIMAP::Message& );
23.5843 +
23.5844 + void socketConnected();
23.5845 + void socketDisconnected();
23.5846 + void socketError();
23.5847 + void socketActivity();
23.5848 +
23.5849 ++ void handleSslError( const KSslErrorUiData &errorData );
23.5850 ++
23.5851 ++ private:
23.5852 ++ void startNext();
23.5853 ++ void clearJobQueue();
23.5854 ++ void setState(Session::State state);
23.5855 ++
23.5856 + void startSocketTimer();
23.5857 + void stopSocketTimer();
23.5858 + void restartSocketTimer();
23.5859 +diff --git a/kimap/sessionlogger.cpp b/kimap/sessionlogger.cpp
23.5860 +index 715a5da..2c4bd07 100644
23.5861 +--- a/kimap/sessionlogger.cpp
23.5862 ++++ b/kimap/sessionlogger.cpp
23.5863 +@@ -20,6 +20,8 @@
23.5864 +
23.5865 + #include "sessionlogger_p.h"
23.5866 +
23.5867 ++#include <KDebug>
23.5868 ++
23.5869 + #include <unistd.h>
23.5870 +
23.5871 + using namespace KIMAP;
23.5872 +@@ -33,7 +35,9 @@ SessionLogger::SessionLogger()
23.5873 + m_file.setFileName( qgetenv( "KIMAP_LOGFILE" )
23.5874 + + '.' + QString::number( getpid() )
23.5875 + + '.' + QString::number( m_id ) );
23.5876 +- m_file.open( QFile::WriteOnly );
23.5877 ++ if (!m_file.open( QFile::WriteOnly )) {
23.5878 ++ kDebug()<<" m_file can be open in write only";
23.5879 ++ }
23.5880 + }
23.5881 +
23.5882 + SessionLogger::~SessionLogger()
23.5883 +@@ -57,6 +61,3 @@ void SessionLogger::disconnectionOccured()
23.5884 + {
23.5885 + m_file.write( "X\n" );
23.5886 + }
23.5887 +-
23.5888 +-
23.5889 +-
23.5890 +diff --git a/kimap/sessionthread.cpp b/kimap/sessionthread.cpp
23.5891 +index b7a1cb9..36e2c83 100644
23.5892 +--- a/kimap/sessionthread.cpp
23.5893 ++++ b/kimap/sessionthread.cpp
23.5894 +@@ -20,65 +20,73 @@
23.5895 + #include "sessionthread_p.h"
23.5896 +
23.5897 + #include <QtCore/QDebug>
23.5898 +-#include <QtCore/QTimer>
23.5899 ++#include <QtCore/QThread>
23.5900 +
23.5901 +-#include <kdebug.h>
23.5902 ++#include <KDE/KDebug>
23.5903 +
23.5904 + #include "imapstreamparser.h"
23.5905 + #include "message_p.h"
23.5906 +-#include "session.h"
23.5907 +
23.5908 + using namespace KIMAP;
23.5909 +
23.5910 +-Q_DECLARE_METATYPE(KTcpSocket::Error)
23.5911 +-Q_DECLARE_METATYPE(KSslErrorUiData)
23.5912 ++Q_DECLARE_METATYPE( KTcpSocket::Error )
23.5913 ++Q_DECLARE_METATYPE( KSslErrorUiData )
23.5914 + static const int _kimap_socketErrorTypeId = qRegisterMetaType<KTcpSocket::Error>();
23.5915 + static const int _kimap_sslErrorUiData = qRegisterMetaType<KSslErrorUiData>();
23.5916 +
23.5917 +-SessionThread::SessionThread( const QString &hostName, quint16 port, Session *parent )
23.5918 +- : QThread(), m_hostName(hostName), m_port(port),
23.5919 +- m_session(parent), m_socket(0), m_stream(0), m_encryptedMode(false)
23.5920 ++SessionThread::SessionThread( const QString &hostName, quint16 port )
23.5921 ++ : QObject(), m_hostName( hostName ), m_port( port ),
23.5922 ++ m_socket( 0 ), m_stream( 0 ), m_mutex(),
23.5923 ++ m_encryptedMode( false ),
23.5924 ++ triedSslVersions( 0 ), doSslFallback( false )
23.5925 + {
23.5926 +- // Yeah, sounds weird, but QThread object is linked to the parent
23.5927 +- // thread not to itself, and I'm too lazy to introduce yet another
23.5928 +- // internal QObject
23.5929 +- moveToThread(this);
23.5930 ++ // Just like the Qt docs now recommend, for event-driven threads:
23.5931 ++ // don't derive from QThread, create one directly and move the object to it.
23.5932 ++ QThread* thread = new QThread();
23.5933 ++ moveToThread( thread );
23.5934 ++ thread->start();
23.5935 ++ QMetaObject::invokeMethod( this, "threadInit" );
23.5936 + }
23.5937 +
23.5938 + SessionThread::~SessionThread()
23.5939 + {
23.5940 +- // don't call quit() directly, this will deadlock in wait() if exec() hasn't run yet
23.5941 +- QMetaObject::invokeMethod( this, "quit" );
23.5942 +- if ( !wait( 10 * 1000 ) ) {
23.5943 ++ QMetaObject::invokeMethod( this, "threadQuit" );
23.5944 ++ if ( !thread()->wait( 10 * 1000 ) ) {
23.5945 + kWarning() << "Session thread refuses to die, killing harder...";
23.5946 +- terminate();
23.5947 ++ thread()->terminate();
23.5948 + // Make sure to wait until it's done, otherwise it can crash when the pthread callback is called
23.5949 +- wait();
23.5950 ++ thread()->wait();
23.5951 + }
23.5952 ++ delete thread();
23.5953 + }
23.5954 +
23.5955 ++// Called in primary thread
23.5956 + void SessionThread::sendData( const QByteArray &payload )
23.5957 + {
23.5958 +- QMutexLocker locker(&m_mutex);
23.5959 ++ QMutexLocker locker( &m_mutex );
23.5960 +
23.5961 + m_dataQueue.enqueue( payload );
23.5962 +- QTimer::singleShot( 0, this, SLOT(writeDataQueue()) );
23.5963 ++ QMetaObject::invokeMethod( this, "writeDataQueue" );
23.5964 + }
23.5965 +
23.5966 ++// Called in secondary thread
23.5967 + void SessionThread::writeDataQueue()
23.5968 + {
23.5969 +- QMutexLocker locker(&m_mutex);
23.5970 ++ Q_ASSERT( QThread::currentThread() == thread() );
23.5971 ++ if ( !m_socket )
23.5972 ++ return;
23.5973 ++ QMutexLocker locker( &m_mutex );
23.5974 +
23.5975 + while ( !m_dataQueue.isEmpty() ) {
23.5976 + m_socket->write( m_dataQueue.dequeue() );
23.5977 + }
23.5978 + }
23.5979 +
23.5980 ++// Called in secondary thread
23.5981 + void SessionThread::readMessage()
23.5982 + {
23.5983 +- QMutexLocker locker(&m_mutex);
23.5984 +-
23.5985 +- if ( m_stream->availableDataSize()==0 ) {
23.5986 ++ Q_ASSERT( QThread::currentThread() == thread() );
23.5987 ++ if ( !m_stream || m_stream->availableDataSize() == 0 ) {
23.5988 + return;
23.5989 + }
23.5990 +
23.5991 +@@ -92,10 +100,10 @@ void SessionThread::readMessage()
23.5992 + if ( string == "NIL" ) {
23.5993 + *payload << Message::Part( QList<QByteArray>() );
23.5994 + } else {
23.5995 +- *payload << Message::Part(string);
23.5996 ++ *payload << Message::Part( string );
23.5997 + }
23.5998 + } else if ( m_stream->hasList() ) {
23.5999 +- *payload << Message::Part(m_stream->readParenthesizedList());
23.6000 ++ *payload << Message::Part( m_stream->readParenthesizedList() );
23.6001 + } else if ( m_stream->hasResponseCode() ) {
23.6002 + payload = &message.responseCode;
23.6003 + } else if ( m_stream->atResponseCodeEnd() ) {
23.6004 +@@ -103,128 +111,213 @@ void SessionThread::readMessage()
23.6005 + } else if ( m_stream->hasLiteral() ) {
23.6006 + QByteArray literal;
23.6007 + while ( !m_stream->atLiteralEnd() ) {
23.6008 +- literal+= m_stream->readLiteralPart();
23.6009 ++ literal += m_stream->readLiteralPart();
23.6010 + }
23.6011 +- *payload << Message::Part(literal);
23.6012 ++ *payload << Message::Part( literal );
23.6013 + } else {
23.6014 +- // Oops! Something really bad happened
23.6015 +- throw ImapParserException( "Inconsistent state, probably due to some packet loss" );
23.6016 ++ // Oops! Something really bad happened, we won't be able to recover
23.6017 ++ // so close the socket immediately
23.6018 ++ qWarning( "Inconsistent state, probably due to some packet loss" );
23.6019 ++ doCloseSocket();
23.6020 ++ return;
23.6021 + }
23.6022 + }
23.6023 +
23.6024 +- emit responseReceived(message);
23.6025 ++ emit responseReceived( message );
23.6026 +
23.6027 +- } catch (KIMAP::ImapParserException e) {
23.6028 ++ } catch ( KIMAP::ImapParserException e ) {
23.6029 + qWarning() << "The stream parser raised an exception:" << e.what();
23.6030 + }
23.6031 +
23.6032 +- if ( m_stream->availableDataSize()>1 ) {
23.6033 +- QTimer::singleShot( 0, this, SLOT(readMessage()) );
23.6034 ++ if ( m_stream->availableDataSize() > 1 ) {
23.6035 ++ QMetaObject::invokeMethod( this, "readMessage", Qt::QueuedConnection );
23.6036 + }
23.6037 +
23.6038 + }
23.6039 +
23.6040 ++// Called in main thread
23.6041 + void SessionThread::closeSocket()
23.6042 + {
23.6043 +- QTimer::singleShot( 0, this, SLOT(doCloseSocket()) );
23.6044 ++ QMetaObject::invokeMethod( this, "doCloseSocket", Qt::QueuedConnection );
23.6045 + }
23.6046 +
23.6047 ++// Called in secondary thread
23.6048 + void SessionThread::doCloseSocket()
23.6049 + {
23.6050 ++ Q_ASSERT( QThread::currentThread() == thread() );
23.6051 ++ if ( !m_socket )
23.6052 ++ return;
23.6053 + m_encryptedMode = false;
23.6054 ++ kDebug() << "close";
23.6055 + m_socket->close();
23.6056 + }
23.6057 +
23.6058 ++// Called in secondary thread
23.6059 + void SessionThread::reconnect()
23.6060 + {
23.6061 +- QMutexLocker locker(&m_mutex);
23.6062 +-
23.6063 ++ Q_ASSERT( QThread::currentThread() == thread() );
23.6064 ++ if ( m_socket == 0 ) // threadQuit already called
23.6065 ++ return;
23.6066 + if ( m_socket->state() != SessionSocket::ConnectedState &&
23.6067 + m_socket->state() != SessionSocket::ConnectingState ) {
23.6068 +- if (m_encryptedMode) {
23.6069 +- m_socket->connectToHostEncrypted(m_hostName, m_port);
23.6070 ++ if ( m_encryptedMode ) {
23.6071 ++ kDebug() << "connectToHostEncrypted" << m_hostName << m_port;
23.6072 ++ m_socket->connectToHostEncrypted( m_hostName, m_port );
23.6073 + } else {
23.6074 +- m_socket->connectToHost(m_hostName, m_port);
23.6075 ++ kDebug() << "connectToHost" << m_hostName << m_port;
23.6076 ++ m_socket->connectToHost( m_hostName, m_port );
23.6077 + }
23.6078 + }
23.6079 + }
23.6080 +
23.6081 +-void SessionThread::run()
23.6082 ++// Called in secondary thread
23.6083 ++void SessionThread::threadInit()
23.6084 + {
23.6085 ++ Q_ASSERT( QThread::currentThread() == thread() );
23.6086 + m_socket = new SessionSocket;
23.6087 + m_stream = new ImapStreamParser( m_socket );
23.6088 + connect( m_socket, SIGNAL(readyRead()),
23.6089 + this, SLOT(readMessage()), Qt::QueuedConnection );
23.6090 +
23.6091 ++ // Delay the call to slotSocketDisconnected so that it finishes disconnecting before we call reconnect()
23.6092 + connect( m_socket, SIGNAL(disconnected()),
23.6093 +- m_session, SLOT(socketDisconnected()) );
23.6094 ++ this, SLOT(slotSocketDisconnected()), Qt::QueuedConnection );
23.6095 + connect( m_socket, SIGNAL(connected()),
23.6096 +- m_session, SLOT(socketConnected()) );
23.6097 ++ this, SIGNAL(socketConnected()) );
23.6098 + connect( m_socket, SIGNAL(error(KTcpSocket::Error)),
23.6099 +- m_session, SLOT(socketError()) );
23.6100 ++ this, SLOT(socketError(KTcpSocket::Error)) );
23.6101 + connect( m_socket, SIGNAL(bytesWritten(qint64)),
23.6102 +- m_session, SLOT(socketActivity()) );
23.6103 +- if ( m_socket->metaObject()->indexOfSignal("encryptedBytesWritten(qint64)" ) > -1 ) {
23.6104 ++ this, SIGNAL(socketActivity()) );
23.6105 ++ if ( m_socket->metaObject()->indexOfSignal( "encryptedBytesWritten(qint64)" ) > -1 ) {
23.6106 + connect( m_socket, SIGNAL(encryptedBytesWritten(qint64)), // needs kdelibs > 4.8
23.6107 +- m_session, SLOT(socketActivity()) );
23.6108 ++ this, SIGNAL(socketActivity()) );
23.6109 + }
23.6110 + connect( m_socket, SIGNAL(readyRead()),
23.6111 +- m_session, SLOT(socketActivity()) );
23.6112 +-
23.6113 +- connect( this, SIGNAL(responseReceived(KIMAP::Message)),
23.6114 +- m_session, SLOT(responseReceived(KIMAP::Message)) );
23.6115 ++ this, SIGNAL(socketActivity()) );
23.6116 +
23.6117 +- QTimer::singleShot( 0, this, SLOT(reconnect()) );
23.6118 +- exec();
23.6119 ++ QMetaObject::invokeMethod(this, "reconnect", Qt::QueuedConnection);
23.6120 ++}
23.6121 +
23.6122 ++// Called in secondary thread
23.6123 ++void SessionThread::threadQuit()
23.6124 ++{
23.6125 ++ Q_ASSERT( QThread::currentThread() == thread() );
23.6126 + delete m_stream;
23.6127 ++ m_stream = 0;
23.6128 + delete m_socket;
23.6129 ++ m_socket = 0;
23.6130 ++ thread()->quit();
23.6131 + }
23.6132 +
23.6133 +-void SessionThread::startSsl(const KTcpSocket::SslVersion &version)
23.6134 ++// Called in primary thread
23.6135 ++void SessionThread::startSsl( KTcpSocket::SslVersion version )
23.6136 + {
23.6137 +- QMutexLocker locker(&m_mutex);
23.6138 ++ QMetaObject::invokeMethod( this, "doStartSsl", Q_ARG(KTcpSocket::SslVersion, version) );
23.6139 ++}
23.6140 ++
23.6141 ++// Called in secondary thread (via invokeMethod)
23.6142 ++void SessionThread::doStartSsl( KTcpSocket::SslVersion version )
23.6143 ++{
23.6144 ++ Q_ASSERT( QThread::currentThread() == thread() );
23.6145 ++ if ( !m_socket )
23.6146 ++ return;
23.6147 ++ if ( version == KTcpSocket::AnySslVersion ) {
23.6148 ++ doSslFallback = true;
23.6149 ++ if ( m_socket->advertisedSslVersion() == KTcpSocket::UnknownSslVersion ) {
23.6150 ++ m_socket->setAdvertisedSslVersion( KTcpSocket::AnySslVersion );
23.6151 ++ } else if ( !( triedSslVersions & KTcpSocket::TlsV1 ) ) {
23.6152 ++ triedSslVersions |= KTcpSocket::TlsV1;
23.6153 ++ m_socket->setAdvertisedSslVersion( KTcpSocket::TlsV1 );
23.6154 ++ } else if ( !( triedSslVersions & KTcpSocket::SslV3 ) ) {
23.6155 ++ triedSslVersions |= KTcpSocket::SslV3;
23.6156 ++ m_socket->setAdvertisedSslVersion( KTcpSocket::SslV3 );
23.6157 ++ } else if ( !( triedSslVersions & KTcpSocket::SslV2 ) ) {
23.6158 ++ triedSslVersions |= KTcpSocket::SslV2;
23.6159 ++ m_socket->setAdvertisedSslVersion( KTcpSocket::SslV2 );
23.6160 ++ doSslFallback = false;
23.6161 ++ }
23.6162 ++ } else {
23.6163 ++ m_socket->setAdvertisedSslVersion( version );
23.6164 ++ }
23.6165 +
23.6166 +- m_socket->setAdvertisedSslVersion(version);
23.6167 + m_socket->ignoreSslErrors();
23.6168 +- connect(m_socket, SIGNAL(encrypted()), this, SLOT(sslConnected()));
23.6169 ++ connect( m_socket, SIGNAL(encrypted()), this, SLOT(sslConnected()) );
23.6170 + m_socket->startClientEncryption();
23.6171 + }
23.6172 +
23.6173 ++// Called in secondary thread
23.6174 ++void SessionThread::slotSocketDisconnected()
23.6175 ++{
23.6176 ++ Q_ASSERT( QThread::currentThread() == thread() );
23.6177 ++ if ( doSslFallback ) {
23.6178 ++ reconnect();
23.6179 ++ } else {
23.6180 ++ emit socketDisconnected();
23.6181 ++ }
23.6182 ++}
23.6183 ++
23.6184 ++// Called in secondary thread
23.6185 ++void SessionThread::socketError(KTcpSocket::Error error)
23.6186 ++{
23.6187 ++ Q_ASSERT( QThread::currentThread() == thread() );
23.6188 ++ if ( !m_socket )
23.6189 ++ return;
23.6190 ++ Q_UNUSED( error ); // can be used for debugging
23.6191 ++ if ( doSslFallback ) {
23.6192 ++ //do not call m_socket->disconnectFromHost() here, as that can trigger an error again (resulting in an endless loop).
23.6193 ++ m_socket->abort();
23.6194 ++ } else {
23.6195 ++ emit socketError();
23.6196 ++ }
23.6197 ++}
23.6198 ++
23.6199 ++// Called in secondary thread
23.6200 + void SessionThread::sslConnected()
23.6201 + {
23.6202 +- QMutexLocker locker(&m_mutex);
23.6203 ++ Q_ASSERT( QThread::currentThread() == thread() );
23.6204 ++ if ( !m_socket )
23.6205 ++ return;
23.6206 + KSslCipher cipher = m_socket->sessionCipher();
23.6207 +
23.6208 +- if ( m_socket->sslErrors().count() > 0 || m_socket->encryptionMode() != KTcpSocket::SslClientMode
23.6209 +- || cipher.isNull() || cipher.usedBits() == 0) {
23.6210 +- qDebug() << "Initial SSL handshake failed. cipher.isNull() is" << cipher.isNull()
23.6211 +- << ", cipher.usedBits() is" << cipher.usedBits()
23.6212 +- << ", the socket says:" << m_socket->errorString()
23.6213 +- << "and the list of SSL errors contains"
23.6214 +- << m_socket->sslErrors().count() << "items.";
23.6215 +- KSslErrorUiData errorData(m_socket);
23.6216 +- emit sslError(errorData);
23.6217 ++ if ( m_socket->sslErrors().count() > 0 ||
23.6218 ++ m_socket->encryptionMode() != KTcpSocket::SslClientMode ||
23.6219 ++ cipher.isNull() || cipher.usedBits() == 0 ) {
23.6220 ++ kDebug() << "Initial SSL handshake failed. cipher.isNull() is" << cipher.isNull()
23.6221 ++ << ", cipher.usedBits() is" << cipher.usedBits()
23.6222 ++ << ", the socket says:" << m_socket->errorString()
23.6223 ++ << "and the list of SSL errors contains"
23.6224 ++ << m_socket->sslErrors().count() << "items.";
23.6225 ++ KSslErrorUiData errorData( m_socket );
23.6226 ++ emit sslError( errorData );
23.6227 + } else {
23.6228 +- qDebug() << "TLS negotiation done.";
23.6229 ++ doSslFallback = false;
23.6230 ++ kDebug() << "TLS negotiation done.";
23.6231 + m_encryptedMode = true;
23.6232 +- emit encryptionNegotiationResult(true, m_socket->negotiatedSslVersion());
23.6233 ++ emit encryptionNegotiationResult( true, m_socket->negotiatedSslVersion() );
23.6234 + }
23.6235 + }
23.6236 +
23.6237 + void SessionThread::sslErrorHandlerResponse(bool response)
23.6238 + {
23.6239 +- QMutexLocker locker(&m_mutex);
23.6240 +- if (response) {
23.6241 ++ QMetaObject::invokeMethod(this, "doSslErrorHandlerResponse", Q_ARG(bool, response));
23.6242 ++}
23.6243 ++
23.6244 ++// Called in secondary thread (via invokeMethod)
23.6245 ++void SessionThread::doSslErrorHandlerResponse(bool response)
23.6246 ++{
23.6247 ++ Q_ASSERT( QThread::currentThread() == thread() );
23.6248 ++ if ( !m_socket )
23.6249 ++ return;
23.6250 ++ if ( response ) {
23.6251 + m_encryptedMode = true;
23.6252 +- emit encryptionNegotiationResult(true, m_socket->negotiatedSslVersion());
23.6253 ++ emit encryptionNegotiationResult( true, m_socket->negotiatedSslVersion() );
23.6254 + } else {
23.6255 + m_encryptedMode = false;
23.6256 + //reconnect in unencrypted mode, so new commands can be issued
23.6257 + m_socket->disconnectFromHost();
23.6258 + m_socket->waitForDisconnected();
23.6259 +- m_socket->connectToHost(m_hostName, m_port);
23.6260 +- emit encryptionNegotiationResult(false, KTcpSocket::UnknownSslVersion);
23.6261 ++ m_socket->connectToHost( m_hostName, m_port );
23.6262 ++ emit encryptionNegotiationResult( false, KTcpSocket::UnknownSslVersion );
23.6263 + }
23.6264 + }
23.6265 +
23.6266 +diff --git a/kimap/sessionthread_p.h b/kimap/sessionthread_p.h
23.6267 +index 672c418..47a94fb 100644
23.6268 +--- a/kimap/sessionthread_p.h
23.6269 ++++ b/kimap/sessionthread_p.h
23.6270 +@@ -22,7 +22,6 @@
23.6271 +
23.6272 + #include <QtCore/QMutex>
23.6273 + #include <QtCore/QQueue>
23.6274 +-#include <QtCore/QThread>
23.6275 +
23.6276 + #include <ktcpsocket.h>
23.6277 +
23.6278 +@@ -32,52 +31,62 @@ namespace KIMAP {
23.6279 +
23.6280 + class ImapStreamParser;
23.6281 + struct Message;
23.6282 +-class Session;
23.6283 +
23.6284 +-class SessionThread : public QThread
23.6285 ++class SessionThread : public QObject
23.6286 + {
23.6287 + Q_OBJECT
23.6288 +
23.6289 + public:
23.6290 +- explicit SessionThread( const QString &hostName, quint16 port, Session *parent );
23.6291 ++ explicit SessionThread( const QString &hostName, quint16 port );
23.6292 + ~SessionThread();
23.6293 +
23.6294 + inline QString hostName() { return m_hostName; }
23.6295 + inline quint16 port() { return m_port; }
23.6296 +
23.6297 + void sendData( const QByteArray &payload );
23.6298 +- void run();
23.6299 +
23.6300 + public slots:
23.6301 + void closeSocket();
23.6302 +- void reconnect();
23.6303 +- void startSsl(const KTcpSocket::SslVersion &version);
23.6304 ++ void startSsl(KTcpSocket::SslVersion version);
23.6305 ++ void sslErrorHandlerResponse(bool result);
23.6306 +
23.6307 + signals:
23.6308 ++ void socketConnected();
23.6309 ++ void socketDisconnected();
23.6310 ++ void socketActivity();
23.6311 ++ void socketError();
23.6312 + void responseReceived(const KIMAP::Message &response);
23.6313 + void encryptionNegotiationResult(bool, KTcpSocket::SslVersion);
23.6314 + void sslError(const KSslErrorUiData&);
23.6315 +
23.6316 + private slots:
23.6317 ++ void reconnect();
23.6318 ++ void threadInit();
23.6319 ++ void threadQuit();
23.6320 + void readMessage();
23.6321 + void writeDataQueue();
23.6322 + void sslConnected();
23.6323 +- void sslErrorHandlerResponse(bool result);
23.6324 + void doCloseSocket();
23.6325 ++ void socketError(KTcpSocket::Error);
23.6326 ++ void slotSocketDisconnected();
23.6327 ++ void doStartSsl(KTcpSocket::SslVersion);
23.6328 ++ void doSslErrorHandlerResponse(bool result);
23.6329 +
23.6330 + private:
23.6331 + QString m_hostName;
23.6332 + quint16 m_port;
23.6333 +
23.6334 +- Session *m_session;
23.6335 + SessionSocket *m_socket;
23.6336 + ImapStreamParser *m_stream;
23.6337 +
23.6338 + QQueue<QByteArray> m_dataQueue;
23.6339 +
23.6340 ++ // Protects m_dataQueue
23.6341 + QMutex m_mutex;
23.6342 +
23.6343 + bool m_encryptedMode;
23.6344 ++ KTcpSocket::SslVersions triedSslVersions;
23.6345 ++ bool doSslFallback;
23.6346 + };
23.6347 +
23.6348 + }
23.6349 +diff --git a/kimap/setacljob.cpp b/kimap/setacljob.cpp
23.6350 +index dea3d81..bb3841d 100644
23.6351 +--- a/kimap/setacljob.cpp
23.6352 ++++ b/kimap/setacljob.cpp
23.6353 +@@ -19,8 +19,8 @@
23.6354 +
23.6355 + #include "setacljob.h"
23.6356 +
23.6357 +-#include <klocale.h>
23.6358 +-#include <kdebug.h>
23.6359 ++#include <KDE/KLocalizedString>
23.6360 ++#include <KDE/KDebug>
23.6361 +
23.6362 + #include "acljobbase_p.h"
23.6363 + #include "message_p.h"
23.6364 +@@ -32,7 +32,7 @@ namespace KIMAP
23.6365 + class SetAclJobPrivate : public AclJobBasePrivate
23.6366 + {
23.6367 + public:
23.6368 +- SetAclJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate(session, name) {}
23.6369 ++ SetAclJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate( session, name ) {}
23.6370 + ~SetAclJobPrivate() { }
23.6371 + };
23.6372 + }
23.6373 +@@ -40,9 +40,8 @@ namespace KIMAP
23.6374 + using namespace KIMAP;
23.6375 +
23.6376 + SetAclJob::SetAclJob( Session *session )
23.6377 +- : AclJobBase(*new SetAclJobPrivate(session, i18n("SetAcl")))
23.6378 ++ : AclJobBase( *new SetAclJobPrivate( session, i18n( "SetAcl" ) ) )
23.6379 + {
23.6380 +-
23.6381 + }
23.6382 +
23.6383 + SetAclJob::~SetAclJob()
23.6384 +@@ -51,32 +50,33 @@ SetAclJob::~SetAclJob()
23.6385 +
23.6386 + void SetAclJob::doStart()
23.6387 + {
23.6388 +- Q_D(SetAclJob);
23.6389 ++ Q_D( SetAclJob );
23.6390 + QByteArray r = Acl::rightsToString( d->rightList );
23.6391 +- if (d->modifier == Add) {
23.6392 +- r.prepend('+');
23.6393 +- } else if (d->modifier == Remove) {
23.6394 +- r.prepend('-');
23.6395 ++ if ( d->modifier == Add ) {
23.6396 ++ r.prepend( '+' );
23.6397 ++ } else if ( d->modifier == Remove ) {
23.6398 ++ r.prepend( '-' );
23.6399 + }
23.6400 +- d->tags << d->sessionInternal()->sendCommand( "SETACL", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + "\" \"" + d->id + "\" \"" + r +'\"');
23.6401 ++ d->tags << d->sessionInternal()->sendCommand( "SETACL", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + "\" \"" + d->id + "\" \"" + r + '\"' );
23.6402 + }
23.6403 +
23.6404 + void SetAclJob::setRights(AclModifier modifier, Acl::Rights rights)
23.6405 + {
23.6406 +- Q_D(SetAclJob);
23.6407 +- d->setRights(modifier, rights);
23.6408 ++ Q_D( SetAclJob );
23.6409 ++ d->setRights( modifier, rights );
23.6410 + }
23.6411 +
23.6412 + void SetAclJob::setIdentifier( const QByteArray &identifier )
23.6413 + {
23.6414 +- Q_D(SetAclJob);
23.6415 +- d->setIdentifier(identifier);
23.6416 ++ Q_D( SetAclJob );
23.6417 ++ d->setIdentifier( identifier );
23.6418 + }
23.6419 +
23.6420 + QByteArray SetAclJob::identifier()
23.6421 + {
23.6422 +- Q_D(SetAclJob);
23.6423 ++ Q_D( SetAclJob );
23.6424 + return d->identifier();
23.6425 + }
23.6426 +
23.6427 + #include "setacljob.moc"
23.6428 ++
23.6429 +diff --git a/kimap/setacljob.h b/kimap/setacljob.h
23.6430 +index 33df18d..c2496c3 100644
23.6431 +--- a/kimap/setacljob.h
23.6432 ++++ b/kimap/setacljob.h
23.6433 +@@ -30,7 +30,6 @@ class Session;
23.6434 + struct Message;
23.6435 + class SetAclJobPrivate;
23.6436 +
23.6437 +-
23.6438 + /**
23.6439 + * Sets the rights that correspond to an identifier on a mailbox
23.6440 + *
23.6441 +@@ -44,7 +43,7 @@ class SetAclJobPrivate;
23.6442 + class KIMAP_EXPORT SetAclJob : public AclJobBase
23.6443 + {
23.6444 + Q_OBJECT
23.6445 +- Q_DECLARE_PRIVATE(SetAclJob)
23.6446 ++ Q_DECLARE_PRIVATE( SetAclJob )
23.6447 +
23.6448 + friend class SessionPrivate;
23.6449 +
23.6450 +@@ -96,6 +95,7 @@ class KIMAP_EXPORT SetAclJob : public AclJobBase
23.6451 + * Note that negative rights override positive rights: if
23.6452 + * "fred" and "-fred" are both assigned the 'w' right, the
23.6453 + * user "fred" will not have the 'w' right.
23.6454 ++ * @param identifier the identifier to set
23.6455 + */
23.6456 + void setIdentifier( const QByteArray &identifier );
23.6457 + /**
23.6458 +diff --git a/kimap/setmetadatajob.cpp b/kimap/setmetadatajob.cpp
23.6459 +index c279812..80e46f9 100644
23.6460 +--- a/kimap/setmetadatajob.cpp
23.6461 ++++ b/kimap/setmetadatajob.cpp
23.6462 +@@ -19,8 +19,8 @@
23.6463 +
23.6464 + #include "setmetadatajob.h"
23.6465 +
23.6466 +-#include <klocale.h>
23.6467 +-#include <kdebug.h>
23.6468 ++#include <KDE/KLocalizedString>
23.6469 ++#include <KDE/KDebug>
23.6470 +
23.6471 + #include "metadatajobbase_p.h"
23.6472 + #include "message_p.h"
23.6473 +@@ -32,7 +32,7 @@ namespace KIMAP
23.6474 + class SetMetaDataJobPrivate : public MetaDataJobBasePrivate
23.6475 + {
23.6476 + public:
23.6477 +- SetMetaDataJobPrivate( Session *session, const QString& name ) : MetaDataJobBasePrivate(session, name), metaDataErrors(0), maxAcceptedSize(-1) { }
23.6478 ++ SetMetaDataJobPrivate( Session *session, const QString& name ) : MetaDataJobBasePrivate( session, name ), metaDataErrors( 0 ), maxAcceptedSize( -1 ) { }
23.6479 + ~SetMetaDataJobPrivate() { }
23.6480 +
23.6481 + QMap<QByteArray, QByteArray> entries;
23.6482 +@@ -46,7 +46,7 @@ namespace KIMAP
23.6483 + using namespace KIMAP;
23.6484 +
23.6485 + SetMetaDataJob::SetMetaDataJob( Session *session )
23.6486 +- : MetaDataJobBase( *new SetMetaDataJobPrivate(session, i18n("SetMetaData")) )
23.6487 ++ : MetaDataJobBase( *new SetMetaDataJobPrivate( session, i18n( "SetMetaData" ) ) )
23.6488 + {
23.6489 + }
23.6490 +
23.6491 +@@ -56,99 +56,102 @@ SetMetaDataJob::~SetMetaDataJob()
23.6492 +
23.6493 + void SetMetaDataJob::doStart()
23.6494 + {
23.6495 +- Q_D(SetMetaDataJob);
23.6496 ++ Q_D( SetMetaDataJob );
23.6497 + QByteArray parameters;
23.6498 + parameters = '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + "\" ";
23.6499 + d->entriesIt = d->entries.constBegin();
23.6500 +
23.6501 + QByteArray command = "SETMETADATA";
23.6502 +- if (d->serverCapability == Annotatemore) {
23.6503 ++ if ( d->serverCapability == Annotatemore ) {
23.6504 + command = "SETANNOTATION";
23.6505 + parameters += '\"' + d->entryName + "\" (";
23.6506 +- d->m_name = i18n("SetAnnotation");
23.6507 +- if (!d->entries.isEmpty()) {
23.6508 +- for (; d->entriesIt != d->entries.constEnd(); ++d->entriesIt) {
23.6509 +- parameters += '\"' + d->entriesIt.key() + "\" \"" + d->entriesIt.value() + "\" ";
23.6510 ++ d->m_name = i18n( "SetAnnotation" );
23.6511 ++ if ( !d->entries.isEmpty() ) {
23.6512 ++ for ( ; d->entriesIt != d->entries.constEnd(); ++d->entriesIt ) {
23.6513 ++ parameters += '\"' + d->entriesIt.key() + "\" \"" + d->entriesIt.value() + "\" ";
23.6514 + }
23.6515 + parameters[parameters.length() - 1] = ')';
23.6516 + }
23.6517 + } else {
23.6518 + parameters += '(';
23.6519 +- if (!d->entries.isEmpty()) {
23.6520 ++ if ( !d->entries.isEmpty() ) {
23.6521 + parameters += '\"' + d->entriesIt.key() + '\"';
23.6522 + parameters += ' ';
23.6523 +- parameters +=" {" + QByteArray::number(d->entriesIt.value().size()) + '}';
23.6524 ++ parameters += " {" + QByteArray::number( d->entriesIt.value().size() ) + '}';
23.6525 + }
23.6526 + }
23.6527 +
23.6528 +- if (d->entries.isEmpty()) {
23.6529 ++ if ( d->entries.isEmpty() ) {
23.6530 + parameters += ')';
23.6531 + }
23.6532 +
23.6533 + d->tags << d->sessionInternal()->sendCommand( command, parameters );
23.6534 +-// qDebug() << "SENT: " << command << " " << parameters;
23.6535 ++// kDebug() << "SENT: " << command << " " << parameters;
23.6536 + }
23.6537 +
23.6538 + void SetMetaDataJob::handleResponse( const Message &response )
23.6539 + {
23.6540 +- Q_D(SetMetaDataJob);
23.6541 ++ Q_D( SetMetaDataJob );
23.6542 +
23.6543 + //TODO: Test if a server can really return more then one untagged NO response. If not, no need to OR the error codes
23.6544 +- if ( !response.content.isEmpty()
23.6545 +- && d->tags.contains( response.content.first().toString() ) ) {
23.6546 ++ if ( !response.content.isEmpty() &&
23.6547 ++ d->tags.contains( response.content.first().toString() ) ) {
23.6548 + if ( response.content[1].toString() == "NO" ) {
23.6549 + setError( UserDefinedError );
23.6550 +- setErrorText( i18n("%1 failed, server replied: %2", d->m_name, response.toString().constData()) );
23.6551 +- if (response.content[2].toString() == "[ANNOTATEMORE TOOMANY]" || response.content[2].toString() == "[METADATA TOOMANY]") {
23.6552 ++ setErrorText( i18n( "%1 failed, server replied: %2", d->m_name, response.toString().constData() ) );
23.6553 ++ if ( response.content[2].toString() == "[ANNOTATEMORE TOOMANY]" ||
23.6554 ++ response.content[2].toString() == "[METADATA TOOMANY]" ) {
23.6555 + d->metaDataErrors |= TooMany;
23.6556 +- } else if (response.content[2].toString() == "[ANNOTATEMORE TOOBIG]" || response.content[2].toString().startsWith("[METADATA MAXSIZE")) {
23.6557 ++ } else if ( response.content[2].toString() == "[ANNOTATEMORE TOOBIG]" ||
23.6558 ++ response.content[2].toString().startsWith( "[METADATA MAXSIZE" ) ) { //krazy:exclude=strings
23.6559 + d->metaDataErrors |= TooBig;
23.6560 + d->maxAcceptedSize = -1;
23.6561 +- if (response.content[2].toString().startsWith("[METADATA MAXSIZE")) { //krazy:exclude=strings
23.6562 ++ if ( response.content[2].toString().startsWith( "[METADATA MAXSIZE" ) ) { //krazy:exclude=strings
23.6563 + QByteArray max = response.content[2].toString();
23.6564 +- max.replace("[METADATA MAXSIZE",""); //krazy:exclude=doublequote_chars
23.6565 +- max.replace("]", ""); //krazy:exclude=doublequote_chars
23.6566 ++ max.replace( "[METADATA MAXSIZE", "" ); //krazy:exclude=doublequote_chars
23.6567 ++ max.replace( "]", "" ); //krazy:exclude=doublequote_chars
23.6568 + d->maxAcceptedSize = max.toLongLong();
23.6569 + }
23.6570 +- } else if (response.content[2].toString() == "[METADATA NOPRIVATE]") {
23.6571 ++ } else if ( response.content[2].toString() == "[METADATA NOPRIVATE]" ) {
23.6572 + d->metaDataErrors |= NoPrivate;
23.6573 + }
23.6574 + } else if ( response.content.size() < 2 ) {
23.6575 +- setErrorText( i18n("%1 failed, malformed reply from the server.", d->m_name) );
23.6576 ++ setErrorText( i18n( "%1 failed, malformed reply from the server.", d->m_name ) );
23.6577 + } else if ( response.content[1].toString() != "OK" ) {
23.6578 + setError( UserDefinedError );
23.6579 +- setErrorText( i18n("%1 failed, server replied: %2", d->m_name, response.toString().constData()) );
23.6580 ++ setErrorText( i18n( "%1 failed, server replied: %2", d->m_name, response.toString().constData() ) );
23.6581 + }
23.6582 + emitResult();
23.6583 + } else if ( d->serverCapability == Metadata && response.content[0].toString() == "+" ) {
23.6584 + QByteArray content = d->entriesIt.value();
23.6585 + ++d->entriesIt;
23.6586 +- if (d->entriesIt == d->entries.constEnd()) {
23.6587 ++ if ( d->entriesIt == d->entries.constEnd() ) {
23.6588 + content += ')';
23.6589 + } else {
23.6590 +- content +=" {" + QByteArray::number(d->entriesIt.value().size()) + '}';
23.6591 ++ content += " {" + QByteArray::number( d->entriesIt.value().size() ) + '}';
23.6592 + }
23.6593 +-// qDebug() << "SENT: " << content;
23.6594 ++// kDebug() << "SENT: " << content;
23.6595 + d->sessionInternal()->sendData( content );
23.6596 + }
23.6597 + }
23.6598 +
23.6599 + void SetMetaDataJob::addMetaData(const QByteArray &name, const QByteArray &value)
23.6600 + {
23.6601 +- Q_D(SetMetaDataJob);
23.6602 ++ Q_D( SetMetaDataJob );
23.6603 + d->entries[name] = value;
23.6604 + }
23.6605 +
23.6606 + void SetMetaDataJob::setEntry(const QByteArray &entry)
23.6607 + {
23.6608 +- Q_D(SetMetaDataJob);
23.6609 ++ Q_D( SetMetaDataJob );
23.6610 + d->entryName = entry;
23.6611 + }
23.6612 +
23.6613 + SetMetaDataJob::MetaDataErrors SetMetaDataJob::metaDataErrors() const
23.6614 + {
23.6615 +- Q_D(const SetMetaDataJob);
23.6616 ++ Q_D( const SetMetaDataJob );
23.6617 + return d->metaDataErrors;
23.6618 + }
23.6619 +
23.6620 + #include "setmetadatajob.moc"
23.6621 ++
23.6622 +diff --git a/kimap/setmetadatajob.h b/kimap/setmetadatajob.h
23.6623 +index 1391ecc..3736539 100644
23.6624 +--- a/kimap/setmetadatajob.h
23.6625 ++++ b/kimap/setmetadatajob.h
23.6626 +@@ -68,7 +68,7 @@ class SetMetaDataJobPrivate;
23.6627 + class KIMAP_EXPORT SetMetaDataJob : public MetaDataJobBase
23.6628 + {
23.6629 + Q_OBJECT
23.6630 +- Q_DECLARE_PRIVATE(SetMetaDataJob)
23.6631 ++ Q_DECLARE_PRIVATE( SetMetaDataJob )
23.6632 +
23.6633 + friend class SessionPrivate;
23.6634 +
23.6635 +@@ -184,7 +184,7 @@ class KIMAP_EXPORT SetMetaDataJob : public MetaDataJobBase
23.6636 + };
23.6637 +
23.6638 + // Q_DECLARE_WHATEVER_THAT_WAS missing
23.6639 +- Q_DECLARE_FLAGS(MetaDataErrors, MetaDataError)
23.6640 ++ Q_DECLARE_FLAGS( MetaDataErrors, MetaDataError )
23.6641 +
23.6642 + /**
23.6643 + * The metadata errors received from the server.
23.6644 +diff --git a/kimap/setquotajob.cpp b/kimap/setquotajob.cpp
23.6645 +index 9dedddd..347aeee 100644
23.6646 +--- a/kimap/setquotajob.cpp
23.6647 ++++ b/kimap/setquotajob.cpp
23.6648 +@@ -19,8 +19,8 @@
23.6649 +
23.6650 + #include "setquotajob.h"
23.6651 +
23.6652 +-#include <klocale.h>
23.6653 +-#include <kdebug.h>
23.6654 ++#include <KDE/KLocalizedString>
23.6655 ++#include <KDE/KDebug>
23.6656 +
23.6657 + #include "quotajobbase_p.h"
23.6658 + #include "message_p.h"
23.6659 +@@ -31,7 +31,7 @@ namespace KIMAP
23.6660 + class SetQuotaJobPrivate : public QuotaJobBasePrivate
23.6661 + {
23.6662 + public:
23.6663 +- SetQuotaJobPrivate( Session *session, const QString& name ) : QuotaJobBasePrivate(session, name) { }
23.6664 ++ SetQuotaJobPrivate( Session *session, const QString& name ) : QuotaJobBasePrivate( session, name ) { }
23.6665 + ~SetQuotaJobPrivate() { }
23.6666 +
23.6667 + QMap<QByteArray, qint64> setList;
23.6668 +@@ -42,7 +42,7 @@ namespace KIMAP
23.6669 + using namespace KIMAP;
23.6670 +
23.6671 + SetQuotaJob::SetQuotaJob( Session *session )
23.6672 +- : QuotaJobBase( *new SetQuotaJobPrivate(session, i18n("SetQuota")) )
23.6673 ++ : QuotaJobBase( *new SetQuotaJobPrivate( session, i18n( "SetQuota" ) ) )
23.6674 + {
23.6675 + }
23.6676 +
23.6677 +@@ -52,54 +52,54 @@ SetQuotaJob::~SetQuotaJob()
23.6678 +
23.6679 + void SetQuotaJob::doStart()
23.6680 + {
23.6681 +- Q_D(SetQuotaJob);
23.6682 ++ Q_D( SetQuotaJob );
23.6683 + QByteArray s;
23.6684 + s += '(';
23.6685 +- for (QMap<QByteArray, qint64>::ConstIterator it = d->setList.constBegin(); it != d->setList.constEnd(); ++it ) {
23.6686 +- s += it.key() + ' ' + QByteArray::number(it.value()) + ' ';
23.6687 ++ for ( QMap<QByteArray, qint64>::ConstIterator it = d->setList.constBegin(); it != d->setList.constEnd(); ++it ) {
23.6688 ++ s += it.key() + ' ' + QByteArray::number( it.value() ) + ' ';
23.6689 + }
23.6690 +- if (d->setList.isEmpty()) {
23.6691 ++ if ( d->setList.isEmpty() ) {
23.6692 + s += ')';
23.6693 + } else {
23.6694 + s[s.length() - 1] = ')';
23.6695 + }
23.6696 +
23.6697 +- qDebug() << "SETQUOTA " << '\"' + d->root + "\" " + s;
23.6698 ++ kDebug() << "SETQUOTA " << '\"' + d->root + "\" " + s;
23.6699 + //XXX: [alexmerry, 2010-07-24]: should d->root be quoted properly?
23.6700 +- d->tags << d->sessionInternal()->sendCommand( "SETQUOTA", '\"' + d->root + "\" " + s);
23.6701 ++ d->tags << d->sessionInternal()->sendCommand( "SETQUOTA", '\"' + d->root + "\" " + s );
23.6702 + }
23.6703 +
23.6704 + void SetQuotaJob::handleResponse(const Message &response)
23.6705 + {
23.6706 +- Q_D(SetQuotaJob);
23.6707 +- if (handleErrorReplies(response) == NotHandled) {
23.6708 +- if ( response.content.size() >= 4
23.6709 +- && response.content[1].toString() == "QUOTA" ) {
23.6710 +- d->quota = d->readQuota(response.content[3]);
23.6711 ++ Q_D( SetQuotaJob );
23.6712 ++ if ( handleErrorReplies( response ) == NotHandled ) {
23.6713 ++ if ( response.content.size() >= 4 &&
23.6714 ++ response.content[1].toString() == "QUOTA" ) {
23.6715 ++ d->quota = d->readQuota( response.content[3] );
23.6716 + }
23.6717 + }
23.6718 + }
23.6719 +
23.6720 +-
23.6721 + void SetQuotaJob::setQuota(const QByteArray &resource, qint64 limit)
23.6722 + {
23.6723 +- Q_D(SetQuotaJob);
23.6724 ++ Q_D( SetQuotaJob );
23.6725 +
23.6726 + d->setList[resource.toUpper()] = limit;
23.6727 + }
23.6728 +
23.6729 + void SetQuotaJob::setRoot(const QByteArray& root)
23.6730 + {
23.6731 +- Q_D(SetQuotaJob);
23.6732 ++ Q_D( SetQuotaJob );
23.6733 +
23.6734 + d->root = root;
23.6735 + }
23.6736 +
23.6737 + QByteArray SetQuotaJob::root() const
23.6738 + {
23.6739 +- Q_D(const SetQuotaJob);
23.6740 ++ Q_D( const SetQuotaJob );
23.6741 +
23.6742 + return d->root;
23.6743 + }
23.6744 +
23.6745 + #include "setquotajob.moc"
23.6746 ++
23.6747 +diff --git a/kimap/setquotajob.h b/kimap/setquotajob.h
23.6748 +index f3fac37..ff21a29 100644
23.6749 +--- a/kimap/setquotajob.h
23.6750 ++++ b/kimap/setquotajob.h
23.6751 +@@ -84,6 +84,7 @@ class KIMAP_EXPORT SetQuotaJob : public QuotaJobBase
23.6752 + * may create it and change the quota roots for any number of
23.6753 + * existing mailboxes in an implementation-defined manner.
23.6754 + *
23.6755 ++ * @param root the quota root to set, in bytes
23.6756 + * @see GetQuotaRootJob
23.6757 + */
23.6758 + void setRoot( const QByteArray &root );
23.6759 +diff --git a/kimap/storejob.cpp b/kimap/storejob.cpp
23.6760 +index cf70503..0118000 100644
23.6761 +--- a/kimap/storejob.cpp
23.6762 ++++ b/kimap/storejob.cpp
23.6763 +@@ -19,8 +19,8 @@
23.6764 +
23.6765 + #include "storejob.h"
23.6766 +
23.6767 +-#include <kdebug.h>
23.6768 +-#include <klocale.h>
23.6769 ++#include <KDE/KDebug>
23.6770 ++#include <KDE/KLocalizedString>
23.6771 +
23.6772 + #include "job_p.h"
23.6773 + #include "message_p.h"
23.6774 +@@ -46,9 +46,9 @@ namespace KIMAP
23.6775 + using namespace KIMAP;
23.6776 +
23.6777 + StoreJob::StoreJob( Session *session )
23.6778 +- : Job( *new StoreJobPrivate(session, i18n("Store")) )
23.6779 ++ : Job( *new StoreJobPrivate( session, i18n( "Store" ) ) )
23.6780 + {
23.6781 +- Q_D(StoreJob);
23.6782 ++ Q_D( StoreJob );
23.6783 + d->uidBased = false;
23.6784 + d->mode = SetFlags;
23.6785 + }
23.6786 +@@ -59,84 +59,86 @@ StoreJob::~StoreJob()
23.6787 +
23.6788 + void StoreJob::setSequenceSet( const ImapSet &set )
23.6789 + {
23.6790 +- Q_D(StoreJob);
23.6791 ++ Q_D( StoreJob );
23.6792 + d->set = set;
23.6793 + }
23.6794 +
23.6795 + ImapSet StoreJob::sequenceSet() const
23.6796 + {
23.6797 +- Q_D(const StoreJob);
23.6798 ++ Q_D( const StoreJob );
23.6799 + return d->set;
23.6800 + }
23.6801 +
23.6802 + void StoreJob::setUidBased(bool uidBased)
23.6803 + {
23.6804 +- Q_D(StoreJob);
23.6805 ++ Q_D( StoreJob );
23.6806 + d->uidBased = uidBased;
23.6807 + }
23.6808 +
23.6809 + bool StoreJob::isUidBased() const
23.6810 + {
23.6811 +- Q_D(const StoreJob);
23.6812 ++ Q_D( const StoreJob );
23.6813 + return d->uidBased;
23.6814 + }
23.6815 +
23.6816 + void StoreJob::setFlags( const MessageFlags &flags )
23.6817 + {
23.6818 +- Q_D(StoreJob);
23.6819 ++ Q_D( StoreJob );
23.6820 + d->flags = flags;
23.6821 + }
23.6822 +
23.6823 + MessageFlags StoreJob::flags() const
23.6824 + {
23.6825 +- Q_D(const StoreJob);
23.6826 ++ Q_D( const StoreJob );
23.6827 + return d->flags;
23.6828 + }
23.6829 +
23.6830 + void StoreJob::setMode( StoreMode mode )
23.6831 + {
23.6832 +- Q_D(StoreJob);
23.6833 ++ Q_D( StoreJob );
23.6834 + d->mode = mode;
23.6835 + }
23.6836 +
23.6837 + StoreJob::StoreMode StoreJob::mode() const
23.6838 + {
23.6839 +- Q_D(const StoreJob);
23.6840 ++ Q_D( const StoreJob );
23.6841 + return d->mode;
23.6842 + }
23.6843 +
23.6844 + QMap<int, MessageFlags> StoreJob::resultingFlags() const
23.6845 + {
23.6846 +- Q_D(const StoreJob);
23.6847 ++ Q_D( const StoreJob );
23.6848 + return d->resultingFlags;
23.6849 + }
23.6850 +
23.6851 + void StoreJob::doStart()
23.6852 + {
23.6853 +- Q_D(StoreJob);
23.6854 ++ Q_D( StoreJob );
23.6855 +
23.6856 + QByteArray parameters = d->set.toImapSequenceSet()+' ';
23.6857 +
23.6858 + switch ( d->mode ) {
23.6859 + case SetFlags:
23.6860 +- parameters+= "FLAGS";
23.6861 ++ parameters += "FLAGS";
23.6862 + break;
23.6863 + case AppendFlags:
23.6864 +- parameters+= "+FLAGS";
23.6865 ++ parameters += "+FLAGS";
23.6866 + break;
23.6867 + case RemoveFlags:
23.6868 +- parameters+= "-FLAGS";
23.6869 ++ parameters += "-FLAGS";
23.6870 + break;
23.6871 + }
23.6872 +
23.6873 +- parameters+=" (";
23.6874 ++ parameters += " (";
23.6875 + foreach ( const QByteArray &flag, d->flags ) {
23.6876 +- parameters+=flag+' ';
23.6877 ++ parameters += flag + ' ';
23.6878 + }
23.6879 +- if (!d->flags.isEmpty()) parameters.chop(1);
23.6880 +- parameters+=')';
23.6881 ++ if ( !d->flags.isEmpty() ) {
23.6882 ++ parameters.chop( 1 );
23.6883 ++ }
23.6884 ++ parameters += ')';
23.6885 +
23.6886 +- qDebug("%s", parameters.constData());
23.6887 ++ kDebug() << parameters;
23.6888 +
23.6889 + QByteArray command = "STORE";
23.6890 + if ( d->uidBased ) {
23.6891 +@@ -148,12 +150,12 @@ void StoreJob::doStart()
23.6892 +
23.6893 + void StoreJob::handleResponse( const Message &response )
23.6894 + {
23.6895 +- Q_D(StoreJob);
23.6896 ++ Q_D( StoreJob );
23.6897 +
23.6898 +- if (handleErrorReplies(response) == NotHandled ) {
23.6899 +- if ( response.content.size() == 4
23.6900 +- && response.content[2].toString()=="FETCH"
23.6901 +- && response.content[3].type()==Message::Part::List ) {
23.6902 ++ if ( handleErrorReplies( response ) == NotHandled ) {
23.6903 ++ if ( response.content.size() == 4 &&
23.6904 ++ response.content[2].toString() == "FETCH" &&
23.6905 ++ response.content[3].type() == Message::Part::List ) {
23.6906 +
23.6907 + int id = response.content[1].toString().toInt();
23.6908 + qint64 uid = 0;
23.6909 +@@ -163,21 +165,21 @@ void StoreJob::handleResponse( const Message &response )
23.6910 + QList<QByteArray> content = response.content[3].toList();
23.6911 +
23.6912 + for ( QList<QByteArray>::ConstIterator it = content.constBegin();
23.6913 +- it!=content.constEnd(); ++it ) {
23.6914 ++ it != content.constEnd(); ++it ) {
23.6915 + QByteArray str = *it;
23.6916 + ++it;
23.6917 +
23.6918 +- if ( str=="FLAGS" ) {
23.6919 +- if ( (*it).startsWith('(') && (*it).endsWith(')') ) {
23.6920 ++ if ( str == "FLAGS" ) {
23.6921 ++ if ( ( *it ).startsWith( '(' ) && ( *it ).endsWith( ')' ) ) {
23.6922 + QByteArray str = *it;
23.6923 +- str.chop(1);
23.6924 +- str.remove(0, 1);
23.6925 +- resultingFlags = str.split(' ');
23.6926 ++ str.chop( 1 );
23.6927 ++ str.remove( 0, 1 );
23.6928 ++ resultingFlags = str.split( ' ' );
23.6929 + } else {
23.6930 + resultingFlags << *it;
23.6931 + }
23.6932 +- } else if ( str=="UID" ) {
23.6933 +- uid = it->toLongLong(&uidFound);
23.6934 ++ } else if ( str == "UID" ) {
23.6935 ++ uid = it->toLongLong( &uidFound );
23.6936 + }
23.6937 + }
23.6938 +
23.6939 +@@ -192,4 +194,5 @@ void StoreJob::handleResponse( const Message &response )
23.6940 + }
23.6941 + }
23.6942 +
23.6943 +-#include "storejob.moc"
23.6944 +\ No newline at end of file
23.6945 ++#include "storejob.moc"
23.6946 ++
23.6947 +diff --git a/kimap/storejob.h b/kimap/storejob.h
23.6948 +index 7c41d90..4de2f76 100644
23.6949 +--- a/kimap/storejob.h
23.6950 ++++ b/kimap/storejob.h
23.6951 +@@ -36,13 +36,12 @@ typedef QList<QByteArray> MessageFlags;
23.6952 + class KIMAP_EXPORT StoreJob : public Job
23.6953 + {
23.6954 + Q_OBJECT
23.6955 +- Q_DECLARE_PRIVATE(StoreJob)
23.6956 ++ Q_DECLARE_PRIVATE( StoreJob )
23.6957 +
23.6958 + friend class SessionPrivate;
23.6959 +
23.6960 + public:
23.6961 +- enum StoreMode
23.6962 +- {
23.6963 ++ enum StoreMode {
23.6964 + SetFlags,
23.6965 + AppendFlags,
23.6966 + RemoveFlags
23.6967 +diff --git a/kimap/subscribejob.cpp b/kimap/subscribejob.cpp
23.6968 +index 880f977..5317f73 100644
23.6969 +--- a/kimap/subscribejob.cpp
23.6970 ++++ b/kimap/subscribejob.cpp
23.6971 +@@ -19,8 +19,8 @@
23.6972 +
23.6973 + #include "subscribejob.h"
23.6974 +
23.6975 +-#include <klocale.h>
23.6976 +-#include <kdebug.h>
23.6977 ++#include <KDE/KLocalizedString>
23.6978 ++#include <KDE/KDebug>
23.6979 +
23.6980 + #include "job_p.h"
23.6981 + #include "message_p.h"
23.6982 +@@ -32,7 +32,7 @@ namespace KIMAP
23.6983 + class SubscribeJobPrivate : public JobPrivate
23.6984 + {
23.6985 + public:
23.6986 +- SubscribeJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { }
23.6987 ++ SubscribeJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { }
23.6988 + ~SubscribeJobPrivate() { }
23.6989 +
23.6990 + QString mailBox;
23.6991 +@@ -42,7 +42,7 @@ namespace KIMAP
23.6992 + using namespace KIMAP;
23.6993 +
23.6994 + SubscribeJob::SubscribeJob( Session *session )
23.6995 +- : Job( *new SubscribeJobPrivate(session, i18n("Subscribe")) )
23.6996 ++ : Job( *new SubscribeJobPrivate( session, i18n( "Subscribe" ) ) )
23.6997 + {
23.6998 + }
23.6999 +
23.7000 +@@ -52,20 +52,21 @@ SubscribeJob::~SubscribeJob()
23.7001 +
23.7002 + void SubscribeJob::doStart()
23.7003 + {
23.7004 +- Q_D(SubscribeJob);
23.7005 +- d->tags << d->sessionInternal()->sendCommand( "SUBSCRIBE", '\"'+KIMAP::encodeImapFolderName( d->mailBox.toUtf8() )+'\"' );
23.7006 ++ Q_D( SubscribeJob );
23.7007 ++ d->tags << d->sessionInternal()->sendCommand( "SUBSCRIBE", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"' );
23.7008 + }
23.7009 +
23.7010 + void SubscribeJob::setMailBox( const QString &mailBox )
23.7011 + {
23.7012 +- Q_D(SubscribeJob);
23.7013 ++ Q_D( SubscribeJob );
23.7014 + d->mailBox = mailBox;
23.7015 + }
23.7016 +
23.7017 + QString SubscribeJob::mailBox() const
23.7018 + {
23.7019 +- Q_D(const SubscribeJob);
23.7020 ++ Q_D( const SubscribeJob );
23.7021 + return d->mailBox;
23.7022 + }
23.7023 +
23.7024 + #include "subscribejob.moc"
23.7025 ++
23.7026 +diff --git a/kimap/subscribejob.h b/kimap/subscribejob.h
23.7027 +index f0db503..e54cf9f 100644
23.7028 +--- a/kimap/subscribejob.h
23.7029 ++++ b/kimap/subscribejob.h
23.7030 +@@ -32,7 +32,7 @@ class SubscribeJobPrivate;
23.7031 + class KIMAP_EXPORT SubscribeJob : public Job
23.7032 + {
23.7033 + Q_OBJECT
23.7034 +- Q_DECLARE_PRIVATE(SubscribeJob)
23.7035 ++ Q_DECLARE_PRIVATE( SubscribeJob )
23.7036 +
23.7037 + friend class SessionPrivate;
23.7038 +
23.7039 +diff --git a/kimap/unsubscribejob.cpp b/kimap/unsubscribejob.cpp
23.7040 +index f570987..06f0900 100644
23.7041 +--- a/kimap/unsubscribejob.cpp
23.7042 ++++ b/kimap/unsubscribejob.cpp
23.7043 +@@ -19,8 +19,8 @@
23.7044 +
23.7045 + #include "unsubscribejob.h"
23.7046 +
23.7047 +-#include <klocale.h>
23.7048 +-#include <kdebug.h>
23.7049 ++#include <KDE/KLocalizedString>
23.7050 ++#include <KDE/KDebug>
23.7051 +
23.7052 + #include "job_p.h"
23.7053 + #include "message_p.h"
23.7054 +@@ -32,7 +32,7 @@ namespace KIMAP
23.7055 + class UnsubscribeJobPrivate : public JobPrivate
23.7056 + {
23.7057 + public:
23.7058 +- UnsubscribeJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { }
23.7059 ++ UnsubscribeJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { }
23.7060 + ~UnsubscribeJobPrivate() { }
23.7061 +
23.7062 + QString mailBox;
23.7063 +@@ -42,7 +42,7 @@ namespace KIMAP
23.7064 + using namespace KIMAP;
23.7065 +
23.7066 + UnsubscribeJob::UnsubscribeJob( Session *session )
23.7067 +- : Job( *new UnsubscribeJobPrivate(session, i18n("Unsubscribe")) )
23.7068 ++ : Job( *new UnsubscribeJobPrivate( session, i18n( "Unsubscribe" ) ) )
23.7069 + {
23.7070 + }
23.7071 +
23.7072 +@@ -52,20 +52,21 @@ UnsubscribeJob::~UnsubscribeJob()
23.7073 +
23.7074 + void UnsubscribeJob::doStart()
23.7075 + {
23.7076 +- Q_D(UnsubscribeJob);
23.7077 +- d->tags << d->sessionInternal()->sendCommand( "UNSUBSCRIBE", '\"'+KIMAP::encodeImapFolderName( d->mailBox.toUtf8() )+'\"' );
23.7078 ++ Q_D( UnsubscribeJob );
23.7079 ++ d->tags << d->sessionInternal()->sendCommand( "UNSUBSCRIBE", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"' );
23.7080 + }
23.7081 +
23.7082 + void UnsubscribeJob::setMailBox( const QString &mailBox )
23.7083 + {
23.7084 +- Q_D(UnsubscribeJob);
23.7085 ++ Q_D( UnsubscribeJob );
23.7086 + d->mailBox = mailBox;
23.7087 + }
23.7088 +
23.7089 + QString UnsubscribeJob::mailBox() const
23.7090 + {
23.7091 +- Q_D(const UnsubscribeJob);
23.7092 ++ Q_D( const UnsubscribeJob );
23.7093 + return d->mailBox;
23.7094 + }
23.7095 +
23.7096 + #include "unsubscribejob.moc"
23.7097 ++
23.7098 +diff --git a/kimap/unsubscribejob.h b/kimap/unsubscribejob.h
23.7099 +index f03875e..1ef8ceb 100644
23.7100 +--- a/kimap/unsubscribejob.h
23.7101 ++++ b/kimap/unsubscribejob.h
23.7102 +@@ -32,7 +32,7 @@ class UnsubscribeJobPrivate;
23.7103 + class KIMAP_EXPORT UnsubscribeJob : public Job
23.7104 + {
23.7105 + Q_OBJECT
23.7106 +- Q_DECLARE_PRIVATE(UnsubscribeJob)
23.7107 ++ Q_DECLARE_PRIVATE( UnsubscribeJob )
23.7108 +
23.7109 + friend class SessionPrivate;
23.7110 +