paul@0 | 1 | commit 9b09d89342ea522cf356d90649465e93ec743ba4 |
paul@0 | 2 | Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> |
paul@0 | 3 | Date: Mon Oct 14 17:45:31 2013 +0200 |
paul@0 | 4 | |
paul@0 | 5 | Fix imap lockups.patch |
paul@0 | 6 | |
paul@0 | 7 | diff --git a/kdecore/CMakeLists.txt b/kdecore/CMakeLists.txt |
paul@0 | 8 | index f543f0e..7cdff03 100644 |
paul@0 | 9 | --- a/kdecore/CMakeLists.txt |
paul@0 | 10 | +++ b/kdecore/CMakeLists.txt |
paul@0 | 11 | @@ -721,3 +721,5 @@ install(FILES |
paul@0 | 12 | # DESTINATION ${SERVICETYPES_INSTALL_DIR} |
paul@0 | 13 | # ) |
paul@0 | 14 | |
paul@0 | 15 | +add_subdirectory(includes) |
paul@0 | 16 | + |
paul@0 | 17 | diff --git a/kdecore/includes/CMakeLists.txt b/kdecore/includes/CMakeLists.txt |
paul@0 | 18 | new file mode 100644 |
paul@0 | 19 | index 0000000..2a10c50 |
paul@0 | 20 | --- /dev/null |
paul@0 | 21 | +++ b/kdecore/includes/CMakeLists.txt |
paul@0 | 22 | @@ -0,0 +1,34 @@ |
paul@0 | 23 | + |
paul@0 | 24 | +macro(install_headers _dir) |
paul@0 | 25 | + install( DIRECTORY ${_dir} DESTINATION ${INCLUDE_INSTALL_DIR} ) |
paul@0 | 26 | +endmacro() |
paul@0 | 27 | + |
paul@0 | 28 | +macro(create_header _file _path _header) |
paul@0 | 29 | + #For installation |
paul@0 | 30 | + set(CAMELCASE_INCLUDE_PATH "../${_header}") |
paul@0 | 31 | + configure_file(config-CamelCaseInclude.cmake ${CMAKE_CURRENT_BINARY_DIR}/KDE/${_file}) |
paul@0 | 32 | + #For including from the kdepimlibs stuff |
paul@0 | 33 | + set(CAMELCASE_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../${_path}/${_header}") |
paul@0 | 34 | + configure_file(config-CamelCaseInclude.cmake ${CMAKE_CURRENT_BINARY_DIR}/includes/KDE/${_file}) |
paul@0 | 35 | +endmacro() |
paul@0 | 36 | + |
paul@0 | 37 | +create_header(KCalendarSystem date kcalendarsystem.h) |
paul@0 | 38 | +create_header(KConfig config kconfig.h) |
paul@0 | 39 | +create_header(KCodecs text kcodecs.h) |
paul@0 | 40 | +create_header(KConfigGroup config kconfiggroup.h) |
paul@0 | 41 | +create_header(KDateTime date kdatetime.h) |
paul@0 | 42 | +create_header(KDebug io kdebug.h) |
paul@0 | 43 | +create_header(KGlobal kernel kglobal.h) |
paul@0 | 44 | +create_header(KJob jobs kjob.h) |
paul@0 | 45 | +create_header(KLocale localization klocale.h) |
paul@0 | 46 | +create_header(KMimeType services kmimetype.h) |
paul@0 | 47 | +create_header(KRandom util krandom.h) |
paul@0 | 48 | +create_header(KSaveFile io ksavefile.h) |
paul@0 | 49 | +create_header(KStandardDirs kernel kstandarddirs.h) |
paul@0 | 50 | +create_header(KSystemTimeZone date ksystemtimezone.h) |
paul@0 | 51 | +create_header(KTemporaryFile io ktemporaryfile.h) |
paul@0 | 52 | +create_header(KTimeZone date ktimezone.h) |
paul@0 | 53 | +create_header(KUrl io kurl.h) |
paul@0 | 54 | +create_header(KLocalizedString localization klocalizedstring.h) |
paul@0 | 55 | + |
paul@0 | 56 | +install_headers(${CMAKE_CURRENT_BINARY_DIR}/KDE) |
paul@0 | 57 | diff --git a/kdecore/includes/config-CamelCaseInclude.cmake b/kdecore/includes/config-CamelCaseInclude.cmake |
paul@0 | 58 | new file mode 100644 |
paul@0 | 59 | index 0000000..b6bb3e9 |
paul@0 | 60 | --- /dev/null |
paul@0 | 61 | +++ b/kdecore/includes/config-CamelCaseInclude.cmake |
paul@0 | 62 | @@ -0,0 +1,2 @@ |
paul@0 | 63 | +#include "${CAMELCASE_INCLUDE_PATH}" |
paul@0 | 64 | + |
paul@0 | 65 | diff --git a/kdecore/network/ktcpsocket.cpp b/kdecore/network/ktcpsocket.cpp |
paul@0 | 66 | index 17b84d1..cdffccf 100644 |
paul@0 | 67 | --- a/kdecore/network/ktcpsocket.cpp |
paul@0 | 68 | +++ b/kdecore/network/ktcpsocket.cpp |
paul@0 | 69 | @@ -63,7 +63,12 @@ static QSsl::SslProtocol qSslProtocolFromK(KTcpSocket::SslVersion sslVersion) |
paul@0 | 70 | return QSsl::AnyProtocol; |
paul@0 | 71 | } |
paul@0 | 72 | //does it contain any valid protocol? |
paul@0 | 73 | - if (!(sslVersion & (KTcpSocket::SslV2 | KTcpSocket::SslV3 | KTcpSocket::TlsV1))) { |
paul@0 | 74 | + KTcpSocket::SslVersions validVersions (KTcpSocket::SslV2 | KTcpSocket::SslV3 | KTcpSocket::TlsV1); |
paul@0 | 75 | +#if QT_VERSION >= 0x040800 |
paul@0 | 76 | + validVersions |= KTcpSocket::TlsV1SslV3; |
paul@0 | 77 | + validVersions |= KTcpSocket::SecureProtocols; |
paul@0 | 78 | +#endif |
paul@0 | 79 | + if (!(sslVersion & validVersions)) { |
paul@0 | 80 | return QSsl::UnknownProtocol; |
paul@0 | 81 | } |
paul@0 | 82 | |
paul@0 | 83 | @@ -316,6 +321,8 @@ public: |
paul@0 | 84 | return KTcpSocket::NetworkError; |
paul@0 | 85 | case QAbstractSocket::UnsupportedSocketOperationError: |
paul@0 | 86 | return KTcpSocket::UnsupportedSocketOperationError; |
paul@0 | 87 | + case QAbstractSocket::SslHandshakeFailedError: |
paul@0 | 88 | + return KTcpSocket::SslHandshakeFailedError; |
paul@0 | 89 | case QAbstractSocket::DatagramTooLargeError: |
paul@0 | 90 | //we don't do UDP |
paul@0 | 91 | case QAbstractSocket::AddressInUseError: |
paul@0 | 92 | diff --git a/kdecore/network/ktcpsocket.h b/kdecore/network/ktcpsocket.h |
paul@0 | 93 | index 58dfa2c..c281b3e 100644 |
paul@0 | 94 | --- a/kdecore/network/ktcpsocket.h |
paul@0 | 95 | +++ b/kdecore/network/ktcpsocket.h |
paul@0 | 96 | @@ -175,7 +175,8 @@ public: |
paul@0 | 97 | SocketResourceError, |
paul@0 | 98 | SocketTimeoutError, |
paul@0 | 99 | NetworkError, |
paul@0 | 100 | - UnsupportedSocketOperationError |
paul@0 | 101 | + UnsupportedSocketOperationError, |
paul@0 | 102 | + SslHandshakeFailedError |
paul@0 | 103 | }; |
paul@0 | 104 | /* |
paul@0 | 105 | The following is based on reading the OpenSSL interface code of both QSslSocket |
paul@0 | 106 | diff --git a/kimap/CMakeLists.txt b/kimap/CMakeLists.txt |
paul@0 | 107 | index e8a7b79..978c5ac 100644 |
paul@0 | 108 | --- a/kimap/CMakeLists.txt |
paul@0 | 109 | +++ b/kimap/CMakeLists.txt |
paul@0 | 110 | @@ -41,7 +41,12 @@ include_directories(${QT_INCLUDES}) |
paul@0 | 111 | #include(GenerateExportHeader) |
paul@0 | 112 | |
paul@0 | 113 | |
paul@0 | 114 | -include_directories( ../kdecore ../ ${CMAKE_CURRENT_BINARY_DIR}) |
paul@0 | 115 | +include_directories( ../kdecore |
paul@0 | 116 | + ${CMAKE_CURRENT_BINARY_DIR}/../kdecore/includes/includes |
paul@0 | 117 | + ${CMAKE_CURRENT_BINARY_DIR}/../kdecore/includes/includes/KDE |
paul@0 | 118 | + ../ |
paul@0 | 119 | + ${CMAKE_CURRENT_BINARY_DIR} |
paul@0 | 120 | +) |
paul@0 | 121 | |
paul@0 | 122 | |
paul@0 | 123 | |
paul@0 | 124 | diff --git a/kimap/acl.cpp b/kimap/acl.cpp |
paul@0 | 125 | index 980538b..d0bf3e2 100644 |
paul@0 | 126 | --- a/kimap/acl.cpp |
paul@0 | 127 | +++ b/kimap/acl.cpp |
paul@0 | 128 | @@ -21,7 +21,7 @@ |
paul@0 | 129 | |
paul@0 | 130 | #include <QtCore/QByteArray> |
paul@0 | 131 | #include <QtCore/QMap> |
paul@0 | 132 | -#include <kglobal.h> |
paul@0 | 133 | +#include <KDE/KGlobal> |
paul@0 | 134 | |
paul@0 | 135 | namespace KIMAP { |
paul@0 | 136 | namespace Acl { |
paul@0 | 137 | @@ -29,8 +29,7 @@ namespace Acl { |
paul@0 | 138 | class RightsMap |
paul@0 | 139 | { |
paul@0 | 140 | public: |
paul@0 | 141 | - RightsMap() |
paul@0 | 142 | - { |
paul@0 | 143 | + RightsMap() { |
paul@0 | 144 | map['l'] = Lookup; |
paul@0 | 145 | map['r'] = Read; |
paul@0 | 146 | map['s'] = KeepSeen; |
paul@0 | 147 | @@ -60,7 +59,7 @@ class RightsMap |
paul@0 | 148 | QMap<char, Right> map; |
paul@0 | 149 | }; |
paul@0 | 150 | |
paul@0 | 151 | -Q_GLOBAL_STATIC(RightsMap, globalRights) |
paul@0 | 152 | +K_GLOBAL_STATIC( RightsMap, globalRights ) |
paul@0 | 153 | |
paul@0 | 154 | } |
paul@0 | 155 | } |
paul@0 | 156 | @@ -69,17 +68,18 @@ KIMAP::Acl::Rights KIMAP::Acl::rightsFromString( const QByteArray &string ) |
paul@0 | 157 | { |
paul@0 | 158 | Rights result; |
paul@0 | 159 | |
paul@0 | 160 | - if ( string.isEmpty() ) |
paul@0 | 161 | + if ( string.isEmpty() ) { |
paul@0 | 162 | return result; |
paul@0 | 163 | + } |
paul@0 | 164 | |
paul@0 | 165 | int pos = 0; |
paul@0 | 166 | - if ( string[0] == '+' || string[0]== '-') { // Skip modifier if any |
paul@0 | 167 | + if ( string[0] == '+' || string[0] == '-' ) { // Skip modifier if any |
paul@0 | 168 | pos++; |
paul@0 | 169 | } |
paul@0 | 170 | |
paul@0 | 171 | for ( int i = pos; i < string.size(); i++ ) { |
paul@0 | 172 | - if ( globalRights()->map.contains( string[i] ) ) { |
paul@0 | 173 | - result|= globalRights()->map[string[i]]; |
paul@0 | 174 | + if ( globalRights->map.contains( string[i] ) ) { |
paul@0 | 175 | + result|= globalRights->map[string[i]]; |
paul@0 | 176 | } |
paul@0 | 177 | } |
paul@0 | 178 | |
paul@0 | 179 | @@ -90,9 +90,9 @@ QByteArray KIMAP::Acl::rightsToString( Rights rights ) |
paul@0 | 180 | { |
paul@0 | 181 | QByteArray result; |
paul@0 | 182 | |
paul@0 | 183 | - for ( int right = Lookup; right<=Custom9; right<<=1 ) { |
paul@0 | 184 | + for ( int right = Lookup; right <= Custom9; right <<= 1 ) { |
paul@0 | 185 | if ( rights & right ) { |
paul@0 | 186 | - result+= globalRights()->map.key( (Right)right ); |
paul@0 | 187 | + result += globalRights->map.key( (Right)right ); |
paul@0 | 188 | } |
paul@0 | 189 | } |
paul@0 | 190 | |
paul@0 | 191 | @@ -125,3 +125,5 @@ KIMAP::Acl::Rights KIMAP::Acl::denormalizedRights( KIMAP::Acl::Rights rights ) |
paul@0 | 192 | return denormalized; |
paul@0 | 193 | } |
paul@0 | 194 | |
paul@0 | 195 | +#include "acl.moc" |
paul@0 | 196 | + |
paul@0 | 197 | diff --git a/kimap/acl.h b/kimap/acl.h |
paul@0 | 198 | index 40e738f..2df610c 100644 |
paul@0 | 199 | --- a/kimap/acl.h |
paul@0 | 200 | +++ b/kimap/acl.h |
paul@0 | 201 | @@ -89,17 +89,19 @@ enum Right { |
paul@0 | 202 | Custom9 = 0x800000 /**< Server-specific right 9 */ |
paul@0 | 203 | }; |
paul@0 | 204 | |
paul@0 | 205 | -Q_DECLARE_FLAGS(Rights, Right) |
paul@0 | 206 | +Q_DECLARE_FLAGS( Rights, Right ) |
paul@0 | 207 | |
paul@0 | 208 | /** |
paul@0 | 209 | * Returns a rights mask that has no obsolete members anymore, i.e. obsolete flags are removed and |
paul@0 | 210 | * replaced by their successors. |
paul@0 | 211 | + * @param rights set of #Rights flags to normalize |
paul@0 | 212 | * @since 4.6 |
paul@0 | 213 | */ |
paul@0 | 214 | KIMAP_EXPORT Rights normalizedRights( Rights rights ); |
paul@0 | 215 | |
paul@0 | 216 | /** |
paul@0 | 217 | * Returns a rights mask that contains both obsolete and new flags if one of them is set. |
paul@0 | 218 | + * @param rights set of #Rights flags to augment |
paul@0 | 219 | * @since 4.6 |
paul@0 | 220 | */ |
paul@0 | 221 | KIMAP_EXPORT Rights denormalizedRights( Rights rights ); |
paul@0 | 222 | diff --git a/kimap/acljobbase.cpp b/kimap/acljobbase.cpp |
paul@0 | 223 | index 9bfe29a..5df4420 100644 |
paul@0 | 224 | --- a/kimap/acljobbase.cpp |
paul@0 | 225 | +++ b/kimap/acljobbase.cpp |
paul@0 | 226 | @@ -22,8 +22,8 @@ |
paul@0 | 227 | #include "message_p.h" |
paul@0 | 228 | #include "session_p.h" |
paul@0 | 229 | |
paul@0 | 230 | -#include <klocale.h> |
paul@0 | 231 | -#include <kdebug.h> |
paul@0 | 232 | +#include <KDE/KLocalizedString> |
paul@0 | 233 | +#include <KDE/KDebug> |
paul@0 | 234 | |
paul@0 | 235 | using namespace KIMAP; |
paul@0 | 236 | |
paul@0 | 237 | @@ -56,7 +56,7 @@ void AclJobBasePrivate::setRights(const QByteArray& rights) |
paul@0 | 238 | break; |
paul@0 | 239 | } |
paul@0 | 240 | |
paul@0 | 241 | - rightList = Acl::rightsFromString(rights); |
paul@0 | 242 | + rightList = Acl::rightsFromString( rights ); |
paul@0 | 243 | } |
paul@0 | 244 | |
paul@0 | 245 | void AclJobBasePrivate::setRights(AclJobBase::AclModifier _modifier, Acl::Rights rights) |
paul@0 | 246 | @@ -66,16 +66,13 @@ void AclJobBasePrivate::setRights(AclJobBase::AclModifier _modifier, Acl::Rights |
paul@0 | 247 | rightList|= rights; |
paul@0 | 248 | } |
paul@0 | 249 | |
paul@0 | 250 | - |
paul@0 | 251 | - |
paul@0 | 252 | AclJobBase::AclJobBase( Session *session ) |
paul@0 | 253 | - : Job( *new AclJobBasePrivate(session, i18n("AclJobBase")) ) |
paul@0 | 254 | + : Job( *new AclJobBasePrivate( session, i18n( "AclJobBase" ) ) ) |
paul@0 | 255 | { |
paul@0 | 256 | } |
paul@0 | 257 | |
paul@0 | 258 | - |
paul@0 | 259 | AclJobBase::AclJobBase( JobPrivate &dd ) |
paul@0 | 260 | - : Job(dd) |
paul@0 | 261 | + : Job( dd ) |
paul@0 | 262 | { |
paul@0 | 263 | |
paul@0 | 264 | } |
paul@0 | 265 | @@ -84,17 +81,17 @@ AclJobBase::~AclJobBase() |
paul@0 | 266 | { |
paul@0 | 267 | } |
paul@0 | 268 | |
paul@0 | 269 | - |
paul@0 | 270 | void AclJobBase::setMailBox( const QString &mailBox ) |
paul@0 | 271 | { |
paul@0 | 272 | - Q_D(AclJobBase); |
paul@0 | 273 | + Q_D( AclJobBase ); |
paul@0 | 274 | d->mailBox = mailBox; |
paul@0 | 275 | } |
paul@0 | 276 | |
paul@0 | 277 | QString AclJobBase::mailBox() const |
paul@0 | 278 | { |
paul@0 | 279 | - Q_D(const AclJobBase); |
paul@0 | 280 | + Q_D( const AclJobBase ); |
paul@0 | 281 | return d->mailBox; |
paul@0 | 282 | } |
paul@0 | 283 | |
paul@0 | 284 | -#include "acljobbase.moc" |
paul@0 | 285 | \ No newline at end of file |
paul@0 | 286 | +#include "acljobbase.moc" |
paul@0 | 287 | + |
paul@0 | 288 | diff --git a/kimap/acljobbase.h b/kimap/acljobbase.h |
paul@0 | 289 | index 39616a2..fe67319 100644 |
paul@0 | 290 | --- a/kimap/acljobbase.h |
paul@0 | 291 | +++ b/kimap/acljobbase.h |
paul@0 | 292 | @@ -43,7 +43,7 @@ class AclJobBasePrivate; |
paul@0 | 293 | class KIMAP_EXPORT AclJobBase : public Job |
paul@0 | 294 | { |
paul@0 | 295 | Q_OBJECT |
paul@0 | 296 | - Q_DECLARE_PRIVATE(AclJobBase) |
paul@0 | 297 | + Q_DECLARE_PRIVATE( AclJobBase ) |
paul@0 | 298 | |
paul@0 | 299 | friend class SessionPrivate; |
paul@0 | 300 | |
paul@0 | 301 | diff --git a/kimap/acljobbase_p.h b/kimap/acljobbase_p.h |
paul@0 | 302 | index 7550489..45345bd 100644 |
paul@0 | 303 | --- a/kimap/acljobbase_p.h |
paul@0 | 304 | +++ b/kimap/acljobbase_p.h |
paul@0 | 305 | @@ -23,14 +23,14 @@ |
paul@0 | 306 | #include "acljobbase.h" |
paul@0 | 307 | #include "job_p.h" |
paul@0 | 308 | #include "session.h" |
paul@0 | 309 | -#include <klocale.h> |
paul@0 | 310 | +#include <KDE/KLocalizedString> |
paul@0 | 311 | |
paul@0 | 312 | namespace KIMAP |
paul@0 | 313 | { |
paul@0 | 314 | class AclJobBasePrivate : public JobPrivate |
paul@0 | 315 | { |
paul@0 | 316 | public: |
paul@0 | 317 | - AclJobBasePrivate( Session *session, const QString& name ) : JobPrivate(session, name), rightList(Acl::None), modifier(AclJobBase::Change) |
paul@0 | 318 | + AclJobBasePrivate( Session *session, const QString& name ) : JobPrivate( session, name ), rightList( Acl::None ), modifier( AclJobBase::Change ) |
paul@0 | 319 | { |
paul@0 | 320 | } |
paul@0 | 321 | ~AclJobBasePrivate() { } |
paul@0 | 322 | diff --git a/kimap/appendjob.cpp b/kimap/appendjob.cpp |
paul@0 | 323 | index b0e5c83..bda3904 100644 |
paul@0 | 324 | --- a/kimap/appendjob.cpp |
paul@0 | 325 | +++ b/kimap/appendjob.cpp |
paul@0 | 326 | @@ -19,7 +19,7 @@ |
paul@0 | 327 | |
paul@0 | 328 | #include "appendjob.h" |
paul@0 | 329 | |
paul@0 | 330 | -#include <klocale.h> |
paul@0 | 331 | +#include <KDE/KLocalizedString> |
paul@0 | 332 | |
paul@0 | 333 | #include "job_p.h" |
paul@0 | 334 | #include "message_p.h" |
paul@0 | 335 | @@ -44,7 +44,7 @@ namespace KIMAP |
paul@0 | 336 | using namespace KIMAP; |
paul@0 | 337 | |
paul@0 | 338 | AppendJob::AppendJob( Session *session ) |
paul@0 | 339 | - : Job( *new AppendJobPrivate(session, i18n("Append")) ) |
paul@0 | 340 | + : Job( *new AppendJobPrivate( session, i18n( "Append" ) ) ) |
paul@0 | 341 | { |
paul@0 | 342 | } |
paul@0 | 343 | |
paul@0 | 344 | @@ -54,73 +54,73 @@ AppendJob::~AppendJob() |
paul@0 | 345 | |
paul@0 | 346 | void AppendJob::setMailBox( const QString &mailBox ) |
paul@0 | 347 | { |
paul@0 | 348 | - Q_D(AppendJob); |
paul@0 | 349 | + Q_D( AppendJob ); |
paul@0 | 350 | d->mailBox = mailBox; |
paul@0 | 351 | } |
paul@0 | 352 | |
paul@0 | 353 | QString AppendJob::mailBox() const |
paul@0 | 354 | { |
paul@0 | 355 | - Q_D(const AppendJob); |
paul@0 | 356 | + Q_D( const AppendJob ); |
paul@0 | 357 | return d->mailBox; |
paul@0 | 358 | } |
paul@0 | 359 | |
paul@0 | 360 | void AppendJob::setFlags( const QList<QByteArray> &flags) |
paul@0 | 361 | { |
paul@0 | 362 | - Q_D(AppendJob); |
paul@0 | 363 | + Q_D( AppendJob ); |
paul@0 | 364 | d->flags = flags; |
paul@0 | 365 | } |
paul@0 | 366 | |
paul@0 | 367 | QList<QByteArray> AppendJob::flags() const |
paul@0 | 368 | { |
paul@0 | 369 | - Q_D(const AppendJob); |
paul@0 | 370 | + Q_D( const AppendJob ); |
paul@0 | 371 | return d->flags; |
paul@0 | 372 | } |
paul@0 | 373 | |
paul@0 | 374 | void AppendJob::setContent( const QByteArray &content ) |
paul@0 | 375 | { |
paul@0 | 376 | - Q_D(AppendJob); |
paul@0 | 377 | + Q_D( AppendJob ); |
paul@0 | 378 | d->content = content; |
paul@0 | 379 | } |
paul@0 | 380 | |
paul@0 | 381 | QByteArray AppendJob::content() const |
paul@0 | 382 | { |
paul@0 | 383 | - Q_D(const AppendJob); |
paul@0 | 384 | + Q_D( const AppendJob ); |
paul@0 | 385 | return d->content; |
paul@0 | 386 | } |
paul@0 | 387 | |
paul@0 | 388 | qint64 AppendJob::uid() const |
paul@0 | 389 | { |
paul@0 | 390 | - Q_D(const AppendJob); |
paul@0 | 391 | + Q_D( const AppendJob ); |
paul@0 | 392 | return d->uid; |
paul@0 | 393 | } |
paul@0 | 394 | |
paul@0 | 395 | void AppendJob::doStart() |
paul@0 | 396 | { |
paul@0 | 397 | - Q_D(AppendJob); |
paul@0 | 398 | + Q_D( AppendJob ); |
paul@0 | 399 | |
paul@0 | 400 | - QByteArray parameters = '\"'+KIMAP::encodeImapFolderName( d->mailBox.toUtf8() )+'\"'; |
paul@0 | 401 | + QByteArray parameters = '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"'; |
paul@0 | 402 | |
paul@0 | 403 | if ( !d->flags.isEmpty() ) { |
paul@0 | 404 | - parameters+=" ("; |
paul@0 | 405 | + parameters += " ("; |
paul@0 | 406 | foreach ( const QByteArray &flag, d->flags ) { |
paul@0 | 407 | - parameters+= flag+' '; |
paul@0 | 408 | + parameters+= flag + ' '; |
paul@0 | 409 | } |
paul@0 | 410 | - parameters.chop(1); |
paul@0 | 411 | - parameters+=')'; |
paul@0 | 412 | + parameters.chop( 1 ); |
paul@0 | 413 | + parameters += ')'; |
paul@0 | 414 | } |
paul@0 | 415 | |
paul@0 | 416 | - parameters+=" {"+QByteArray::number(d->content.size())+'}'; |
paul@0 | 417 | + parameters += " {" + QByteArray::number( d->content.size() ) + '}'; |
paul@0 | 418 | |
paul@0 | 419 | d->tags << d->sessionInternal()->sendCommand( "APPEND", parameters ); |
paul@0 | 420 | } |
paul@0 | 421 | |
paul@0 | 422 | void AppendJob::handleResponse( const Message &response ) |
paul@0 | 423 | { |
paul@0 | 424 | - Q_D(AppendJob); |
paul@0 | 425 | + Q_D( AppendJob ); |
paul@0 | 426 | |
paul@0 | 427 | for ( QList<Message::Part>::ConstIterator it = response.responseCode.begin(); |
paul@0 | 428 | it != response.responseCode.end(); ++it ) { |
paul@0 | 429 | - if ( it->toString()=="APPENDUID" ) { |
paul@0 | 430 | + if ( it->toString() == "APPENDUID" ) { |
paul@0 | 431 | it = it + 2; |
paul@0 | 432 | if ( it != response.responseCode.end() ) { |
paul@0 | 433 | d->uid = it->toString().toLongLong(); |
paul@0 | 434 | @@ -129,7 +129,7 @@ void AppendJob::handleResponse( const Message &response ) |
paul@0 | 435 | } |
paul@0 | 436 | } |
paul@0 | 437 | |
paul@0 | 438 | - if (handleErrorReplies(response) == NotHandled ) { |
paul@0 | 439 | + if ( handleErrorReplies( response ) == NotHandled ) { |
paul@0 | 440 | if ( response.content[0].toString() == "+" ) { |
paul@0 | 441 | d->sessionInternal()->sendData( d->content ); |
paul@0 | 442 | } |
paul@0 | 443 | @@ -137,3 +137,4 @@ void AppendJob::handleResponse( const Message &response ) |
paul@0 | 444 | } |
paul@0 | 445 | |
paul@0 | 446 | #include "appendjob.moc" |
paul@0 | 447 | + |
paul@0 | 448 | diff --git a/kimap/appendjob.h b/kimap/appendjob.h |
paul@0 | 449 | index 9fdc2bd..d01f4f2 100644 |
paul@0 | 450 | --- a/kimap/appendjob.h |
paul@0 | 451 | +++ b/kimap/appendjob.h |
paul@0 | 452 | @@ -42,7 +42,7 @@ class AppendJobPrivate; |
paul@0 | 453 | class KIMAP_EXPORT AppendJob : public Job |
paul@0 | 454 | { |
paul@0 | 455 | Q_OBJECT |
paul@0 | 456 | - Q_DECLARE_PRIVATE(AppendJob) |
paul@0 | 457 | + Q_DECLARE_PRIVATE( AppendJob ) |
paul@0 | 458 | |
paul@0 | 459 | friend class SessionPrivate; |
paul@0 | 460 | |
paul@0 | 461 | diff --git a/kimap/capabilitiesjob.cpp b/kimap/capabilitiesjob.cpp |
paul@0 | 462 | index b07e1b9..a9b52dc 100644 |
paul@0 | 463 | --- a/kimap/capabilitiesjob.cpp |
paul@0 | 464 | +++ b/kimap/capabilitiesjob.cpp |
paul@0 | 465 | @@ -19,7 +19,7 @@ |
paul@0 | 466 | |
paul@0 | 467 | #include "capabilitiesjob.h" |
paul@0 | 468 | |
paul@0 | 469 | -#include <klocale.h> |
paul@0 | 470 | +#include <KDE/KLocalizedString> |
paul@0 | 471 | |
paul@0 | 472 | #include "job_p.h" |
paul@0 | 473 | #include "message_p.h" |
paul@0 | 474 | @@ -30,7 +30,7 @@ namespace KIMAP |
paul@0 | 475 | class CapabilitiesJobPrivate : public JobPrivate |
paul@0 | 476 | { |
paul@0 | 477 | public: |
paul@0 | 478 | - CapabilitiesJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { } |
paul@0 | 479 | + CapabilitiesJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { } |
paul@0 | 480 | ~CapabilitiesJobPrivate() { } |
paul@0 | 481 | |
paul@0 | 482 | QStringList capabilities; |
paul@0 | 483 | @@ -40,7 +40,7 @@ namespace KIMAP |
paul@0 | 484 | using namespace KIMAP; |
paul@0 | 485 | |
paul@0 | 486 | CapabilitiesJob::CapabilitiesJob( Session *session ) |
paul@0 | 487 | - : Job( *new CapabilitiesJobPrivate(session, i18n("Capabilities")) ) |
paul@0 | 488 | + : Job( *new CapabilitiesJobPrivate( session, i18n( "Capabilities" ) ) ) |
paul@0 | 489 | { |
paul@0 | 490 | } |
paul@0 | 491 | |
paul@0 | 492 | @@ -50,29 +50,30 @@ CapabilitiesJob::~CapabilitiesJob() |
paul@0 | 493 | |
paul@0 | 494 | QStringList CapabilitiesJob::capabilities() const |
paul@0 | 495 | { |
paul@0 | 496 | - Q_D(const CapabilitiesJob); |
paul@0 | 497 | + Q_D( const CapabilitiesJob ); |
paul@0 | 498 | return d->capabilities; |
paul@0 | 499 | } |
paul@0 | 500 | |
paul@0 | 501 | void CapabilitiesJob::doStart() |
paul@0 | 502 | { |
paul@0 | 503 | - Q_D(CapabilitiesJob); |
paul@0 | 504 | + Q_D( CapabilitiesJob ); |
paul@0 | 505 | d->tags << d->sessionInternal()->sendCommand( "CAPABILITY" ); |
paul@0 | 506 | } |
paul@0 | 507 | |
paul@0 | 508 | void CapabilitiesJob::handleResponse( const Message &response ) |
paul@0 | 509 | { |
paul@0 | 510 | |
paul@0 | 511 | - Q_D(CapabilitiesJob); |
paul@0 | 512 | - if (handleErrorReplies(response) == NotHandled) { |
paul@0 | 513 | - if ( response.content.size() >= 2 |
paul@0 | 514 | - && response.content[1].toString()=="CAPABILITY" ) { |
paul@0 | 515 | - for (int i=2; i<response.content.size(); ++i) { |
paul@0 | 516 | + Q_D( CapabilitiesJob ); |
paul@0 | 517 | + if ( handleErrorReplies( response ) == NotHandled ) { |
paul@0 | 518 | + if ( response.content.size() >= 2 && |
paul@0 | 519 | + response.content[1].toString() == "CAPABILITY" ) { |
paul@0 | 520 | + for ( int i = 2; i < response.content.size(); ++i ) { |
paul@0 | 521 | d->capabilities << response.content[i].toString().toUpper(); |
paul@0 | 522 | } |
paul@0 | 523 | - emit capabilitiesReceived(d->capabilities); |
paul@0 | 524 | + emit capabilitiesReceived( d->capabilities ); |
paul@0 | 525 | } |
paul@0 | 526 | } |
paul@0 | 527 | } |
paul@0 | 528 | |
paul@0 | 529 | #include "capabilitiesjob.moc" |
paul@0 | 530 | + |
paul@0 | 531 | diff --git a/kimap/capabilitiesjob.h b/kimap/capabilitiesjob.h |
paul@0 | 532 | index 0306f26..42ab3b1 100644 |
paul@0 | 533 | --- a/kimap/capabilitiesjob.h |
paul@0 | 534 | +++ b/kimap/capabilitiesjob.h |
paul@0 | 535 | @@ -45,7 +45,7 @@ class CapabilitiesJobPrivate; |
paul@0 | 536 | class KIMAP_EXPORT CapabilitiesJob : public Job |
paul@0 | 537 | { |
paul@0 | 538 | Q_OBJECT |
paul@0 | 539 | - Q_DECLARE_PRIVATE(CapabilitiesJob) |
paul@0 | 540 | + Q_DECLARE_PRIVATE( CapabilitiesJob ) |
paul@0 | 541 | |
paul@0 | 542 | friend class SessionPrivate; |
paul@0 | 543 | |
paul@0 | 544 | diff --git a/kimap/closejob.cpp b/kimap/closejob.cpp |
paul@0 | 545 | index ea6416f..a59f386 100644 |
paul@0 | 546 | --- a/kimap/closejob.cpp |
paul@0 | 547 | +++ b/kimap/closejob.cpp |
paul@0 | 548 | @@ -19,7 +19,7 @@ |
paul@0 | 549 | |
paul@0 | 550 | #include "closejob.h" |
paul@0 | 551 | |
paul@0 | 552 | -#include <klocale.h> |
paul@0 | 553 | +#include <KDE/KLocalizedString> |
paul@0 | 554 | |
paul@0 | 555 | #include "job_p.h" |
paul@0 | 556 | #include "message_p.h" |
paul@0 | 557 | @@ -30,7 +30,7 @@ namespace KIMAP |
paul@0 | 558 | class CloseJobPrivate : public JobPrivate |
paul@0 | 559 | { |
paul@0 | 560 | public: |
paul@0 | 561 | - CloseJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { } |
paul@0 | 562 | + CloseJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { } |
paul@0 | 563 | ~CloseJobPrivate() { } |
paul@0 | 564 | }; |
paul@0 | 565 | } |
paul@0 | 566 | @@ -38,7 +38,7 @@ namespace KIMAP |
paul@0 | 567 | using namespace KIMAP; |
paul@0 | 568 | |
paul@0 | 569 | CloseJob::CloseJob( Session *session ) |
paul@0 | 570 | - : Job( *new CloseJobPrivate(session, i18n("Close")) ) |
paul@0 | 571 | + : Job( *new CloseJobPrivate( session, i18n( "Close" ) ) ) |
paul@0 | 572 | { |
paul@0 | 573 | } |
paul@0 | 574 | |
paul@0 | 575 | @@ -48,8 +48,9 @@ CloseJob::~CloseJob() |
paul@0 | 576 | |
paul@0 | 577 | void CloseJob::doStart() |
paul@0 | 578 | { |
paul@0 | 579 | - Q_D(CloseJob); |
paul@0 | 580 | + Q_D( CloseJob ); |
paul@0 | 581 | d->tags << d->sessionInternal()->sendCommand( "CLOSE" ); |
paul@0 | 582 | } |
paul@0 | 583 | |
paul@0 | 584 | #include "closejob.moc" |
paul@0 | 585 | + |
paul@0 | 586 | diff --git a/kimap/closejob.h b/kimap/closejob.h |
paul@0 | 587 | index 3cadc72..35d64bd 100644 |
paul@0 | 588 | --- a/kimap/closejob.h |
paul@0 | 589 | +++ b/kimap/closejob.h |
paul@0 | 590 | @@ -52,7 +52,7 @@ class CloseJobPrivate; |
paul@0 | 591 | class KIMAP_EXPORT CloseJob : public Job |
paul@0 | 592 | { |
paul@0 | 593 | Q_OBJECT |
paul@0 | 594 | - Q_DECLARE_PRIVATE(CloseJob) |
paul@0 | 595 | + Q_DECLARE_PRIVATE( CloseJob ) |
paul@0 | 596 | |
paul@0 | 597 | friend class SessionPrivate; |
paul@0 | 598 | |
paul@0 | 599 | diff --git a/kimap/copyjob.cpp b/kimap/copyjob.cpp |
paul@0 | 600 | index 05f2efb..a07d509 100644 |
paul@0 | 601 | --- a/kimap/copyjob.cpp |
paul@0 | 602 | +++ b/kimap/copyjob.cpp |
paul@0 | 603 | @@ -19,8 +19,8 @@ |
paul@0 | 604 | |
paul@0 | 605 | #include "copyjob.h" |
paul@0 | 606 | |
paul@0 | 607 | -#include <klocale.h> |
paul@0 | 608 | -#include <kdebug.h> |
paul@0 | 609 | +#include <KDE/KLocalizedString> |
paul@0 | 610 | +#include <KDE/KDebug> |
paul@0 | 611 | |
paul@0 | 612 | #include "job_p.h" |
paul@0 | 613 | #include "message_p.h" |
paul@0 | 614 | @@ -34,7 +34,7 @@ namespace KIMAP |
paul@0 | 615 | class CopyJobPrivate : public JobPrivate |
paul@0 | 616 | { |
paul@0 | 617 | public: |
paul@0 | 618 | - CopyJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { } |
paul@0 | 619 | + CopyJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { } |
paul@0 | 620 | ~CopyJobPrivate() { } |
paul@0 | 621 | |
paul@0 | 622 | QString mailBox; |
paul@0 | 623 | @@ -47,9 +47,9 @@ namespace KIMAP |
paul@0 | 624 | using namespace KIMAP; |
paul@0 | 625 | |
paul@0 | 626 | CopyJob::CopyJob( Session *session ) |
paul@0 | 627 | - : Job( *new CopyJobPrivate(session, i18n("Copy")) ) |
paul@0 | 628 | + : Job( *new CopyJobPrivate( session, i18n( "Copy" ) ) ) |
paul@0 | 629 | { |
paul@0 | 630 | - Q_D(CopyJob); |
paul@0 | 631 | + Q_D( CopyJob ); |
paul@0 | 632 | d->uidBased = false; |
paul@0 | 633 | } |
paul@0 | 634 | |
paul@0 | 635 | @@ -59,53 +59,52 @@ CopyJob::~CopyJob() |
paul@0 | 636 | |
paul@0 | 637 | void CopyJob::setMailBox( const QString &mailBox ) |
paul@0 | 638 | { |
paul@0 | 639 | - Q_D(CopyJob); |
paul@0 | 640 | + Q_D( CopyJob ); |
paul@0 | 641 | d->mailBox = mailBox; |
paul@0 | 642 | } |
paul@0 | 643 | |
paul@0 | 644 | QString CopyJob::mailBox() const |
paul@0 | 645 | { |
paul@0 | 646 | - Q_D(const CopyJob); |
paul@0 | 647 | + Q_D( const CopyJob ); |
paul@0 | 648 | return d->mailBox; |
paul@0 | 649 | } |
paul@0 | 650 | |
paul@0 | 651 | void CopyJob::setSequenceSet( const ImapSet &set ) |
paul@0 | 652 | { |
paul@0 | 653 | - Q_D(CopyJob); |
paul@0 | 654 | + Q_D( CopyJob ); |
paul@0 | 655 | d->set = set; |
paul@0 | 656 | } |
paul@0 | 657 | |
paul@0 | 658 | ImapSet CopyJob::sequenceSet() const |
paul@0 | 659 | { |
paul@0 | 660 | - Q_D(const CopyJob); |
paul@0 | 661 | + Q_D( const CopyJob ); |
paul@0 | 662 | return d->set; |
paul@0 | 663 | } |
paul@0 | 664 | |
paul@0 | 665 | - |
paul@0 | 666 | void CopyJob::setUidBased( bool uidBased ) |
paul@0 | 667 | { |
paul@0 | 668 | - Q_D(CopyJob); |
paul@0 | 669 | + Q_D( CopyJob ); |
paul@0 | 670 | d->uidBased = uidBased; |
paul@0 | 671 | } |
paul@0 | 672 | |
paul@0 | 673 | bool CopyJob::isUidBased() const |
paul@0 | 674 | { |
paul@0 | 675 | - Q_D(const CopyJob); |
paul@0 | 676 | + Q_D( const CopyJob ); |
paul@0 | 677 | return d->uidBased; |
paul@0 | 678 | } |
paul@0 | 679 | |
paul@0 | 680 | ImapSet CopyJob::resultingUids() const |
paul@0 | 681 | { |
paul@0 | 682 | - Q_D(const CopyJob); |
paul@0 | 683 | + Q_D( const CopyJob ); |
paul@0 | 684 | return d->resultingUids; |
paul@0 | 685 | } |
paul@0 | 686 | |
paul@0 | 687 | void CopyJob::doStart() |
paul@0 | 688 | { |
paul@0 | 689 | - Q_D(CopyJob); |
paul@0 | 690 | + Q_D( CopyJob ); |
paul@0 | 691 | |
paul@0 | 692 | QByteArray parameters = d->set.toImapSequenceSet()+' '; |
paul@0 | 693 | - parameters+= '\"'+KIMAP::encodeImapFolderName( d->mailBox.toUtf8() )+'\"'; |
paul@0 | 694 | + parameters += '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"'; |
paul@0 | 695 | |
paul@0 | 696 | QByteArray command = "COPY"; |
paul@0 | 697 | if ( d->uidBased ) { |
paul@0 | 698 | @@ -117,11 +116,11 @@ void CopyJob::doStart() |
paul@0 | 699 | |
paul@0 | 700 | void CopyJob::handleResponse( const Message &response ) |
paul@0 | 701 | { |
paul@0 | 702 | - Q_D(CopyJob); |
paul@0 | 703 | + Q_D( CopyJob ); |
paul@0 | 704 | |
paul@0 | 705 | for ( QList<Message::Part>::ConstIterator it = response.responseCode.begin(); |
paul@0 | 706 | it != response.responseCode.end(); ++it ) { |
paul@0 | 707 | - if ( it->toString()=="COPYUID" ) { |
paul@0 | 708 | + if ( it->toString() == "COPYUID" ) { |
paul@0 | 709 | it = it + 3; |
paul@0 | 710 | if ( it < response.responseCode.end() ) { |
paul@0 | 711 | d->resultingUids = ImapSet::fromImapSequenceSet( it->toString() ); |
paul@0 | 712 | @@ -134,3 +133,4 @@ void CopyJob::handleResponse( const Message &response ) |
paul@0 | 713 | } |
paul@0 | 714 | |
paul@0 | 715 | #include "copyjob.moc" |
paul@0 | 716 | + |
paul@0 | 717 | diff --git a/kimap/copyjob.h b/kimap/copyjob.h |
paul@0 | 718 | index 5e75fdc..c64bcbf 100644 |
paul@0 | 719 | --- a/kimap/copyjob.h |
paul@0 | 720 | +++ b/kimap/copyjob.h |
paul@0 | 721 | @@ -46,7 +46,7 @@ class CopyJobPrivate; |
paul@0 | 722 | class KIMAP_EXPORT CopyJob : public Job |
paul@0 | 723 | { |
paul@0 | 724 | Q_OBJECT |
paul@0 | 725 | - Q_DECLARE_PRIVATE(CopyJob) |
paul@0 | 726 | + Q_DECLARE_PRIVATE( CopyJob ) |
paul@0 | 727 | |
paul@0 | 728 | friend class SessionPrivate; |
paul@0 | 729 | |
paul@0 | 730 | diff --git a/kimap/createjob.cpp b/kimap/createjob.cpp |
paul@0 | 731 | index 6f25e0a..b6d486f 100644 |
paul@0 | 732 | --- a/kimap/createjob.cpp |
paul@0 | 733 | +++ b/kimap/createjob.cpp |
paul@0 | 734 | @@ -19,8 +19,8 @@ |
paul@0 | 735 | |
paul@0 | 736 | #include "createjob.h" |
paul@0 | 737 | |
paul@0 | 738 | -#include <klocale.h> |
paul@0 | 739 | -#include <kdebug.h> |
paul@0 | 740 | +#include <KDE/KLocalizedString> |
paul@0 | 741 | +#include <KDE/KDebug> |
paul@0 | 742 | |
paul@0 | 743 | #include "job_p.h" |
paul@0 | 744 | #include "message_p.h" |
paul@0 | 745 | @@ -32,7 +32,7 @@ namespace KIMAP |
paul@0 | 746 | class CreateJobPrivate : public JobPrivate |
paul@0 | 747 | { |
paul@0 | 748 | public: |
paul@0 | 749 | - CreateJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { } |
paul@0 | 750 | + CreateJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { } |
paul@0 | 751 | ~CreateJobPrivate() { } |
paul@0 | 752 | |
paul@0 | 753 | QString mailBox; |
paul@0 | 754 | @@ -42,7 +42,7 @@ namespace KIMAP |
paul@0 | 755 | using namespace KIMAP; |
paul@0 | 756 | |
paul@0 | 757 | CreateJob::CreateJob( Session *session ) |
paul@0 | 758 | - : Job( *new CreateJobPrivate(session, i18n("Create")) ) |
paul@0 | 759 | + : Job( *new CreateJobPrivate( session, i18n( "Create" ) ) ) |
paul@0 | 760 | { |
paul@0 | 761 | } |
paul@0 | 762 | |
paul@0 | 763 | @@ -52,20 +52,21 @@ CreateJob::~CreateJob() |
paul@0 | 764 | |
paul@0 | 765 | void CreateJob::doStart() |
paul@0 | 766 | { |
paul@0 | 767 | - Q_D(CreateJob); |
paul@0 | 768 | - d->tags << d->sessionInternal()->sendCommand( "CREATE", '\"'+KIMAP::encodeImapFolderName( d->mailBox.toUtf8() )+'\"' ); |
paul@0 | 769 | + Q_D( CreateJob ); |
paul@0 | 770 | + d->tags << d->sessionInternal()->sendCommand( "CREATE", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"' ); |
paul@0 | 771 | } |
paul@0 | 772 | |
paul@0 | 773 | void CreateJob::setMailBox( const QString &mailBox ) |
paul@0 | 774 | { |
paul@0 | 775 | - Q_D(CreateJob); |
paul@0 | 776 | + Q_D( CreateJob ); |
paul@0 | 777 | d->mailBox = mailBox; |
paul@0 | 778 | } |
paul@0 | 779 | |
paul@0 | 780 | QString CreateJob::mailBox() const |
paul@0 | 781 | { |
paul@0 | 782 | - Q_D(const CreateJob); |
paul@0 | 783 | + Q_D( const CreateJob ); |
paul@0 | 784 | return d->mailBox; |
paul@0 | 785 | } |
paul@0 | 786 | |
paul@0 | 787 | #include "createjob.moc" |
paul@0 | 788 | + |
paul@0 | 789 | diff --git a/kimap/createjob.h b/kimap/createjob.h |
paul@0 | 790 | index daab478..9977898 100644 |
paul@0 | 791 | --- a/kimap/createjob.h |
paul@0 | 792 | +++ b/kimap/createjob.h |
paul@0 | 793 | @@ -47,7 +47,7 @@ class CreateJobPrivate; |
paul@0 | 794 | class KIMAP_EXPORT CreateJob : public Job |
paul@0 | 795 | { |
paul@0 | 796 | Q_OBJECT |
paul@0 | 797 | - Q_DECLARE_PRIVATE(CreateJob) |
paul@0 | 798 | + Q_DECLARE_PRIVATE( CreateJob ) |
paul@0 | 799 | |
paul@0 | 800 | friend class SessionPrivate; |
paul@0 | 801 | |
paul@0 | 802 | diff --git a/kimap/deleteacljob.cpp b/kimap/deleteacljob.cpp |
paul@0 | 803 | index b5ea9a9..ca3a206 100644 |
paul@0 | 804 | --- a/kimap/deleteacljob.cpp |
paul@0 | 805 | +++ b/kimap/deleteacljob.cpp |
paul@0 | 806 | @@ -19,8 +19,8 @@ |
paul@0 | 807 | |
paul@0 | 808 | #include "deleteacljob.h" |
paul@0 | 809 | |
paul@0 | 810 | -#include <klocale.h> |
paul@0 | 811 | -#include <kdebug.h> |
paul@0 | 812 | +#include <KDE/KLocalizedString> |
paul@0 | 813 | +#include <KDE/KDebug> |
paul@0 | 814 | |
paul@0 | 815 | #include "acljobbase_p.h" |
paul@0 | 816 | #include "message_p.h" |
paul@0 | 817 | @@ -32,7 +32,7 @@ namespace KIMAP |
paul@0 | 818 | class DeleteAclJobPrivate : public AclJobBasePrivate |
paul@0 | 819 | { |
paul@0 | 820 | public: |
paul@0 | 821 | - DeleteAclJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate(session, name) {} |
paul@0 | 822 | + DeleteAclJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate( session, name ) {} |
paul@0 | 823 | ~DeleteAclJobPrivate() { } |
paul@0 | 824 | }; |
paul@0 | 825 | } |
paul@0 | 826 | @@ -42,8 +42,8 @@ using namespace KIMAP; |
paul@0 | 827 | DeleteAclJob::DeleteAclJob( Session *session ) |
paul@0 | 828 | : AclJobBase( session ) |
paul@0 | 829 | { |
paul@0 | 830 | - Q_D(DeleteAclJob); |
paul@0 | 831 | - d->m_name = i18n("DeleteAclJob"); |
paul@0 | 832 | + Q_D( DeleteAclJob ); |
paul@0 | 833 | + d->m_name = i18n( "DeleteAclJob" ); |
paul@0 | 834 | } |
paul@0 | 835 | |
paul@0 | 836 | DeleteAclJob::~DeleteAclJob() |
paul@0 | 837 | @@ -52,21 +52,22 @@ DeleteAclJob::~DeleteAclJob() |
paul@0 | 838 | |
paul@0 | 839 | void DeleteAclJob::doStart() |
paul@0 | 840 | { |
paul@0 | 841 | - Q_D(DeleteAclJob); |
paul@0 | 842 | + Q_D( DeleteAclJob ); |
paul@0 | 843 | |
paul@0 | 844 | - d->tags << d->sessionInternal()->sendCommand( "DELETEACL", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + "\" \"" + d->id); |
paul@0 | 845 | + d->tags << d->sessionInternal()->sendCommand( "DELETEACL", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + "\" \"" + d->id ); |
paul@0 | 846 | } |
paul@0 | 847 | |
paul@0 | 848 | void DeleteAclJob::setIdentifier( const QByteArray &identifier ) |
paul@0 | 849 | { |
paul@0 | 850 | - Q_D(DeleteAclJob); |
paul@0 | 851 | - d->setIdentifier(identifier); |
paul@0 | 852 | + Q_D( DeleteAclJob ); |
paul@0 | 853 | + d->setIdentifier( identifier ); |
paul@0 | 854 | } |
paul@0 | 855 | |
paul@0 | 856 | QByteArray DeleteAclJob::identifier() |
paul@0 | 857 | { |
paul@0 | 858 | - Q_D(DeleteAclJob); |
paul@0 | 859 | + Q_D( DeleteAclJob ); |
paul@0 | 860 | return d->identifier(); |
paul@0 | 861 | } |
paul@0 | 862 | |
paul@0 | 863 | #include "deleteacljob.moc" |
paul@0 | 864 | + |
paul@0 | 865 | diff --git a/kimap/deleteacljob.h b/kimap/deleteacljob.h |
paul@0 | 866 | index 0f06055..7beed89 100644 |
paul@0 | 867 | --- a/kimap/deleteacljob.h |
paul@0 | 868 | +++ b/kimap/deleteacljob.h |
paul@0 | 869 | @@ -47,7 +47,7 @@ class DeleteAclJobPrivate; |
paul@0 | 870 | class KIMAP_EXPORT DeleteAclJob : public AclJobBase |
paul@0 | 871 | { |
paul@0 | 872 | Q_OBJECT |
paul@0 | 873 | - Q_DECLARE_PRIVATE(DeleteAclJob) |
paul@0 | 874 | + Q_DECLARE_PRIVATE( DeleteAclJob ) |
paul@0 | 875 | |
paul@0 | 876 | friend class SessionPrivate; |
paul@0 | 877 | |
paul@0 | 878 | diff --git a/kimap/deletejob.cpp b/kimap/deletejob.cpp |
paul@0 | 879 | index 59201ff..c1149ca 100644 |
paul@0 | 880 | --- a/kimap/deletejob.cpp |
paul@0 | 881 | +++ b/kimap/deletejob.cpp |
paul@0 | 882 | @@ -19,8 +19,8 @@ |
paul@0 | 883 | |
paul@0 | 884 | #include "deletejob.h" |
paul@0 | 885 | |
paul@0 | 886 | -#include <klocale.h> |
paul@0 | 887 | -#include <kdebug.h> |
paul@0 | 888 | +#include <KDE/KLocalizedString> |
paul@0 | 889 | +#include <KDE/KDebug> |
paul@0 | 890 | |
paul@0 | 891 | #include "job_p.h" |
paul@0 | 892 | #include "message_p.h" |
paul@0 | 893 | @@ -32,7 +32,7 @@ namespace KIMAP |
paul@0 | 894 | class DeleteJobPrivate : public JobPrivate |
paul@0 | 895 | { |
paul@0 | 896 | public: |
paul@0 | 897 | - DeleteJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { } |
paul@0 | 898 | + DeleteJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { } |
paul@0 | 899 | ~DeleteJobPrivate() { } |
paul@0 | 900 | |
paul@0 | 901 | QString mailBox; |
paul@0 | 902 | @@ -42,7 +42,7 @@ namespace KIMAP |
paul@0 | 903 | using namespace KIMAP; |
paul@0 | 904 | |
paul@0 | 905 | DeleteJob::DeleteJob( Session *session ) |
paul@0 | 906 | - : Job( *new DeleteJobPrivate(session, i18n("Delete")) ) |
paul@0 | 907 | + : Job( *new DeleteJobPrivate( session, i18n( "Delete" ) ) ) |
paul@0 | 908 | { |
paul@0 | 909 | } |
paul@0 | 910 | |
paul@0 | 911 | @@ -52,20 +52,21 @@ DeleteJob::~DeleteJob() |
paul@0 | 912 | |
paul@0 | 913 | void DeleteJob::doStart() |
paul@0 | 914 | { |
paul@0 | 915 | - Q_D(DeleteJob); |
paul@0 | 916 | - d->tags << d->sessionInternal()->sendCommand( "DELETE", '\"'+KIMAP::encodeImapFolderName( d->mailBox.toUtf8() )+'\"' ); |
paul@0 | 917 | + Q_D( DeleteJob ); |
paul@0 | 918 | + d->tags << d->sessionInternal()->sendCommand( "DELETE", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"' ); |
paul@0 | 919 | } |
paul@0 | 920 | |
paul@0 | 921 | void DeleteJob::setMailBox( const QString &mailBox ) |
paul@0 | 922 | { |
paul@0 | 923 | - Q_D(DeleteJob); |
paul@0 | 924 | + Q_D( DeleteJob ); |
paul@0 | 925 | d->mailBox = mailBox; |
paul@0 | 926 | } |
paul@0 | 927 | |
paul@0 | 928 | QString DeleteJob::mailBox() const |
paul@0 | 929 | { |
paul@0 | 930 | - Q_D(const DeleteJob); |
paul@0 | 931 | + Q_D( const DeleteJob ); |
paul@0 | 932 | return d->mailBox; |
paul@0 | 933 | } |
paul@0 | 934 | |
paul@0 | 935 | -#include "deletejob.moc" |
paul@0 | 936 | \ No newline at end of file |
paul@0 | 937 | +#include "deletejob.moc" |
paul@0 | 938 | + |
paul@0 | 939 | diff --git a/kimap/deletejob.h b/kimap/deletejob.h |
paul@0 | 940 | index 2876a90..926ee3c 100644 |
paul@0 | 941 | --- a/kimap/deletejob.h |
paul@0 | 942 | +++ b/kimap/deletejob.h |
paul@0 | 943 | @@ -46,7 +46,7 @@ class DeleteJobPrivate; |
paul@0 | 944 | class KIMAP_EXPORT DeleteJob : public Job |
paul@0 | 945 | { |
paul@0 | 946 | Q_OBJECT |
paul@0 | 947 | - Q_DECLARE_PRIVATE(DeleteJob) |
paul@0 | 948 | + Q_DECLARE_PRIVATE( DeleteJob ) |
paul@0 | 949 | |
paul@0 | 950 | friend class SessionPrivate; |
paul@0 | 951 | |
paul@0 | 952 | diff --git a/kimap/expungejob.cpp b/kimap/expungejob.cpp |
paul@0 | 953 | index 8da8285..63bed80 100644 |
paul@0 | 954 | --- a/kimap/expungejob.cpp |
paul@0 | 955 | +++ b/kimap/expungejob.cpp |
paul@0 | 956 | @@ -19,8 +19,8 @@ |
paul@0 | 957 | |
paul@0 | 958 | #include "expungejob.h" |
paul@0 | 959 | |
paul@0 | 960 | -#include <klocale.h> |
paul@0 | 961 | -#include <kdebug.h> |
paul@0 | 962 | +#include <KDE/KLocalizedString> |
paul@0 | 963 | +#include <KDE/KDebug> |
paul@0 | 964 | |
paul@0 | 965 | #include "job_p.h" |
paul@0 | 966 | #include "message_p.h" |
paul@0 | 967 | @@ -31,7 +31,7 @@ namespace KIMAP |
paul@0 | 968 | class ExpungeJobPrivate : public JobPrivate |
paul@0 | 969 | { |
paul@0 | 970 | public: |
paul@0 | 971 | - ExpungeJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { } |
paul@0 | 972 | + ExpungeJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { } |
paul@0 | 973 | ~ExpungeJobPrivate() { } |
paul@0 | 974 | #if 0 |
paul@0 | 975 | QList< int > items; |
paul@0 | 976 | @@ -42,7 +42,7 @@ namespace KIMAP |
paul@0 | 977 | using namespace KIMAP; |
paul@0 | 978 | |
paul@0 | 979 | ExpungeJob::ExpungeJob( Session *session ) |
paul@0 | 980 | - : Job( *new ExpungeJobPrivate(session, i18n("Expunge")) ) |
paul@0 | 981 | + : Job( *new ExpungeJobPrivate( session, i18n( "Expunge" ) ) ) |
paul@0 | 982 | { |
paul@0 | 983 | } |
paul@0 | 984 | |
paul@0 | 985 | @@ -52,7 +52,7 @@ ExpungeJob::~ExpungeJob() |
paul@0 | 986 | |
paul@0 | 987 | void ExpungeJob::doStart() |
paul@0 | 988 | { |
paul@0 | 989 | - Q_D(ExpungeJob); |
paul@0 | 990 | + Q_D( ExpungeJob ); |
paul@0 | 991 | d->tags << d->sessionInternal()->sendCommand( "EXPUNGE" ); |
paul@0 | 992 | } |
paul@0 | 993 | |
paul@0 | 994 | @@ -60,25 +60,26 @@ void ExpungeJob::handleResponse( const Message &response ) |
paul@0 | 995 | { |
paul@0 | 996 | // Q_D(ExpungeJob); |
paul@0 | 997 | |
paul@0 | 998 | - if (handleErrorReplies(response) == NotHandled) { |
paul@0 | 999 | + if ( handleErrorReplies( response ) == NotHandled ) { |
paul@0 | 1000 | if ( response.content.size() >= 2 ) { |
paul@0 | 1001 | QByteArray code = response.content[2].toString(); |
paul@0 | 1002 | - if (code == "EXPUNGE") { |
paul@0 | 1003 | + if ( code == "EXPUNGE" ) { |
paul@0 | 1004 | #if 0 |
paul@0 | 1005 | QByteArray s = response.content[1].toString(); |
paul@0 | 1006 | bool ok = true; |
paul@0 | 1007 | - int id = s.toInt(&ok); |
paul@0 | 1008 | - if (ok) { |
paul@0 | 1009 | - d->items.append(id); |
paul@0 | 1010 | + int id = s.toInt( &ok ); |
paul@0 | 1011 | + if ( ok ) { |
paul@0 | 1012 | + d->items.append( id ); |
paul@0 | 1013 | } |
paul@0 | 1014 | //TODO error handling |
paul@0 | 1015 | #endif |
paul@0 | 1016 | return; |
paul@0 | 1017 | } |
paul@0 | 1018 | } |
paul@0 | 1019 | - qDebug() << "Unhandled response: " << response.toString().constData(); |
paul@0 | 1020 | + kDebug() << "Unhandled response: " << response.toString().constData(); |
paul@0 | 1021 | |
paul@0 | 1022 | } |
paul@0 | 1023 | } |
paul@0 | 1024 | |
paul@0 | 1025 | #include "expungejob.moc" |
paul@0 | 1026 | + |
paul@0 | 1027 | diff --git a/kimap/expungejob.h b/kimap/expungejob.h |
paul@0 | 1028 | index 9862f59..7e2918b 100644 |
paul@0 | 1029 | --- a/kimap/expungejob.h |
paul@0 | 1030 | +++ b/kimap/expungejob.h |
paul@0 | 1031 | @@ -45,7 +45,7 @@ class ExpungeJobPrivate; |
paul@0 | 1032 | class KIMAP_EXPORT ExpungeJob : public Job |
paul@0 | 1033 | { |
paul@0 | 1034 | Q_OBJECT |
paul@0 | 1035 | - Q_DECLARE_PRIVATE(ExpungeJob) |
paul@0 | 1036 | + Q_DECLARE_PRIVATE( ExpungeJob ) |
paul@0 | 1037 | |
paul@0 | 1038 | friend class SessionPrivate; |
paul@0 | 1039 | |
paul@0 | 1040 | diff --git a/kimap/fetchjob.cpp b/kimap/fetchjob.cpp |
paul@0 | 1041 | index 32582b2..bbb12a4 100644 |
paul@0 | 1042 | --- a/kimap/fetchjob.cpp |
paul@0 | 1043 | +++ b/kimap/fetchjob.cpp |
paul@0 | 1044 | @@ -20,8 +20,8 @@ |
paul@0 | 1045 | #include "fetchjob.h" |
paul@0 | 1046 | |
paul@0 | 1047 | #include <QtCore/QTimer> |
paul@0 | 1048 | -#include <kdebug.h> |
paul@0 | 1049 | -#include <klocale.h> |
paul@0 | 1050 | +#include <KDE/KDebug> |
paul@0 | 1051 | +#include <KDE/KLocalizedString> |
paul@0 | 1052 | |
paul@0 | 1053 | #include "job_p.h" |
paul@0 | 1054 | #include "message_p.h" |
paul@0 | 1055 | @@ -32,7 +32,7 @@ namespace KIMAP |
paul@0 | 1056 | class FetchJobPrivate : public JobPrivate |
paul@0 | 1057 | { |
paul@0 | 1058 | public: |
paul@0 | 1059 | - FetchJobPrivate( FetchJob *job, Session *session, const QString& name ) : JobPrivate( session, name ), q(job), uidBased(false) { } |
paul@0 | 1060 | + FetchJobPrivate( FetchJob *job, Session *session, const QString& name ) : JobPrivate( session, name ), q( job ), uidBased( false ) { } |
paul@0 | 1061 | ~FetchJobPrivate() { } |
paul@0 | 1062 | |
paul@0 | 1063 | void parseBodyStructure( const QByteArray &structure, int &pos, KMime::Content *content ); |
paul@0 | 1064 | @@ -87,9 +87,9 @@ namespace KIMAP |
paul@0 | 1065 | using namespace KIMAP; |
paul@0 | 1066 | |
paul@0 | 1067 | FetchJob::FetchJob( Session *session ) |
paul@0 | 1068 | - : Job( *new FetchJobPrivate(this, session, i18n("Fetch")) ) |
paul@0 | 1069 | + : Job( *new FetchJobPrivate( this, session, i18n( "Fetch" ) ) ) |
paul@0 | 1070 | { |
paul@0 | 1071 | - Q_D(FetchJob); |
paul@0 | 1072 | + Q_D( FetchJob ); |
paul@0 | 1073 | d->scope.mode = FetchScope::Content; |
paul@0 | 1074 | connect( &d->emitPendingsTimer, SIGNAL(timeout()), |
paul@0 | 1075 | this, SLOT(emitPendings()) ); |
paul@0 | 1076 | @@ -101,38 +101,38 @@ FetchJob::~FetchJob() |
paul@0 | 1077 | |
paul@0 | 1078 | void FetchJob::setSequenceSet( const ImapSet &set ) |
paul@0 | 1079 | { |
paul@0 | 1080 | - Q_D(FetchJob); |
paul@0 | 1081 | + Q_D( FetchJob ); |
paul@0 | 1082 | Q_ASSERT( !set.toImapSequenceSet().trimmed().isEmpty() ); |
paul@0 | 1083 | d->set = set; |
paul@0 | 1084 | } |
paul@0 | 1085 | |
paul@0 | 1086 | ImapSet FetchJob::sequenceSet() const |
paul@0 | 1087 | { |
paul@0 | 1088 | - Q_D(const FetchJob); |
paul@0 | 1089 | + Q_D( const FetchJob ); |
paul@0 | 1090 | return d->set; |
paul@0 | 1091 | } |
paul@0 | 1092 | |
paul@0 | 1093 | void FetchJob::setUidBased(bool uidBased) |
paul@0 | 1094 | { |
paul@0 | 1095 | - Q_D(FetchJob); |
paul@0 | 1096 | + Q_D( FetchJob ); |
paul@0 | 1097 | d->uidBased = uidBased; |
paul@0 | 1098 | } |
paul@0 | 1099 | |
paul@0 | 1100 | bool FetchJob::isUidBased() const |
paul@0 | 1101 | { |
paul@0 | 1102 | - Q_D(const FetchJob); |
paul@0 | 1103 | + Q_D( const FetchJob ); |
paul@0 | 1104 | return d->uidBased; |
paul@0 | 1105 | } |
paul@0 | 1106 | |
paul@0 | 1107 | void FetchJob::setScope( const FetchScope &scope ) |
paul@0 | 1108 | { |
paul@0 | 1109 | - Q_D(FetchJob); |
paul@0 | 1110 | + Q_D( FetchJob ); |
paul@0 | 1111 | d->scope = scope; |
paul@0 | 1112 | } |
paul@0 | 1113 | |
paul@0 | 1114 | FetchJob::FetchScope FetchJob::scope() const |
paul@0 | 1115 | { |
paul@0 | 1116 | - Q_D(const FetchJob); |
paul@0 | 1117 | + Q_D( const FetchJob ); |
paul@0 | 1118 | return d->scope; |
paul@0 | 1119 | } |
paul@0 | 1120 | |
paul@0 | 1121 | @@ -163,7 +163,7 @@ QMap<qint64, qint64> FetchJob::uids() const |
paul@0 | 1122 | |
paul@0 | 1123 | void FetchJob::doStart() |
paul@0 | 1124 | { |
paul@0 | 1125 | - Q_D(FetchJob); |
paul@0 | 1126 | + Q_D( FetchJob ); |
paul@0 | 1127 | |
paul@0 | 1128 | QByteArray parameters = d->set.toImapSequenceSet()+' '; |
paul@0 | 1129 | Q_ASSERT( !parameters.trimmed().isEmpty() ); |
paul@0 | 1130 | @@ -171,51 +171,51 @@ void FetchJob::doStart() |
paul@0 | 1131 | switch ( d->scope.mode ) { |
paul@0 | 1132 | case FetchScope::Headers: |
paul@0 | 1133 | if ( d->scope.parts.isEmpty() ) { |
paul@0 | 1134 | - parameters+="(RFC822.SIZE INTERNALDATE BODY.PEEK[HEADER.FIELDS (TO FROM MESSAGE-ID REFERENCES IN-REPLY-TO SUBJECT DATE)] FLAGS UID)"; |
paul@0 | 1135 | + parameters += "(RFC822.SIZE INTERNALDATE BODY.PEEK[HEADER.FIELDS (TO FROM MESSAGE-ID REFERENCES IN-REPLY-TO SUBJECT DATE)] FLAGS UID)"; |
paul@0 | 1136 | } else { |
paul@0 | 1137 | - parameters+='('; |
paul@0 | 1138 | + parameters += '('; |
paul@0 | 1139 | foreach ( const QByteArray &part, d->scope.parts ) { |
paul@0 | 1140 | - parameters+="BODY.PEEK["+part+".MIME] "; |
paul@0 | 1141 | + parameters += "BODY.PEEK[" + part + ".MIME] "; |
paul@0 | 1142 | } |
paul@0 | 1143 | - parameters+="UID)"; |
paul@0 | 1144 | + parameters += "UID)"; |
paul@0 | 1145 | } |
paul@0 | 1146 | break; |
paul@0 | 1147 | case FetchScope::Flags: |
paul@0 | 1148 | - parameters+="(FLAGS UID)"; |
paul@0 | 1149 | + parameters += "(FLAGS UID)"; |
paul@0 | 1150 | break; |
paul@0 | 1151 | case FetchScope::Structure: |
paul@0 | 1152 | - parameters+="(BODYSTRUCTURE UID)"; |
paul@0 | 1153 | + parameters += "(BODYSTRUCTURE UID)"; |
paul@0 | 1154 | break; |
paul@0 | 1155 | case FetchScope::Content: |
paul@0 | 1156 | if ( d->scope.parts.isEmpty() ) { |
paul@0 | 1157 | - parameters+="(BODY.PEEK[] UID)"; |
paul@0 | 1158 | + parameters += "(BODY.PEEK[] UID)"; |
paul@0 | 1159 | } else { |
paul@0 | 1160 | - parameters+='('; |
paul@0 | 1161 | + parameters += '('; |
paul@0 | 1162 | foreach ( const QByteArray &part, d->scope.parts ) { |
paul@0 | 1163 | - parameters+="BODY.PEEK["+part+"] "; |
paul@0 | 1164 | + parameters += "BODY.PEEK[" + part + "] "; |
paul@0 | 1165 | } |
paul@0 | 1166 | - parameters+="UID)"; |
paul@0 | 1167 | + parameters += "UID)"; |
paul@0 | 1168 | } |
paul@0 | 1169 | break; |
paul@0 | 1170 | case FetchScope::Full: |
paul@0 | 1171 | - parameters+="(RFC822.SIZE INTERNALDATE BODY.PEEK[] FLAGS UID)"; |
paul@0 | 1172 | + parameters += "(RFC822.SIZE INTERNALDATE BODY.PEEK[] FLAGS UID)"; |
paul@0 | 1173 | break; |
paul@0 | 1174 | case FetchScope::HeaderAndContent: |
paul@0 | 1175 | if ( d->scope.parts.isEmpty() ) { |
paul@0 | 1176 | - parameters+="(BODY.PEEK[] FLAGS UID)"; |
paul@0 | 1177 | + parameters += "(BODY.PEEK[] FLAGS UID)"; |
paul@0 | 1178 | } else { |
paul@0 | 1179 | - parameters+="(BODY.PEEK[HEADER.FIELDS (TO FROM MESSAGE-ID REFERENCES IN-REPLY-TO SUBJECT DATE)]"; |
paul@0 | 1180 | + parameters += "(BODY.PEEK[HEADER.FIELDS (TO FROM MESSAGE-ID REFERENCES IN-REPLY-TO SUBJECT DATE)]"; |
paul@0 | 1181 | foreach ( const QByteArray &part, d->scope.parts ) { |
paul@0 | 1182 | - parameters+=" BODY.PEEK["+part+".MIME] BODY.PEEK["+part+"]"; //krazy:exclude=doublequote_chars |
paul@0 | 1183 | + parameters += " BODY.PEEK[" + part + ".MIME] BODY.PEEK[" + part + "]"; //krazy:exclude=doublequote_chars |
paul@0 | 1184 | } |
paul@0 | 1185 | - parameters+=" FLAGS UID)"; |
paul@0 | 1186 | + parameters += " FLAGS UID)"; |
paul@0 | 1187 | } |
paul@0 | 1188 | break; |
paul@0 | 1189 | } |
paul@0 | 1190 | |
paul@0 | 1191 | QByteArray command = "FETCH"; |
paul@0 | 1192 | if ( d->uidBased ) { |
paul@0 | 1193 | - command = "UID "+command; |
paul@0 | 1194 | + command = "UID " + command; |
paul@0 | 1195 | } |
paul@0 | 1196 | |
paul@0 | 1197 | d->emitPendingsTimer.start( 100 ); |
paul@0 | 1198 | @@ -225,21 +225,21 @@ void FetchJob::doStart() |
paul@0 | 1199 | |
paul@0 | 1200 | void FetchJob::handleResponse( const Message &response ) |
paul@0 | 1201 | { |
paul@0 | 1202 | - Q_D(FetchJob); |
paul@0 | 1203 | + Q_D( FetchJob ); |
paul@0 | 1204 | |
paul@0 | 1205 | // We can predict it'll be handled by handleErrorReplies() so stop |
paul@0 | 1206 | // the timer now so that result() will really be the last emitted signal. |
paul@0 | 1207 | - if ( !response.content.isEmpty() |
paul@0 | 1208 | - && d->tags.size() == 1 |
paul@0 | 1209 | - && d->tags.contains( response.content.first().toString() ) ) { |
paul@0 | 1210 | + if ( !response.content.isEmpty() && |
paul@0 | 1211 | + d->tags.size() == 1 && |
paul@0 | 1212 | + d->tags.contains( response.content.first().toString() ) ) { |
paul@0 | 1213 | d->emitPendingsTimer.stop(); |
paul@0 | 1214 | d->emitPendings(); |
paul@0 | 1215 | } |
paul@0 | 1216 | |
paul@0 | 1217 | - if (handleErrorReplies(response) == NotHandled ) { |
paul@0 | 1218 | - if ( response.content.size() == 4 |
paul@0 | 1219 | - && response.content[2].toString()=="FETCH" |
paul@0 | 1220 | - && response.content[3].type()==Message::Part::List ) { |
paul@0 | 1221 | + if ( handleErrorReplies( response ) == NotHandled ) { |
paul@0 | 1222 | + if ( response.content.size() == 4 && |
paul@0 | 1223 | + response.content[2].toString() == "FETCH" && |
paul@0 | 1224 | + response.content[3].type() == Message::Part::List ) { |
paul@0 | 1225 | |
paul@0 | 1226 | qint64 id = response.content[1].toString().toLongLong(); |
paul@0 | 1227 | QList<QByteArray> content = response.content[3].toList(); |
paul@0 | 1228 | @@ -249,67 +249,69 @@ void FetchJob::handleResponse( const Message &response ) |
paul@0 | 1229 | MessageParts parts; |
paul@0 | 1230 | |
paul@0 | 1231 | for ( QList<QByteArray>::ConstIterator it = content.constBegin(); |
paul@0 | 1232 | - it!=content.constEnd(); ++it ) { |
paul@0 | 1233 | + it != content.constEnd(); ++it ) { |
paul@0 | 1234 | QByteArray str = *it; |
paul@0 | 1235 | ++it; |
paul@0 | 1236 | |
paul@0 | 1237 | - if ( it==content.constEnd() ) { // Uh oh, message was truncated? |
paul@0 | 1238 | + if ( it == content.constEnd() ) { // Uh oh, message was truncated? |
paul@0 | 1239 | kWarning() << "FETCH reply got truncated, skipping."; |
paul@0 | 1240 | break; |
paul@0 | 1241 | } |
paul@0 | 1242 | |
paul@0 | 1243 | - if ( str=="UID" ) { |
paul@0 | 1244 | + if ( str == "UID" ) { |
paul@0 | 1245 | d->pendingUids[id] = it->toLongLong(); |
paul@0 | 1246 | - } else if ( str=="RFC822.SIZE" ) { |
paul@0 | 1247 | + } else if ( str == "RFC822.SIZE" ) { |
paul@0 | 1248 | d->pendingSizes[id] = it->toLongLong(); |
paul@0 | 1249 | - } else if ( str=="INTERNALDATE" ) { |
paul@0 | 1250 | + } else if ( str == "INTERNALDATE" ) { |
paul@0 | 1251 | message->date()->setDateTime( KDateTime::fromString( *it, KDateTime::RFCDate ) ); |
paul@0 | 1252 | - } else if ( str=="FLAGS" ) { |
paul@0 | 1253 | - if ( (*it).startsWith('(') && (*it).endsWith(')') ) { |
paul@0 | 1254 | + } else if ( str == "FLAGS" ) { |
paul@0 | 1255 | + if ( ( *it ).startsWith( '(' ) && ( *it ).endsWith( ')' ) ) { |
paul@0 | 1256 | QByteArray str = *it; |
paul@0 | 1257 | - str.chop(1); |
paul@0 | 1258 | - str.remove(0, 1); |
paul@0 | 1259 | - d->pendingFlags[id] = str.split(' '); |
paul@0 | 1260 | + str.chop( 1 ); |
paul@0 | 1261 | + str.remove( 0, 1 ); |
paul@0 | 1262 | + d->pendingFlags[id] = str.split( ' ' ); |
paul@0 | 1263 | } else { |
paul@0 | 1264 | d->pendingFlags[id] << *it; |
paul@0 | 1265 | } |
paul@0 | 1266 | - } else if ( str=="BODYSTRUCTURE" ) { |
paul@0 | 1267 | + } else if ( str == "BODYSTRUCTURE" ) { |
paul@0 | 1268 | int pos = 0; |
paul@0 | 1269 | - d->parseBodyStructure(*it, pos, message.get()); |
paul@0 | 1270 | + d->parseBodyStructure( *it, pos, message.get() ); |
paul@0 | 1271 | message->assemble(); |
paul@0 | 1272 | d->pendingMessages[id] = message; |
paul@0 | 1273 | - } else if ( str.startsWith( "BODY[") ) { //krazy:exclude=strings |
paul@0 | 1274 | - if ( !str.endsWith(']') ) { // BODY[ ... ] might have been split, skip until we find the ] |
paul@0 | 1275 | - while ( !(*it).endsWith(']') ) ++it; |
paul@0 | 1276 | + } else if ( str.startsWith( "BODY[" ) ) { //krazy:exclude=strings |
paul@0 | 1277 | + if ( !str.endsWith( ']' ) ) { // BODY[ ... ] might have been split, skip until we find the ] |
paul@0 | 1278 | + while ( !( *it ).endsWith( ']' ) ) { |
paul@0 | 1279 | + ++it; |
paul@0 | 1280 | + } |
paul@0 | 1281 | ++it; |
paul@0 | 1282 | } |
paul@0 | 1283 | |
paul@0 | 1284 | int index; |
paul@0 | 1285 | - if ( (index=str.indexOf("HEADER"))>0 || (index=str.indexOf("MIME"))>0 ) { // headers |
paul@0 | 1286 | - if ( str[index-1]=='.' ) { |
paul@0 | 1287 | - QByteArray partId = str.mid( 5, index-6 ); |
paul@0 | 1288 | + if ( ( index = str.indexOf( "HEADER" ) ) > 0 || ( index = str.indexOf( "MIME" ) ) > 0 ) { // headers |
paul@0 | 1289 | + if ( str[index-1] == '.' ) { |
paul@0 | 1290 | + QByteArray partId = str.mid( 5, index - 6 ); |
paul@0 | 1291 | if ( !parts.contains( partId ) ) { |
paul@0 | 1292 | parts[partId] = ContentPtr( new KMime::Content ); |
paul@0 | 1293 | } |
paul@0 | 1294 | - parts[partId]->setHead(*it); |
paul@0 | 1295 | + parts[partId]->setHead( *it ); |
paul@0 | 1296 | parts[partId]->parse(); |
paul@0 | 1297 | d->pendingParts[id] = parts; |
paul@0 | 1298 | } else { |
paul@0 | 1299 | - message->setHead(*it); |
paul@0 | 1300 | + message->setHead( *it ); |
paul@0 | 1301 | shouldParseMessage = true; |
paul@0 | 1302 | } |
paul@0 | 1303 | } else { // full payload |
paul@0 | 1304 | - if ( str=="BODY[]" ) { |
paul@0 | 1305 | - message->setContent( KMime::CRLFtoLF(*it) ); |
paul@0 | 1306 | + if ( str == "BODY[]" ) { |
paul@0 | 1307 | + message->setContent( KMime::CRLFtoLF( *it ) ); |
paul@0 | 1308 | shouldParseMessage = true; |
paul@0 | 1309 | |
paul@0 | 1310 | d->pendingMessages[id] = message; |
paul@0 | 1311 | } else { |
paul@0 | 1312 | - QByteArray partId = str.mid( 5, str.size()-6 ); |
paul@0 | 1313 | + QByteArray partId = str.mid( 5, str.size() - 6 ); |
paul@0 | 1314 | if ( !parts.contains( partId ) ) { |
paul@0 | 1315 | parts[partId] = ContentPtr( new KMime::Content ); |
paul@0 | 1316 | } |
paul@0 | 1317 | - parts[partId]->setBody(*it); |
paul@0 | 1318 | + parts[partId]->setBody( *it ); |
paul@0 | 1319 | parts[partId]->parse(); |
paul@0 | 1320 | |
paul@0 | 1321 | d->pendingParts[id] = parts; |
paul@0 | 1322 | @@ -334,21 +336,20 @@ void FetchJob::handleResponse( const Message &response ) |
paul@0 | 1323 | |
paul@0 | 1324 | void FetchJobPrivate::parseBodyStructure(const QByteArray &structure, int &pos, KMime::Content *content) |
paul@0 | 1325 | { |
paul@0 | 1326 | - skipLeadingSpaces(structure, pos); |
paul@0 | 1327 | + skipLeadingSpaces( structure, pos ); |
paul@0 | 1328 | |
paul@0 | 1329 | - if ( structure[pos]!='(' ) { |
paul@0 | 1330 | + if ( structure[pos] != '(' ) { |
paul@0 | 1331 | return; |
paul@0 | 1332 | } |
paul@0 | 1333 | |
paul@0 | 1334 | pos++; |
paul@0 | 1335 | |
paul@0 | 1336 | - |
paul@0 | 1337 | - if ( structure[pos]!='(' ) { // simple part |
paul@0 | 1338 | + if ( structure[pos] != '(' ) { // simple part |
paul@0 | 1339 | pos--; |
paul@0 | 1340 | parsePart( structure, pos, content ); |
paul@0 | 1341 | } else { // multi part |
paul@0 | 1342 | - content->contentType()->setMimeType("MULTIPART/MIXED"); |
paul@0 | 1343 | - while ( pos<structure.size() && structure[pos]=='(' ) { |
paul@0 | 1344 | + content->contentType()->setMimeType( "MULTIPART/MIXED" ); |
paul@0 | 1345 | + while ( pos < structure.size() && structure[pos] == '(' ) { |
paul@0 | 1346 | KMime::Content *child = new KMime::Content; |
paul@0 | 1347 | content->addContent( child ); |
paul@0 | 1348 | parseBodyStructure( structure, pos, child ); |
paul@0 | 1349 | @@ -356,17 +357,17 @@ void FetchJobPrivate::parseBodyStructure(const QByteArray &structure, int &pos, |
paul@0 | 1350 | } |
paul@0 | 1351 | |
paul@0 | 1352 | QByteArray subType = parseString( structure, pos ); |
paul@0 | 1353 | - content->contentType()->setMimeType( "MULTIPART/"+subType ); |
paul@0 | 1354 | + content->contentType()->setMimeType( "MULTIPART/" + subType ); |
paul@0 | 1355 | |
paul@0 | 1356 | QByteArray parameters = parseSentence( structure, pos ); // FIXME: Read the charset |
paul@0 | 1357 | - if (parameters.contains("BOUNDARY") ) { |
paul@0 | 1358 | - content->contentType()->setBoundary(parameters.remove(0, parameters.indexOf("BOUNDARY") + 11).split('\"')[0]); |
paul@0 | 1359 | + if ( parameters.contains( "BOUNDARY" ) ) { |
paul@0 | 1360 | + content->contentType()->setBoundary( parameters.remove( 0, parameters.indexOf( "BOUNDARY" ) + 11 ).split( '\"' )[0] ); |
paul@0 | 1361 | } |
paul@0 | 1362 | |
paul@0 | 1363 | QByteArray disposition = parseSentence( structure, pos ); |
paul@0 | 1364 | - if ( disposition.contains("INLINE") ) { |
paul@0 | 1365 | + if ( disposition.contains( "INLINE" ) ) { |
paul@0 | 1366 | content->contentDisposition()->setDisposition( KMime::Headers::CDinline ); |
paul@0 | 1367 | - } else if ( disposition.contains("ATTACHMENT") ) { |
paul@0 | 1368 | + } else if ( disposition.contains( "ATTACHMENT" ) ) { |
paul@0 | 1369 | content->contentDisposition()->setDisposition( KMime::Headers::CDattachment ); |
paul@0 | 1370 | } |
paul@0 | 1371 | |
paul@0 | 1372 | @@ -374,7 +375,7 @@ void FetchJobPrivate::parseBodyStructure(const QByteArray &structure, int &pos, |
paul@0 | 1373 | } |
paul@0 | 1374 | |
paul@0 | 1375 | // Consume what's left |
paul@0 | 1376 | - while ( pos<structure.size() && structure[pos]!=')' ) { |
paul@0 | 1377 | + while ( pos < structure.size() && structure[pos] != ')' ) { |
paul@0 | 1378 | skipLeadingSpaces( structure, pos ); |
paul@0 | 1379 | parseSentence( structure, pos ); |
paul@0 | 1380 | skipLeadingSpaces( structure, pos ); |
paul@0 | 1381 | @@ -385,7 +386,7 @@ void FetchJobPrivate::parseBodyStructure(const QByteArray &structure, int &pos, |
paul@0 | 1382 | |
paul@0 | 1383 | void FetchJobPrivate::parsePart( const QByteArray &structure, int &pos, KMime::Content *content ) |
paul@0 | 1384 | { |
paul@0 | 1385 | - if ( structure[pos]!='(' ) { |
paul@0 | 1386 | + if ( structure[pos] != '(' ) { |
paul@0 | 1387 | return; |
paul@0 | 1388 | } |
paul@0 | 1389 | |
paul@0 | 1390 | @@ -394,7 +395,7 @@ void FetchJobPrivate::parsePart( const QByteArray &structure, int &pos, KMime::C |
paul@0 | 1391 | QByteArray mainType = parseString( structure, pos ); |
paul@0 | 1392 | QByteArray subType = parseString( structure, pos ); |
paul@0 | 1393 | |
paul@0 | 1394 | - content->contentType()->setMimeType( mainType+'/'+subType ); |
paul@0 | 1395 | + content->contentType()->setMimeType( mainType + '/' + subType ); |
paul@0 | 1396 | |
paul@0 | 1397 | parseSentence( structure, pos ); // Ditch the parameters... FIXME: Read it to get charset and name |
paul@0 | 1398 | parseString( structure, pos ); // ... and the id |
paul@0 | 1399 | @@ -406,20 +407,20 @@ void FetchJobPrivate::parsePart( const QByteArray &structure, int &pos, KMime::C |
paul@0 | 1400 | parseString( structure, pos ); // ... and the line count |
paul@0 | 1401 | |
paul@0 | 1402 | QByteArray disposition = parseSentence( structure, pos ); |
paul@0 | 1403 | - if ( disposition.contains("INLINE") ) { |
paul@0 | 1404 | + if ( disposition.contains( "INLINE" ) ) { |
paul@0 | 1405 | content->contentDisposition()->setDisposition( KMime::Headers::CDinline ); |
paul@0 | 1406 | - } else if ( disposition.contains("ATTACHMENT") ) { |
paul@0 | 1407 | + } else if ( disposition.contains( "ATTACHMENT" ) ) { |
paul@0 | 1408 | content->contentDisposition()->setDisposition( KMime::Headers::CDattachment ); |
paul@0 | 1409 | } |
paul@0 | 1410 | - if ( (content->contentDisposition()->disposition() == KMime::Headers::CDattachment |
paul@0 | 1411 | - || content->contentDisposition()->disposition() == KMime::Headers::CDinline) |
paul@0 | 1412 | - && disposition.contains("FILENAME") ) { |
paul@0 | 1413 | - QByteArray filename = disposition.remove(0, disposition.indexOf("FILENAME") + 11).split('\"')[0]; |
paul@0 | 1414 | + if ( ( content->contentDisposition()->disposition() == KMime::Headers::CDattachment || |
paul@0 | 1415 | + content->contentDisposition()->disposition() == KMime::Headers::CDinline ) && |
paul@0 | 1416 | + disposition.contains( "FILENAME" ) ) { |
paul@0 | 1417 | + QByteArray filename = disposition.remove( 0, disposition.indexOf( "FILENAME" ) + 11 ).split( '\"' )[0]; |
paul@0 | 1418 | content->contentDisposition()->setFilename( filename ); |
paul@0 | 1419 | } |
paul@0 | 1420 | |
paul@0 | 1421 | // Consume what's left |
paul@0 | 1422 | - while ( pos<structure.size() && structure[pos]!=')' ) { |
paul@0 | 1423 | + while ( pos < structure.size() && structure[pos] != ')' ) { |
paul@0 | 1424 | skipLeadingSpaces( structure, pos ); |
paul@0 | 1425 | parseSentence( structure, pos ); |
paul@0 | 1426 | skipLeadingSpaces( structure, pos ); |
paul@0 | 1427 | @@ -433,7 +434,7 @@ QByteArray FetchJobPrivate::parseSentence( const QByteArray &structure, int &pos |
paul@0 | 1428 | |
paul@0 | 1429 | skipLeadingSpaces( structure, pos ); |
paul@0 | 1430 | |
paul@0 | 1431 | - if ( structure[pos]!='(' ) { |
paul@0 | 1432 | + if ( structure[pos] != '(' ) { |
paul@0 | 1433 | return parseString( structure, pos ); |
paul@0 | 1434 | } |
paul@0 | 1435 | |
paul@0 | 1436 | @@ -458,12 +459,12 @@ QByteArray FetchJobPrivate::parseSentence( const QByteArray &structure, int &pos |
paul@0 | 1437 | stack--; |
paul@0 | 1438 | break; |
paul@0 | 1439 | default: |
paul@0 | 1440 | - skipLeadingSpaces(structure, pos); |
paul@0 | 1441 | - parseString(structure, pos); |
paul@0 | 1442 | - skipLeadingSpaces(structure, pos); |
paul@0 | 1443 | + skipLeadingSpaces( structure, pos ); |
paul@0 | 1444 | + parseString( structure, pos ); |
paul@0 | 1445 | + skipLeadingSpaces( structure, pos ); |
paul@0 | 1446 | break; |
paul@0 | 1447 | } |
paul@0 | 1448 | - } while ( pos<structure.size() && stack!=0 ); |
paul@0 | 1449 | + } while ( pos < structure.size() && stack != 0 ); |
paul@0 | 1450 | |
paul@0 | 1451 | result = structure.mid( start, pos - start ); |
paul@0 | 1452 | |
paul@0 | 1453 | @@ -484,12 +485,12 @@ QByteArray FetchJobPrivate::parseString( const QByteArray &structure, int &pos ) |
paul@0 | 1454 | pos++; |
paul@0 | 1455 | Q_FOREVER { |
paul@0 | 1456 | if ( structure[pos] == '\\' ) { |
paul@0 | 1457 | - pos+= 2; |
paul@0 | 1458 | + pos += 2; |
paul@0 | 1459 | foundSlash = true; |
paul@0 | 1460 | continue; |
paul@0 | 1461 | } |
paul@0 | 1462 | if ( structure[pos] == '"' ) { |
paul@0 | 1463 | - result = structure.mid( start+1, pos - start - 1); |
paul@0 | 1464 | + result = structure.mid( start + 1, pos - start - 1 ); |
paul@0 | 1465 | pos++; |
paul@0 | 1466 | break; |
paul@0 | 1467 | } |
paul@0 | 1468 | @@ -497,27 +498,38 @@ QByteArray FetchJobPrivate::parseString( const QByteArray &structure, int &pos ) |
paul@0 | 1469 | } |
paul@0 | 1470 | } else { // unquoted string |
paul@0 | 1471 | Q_FOREVER { |
paul@0 | 1472 | - if ( structure[pos] == ' ' || structure[pos] == '(' || structure[pos] == ')' || structure[pos] == '[' || structure[pos] == ']' || structure[pos] == '\n' || structure[pos] == '\r' || structure[pos] == '"') { |
paul@0 | 1473 | + if ( structure[pos] == ' ' || |
paul@0 | 1474 | + structure[pos] == '(' || |
paul@0 | 1475 | + structure[pos] == ')' || |
paul@0 | 1476 | + structure[pos] == '[' || |
paul@0 | 1477 | + structure[pos] == ']' || |
paul@0 | 1478 | + structure[pos] == '\n' || |
paul@0 | 1479 | + structure[pos] == '\r' || |
paul@0 | 1480 | + structure[pos] == '"' ) { |
paul@0 | 1481 | break; |
paul@0 | 1482 | } |
paul@0 | 1483 | - if (structure[pos] == '\\') |
paul@0 | 1484 | + if ( structure[pos] == '\\' ) { |
paul@0 | 1485 | foundSlash = true; |
paul@0 | 1486 | + } |
paul@0 | 1487 | pos++; |
paul@0 | 1488 | } |
paul@0 | 1489 | |
paul@0 | 1490 | result = structure.mid( start, pos - start ); |
paul@0 | 1491 | |
paul@0 | 1492 | // transform unquoted NIL |
paul@0 | 1493 | - if ( result == "NIL" ) |
paul@0 | 1494 | + if ( result == "NIL" ) { |
paul@0 | 1495 | result.clear(); |
paul@0 | 1496 | + } |
paul@0 | 1497 | } |
paul@0 | 1498 | |
paul@0 | 1499 | // simplify slashes |
paul@0 | 1500 | if ( foundSlash ) { |
paul@0 | 1501 | - while ( result.contains( "\\\"" ) ) |
paul@0 | 1502 | + while ( result.contains( "\\\"" ) ) { |
paul@0 | 1503 | result.replace( "\\\"", "\"" ); |
paul@0 | 1504 | - while ( result.contains( "\\\\" ) ) |
paul@0 | 1505 | + } |
paul@0 | 1506 | + while ( result.contains( "\\\\" ) ) { |
paul@0 | 1507 | result.replace( "\\\\", "\\" ); |
paul@0 | 1508 | + } |
paul@0 | 1509 | } |
paul@0 | 1510 | |
paul@0 | 1511 | return result; |
paul@0 | 1512 | @@ -525,7 +537,10 @@ QByteArray FetchJobPrivate::parseString( const QByteArray &structure, int &pos ) |
paul@0 | 1513 | |
paul@0 | 1514 | void FetchJobPrivate::skipLeadingSpaces( const QByteArray &structure, int &pos ) |
paul@0 | 1515 | { |
paul@0 | 1516 | - while ( structure[pos]==' ' && pos<structure.size() ) pos++; |
paul@0 | 1517 | + while ( pos < structure.size() && structure[pos] == ' ' ) { |
paul@0 | 1518 | + pos++; |
paul@0 | 1519 | + } |
paul@0 | 1520 | } |
paul@0 | 1521 | |
paul@0 | 1522 | #include "fetchjob.moc" |
paul@0 | 1523 | + |
paul@0 | 1524 | diff --git a/kimap/fetchjob.h b/kimap/fetchjob.h |
paul@0 | 1525 | index aa31d2d..75fe6b6 100644 |
paul@0 | 1526 | --- a/kimap/fetchjob.h |
paul@0 | 1527 | +++ b/kimap/fetchjob.h |
paul@0 | 1528 | @@ -56,7 +56,7 @@ typedef QList<QByteArray> MessageFlags; |
paul@0 | 1529 | class KIMAP_EXPORT FetchJob : public Job |
paul@0 | 1530 | { |
paul@0 | 1531 | Q_OBJECT |
paul@0 | 1532 | - Q_DECLARE_PRIVATE(FetchJob) |
paul@0 | 1533 | + Q_DECLARE_PRIVATE( FetchJob ) |
paul@0 | 1534 | |
paul@0 | 1535 | friend class SessionPrivate; |
paul@0 | 1536 | |
paul@0 | 1537 | diff --git a/kimap/getacljob.cpp b/kimap/getacljob.cpp |
paul@0 | 1538 | index fbe8d80..b218776 100644 |
paul@0 | 1539 | --- a/kimap/getacljob.cpp |
paul@0 | 1540 | +++ b/kimap/getacljob.cpp |
paul@0 | 1541 | @@ -19,8 +19,8 @@ |
paul@0 | 1542 | |
paul@0 | 1543 | #include "getacljob.h" |
paul@0 | 1544 | |
paul@0 | 1545 | -#include <klocale.h> |
paul@0 | 1546 | -#include <kdebug.h> |
paul@0 | 1547 | +#include <KDE/KLocalizedString> |
paul@0 | 1548 | +#include <KDE/KDebug> |
paul@0 | 1549 | |
paul@0 | 1550 | #include "acljobbase_p.h" |
paul@0 | 1551 | #include "message_p.h" |
paul@0 | 1552 | @@ -32,7 +32,7 @@ namespace KIMAP |
paul@0 | 1553 | class GetAclJobPrivate : public AclJobBasePrivate |
paul@0 | 1554 | { |
paul@0 | 1555 | public: |
paul@0 | 1556 | - GetAclJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate(session, name) {} |
paul@0 | 1557 | + GetAclJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate( session, name ) {} |
paul@0 | 1558 | ~GetAclJobPrivate() { } |
paul@0 | 1559 | |
paul@0 | 1560 | QMap<QByteArray, Acl::Rights> userRights; |
paul@0 | 1561 | @@ -42,7 +42,7 @@ namespace KIMAP |
paul@0 | 1562 | using namespace KIMAP; |
paul@0 | 1563 | |
paul@0 | 1564 | GetAclJob::GetAclJob( Session *session ) |
paul@0 | 1565 | - : AclJobBase( *new GetAclJobPrivate(session, i18n("GetAcl") )) |
paul@0 | 1566 | + : AclJobBase( *new GetAclJobPrivate( session, i18n( "GetAcl" ) ) ) |
paul@0 | 1567 | { |
paul@0 | 1568 | } |
paul@0 | 1569 | |
paul@0 | 1570 | @@ -52,24 +52,24 @@ GetAclJob::~GetAclJob() |
paul@0 | 1571 | |
paul@0 | 1572 | void GetAclJob::doStart() |
paul@0 | 1573 | { |
paul@0 | 1574 | - Q_D(GetAclJob); |
paul@0 | 1575 | + Q_D( GetAclJob ); |
paul@0 | 1576 | |
paul@0 | 1577 | - d->tags << d->sessionInternal()->sendCommand( "GETACL", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"'); |
paul@0 | 1578 | + d->tags << d->sessionInternal()->sendCommand( "GETACL", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"' ); |
paul@0 | 1579 | } |
paul@0 | 1580 | |
paul@0 | 1581 | void GetAclJob::handleResponse( const Message &response ) |
paul@0 | 1582 | { |
paul@0 | 1583 | - Q_D(GetAclJob); |
paul@0 | 1584 | -// qDebug() << response.toString(); |
paul@0 | 1585 | + Q_D( GetAclJob ); |
paul@0 | 1586 | +// kDebug() << response.toString(); |
paul@0 | 1587 | |
paul@0 | 1588 | - if (handleErrorReplies(response) == NotHandled) { |
paul@0 | 1589 | - if ( response.content.size() >= 4 |
paul@0 | 1590 | - && response.content[1].toString() == "ACL" ) { |
paul@0 | 1591 | + if ( handleErrorReplies( response ) == NotHandled ) { |
paul@0 | 1592 | + if ( response.content.size() >= 4 && |
paul@0 | 1593 | + response.content[1].toString() == "ACL" ) { |
paul@0 | 1594 | int i = 3; |
paul@0 | 1595 | while ( i < response.content.size() - 1 ) { |
paul@0 | 1596 | QByteArray id = response.content[i].toString(); |
paul@0 | 1597 | QByteArray rights = response.content[i + 1].toString(); |
paul@0 | 1598 | - d->userRights[id] = Acl::rightsFromString(rights); |
paul@0 | 1599 | + d->userRights[id] = Acl::rightsFromString( rights ); |
paul@0 | 1600 | i += 2; |
paul@0 | 1601 | } |
paul@0 | 1602 | } |
paul@0 | 1603 | @@ -78,15 +78,14 @@ void GetAclJob::handleResponse( const Message &response ) |
paul@0 | 1604 | |
paul@0 | 1605 | QList<QByteArray> GetAclJob::identifiers() const |
paul@0 | 1606 | { |
paul@0 | 1607 | - Q_D(const GetAclJob); |
paul@0 | 1608 | + Q_D( const GetAclJob ); |
paul@0 | 1609 | return d->userRights.keys(); |
paul@0 | 1610 | } |
paul@0 | 1611 | |
paul@0 | 1612 | bool GetAclJob::hasRightEnabled(const QByteArray &identifier, Acl::Right right) const |
paul@0 | 1613 | { |
paul@0 | 1614 | - Q_D(const GetAclJob); |
paul@0 | 1615 | - if (d->userRights.contains(identifier)) |
paul@0 | 1616 | - { |
paul@0 | 1617 | + Q_D( const GetAclJob ); |
paul@0 | 1618 | + if ( d->userRights.contains( identifier ) ) { |
paul@0 | 1619 | Acl::Rights rights = d->userRights[identifier]; |
paul@0 | 1620 | return rights & right; |
paul@0 | 1621 | } |
paul@0 | 1622 | @@ -96,10 +95,9 @@ bool GetAclJob::hasRightEnabled(const QByteArray &identifier, Acl::Right right) |
paul@0 | 1623 | |
paul@0 | 1624 | Acl::Rights GetAclJob::rights(const QByteArray &identifier) const |
paul@0 | 1625 | { |
paul@0 | 1626 | - Q_D(const GetAclJob); |
paul@0 | 1627 | + Q_D( const GetAclJob ); |
paul@0 | 1628 | Acl::Rights result; |
paul@0 | 1629 | - if (d->userRights.contains(identifier)) |
paul@0 | 1630 | - { |
paul@0 | 1631 | + if ( d->userRights.contains( identifier ) ) { |
paul@0 | 1632 | result = d->userRights[identifier]; |
paul@0 | 1633 | } |
paul@0 | 1634 | return result; |
paul@0 | 1635 | @@ -107,8 +105,9 @@ Acl::Rights GetAclJob::rights(const QByteArray &identifier) const |
paul@0 | 1636 | |
paul@0 | 1637 | QMap<QByteArray, Acl::Rights> GetAclJob::allRights() const |
paul@0 | 1638 | { |
paul@0 | 1639 | - Q_D(const GetAclJob); |
paul@0 | 1640 | + Q_D( const GetAclJob ); |
paul@0 | 1641 | return d->userRights; |
paul@0 | 1642 | } |
paul@0 | 1643 | |
paul@0 | 1644 | -#include "getacljob.moc" |
paul@0 | 1645 | \ No newline at end of file |
paul@0 | 1646 | +#include "getacljob.moc" |
paul@0 | 1647 | + |
paul@0 | 1648 | diff --git a/kimap/getacljob.h b/kimap/getacljob.h |
paul@0 | 1649 | index dd652d2..77a6648 100644 |
paul@0 | 1650 | --- a/kimap/getacljob.h |
paul@0 | 1651 | +++ b/kimap/getacljob.h |
paul@0 | 1652 | @@ -30,7 +30,6 @@ class Session; |
paul@0 | 1653 | struct Message; |
paul@0 | 1654 | class GetAclJobPrivate; |
paul@0 | 1655 | |
paul@0 | 1656 | - |
paul@0 | 1657 | /** |
paul@0 | 1658 | * Gets the ACL for a mailbox |
paul@0 | 1659 | * |
paul@0 | 1660 | @@ -63,7 +62,7 @@ class GetAclJobPrivate; |
paul@0 | 1661 | class KIMAP_EXPORT GetAclJob : public AclJobBase |
paul@0 | 1662 | { |
paul@0 | 1663 | Q_OBJECT |
paul@0 | 1664 | - Q_DECLARE_PRIVATE(GetAclJob) |
paul@0 | 1665 | + Q_DECLARE_PRIVATE( GetAclJob ) |
paul@0 | 1666 | |
paul@0 | 1667 | friend class SessionPrivate; |
paul@0 | 1668 | |
paul@0 | 1669 | diff --git a/kimap/getmetadatajob.cpp b/kimap/getmetadatajob.cpp |
paul@0 | 1670 | index 69be41d..4dddce3 100644 |
paul@0 | 1671 | --- a/kimap/getmetadatajob.cpp |
paul@0 | 1672 | +++ b/kimap/getmetadatajob.cpp |
paul@0 | 1673 | @@ -19,8 +19,8 @@ |
paul@0 | 1674 | |
paul@0 | 1675 | #include "getmetadatajob.h" |
paul@0 | 1676 | |
paul@0 | 1677 | -#include <klocale.h> |
paul@0 | 1678 | -#include <kdebug.h> |
paul@0 | 1679 | +#include <KDE/KLocalizedString> |
paul@0 | 1680 | +#include <KDE/KDebug> |
paul@0 | 1681 | |
paul@0 | 1682 | #include "metadatajobbase_p.h" |
paul@0 | 1683 | #include "message_p.h" |
paul@0 | 1684 | @@ -32,7 +32,7 @@ namespace KIMAP |
paul@0 | 1685 | class GetMetaDataJobPrivate : public MetaDataJobBasePrivate |
paul@0 | 1686 | { |
paul@0 | 1687 | public: |
paul@0 | 1688 | - GetMetaDataJobPrivate( Session *session, const QString& name ) : MetaDataJobBasePrivate(session, name), maxSize(-1), depth("0") { } |
paul@0 | 1689 | + GetMetaDataJobPrivate( Session *session, const QString& name ) : MetaDataJobBasePrivate( session, name ), maxSize( -1 ), depth( "0" ) { } |
paul@0 | 1690 | ~GetMetaDataJobPrivate() { } |
paul@0 | 1691 | |
paul@0 | 1692 | qint64 maxSize; |
paul@0 | 1693 | @@ -47,7 +47,7 @@ namespace KIMAP |
paul@0 | 1694 | using namespace KIMAP; |
paul@0 | 1695 | |
paul@0 | 1696 | GetMetaDataJob::GetMetaDataJob( Session *session ) |
paul@0 | 1697 | - : MetaDataJobBase( *new GetMetaDataJobPrivate(session, i18n("GetMetaData")) ) |
paul@0 | 1698 | + : MetaDataJobBase( *new GetMetaDataJobPrivate( session, i18n( "GetMetaData" ) ) ) |
paul@0 | 1699 | { |
paul@0 | 1700 | } |
paul@0 | 1701 | |
paul@0 | 1702 | @@ -57,94 +57,100 @@ GetMetaDataJob::~GetMetaDataJob() |
paul@0 | 1703 | |
paul@0 | 1704 | void GetMetaDataJob::doStart() |
paul@0 | 1705 | { |
paul@0 | 1706 | - Q_D(GetMetaDataJob); |
paul@0 | 1707 | + Q_D( GetMetaDataJob ); |
paul@0 | 1708 | QByteArray parameters; |
paul@0 | 1709 | parameters = '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + "\" "; |
paul@0 | 1710 | |
paul@0 | 1711 | QByteArray command = "GETMETADATA"; |
paul@0 | 1712 | - if (d->serverCapability == Annotatemore) { |
paul@0 | 1713 | - d->m_name = i18n("GetAnnotation"); |
paul@0 | 1714 | + if ( d->serverCapability == Annotatemore ) { |
paul@0 | 1715 | + d->m_name = i18n( "GetAnnotation" ); |
paul@0 | 1716 | command = "GETANNOTATION"; |
paul@0 | 1717 | - if (d->entries.size() > 1) |
paul@0 | 1718 | + if ( d->entries.size() > 1 ) { |
paul@0 | 1719 | parameters += '('; |
paul@0 | 1720 | - Q_FOREACH(const QByteArray &entry, d->entries) { |
paul@0 | 1721 | + } |
paul@0 | 1722 | + Q_FOREACH ( const QByteArray &entry, d->entries ) { |
paul@0 | 1723 | parameters += '\"' + entry + "\" "; |
paul@0 | 1724 | } |
paul@0 | 1725 | - if (d->entries.size() > 1) |
paul@0 | 1726 | - parameters[parameters.length() -1 ] = ')'; |
paul@0 | 1727 | - else |
paul@0 | 1728 | - parameters.truncate(parameters.length() -1); |
paul@0 | 1729 | + if ( d->entries.size() > 1 ) { |
paul@0 | 1730 | + parameters[parameters.length() - 1 ] = ')'; |
paul@0 | 1731 | + } else { |
paul@0 | 1732 | + parameters.truncate( parameters.length() - 1 ); |
paul@0 | 1733 | + } |
paul@0 | 1734 | |
paul@0 | 1735 | parameters += ' '; |
paul@0 | 1736 | |
paul@0 | 1737 | - if (d->attributes.size() > 1) |
paul@0 | 1738 | + if ( d->attributes.size() > 1 ) { |
paul@0 | 1739 | parameters += '('; |
paul@0 | 1740 | - Q_FOREACH(const QByteArray &attribute, d->attributes) { |
paul@0 | 1741 | + } |
paul@0 | 1742 | + Q_FOREACH ( const QByteArray &attribute, d->attributes ) { |
paul@0 | 1743 | parameters += '\"' + attribute + "\" "; |
paul@0 | 1744 | } |
paul@0 | 1745 | - if (d->attributes.size() > 1) |
paul@0 | 1746 | - parameters[parameters.length() -1 ] = ')'; |
paul@0 | 1747 | - else |
paul@0 | 1748 | - parameters.truncate(parameters.length() -1); |
paul@0 | 1749 | + if ( d->attributes.size() > 1 ) { |
paul@0 | 1750 | + parameters[parameters.length() - 1 ] = ')'; |
paul@0 | 1751 | + } else { |
paul@0 | 1752 | + parameters.truncate( parameters.length() - 1 ); |
paul@0 | 1753 | + } |
paul@0 | 1754 | |
paul@0 | 1755 | } else { |
paul@0 | 1756 | - if (d->depth != "0") { |
paul@0 | 1757 | + if ( d->depth != "0" ) { |
paul@0 | 1758 | parameters += "(DEPTH " + d->depth; |
paul@0 | 1759 | } |
paul@0 | 1760 | - if (d->maxSize != -1) { |
paul@0 | 1761 | - parameters += "(MAXSIZE " + QByteArray::number(d->maxSize) + ')'; |
paul@0 | 1762 | + if ( d->maxSize != -1 ) { |
paul@0 | 1763 | + parameters += "(MAXSIZE " + QByteArray::number( d->maxSize ) + ')'; |
paul@0 | 1764 | } |
paul@0 | 1765 | - if (d->depth != "0") { |
paul@0 | 1766 | + if ( d->depth != "0" ) { |
paul@0 | 1767 | parameters += " )"; |
paul@0 | 1768 | } |
paul@0 | 1769 | |
paul@0 | 1770 | - if (d->entries.size() > 1) |
paul@0 | 1771 | + if ( d->entries.size() > 1 ) { |
paul@0 | 1772 | parameters += '('; |
paul@0 | 1773 | - Q_FOREACH(const QByteArray &entry, d->entries) { |
paul@0 | 1774 | + } |
paul@0 | 1775 | + Q_FOREACH ( const QByteArray &entry, d->entries ) { |
paul@0 | 1776 | parameters += '\"' + entry + "\" "; |
paul@0 | 1777 | } |
paul@0 | 1778 | - if (d->entries.size() > 1) |
paul@0 | 1779 | - parameters[parameters.length() -1 ] = ')'; |
paul@0 | 1780 | + if ( d->entries.size() > 1 ) { |
paul@0 | 1781 | + parameters[parameters.length() - 1 ] = ')'; |
paul@0 | 1782 | + } |
paul@0 | 1783 | } |
paul@0 | 1784 | |
paul@0 | 1785 | - if (d->entries.isEmpty()) { |
paul@0 | 1786 | + if ( d->entries.isEmpty() ) { { |
paul@0 | 1787 | parameters += ')'; |
paul@0 | 1788 | } |
paul@0 | 1789 | + } |
paul@0 | 1790 | |
paul@0 | 1791 | d->tags << d->sessionInternal()->sendCommand( command, parameters ); |
paul@0 | 1792 | -// qDebug() << "SENT: " << command << " " << parameters; |
paul@0 | 1793 | +// kDebug() << "SENT: " << command << " " << parameters; |
paul@0 | 1794 | } |
paul@0 | 1795 | |
paul@0 | 1796 | void GetMetaDataJob::handleResponse( const Message &response ) |
paul@0 | 1797 | { |
paul@0 | 1798 | - Q_D(GetMetaDataJob); |
paul@0 | 1799 | -// qDebug() << "GOT: " << response.toString(); |
paul@0 | 1800 | + Q_D( GetMetaDataJob ); |
paul@0 | 1801 | +// kDebug() << "GOT: " << response.toString(); |
paul@0 | 1802 | |
paul@0 | 1803 | //TODO: handle NO error messages having [METADATA MAXSIZE NNN], [METADATA TOOMANY], [METADATA NOPRIVATE] (see rfc5464) |
paul@0 | 1804 | // or [ANNOTATEMORE TOOBIG], [ANNOTATEMORE TOOMANY] respectively |
paul@0 | 1805 | - if (handleErrorReplies(response) == NotHandled ) { |
paul@0 | 1806 | + if ( handleErrorReplies( response ) == NotHandled ) { |
paul@0 | 1807 | if ( response.content.size() >= 4 ) { |
paul@0 | 1808 | - if (d->serverCapability == Annotatemore && response.content[1].toString() == "ANNOTATION" ) { |
paul@0 | 1809 | + if ( d->serverCapability == Annotatemore && response.content[1].toString() == "ANNOTATION" ) { |
paul@0 | 1810 | QString mailBox = QString::fromUtf8( KIMAP::decodeImapFolderName( response.content[2].toString() ) ); |
paul@0 | 1811 | |
paul@0 | 1812 | int i = 3; |
paul@0 | 1813 | - while (i < response.content.size() - 1) { |
paul@0 | 1814 | + while ( i < response.content.size() - 1 ) { |
paul@0 | 1815 | QByteArray entry = response.content[i].toString(); |
paul@0 | 1816 | QList<QByteArray> attributes = response.content[i + 1].toList(); |
paul@0 | 1817 | int j = 0; |
paul@0 | 1818 | - while ( j < attributes.size() - 1) { |
paul@0 | 1819 | + while ( j < attributes.size() - 1 ) { |
paul@0 | 1820 | d->metadata[mailBox][entry][attributes[j]] = attributes[j + 1]; |
paul@0 | 1821 | j += 2; |
paul@0 | 1822 | } |
paul@0 | 1823 | i += 2; |
paul@0 | 1824 | } |
paul@0 | 1825 | - } else |
paul@0 | 1826 | - if (d->serverCapability == Metadata && response.content[1].toString() == "METADATA" ) { |
paul@0 | 1827 | + } else if ( d->serverCapability == Metadata && response.content[1].toString() == "METADATA" ) { |
paul@0 | 1828 | QString mailBox = QString::fromUtf8( KIMAP::decodeImapFolderName( response.content[2].toString() ) ); |
paul@0 | 1829 | |
paul@0 | 1830 | QList<QByteArray> entries = response.content[3].toList(); |
paul@0 | 1831 | int i = 0; |
paul@0 | 1832 | - while ( i < entries.size() - 1) { |
paul@0 | 1833 | + while ( i < entries.size() - 1 ) { |
paul@0 | 1834 | d->metadata[mailBox][entries[i]][""] = entries[i + 1]; |
paul@0 | 1835 | i += 2; |
paul@0 | 1836 | } |
paul@0 | 1837 | @@ -155,25 +161,25 @@ void GetMetaDataJob::handleResponse( const Message &response ) |
paul@0 | 1838 | |
paul@0 | 1839 | void GetMetaDataJob::addEntry(const QByteArray &entry, const QByteArray &attribute) |
paul@0 | 1840 | { |
paul@0 | 1841 | - Q_D(GetMetaDataJob); |
paul@0 | 1842 | - if (d->serverCapability == Annotatemore && attribute.isNull()) |
paul@0 | 1843 | + Q_D( GetMetaDataJob ); |
paul@0 | 1844 | + if ( d->serverCapability == Annotatemore && attribute.isNull() ) { |
paul@0 | 1845 | qWarning() << "In ANNOTATEMORE mode an attribute must be specified with addEntry!"; |
paul@0 | 1846 | - d->entries.append(entry); |
paul@0 | 1847 | - d->attributes.append(attribute); |
paul@0 | 1848 | + } |
paul@0 | 1849 | + d->entries.append( entry ); |
paul@0 | 1850 | + d->attributes.append( attribute ); |
paul@0 | 1851 | } |
paul@0 | 1852 | |
paul@0 | 1853 | void GetMetaDataJob::setMaximumSize(qint64 size) |
paul@0 | 1854 | { |
paul@0 | 1855 | - Q_D(GetMetaDataJob); |
paul@0 | 1856 | + Q_D( GetMetaDataJob ); |
paul@0 | 1857 | d->maxSize = size; |
paul@0 | 1858 | } |
paul@0 | 1859 | |
paul@0 | 1860 | void GetMetaDataJob::setDepth(Depth depth) |
paul@0 | 1861 | { |
paul@0 | 1862 | - Q_D(GetMetaDataJob); |
paul@0 | 1863 | + Q_D( GetMetaDataJob ); |
paul@0 | 1864 | |
paul@0 | 1865 | - switch (depth) |
paul@0 | 1866 | - { |
paul@0 | 1867 | + switch ( depth ) { |
paul@0 | 1868 | case OneLevel: |
paul@0 | 1869 | d->depth = "1"; //krazy:exclude=doublequote_chars |
paul@0 | 1870 | break; |
paul@0 | 1871 | @@ -187,26 +193,27 @@ void GetMetaDataJob::setDepth(Depth depth) |
paul@0 | 1872 | |
paul@0 | 1873 | QByteArray GetMetaDataJob::metaData(const QString &mailBox, const QByteArray &entry, const QByteArray &attribute) const |
paul@0 | 1874 | { |
paul@0 | 1875 | - Q_D(const GetMetaDataJob); |
paul@0 | 1876 | + Q_D( const GetMetaDataJob ); |
paul@0 | 1877 | QByteArray attr = attribute; |
paul@0 | 1878 | |
paul@0 | 1879 | - if (d->serverCapability == Metadata) |
paul@0 | 1880 | + if ( d->serverCapability == Metadata ) { |
paul@0 | 1881 | attr = ""; |
paul@0 | 1882 | + } |
paul@0 | 1883 | |
paul@0 | 1884 | QByteArray result; |
paul@0 | 1885 | - if (d->metadata.contains(mailBox)) { |
paul@0 | 1886 | - if (d->metadata[mailBox].contains(entry)) { |
paul@0 | 1887 | - result = d->metadata[mailBox][entry].value(attr); |
paul@0 | 1888 | + if ( d->metadata.contains( mailBox ) ) { |
paul@0 | 1889 | + if ( d->metadata[mailBox].contains( entry ) ) { |
paul@0 | 1890 | + result = d->metadata[mailBox][entry].value( attr ); |
paul@0 | 1891 | } |
paul@0 | 1892 | } |
paul@0 | 1893 | - |
paul@0 | 1894 | return result; |
paul@0 | 1895 | } |
paul@0 | 1896 | |
paul@0 | 1897 | QMap<QByteArray, QMap<QByteArray, QByteArray> > GetMetaDataJob::allMetaData(const QString &mailBox) const |
paul@0 | 1898 | { |
paul@0 | 1899 | - Q_D(const GetMetaDataJob); |
paul@0 | 1900 | + Q_D( const GetMetaDataJob ); |
paul@0 | 1901 | return d->metadata[mailBox]; |
paul@0 | 1902 | } |
paul@0 | 1903 | |
paul@0 | 1904 | -#include "getmetadatajob.moc" |
paul@0 | 1905 | \ No newline at end of file |
paul@0 | 1906 | +#include "getmetadatajob.moc" |
paul@0 | 1907 | + |
paul@0 | 1908 | diff --git a/kimap/getquotajob.cpp b/kimap/getquotajob.cpp |
paul@0 | 1909 | index 9d1efb0..35d901e 100644 |
paul@0 | 1910 | --- a/kimap/getquotajob.cpp |
paul@0 | 1911 | +++ b/kimap/getquotajob.cpp |
paul@0 | 1912 | @@ -19,8 +19,8 @@ |
paul@0 | 1913 | |
paul@0 | 1914 | #include "getquotajob.h" |
paul@0 | 1915 | |
paul@0 | 1916 | -#include <klocale.h> |
paul@0 | 1917 | -#include <kdebug.h> |
paul@0 | 1918 | +#include <KDE/KLocalizedString> |
paul@0 | 1919 | +#include <KDE/KDebug> |
paul@0 | 1920 | |
paul@0 | 1921 | #include "quotajobbase_p.h" |
paul@0 | 1922 | #include "message_p.h" |
paul@0 | 1923 | @@ -31,7 +31,7 @@ namespace KIMAP |
paul@0 | 1924 | class GetQuotaJobPrivate : public QuotaJobBasePrivate |
paul@0 | 1925 | { |
paul@0 | 1926 | public: |
paul@0 | 1927 | - GetQuotaJobPrivate( Session *session, const QString& name ) : QuotaJobBasePrivate(session, name) { } |
paul@0 | 1928 | + GetQuotaJobPrivate( Session *session, const QString& name ) : QuotaJobBasePrivate( session, name ) { } |
paul@0 | 1929 | ~GetQuotaJobPrivate() { } |
paul@0 | 1930 | |
paul@0 | 1931 | QByteArray root; |
paul@0 | 1932 | @@ -41,7 +41,7 @@ namespace KIMAP |
paul@0 | 1933 | using namespace KIMAP; |
paul@0 | 1934 | |
paul@0 | 1935 | GetQuotaJob::GetQuotaJob( Session *session ) |
paul@0 | 1936 | - : QuotaJobBase( *new GetQuotaJobPrivate(session, i18n("GetQuota")) ) |
paul@0 | 1937 | + : QuotaJobBase( *new GetQuotaJobPrivate( session, i18n( "GetQuota" ) ) ) |
paul@0 | 1938 | { |
paul@0 | 1939 | } |
paul@0 | 1940 | |
paul@0 | 1941 | @@ -51,34 +51,33 @@ GetQuotaJob::~GetQuotaJob() |
paul@0 | 1942 | |
paul@0 | 1943 | void GetQuotaJob::doStart() |
paul@0 | 1944 | { |
paul@0 | 1945 | - Q_D(GetQuotaJob); |
paul@0 | 1946 | + Q_D( GetQuotaJob ); |
paul@0 | 1947 | //XXX: [alexmerry, 2010-07-24]: should d->root be quoted properly? |
paul@0 | 1948 | - d->tags << d->sessionInternal()->sendCommand( "GETQUOTA", '\"' + d->root + '\"'); |
paul@0 | 1949 | + d->tags << d->sessionInternal()->sendCommand( "GETQUOTA", '\"' + d->root + '\"' ); |
paul@0 | 1950 | } |
paul@0 | 1951 | |
paul@0 | 1952 | void GetQuotaJob::handleResponse(const Message &response) |
paul@0 | 1953 | { |
paul@0 | 1954 | - Q_D(GetQuotaJob); |
paul@0 | 1955 | - if (handleErrorReplies(response) == NotHandled) { |
paul@0 | 1956 | - if ( response.content.size() >= 4 |
paul@0 | 1957 | - && response.content[1].toString() == "QUOTA" ) { |
paul@0 | 1958 | - d->quota = d->readQuota(response.content[3]); |
paul@0 | 1959 | + Q_D( GetQuotaJob ); |
paul@0 | 1960 | + if ( handleErrorReplies( response ) == NotHandled ) { |
paul@0 | 1961 | + if ( response.content.size() >= 4 && |
paul@0 | 1962 | + response.content[1].toString() == "QUOTA" ) { |
paul@0 | 1963 | + d->quota = d->readQuota( response.content[3] ); |
paul@0 | 1964 | } |
paul@0 | 1965 | } |
paul@0 | 1966 | } |
paul@0 | 1967 | |
paul@0 | 1968 | void GetQuotaJob::setRoot(const QByteArray& root) |
paul@0 | 1969 | { |
paul@0 | 1970 | - Q_D(GetQuotaJob); |
paul@0 | 1971 | - |
paul@0 | 1972 | + Q_D( GetQuotaJob ); |
paul@0 | 1973 | d->root = root; |
paul@0 | 1974 | } |
paul@0 | 1975 | |
paul@0 | 1976 | QByteArray GetQuotaJob::root() const |
paul@0 | 1977 | { |
paul@0 | 1978 | - Q_D(const GetQuotaJob); |
paul@0 | 1979 | - |
paul@0 | 1980 | + Q_D( const GetQuotaJob ); |
paul@0 | 1981 | return d->root; |
paul@0 | 1982 | } |
paul@0 | 1983 | |
paul@0 | 1984 | -#include "getquotajob.moc" |
paul@0 | 1985 | \ No newline at end of file |
paul@0 | 1986 | +#include "getquotajob.moc" |
paul@0 | 1987 | + |
paul@0 | 1988 | diff --git a/kimap/getquotajob.h b/kimap/getquotajob.h |
paul@0 | 1989 | index 01231ea..698450a 100644 |
paul@0 | 1990 | --- a/kimap/getquotajob.h |
paul@0 | 1991 | +++ b/kimap/getquotajob.h |
paul@0 | 1992 | @@ -50,7 +50,7 @@ class GetQuotaJobPrivate; |
paul@0 | 1993 | class KIMAP_EXPORT GetQuotaJob : public QuotaJobBase |
paul@0 | 1994 | { |
paul@0 | 1995 | Q_OBJECT |
paul@0 | 1996 | - Q_DECLARE_PRIVATE(GetQuotaJob) |
paul@0 | 1997 | + Q_DECLARE_PRIVATE( GetQuotaJob ) |
paul@0 | 1998 | |
paul@0 | 1999 | friend class SessionPrivate; |
paul@0 | 2000 | |
paul@0 | 2001 | @@ -60,7 +60,7 @@ class KIMAP_EXPORT GetQuotaJob : public QuotaJobBase |
paul@0 | 2002 | |
paul@0 | 2003 | /** |
paul@0 | 2004 | * Set the quota root to get the resource limits for. |
paul@0 | 2005 | - * |
paul@0 | 2006 | + * @param root the quota root to set |
paul@0 | 2007 | * @see GetQuotaRootJob |
paul@0 | 2008 | */ |
paul@0 | 2009 | void setRoot(const QByteArray &root); |
paul@0 | 2010 | diff --git a/kimap/getquotarootjob.cpp b/kimap/getquotarootjob.cpp |
paul@0 | 2011 | index ee438a3..49e7bef 100644 |
paul@0 | 2012 | --- a/kimap/getquotarootjob.cpp |
paul@0 | 2013 | +++ b/kimap/getquotarootjob.cpp |
paul@0 | 2014 | @@ -19,8 +19,8 @@ |
paul@0 | 2015 | |
paul@0 | 2016 | #include "getquotarootjob.h" |
paul@0 | 2017 | |
paul@0 | 2018 | -#include <klocale.h> |
paul@0 | 2019 | -#include <kdebug.h> |
paul@0 | 2020 | +#include <KDE/KLocalizedString> |
paul@0 | 2021 | +#include <KDE/KDebug> |
paul@0 | 2022 | |
paul@0 | 2023 | #include "quotajobbase_p.h" |
paul@0 | 2024 | #include "message_p.h" |
paul@0 | 2025 | @@ -32,7 +32,7 @@ namespace KIMAP |
paul@0 | 2026 | class GetQuotaRootJobPrivate : public QuotaJobBasePrivate |
paul@0 | 2027 | { |
paul@0 | 2028 | public: |
paul@0 | 2029 | - GetQuotaRootJobPrivate( Session *session, const QString& name ) : QuotaJobBasePrivate(session, name) { } |
paul@0 | 2030 | + GetQuotaRootJobPrivate( Session *session, const QString& name ) : QuotaJobBasePrivate( session, name ) { } |
paul@0 | 2031 | ~GetQuotaRootJobPrivate() { } |
paul@0 | 2032 | |
paul@0 | 2033 | QString mailBox; |
paul@0 | 2034 | @@ -44,7 +44,7 @@ namespace KIMAP |
paul@0 | 2035 | using namespace KIMAP; |
paul@0 | 2036 | |
paul@0 | 2037 | GetQuotaRootJob::GetQuotaRootJob( Session *session ) |
paul@0 | 2038 | - : QuotaJobBase( *new GetQuotaRootJobPrivate(session, i18n("GetQuotaRoot")) ) |
paul@0 | 2039 | + : QuotaJobBase( *new GetQuotaRootJobPrivate( session, i18n( "GetQuotaRoot" ) ) ) |
paul@0 | 2040 | { |
paul@0 | 2041 | } |
paul@0 | 2042 | |
paul@0 | 2043 | @@ -54,43 +54,41 @@ GetQuotaRootJob::~GetQuotaRootJob() |
paul@0 | 2044 | |
paul@0 | 2045 | void GetQuotaRootJob::doStart() |
paul@0 | 2046 | { |
paul@0 | 2047 | - Q_D(GetQuotaRootJob); |
paul@0 | 2048 | - d->tags << d->sessionInternal()->sendCommand( "GETQUOTAROOT", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"'); |
paul@0 | 2049 | + Q_D( GetQuotaRootJob ); |
paul@0 | 2050 | + d->tags << d->sessionInternal()->sendCommand( "GETQUOTAROOT", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"' ); |
paul@0 | 2051 | } |
paul@0 | 2052 | |
paul@0 | 2053 | void GetQuotaRootJob::handleResponse(const Message &response) |
paul@0 | 2054 | { |
paul@0 | 2055 | - Q_D(GetQuotaRootJob); |
paul@0 | 2056 | - if (handleErrorReplies(response) == NotHandled) { |
paul@0 | 2057 | + Q_D( GetQuotaRootJob ); |
paul@0 | 2058 | + if ( handleErrorReplies( response ) == NotHandled ) { |
paul@0 | 2059 | if ( response.content.size() >= 3 ) { |
paul@0 | 2060 | - if (response.content[1].toString() == "QUOTAROOT" ) { |
paul@0 | 2061 | + if ( response.content[1].toString() == "QUOTAROOT" ) { |
paul@0 | 2062 | d->rootList.clear(); |
paul@0 | 2063 | //some impls don't give the root a name which for us seems as if |
paul@0 | 2064 | //there were no message part |
paul@0 | 2065 | if ( response.content.size() == 3 ) { |
paul@0 | 2066 | - d->rootList.append(""); |
paul@0 | 2067 | + d->rootList.append( "" ); |
paul@0 | 2068 | } else { |
paul@0 | 2069 | int i = 3; |
paul@0 | 2070 | - while ( i < response.content.size()) |
paul@0 | 2071 | - { |
paul@0 | 2072 | - d->rootList.append(response.content[i].toString()); |
paul@0 | 2073 | + while ( i < response.content.size() ) { |
paul@0 | 2074 | + d->rootList.append( response.content[i].toString() ); |
paul@0 | 2075 | i++; |
paul@0 | 2076 | } |
paul@0 | 2077 | } |
paul@0 | 2078 | - } else |
paul@0 | 2079 | - if (response.content[1].toString() == "QUOTA" ) { |
paul@0 | 2080 | + } else if ( response.content[1].toString() == "QUOTA" ) { |
paul@0 | 2081 | QByteArray rootName; |
paul@0 | 2082 | int quotaContentIndex = 3; |
paul@0 | 2083 | //some impls don't give the root a name in the response |
paul@0 | 2084 | - if (response.content.size() == 3 ) { |
paul@0 | 2085 | + if ( response.content.size() == 3 ) { |
paul@0 | 2086 | quotaContentIndex = 2; |
paul@0 | 2087 | } else { |
paul@0 | 2088 | rootName = response.content[2].toString(); |
paul@0 | 2089 | - } |
paul@0 | 2090 | + } |
paul@0 | 2091 | |
paul@0 | 2092 | const QMap<QByteArray, QPair<qint64, qint64> >& quota = d->readQuota(response.content[quotaContentIndex]); |
paul@0 | 2093 | - if (d->quotas.contains(rootName)) { |
paul@0 | 2094 | - d->quotas[ rootName ].unite(quota); |
paul@0 | 2095 | + if ( d->quotas.contains( rootName ) ) { |
paul@0 | 2096 | + d->quotas[ rootName ].unite( quota ); |
paul@0 | 2097 | } else { |
paul@0 | 2098 | d->quotas[ rootName ] = quota; |
paul@0 | 2099 | } |
paul@0 | 2100 | @@ -99,61 +97,54 @@ void GetQuotaRootJob::handleResponse(const Message &response) |
paul@0 | 2101 | } |
paul@0 | 2102 | } |
paul@0 | 2103 | |
paul@0 | 2104 | - |
paul@0 | 2105 | void GetQuotaRootJob::setMailBox(const QString& mailBox) |
paul@0 | 2106 | { |
paul@0 | 2107 | - Q_D(GetQuotaRootJob); |
paul@0 | 2108 | - |
paul@0 | 2109 | + Q_D( GetQuotaRootJob ); |
paul@0 | 2110 | d->mailBox = mailBox; |
paul@0 | 2111 | } |
paul@0 | 2112 | |
paul@0 | 2113 | QString GetQuotaRootJob::mailBox() const |
paul@0 | 2114 | { |
paul@0 | 2115 | - Q_D(const GetQuotaRootJob); |
paul@0 | 2116 | - |
paul@0 | 2117 | + Q_D( const GetQuotaRootJob ); |
paul@0 | 2118 | return d->mailBox; |
paul@0 | 2119 | } |
paul@0 | 2120 | |
paul@0 | 2121 | QList<QByteArray> GetQuotaRootJob::roots() const |
paul@0 | 2122 | { |
paul@0 | 2123 | - Q_D(const GetQuotaRootJob); |
paul@0 | 2124 | - |
paul@0 | 2125 | + Q_D( const GetQuotaRootJob ); |
paul@0 | 2126 | return d->rootList; |
paul@0 | 2127 | } |
paul@0 | 2128 | |
paul@0 | 2129 | qint64 GetQuotaRootJob::usage(const QByteArray &root, const QByteArray &resource) const |
paul@0 | 2130 | { |
paul@0 | 2131 | - Q_D(const GetQuotaRootJob); |
paul@0 | 2132 | - |
paul@0 | 2133 | + Q_D( const GetQuotaRootJob ); |
paul@0 | 2134 | QByteArray r = resource.toUpper(); |
paul@0 | 2135 | |
paul@0 | 2136 | - if (d->quotas.contains(root) && d->quotas[root].contains(r)) { |
paul@0 | 2137 | + if ( d->quotas.contains( root ) && d->quotas[root].contains( r ) ) { |
paul@0 | 2138 | return d->quotas[root][r].first; |
paul@0 | 2139 | } |
paul@0 | 2140 | - |
paul@0 | 2141 | return -1; |
paul@0 | 2142 | } |
paul@0 | 2143 | |
paul@0 | 2144 | qint64 GetQuotaRootJob::limit(const QByteArray &root, const QByteArray &resource) const |
paul@0 | 2145 | { |
paul@0 | 2146 | - Q_D(const GetQuotaRootJob); |
paul@0 | 2147 | + Q_D( const GetQuotaRootJob ); |
paul@0 | 2148 | |
paul@0 | 2149 | QByteArray r = resource.toUpper(); |
paul@0 | 2150 | |
paul@0 | 2151 | - if (d->quotas.contains(root) && d->quotas[root].contains(r)) { |
paul@0 | 2152 | + if ( d->quotas.contains( root ) && d->quotas[root].contains( r ) ) { |
paul@0 | 2153 | return d->quotas[root][r].second; |
paul@0 | 2154 | } |
paul@0 | 2155 | - |
paul@0 | 2156 | return -1; |
paul@0 | 2157 | } |
paul@0 | 2158 | |
paul@0 | 2159 | QMap<QByteArray, qint64> GetQuotaRootJob::allUsages(const QByteArray &root) const |
paul@0 | 2160 | { |
paul@0 | 2161 | - Q_D(const GetQuotaRootJob); |
paul@0 | 2162 | + Q_D( const GetQuotaRootJob ); |
paul@0 | 2163 | |
paul@0 | 2164 | QMap<QByteArray, qint64> result; |
paul@0 | 2165 | |
paul@0 | 2166 | - if (d->quotas.contains(root)) { |
paul@0 | 2167 | + if ( d->quotas.contains( root ) ) { |
paul@0 | 2168 | const QMap< QByteArray, QPair<qint64, qint64> > quota = d->quotas[root]; |
paul@0 | 2169 | QMapIterator<QByteArray, QPair<qint64, qint64> > it( quota ); |
paul@0 | 2170 | while ( it.hasNext() ) { |
paul@0 | 2171 | @@ -161,17 +152,16 @@ QMap<QByteArray, qint64> GetQuotaRootJob::allUsages(const QByteArray &root) cons |
paul@0 | 2172 | result[it.key()] = it.value().first; |
paul@0 | 2173 | } |
paul@0 | 2174 | } |
paul@0 | 2175 | - |
paul@0 | 2176 | return result; |
paul@0 | 2177 | } |
paul@0 | 2178 | |
paul@0 | 2179 | QMap<QByteArray, qint64> GetQuotaRootJob::allLimits(const QByteArray &root) const |
paul@0 | 2180 | { |
paul@0 | 2181 | - Q_D(const GetQuotaRootJob); |
paul@0 | 2182 | + Q_D( const GetQuotaRootJob ); |
paul@0 | 2183 | |
paul@0 | 2184 | QMap<QByteArray, qint64> result; |
paul@0 | 2185 | |
paul@0 | 2186 | - if (d->quotas.contains(root)) { |
paul@0 | 2187 | + if ( d->quotas.contains( root ) ) { |
paul@0 | 2188 | const QMap< QByteArray, QPair<qint64, qint64> > quota = d->quotas[root]; |
paul@0 | 2189 | QMapIterator<QByteArray, QPair<qint64, qint64> > it( quota ); |
paul@0 | 2190 | while ( it.hasNext() ) { |
paul@0 | 2191 | @@ -179,8 +169,8 @@ QMap<QByteArray, qint64> GetQuotaRootJob::allLimits(const QByteArray &root) cons |
paul@0 | 2192 | result[it.key()] = it.value().second; |
paul@0 | 2193 | } |
paul@0 | 2194 | } |
paul@0 | 2195 | - |
paul@0 | 2196 | return result; |
paul@0 | 2197 | } |
paul@0 | 2198 | |
paul@0 | 2199 | #include "getquotarootjob.moc" |
paul@0 | 2200 | + |
paul@0 | 2201 | diff --git a/kimap/getquotarootjob.h b/kimap/getquotarootjob.h |
paul@0 | 2202 | index b1fa49e..3541e18 100644 |
paul@0 | 2203 | --- a/kimap/getquotarootjob.h |
paul@0 | 2204 | +++ b/kimap/getquotarootjob.h |
paul@0 | 2205 | @@ -50,7 +50,7 @@ class GetQuotaRootJobPrivate; |
paul@0 | 2206 | class KIMAP_EXPORT GetQuotaRootJob : public QuotaJobBase |
paul@0 | 2207 | { |
paul@0 | 2208 | Q_OBJECT |
paul@0 | 2209 | - Q_DECLARE_PRIVATE(GetQuotaRootJob) |
paul@0 | 2210 | + Q_DECLARE_PRIVATE( GetQuotaRootJob ) |
paul@0 | 2211 | |
paul@0 | 2212 | friend class SessionPrivate; |
paul@0 | 2213 | |
paul@0 | 2214 | diff --git a/kimap/idlejob.cpp b/kimap/idlejob.cpp |
paul@0 | 2215 | index 0248697..5f75429 100644 |
paul@0 | 2216 | --- a/kimap/idlejob.cpp |
paul@0 | 2217 | +++ b/kimap/idlejob.cpp |
paul@0 | 2218 | @@ -20,7 +20,7 @@ |
paul@0 | 2219 | #include "idlejob.h" |
paul@0 | 2220 | |
paul@0 | 2221 | #include <QtCore/QTimer> |
paul@0 | 2222 | -#include <klocale.h> |
paul@0 | 2223 | +#include <KDE/KLocalizedString> |
paul@0 | 2224 | |
paul@0 | 2225 | #include "job_p.h" |
paul@0 | 2226 | #include "message_p.h" |
paul@0 | 2227 | @@ -32,7 +32,7 @@ namespace KIMAP |
paul@0 | 2228 | { |
paul@0 | 2229 | public: |
paul@0 | 2230 | IdleJobPrivate( IdleJob *job, Session *session, const QString& name ) |
paul@0 | 2231 | - : JobPrivate( session, name ), q(job), |
paul@0 | 2232 | + : JobPrivate( session, name ), q( job ), |
paul@0 | 2233 | messageCount( -1 ), recentCount( -1 ), |
paul@0 | 2234 | lastMessageCount( -1 ), lastRecentCount( -1 ), |
paul@0 | 2235 | originalSocketTimeout( -1 ) { } |
paul@0 | 2236 | @@ -42,8 +42,8 @@ namespace KIMAP |
paul@0 | 2237 | { |
paul@0 | 2238 | emitStatsTimer.stop(); |
paul@0 | 2239 | |
paul@0 | 2240 | - emit q->mailBoxStats(q, m_session->selectedMailBox(), |
paul@0 | 2241 | - messageCount, recentCount); |
paul@0 | 2242 | + emit q->mailBoxStats( q, m_session->selectedMailBox(), |
paul@0 | 2243 | + messageCount, recentCount ); |
paul@0 | 2244 | |
paul@0 | 2245 | lastMessageCount = messageCount; |
paul@0 | 2246 | lastRecentCount = recentCount; |
paul@0 | 2247 | @@ -69,9 +69,9 @@ namespace KIMAP |
paul@0 | 2248 | using namespace KIMAP; |
paul@0 | 2249 | |
paul@0 | 2250 | IdleJob::IdleJob( Session *session ) |
paul@0 | 2251 | - : Job( *new IdleJobPrivate(this, session, i18nc("name of the idle job", "Idle")) ) |
paul@0 | 2252 | + : Job( *new IdleJobPrivate( this, session, i18nc( "name of the idle job", "Idle" ) ) ) |
paul@0 | 2253 | { |
paul@0 | 2254 | - Q_D(IdleJob); |
paul@0 | 2255 | + Q_D( IdleJob ); |
paul@0 | 2256 | connect( &d->emitStatsTimer, SIGNAL(timeout()), |
paul@0 | 2257 | this, SLOT(emitStats()) ); |
paul@0 | 2258 | } |
paul@0 | 2259 | @@ -82,14 +82,14 @@ IdleJob::~IdleJob() |
paul@0 | 2260 | |
paul@0 | 2261 | void KIMAP::IdleJob::stop() |
paul@0 | 2262 | { |
paul@0 | 2263 | - Q_D(IdleJob); |
paul@0 | 2264 | + Q_D( IdleJob ); |
paul@0 | 2265 | d->sessionInternal()->setSocketTimeout( d->originalSocketTimeout ); |
paul@0 | 2266 | d->sessionInternal()->sendData( "DONE" ); |
paul@0 | 2267 | } |
paul@0 | 2268 | |
paul@0 | 2269 | void IdleJob::doStart() |
paul@0 | 2270 | { |
paul@0 | 2271 | - Q_D(IdleJob); |
paul@0 | 2272 | + Q_D( IdleJob ); |
paul@0 | 2273 | d->originalSocketTimeout = d->sessionInternal()->socketTimeout(); |
paul@0 | 2274 | d->sessionInternal()->setSocketTimeout( -1 ); |
paul@0 | 2275 | d->tags << d->sessionInternal()->sendCommand( "IDLE" ); |
paul@0 | 2276 | @@ -97,33 +97,32 @@ void IdleJob::doStart() |
paul@0 | 2277 | |
paul@0 | 2278 | void IdleJob::handleResponse( const Message &response ) |
paul@0 | 2279 | { |
paul@0 | 2280 | - Q_D(IdleJob); |
paul@0 | 2281 | + Q_D( IdleJob ); |
paul@0 | 2282 | |
paul@0 | 2283 | // We can predict it'll be handled by handleErrorReplies() so emit |
paul@0 | 2284 | // pending signals now (if needed) so that result() will really be |
paul@0 | 2285 | // the last emitted signal. |
paul@0 | 2286 | - if ( !response.content.isEmpty() |
paul@0 | 2287 | - && d->tags.size() == 1 |
paul@0 | 2288 | - && d->tags.contains( response.content.first().toString() ) |
paul@0 | 2289 | - && ( d->messageCount>=0 || d->recentCount>=0 ) ) { |
paul@0 | 2290 | + if ( !response.content.isEmpty() && |
paul@0 | 2291 | + d->tags.size() == 1 && |
paul@0 | 2292 | + d->tags.contains( response.content.first().toString() ) && |
paul@0 | 2293 | + ( d->messageCount >= 0 || d->recentCount >= 0 ) ) { |
paul@0 | 2294 | d->emitStats(); |
paul@0 | 2295 | } |
paul@0 | 2296 | |
paul@0 | 2297 | - |
paul@0 | 2298 | - if (handleErrorReplies(response) == NotHandled ) { |
paul@0 | 2299 | - if ( response.content.size() > 0 && response.content[0].toString()=="+" ) { |
paul@0 | 2300 | + if ( handleErrorReplies( response ) == NotHandled ) { |
paul@0 | 2301 | + if ( response.content.size() > 0 && response.content[0].toString() == "+" ) { |
paul@0 | 2302 | // Got the continuation all is fine |
paul@0 | 2303 | return; |
paul@0 | 2304 | |
paul@0 | 2305 | } else if ( response.content.size() > 2 ) { |
paul@0 | 2306 | - if ( response.content[2].toString()=="EXISTS" ) { |
paul@0 | 2307 | - if ( d->messageCount>=0 ) { |
paul@0 | 2308 | + if ( response.content[2].toString() == "EXISTS" ) { |
paul@0 | 2309 | + if ( d->messageCount >= 0 ) { |
paul@0 | 2310 | d->emitStats(); |
paul@0 | 2311 | } |
paul@0 | 2312 | |
paul@0 | 2313 | d->messageCount = response.content[1].toString().toInt(); |
paul@0 | 2314 | - } else if ( response.content[2].toString()=="RECENT" ) { |
paul@0 | 2315 | - if ( d->recentCount>=0 ) { |
paul@0 | 2316 | + } else if ( response.content[2].toString() == "RECENT" ) { |
paul@0 | 2317 | + if ( d->recentCount >= 0 ) { |
paul@0 | 2318 | d->emitStats(); |
paul@0 | 2319 | } |
paul@0 | 2320 | |
paul@0 | 2321 | @@ -141,20 +140,21 @@ void IdleJob::handleResponse( const Message &response ) |
paul@0 | 2322 | |
paul@0 | 2323 | QString KIMAP::IdleJob::lastMailBox() const |
paul@0 | 2324 | { |
paul@0 | 2325 | - Q_D(const IdleJob); |
paul@0 | 2326 | + Q_D( const IdleJob ); |
paul@0 | 2327 | return d->m_session->selectedMailBox(); |
paul@0 | 2328 | } |
paul@0 | 2329 | |
paul@0 | 2330 | int KIMAP::IdleJob::lastMessageCount() const |
paul@0 | 2331 | { |
paul@0 | 2332 | - Q_D(const IdleJob); |
paul@0 | 2333 | + Q_D( const IdleJob ); |
paul@0 | 2334 | return d->lastMessageCount; |
paul@0 | 2335 | } |
paul@0 | 2336 | |
paul@0 | 2337 | int KIMAP::IdleJob::lastRecentCount() const |
paul@0 | 2338 | { |
paul@0 | 2339 | - Q_D(const IdleJob); |
paul@0 | 2340 | + Q_D( const IdleJob ); |
paul@0 | 2341 | return d->lastRecentCount; |
paul@0 | 2342 | } |
paul@0 | 2343 | |
paul@0 | 2344 | #include "idlejob.moc" |
paul@0 | 2345 | + |
paul@0 | 2346 | diff --git a/kimap/idlejob.h b/kimap/idlejob.h |
paul@0 | 2347 | index 3a0917b..784155a 100644 |
paul@0 | 2348 | --- a/kimap/idlejob.h |
paul@0 | 2349 | +++ b/kimap/idlejob.h |
paul@0 | 2350 | @@ -63,7 +63,7 @@ class IdleJobPrivate; |
paul@0 | 2351 | class KIMAP_EXPORT IdleJob : public Job |
paul@0 | 2352 | { |
paul@0 | 2353 | Q_OBJECT |
paul@0 | 2354 | - Q_DECLARE_PRIVATE(IdleJob) |
paul@0 | 2355 | + Q_DECLARE_PRIVATE( IdleJob ) |
paul@0 | 2356 | |
paul@0 | 2357 | public: |
paul@0 | 2358 | explicit IdleJob( Session *session ); |
paul@0 | 2359 | diff --git a/kimap/imapset.cpp b/kimap/imapset.cpp |
paul@0 | 2360 | index 8588452..6c4e9ea 100644 |
paul@0 | 2361 | --- a/kimap/imapset.cpp |
paul@0 | 2362 | +++ b/kimap/imapset.cpp |
paul@0 | 2363 | @@ -56,7 +56,6 @@ class ImapSet::Private : public QSharedData |
paul@0 | 2364 | ImapInterval::List intervals; |
paul@0 | 2365 | }; |
paul@0 | 2366 | |
paul@0 | 2367 | - |
paul@0 | 2368 | ImapInterval::ImapInterval() : |
paul@0 | 2369 | d( new Private ) |
paul@0 | 2370 | { |
paul@0 | 2371 | @@ -80,8 +79,9 @@ ImapInterval::~ ImapInterval() |
paul@0 | 2372 | |
paul@0 | 2373 | ImapInterval& ImapInterval::operator =(const ImapInterval & other) |
paul@0 | 2374 | { |
paul@0 | 2375 | - if ( this != & other ) |
paul@0 | 2376 | + if ( this != &other ) { |
paul@0 | 2377 | d = other.d; |
paul@0 | 2378 | + } |
paul@0 | 2379 | return *this; |
paul@0 | 2380 | } |
paul@0 | 2381 | |
paul@0 | 2382 | @@ -92,10 +92,12 @@ bool ImapInterval::operator ==(const ImapInterval & other) const |
paul@0 | 2383 | |
paul@0 | 2384 | ImapInterval::Id ImapInterval::size() const |
paul@0 | 2385 | { |
paul@0 | 2386 | - if ( !d->begin && !d->end ) |
paul@0 | 2387 | + if ( !d->begin && !d->end ) { |
paul@0 | 2388 | return 0; |
paul@0 | 2389 | - if ( d->begin && !d->end ) |
paul@0 | 2390 | + } |
paul@0 | 2391 | + if ( d->begin && !d->end ) { |
paul@0 | 2392 | return Q_INT64_C( 0x7FFFFFFFFFFFFFFF ) - d->begin + 1; |
paul@0 | 2393 | + } |
paul@0 | 2394 | return d->end - d->begin + 1; |
paul@0 | 2395 | } |
paul@0 | 2396 | |
paul@0 | 2397 | @@ -116,8 +118,9 @@ bool ImapInterval::hasDefinedEnd() const |
paul@0 | 2398 | |
paul@0 | 2399 | ImapInterval::Id ImapInterval::end() const |
paul@0 | 2400 | { |
paul@0 | 2401 | - if ( hasDefinedEnd() ) |
paul@0 | 2402 | + if ( hasDefinedEnd() ) { |
paul@0 | 2403 | return d->end; |
paul@0 | 2404 | + } |
paul@0 | 2405 | return 0xFFFFFFFF; // should be INT_MAX, but where is that defined again? |
paul@0 | 2406 | } |
paul@0 | 2407 | |
paul@0 | 2408 | @@ -137,16 +140,19 @@ void ImapInterval::setEnd(Id value) |
paul@0 | 2409 | |
paul@0 | 2410 | QByteArray ImapInterval::toImapSequence() const |
paul@0 | 2411 | { |
paul@0 | 2412 | - if ( size() == 0 ) |
paul@0 | 2413 | + if ( size() == 0 ) { |
paul@0 | 2414 | return QByteArray(); |
paul@0 | 2415 | - if ( size() == 1 ) |
paul@0 | 2416 | + } |
paul@0 | 2417 | + if ( size() == 1 ) { |
paul@0 | 2418 | return QByteArray::number( d->begin ); |
paul@0 | 2419 | + } |
paul@0 | 2420 | QByteArray rv; |
paul@0 | 2421 | rv += QByteArray::number( d->begin ) + ':'; |
paul@0 | 2422 | - if ( hasDefinedEnd() ) |
paul@0 | 2423 | + if ( hasDefinedEnd() ) { |
paul@0 | 2424 | rv += QByteArray::number( d->end ); |
paul@0 | 2425 | - else |
paul@0 | 2426 | + } else { |
paul@0 | 2427 | rv += '*'; |
paul@0 | 2428 | + } |
paul@0 | 2429 | return rv; |
paul@0 | 2430 | } |
paul@0 | 2431 | |
paul@0 | 2432 | @@ -158,7 +164,7 @@ ImapInterval ImapInterval::fromImapSequence( const QByteArray &sequence ) |
paul@0 | 2433 | } |
paul@0 | 2434 | |
paul@0 | 2435 | bool ok = false; |
paul@0 | 2436 | - Id begin = values[0].toLongLong(&ok); |
paul@0 | 2437 | + Id begin = values[0].toLongLong( &ok ); |
paul@0 | 2438 | |
paul@0 | 2439 | if ( !ok ) { |
paul@0 | 2440 | return ImapInterval(); |
paul@0 | 2441 | @@ -172,7 +178,7 @@ ImapInterval ImapInterval::fromImapSequence( const QByteArray &sequence ) |
paul@0 | 2442 | end = 0; |
paul@0 | 2443 | } else { |
paul@0 | 2444 | ok = false; |
paul@0 | 2445 | - end = values[1].toLongLong(&ok); |
paul@0 | 2446 | + end = values[1].toLongLong( &ok ); |
paul@0 | 2447 | if ( !ok ) { |
paul@0 | 2448 | return ImapInterval(); |
paul@0 | 2449 | } |
paul@0 | 2450 | @@ -209,8 +215,9 @@ ImapSet::~ImapSet() |
paul@0 | 2451 | |
paul@0 | 2452 | ImapSet & ImapSet::operator =(const ImapSet & other) |
paul@0 | 2453 | { |
paul@0 | 2454 | - if ( this != &other ) |
paul@0 | 2455 | + if ( this != &other ) { |
paul@0 | 2456 | d = other.d; |
paul@0 | 2457 | + } |
paul@0 | 2458 | return *this; |
paul@0 | 2459 | } |
paul@0 | 2460 | |
paul@0 | 2461 | @@ -238,7 +245,7 @@ void ImapSet::add(const QList<Id> & values) |
paul@0 | 2462 | { |
paul@0 | 2463 | QList<Id> vals = values; |
paul@0 | 2464 | qSort( vals ); |
paul@0 | 2465 | - for( int i = 0; i < vals.count(); ++i ) { |
paul@0 | 2466 | + for ( int i = 0; i < vals.count(); ++i ) { |
paul@0 | 2467 | const int begin = vals[i]; |
paul@0 | 2468 | Q_ASSERT( begin >= 0 ); |
paul@0 | 2469 | if ( i == vals.count() - 1 ) { |
paul@0 | 2470 | @@ -248,7 +255,7 @@ void ImapSet::add(const QList<Id> & values) |
paul@0 | 2471 | do { |
paul@0 | 2472 | ++i; |
paul@0 | 2473 | Q_ASSERT( vals[i] >= 0 ); |
paul@0 | 2474 | - if ( vals[i] != (vals[i - 1] + 1) ) { |
paul@0 | 2475 | + if ( vals[i] != ( vals[i - 1] + 1 ) ) { |
paul@0 | 2476 | --i; |
paul@0 | 2477 | break; |
paul@0 | 2478 | } |
paul@0 | 2479 | @@ -276,7 +283,7 @@ QByteArray ImapSet::toImapSequenceSet() const |
paul@0 | 2480 | QList<QByteArray>::ConstIterator it = rv.constBegin(); |
paul@0 | 2481 | ++it; |
paul@0 | 2482 | for ( ; it != rv.constEnd(); ++it ) { |
paul@0 | 2483 | - result += ',' + (*it); |
paul@0 | 2484 | + result += ',' + ( *it ); |
paul@0 | 2485 | } |
paul@0 | 2486 | } |
paul@0 | 2487 | |
paul@0 | 2488 | @@ -289,7 +296,7 @@ ImapSet ImapSet::fromImapSequenceSet( const QByteArray &sequence ) |
paul@0 | 2489 | |
paul@0 | 2490 | QList<QByteArray> intervals = sequence.split( ',' ); |
paul@0 | 2491 | |
paul@0 | 2492 | - foreach( const QByteArray &interval, intervals ) { |
paul@0 | 2493 | + foreach ( const QByteArray &interval, intervals ) { |
paul@0 | 2494 | if ( !interval.isEmpty() ) { |
paul@0 | 2495 | result.add( ImapInterval::fromImapSequence( interval ) ); |
paul@0 | 2496 | } |
paul@0 | 2497 | @@ -319,4 +326,3 @@ QDebug& operator<<( QDebug &d, const ImapSet &set ) |
paul@0 | 2498 | d << set.toImapSequenceSet(); |
paul@0 | 2499 | return d; |
paul@0 | 2500 | } |
paul@0 | 2501 | - |
paul@0 | 2502 | diff --git a/kimap/imapset.h b/kimap/imapset.h |
paul@0 | 2503 | index a3417ac..a217251 100644 |
paul@0 | 2504 | --- a/kimap/imapset.h |
paul@0 | 2505 | +++ b/kimap/imapset.h |
paul@0 | 2506 | @@ -199,6 +199,7 @@ class KIMAP_EXPORT ImapSet |
paul@0 | 2507 | /** |
paul@0 | 2508 | Adds the given ImapInterval to this set. |
paul@0 | 2509 | No interval merging is performed. |
paul@0 | 2510 | + @param interval the interval to add |
paul@0 | 2511 | */ |
paul@0 | 2512 | void add( const ImapInterval &interval ); |
paul@0 | 2513 | |
paul@0 | 2514 | diff --git a/kimap/imapstreamparser.cpp b/kimap/imapstreamparser.cpp |
paul@0 | 2515 | index 50a8552..37bf691 100644 |
paul@0 | 2516 | --- a/kimap/imapstreamparser.cpp |
paul@0 | 2517 | +++ b/kimap/imapstreamparser.cpp |
paul@0 | 2518 | @@ -48,20 +48,21 @@ QString ImapStreamParser::readUtf8String() |
paul@0 | 2519 | return result; |
paul@0 | 2520 | } |
paul@0 | 2521 | |
paul@0 | 2522 | - |
paul@0 | 2523 | QByteArray ImapStreamParser::readString() |
paul@0 | 2524 | { |
paul@0 | 2525 | QByteArray result; |
paul@0 | 2526 | - if ( !waitForMoreData( m_data.length() == 0 ) ) |
paul@0 | 2527 | - throw ImapParserException("Unable to read more data"); |
paul@0 | 2528 | + if ( !waitForMoreData( m_data.length() == 0 ) ) { |
paul@0 | 2529 | + throw ImapParserException( "Unable to read more data" ); |
paul@0 | 2530 | + } |
paul@0 | 2531 | stripLeadingSpaces(); |
paul@0 | 2532 | - if ( !waitForMoreData( m_position >= m_data.length() ) ) |
paul@0 | 2533 | - throw ImapParserException("Unable to read more data"); |
paul@0 | 2534 | + if ( !waitForMoreData( m_position >= m_data.length() ) ) { |
paul@0 | 2535 | + throw ImapParserException( "Unable to read more data" ); |
paul@0 | 2536 | + } |
paul@0 | 2537 | |
paul@0 | 2538 | // literal string |
paul@0 | 2539 | // TODO: error handling |
paul@0 | 2540 | if ( hasLiteral() ) { |
paul@0 | 2541 | - while (!atLiteralEnd()) { |
paul@0 | 2542 | + while ( !atLiteralEnd() ) { |
paul@0 | 2543 | result += readLiteralPart(); |
paul@0 | 2544 | } |
paul@0 | 2545 | return result; |
paul@0 | 2546 | @@ -73,58 +74,65 @@ QByteArray ImapStreamParser::readString() |
paul@0 | 2547 | |
paul@0 | 2548 | bool ImapStreamParser::hasString() |
paul@0 | 2549 | { |
paul@0 | 2550 | - if ( !waitForMoreData( m_position >= m_data.length() ) ) |
paul@0 | 2551 | - throw ImapParserException("Unable to read more data"); |
paul@0 | 2552 | + if ( !waitForMoreData( m_position >= m_data.length() ) ) { |
paul@0 | 2553 | + throw ImapParserException( "Unable to read more data" ); |
paul@0 | 2554 | + } |
paul@0 | 2555 | int savedPos = m_position; |
paul@0 | 2556 | stripLeadingSpaces(); |
paul@0 | 2557 | int pos = m_position; |
paul@0 | 2558 | m_position = savedPos; |
paul@0 | 2559 | - if ( m_data.at(pos) == '{' ) |
paul@0 | 2560 | + if ( m_data.at( pos ) == '{' ) { |
paul@0 | 2561 | return true; //literal string |
paul@0 | 2562 | - if (m_data.at(pos) == '"' ) |
paul@0 | 2563 | + } |
paul@0 | 2564 | + if ( m_data.at( pos ) == '"' ) { |
paul@0 | 2565 | return true; //quoted string |
paul@0 | 2566 | - if ( m_data.at(pos) != ' ' && |
paul@0 | 2567 | - m_data.at(pos) != '(' && |
paul@0 | 2568 | - m_data.at(pos) != ')' && |
paul@0 | 2569 | - m_data.at(pos) != '[' && |
paul@0 | 2570 | - m_data.at(pos) != ']' && |
paul@0 | 2571 | - m_data.at(pos) != '\n' && |
paul@0 | 2572 | - m_data.at(pos) != '\r' ) |
paul@0 | 2573 | + } |
paul@0 | 2574 | + if ( m_data.at( pos ) != ' ' && |
paul@0 | 2575 | + m_data.at( pos ) != '(' && |
paul@0 | 2576 | + m_data.at( pos ) != ')' && |
paul@0 | 2577 | + m_data.at( pos ) != '[' && |
paul@0 | 2578 | + m_data.at( pos ) != ']' && |
paul@0 | 2579 | + m_data.at( pos ) != '\n' && |
paul@0 | 2580 | + m_data.at( pos ) != '\r' ) { |
paul@0 | 2581 | return true; //unquoted string |
paul@0 | 2582 | + } |
paul@0 | 2583 | |
paul@0 | 2584 | return false; //something else, not a string |
paul@0 | 2585 | } |
paul@0 | 2586 | |
paul@0 | 2587 | bool ImapStreamParser::hasLiteral() |
paul@0 | 2588 | { |
paul@0 | 2589 | - if ( !waitForMoreData( m_position >= m_data.length() ) ) |
paul@0 | 2590 | - throw ImapParserException("Unable to read more data"); |
paul@0 | 2591 | + if ( !waitForMoreData( m_position >= m_data.length() ) ) { |
paul@0 | 2592 | + throw ImapParserException( "Unable to read more data" ); |
paul@0 | 2593 | + } |
paul@0 | 2594 | int savedPos = m_position; |
paul@0 | 2595 | stripLeadingSpaces(); |
paul@0 | 2596 | - if ( m_data.at(m_position) == '{' ) |
paul@0 | 2597 | - { |
paul@0 | 2598 | + if ( m_data.at( m_position ) == '{' ) { |
paul@0 | 2599 | int end = -1; |
paul@0 | 2600 | do { |
paul@0 | 2601 | end = m_data.indexOf( '}', m_position ); |
paul@0 | 2602 | - if ( !waitForMoreData( end == -1 ) ) |
paul@0 | 2603 | - throw ImapParserException("Unable to read more data"); |
paul@0 | 2604 | - } while (end == -1); |
paul@0 | 2605 | + if ( !waitForMoreData( end == -1 ) ) { |
paul@0 | 2606 | + throw ImapParserException( "Unable to read more data" ); |
paul@0 | 2607 | + } |
paul@0 | 2608 | + } while ( end == -1 ); |
paul@0 | 2609 | Q_ASSERT( end > m_position ); |
paul@0 | 2610 | m_literalSize = m_data.mid( m_position + 1, end - m_position - 1 ).toInt(); |
paul@0 | 2611 | // strip CRLF |
paul@0 | 2612 | m_position = end + 1; |
paul@0 | 2613 | |
paul@0 | 2614 | - if ( m_position < m_data.length() && m_data.at(m_position) == '\r' ) |
paul@0 | 2615 | + if ( m_position < m_data.length() && m_data.at( m_position ) == '\r' ) { |
paul@0 | 2616 | ++m_position; |
paul@0 | 2617 | - if ( m_position < m_data.length() && m_data.at(m_position) == '\n' ) |
paul@0 | 2618 | + } |
paul@0 | 2619 | + if ( m_position < m_data.length() && m_data.at( m_position ) == '\n' ) { |
paul@0 | 2620 | ++m_position; |
paul@0 | 2621 | + } |
paul@0 | 2622 | |
paul@0 | 2623 | //FIXME: Makes sense only on the server side? |
paul@0 | 2624 | - if (m_isServerModeEnabled && m_literalSize > 0) |
paul@0 | 2625 | + if ( m_isServerModeEnabled && m_literalSize > 0 ) { |
paul@0 | 2626 | sendContinuationResponse( m_literalSize ); |
paul@0 | 2627 | + } |
paul@0 | 2628 | return true; |
paul@0 | 2629 | - } else |
paul@0 | 2630 | - { |
paul@0 | 2631 | + } else { |
paul@0 | 2632 | m_position = savedPos; |
paul@0 | 2633 | return false; |
paul@0 | 2634 | } |
paul@0 | 2635 | @@ -132,7 +140,7 @@ bool ImapStreamParser::hasLiteral() |
paul@0 | 2636 | |
paul@0 | 2637 | bool ImapStreamParser::atLiteralEnd() const |
paul@0 | 2638 | { |
paul@0 | 2639 | - return (m_literalSize == 0); |
paul@0 | 2640 | + return ( m_literalSize == 0 ); |
paul@0 | 2641 | } |
paul@0 | 2642 | |
paul@0 | 2643 | QByteArray ImapStreamParser::readLiteralPart() |
paul@0 | 2644 | @@ -140,18 +148,19 @@ QByteArray ImapStreamParser::readLiteralPart() |
paul@0 | 2645 | static qint64 maxLiteralPartSize = 4096; |
paul@0 | 2646 | int size = qMin(maxLiteralPartSize, m_literalSize); |
paul@0 | 2647 | |
paul@0 | 2648 | - if ( !waitForMoreData( m_data.length() < m_position + size ) ) |
paul@0 | 2649 | - throw ImapParserException("Unable to read more data"); |
paul@0 | 2650 | + if ( !waitForMoreData( m_data.length() < m_position + size ) ) { |
paul@0 | 2651 | + throw ImapParserException( "Unable to read more data" ); |
paul@0 | 2652 | + } |
paul@0 | 2653 | |
paul@0 | 2654 | if ( m_data.length() < m_position + size ) { // Still not enough data |
paul@0 | 2655 | // Take what's already there |
paul@0 | 2656 | size = m_data.length() - m_position; |
paul@0 | 2657 | } |
paul@0 | 2658 | |
paul@0 | 2659 | - QByteArray result = m_data.mid(m_position, size); |
paul@0 | 2660 | + QByteArray result = m_data.mid( m_position, size ); |
paul@0 | 2661 | m_position += size; |
paul@0 | 2662 | m_literalSize -= size; |
paul@0 | 2663 | - Q_ASSERT(m_literalSize >= 0); |
paul@0 | 2664 | + Q_ASSERT( m_literalSize >= 0 ); |
paul@0 | 2665 | trimBuffer(); |
paul@0 | 2666 | |
paul@0 | 2667 | return result; |
paul@0 | 2668 | @@ -159,80 +168,81 @@ QByteArray ImapStreamParser::readLiteralPart() |
paul@0 | 2669 | |
paul@0 | 2670 | bool ImapStreamParser::hasList() |
paul@0 | 2671 | { |
paul@0 | 2672 | - if ( !waitForMoreData( m_position >= m_data.length() ) ) |
paul@0 | 2673 | - throw ImapParserException("Unable to read more data"); |
paul@0 | 2674 | + if ( !waitForMoreData( m_position >= m_data.length() ) ) { |
paul@0 | 2675 | + throw ImapParserException( "Unable to read more data" ); |
paul@0 | 2676 | + } |
paul@0 | 2677 | int savedPos = m_position; |
paul@0 | 2678 | stripLeadingSpaces(); |
paul@0 | 2679 | int pos = m_position; |
paul@0 | 2680 | m_position = savedPos; |
paul@0 | 2681 | - if ( m_data.at(pos) == '(' ) |
paul@0 | 2682 | - { |
paul@0 | 2683 | + if ( m_data.at( pos ) == '(' ) { |
paul@0 | 2684 | return true; |
paul@0 | 2685 | } |
paul@0 | 2686 | - |
paul@0 | 2687 | return false; |
paul@0 | 2688 | } |
paul@0 | 2689 | |
paul@0 | 2690 | bool ImapStreamParser::atListEnd() |
paul@0 | 2691 | { |
paul@0 | 2692 | - if ( !waitForMoreData( m_position >= m_data.length() ) ) |
paul@0 | 2693 | - throw ImapParserException("Unable to read more data"); |
paul@0 | 2694 | + if ( !waitForMoreData( m_position >= m_data.length() ) ) { |
paul@0 | 2695 | + throw ImapParserException( "Unable to read more data" ); |
paul@0 | 2696 | + } |
paul@0 | 2697 | int savedPos = m_position; |
paul@0 | 2698 | stripLeadingSpaces(); |
paul@0 | 2699 | int pos = m_position; |
paul@0 | 2700 | m_position = savedPos; |
paul@0 | 2701 | - if ( m_data.at(pos) == ')' ) |
paul@0 | 2702 | - { |
paul@0 | 2703 | + if ( m_data.at( pos ) == ')' ) { |
paul@0 | 2704 | m_position = pos + 1; |
paul@0 | 2705 | return true; |
paul@0 | 2706 | } |
paul@0 | 2707 | - |
paul@0 | 2708 | return false; |
paul@0 | 2709 | } |
paul@0 | 2710 | |
paul@0 | 2711 | QList<QByteArray> ImapStreamParser::readParenthesizedList() |
paul@0 | 2712 | { |
paul@0 | 2713 | QList<QByteArray> result; |
paul@0 | 2714 | - if (! waitForMoreData( m_data.length() <= m_position ) ) |
paul@0 | 2715 | - throw ImapParserException("Unable to read more data"); |
paul@0 | 2716 | + if ( !waitForMoreData( m_data.length() <= m_position ) ) { |
paul@0 | 2717 | + throw ImapParserException( "Unable to read more data" ); |
paul@0 | 2718 | + } |
paul@0 | 2719 | |
paul@0 | 2720 | stripLeadingSpaces(); |
paul@0 | 2721 | - if ( m_data.at(m_position) != '(' ) |
paul@0 | 2722 | + if ( m_data.at( m_position ) != '(' ) { |
paul@0 | 2723 | return result; //no list found |
paul@0 | 2724 | + } |
paul@0 | 2725 | |
paul@0 | 2726 | bool concatToLast = false; |
paul@0 | 2727 | int count = 0; |
paul@0 | 2728 | int sublistbegin = m_position; |
paul@0 | 2729 | int i = m_position + 1; |
paul@0 | 2730 | Q_FOREVER { |
paul@0 | 2731 | - if ( !waitForMoreData( m_data.length() <= i ) ) |
paul@0 | 2732 | - { |
paul@0 | 2733 | + if ( !waitForMoreData( m_data.length() <= i ) ) { |
paul@0 | 2734 | m_position = i; |
paul@0 | 2735 | - throw ImapParserException("Unable to read more data"); |
paul@0 | 2736 | + throw ImapParserException( "Unable to read more data" ); |
paul@0 | 2737 | } |
paul@0 | 2738 | - if ( m_data.at(i) == '(' ) { |
paul@0 | 2739 | + if ( m_data.at( i ) == '(' ) { |
paul@0 | 2740 | ++count; |
paul@0 | 2741 | - if ( count == 1 ) |
paul@0 | 2742 | + if ( count == 1 ) { |
paul@0 | 2743 | sublistbegin = i; |
paul@0 | 2744 | + } |
paul@0 | 2745 | ++i; |
paul@0 | 2746 | continue; |
paul@0 | 2747 | } |
paul@0 | 2748 | - if ( m_data.at(i) == ')' ) { |
paul@0 | 2749 | + if ( m_data.at( i ) == ')' ) { |
paul@0 | 2750 | if ( count <= 0 ) { |
paul@0 | 2751 | m_position = i + 1; |
paul@0 | 2752 | return result; |
paul@0 | 2753 | } |
paul@0 | 2754 | - if ( count == 1 ) |
paul@0 | 2755 | + if ( count == 1 ) { |
paul@0 | 2756 | result.append( m_data.mid( sublistbegin, i - sublistbegin + 1 ) ); |
paul@0 | 2757 | + } |
paul@0 | 2758 | --count; |
paul@0 | 2759 | ++i; |
paul@0 | 2760 | continue; |
paul@0 | 2761 | } |
paul@0 | 2762 | - if ( m_data.at(i) == ' ' ) { |
paul@0 | 2763 | + if ( m_data.at( i ) == ' ' ) { |
paul@0 | 2764 | ++i; |
paul@0 | 2765 | continue; |
paul@0 | 2766 | } |
paul@0 | 2767 | - if ( m_data.at(i) == '"' ) { |
paul@0 | 2768 | + if ( m_data.at( i ) == '"' ) { |
paul@0 | 2769 | if ( count > 0 ) { |
paul@0 | 2770 | m_position = i; |
paul@0 | 2771 | parseQuotedString(); |
paul@0 | 2772 | @@ -240,27 +250,27 @@ QList<QByteArray> ImapStreamParser::readParenthesizedList() |
paul@0 | 2773 | continue; |
paul@0 | 2774 | } |
paul@0 | 2775 | } |
paul@0 | 2776 | - if ( m_data.at(i) == '[' ) { |
paul@0 | 2777 | + if ( m_data.at( i ) == '[' ) { |
paul@0 | 2778 | concatToLast = true; |
paul@0 | 2779 | if ( result.isEmpty() ) { |
paul@0 | 2780 | result.append( QByteArray() ); |
paul@0 | 2781 | } |
paul@0 | 2782 | - result.last()+='['; |
paul@0 | 2783 | + result.last() += '['; |
paul@0 | 2784 | ++i; |
paul@0 | 2785 | continue; |
paul@0 | 2786 | } |
paul@0 | 2787 | - if ( m_data.at(i) == ']' ) { |
paul@0 | 2788 | + if ( m_data.at( i ) == ']' ) { |
paul@0 | 2789 | concatToLast = false; |
paul@0 | 2790 | - result.last()+=']'; |
paul@0 | 2791 | + result.last() += ']'; |
paul@0 | 2792 | ++i; |
paul@0 | 2793 | continue; |
paul@0 | 2794 | } |
paul@0 | 2795 | if ( count == 0 ) { |
paul@0 | 2796 | m_position = i; |
paul@0 | 2797 | QByteArray ba; |
paul@0 | 2798 | - if (hasLiteral()) { |
paul@0 | 2799 | - while (!atLiteralEnd()) { |
paul@0 | 2800 | - ba+=readLiteralPart(); |
paul@0 | 2801 | + if ( hasLiteral() ) { |
paul@0 | 2802 | + while ( !atLiteralEnd() ) { |
paul@0 | 2803 | + ba += readLiteralPart(); |
paul@0 | 2804 | } |
paul@0 | 2805 | } else { |
paul@0 | 2806 | ba = readString(); |
paul@0 | 2807 | @@ -268,13 +278,14 @@ QList<QByteArray> ImapStreamParser::readParenthesizedList() |
paul@0 | 2808 | |
paul@0 | 2809 | // We might sometime get some unwanted CRLF, but we're still not at the end |
paul@0 | 2810 | // of the list, would make further string reads fail so eat the CRLFs. |
paul@0 | 2811 | - while ( ( m_position < m_data.size() ) && ( m_data.at(m_position) == '\r' || m_data.at(m_position) == '\n' ) ) { |
paul@0 | 2812 | + while ( ( m_position < m_data.size() ) && |
paul@0 | 2813 | + ( m_data.at( m_position ) == '\r' || m_data.at( m_position ) == '\n' ) ) { |
paul@0 | 2814 | m_position++; |
paul@0 | 2815 | } |
paul@0 | 2816 | |
paul@0 | 2817 | i = m_position - 1; |
paul@0 | 2818 | - if (concatToLast) { |
paul@0 | 2819 | - result.last()+=ba; |
paul@0 | 2820 | + if ( concatToLast ) { |
paul@0 | 2821 | + result.last() += ba; |
paul@0 | 2822 | } else { |
paul@0 | 2823 | result.append( ba ); |
paul@0 | 2824 | } |
paul@0 | 2825 | @@ -287,68 +298,68 @@ QList<QByteArray> ImapStreamParser::readParenthesizedList() |
paul@0 | 2826 | |
paul@0 | 2827 | bool ImapStreamParser::hasResponseCode() |
paul@0 | 2828 | { |
paul@0 | 2829 | - if ( !waitForMoreData( m_position >= m_data.length() ) ) |
paul@0 | 2830 | - throw ImapParserException("Unable to read more data"); |
paul@0 | 2831 | + if ( !waitForMoreData( m_position >= m_data.length() ) ) { |
paul@0 | 2832 | + throw ImapParserException( "Unable to read more data" ); |
paul@0 | 2833 | + } |
paul@0 | 2834 | int savedPos = m_position; |
paul@0 | 2835 | stripLeadingSpaces(); |
paul@0 | 2836 | int pos = m_position; |
paul@0 | 2837 | m_position = savedPos; |
paul@0 | 2838 | - if ( m_data.at(pos) == '[' ) |
paul@0 | 2839 | - { |
paul@0 | 2840 | + if ( m_data.at( pos ) == '[' ) { |
paul@0 | 2841 | m_position = pos + 1; |
paul@0 | 2842 | return true; |
paul@0 | 2843 | } |
paul@0 | 2844 | - |
paul@0 | 2845 | return false; |
paul@0 | 2846 | } |
paul@0 | 2847 | |
paul@0 | 2848 | bool ImapStreamParser::atResponseCodeEnd() |
paul@0 | 2849 | { |
paul@0 | 2850 | - if ( !waitForMoreData( m_position >= m_data.length() ) ) |
paul@0 | 2851 | - throw ImapParserException("Unable to read more data"); |
paul@0 | 2852 | + if ( !waitForMoreData( m_position >= m_data.length() ) ) { |
paul@0 | 2853 | + throw ImapParserException( "Unable to read more data" ); |
paul@0 | 2854 | + } |
paul@0 | 2855 | int savedPos = m_position; |
paul@0 | 2856 | stripLeadingSpaces(); |
paul@0 | 2857 | int pos = m_position; |
paul@0 | 2858 | m_position = savedPos; |
paul@0 | 2859 | - if ( m_data.at(pos) == ']' ) |
paul@0 | 2860 | - { |
paul@0 | 2861 | + if ( m_data.at( pos ) == ']' ) { |
paul@0 | 2862 | m_position = pos + 1; |
paul@0 | 2863 | return true; |
paul@0 | 2864 | } |
paul@0 | 2865 | - |
paul@0 | 2866 | return false; |
paul@0 | 2867 | } |
paul@0 | 2868 | |
paul@0 | 2869 | QByteArray ImapStreamParser::parseQuotedString() |
paul@0 | 2870 | { |
paul@0 | 2871 | QByteArray result; |
paul@0 | 2872 | - if (! waitForMoreData( m_data.length() == 0 ) ) |
paul@0 | 2873 | - throw ImapParserException("Unable to read more data"); |
paul@0 | 2874 | + if ( !waitForMoreData( m_data.length() == 0 ) ) { |
paul@0 | 2875 | + throw ImapParserException( "Unable to read more data" ); |
paul@0 | 2876 | + } |
paul@0 | 2877 | stripLeadingSpaces(); |
paul@0 | 2878 | int end = m_position; |
paul@0 | 2879 | result.clear(); |
paul@0 | 2880 | - if ( !waitForMoreData( m_position >= m_data.length() ) ) |
paul@0 | 2881 | - throw ImapParserException("Unable to read more data"); |
paul@0 | 2882 | - if ( !waitForMoreData( m_position >= m_data.length() ) ) |
paul@0 | 2883 | - throw ImapParserException("Unable to read more data"); |
paul@0 | 2884 | + if ( !waitForMoreData( m_position >= m_data.length() ) ) { |
paul@0 | 2885 | + throw ImapParserException( "Unable to read more data" ); |
paul@0 | 2886 | + } |
paul@0 | 2887 | + if ( !waitForMoreData( m_position >= m_data.length() ) ) { |
paul@0 | 2888 | + throw ImapParserException( "Unable to read more data" ); |
paul@0 | 2889 | + } |
paul@0 | 2890 | |
paul@0 | 2891 | bool foundSlash = false; |
paul@0 | 2892 | // quoted string |
paul@0 | 2893 | - if ( m_data.at(m_position) == '"' ) { |
paul@0 | 2894 | + if ( m_data.at( m_position ) == '"' ) { |
paul@0 | 2895 | ++m_position; |
paul@0 | 2896 | int i = m_position; |
paul@0 | 2897 | Q_FOREVER { |
paul@0 | 2898 | - if ( !waitForMoreData( m_data.length() <= i ) ) |
paul@0 | 2899 | - { |
paul@0 | 2900 | + if ( !waitForMoreData( m_data.length() <= i ) ) { |
paul@0 | 2901 | m_position = i; |
paul@0 | 2902 | - throw ImapParserException("Unable to read more data"); |
paul@0 | 2903 | + throw ImapParserException( "Unable to read more data" ); |
paul@0 | 2904 | } |
paul@0 | 2905 | - if ( m_data.at(i) == '\\' ) { |
paul@0 | 2906 | + if ( m_data.at( i ) == '\\' ) { |
paul@0 | 2907 | i += 2; |
paul@0 | 2908 | foundSlash = true; |
paul@0 | 2909 | continue; |
paul@0 | 2910 | } |
paul@0 | 2911 | - if ( m_data.at(i) == '"' ) { |
paul@0 | 2912 | + if ( m_data.at( i ) == '"' ) { |
paul@0 | 2913 | result = m_data.mid( m_position, i - m_position ); |
paul@0 | 2914 | end = i + 1; // skip the '"' |
paul@0 | 2915 | break; |
paul@0 | 2916 | @@ -362,32 +373,42 @@ QByteArray ImapStreamParser::parseQuotedString() |
paul@0 | 2917 | bool reachedInputEnd = true; |
paul@0 | 2918 | int i = m_position; |
paul@0 | 2919 | Q_FOREVER { |
paul@0 | 2920 | - if ( !waitForMoreData( m_data.length() <= i ) ) |
paul@0 | 2921 | - { |
paul@0 | 2922 | + if ( !waitForMoreData( m_data.length() <= i ) ) { |
paul@0 | 2923 | m_position = i; |
paul@0 | 2924 | - throw ImapParserException("Unable to read more data"); |
paul@0 | 2925 | + throw ImapParserException( "Unable to read more data" ); |
paul@0 | 2926 | } |
paul@0 | 2927 | - 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) == '"') { |
paul@0 | 2928 | + if ( m_data.at( i ) == ' ' || |
paul@0 | 2929 | + m_data.at( i ) == '(' || |
paul@0 | 2930 | + m_data.at( i ) == ')' || |
paul@0 | 2931 | + m_data.at( i ) == '[' || |
paul@0 | 2932 | + m_data.at( i ) == ']' || |
paul@0 | 2933 | + m_data.at( i ) == '\n' || |
paul@0 | 2934 | + m_data.at( i ) == '\r' || |
paul@0 | 2935 | + m_data.at( i ) == '"' ) { |
paul@0 | 2936 | end = i; |
paul@0 | 2937 | reachedInputEnd = false; |
paul@0 | 2938 | break; |
paul@0 | 2939 | } |
paul@0 | 2940 | - if (m_data.at(i) == '\\') |
paul@0 | 2941 | + if ( m_data.at( i ) == '\\' ) { |
paul@0 | 2942 | foundSlash = true; |
paul@0 | 2943 | + } |
paul@0 | 2944 | i++; |
paul@0 | 2945 | } |
paul@0 | 2946 | - if ( reachedInputEnd ) //FIXME: how can it get here? |
paul@0 | 2947 | + if ( reachedInputEnd ) { //FIXME: how can it get here? |
paul@0 | 2948 | end = m_data.length(); |
paul@0 | 2949 | + } |
paul@0 | 2950 | |
paul@0 | 2951 | result = m_data.mid( m_position, end - m_position ); |
paul@0 | 2952 | } |
paul@0 | 2953 | |
paul@0 | 2954 | // strip quotes |
paul@0 | 2955 | if ( foundSlash ) { |
paul@0 | 2956 | - while ( result.contains( "\\\"" ) ) |
paul@0 | 2957 | + while ( result.contains( "\\\"" ) ) { |
paul@0 | 2958 | result.replace( "\\\"", "\"" ); |
paul@0 | 2959 | - while ( result.contains( "\\\\" ) ) |
paul@0 | 2960 | + } |
paul@0 | 2961 | + while ( result.contains( "\\\\" ) ) { |
paul@0 | 2962 | result.replace( "\\\\", "\\" ); |
paul@0 | 2963 | + } |
paul@0 | 2964 | } |
paul@0 | 2965 | m_position = end; |
paul@0 | 2966 | return result; |
paul@0 | 2967 | @@ -396,24 +417,28 @@ QByteArray ImapStreamParser::parseQuotedString() |
paul@0 | 2968 | qint64 ImapStreamParser::readNumber( bool * ok ) |
paul@0 | 2969 | { |
paul@0 | 2970 | qint64 result; |
paul@0 | 2971 | - if ( ok ) |
paul@0 | 2972 | + if ( ok ) { |
paul@0 | 2973 | *ok = false; |
paul@0 | 2974 | - if (! waitForMoreData( m_data.length() == 0 ) ) |
paul@0 | 2975 | - throw ImapParserException("Unable to read more data"); |
paul@0 | 2976 | + } |
paul@0 | 2977 | + if ( !waitForMoreData( m_data.length() == 0 ) ) { |
paul@0 | 2978 | + throw ImapParserException( "Unable to read more data" ); |
paul@0 | 2979 | + } |
paul@0 | 2980 | stripLeadingSpaces(); |
paul@0 | 2981 | - if ( !waitForMoreData( m_position >= m_data.length() ) ) |
paul@0 | 2982 | - throw ImapParserException("Unable to read more data"); |
paul@0 | 2983 | - if ( m_position >= m_data.length() ) |
paul@0 | 2984 | - throw ImapParserException("Unable to read more data"); |
paul@0 | 2985 | + if ( !waitForMoreData( m_position >= m_data.length() ) ) { |
paul@0 | 2986 | + throw ImapParserException( "Unable to read more data" ); |
paul@0 | 2987 | + } |
paul@0 | 2988 | + if ( m_position >= m_data.length() ) { |
paul@0 | 2989 | + throw ImapParserException( "Unable to read more data" ); |
paul@0 | 2990 | + } |
paul@0 | 2991 | int i = m_position; |
paul@0 | 2992 | Q_FOREVER { |
paul@0 | 2993 | - if ( !waitForMoreData( m_data.length() <= i ) ) |
paul@0 | 2994 | - { |
paul@0 | 2995 | + if ( !waitForMoreData( m_data.length() <= i ) ) { |
paul@0 | 2996 | m_position = i; |
paul@0 | 2997 | - throw ImapParserException("Unable to read more data"); |
paul@0 | 2998 | + throw ImapParserException( "Unable to read more data" ); |
paul@0 | 2999 | } |
paul@0 | 3000 | - if ( !isdigit( m_data.at( i ) ) ) |
paul@0 | 3001 | + if ( !isdigit( m_data.at( i ) ) ) { |
paul@0 | 3002 | break; |
paul@0 | 3003 | + } |
paul@0 | 3004 | ++i; |
paul@0 | 3005 | } |
paul@0 | 3006 | const QByteArray tmp = m_data.mid( m_position, i - m_position ); |
paul@0 | 3007 | @@ -425,8 +450,7 @@ qint64 ImapStreamParser::readNumber( bool * ok ) |
paul@0 | 3008 | void ImapStreamParser::stripLeadingSpaces() |
paul@0 | 3009 | { |
paul@0 | 3010 | for ( int i = m_position; i < m_data.length(); ++i ) { |
paul@0 | 3011 | - if ( m_data.at(i) != ' ' ) |
paul@0 | 3012 | - { |
paul@0 | 3013 | + if ( m_data.at( i ) != ' ' ) { |
paul@0 | 3014 | m_position = i; |
paul@0 | 3015 | return; |
paul@0 | 3016 | } |
paul@0 | 3017 | @@ -438,10 +462,9 @@ bool ImapStreamParser::waitForMoreData( bool wait ) |
paul@0 | 3018 | { |
paul@0 | 3019 | if ( wait ) { |
paul@0 | 3020 | if ( m_socket->bytesAvailable() > 0 || |
paul@0 | 3021 | - m_socket->waitForReadyRead(30000) ) { |
paul@0 | 3022 | + m_socket->waitForReadyRead( 30000 ) ) { |
paul@0 | 3023 | m_data.append( m_socket->readAll() ); |
paul@0 | 3024 | - } else |
paul@0 | 3025 | - { |
paul@0 | 3026 | + } else { |
paul@0 | 3027 | return false; |
paul@0 | 3028 | } |
paul@0 | 3029 | } |
paul@0 | 3030 | @@ -455,28 +478,31 @@ void ImapStreamParser::setData( const QByteArray &data ) |
paul@0 | 3031 | |
paul@0 | 3032 | QByteArray ImapStreamParser::readRemainingData() |
paul@0 | 3033 | { |
paul@0 | 3034 | - return m_data.mid(m_position); |
paul@0 | 3035 | + return m_data.mid( m_position ); |
paul@0 | 3036 | } |
paul@0 | 3037 | |
paul@0 | 3038 | int ImapStreamParser::availableDataSize() const |
paul@0 | 3039 | { |
paul@0 | 3040 | - return m_socket->bytesAvailable()+m_data.size()-m_position; |
paul@0 | 3041 | + return m_socket->bytesAvailable() + m_data.size() - m_position; |
paul@0 | 3042 | } |
paul@0 | 3043 | |
paul@0 | 3044 | bool ImapStreamParser::atCommandEnd() |
paul@0 | 3045 | { |
paul@0 | 3046 | int savedPos = m_position; |
paul@0 | 3047 | do { |
paul@0 | 3048 | - if ( !waitForMoreData( m_position >= m_data.length() ) ) |
paul@0 | 3049 | - throw ImapParserException("Unable to read more data"); |
paul@0 | 3050 | + if ( !waitForMoreData( m_position >= m_data.length() ) ) { |
paul@0 | 3051 | + throw ImapParserException( "Unable to read more data" ); |
paul@0 | 3052 | + } |
paul@0 | 3053 | stripLeadingSpaces(); |
paul@0 | 3054 | } while ( m_position >= m_data.size() ); |
paul@0 | 3055 | |
paul@0 | 3056 | - if ( m_data.at(m_position) == '\n' || m_data.at(m_position) == '\r') { |
paul@0 | 3057 | - if ( m_data.at(m_position) == '\r' ) |
paul@0 | 3058 | + if ( m_data.at( m_position ) == '\n' || m_data.at( m_position ) == '\r' ) { |
paul@0 | 3059 | + if ( m_data.at( m_position ) == '\r' ) { |
paul@0 | 3060 | ++m_position; |
paul@0 | 3061 | - if ( m_position < m_data.length() && m_data.at(m_position) == '\n' ) |
paul@0 | 3062 | + } |
paul@0 | 3063 | + if ( m_position < m_data.length() && m_data.at( m_position ) == '\n' ) { |
paul@0 | 3064 | ++m_position; |
paul@0 | 3065 | + } |
paul@0 | 3066 | |
paul@0 | 3067 | // We'd better empty m_data from time to time before it grows out of control |
paul@0 | 3068 | trimBuffer(); |
paul@0 | 3069 | @@ -493,29 +519,30 @@ QByteArray ImapStreamParser::readUntilCommandEnd() |
paul@0 | 3070 | int i = m_position; |
paul@0 | 3071 | int paranthesisBalance = 0; |
paul@0 | 3072 | Q_FOREVER { |
paul@0 | 3073 | - if ( !waitForMoreData( m_data.length() <= i ) ) |
paul@0 | 3074 | - { |
paul@0 | 3075 | + if ( !waitForMoreData( m_data.length() <= i ) ) { |
paul@0 | 3076 | m_position = i; |
paul@0 | 3077 | - throw ImapParserException("Unable to read more data"); |
paul@0 | 3078 | + throw ImapParserException( "Unable to read more data" ); |
paul@0 | 3079 | } |
paul@0 | 3080 | - if ( m_data.at(i) == '{' ) |
paul@0 | 3081 | - { |
paul@0 | 3082 | + if ( m_data.at( i ) == '{' ) { |
paul@0 | 3083 | m_position = i - 1; |
paul@0 | 3084 | hasLiteral(); //init literal size |
paul@0 | 3085 | - result.append(m_data.mid(i-1, m_position - i +1)); |
paul@0 | 3086 | - while (!atLiteralEnd()) |
paul@0 | 3087 | - { |
paul@0 | 3088 | + result.append( m_data.mid( i - 1, m_position - i + 1 ) ); |
paul@0 | 3089 | + while ( !atLiteralEnd() ) { |
paul@0 | 3090 | result.append( readLiteralPart() ); |
paul@0 | 3091 | } |
paul@0 | 3092 | i = m_position; |
paul@0 | 3093 | } |
paul@0 | 3094 | - if ( m_data.at(i) == '(' ) |
paul@0 | 3095 | + if ( m_data.at( i ) == '(' ) { |
paul@0 | 3096 | paranthesisBalance++; |
paul@0 | 3097 | - if ( m_data.at(i) == ')' ) |
paul@0 | 3098 | + } |
paul@0 | 3099 | + if ( m_data.at( i ) == ')' ) { |
paul@0 | 3100 | paranthesisBalance--; |
paul@0 | 3101 | - if ( ( i == m_data.length() && paranthesisBalance == 0 ) || m_data.at(i) == '\n' || m_data.at(i) == '\r') |
paul@0 | 3102 | + } |
paul@0 | 3103 | + if ( ( i == m_data.length() && paranthesisBalance == 0 ) || |
paul@0 | 3104 | + m_data.at( i ) == '\n' || m_data.at( i ) == '\r') { |
paul@0 | 3105 | break; //command end |
paul@0 | 3106 | - result.append( m_data.at(i) ); |
paul@0 | 3107 | + } |
paul@0 | 3108 | + result.append( m_data.at( i ) ); |
paul@0 | 3109 | ++i; |
paul@0 | 3110 | } |
paul@0 | 3111 | m_position = i; |
paul@0 | 3112 | @@ -525,16 +552,17 @@ QByteArray ImapStreamParser::readUntilCommandEnd() |
paul@0 | 3113 | |
paul@0 | 3114 | void ImapStreamParser::sendContinuationResponse( qint64 size ) |
paul@0 | 3115 | { |
paul@0 | 3116 | - QByteArray block = "+ Ready for literal data (expecting " |
paul@0 | 3117 | - + QByteArray::number( size ) + " bytes)\r\n"; |
paul@0 | 3118 | - m_socket->write(block); |
paul@0 | 3119 | - m_socket->waitForBytesWritten(30000); |
paul@0 | 3120 | + QByteArray block = "+ Ready for literal data (expecting " + |
paul@0 | 3121 | + QByteArray::number( size ) + " bytes)\r\n"; |
paul@0 | 3122 | + m_socket->write( block ); |
paul@0 | 3123 | + m_socket->waitForBytesWritten( 30000 ); |
paul@0 | 3124 | } |
paul@0 | 3125 | |
paul@0 | 3126 | void ImapStreamParser::trimBuffer() |
paul@0 | 3127 | { |
paul@0 | 3128 | - if ( m_position < 4096 ) // right() is expensive, so don't do it for every line |
paul@0 | 3129 | + if ( m_position < 4096 ) { // right() is expensive, so don't do it for every line |
paul@0 | 3130 | return; |
paul@0 | 3131 | - m_data = m_data.right(m_data.size()-m_position); |
paul@0 | 3132 | + } |
paul@0 | 3133 | + m_data = m_data.right( m_data.size() - m_position ); |
paul@0 | 3134 | m_position = 0; |
paul@0 | 3135 | } |
paul@0 | 3136 | diff --git a/kimap/imapstreamparser.h b/kimap/imapstreamparser.h |
paul@0 | 3137 | index 7c43d1d..12e97b0 100644 |
paul@0 | 3138 | --- a/kimap/imapstreamparser.h |
paul@0 | 3139 | +++ b/kimap/imapstreamparser.h |
paul@0 | 3140 | @@ -36,9 +36,9 @@ namespace KIMAP { |
paul@0 | 3141 | class ImapParserException : public std::exception |
paul@0 | 3142 | { |
paul@0 | 3143 | public: |
paul@0 | 3144 | - ImapParserException( const char *what ) throw() : mWhat( what ) {} |
paul@0 | 3145 | - ImapParserException( const QByteArray &what ) throw() : mWhat( what ) {} |
paul@0 | 3146 | - ImapParserException( const QString &what ) throw() : mWhat( what.toUtf8() ) {} |
paul@0 | 3147 | + explicit ImapParserException( const char *what ) throw() : mWhat( what ) {} |
paul@0 | 3148 | + explicit ImapParserException( const QByteArray &what ) throw() : mWhat( what ) {} |
paul@0 | 3149 | + explicit ImapParserException( const QString &what ) throw() : mWhat( what.toUtf8() ) {} |
paul@0 | 3150 | ImapParserException( const ImapParserException &other ) throw() : std::exception( other ), mWhat( other.what() ) {} |
paul@0 | 3151 | virtual ~ImapParserException() throw() {} |
paul@0 | 3152 | const char *what() const throw() { return mWhat.constData(); } |
paul@0 | 3153 | @@ -86,7 +86,6 @@ class KIMAP_EXPORT ImapStreamParser |
paul@0 | 3154 | */ |
paul@0 | 3155 | QList<QByteArray> readParenthesizedList(); |
paul@0 | 3156 | |
paul@0 | 3157 | - |
paul@0 | 3158 | /** |
paul@0 | 3159 | * Get the next data as a number. This call might block. |
paul@0 | 3160 | * @param ok true if the data found was a number |
paul@0 | 3161 | @@ -181,7 +180,6 @@ class KIMAP_EXPORT ImapStreamParser |
paul@0 | 3162 | |
paul@0 | 3163 | void setData( const QByteArray &data ); |
paul@0 | 3164 | |
paul@0 | 3165 | - |
paul@0 | 3166 | private: |
paul@0 | 3167 | void stripLeadingSpaces(); |
paul@0 | 3168 | QByteArray parseQuotedString(); |
paul@0 | 3169 | diff --git a/kimap/job.cpp b/kimap/job.cpp |
paul@0 | 3170 | index cd30eec..938c941 100644 |
paul@0 | 3171 | --- a/kimap/job.cpp |
paul@0 | 3172 | +++ b/kimap/job.cpp |
paul@0 | 3173 | @@ -22,21 +22,19 @@ |
paul@0 | 3174 | #include "message_p.h" |
paul@0 | 3175 | #include "session_p.h" |
paul@0 | 3176 | |
paul@0 | 3177 | -#include <klocale.h> |
paul@0 | 3178 | -#include <kdebug.h> |
paul@0 | 3179 | +#include <KDE/KLocalizedString> |
paul@0 | 3180 | +#include <KDE/KDebug> |
paul@0 | 3181 | |
paul@0 | 3182 | using namespace KIMAP; |
paul@0 | 3183 | |
paul@0 | 3184 | Job::Job( Session *session ) |
paul@0 | 3185 | - : KJob( session ), d_ptr(new JobPrivate(session, i18n("Job"))) |
paul@0 | 3186 | + : KJob( session ), d_ptr( new JobPrivate( session, i18n( "Job" ) ) ) |
paul@0 | 3187 | { |
paul@0 | 3188 | - |
paul@0 | 3189 | } |
paul@0 | 3190 | |
paul@0 | 3191 | Job::Job( JobPrivate &dd ) |
paul@0 | 3192 | - : KJob( dd.m_session ), d_ptr(&dd) |
paul@0 | 3193 | + : KJob( dd.m_session ), d_ptr( &dd ) |
paul@0 | 3194 | { |
paul@0 | 3195 | - |
paul@0 | 3196 | } |
paul@0 | 3197 | |
paul@0 | 3198 | Job::~Job() |
paul@0 | 3199 | @@ -46,40 +44,40 @@ Job::~Job() |
paul@0 | 3200 | |
paul@0 | 3201 | Session *Job::session() const |
paul@0 | 3202 | { |
paul@0 | 3203 | - Q_D(const Job); |
paul@0 | 3204 | + Q_D( const Job ); |
paul@0 | 3205 | return d->m_session; |
paul@0 | 3206 | } |
paul@0 | 3207 | |
paul@0 | 3208 | void Job::start() |
paul@0 | 3209 | { |
paul@0 | 3210 | - Q_D(Job); |
paul@0 | 3211 | - d->sessionInternal()->addJob(this); |
paul@0 | 3212 | + Q_D( Job ); |
paul@0 | 3213 | + d->sessionInternal()->addJob( this ); |
paul@0 | 3214 | } |
paul@0 | 3215 | |
paul@0 | 3216 | void Job::handleResponse(const Message &response) |
paul@0 | 3217 | { |
paul@0 | 3218 | - handleErrorReplies(response); |
paul@0 | 3219 | + handleErrorReplies( response ); |
paul@0 | 3220 | } |
paul@0 | 3221 | |
paul@0 | 3222 | void Job::connectionLost() |
paul@0 | 3223 | { |
paul@0 | 3224 | setError( KJob::UserDefinedError ); |
paul@0 | 3225 | - setErrorText( i18n("Connection to server lost.") ); |
paul@0 | 3226 | + setErrorText( i18n( "Connection to server lost." ) ); |
paul@0 | 3227 | emitResult(); |
paul@0 | 3228 | } |
paul@0 | 3229 | |
paul@0 | 3230 | Job::HandlerResponse Job::handleErrorReplies(const Message &response) |
paul@0 | 3231 | { |
paul@0 | 3232 | - Q_D(Job); |
paul@0 | 3233 | -// qDebug() << response.toString(); |
paul@0 | 3234 | + Q_D( Job ); |
paul@0 | 3235 | +// kDebug() << response.toString(); |
paul@0 | 3236 | |
paul@0 | 3237 | - if ( !response.content.isEmpty() |
paul@0 | 3238 | - && d->tags.contains( response.content.first().toString() ) ) { |
paul@0 | 3239 | + if ( !response.content.isEmpty() && |
paul@0 | 3240 | + d->tags.contains( response.content.first().toString() ) ) { |
paul@0 | 3241 | if ( response.content.size() < 2 ) { |
paul@0 | 3242 | - setErrorText( i18n("%1 failed, malformed reply from the server.", d->m_name) ); |
paul@0 | 3243 | + setErrorText( i18n( "%1 failed, malformed reply from the server.", d->m_name ) ); |
paul@0 | 3244 | } else if ( response.content[1].toString() != "OK" ) { |
paul@0 | 3245 | setError( UserDefinedError ); |
paul@0 | 3246 | - setErrorText( i18n("%1 failed, server replied: %2", d->m_name, response.toString().constData()) ); |
paul@0 | 3247 | + setErrorText( i18n( "%1 failed, server replied: %2", d->m_name, response.toString().constData() ) ); |
paul@0 | 3248 | } |
paul@0 | 3249 | d->tags.removeAll( response.content.first().toString() ); |
paul@0 | 3250 | if ( d->tags.isEmpty() ) { // Only emit result when the last command returned |
paul@0 | 3251 | @@ -92,3 +90,4 @@ Job::HandlerResponse Job::handleErrorReplies(const Message &response) |
paul@0 | 3252 | } |
paul@0 | 3253 | |
paul@0 | 3254 | #include "job.moc" |
paul@0 | 3255 | + |
paul@0 | 3256 | diff --git a/kimap/job.h b/kimap/job.h |
paul@0 | 3257 | index 79dd9a6..6bb5670 100644 |
paul@0 | 3258 | --- a/kimap/job.h |
paul@0 | 3259 | +++ b/kimap/job.h |
paul@0 | 3260 | @@ -22,7 +22,7 @@ |
paul@0 | 3261 | |
paul@0 | 3262 | #include "kimap_export.h" |
paul@0 | 3263 | |
paul@0 | 3264 | -#include <kjob.h> |
paul@0 | 3265 | +#include <KDE/KJob> |
paul@0 | 3266 | |
paul@0 | 3267 | namespace KIMAP { |
paul@0 | 3268 | |
paul@0 | 3269 | @@ -34,7 +34,7 @@ struct Message; |
paul@0 | 3270 | class KIMAP_EXPORT Job : public KJob |
paul@0 | 3271 | { |
paul@0 | 3272 | Q_OBJECT |
paul@0 | 3273 | - Q_DECLARE_PRIVATE(Job) |
paul@0 | 3274 | + Q_DECLARE_PRIVATE( Job ) |
paul@0 | 3275 | |
paul@0 | 3276 | friend class SessionPrivate; |
paul@0 | 3277 | |
paul@0 | 3278 | diff --git a/kimap/job_p.h b/kimap/job_p.h |
paul@0 | 3279 | index b04cf9c..6e4b717 100644 |
paul@0 | 3280 | --- a/kimap/job_p.h |
paul@0 | 3281 | +++ b/kimap/job_p.h |
paul@0 | 3282 | @@ -21,7 +21,7 @@ |
paul@0 | 3283 | #define KIMAP_JOB_P_H |
paul@0 | 3284 | |
paul@0 | 3285 | #include "session.h" |
paul@0 | 3286 | -#include <klocale.h> |
paul@0 | 3287 | +#include <KDE/KLocalizedString> |
paul@0 | 3288 | |
paul@0 | 3289 | namespace KIMAP { |
paul@0 | 3290 | |
paul@0 | 3291 | @@ -30,7 +30,7 @@ class SessionPrivate; |
paul@0 | 3292 | class JobPrivate |
paul@0 | 3293 | { |
paul@0 | 3294 | public: |
paul@0 | 3295 | - JobPrivate( Session *session, const QString& name ) : m_session(session) { |
paul@0 | 3296 | + JobPrivate( Session *session, const QString& name ) : m_session( session ) { |
paul@0 | 3297 | m_name = name; |
paul@0 | 3298 | } |
paul@0 | 3299 | virtual ~JobPrivate() { } |
paul@0 | 3300 | diff --git a/kimap/listjob.cpp b/kimap/listjob.cpp |
paul@0 | 3301 | index 60f8071..322fc37 100644 |
paul@0 | 3302 | --- a/kimap/listjob.cpp |
paul@0 | 3303 | +++ b/kimap/listjob.cpp |
paul@0 | 3304 | @@ -21,7 +21,7 @@ |
paul@0 | 3305 | |
paul@0 | 3306 | #include <boost/bind.hpp> |
paul@0 | 3307 | #include <QtCore/QTimer> |
paul@0 | 3308 | -#include <klocale.h> |
paul@0 | 3309 | +#include <KDE/KLocalizedString> |
paul@0 | 3310 | |
paul@0 | 3311 | #include "job_p.h" |
paul@0 | 3312 | #include "message_p.h" |
paul@0 | 3313 | @@ -33,7 +33,7 @@ namespace KIMAP |
paul@0 | 3314 | class ListJobPrivate : public JobPrivate |
paul@0 | 3315 | { |
paul@0 | 3316 | public: |
paul@0 | 3317 | - ListJobPrivate( ListJob *job, Session *session, const QString& name ) : JobPrivate(session, name), q(job), option(ListJob::NoOption) { } |
paul@0 | 3318 | + ListJobPrivate( ListJob *job, Session *session, const QString& name ) : JobPrivate( session, name ), q( job ), option( ListJob::NoOption ) { } |
paul@0 | 3319 | ~ListJobPrivate() { } |
paul@0 | 3320 | |
paul@0 | 3321 | void emitPendings() |
paul@0 | 3322 | @@ -63,9 +63,9 @@ namespace KIMAP |
paul@0 | 3323 | using namespace KIMAP; |
paul@0 | 3324 | |
paul@0 | 3325 | ListJob::ListJob( Session *session ) |
paul@0 | 3326 | - : Job( *new ListJobPrivate(this, session, i18n("List")) ) |
paul@0 | 3327 | + : Job( *new ListJobPrivate( this, session, i18n( "List" ) ) ) |
paul@0 | 3328 | { |
paul@0 | 3329 | - Q_D(ListJob); |
paul@0 | 3330 | + Q_D( ListJob ); |
paul@0 | 3331 | connect( &d->emitPendingsTimer, SIGNAL(timeout()), |
paul@0 | 3332 | this, SLOT(emitPendings()) ); |
paul@0 | 3333 | } |
paul@0 | 3334 | @@ -76,8 +76,8 @@ ListJob::~ListJob() |
paul@0 | 3335 | |
paul@0 | 3336 | void ListJob::setIncludeUnsubscribed( bool include ) |
paul@0 | 3337 | { |
paul@0 | 3338 | - Q_D(ListJob); |
paul@0 | 3339 | - if (include) { |
paul@0 | 3340 | + Q_D( ListJob ); |
paul@0 | 3341 | + if ( include ) { |
paul@0 | 3342 | d->option = ListJob::IncludeUnsubscribed; |
paul@0 | 3343 | } else { |
paul@0 | 3344 | d->option = ListJob::NoOption; |
paul@0 | 3345 | @@ -86,31 +86,31 @@ void ListJob::setIncludeUnsubscribed( bool include ) |
paul@0 | 3346 | |
paul@0 | 3347 | bool ListJob::isIncludeUnsubscribed() const |
paul@0 | 3348 | { |
paul@0 | 3349 | - Q_D(const ListJob); |
paul@0 | 3350 | + Q_D( const ListJob ); |
paul@0 | 3351 | return ( d->option == ListJob::IncludeUnsubscribed ); |
paul@0 | 3352 | } |
paul@0 | 3353 | |
paul@0 | 3354 | void ListJob::setOption( Option option ) |
paul@0 | 3355 | { |
paul@0 | 3356 | - Q_D(ListJob); |
paul@0 | 3357 | + Q_D( ListJob ); |
paul@0 | 3358 | d->option = option; |
paul@0 | 3359 | } |
paul@0 | 3360 | |
paul@0 | 3361 | ListJob::Option ListJob::option() const |
paul@0 | 3362 | { |
paul@0 | 3363 | - Q_D(const ListJob); |
paul@0 | 3364 | + Q_D( const ListJob ); |
paul@0 | 3365 | return d->option; |
paul@0 | 3366 | } |
paul@0 | 3367 | |
paul@0 | 3368 | void ListJob::setQueriedNamespaces( const QList<MailBoxDescriptor> &namespaces ) |
paul@0 | 3369 | { |
paul@0 | 3370 | - Q_D(ListJob); |
paul@0 | 3371 | + Q_D( ListJob ); |
paul@0 | 3372 | d->namespaces = namespaces; |
paul@0 | 3373 | } |
paul@0 | 3374 | |
paul@0 | 3375 | QList<MailBoxDescriptor> ListJob::queriedNamespaces() const |
paul@0 | 3376 | { |
paul@0 | 3377 | - Q_D(const ListJob); |
paul@0 | 3378 | + Q_D( const ListJob ); |
paul@0 | 3379 | return d->namespaces; |
paul@0 | 3380 | } |
paul@0 | 3381 | |
paul@0 | 3382 | @@ -126,9 +126,9 @@ QMap< MailBoxDescriptor, QList<QByteArray> > ListJob::flags() const |
paul@0 | 3383 | |
paul@0 | 3384 | void ListJob::doStart() |
paul@0 | 3385 | { |
paul@0 | 3386 | - Q_D(ListJob); |
paul@0 | 3387 | + Q_D( ListJob ); |
paul@0 | 3388 | |
paul@0 | 3389 | - switch (d->option) { |
paul@0 | 3390 | + switch ( d->option ) { |
paul@0 | 3391 | break; |
paul@0 | 3392 | case IncludeUnsubscribed: |
paul@0 | 3393 | d->command = "LIST"; |
paul@0 | 3394 | @@ -157,20 +157,20 @@ void ListJob::doStart() |
paul@0 | 3395 | } |
paul@0 | 3396 | |
paul@0 | 3397 | d->tags << d->sessionInternal()->sendCommand( d->command, |
paul@0 | 3398 | - parameters.arg( descriptor.name+'*' ).toUtf8() ); |
paul@0 | 3399 | + parameters.arg( descriptor.name + '*' ).toUtf8() ); |
paul@0 | 3400 | } |
paul@0 | 3401 | } |
paul@0 | 3402 | } |
paul@0 | 3403 | |
paul@0 | 3404 | void ListJob::handleResponse( const Message &response ) |
paul@0 | 3405 | { |
paul@0 | 3406 | - Q_D(ListJob); |
paul@0 | 3407 | + Q_D( ListJob ); |
paul@0 | 3408 | |
paul@0 | 3409 | // We can predict it'll be handled by handleErrorReplies() so stop |
paul@0 | 3410 | // the timer now so that result() will really be the last emitted signal. |
paul@0 | 3411 | - if ( !response.content.isEmpty() |
paul@0 | 3412 | - && d->tags.size() == 1 |
paul@0 | 3413 | - && d->tags.contains( response.content.first().toString() ) ) { |
paul@0 | 3414 | + if ( !response.content.isEmpty() && |
paul@0 | 3415 | + d->tags.size() == 1 && |
paul@0 | 3416 | + d->tags.contains( response.content.first().toString() ) ) { |
paul@0 | 3417 | d->emitPendingsTimer.stop(); |
paul@0 | 3418 | d->emitPendings(); |
paul@0 | 3419 | } |
paul@0 | 3420 | @@ -178,7 +178,7 @@ void ListJob::handleResponse( const Message &response ) |
paul@0 | 3421 | if ( handleErrorReplies( response ) == NotHandled ) { |
paul@0 | 3422 | if ( response.content.size() >= 5 && response.content[1].toString() == d->command ) { |
paul@0 | 3423 | QList<QByteArray> flags = response.content[2].toList(); |
paul@0 | 3424 | - std::transform( flags.begin(), flags.end(), flags.begin(), boost::bind(&QByteArray::toLower, _1) ); |
paul@0 | 3425 | + std::transform( flags.begin(), flags.end(), flags.begin(), boost::bind( &QByteArray::toLower, _1 ) ); |
paul@0 | 3426 | QByteArray separator = response.content[3].toString(); |
paul@0 | 3427 | if ( separator.isEmpty() ) { |
paul@0 | 3428 | // Defaults to / for servers reporting an empty list |
paul@0 | 3429 | @@ -186,7 +186,7 @@ void ListJob::handleResponse( const Message &response ) |
paul@0 | 3430 | // only do it for mailboxes with no child. |
paul@0 | 3431 | separator = "/"; //krazy:exclude=doublequote_chars since a QByteArray |
paul@0 | 3432 | } |
paul@0 | 3433 | - Q_ASSERT(separator.size()==1); |
paul@0 | 3434 | + Q_ASSERT( separator.size() == 1 ); |
paul@0 | 3435 | QByteArray fullName; |
paul@0 | 3436 | for ( int i=4; i<response.content.size(); i++ ) { |
paul@0 | 3437 | fullName += response.content[i].toString() + ' '; |
paul@0 | 3438 | @@ -209,12 +209,16 @@ void ListJob::handleResponse( const Message &response ) |
paul@0 | 3439 | void ListJob::convertInboxName(KIMAP::MailBoxDescriptor& descriptor) |
paul@0 | 3440 | { |
paul@0 | 3441 | //Inbox must be case sensitive, according to the RFC, so make it always uppercase |
paul@0 | 3442 | - QStringList pathParts = descriptor.name.split(descriptor.separator); |
paul@0 | 3443 | - if ( !pathParts.isEmpty() && pathParts[0].compare( QLatin1String("INBOX"), Qt::CaseInsensitive ) == 0 ) { |
paul@0 | 3444 | - pathParts.removeAt(0); |
paul@0 | 3445 | - descriptor.name = QLatin1String("INBOX"); |
paul@0 | 3446 | - if ( !pathParts.isEmpty() ) |
paul@0 | 3447 | + QStringList pathParts = descriptor.name.split( descriptor.separator ); |
paul@0 | 3448 | + if ( !pathParts.isEmpty() && |
paul@0 | 3449 | + pathParts[0].compare( QLatin1String( "INBOX" ), Qt::CaseInsensitive ) == 0 ) { |
paul@0 | 3450 | + pathParts.removeAt( 0 ); |
paul@0 | 3451 | + descriptor.name = QLatin1String( "INBOX" ); |
paul@0 | 3452 | + if ( !pathParts.isEmpty() ) { |
paul@0 | 3453 | descriptor.name += descriptor.separator + pathParts.join( descriptor.separator ); |
paul@0 | 3454 | + } |
paul@0 | 3455 | } |
paul@0 | 3456 | } |
paul@0 | 3457 | + |
paul@0 | 3458 | #include "listjob.moc" |
paul@0 | 3459 | + |
paul@0 | 3460 | diff --git a/kimap/listjob.h b/kimap/listjob.h |
paul@0 | 3461 | index c90cea6..4d87018 100644 |
paul@0 | 3462 | --- a/kimap/listjob.h |
paul@0 | 3463 | +++ b/kimap/listjob.h |
paul@0 | 3464 | @@ -37,19 +37,19 @@ struct KIMAP_EXPORT MailBoxDescriptor |
paul@0 | 3465 | |
paul@0 | 3466 | inline bool operator==(const MailBoxDescriptor &other) const |
paul@0 | 3467 | { |
paul@0 | 3468 | - return other.name==name && other.separator==separator; |
paul@0 | 3469 | + return other.name == name && other.separator == separator; |
paul@0 | 3470 | } |
paul@0 | 3471 | |
paul@0 | 3472 | inline bool operator<(const MailBoxDescriptor &other) const |
paul@0 | 3473 | { |
paul@0 | 3474 | - return other.name<name || (other.name==name && other.separator<separator); |
paul@0 | 3475 | + return other.name < name || ( other.name == name && other.separator < separator ); |
paul@0 | 3476 | } |
paul@0 | 3477 | }; |
paul@0 | 3478 | |
paul@0 | 3479 | class KIMAP_EXPORT ListJob : public Job |
paul@0 | 3480 | { |
paul@0 | 3481 | Q_OBJECT |
paul@0 | 3482 | - Q_DECLARE_PRIVATE(ListJob) |
paul@0 | 3483 | + Q_DECLARE_PRIVATE( ListJob ) |
paul@0 | 3484 | |
paul@0 | 3485 | friend class SessionPrivate; |
paul@0 | 3486 | |
paul@0 | 3487 | diff --git a/kimap/listrightsjob.cpp b/kimap/listrightsjob.cpp |
paul@0 | 3488 | index 4e79aec..bde9ff0 100644 |
paul@0 | 3489 | --- a/kimap/listrightsjob.cpp |
paul@0 | 3490 | +++ b/kimap/listrightsjob.cpp |
paul@0 | 3491 | @@ -19,8 +19,8 @@ |
paul@0 | 3492 | |
paul@0 | 3493 | #include "listrightsjob.h" |
paul@0 | 3494 | |
paul@0 | 3495 | -#include <klocale.h> |
paul@0 | 3496 | -#include <kdebug.h> |
paul@0 | 3497 | +#include <KDE/KLocalizedString> |
paul@0 | 3498 | +#include <KDE/KDebug> |
paul@0 | 3499 | |
paul@0 | 3500 | #include "acljobbase_p.h" |
paul@0 | 3501 | #include "message_p.h" |
paul@0 | 3502 | @@ -32,7 +32,7 @@ namespace KIMAP |
paul@0 | 3503 | class ListRightsJobPrivate : public AclJobBasePrivate |
paul@0 | 3504 | { |
paul@0 | 3505 | public: |
paul@0 | 3506 | - ListRightsJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate(session, name), defaultRights(Acl::None) {} |
paul@0 | 3507 | + ListRightsJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate( session, name ), defaultRights( Acl::None ) {} |
paul@0 | 3508 | ~ListRightsJobPrivate() { } |
paul@0 | 3509 | |
paul@0 | 3510 | Acl::Rights defaultRights; |
paul@0 | 3511 | @@ -44,7 +44,7 @@ namespace KIMAP |
paul@0 | 3512 | using namespace KIMAP; |
paul@0 | 3513 | |
paul@0 | 3514 | ListRightsJob::ListRightsJob( Session *session ) |
paul@0 | 3515 | - : AclJobBase(*new ListRightsJobPrivate(session, i18n("ListRights"))) |
paul@0 | 3516 | + : AclJobBase( *new ListRightsJobPrivate( session, i18n( "ListRights" ) ) ) |
paul@0 | 3517 | { |
paul@0 | 3518 | |
paul@0 | 3519 | } |
paul@0 | 3520 | @@ -55,53 +55,53 @@ ListRightsJob::~ListRightsJob() |
paul@0 | 3521 | |
paul@0 | 3522 | void ListRightsJob::doStart() |
paul@0 | 3523 | { |
paul@0 | 3524 | - Q_D(ListRightsJob); |
paul@0 | 3525 | + Q_D( ListRightsJob ); |
paul@0 | 3526 | |
paul@0 | 3527 | d->tags << d->sessionInternal()->sendCommand( "LISTRIGHTS", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + "\" \"" + d->id + "\"" ); |
paul@0 | 3528 | } |
paul@0 | 3529 | |
paul@0 | 3530 | void ListRightsJob::handleResponse( const Message &response ) |
paul@0 | 3531 | { |
paul@0 | 3532 | - Q_D(ListRightsJob); |
paul@0 | 3533 | + Q_D( ListRightsJob ); |
paul@0 | 3534 | |
paul@0 | 3535 | - if (handleErrorReplies(response) == NotHandled) { |
paul@0 | 3536 | - if ( response.content.size() >= 4 |
paul@0 | 3537 | - && response.content[1].toString() == "LISTRIGHTS" ) { |
paul@0 | 3538 | + if ( handleErrorReplies( response ) == NotHandled ) { |
paul@0 | 3539 | + if ( response.content.size() >= 4 && |
paul@0 | 3540 | + response.content[1].toString() == "LISTRIGHTS" ) { |
paul@0 | 3541 | QByteArray s = response.content[4].toString(); |
paul@0 | 3542 | - d->defaultRights = Acl::rightsFromString(s); |
paul@0 | 3543 | + d->defaultRights = Acl::rightsFromString( s ); |
paul@0 | 3544 | int i = 5; |
paul@0 | 3545 | - while ( i < response.content.size()) { |
paul@0 | 3546 | + while ( i < response.content.size() ) { |
paul@0 | 3547 | s = response.content[i].toString(); |
paul@0 | 3548 | - d->possibleRights.append(Acl::rightsFromString(s)); |
paul@0 | 3549 | + d->possibleRights.append( Acl::rightsFromString( s ) ); |
paul@0 | 3550 | i++; |
paul@0 | 3551 | } |
paul@0 | 3552 | } |
paul@0 | 3553 | } |
paul@0 | 3554 | } |
paul@0 | 3555 | |
paul@0 | 3556 | - |
paul@0 | 3557 | void ListRightsJob::setIdentifier( const QByteArray &identifier ) |
paul@0 | 3558 | { |
paul@0 | 3559 | - Q_D(ListRightsJob); |
paul@0 | 3560 | - d->setIdentifier(identifier); |
paul@0 | 3561 | + Q_D( ListRightsJob ); |
paul@0 | 3562 | + d->setIdentifier( identifier ); |
paul@0 | 3563 | } |
paul@0 | 3564 | |
paul@0 | 3565 | QByteArray ListRightsJob::identifier() |
paul@0 | 3566 | { |
paul@0 | 3567 | - Q_D(ListRightsJob); |
paul@0 | 3568 | + Q_D( ListRightsJob ); |
paul@0 | 3569 | return d->identifier(); |
paul@0 | 3570 | } |
paul@0 | 3571 | |
paul@0 | 3572 | Acl::Rights ListRightsJob::defaultRights() |
paul@0 | 3573 | { |
paul@0 | 3574 | - Q_D(ListRightsJob); |
paul@0 | 3575 | + Q_D( ListRightsJob ); |
paul@0 | 3576 | return d->defaultRights; |
paul@0 | 3577 | } |
paul@0 | 3578 | |
paul@0 | 3579 | QList<Acl::Rights> ListRightsJob::possibleRights() |
paul@0 | 3580 | { |
paul@0 | 3581 | - Q_D(ListRightsJob); |
paul@0 | 3582 | + Q_D( ListRightsJob ); |
paul@0 | 3583 | return d->possibleRights; |
paul@0 | 3584 | } |
paul@0 | 3585 | |
paul@0 | 3586 | #include "listrightsjob.moc" |
paul@0 | 3587 | + |
paul@0 | 3588 | diff --git a/kimap/listrightsjob.h b/kimap/listrightsjob.h |
paul@0 | 3589 | index ed4850d..edff595 100644 |
paul@0 | 3590 | --- a/kimap/listrightsjob.h |
paul@0 | 3591 | +++ b/kimap/listrightsjob.h |
paul@0 | 3592 | @@ -30,7 +30,6 @@ class Session; |
paul@0 | 3593 | struct Message; |
paul@0 | 3594 | class ListRightsJobPrivate; |
paul@0 | 3595 | |
paul@0 | 3596 | - |
paul@0 | 3597 | /** |
paul@0 | 3598 | * Lists the possible and automatic rights for |
paul@0 | 3599 | * an identifier on a mailbox |
paul@0 | 3600 | @@ -49,7 +48,7 @@ class ListRightsJobPrivate; |
paul@0 | 3601 | class KIMAP_EXPORT ListRightsJob : public AclJobBase |
paul@0 | 3602 | { |
paul@0 | 3603 | Q_OBJECT |
paul@0 | 3604 | - Q_DECLARE_PRIVATE(ListRightsJob) |
paul@0 | 3605 | + Q_DECLARE_PRIVATE( ListRightsJob ) |
paul@0 | 3606 | |
paul@0 | 3607 | friend class SessionPrivate; |
paul@0 | 3608 | |
paul@0 | 3609 | diff --git a/kimap/loginjob.cpp b/kimap/loginjob.cpp |
paul@0 | 3610 | index da869be..02634b0 100644 |
paul@0 | 3611 | --- a/kimap/loginjob.cpp |
paul@0 | 3612 | +++ b/kimap/loginjob.cpp |
paul@0 | 3613 | @@ -2,7 +2,6 @@ |
paul@0 | 3614 | Copyright (c) 2009 Kevin Ottens <ervin@kde.org> |
paul@0 | 3615 | Copyright (c) 2009 Andras Mantia <amantia@kde.org> |
paul@0 | 3616 | |
paul@0 | 3617 | - |
paul@0 | 3618 | This library is free software; you can redistribute it and/or modify it |
paul@0 | 3619 | under the terms of the GNU Library General Public License as published by |
paul@0 | 3620 | the Free Software Foundation; either version 2 of the License, or (at your |
paul@0 | 3621 | @@ -21,8 +20,8 @@ |
paul@0 | 3622 | |
paul@0 | 3623 | #include "loginjob.h" |
paul@0 | 3624 | |
paul@0 | 3625 | -#include <klocale.h> |
paul@0 | 3626 | -#include <kdebug.h> |
paul@0 | 3627 | +#include <KDE/KLocalizedString> |
paul@0 | 3628 | +#include <KDE/KDebug> |
paul@0 | 3629 | #include <ktcpsocket.h> |
paul@0 | 3630 | |
paul@0 | 3631 | #include "job_p.h" |
paul@0 | 3632 | @@ -59,7 +58,7 @@ namespace KIMAP |
paul@0 | 3633 | Authenticate |
paul@0 | 3634 | }; |
paul@0 | 3635 | |
paul@0 | 3636 | - LoginJobPrivate( LoginJob *job, Session *session, const QString& name ) : JobPrivate(session, name), q(job), encryptionMode(LoginJob::Unencrypted), authState(Login), plainLoginDisabled(false) { |
paul@0 | 3637 | + LoginJobPrivate( LoginJob *job, Session *session, const QString& name ) : JobPrivate( session, name ), q( job ), encryptionMode( LoginJob::Unencrypted ), authState( Login ), plainLoginDisabled( false ) { |
paul@0 | 3638 | conn = 0; |
paul@0 | 3639 | client_interact = 0; |
paul@0 | 3640 | } |
paul@0 | 3641 | @@ -93,7 +92,7 @@ using namespace KIMAP; |
paul@0 | 3642 | |
paul@0 | 3643 | bool LoginJobPrivate::sasl_interact() |
paul@0 | 3644 | { |
paul@0 | 3645 | - kDebug() <<"sasl_interact"; |
paul@0 | 3646 | + kDebug() << "sasl_interact"; |
paul@0 | 3647 | sasl_interact_t *interact = client_interact; |
paul@0 | 3648 | |
paul@0 | 3649 | //some mechanisms do not require username && pass, so it doesn't need a popup |
paul@0 | 3650 | @@ -107,23 +106,23 @@ bool LoginJobPrivate::sasl_interact() |
paul@0 | 3651 | } |
paul@0 | 3652 | |
paul@0 | 3653 | interact = client_interact; |
paul@0 | 3654 | - while( interact->id != SASL_CB_LIST_END ) { |
paul@0 | 3655 | - kDebug() <<"SASL_INTERACT id:" << interact->id; |
paul@0 | 3656 | - switch( interact->id ) { |
paul@0 | 3657 | + while ( interact->id != SASL_CB_LIST_END ) { |
paul@0 | 3658 | + kDebug() << "SASL_INTERACT id:" << interact->id; |
paul@0 | 3659 | + switch ( interact->id ) { |
paul@0 | 3660 | case SASL_CB_AUTHNAME: |
paul@0 | 3661 | if ( !authorizationName.isEmpty() ) { |
paul@0 | 3662 | - kDebug() <<"SASL_CB_[AUTHNAME]: '" << authorizationName <<"'"; |
paul@0 | 3663 | + kDebug() << "SASL_CB_[AUTHNAME]: '" << authorizationName << "'"; |
paul@0 | 3664 | interact->result = strdup( authorizationName.toUtf8() ); |
paul@0 | 3665 | interact->len = strlen( (const char *) interact->result ); |
paul@0 | 3666 | break; |
paul@0 | 3667 | } |
paul@0 | 3668 | case SASL_CB_USER: |
paul@0 | 3669 | - kDebug() <<"SASL_CB_[USER|AUTHNAME]: '" << userName <<"'"; |
paul@0 | 3670 | + kDebug() << "SASL_CB_[USER|AUTHNAME]: '" << userName << "'"; |
paul@0 | 3671 | interact->result = strdup( userName.toUtf8() ); |
paul@0 | 3672 | interact->len = strlen( (const char *) interact->result ); |
paul@0 | 3673 | break; |
paul@0 | 3674 | case SASL_CB_PASS: |
paul@0 | 3675 | - kDebug() <<"SASL_CB_PASS: [hidden]"; |
paul@0 | 3676 | + kDebug() << "SASL_CB_PASS: [hidden]"; |
paul@0 | 3677 | interact->result = strdup( password.toUtf8() ); |
paul@0 | 3678 | interact->len = strlen( (const char *) interact->result ); |
paul@0 | 3679 | break; |
paul@0 | 3680 | @@ -137,62 +136,64 @@ bool LoginJobPrivate::sasl_interact() |
paul@0 | 3681 | return true; |
paul@0 | 3682 | } |
paul@0 | 3683 | |
paul@0 | 3684 | - |
paul@0 | 3685 | LoginJob::LoginJob( Session *session ) |
paul@0 | 3686 | - : Job( *new LoginJobPrivate(this, session, i18n("Login")) ) |
paul@0 | 3687 | + : Job( *new LoginJobPrivate( this, session, i18n( "Login" ) ) ) |
paul@0 | 3688 | { |
paul@0 | 3689 | - Q_D(LoginJob); |
paul@0 | 3690 | - connect(d->sessionInternal(), SIGNAL(encryptionNegotiationResult(bool)), this, SLOT(sslResponse(bool))); |
paul@0 | 3691 | + Q_D( LoginJob ); |
paul@0 | 3692 | + connect( d->sessionInternal(), SIGNAL(encryptionNegotiationResult(bool)), this, SLOT(sslResponse(bool)) ); |
paul@0 | 3693 | + kDebug() << this; |
paul@0 | 3694 | } |
paul@0 | 3695 | |
paul@0 | 3696 | LoginJob::~LoginJob() |
paul@0 | 3697 | { |
paul@0 | 3698 | + kDebug() << this; |
paul@0 | 3699 | } |
paul@0 | 3700 | |
paul@0 | 3701 | QString LoginJob::userName() const |
paul@0 | 3702 | { |
paul@0 | 3703 | - Q_D(const LoginJob); |
paul@0 | 3704 | + Q_D( const LoginJob ); |
paul@0 | 3705 | return d->userName; |
paul@0 | 3706 | } |
paul@0 | 3707 | |
paul@0 | 3708 | void LoginJob::setUserName( const QString &userName ) |
paul@0 | 3709 | { |
paul@0 | 3710 | - Q_D(LoginJob); |
paul@0 | 3711 | + Q_D( LoginJob ); |
paul@0 | 3712 | d->userName = userName; |
paul@0 | 3713 | } |
paul@0 | 3714 | |
paul@0 | 3715 | QString LoginJob::authorizationName() const |
paul@0 | 3716 | { |
paul@0 | 3717 | - Q_D(const LoginJob); |
paul@0 | 3718 | + Q_D( const LoginJob ); |
paul@0 | 3719 | return d->authorizationName; |
paul@0 | 3720 | } |
paul@0 | 3721 | |
paul@0 | 3722 | void LoginJob::setAuthorizationName( const QString& authorizationName ) |
paul@0 | 3723 | { |
paul@0 | 3724 | - Q_D(LoginJob); |
paul@0 | 3725 | + Q_D( LoginJob ); |
paul@0 | 3726 | d->authorizationName = authorizationName; |
paul@0 | 3727 | } |
paul@0 | 3728 | |
paul@0 | 3729 | QString LoginJob::password() const |
paul@0 | 3730 | { |
paul@0 | 3731 | - Q_D(const LoginJob); |
paul@0 | 3732 | + Q_D( const LoginJob ); |
paul@0 | 3733 | return d->password; |
paul@0 | 3734 | } |
paul@0 | 3735 | |
paul@0 | 3736 | void LoginJob::setPassword( const QString &password ) |
paul@0 | 3737 | { |
paul@0 | 3738 | - Q_D(LoginJob); |
paul@0 | 3739 | + Q_D( LoginJob ); |
paul@0 | 3740 | d->password = password; |
paul@0 | 3741 | } |
paul@0 | 3742 | |
paul@0 | 3743 | void LoginJob::doStart() |
paul@0 | 3744 | { |
paul@0 | 3745 | - Q_D(LoginJob); |
paul@0 | 3746 | + Q_D( LoginJob ); |
paul@0 | 3747 | |
paul@0 | 3748 | + kDebug() << this; |
paul@0 | 3749 | // Don't authenticate on a session in the authenticated state |
paul@0 | 3750 | if ( session()->state() == Session::Authenticated || session()->state() == Session::Selected ) { |
paul@0 | 3751 | setError( UserDefinedError ); |
paul@0 | 3752 | - setErrorText( i18n("IMAP session in the wrong state for authentication") ); |
paul@0 | 3753 | + setErrorText( i18n( "IMAP session in the wrong state for authentication" ) ); |
paul@0 | 3754 | emitResult(); |
paul@0 | 3755 | return; |
paul@0 | 3756 | } |
paul@0 | 3757 | @@ -209,53 +210,57 @@ void LoginJob::doStart() |
paul@0 | 3758 | // (so for instance we won't issue another STARTTLS for nothing if that's |
paul@0 | 3759 | // not needed) |
paul@0 | 3760 | case KTcpSocket::SslV2: |
paul@0 | 3761 | - if ( encryptionMode==SslV2 ) { |
paul@0 | 3762 | + if ( encryptionMode == SslV2 ) { |
paul@0 | 3763 | encryptionMode = Unencrypted; |
paul@0 | 3764 | } |
paul@0 | 3765 | break; |
paul@0 | 3766 | case KTcpSocket::SslV3: |
paul@0 | 3767 | - if ( encryptionMode==SslV3 ) { |
paul@0 | 3768 | + if ( encryptionMode == SslV3 ) { |
paul@0 | 3769 | encryptionMode = Unencrypted; |
paul@0 | 3770 | } |
paul@0 | 3771 | break; |
paul@0 | 3772 | case KTcpSocket::TlsV1: |
paul@0 | 3773 | - if ( encryptionMode==TlsV1 ) { |
paul@0 | 3774 | + if ( encryptionMode == TlsV1 ) { |
paul@0 | 3775 | encryptionMode = Unencrypted; |
paul@0 | 3776 | } |
paul@0 | 3777 | break; |
paul@0 | 3778 | case KTcpSocket::AnySslVersion: |
paul@0 | 3779 | - if ( encryptionMode==AnySslVersion ) { |
paul@0 | 3780 | + if ( encryptionMode == AnySslVersion ) { |
paul@0 | 3781 | encryptionMode = Unencrypted; |
paul@0 | 3782 | } |
paul@0 | 3783 | break; |
paul@0 | 3784 | } |
paul@0 | 3785 | |
paul@0 | 3786 | - if (encryptionMode == SslV2 |
paul@0 | 3787 | - || encryptionMode == SslV3 |
paul@0 | 3788 | - || encryptionMode == SslV3_1 |
paul@0 | 3789 | - || encryptionMode == AnySslVersion) { |
paul@0 | 3790 | + if ( encryptionMode == SslV2 || |
paul@0 | 3791 | + encryptionMode == SslV3 || |
paul@0 | 3792 | + encryptionMode == SslV3_1 || |
paul@0 | 3793 | + encryptionMode == AnySslVersion ) { |
paul@0 | 3794 | KTcpSocket::SslVersion version = KTcpSocket::SslV2; |
paul@0 | 3795 | - if (encryptionMode == SslV3) |
paul@0 | 3796 | + if ( encryptionMode == SslV3 ) { |
paul@0 | 3797 | version = KTcpSocket::SslV3; |
paul@0 | 3798 | - if (encryptionMode == SslV3_1) |
paul@0 | 3799 | + } |
paul@0 | 3800 | + if ( encryptionMode == SslV3_1 ) { |
paul@0 | 3801 | version = KTcpSocket::SslV3_1; |
paul@0 | 3802 | - if (encryptionMode == AnySslVersion) |
paul@0 | 3803 | + } |
paul@0 | 3804 | + if ( encryptionMode == AnySslVersion ) { |
paul@0 | 3805 | version = KTcpSocket::AnySslVersion; |
paul@0 | 3806 | - d->sessionInternal()->startSsl(version); |
paul@0 | 3807 | + } |
paul@0 | 3808 | + d->sessionInternal()->startSsl( version ); |
paul@0 | 3809 | |
paul@0 | 3810 | - } else if (encryptionMode == TlsV1) { |
paul@0 | 3811 | + } else if ( encryptionMode == TlsV1 ) { |
paul@0 | 3812 | d->authState = LoginJobPrivate::StartTls; |
paul@0 | 3813 | d->tags << d->sessionInternal()->sendCommand( "STARTTLS" ); |
paul@0 | 3814 | |
paul@0 | 3815 | - } else if (encryptionMode == Unencrypted ) { |
paul@0 | 3816 | - if (d->authMode.isEmpty()) { |
paul@0 | 3817 | + } else if ( encryptionMode == Unencrypted ) { |
paul@0 | 3818 | + if ( d->authMode.isEmpty() ) { |
paul@0 | 3819 | d->authState = LoginJobPrivate::Login; |
paul@0 | 3820 | + kDebug() << "sending LOGIN"; |
paul@0 | 3821 | d->tags << d->sessionInternal()->sendCommand( "LOGIN", |
paul@0 | 3822 | - '"'+quoteIMAP( d->userName ).toUtf8()+'"' |
paul@0 | 3823 | - +' ' |
paul@0 | 3824 | - +'"'+quoteIMAP(d->password ).toUtf8()+'"' ); |
paul@0 | 3825 | + '"' + quoteIMAP( d->userName ).toUtf8() + '"' + |
paul@0 | 3826 | + ' ' + |
paul@0 | 3827 | + '"' + quoteIMAP( d->password ).toUtf8() + '"' ); |
paul@0 | 3828 | } else { |
paul@0 | 3829 | - if (!d->startAuthentication()) { |
paul@0 | 3830 | + if ( !d->startAuthentication() ) { |
paul@0 | 3831 | emitResult(); |
paul@0 | 3832 | } |
paul@0 | 3833 | } |
paul@0 | 3834 | @@ -264,17 +269,18 @@ void LoginJob::doStart() |
paul@0 | 3835 | |
paul@0 | 3836 | void LoginJob::handleResponse( const Message &response ) |
paul@0 | 3837 | { |
paul@0 | 3838 | - Q_D(LoginJob); |
paul@0 | 3839 | + Q_D( LoginJob ); |
paul@0 | 3840 | |
paul@0 | 3841 | - if ( response.content.isEmpty() ) |
paul@0 | 3842 | + if ( response.content.isEmpty() ) { |
paul@0 | 3843 | return; |
paul@0 | 3844 | + } |
paul@0 | 3845 | |
paul@0 | 3846 | //set the actual command name for standard responses |
paul@0 | 3847 | - QString commandName = i18n("Login"); |
paul@0 | 3848 | - if (d->authState == LoginJobPrivate::Capability) { |
paul@0 | 3849 | - commandName = i18n("Capability"); |
paul@0 | 3850 | - } else if (d->authState == LoginJobPrivate::StartTls) { |
paul@0 | 3851 | - commandName = i18n("StartTls"); |
paul@0 | 3852 | + QString commandName = i18n( "Login" ); |
paul@0 | 3853 | + if ( d->authState == LoginJobPrivate::Capability ) { |
paul@0 | 3854 | + commandName = i18n( "Capability" ); |
paul@0 | 3855 | + } else if ( d->authState == LoginJobPrivate::StartTls ) { |
paul@0 | 3856 | + commandName = i18n( "StartTls" ); |
paul@0 | 3857 | } |
paul@0 | 3858 | |
paul@0 | 3859 | enum ResponseCode { |
paul@0 | 3860 | @@ -286,36 +292,41 @@ void LoginJob::handleResponse( const Message &response ) |
paul@0 | 3861 | }; |
paul@0 | 3862 | |
paul@0 | 3863 | QByteArray tag = response.content.first().toString(); |
paul@0 | 3864 | - ResponseCode code; |
paul@0 | 3865 | + ResponseCode code = OK; |
paul@0 | 3866 | + |
paul@0 | 3867 | + kDebug() << commandName << tag; |
paul@0 | 3868 | |
paul@0 | 3869 | if ( tag == "+" ) { |
paul@0 | 3870 | code = CONTINUATION; |
paul@0 | 3871 | } else if ( tag == "*" ) { |
paul@0 | 3872 | - if ( response.content.size() < 2 ) |
paul@0 | 3873 | + if ( response.content.size() < 2 ) { |
paul@0 | 3874 | code = MALFORMED; // Received empty untagged response |
paul@0 | 3875 | - else |
paul@0 | 3876 | + } else { |
paul@0 | 3877 | code = UNTAGGED; |
paul@0 | 3878 | - } else if ( d->tags.contains(tag) ) { |
paul@0 | 3879 | - if ( response.content.size() < 2 ) |
paul@0 | 3880 | + } |
paul@0 | 3881 | + } else if ( d->tags.contains( tag ) ) { |
paul@0 | 3882 | + if ( response.content.size() < 2 ) { |
paul@0 | 3883 | code = MALFORMED; |
paul@0 | 3884 | - else if ( response.content[1].toString() == "OK" ) |
paul@0 | 3885 | + } else if ( response.content[1].toString() == "OK" ) { |
paul@0 | 3886 | code = OK; |
paul@0 | 3887 | - else |
paul@0 | 3888 | + } else { |
paul@0 | 3889 | code = ERR; |
paul@0 | 3890 | + } |
paul@0 | 3891 | } |
paul@0 | 3892 | |
paul@0 | 3893 | - switch (code) { |
paul@0 | 3894 | + switch ( code ) { |
paul@0 | 3895 | case MALFORMED: |
paul@0 | 3896 | // We'll handle it later |
paul@0 | 3897 | break; |
paul@0 | 3898 | |
paul@0 | 3899 | case ERR: |
paul@0 | 3900 | //server replied with NO or BAD for SASL authentication |
paul@0 | 3901 | - if (d->authState == LoginJobPrivate::Authenticate) |
paul@0 | 3902 | + if ( d->authState == LoginJobPrivate::Authenticate ) { |
paul@0 | 3903 | sasl_dispose( &d->conn ); |
paul@0 | 3904 | + } |
paul@0 | 3905 | |
paul@0 | 3906 | setError( UserDefinedError ); |
paul@0 | 3907 | - setErrorText( i18n("%1 failed, server replied: %2", commandName, response.toString().constData()) ); |
paul@0 | 3908 | + setErrorText( i18n( "%1 failed, server replied: %2", commandName, response.toString().constData() ) ); |
paul@0 | 3909 | emitResult(); |
paul@0 | 3910 | return; |
paul@0 | 3911 | |
paul@0 | 3912 | @@ -323,11 +334,12 @@ void LoginJob::handleResponse( const Message &response ) |
paul@0 | 3913 | // The only untagged response interesting for us here is CAPABILITY |
paul@0 | 3914 | if ( response.content[1].toString() == "CAPABILITY" ) { |
paul@0 | 3915 | QList<Message::Part>::const_iterator p = response.content.begin() + 2; |
paul@0 | 3916 | - while (p != response.content.end()) { |
paul@0 | 3917 | + while ( p != response.content.end() ) { |
paul@0 | 3918 | QString capability = p->toString(); |
paul@0 | 3919 | d->capabilities << capability; |
paul@0 | 3920 | - if (capability == "LOGINDISABLED") |
paul@0 | 3921 | + if ( capability == "LOGINDISABLED" ) { |
paul@0 | 3922 | d->plainLoginDisabled = true; |
paul@0 | 3923 | + } |
paul@0 | 3924 | ++p; |
paul@0 | 3925 | } |
paul@0 | 3926 | kDebug() << "Capabilities updated: " << d->capabilities; |
paul@0 | 3927 | @@ -335,7 +347,7 @@ void LoginJob::handleResponse( const Message &response ) |
paul@0 | 3928 | break; |
paul@0 | 3929 | |
paul@0 | 3930 | case CONTINUATION: |
paul@0 | 3931 | - if (d->authState != LoginJobPrivate::Authenticate) { |
paul@0 | 3932 | + if ( d->authState != LoginJobPrivate::Authenticate ) { |
paul@0 | 3933 | // Received unexpected continuation response for something |
paul@0 | 3934 | // other than AUTHENTICATE command |
paul@0 | 3935 | code = MALFORMED; |
paul@0 | 3936 | @@ -343,7 +355,7 @@ void LoginJob::handleResponse( const Message &response ) |
paul@0 | 3937 | } |
paul@0 | 3938 | |
paul@0 | 3939 | if ( d->authMode == QLatin1String( "PLAIN" ) ) { |
paul@0 | 3940 | - if ( response.content.size()>1 && response.content.at( 1 ).toString()=="OK" ) { |
paul@0 | 3941 | + if ( response.content.size()>1 && response.content.at( 1 ).toString() == "OK" ) { |
paul@0 | 3942 | return; |
paul@0 | 3943 | } |
paul@0 | 3944 | QByteArray challengeResponse; |
paul@0 | 3945 | @@ -357,7 +369,7 @@ void LoginJob::handleResponse( const Message &response ) |
paul@0 | 3946 | challengeResponse = challengeResponse.toBase64(); |
paul@0 | 3947 | d->sessionInternal()->sendData( challengeResponse ); |
paul@0 | 3948 | } else if ( response.content.size() >= 2 ) { |
paul@0 | 3949 | - if (!d->answerChallenge(QByteArray::fromBase64(response.content[1].toString()))) { |
paul@0 | 3950 | + if ( !d->answerChallenge( QByteArray::fromBase64( response.content[1].toString() ) ) ) { |
paul@0 | 3951 | emitResult(); //error, we're done |
paul@0 | 3952 | } |
paul@0 | 3953 | } else { |
paul@0 | 3954 | @@ -368,41 +380,41 @@ void LoginJob::handleResponse( const Message &response ) |
paul@0 | 3955 | |
paul@0 | 3956 | case OK: |
paul@0 | 3957 | |
paul@0 | 3958 | - switch (d->authState) { |
paul@0 | 3959 | + switch ( d->authState ) { |
paul@0 | 3960 | case LoginJobPrivate::StartTls: |
paul@0 | 3961 | - d->sessionInternal()->startSsl(KTcpSocket::TlsV1); |
paul@0 | 3962 | + d->sessionInternal()->startSsl( KTcpSocket::TlsV1 ); |
paul@0 | 3963 | break; |
paul@0 | 3964 | |
paul@0 | 3965 | case LoginJobPrivate::Capability: |
paul@0 | 3966 | //cleartext login, if enabled |
paul@0 | 3967 | - if (d->authMode.isEmpty()) { |
paul@0 | 3968 | - if (d->plainLoginDisabled) { |
paul@0 | 3969 | + if ( d->authMode.isEmpty() ) { |
paul@0 | 3970 | + if ( d->plainLoginDisabled ) { |
paul@0 | 3971 | setError( UserDefinedError ); |
paul@0 | 3972 | - setErrorText( i18n("Login failed, plain login is disabled by the server.") ); |
paul@0 | 3973 | + setErrorText( i18n( "Login failed, plain login is disabled by the server." ) ); |
paul@0 | 3974 | emitResult(); |
paul@0 | 3975 | } else { |
paul@0 | 3976 | d->authState = LoginJobPrivate::Login; |
paul@0 | 3977 | d->tags << d->sessionInternal()->sendCommand( "LOGIN", |
paul@0 | 3978 | - '"'+quoteIMAP( d->userName ).toUtf8()+'"' |
paul@0 | 3979 | - +' ' |
paul@0 | 3980 | - +'"'+quoteIMAP( d->password ).toUtf8()+'"'); |
paul@0 | 3981 | + '"' + quoteIMAP( d->userName ).toUtf8() + '"' + |
paul@0 | 3982 | + ' ' + |
paul@0 | 3983 | + '"' + quoteIMAP( d->password ).toUtf8() + '"' ); |
paul@0 | 3984 | } |
paul@0 | 3985 | } else { |
paul@0 | 3986 | bool authModeSupported = false; |
paul@0 | 3987 | //find the selected SASL authentication method |
paul@0 | 3988 | - Q_FOREACH(const QString &capability, d->capabilities) { |
paul@0 | 3989 | - if (capability.startsWith(QLatin1String("AUTH="))) { |
paul@0 | 3990 | - if (capability.mid(5) == d->authMode) { |
paul@0 | 3991 | + Q_FOREACH ( const QString &capability, d->capabilities ) { |
paul@0 | 3992 | + if ( capability.startsWith( QLatin1String( "AUTH=" ) ) ) { |
paul@0 | 3993 | + if ( capability.mid( 5 ) == d->authMode ) { |
paul@0 | 3994 | authModeSupported = true; |
paul@0 | 3995 | break; |
paul@0 | 3996 | } |
paul@0 | 3997 | } |
paul@0 | 3998 | } |
paul@0 | 3999 | - if (!authModeSupported) { |
paul@0 | 4000 | + if ( !authModeSupported ) { |
paul@0 | 4001 | setError( UserDefinedError ); |
paul@0 | 4002 | - setErrorText( i18n("Login failed, authentication mode %1 is not supported by the server.", d->authMode) ); |
paul@0 | 4003 | + setErrorText( i18n( "Login failed, authentication mode %1 is not supported by the server.", d->authMode ) ); |
paul@0 | 4004 | emitResult(); |
paul@0 | 4005 | - } else if (!d->startAuthentication()) { |
paul@0 | 4006 | + } else if ( !d->startAuthentication() ) { |
paul@0 | 4007 | emitResult(); //problem, we're done |
paul@0 | 4008 | } |
paul@0 | 4009 | } |
paul@0 | 4010 | @@ -421,7 +433,7 @@ void LoginJob::handleResponse( const Message &response ) |
paul@0 | 4011 | } |
paul@0 | 4012 | |
paul@0 | 4013 | if ( code == MALFORMED ) { |
paul@0 | 4014 | - setErrorText( i18n("%1 failed, malformed reply from the server.", commandName) ); |
paul@0 | 4015 | + setErrorText( i18n( "%1 failed, malformed reply from the server.", commandName ) ); |
paul@0 | 4016 | emitResult(); |
paul@0 | 4017 | } |
paul@0 | 4018 | } |
paul@0 | 4019 | @@ -429,9 +441,9 @@ void LoginJob::handleResponse( const Message &response ) |
paul@0 | 4020 | bool LoginJobPrivate::startAuthentication() |
paul@0 | 4021 | { |
paul@0 | 4022 | //SASL authentication |
paul@0 | 4023 | - if (!initSASL()) { |
paul@0 | 4024 | + if ( !initSASL() ) { |
paul@0 | 4025 | q->setError( LoginJob::UserDefinedError ); |
paul@0 | 4026 | - q->setErrorText( i18n("Login failed, client cannot initialize the SASL library.") ); |
paul@0 | 4027 | + q->setErrorText( i18n( "Login failed, client cannot initialize the SASL library." ) ); |
paul@0 | 4028 | return false; |
paul@0 | 4029 | } |
paul@0 | 4030 | |
paul@0 | 4031 | @@ -442,14 +454,14 @@ bool LoginJobPrivate::startAuthentication() |
paul@0 | 4032 | |
paul@0 | 4033 | int result = sasl_client_new( "imap", m_session->hostName().toLatin1(), 0, 0, callbacks, 0, &conn ); |
paul@0 | 4034 | if ( result != SASL_OK ) { |
paul@0 | 4035 | - kDebug() <<"sasl_client_new failed with:" << result; |
paul@0 | 4036 | + kDebug() << "sasl_client_new failed with:" << result; |
paul@0 | 4037 | q->setError( LoginJob::UserDefinedError ); |
paul@0 | 4038 | q->setErrorText( QString::fromUtf8( sasl_errdetail( conn ) ) ); |
paul@0 | 4039 | return false; |
paul@0 | 4040 | } |
paul@0 | 4041 | |
paul@0 | 4042 | do { |
paul@0 | 4043 | - result = sasl_client_start(conn, authMode.toLatin1(), &client_interact, capabilities.contains("SASL-IR") ? &out : 0, &outlen, &mechusing); |
paul@0 | 4044 | + result = sasl_client_start( conn, authMode.toLatin1(), &client_interact, capabilities.contains( "SASL-IR" ) ? &out : 0, &outlen, &mechusing ); |
paul@0 | 4045 | |
paul@0 | 4046 | if ( result == SASL_INTERACT ) { |
paul@0 | 4047 | if ( !sasl_interact() ) { |
paul@0 | 4048 | @@ -461,7 +473,7 @@ bool LoginJobPrivate::startAuthentication() |
paul@0 | 4049 | } while ( result == SASL_INTERACT ); |
paul@0 | 4050 | |
paul@0 | 4051 | if ( result != SASL_CONTINUE && result != SASL_OK ) { |
paul@0 | 4052 | - kDebug() <<"sasl_client_start failed with:" << result; |
paul@0 | 4053 | + kDebug() << "sasl_client_start failed with:" << result; |
paul@0 | 4054 | q->setError( LoginJob::UserDefinedError ); |
paul@0 | 4055 | q->setErrorText( QString::fromUtf8( sasl_errdetail( conn ) ) ); |
paul@0 | 4056 | sasl_dispose( &conn ); |
paul@0 | 4057 | @@ -487,12 +499,12 @@ bool LoginJobPrivate::answerChallenge(const QByteArray &data) |
paul@0 | 4058 | const char *out = 0; |
paul@0 | 4059 | uint outlen = 0; |
paul@0 | 4060 | do { |
paul@0 | 4061 | - result = sasl_client_step(conn, challenge.isEmpty() ? 0 : challenge.data(), |
paul@0 | 4062 | - challenge.size(), |
paul@0 | 4063 | - &client_interact, |
paul@0 | 4064 | - &out, &outlen); |
paul@0 | 4065 | + result = sasl_client_step( conn, challenge.isEmpty() ? 0 : challenge.data(), |
paul@0 | 4066 | + challenge.size(), |
paul@0 | 4067 | + &client_interact, |
paul@0 | 4068 | + &out, &outlen ); |
paul@0 | 4069 | |
paul@0 | 4070 | - if (result == SASL_INTERACT) { |
paul@0 | 4071 | + if ( result == SASL_INTERACT ) { |
paul@0 | 4072 | if ( !sasl_interact() ) { |
paul@0 | 4073 | q->setError( LoginJob::UserDefinedError ); //TODO: check up the actual error |
paul@0 | 4074 | sasl_dispose( &conn ); |
paul@0 | 4075 | @@ -502,7 +514,7 @@ bool LoginJobPrivate::answerChallenge(const QByteArray &data) |
paul@0 | 4076 | } while ( result == SASL_INTERACT ); |
paul@0 | 4077 | |
paul@0 | 4078 | if ( result != SASL_CONTINUE && result != SASL_OK ) { |
paul@0 | 4079 | - kDebug() <<"sasl_client_step failed with:" << result; |
paul@0 | 4080 | + kDebug() << "sasl_client_step failed with:" << result; |
paul@0 | 4081 | q->setError( LoginJob::UserDefinedError ); //TODO: check up the actual error |
paul@0 | 4082 | q->setErrorText( QString::fromUtf8( sasl_errdetail( conn ) ) ); |
paul@0 | 4083 | sasl_dispose( &conn ); |
paul@0 | 4084 | @@ -519,12 +531,12 @@ bool LoginJobPrivate::answerChallenge(const QByteArray &data) |
paul@0 | 4085 | |
paul@0 | 4086 | void LoginJobPrivate::sslResponse(bool response) |
paul@0 | 4087 | { |
paul@0 | 4088 | - if (response) { |
paul@0 | 4089 | + if ( response ) { |
paul@0 | 4090 | authState = LoginJobPrivate::Capability; |
paul@0 | 4091 | tags << sessionInternal()->sendCommand( "CAPABILITY" ); |
paul@0 | 4092 | } else { |
paul@0 | 4093 | q->setError( LoginJob::UserDefinedError ); |
paul@0 | 4094 | - q->setErrorText( i18n("Login failed, TLS negotiation failed." )); |
paul@0 | 4095 | + q->setErrorText( i18n( "Login failed, TLS negotiation failed." ) ); |
paul@0 | 4096 | encryptionMode = LoginJob::Unencrypted; |
paul@0 | 4097 | q->emitResult(); |
paul@0 | 4098 | } |
paul@0 | 4099 | @@ -532,21 +544,20 @@ void LoginJobPrivate::sslResponse(bool response) |
paul@0 | 4100 | |
paul@0 | 4101 | void LoginJob::setEncryptionMode(EncryptionMode mode) |
paul@0 | 4102 | { |
paul@0 | 4103 | - Q_D(LoginJob); |
paul@0 | 4104 | + Q_D( LoginJob ); |
paul@0 | 4105 | d->encryptionMode = mode; |
paul@0 | 4106 | } |
paul@0 | 4107 | |
paul@0 | 4108 | LoginJob::EncryptionMode LoginJob::encryptionMode() |
paul@0 | 4109 | { |
paul@0 | 4110 | - Q_D(LoginJob); |
paul@0 | 4111 | + Q_D( LoginJob ); |
paul@0 | 4112 | return d->encryptionMode; |
paul@0 | 4113 | } |
paul@0 | 4114 | |
paul@0 | 4115 | void LoginJob::setAuthenticationMode(AuthenticationMode mode) |
paul@0 | 4116 | { |
paul@0 | 4117 | - Q_D(LoginJob); |
paul@0 | 4118 | - switch (mode) |
paul@0 | 4119 | - { |
paul@0 | 4120 | + Q_D( LoginJob ); |
paul@0 | 4121 | + switch ( mode ) { |
paul@0 | 4122 | case ClearText: d->authMode = ""; |
paul@0 | 4123 | break; |
paul@0 | 4124 | case Login: d->authMode = "LOGIN"; |
paul@0 | 4125 | @@ -568,13 +579,13 @@ void LoginJob::setAuthenticationMode(AuthenticationMode mode) |
paul@0 | 4126 | |
paul@0 | 4127 | void LoginJob::connectionLost() |
paul@0 | 4128 | { |
paul@0 | 4129 | - Q_D(LoginJob); |
paul@0 | 4130 | + Q_D( LoginJob ); |
paul@0 | 4131 | |
paul@0 | 4132 | //don't emit the result if the connection was lost before getting the tls result, as it can mean |
paul@0 | 4133 | //the TLS handshake failed and the socket was reconnected in normal mode |
paul@0 | 4134 | - if (d->authState != LoginJobPrivate::StartTls) { |
paul@0 | 4135 | + if ( d->authState != LoginJobPrivate::StartTls ) { |
paul@0 | 4136 | setError( ERR_COULD_NOT_CONNECT ); |
paul@0 | 4137 | - setErrorText( i18n("Connection to server lost.") ); |
paul@0 | 4138 | + setErrorText( i18n( "Connection to server lost." ) ); |
paul@0 | 4139 | emitResult(); |
paul@0 | 4140 | } |
paul@0 | 4141 | |
paul@0 | 4142 | @@ -585,25 +596,26 @@ void LoginJobPrivate::saveServerGreeting(const Message &response) |
paul@0 | 4143 | // Concatenate the parts of the server response into a string, while dropping the first two parts |
paul@0 | 4144 | // (the response tag and the "OK" code), and being careful not to add useless extra whitespace. |
paul@0 | 4145 | |
paul@0 | 4146 | - for ( int i=2; i<response.content.size(); i++) { |
paul@0 | 4147 | - if ( response.content.at(i).type()==Message::Part::List ) { |
paul@0 | 4148 | - serverGreeting+='('; |
paul@0 | 4149 | - foreach ( const QByteArray &item, response.content.at(i).toList() ) { |
paul@0 | 4150 | - serverGreeting+=item+' '; |
paul@0 | 4151 | + for ( int i = 2; i < response.content.size(); i++ ) { |
paul@0 | 4152 | + if ( response.content.at( i ).type() == Message::Part::List ) { |
paul@0 | 4153 | + serverGreeting += '('; |
paul@0 | 4154 | + foreach ( const QByteArray &item, response.content.at( i ).toList() ) { |
paul@0 | 4155 | + serverGreeting += item + ' '; |
paul@0 | 4156 | } |
paul@0 | 4157 | - serverGreeting.chop(1); |
paul@0 | 4158 | - serverGreeting+=") "; |
paul@0 | 4159 | + serverGreeting.chop( 1 ); |
paul@0 | 4160 | + serverGreeting += ") "; |
paul@0 | 4161 | } else { |
paul@0 | 4162 | - serverGreeting+=response.content.at(i).toString()+' '; |
paul@0 | 4163 | + serverGreeting+=response.content.at( i ).toString() + ' '; |
paul@0 | 4164 | } |
paul@0 | 4165 | } |
paul@0 | 4166 | - serverGreeting.chop(1); |
paul@0 | 4167 | + serverGreeting.chop( 1 ); |
paul@0 | 4168 | } |
paul@0 | 4169 | |
paul@0 | 4170 | QString LoginJob::serverGreeting() const |
paul@0 | 4171 | { |
paul@0 | 4172 | - Q_D(const LoginJob); |
paul@0 | 4173 | + Q_D( const LoginJob ); |
paul@0 | 4174 | return d->serverGreeting; |
paul@0 | 4175 | } |
paul@0 | 4176 | |
paul@0 | 4177 | #include "loginjob.moc" |
paul@0 | 4178 | + |
paul@0 | 4179 | diff --git a/kimap/loginjob.h b/kimap/loginjob.h |
paul@0 | 4180 | index 6064214..2c6040a 100644 |
paul@0 | 4181 | --- a/kimap/loginjob.h |
paul@0 | 4182 | +++ b/kimap/loginjob.h |
paul@0 | 4183 | @@ -34,7 +34,7 @@ class LoginJobPrivate; |
paul@0 | 4184 | class KIMAP_EXPORT LoginJob : public Job |
paul@0 | 4185 | { |
paul@0 | 4186 | Q_OBJECT |
paul@0 | 4187 | - Q_DECLARE_PRIVATE(LoginJob) |
paul@0 | 4188 | + Q_DECLARE_PRIVATE( LoginJob ) |
paul@0 | 4189 | |
paul@0 | 4190 | friend class SessionPrivate; |
paul@0 | 4191 | |
paul@0 | 4192 | diff --git a/kimap/logoutjob.cpp b/kimap/logoutjob.cpp |
paul@0 | 4193 | index 9f191dd..5c9bc19 100644 |
paul@0 | 4194 | --- a/kimap/logoutjob.cpp |
paul@0 | 4195 | +++ b/kimap/logoutjob.cpp |
paul@0 | 4196 | @@ -19,7 +19,7 @@ |
paul@0 | 4197 | |
paul@0 | 4198 | #include "logoutjob.h" |
paul@0 | 4199 | |
paul@0 | 4200 | -#include <klocale.h> |
paul@0 | 4201 | +#include <KDE/KLocalizedString> |
paul@0 | 4202 | |
paul@0 | 4203 | #include "job_p.h" |
paul@0 | 4204 | #include "message_p.h" |
paul@0 | 4205 | @@ -30,7 +30,7 @@ namespace KIMAP |
paul@0 | 4206 | class LogoutJobPrivate : public JobPrivate |
paul@0 | 4207 | { |
paul@0 | 4208 | public: |
paul@0 | 4209 | - LogoutJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { } |
paul@0 | 4210 | + LogoutJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { } |
paul@0 | 4211 | ~LogoutJobPrivate() { } |
paul@0 | 4212 | }; |
paul@0 | 4213 | } |
paul@0 | 4214 | @@ -38,7 +38,7 @@ namespace KIMAP |
paul@0 | 4215 | using namespace KIMAP; |
paul@0 | 4216 | |
paul@0 | 4217 | LogoutJob::LogoutJob( Session *session ) |
paul@0 | 4218 | - : Job( *new LogoutJobPrivate(session, i18n("Logout")) ) |
paul@0 | 4219 | + : Job( *new LogoutJobPrivate( session, i18n( "Logout" ) ) ) |
paul@0 | 4220 | { |
paul@0 | 4221 | } |
paul@0 | 4222 | |
paul@0 | 4223 | @@ -48,7 +48,7 @@ LogoutJob::~LogoutJob() |
paul@0 | 4224 | |
paul@0 | 4225 | void LogoutJob::doStart() |
paul@0 | 4226 | { |
paul@0 | 4227 | - Q_D(LogoutJob); |
paul@0 | 4228 | + Q_D( LogoutJob ); |
paul@0 | 4229 | d->tags << d->sessionInternal()->sendCommand( "LOGOUT" ); |
paul@0 | 4230 | } |
paul@0 | 4231 | |
paul@0 | 4232 | @@ -58,3 +58,4 @@ void LogoutJob::connectionLost() |
paul@0 | 4233 | } |
paul@0 | 4234 | |
paul@0 | 4235 | #include "logoutjob.moc" |
paul@0 | 4236 | + |
paul@0 | 4237 | diff --git a/kimap/logoutjob.h b/kimap/logoutjob.h |
paul@0 | 4238 | index e3f6553..288400f 100644 |
paul@0 | 4239 | --- a/kimap/logoutjob.h |
paul@0 | 4240 | +++ b/kimap/logoutjob.h |
paul@0 | 4241 | @@ -32,7 +32,7 @@ class LogoutJobPrivate; |
paul@0 | 4242 | class KIMAP_EXPORT LogoutJob : public Job |
paul@0 | 4243 | { |
paul@0 | 4244 | Q_OBJECT |
paul@0 | 4245 | - Q_DECLARE_PRIVATE(LogoutJob) |
paul@0 | 4246 | + Q_DECLARE_PRIVATE( LogoutJob ) |
paul@0 | 4247 | |
paul@0 | 4248 | friend class SessionPrivate; |
paul@0 | 4249 | |
paul@0 | 4250 | diff --git a/kimap/message_p.h b/kimap/message_p.h |
paul@0 | 4251 | index 9d703bf..e6dd502 100644 |
paul@0 | 4252 | --- a/kimap/message_p.h |
paul@0 | 4253 | +++ b/kimap/message_p.h |
paul@0 | 4254 | @@ -34,9 +34,9 @@ struct Message |
paul@0 | 4255 | enum Type { String = 0, List }; |
paul@0 | 4256 | |
paul@0 | 4257 | explicit Part(const QByteArray &string) |
paul@0 | 4258 | - : m_type(String), m_string(string) { } |
paul@0 | 4259 | + : m_type( String ), m_string( string ) { } |
paul@0 | 4260 | explicit Part(const QList<QByteArray> &list) |
paul@0 | 4261 | - : m_type(List), m_list(list) { } |
paul@0 | 4262 | + : m_type( List ), m_list( list ) { } |
paul@0 | 4263 | |
paul@0 | 4264 | inline Type type() const { return m_type; } |
paul@0 | 4265 | inline QByteArray toString() const { return m_string; } |
paul@0 | 4266 | @@ -53,22 +53,22 @@ struct Message |
paul@0 | 4267 | QByteArray result; |
paul@0 | 4268 | |
paul@0 | 4269 | foreach ( const Part &part, content ) { |
paul@0 | 4270 | - if ( part.type()==Part::List ) { |
paul@0 | 4271 | - result+='('; |
paul@0 | 4272 | + if ( part.type() == Part::List ) { |
paul@0 | 4273 | + result += '('; |
paul@0 | 4274 | foreach ( const QByteArray &item, part.toList() ) { |
paul@0 | 4275 | - result+= ' '; |
paul@0 | 4276 | - result+= item; |
paul@0 | 4277 | + result += ' '; |
paul@0 | 4278 | + result += item; |
paul@0 | 4279 | } |
paul@0 | 4280 | - result+=" ) "; |
paul@0 | 4281 | + result += " ) "; |
paul@0 | 4282 | } else { |
paul@0 | 4283 | - result+= part.toString()+' '; |
paul@0 | 4284 | + result += part.toString() + ' '; |
paul@0 | 4285 | } |
paul@0 | 4286 | } |
paul@0 | 4287 | |
paul@0 | 4288 | if ( !responseCode.isEmpty() ) { |
paul@0 | 4289 | result+="[ "; |
paul@0 | 4290 | foreach ( const Part &part, responseCode ) { |
paul@0 | 4291 | - if ( part.type()==Part::List ) { |
paul@0 | 4292 | + if ( part.type() == Part::List ) { |
paul@0 | 4293 | result+='('; |
paul@0 | 4294 | foreach ( const QByteArray &item, part.toList() ) { |
paul@0 | 4295 | result+= ' '; |
paul@0 | 4296 | @@ -76,7 +76,7 @@ struct Message |
paul@0 | 4297 | } |
paul@0 | 4298 | result+=" ) "; |
paul@0 | 4299 | } else { |
paul@0 | 4300 | - result+= part.toString()+' '; |
paul@0 | 4301 | + result+= part.toString() + ' '; |
paul@0 | 4302 | } |
paul@0 | 4303 | } |
paul@0 | 4304 | result+=" ]"; |
paul@0 | 4305 | @@ -91,7 +91,7 @@ struct Message |
paul@0 | 4306 | |
paul@0 | 4307 | } |
paul@0 | 4308 | |
paul@0 | 4309 | -Q_DECLARE_METATYPE(KIMAP::Message) |
paul@0 | 4310 | +Q_DECLARE_METATYPE( KIMAP::Message ) |
paul@0 | 4311 | static const int _kimap_messageTypeId = qRegisterMetaType<KIMAP::Message>(); |
paul@0 | 4312 | |
paul@0 | 4313 | #endif |
paul@0 | 4314 | diff --git a/kimap/metadatajobbase.cpp b/kimap/metadatajobbase.cpp |
paul@0 | 4315 | index fa9dc53..bc7a8d5 100644 |
paul@0 | 4316 | --- a/kimap/metadatajobbase.cpp |
paul@0 | 4317 | +++ b/kimap/metadatajobbase.cpp |
paul@0 | 4318 | @@ -22,50 +22,48 @@ |
paul@0 | 4319 | #include "message_p.h" |
paul@0 | 4320 | #include "session_p.h" |
paul@0 | 4321 | |
paul@0 | 4322 | -#include <klocale.h> |
paul@0 | 4323 | -#include <kdebug.h> |
paul@0 | 4324 | +#include <KDE/KLocalizedString> |
paul@0 | 4325 | +#include <KDE/KDebug> |
paul@0 | 4326 | |
paul@0 | 4327 | using namespace KIMAP; |
paul@0 | 4328 | |
paul@0 | 4329 | MetaDataJobBase::MetaDataJobBase( Session *session ) |
paul@0 | 4330 | - : Job( *new MetaDataJobBasePrivate(session, i18n("MetaDataJobBase")) ) |
paul@0 | 4331 | + : Job( *new MetaDataJobBasePrivate( session, i18n( "MetaDataJobBase" ) ) ) |
paul@0 | 4332 | { |
paul@0 | 4333 | } |
paul@0 | 4334 | |
paul@0 | 4335 | - |
paul@0 | 4336 | MetaDataJobBase::MetaDataJobBase( JobPrivate &dd ) |
paul@0 | 4337 | - : Job(dd) |
paul@0 | 4338 | + : Job( dd ) |
paul@0 | 4339 | { |
paul@0 | 4340 | - |
paul@0 | 4341 | } |
paul@0 | 4342 | |
paul@0 | 4343 | MetaDataJobBase::~MetaDataJobBase() |
paul@0 | 4344 | { |
paul@0 | 4345 | } |
paul@0 | 4346 | |
paul@0 | 4347 | - |
paul@0 | 4348 | void MetaDataJobBase::setMailBox( const QString &mailBox ) |
paul@0 | 4349 | { |
paul@0 | 4350 | - Q_D(MetaDataJobBase); |
paul@0 | 4351 | + Q_D( MetaDataJobBase ); |
paul@0 | 4352 | d->mailBox = mailBox; |
paul@0 | 4353 | } |
paul@0 | 4354 | |
paul@0 | 4355 | QString MetaDataJobBase::mailBox() const |
paul@0 | 4356 | { |
paul@0 | 4357 | - Q_D(const MetaDataJobBase); |
paul@0 | 4358 | + Q_D( const MetaDataJobBase ); |
paul@0 | 4359 | return d->mailBox; |
paul@0 | 4360 | } |
paul@0 | 4361 | |
paul@0 | 4362 | void MetaDataJobBase::setServerCapability(const ServerCapability& capability) |
paul@0 | 4363 | { |
paul@0 | 4364 | - Q_D(MetaDataJobBase); |
paul@0 | 4365 | + Q_D( MetaDataJobBase ); |
paul@0 | 4366 | d->serverCapability = capability; |
paul@0 | 4367 | } |
paul@0 | 4368 | |
paul@0 | 4369 | MetaDataJobBase::ServerCapability MetaDataJobBase::serverCapability() const |
paul@0 | 4370 | { |
paul@0 | 4371 | - Q_D(const MetaDataJobBase); |
paul@0 | 4372 | + Q_D( const MetaDataJobBase ); |
paul@0 | 4373 | return d->serverCapability; |
paul@0 | 4374 | } |
paul@0 | 4375 | |
paul@0 | 4376 | #include "metadatajobbase.moc" |
paul@0 | 4377 | + |
paul@0 | 4378 | diff --git a/kimap/metadatajobbase.h b/kimap/metadatajobbase.h |
paul@0 | 4379 | index f7ad6e2..de46736 100644 |
paul@0 | 4380 | --- a/kimap/metadatajobbase.h |
paul@0 | 4381 | +++ b/kimap/metadatajobbase.h |
paul@0 | 4382 | @@ -47,7 +47,7 @@ class MetaDataJobBasePrivate; |
paul@0 | 4383 | class KIMAP_EXPORT MetaDataJobBase : public Job |
paul@0 | 4384 | { |
paul@0 | 4385 | Q_OBJECT |
paul@0 | 4386 | - Q_DECLARE_PRIVATE(MetaDataJobBase) |
paul@0 | 4387 | + Q_DECLARE_PRIVATE( MetaDataJobBase ) |
paul@0 | 4388 | |
paul@0 | 4389 | friend class SessionPrivate; |
paul@0 | 4390 | |
paul@0 | 4391 | diff --git a/kimap/metadatajobbase_p.h b/kimap/metadatajobbase_p.h |
paul@0 | 4392 | index 983a344..140ef20 100644 |
paul@0 | 4393 | --- a/kimap/metadatajobbase_p.h |
paul@0 | 4394 | +++ b/kimap/metadatajobbase_p.h |
paul@0 | 4395 | @@ -30,7 +30,7 @@ namespace KIMAP |
paul@0 | 4396 | class MetaDataJobBasePrivate : public JobPrivate |
paul@0 | 4397 | { |
paul@0 | 4398 | public: |
paul@0 | 4399 | - MetaDataJobBasePrivate( Session *session, const QString& name ) : JobPrivate(session, name), serverCapability(MetaDataJobBase::Metadata) |
paul@0 | 4400 | + MetaDataJobBasePrivate( Session *session, const QString& name ) : JobPrivate( session, name ), serverCapability( MetaDataJobBase::Metadata ) |
paul@0 | 4401 | {} |
paul@0 | 4402 | |
paul@0 | 4403 | ~MetaDataJobBasePrivate() { } |
paul@0 | 4404 | diff --git a/kimap/myrightsjob.cpp b/kimap/myrightsjob.cpp |
paul@0 | 4405 | index 46354ae..49790b3 100644 |
paul@0 | 4406 | --- a/kimap/myrightsjob.cpp |
paul@0 | 4407 | +++ b/kimap/myrightsjob.cpp |
paul@0 | 4408 | @@ -19,8 +19,8 @@ |
paul@0 | 4409 | |
paul@0 | 4410 | #include "myrightsjob.h" |
paul@0 | 4411 | |
paul@0 | 4412 | -#include <klocale.h> |
paul@0 | 4413 | -#include <kdebug.h> |
paul@0 | 4414 | +#include <KDE/KLocalizedString> |
paul@0 | 4415 | +#include <KDE/KDebug> |
paul@0 | 4416 | |
paul@0 | 4417 | #include "acljobbase_p.h" |
paul@0 | 4418 | #include "message_p.h" |
paul@0 | 4419 | @@ -32,7 +32,7 @@ namespace KIMAP |
paul@0 | 4420 | class MyRightsJobPrivate : public AclJobBasePrivate |
paul@0 | 4421 | { |
paul@0 | 4422 | public: |
paul@0 | 4423 | - MyRightsJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate(session, name), myRights(Acl::None) {} |
paul@0 | 4424 | + MyRightsJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate( session, name ), myRights( Acl::None ) {} |
paul@0 | 4425 | ~MyRightsJobPrivate() { } |
paul@0 | 4426 | |
paul@0 | 4427 | Acl::Rights myRights; |
paul@0 | 4428 | @@ -42,7 +42,7 @@ namespace KIMAP |
paul@0 | 4429 | using namespace KIMAP; |
paul@0 | 4430 | |
paul@0 | 4431 | MyRightsJob::MyRightsJob( Session *session ) |
paul@0 | 4432 | - : AclJobBase( *new MyRightsJobPrivate(session, i18n("MyRights") )) |
paul@0 | 4433 | + : AclJobBase( *new MyRightsJobPrivate( session, i18n( "MyRights" ) ) ) |
paul@0 | 4434 | { |
paul@0 | 4435 | } |
paul@0 | 4436 | |
paul@0 | 4437 | @@ -52,18 +52,18 @@ MyRightsJob::~MyRightsJob() |
paul@0 | 4438 | |
paul@0 | 4439 | void MyRightsJob::doStart() |
paul@0 | 4440 | { |
paul@0 | 4441 | - Q_D(MyRightsJob); |
paul@0 | 4442 | + Q_D( MyRightsJob ); |
paul@0 | 4443 | |
paul@0 | 4444 | - d->tags << d->sessionInternal()->sendCommand( "MYRIGHTS", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"'); |
paul@0 | 4445 | + d->tags << d->sessionInternal()->sendCommand( "MYRIGHTS", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"' ); |
paul@0 | 4446 | } |
paul@0 | 4447 | |
paul@0 | 4448 | void MyRightsJob::handleResponse( const Message &response ) |
paul@0 | 4449 | { |
paul@0 | 4450 | - Q_D(MyRightsJob); |
paul@0 | 4451 | + Q_D( MyRightsJob ); |
paul@0 | 4452 | |
paul@0 | 4453 | - if (handleErrorReplies(response) == NotHandled) { |
paul@0 | 4454 | - if ( response.content.size() == 4 |
paul@0 | 4455 | - && response.content[1].toString() == "MYRIGHTS" ) { |
paul@0 | 4456 | + if ( handleErrorReplies( response ) == NotHandled ) { |
paul@0 | 4457 | + if ( response.content.size() == 4 && |
paul@0 | 4458 | + response.content[1].toString() == "MYRIGHTS" ) { |
paul@0 | 4459 | d->myRights = Acl::rightsFromString( response.content[3].toString() ); |
paul@0 | 4460 | } |
paul@0 | 4461 | } |
paul@0 | 4462 | @@ -71,14 +71,15 @@ void MyRightsJob::handleResponse( const Message &response ) |
paul@0 | 4463 | |
paul@0 | 4464 | bool MyRightsJob::hasRightEnabled(Acl::Right right) |
paul@0 | 4465 | { |
paul@0 | 4466 | - Q_D(MyRightsJob); |
paul@0 | 4467 | + Q_D( MyRightsJob ); |
paul@0 | 4468 | return d->myRights & right; |
paul@0 | 4469 | } |
paul@0 | 4470 | |
paul@0 | 4471 | Acl::Rights MyRightsJob::rights() |
paul@0 | 4472 | { |
paul@0 | 4473 | - Q_D(MyRightsJob); |
paul@0 | 4474 | + Q_D( MyRightsJob ); |
paul@0 | 4475 | return d->myRights; |
paul@0 | 4476 | } |
paul@0 | 4477 | |
paul@0 | 4478 | #include "myrightsjob.moc" |
paul@0 | 4479 | + |
paul@0 | 4480 | diff --git a/kimap/myrightsjob.h b/kimap/myrightsjob.h |
paul@0 | 4481 | index 4e57d0e..24973d5 100644 |
paul@0 | 4482 | --- a/kimap/myrightsjob.h |
paul@0 | 4483 | +++ b/kimap/myrightsjob.h |
paul@0 | 4484 | @@ -56,7 +56,7 @@ class MyRightsJobPrivate; |
paul@0 | 4485 | class KIMAP_EXPORT MyRightsJob : public AclJobBase |
paul@0 | 4486 | { |
paul@0 | 4487 | Q_OBJECT |
paul@0 | 4488 | - Q_DECLARE_PRIVATE(MyRightsJob) |
paul@0 | 4489 | + Q_DECLARE_PRIVATE( MyRightsJob ) |
paul@0 | 4490 | |
paul@0 | 4491 | friend class SessionPrivate; |
paul@0 | 4492 | |
paul@0 | 4493 | diff --git a/kimap/namespacejob.cpp b/kimap/namespacejob.cpp |
paul@0 | 4494 | index 639e55d..47b3930 100644 |
paul@0 | 4495 | --- a/kimap/namespacejob.cpp |
paul@0 | 4496 | +++ b/kimap/namespacejob.cpp |
paul@0 | 4497 | @@ -19,8 +19,8 @@ |
paul@0 | 4498 | |
paul@0 | 4499 | #include "namespacejob.h" |
paul@0 | 4500 | |
paul@0 | 4501 | -#include <kdebug.h> |
paul@0 | 4502 | -#include <klocale.h> |
paul@0 | 4503 | +#include <KDE/KDebug> |
paul@0 | 4504 | +#include <KDE/KLocalizedString> |
paul@0 | 4505 | |
paul@0 | 4506 | #include "job_p.h" |
paul@0 | 4507 | #include "listjob.h" |
paul@0 | 4508 | @@ -34,7 +34,7 @@ namespace KIMAP |
paul@0 | 4509 | class NamespaceJobPrivate : public JobPrivate |
paul@0 | 4510 | { |
paul@0 | 4511 | public: |
paul@0 | 4512 | - NamespaceJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { } |
paul@0 | 4513 | + NamespaceJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { } |
paul@0 | 4514 | ~NamespaceJobPrivate() { } |
paul@0 | 4515 | |
paul@0 | 4516 | QList<MailBoxDescriptor> processNamespaceList( const QList<QByteArray> &namespaceList ) |
paul@0 | 4517 | @@ -55,7 +55,7 @@ namespace KIMAP |
paul@0 | 4518 | descriptor.separator = QChar( parts[1][0] ); |
paul@0 | 4519 | |
paul@0 | 4520 | result << descriptor; |
paul@0 | 4521 | - } catch (KIMAP::ImapParserException e) { |
paul@0 | 4522 | + } catch ( KIMAP::ImapParserException e ) { |
paul@0 | 4523 | qWarning() << "The stream parser raised an exception during namespace list parsing:" << e.what(); |
paul@0 | 4524 | qWarning() << "namespacelist:" << namespaceList; |
paul@0 | 4525 | } |
paul@0 | 4526 | @@ -74,7 +74,7 @@ namespace KIMAP |
paul@0 | 4527 | using namespace KIMAP; |
paul@0 | 4528 | |
paul@0 | 4529 | NamespaceJob::NamespaceJob( Session *session ) |
paul@0 | 4530 | - : Job( *new NamespaceJobPrivate(session, i18n("Namespace")) ) |
paul@0 | 4531 | + : Job( *new NamespaceJobPrivate( session, i18n( "Namespace" ) ) ) |
paul@0 | 4532 | { |
paul@0 | 4533 | } |
paul@0 | 4534 | |
paul@0 | 4535 | @@ -84,25 +84,25 @@ NamespaceJob::~NamespaceJob() |
paul@0 | 4536 | |
paul@0 | 4537 | QList<MailBoxDescriptor> NamespaceJob::personalNamespaces() const |
paul@0 | 4538 | { |
paul@0 | 4539 | - Q_D(const NamespaceJob); |
paul@0 | 4540 | + Q_D( const NamespaceJob ); |
paul@0 | 4541 | return d->personalNamespaces; |
paul@0 | 4542 | } |
paul@0 | 4543 | |
paul@0 | 4544 | QList<MailBoxDescriptor> NamespaceJob::userNamespaces() const |
paul@0 | 4545 | { |
paul@0 | 4546 | - Q_D(const NamespaceJob); |
paul@0 | 4547 | + Q_D( const NamespaceJob ); |
paul@0 | 4548 | return d->userNamespaces; |
paul@0 | 4549 | } |
paul@0 | 4550 | |
paul@0 | 4551 | QList<MailBoxDescriptor> NamespaceJob::sharedNamespaces() const |
paul@0 | 4552 | { |
paul@0 | 4553 | - Q_D(const NamespaceJob); |
paul@0 | 4554 | + Q_D( const NamespaceJob ); |
paul@0 | 4555 | return d->sharedNamespaces; |
paul@0 | 4556 | } |
paul@0 | 4557 | |
paul@0 | 4558 | bool NamespaceJob::containsEmptyNamespace() const |
paul@0 | 4559 | { |
paul@0 | 4560 | - Q_D(const NamespaceJob); |
paul@0 | 4561 | + Q_D( const NamespaceJob ); |
paul@0 | 4562 | QList<MailBoxDescriptor> completeList = d->personalNamespaces |
paul@0 | 4563 | + d->userNamespaces |
paul@0 | 4564 | + d->sharedNamespaces; |
paul@0 | 4565 | @@ -118,16 +118,16 @@ bool NamespaceJob::containsEmptyNamespace() const |
paul@0 | 4566 | |
paul@0 | 4567 | void NamespaceJob::doStart() |
paul@0 | 4568 | { |
paul@0 | 4569 | - Q_D(NamespaceJob); |
paul@0 | 4570 | + Q_D( NamespaceJob ); |
paul@0 | 4571 | d->tags << d->sessionInternal()->sendCommand( "NAMESPACE" ); |
paul@0 | 4572 | } |
paul@0 | 4573 | |
paul@0 | 4574 | void NamespaceJob::handleResponse( const Message &response ) |
paul@0 | 4575 | { |
paul@0 | 4576 | - Q_D(NamespaceJob); |
paul@0 | 4577 | - if (handleErrorReplies(response) == NotHandled) { |
paul@0 | 4578 | - if ( response.content.size() >= 5 |
paul@0 | 4579 | - && response.content[1].toString()=="NAMESPACE" ) { |
paul@0 | 4580 | + Q_D( NamespaceJob ); |
paul@0 | 4581 | + if ( handleErrorReplies( response ) == NotHandled ) { |
paul@0 | 4582 | + if ( response.content.size() >= 5 && |
paul@0 | 4583 | + response.content[1].toString() == "NAMESPACE" ) { |
paul@0 | 4584 | // Personal namespaces |
paul@0 | 4585 | d->personalNamespaces = d->processNamespaceList( response.content[2].toList() ); |
paul@0 | 4586 | |
paul@0 | 4587 | @@ -141,3 +141,4 @@ void NamespaceJob::handleResponse( const Message &response ) |
paul@0 | 4588 | } |
paul@0 | 4589 | |
paul@0 | 4590 | #include "namespacejob.moc" |
paul@0 | 4591 | + |
paul@0 | 4592 | diff --git a/kimap/namespacejob.h b/kimap/namespacejob.h |
paul@0 | 4593 | index 130c788..429d1d8 100644 |
paul@0 | 4594 | --- a/kimap/namespacejob.h |
paul@0 | 4595 | +++ b/kimap/namespacejob.h |
paul@0 | 4596 | @@ -34,7 +34,7 @@ class NamespaceJobPrivate; |
paul@0 | 4597 | class KIMAP_EXPORT NamespaceJob : public Job |
paul@0 | 4598 | { |
paul@0 | 4599 | Q_OBJECT |
paul@0 | 4600 | - Q_DECLARE_PRIVATE(NamespaceJob) |
paul@0 | 4601 | + Q_DECLARE_PRIVATE( NamespaceJob ) |
paul@0 | 4602 | |
paul@0 | 4603 | friend class SessionPrivate; |
paul@0 | 4604 | |
paul@0 | 4605 | diff --git a/kimap/quotajobbase.cpp b/kimap/quotajobbase.cpp |
paul@0 | 4606 | index 16737ce..5ae6d56 100644 |
paul@0 | 4607 | --- a/kimap/quotajobbase.cpp |
paul@0 | 4608 | +++ b/kimap/quotajobbase.cpp |
paul@0 | 4609 | @@ -22,8 +22,8 @@ |
paul@0 | 4610 | #include "message_p.h" |
paul@0 | 4611 | #include "session_p.h" |
paul@0 | 4612 | |
paul@0 | 4613 | -#include <klocale.h> |
paul@0 | 4614 | -#include <kdebug.h> |
paul@0 | 4615 | +#include <KDE/KLocalizedString> |
paul@0 | 4616 | +#include <KDE/KDebug> |
paul@0 | 4617 | |
paul@0 | 4618 | using namespace KIMAP; |
paul@0 | 4619 | |
paul@0 | 4620 | @@ -37,7 +37,7 @@ QMap<QByteArray, QPair<qint64, qint64> > QuotaJobBasePrivate::readQuota( const M |
paul@0 | 4621 | QByteArray resource = quotas[i].toUpper(); |
paul@0 | 4622 | qint64 usage = quotas[i+1].toInt(); |
paul@0 | 4623 | qint64 limit = quotas[i+2].toInt(); |
paul@0 | 4624 | - quotaMap[resource] = qMakePair(usage, limit); |
paul@0 | 4625 | + quotaMap[resource] = qMakePair( usage, limit ); |
paul@0 | 4626 | i += 3; |
paul@0 | 4627 | } |
paul@0 | 4628 | |
paul@0 | 4629 | @@ -45,45 +45,40 @@ QMap<QByteArray, QPair<qint64, qint64> > QuotaJobBasePrivate::readQuota( const M |
paul@0 | 4630 | } |
paul@0 | 4631 | |
paul@0 | 4632 | QuotaJobBase::QuotaJobBase( Session *session ) |
paul@0 | 4633 | - : Job( *new QuotaJobBasePrivate(session, i18n("QuotaJobBase")) ) |
paul@0 | 4634 | + : Job( *new QuotaJobBasePrivate( session, i18n( "QuotaJobBase" ) ) ) |
paul@0 | 4635 | { |
paul@0 | 4636 | } |
paul@0 | 4637 | |
paul@0 | 4638 | - |
paul@0 | 4639 | QuotaJobBase::QuotaJobBase( JobPrivate &dd ) |
paul@0 | 4640 | - : Job(dd) |
paul@0 | 4641 | + : Job( dd ) |
paul@0 | 4642 | { |
paul@0 | 4643 | - |
paul@0 | 4644 | } |
paul@0 | 4645 | |
paul@0 | 4646 | QuotaJobBase::~QuotaJobBase() |
paul@0 | 4647 | { |
paul@0 | 4648 | } |
paul@0 | 4649 | |
paul@0 | 4650 | - |
paul@0 | 4651 | qint64 QuotaJobBase::usage(const QByteArray& resource) |
paul@0 | 4652 | { |
paul@0 | 4653 | - Q_D(QuotaJobBase); |
paul@0 | 4654 | + Q_D( QuotaJobBase ); |
paul@0 | 4655 | |
paul@0 | 4656 | QByteArray r = resource.toUpper(); |
paul@0 | 4657 | |
paul@0 | 4658 | - if (d->quota.contains(r)) { |
paul@0 | 4659 | + if ( d->quota.contains( r ) ) { |
paul@0 | 4660 | return d->quota[r].first; |
paul@0 | 4661 | } |
paul@0 | 4662 | - |
paul@0 | 4663 | return -1; |
paul@0 | 4664 | } |
paul@0 | 4665 | |
paul@0 | 4666 | qint64 QuotaJobBase::limit(const QByteArray& resource) |
paul@0 | 4667 | { |
paul@0 | 4668 | - Q_D(QuotaJobBase); |
paul@0 | 4669 | + Q_D( QuotaJobBase ); |
paul@0 | 4670 | |
paul@0 | 4671 | QByteArray r = resource.toUpper(); |
paul@0 | 4672 | |
paul@0 | 4673 | - if (d->quota.contains(r)) { |
paul@0 | 4674 | + if ( d->quota.contains( r ) ) { |
paul@0 | 4675 | return d->quota[r].second; |
paul@0 | 4676 | } |
paul@0 | 4677 | - |
paul@0 | 4678 | return -1; |
paul@0 | 4679 | } |
paul@0 | 4680 | |
paul@0 | 4681 | diff --git a/kimap/quotajobbase.h b/kimap/quotajobbase.h |
paul@0 | 4682 | index 640ca0d..29b06bb 100644 |
paul@0 | 4683 | --- a/kimap/quotajobbase.h |
paul@0 | 4684 | +++ b/kimap/quotajobbase.h |
paul@0 | 4685 | @@ -42,7 +42,7 @@ class QuotaJobBasePrivate; |
paul@0 | 4686 | class KIMAP_EXPORT QuotaJobBase : public Job |
paul@0 | 4687 | { |
paul@0 | 4688 | Q_OBJECT |
paul@0 | 4689 | - Q_DECLARE_PRIVATE(QuotaJobBase) |
paul@0 | 4690 | + Q_DECLARE_PRIVATE( QuotaJobBase ) |
paul@0 | 4691 | |
paul@0 | 4692 | friend class SessionPrivate; |
paul@0 | 4693 | |
paul@0 | 4694 | diff --git a/kimap/quotajobbase_p.h b/kimap/quotajobbase_p.h |
paul@0 | 4695 | index aedc752..dc4313b 100644 |
paul@0 | 4696 | --- a/kimap/quotajobbase_p.h |
paul@0 | 4697 | +++ b/kimap/quotajobbase_p.h |
paul@0 | 4698 | @@ -24,12 +24,14 @@ |
paul@0 | 4699 | #include "message_p.h" |
paul@0 | 4700 | #include "session.h" |
paul@0 | 4701 | |
paul@0 | 4702 | +#include <QMap> |
paul@0 | 4703 | + |
paul@0 | 4704 | namespace KIMAP |
paul@0 | 4705 | { |
paul@0 | 4706 | class QuotaJobBasePrivate : public JobPrivate |
paul@0 | 4707 | { |
paul@0 | 4708 | public: |
paul@0 | 4709 | - QuotaJobBasePrivate( Session *session, const QString& name ) : JobPrivate(session, name) |
paul@0 | 4710 | + QuotaJobBasePrivate( Session *session, const QString& name ) : JobPrivate( session, name ) |
paul@0 | 4711 | {} |
paul@0 | 4712 | |
paul@0 | 4713 | ~QuotaJobBasePrivate() { } |
paul@0 | 4714 | diff --git a/kimap/renamejob.cpp b/kimap/renamejob.cpp |
paul@0 | 4715 | index 1ec357d..a8c8505 100644 |
paul@0 | 4716 | --- a/kimap/renamejob.cpp |
paul@0 | 4717 | +++ b/kimap/renamejob.cpp |
paul@0 | 4718 | @@ -19,8 +19,8 @@ |
paul@0 | 4719 | |
paul@0 | 4720 | #include "renamejob.h" |
paul@0 | 4721 | |
paul@0 | 4722 | -#include <klocale.h> |
paul@0 | 4723 | -#include <kdebug.h> |
paul@0 | 4724 | +#include <KDE/KLocalizedString> |
paul@0 | 4725 | +#include <KDE/KDebug> |
paul@0 | 4726 | |
paul@0 | 4727 | #include "job_p.h" |
paul@0 | 4728 | #include "message_p.h" |
paul@0 | 4729 | @@ -32,7 +32,7 @@ namespace KIMAP |
paul@0 | 4730 | class RenameJobPrivate : public JobPrivate |
paul@0 | 4731 | { |
paul@0 | 4732 | public: |
paul@0 | 4733 | - RenameJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { } |
paul@0 | 4734 | + RenameJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { } |
paul@0 | 4735 | ~RenameJobPrivate() { } |
paul@0 | 4736 | |
paul@0 | 4737 | QString sourceMailBox; |
paul@0 | 4738 | @@ -43,7 +43,7 @@ namespace KIMAP |
paul@0 | 4739 | using namespace KIMAP; |
paul@0 | 4740 | |
paul@0 | 4741 | RenameJob::RenameJob( Session *session ) |
paul@0 | 4742 | - : Job( *new RenameJobPrivate(session, i18n("Rename")) ) |
paul@0 | 4743 | + : Job( *new RenameJobPrivate( session, i18n( "Rename" ) ) ) |
paul@0 | 4744 | { |
paul@0 | 4745 | } |
paul@0 | 4746 | |
paul@0 | 4747 | @@ -53,33 +53,34 @@ RenameJob::~RenameJob() |
paul@0 | 4748 | |
paul@0 | 4749 | void RenameJob::doStart() |
paul@0 | 4750 | { |
paul@0 | 4751 | - Q_D(RenameJob); |
paul@0 | 4752 | - d->tags << d->sessionInternal()->sendCommand( "RENAME", '\"' + KIMAP::encodeImapFolderName( d->sourceMailBox.toUtf8() ) + "\" \"" |
paul@0 | 4753 | - + KIMAP::encodeImapFolderName( d->destinationMailBox.toUtf8() )+ '\"' ); |
paul@0 | 4754 | + Q_D( RenameJob ); |
paul@0 | 4755 | + d->tags << d->sessionInternal()->sendCommand( "RENAME", '\"' + KIMAP::encodeImapFolderName( d->sourceMailBox.toUtf8() ) + |
paul@0 | 4756 | + "\" \"" + KIMAP::encodeImapFolderName( d->destinationMailBox.toUtf8() ) + '\"' ); |
paul@0 | 4757 | } |
paul@0 | 4758 | |
paul@0 | 4759 | void RenameJob::setSourceMailBox( const QString &mailBox ) |
paul@0 | 4760 | { |
paul@0 | 4761 | - Q_D(RenameJob); |
paul@0 | 4762 | + Q_D( RenameJob ); |
paul@0 | 4763 | d->sourceMailBox = mailBox; |
paul@0 | 4764 | } |
paul@0 | 4765 | |
paul@0 | 4766 | QString RenameJob::sourceMailBox() const |
paul@0 | 4767 | { |
paul@0 | 4768 | - Q_D(const RenameJob); |
paul@0 | 4769 | + Q_D( const RenameJob ); |
paul@0 | 4770 | return d->sourceMailBox; |
paul@0 | 4771 | } |
paul@0 | 4772 | |
paul@0 | 4773 | void RenameJob::setDestinationMailBox( const QString &mailBox ) |
paul@0 | 4774 | { |
paul@0 | 4775 | - Q_D(RenameJob); |
paul@0 | 4776 | + Q_D( RenameJob ); |
paul@0 | 4777 | d->destinationMailBox = mailBox; |
paul@0 | 4778 | } |
paul@0 | 4779 | |
paul@0 | 4780 | QString RenameJob::destinationMailBox() const |
paul@0 | 4781 | { |
paul@0 | 4782 | - Q_D(const RenameJob); |
paul@0 | 4783 | + Q_D( const RenameJob ); |
paul@0 | 4784 | return d->destinationMailBox; |
paul@0 | 4785 | } |
paul@0 | 4786 | |
paul@0 | 4787 | #include "renamejob.moc" |
paul@0 | 4788 | + |
paul@0 | 4789 | diff --git a/kimap/renamejob.h b/kimap/renamejob.h |
paul@0 | 4790 | index 84ae96a..28949f5 100644 |
paul@0 | 4791 | --- a/kimap/renamejob.h |
paul@0 | 4792 | +++ b/kimap/renamejob.h |
paul@0 | 4793 | @@ -32,7 +32,7 @@ class RenameJobPrivate; |
paul@0 | 4794 | class KIMAP_EXPORT RenameJob : public Job |
paul@0 | 4795 | { |
paul@0 | 4796 | Q_OBJECT |
paul@0 | 4797 | - Q_DECLARE_PRIVATE(RenameJob) |
paul@0 | 4798 | + Q_DECLARE_PRIVATE( RenameJob ) |
paul@0 | 4799 | |
paul@0 | 4800 | friend class SessionPrivate; |
paul@0 | 4801 | |
paul@0 | 4802 | diff --git a/kimap/rfccodecs.cpp b/kimap/rfccodecs.cpp |
paul@0 | 4803 | index f102514..04cc886 100644 |
paul@0 | 4804 | --- a/kimap/rfccodecs.cpp |
paul@0 | 4805 | +++ b/kimap/rfccodecs.cpp |
paul@0 | 4806 | @@ -331,7 +331,7 @@ const QString KIMAP::decodeRFC2047String( const QString &str, |
paul@0 | 4807 | } |
paul@0 | 4808 | |
paul@0 | 4809 | // FIXME get rid of the conversion? |
paul@0 | 4810 | - QByteArray aStr = str.toAscii (); // QString.length() means Unicode chars |
paul@0 | 4811 | + QByteArray aStr = str.toLatin1 (); // QString.length() means Unicode chars |
paul@0 | 4812 | QByteArray result; |
paul@0 | 4813 | char *pos, *beg, *end, *mid = 0; |
paul@0 | 4814 | QByteArray cstr; |
paul@0 | 4815 | @@ -353,8 +353,9 @@ const QString KIMAP::decodeRFC2047String( const QString &str, |
paul@0 | 4816 | for ( i = 2, pos += 2; |
paul@0 | 4817 | i < maxLen && |
paul@0 | 4818 | ( *pos != '?' && ( ispunct( *pos ) || isalnum ( *pos ) ) ); |
paul@0 | 4819 | - i++ ) |
paul@0 | 4820 | + i++ ) { |
paul@0 | 4821 | pos++; |
paul@0 | 4822 | + } |
paul@0 | 4823 | if ( *pos != '?' || i < 4 || i >= maxLen ) { |
paul@0 | 4824 | valid = false; |
paul@0 | 4825 | } else { |
paul@0 | 4826 | @@ -376,7 +377,7 @@ const QString KIMAP::decodeRFC2047String( const QString &str, |
paul@0 | 4827 | } |
paul@0 | 4828 | pos += 3; |
paul@0 | 4829 | i += 3; |
paul@0 | 4830 | -// qDebug() << "Charset:" << charset << "- Language:" << language << "-'" << pos << "'"; |
paul@0 | 4831 | +// kDebug() << "Charset:" << charset << "- Language:" << language << "-'" << pos << "'"; |
paul@0 | 4832 | } |
paul@0 | 4833 | if ( valid ) { |
paul@0 | 4834 | mid = pos; |
paul@0 | 4835 | @@ -401,10 +402,10 @@ const QString KIMAP::decodeRFC2047String( const QString &str, |
paul@0 | 4836 | cstr[i] = ' '; |
paul@0 | 4837 | } |
paul@0 | 4838 | } |
paul@0 | 4839 | -// qDebug() << "before QP '" |
paul@0 | 4840 | +// kDebug() << "before QP '" |
paul@0 | 4841 | // << cstr << "'"; |
paul@0 | 4842 | cstr = KCodecs::quotedPrintableDecode( cstr ); |
paul@0 | 4843 | -// qDebug() << "after QP '" |
paul@0 | 4844 | +// kDebug() << "after QP '" |
paul@0 | 4845 | // << cstr << "'"; |
paul@0 | 4846 | } else { |
paul@0 | 4847 | // decode base64 text |
paul@0 | 4848 | @@ -418,7 +419,7 @@ const QString KIMAP::decodeRFC2047String( const QString &str, |
paul@0 | 4849 | |
paul@0 | 4850 | pos = end - 1; |
paul@0 | 4851 | } else { |
paul@0 | 4852 | -// qDebug() << "invalid"; |
paul@0 | 4853 | +// kDebug() << "invalid"; |
paul@0 | 4854 | //result += "=?"; |
paul@0 | 4855 | //pos = beg -1; // because pos gets increased shortly afterwards |
paul@0 | 4856 | pos = beg - 2; |
paul@0 | 4857 | @@ -427,9 +428,9 @@ const QString KIMAP::decodeRFC2047String( const QString &str, |
paul@0 | 4858 | } |
paul@0 | 4859 | } |
paul@0 | 4860 | if ( !charset.isEmpty () ) { |
paul@0 | 4861 | - QTextCodec *aCodec = codecForName( charset.toAscii () ); |
paul@0 | 4862 | + QTextCodec *aCodec = codecForName( charset.toLatin1 () ); |
paul@0 | 4863 | if ( aCodec ) { |
paul@0 | 4864 | -// qDebug() << "Codec is" << aCodec->name(); |
paul@0 | 4865 | +// kDebug() << "Codec is" << aCodec->name(); |
paul@0 | 4866 | return aCodec->toUnicode( result ); |
paul@0 | 4867 | } |
paul@0 | 4868 | } |
paul@0 | 4869 | @@ -636,7 +637,7 @@ const QString KIMAP::decodeRFC2231String( const QString &str ) |
paul@0 | 4870 | QString st = str.mid ( l + 1 ); |
paul@0 | 4871 | QString language = str.mid ( p + 1, l - p - 1 ); |
paul@0 | 4872 | |
paul@0 | 4873 | - //qDebug() << "Charset:" << charset << "Language:" << language; |
paul@0 | 4874 | + //kDebug() << "Charset:" << charset << "Language:" << language; |
paul@0 | 4875 | |
paul@0 | 4876 | char ch, ch2; |
paul@0 | 4877 | p = 0; |
paul@0 | 4878 | diff --git a/kimap/searchjob.cpp b/kimap/searchjob.cpp |
paul@0 | 4879 | index ede53a3..0e91010 100644 |
paul@0 | 4880 | --- a/kimap/searchjob.cpp |
paul@0 | 4881 | +++ b/kimap/searchjob.cpp |
paul@0 | 4882 | @@ -19,8 +19,8 @@ |
paul@0 | 4883 | |
paul@0 | 4884 | #include "searchjob.h" |
paul@0 | 4885 | |
paul@0 | 4886 | -#include <klocale.h> |
paul@0 | 4887 | -#include <kdebug.h> |
paul@0 | 4888 | +#include <KDE/KLocalizedString> |
paul@0 | 4889 | +#include <KDE/KDebug> |
paul@0 | 4890 | |
paul@0 | 4891 | #include <QtCore/QDate> |
paul@0 | 4892 | |
paul@0 | 4893 | @@ -35,7 +35,7 @@ namespace KIMAP |
paul@0 | 4894 | class SearchJobPrivate : public JobPrivate |
paul@0 | 4895 | { |
paul@0 | 4896 | public: |
paul@0 | 4897 | - SearchJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name), logic(SearchJob::And) { |
paul@0 | 4898 | + SearchJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ), logic( SearchJob::And ) { |
paul@0 | 4899 | criteriaMap[SearchJob::All] = "ALL"; |
paul@0 | 4900 | criteriaMap[SearchJob::Answered] = "ANSWERED"; |
paul@0 | 4901 | criteriaMap[SearchJob::BCC] = "BCC"; |
paul@0 | 4902 | @@ -89,7 +89,6 @@ namespace KIMAP |
paul@0 | 4903 | } |
paul@0 | 4904 | ~SearchJobPrivate() { } |
paul@0 | 4905 | |
paul@0 | 4906 | - |
paul@0 | 4907 | QByteArray charset; |
paul@0 | 4908 | QList<QByteArray> criterias; |
paul@0 | 4909 | QMap<SearchJob::SearchCriteria, QByteArray > criteriaMap; |
paul@0 | 4910 | @@ -105,7 +104,7 @@ namespace KIMAP |
paul@0 | 4911 | using namespace KIMAP; |
paul@0 | 4912 | |
paul@0 | 4913 | SearchJob::SearchJob( Session *session ) |
paul@0 | 4914 | - : Job( *new SearchJobPrivate(session, i18nc("Name of the search job", "Search")) ) |
paul@0 | 4915 | + : Job( *new SearchJobPrivate( session, i18nc( "Name of the search job", "Search" ) ) ) |
paul@0 | 4916 | { |
paul@0 | 4917 | } |
paul@0 | 4918 | |
paul@0 | 4919 | @@ -115,37 +114,41 @@ SearchJob::~SearchJob() |
paul@0 | 4920 | |
paul@0 | 4921 | void SearchJob::doStart() |
paul@0 | 4922 | { |
paul@0 | 4923 | - Q_D(SearchJob); |
paul@0 | 4924 | + Q_D( SearchJob ); |
paul@0 | 4925 | |
paul@0 | 4926 | QByteArray searchKey; |
paul@0 | 4927 | |
paul@0 | 4928 | - if (!d->charset.isEmpty()) { |
paul@0 | 4929 | + if ( !d->charset.isEmpty() ) { |
paul@0 | 4930 | searchKey = "CHARSET " + d->charset; |
paul@0 | 4931 | } |
paul@0 | 4932 | |
paul@0 | 4933 | - if (d->logic == SearchJob::Not) { |
paul@0 | 4934 | - searchKey += "NOT"; |
paul@0 | 4935 | - } else if (d->logic == SearchJob::Or) { |
paul@0 | 4936 | - searchKey += "OR"; |
paul@0 | 4937 | + if ( d->logic == SearchJob::Not ) { |
paul@0 | 4938 | + searchKey += "NOT "; |
paul@0 | 4939 | + } else if ( d->logic == SearchJob::Or && d->criterias.size() > 1 ) { |
paul@0 | 4940 | + searchKey += "OR "; |
paul@0 | 4941 | } |
paul@0 | 4942 | |
paul@0 | 4943 | if ( d->logic == SearchJob::And ) { |
paul@0 | 4944 | - for ( int i = 0; i<d->criterias.size(); i++ ) { |
paul@0 | 4945 | + for ( int i = 0; i < d->criterias.size(); i++ ) { |
paul@0 | 4946 | const QByteArray key = d->criterias.at( i ); |
paul@0 | 4947 | - if ( i>0 ) searchKey+= ' '; |
paul@0 | 4948 | + if ( i > 0 ) { |
paul@0 | 4949 | + searchKey += ' '; |
paul@0 | 4950 | + } |
paul@0 | 4951 | searchKey += key; |
paul@0 | 4952 | } |
paul@0 | 4953 | } else { |
paul@0 | 4954 | - for ( int i = 0; i<d->criterias.size(); i++ ) { |
paul@0 | 4955 | + for ( int i = 0; i < d->criterias.size(); i++ ) { |
paul@0 | 4956 | const QByteArray key = d->criterias.at( i ); |
paul@0 | 4957 | - if ( i>0 ) searchKey+= ' '; |
paul@0 | 4958 | + if ( i > 0 ) { |
paul@0 | 4959 | + searchKey += ' '; |
paul@0 | 4960 | + } |
paul@0 | 4961 | searchKey += '(' + key + ')'; |
paul@0 | 4962 | } |
paul@0 | 4963 | } |
paul@0 | 4964 | |
paul@0 | 4965 | QByteArray command = "SEARCH"; |
paul@0 | 4966 | if ( d->uidBased ) { |
paul@0 | 4967 | - command = "UID "+ command; |
paul@0 | 4968 | + command = "UID " + command; |
paul@0 | 4969 | } |
paul@0 | 4970 | |
paul@0 | 4971 | d->tags << d->sessionInternal()->sendCommand( command, searchKey ); |
paul@0 | 4972 | @@ -153,44 +156,43 @@ void SearchJob::doStart() |
paul@0 | 4973 | |
paul@0 | 4974 | void SearchJob::handleResponse( const Message &response ) |
paul@0 | 4975 | { |
paul@0 | 4976 | - Q_D(SearchJob); |
paul@0 | 4977 | + Q_D( SearchJob ); |
paul@0 | 4978 | |
paul@0 | 4979 | - if (handleErrorReplies(response) == NotHandled ) { |
paul@0 | 4980 | + if ( handleErrorReplies( response ) == NotHandled ) { |
paul@0 | 4981 | if ( response.content[0].toString() == "+" ) { |
paul@0 | 4982 | d->sessionInternal()->sendData( d->contents[d->nextContent] ); |
paul@0 | 4983 | d->nextContent++; |
paul@0 | 4984 | } else if ( response.content[1].toString() == "SEARCH" ) { |
paul@0 | 4985 | - for(int i = 2; i < response.content.size(); i++) { |
paul@0 | 4986 | - d->results.append(response.content[i].toString().toInt()); |
paul@0 | 4987 | + for ( int i = 2; i < response.content.size(); i++ ) { |
paul@0 | 4988 | + d->results.append( response.content[i].toString().toInt() ); |
paul@0 | 4989 | } |
paul@0 | 4990 | } |
paul@0 | 4991 | } |
paul@0 | 4992 | } |
paul@0 | 4993 | |
paul@0 | 4994 | - |
paul@0 | 4995 | void SearchJob::setCharset( const QByteArray &charset ) |
paul@0 | 4996 | { |
paul@0 | 4997 | - Q_D(SearchJob); |
paul@0 | 4998 | + Q_D( SearchJob ); |
paul@0 | 4999 | d->charset = charset; |
paul@0 | 5000 | } |
paul@0 | 5001 | |
paul@0 | 5002 | QByteArray SearchJob::charset() const |
paul@0 | 5003 | { |
paul@0 | 5004 | - Q_D(const SearchJob); |
paul@0 | 5005 | + Q_D( const SearchJob ); |
paul@0 | 5006 | return d->charset; |
paul@0 | 5007 | } |
paul@0 | 5008 | |
paul@0 | 5009 | void SearchJob::setSearchLogic( SearchLogic logic ) |
paul@0 | 5010 | { |
paul@0 | 5011 | - Q_D(SearchJob); |
paul@0 | 5012 | + Q_D( SearchJob ); |
paul@0 | 5013 | d->logic = logic; |
paul@0 | 5014 | } |
paul@0 | 5015 | |
paul@0 | 5016 | void SearchJob::addSearchCriteria( SearchCriteria criteria ) |
paul@0 | 5017 | { |
paul@0 | 5018 | - Q_D(SearchJob); |
paul@0 | 5019 | + Q_D( SearchJob ); |
paul@0 | 5020 | |
paul@0 | 5021 | - switch (criteria) { |
paul@0 | 5022 | + switch ( criteria ) { |
paul@0 | 5023 | case All: |
paul@0 | 5024 | case Answered: |
paul@0 | 5025 | case Deleted: |
paul@0 | 5026 | @@ -205,36 +207,34 @@ void SearchJob::addSearchCriteria( SearchCriteria criteria ) |
paul@0 | 5027 | case Undraft: |
paul@0 | 5028 | case Unflagged: |
paul@0 | 5029 | case Unseen: |
paul@0 | 5030 | - d->criterias.append(d->criteriaMap[criteria]); |
paul@0 | 5031 | + d->criterias.append( d->criteriaMap[criteria] ); |
paul@0 | 5032 | break; |
paul@0 | 5033 | default: |
paul@0 | 5034 | //TODO Discuss if we keep error checking here, or accept anything, even if it is wrong |
paul@0 | 5035 | - qDebug() << "Criteria " << d->criteriaMap[criteria] << " needs an argument, but none was specified."; |
paul@0 | 5036 | + kDebug() << "Criteria " << d->criteriaMap[criteria] << " needs an argument, but none was specified."; |
paul@0 | 5037 | break; |
paul@0 | 5038 | } |
paul@0 | 5039 | } |
paul@0 | 5040 | |
paul@0 | 5041 | - |
paul@0 | 5042 | void SearchJob::addSearchCriteria( SearchCriteria criteria, int argument ) |
paul@0 | 5043 | { |
paul@0 | 5044 | - Q_D(SearchJob); |
paul@0 | 5045 | - switch (criteria) { |
paul@0 | 5046 | + Q_D( SearchJob ); |
paul@0 | 5047 | + switch ( criteria ) { |
paul@0 | 5048 | case Larger: |
paul@0 | 5049 | case Smaller: |
paul@0 | 5050 | - d->criterias.append(d->criteriaMap[criteria] + ' ' + QByteArray::number(argument)); |
paul@0 | 5051 | + d->criterias.append( d->criteriaMap[criteria] + ' ' + QByteArray::number( argument ) ); |
paul@0 | 5052 | break; |
paul@0 | 5053 | default: |
paul@0 | 5054 | //TODO Discuss if we keep error checking here, or accept anything, even if it is wrong |
paul@0 | 5055 | - qDebug() << "Criteria " << d->criteriaMap[criteria] << " doesn't accept an integer as an argument."; |
paul@0 | 5056 | + kDebug() << "Criteria " << d->criteriaMap[criteria] << " doesn't accept an integer as an argument."; |
paul@0 | 5057 | break; |
paul@0 | 5058 | } |
paul@0 | 5059 | } |
paul@0 | 5060 | |
paul@0 | 5061 | - |
paul@0 | 5062 | void SearchJob::addSearchCriteria( SearchCriteria criteria, const QByteArray &argument ) |
paul@0 | 5063 | { |
paul@0 | 5064 | - Q_D(SearchJob); |
paul@0 | 5065 | - switch (criteria) { |
paul@0 | 5066 | + Q_D( SearchJob ); |
paul@0 | 5067 | + switch ( criteria ) { |
paul@0 | 5068 | case BCC: |
paul@0 | 5069 | case Body: |
paul@0 | 5070 | case CC: |
paul@0 | 5071 | @@ -242,71 +242,71 @@ void SearchJob::addSearchCriteria( SearchCriteria criteria, const QByteArray &ar |
paul@0 | 5072 | case Subject: |
paul@0 | 5073 | case Text: |
paul@0 | 5074 | case To: |
paul@0 | 5075 | - d->contents.append(argument); |
paul@0 | 5076 | - d->criterias.append(d->criteriaMap[criteria] + " {" + QByteArray::number(argument.size()) + '}'); |
paul@0 | 5077 | + d->contents.append( argument ); |
paul@0 | 5078 | + d->criterias.append( d->criteriaMap[criteria] + " {" + QByteArray::number( argument.size() ) + '}' ); |
paul@0 | 5079 | break; |
paul@0 | 5080 | case Keyword: |
paul@0 | 5081 | case Unkeyword: |
paul@0 | 5082 | case Header: |
paul@0 | 5083 | case Uid: |
paul@0 | 5084 | - d->criterias.append(d->criteriaMap[criteria] + ' ' + argument); |
paul@0 | 5085 | + d->criterias.append( d->criteriaMap[criteria] + ' ' + argument ); |
paul@0 | 5086 | break; |
paul@0 | 5087 | default: |
paul@0 | 5088 | //TODO Discuss if we keep error checking here, or accept anything, even if it is wrong |
paul@0 | 5089 | - qDebug() << "Criteria " << d->criteriaMap[criteria] << " doesn't accept any argument."; |
paul@0 | 5090 | + kDebug() << "Criteria " << d->criteriaMap[criteria] << " doesn't accept any argument."; |
paul@0 | 5091 | break; |
paul@0 | 5092 | } |
paul@0 | 5093 | } |
paul@0 | 5094 | |
paul@0 | 5095 | void SearchJob::addSearchCriteria( SearchCriteria criteria, const QDate &argument ) |
paul@0 | 5096 | { |
paul@0 | 5097 | - Q_D(SearchJob); |
paul@0 | 5098 | - switch (criteria) { |
paul@0 | 5099 | + Q_D( SearchJob ); |
paul@0 | 5100 | + switch ( criteria ) { |
paul@0 | 5101 | case Before: |
paul@0 | 5102 | case On: |
paul@0 | 5103 | case SentBefore: |
paul@0 | 5104 | case SentSince: |
paul@0 | 5105 | case Since: { |
paul@0 | 5106 | - QByteArray date = QByteArray::number(argument.day()) + '-'; |
paul@0 | 5107 | + QByteArray date = QByteArray::number( argument.day() ) + '-'; |
paul@0 | 5108 | date += d->months[argument.month()] + '-'; |
paul@0 | 5109 | - date += QByteArray::number(argument.year()); |
paul@0 | 5110 | - d->criterias.append(d->criteriaMap[criteria] + " \"" + date + '\"'); |
paul@0 | 5111 | + date += QByteArray::number( argument.year() ); |
paul@0 | 5112 | + d->criterias.append( d->criteriaMap[criteria] + " \"" + date + '\"' ); |
paul@0 | 5113 | break; |
paul@0 | 5114 | } |
paul@0 | 5115 | default: |
paul@0 | 5116 | //TODO Discuss if we keep error checking here, or accept anything, even if it is wrong |
paul@0 | 5117 | - qDebug() << "Criteria " << d->criteriaMap[criteria] << " doesn't accept a date as argument."; |
paul@0 | 5118 | + kDebug() << "Criteria " << d->criteriaMap[criteria] << " doesn't accept a date as argument."; |
paul@0 | 5119 | break; |
paul@0 | 5120 | } |
paul@0 | 5121 | } |
paul@0 | 5122 | |
paul@0 | 5123 | void SearchJob::addSearchCriteria( const QByteArray &searchCriteria ) |
paul@0 | 5124 | { |
paul@0 | 5125 | - Q_D(SearchJob); |
paul@0 | 5126 | - d->criterias.append(searchCriteria); |
paul@0 | 5127 | + Q_D( SearchJob ); |
paul@0 | 5128 | + d->criterias.append( searchCriteria ); |
paul@0 | 5129 | } |
paul@0 | 5130 | |
paul@0 | 5131 | void SearchJob::setUidBased(bool uidBased) |
paul@0 | 5132 | { |
paul@0 | 5133 | - Q_D(SearchJob); |
paul@0 | 5134 | + Q_D( SearchJob ); |
paul@0 | 5135 | d->uidBased = uidBased; |
paul@0 | 5136 | } |
paul@0 | 5137 | |
paul@0 | 5138 | bool SearchJob::isUidBased() const |
paul@0 | 5139 | { |
paul@0 | 5140 | - Q_D(const SearchJob); |
paul@0 | 5141 | + Q_D( const SearchJob ); |
paul@0 | 5142 | return d->uidBased; |
paul@0 | 5143 | } |
paul@0 | 5144 | |
paul@0 | 5145 | QList<qint64> SearchJob::results() const |
paul@0 | 5146 | { |
paul@0 | 5147 | - Q_D(const SearchJob); |
paul@0 | 5148 | + Q_D( const SearchJob ); |
paul@0 | 5149 | return d->results; |
paul@0 | 5150 | } |
paul@0 | 5151 | |
paul@0 | 5152 | QList<int> SearchJob::foundItems() |
paul@0 | 5153 | { |
paul@0 | 5154 | - Q_D(const SearchJob); |
paul@0 | 5155 | + Q_D( const SearchJob ); |
paul@0 | 5156 | |
paul@0 | 5157 | QList<int> results; |
paul@0 | 5158 | qCopy( d->results.begin(), d->results.end(), results.begin() ); |
paul@0 | 5159 | @@ -314,4 +314,5 @@ QList<int> SearchJob::foundItems() |
paul@0 | 5160 | return results; |
paul@0 | 5161 | } |
paul@0 | 5162 | |
paul@0 | 5163 | -#include "searchjob.moc" |
paul@0 | 5164 | \ No newline at end of file |
paul@0 | 5165 | +#include "searchjob.moc" |
paul@0 | 5166 | + |
paul@0 | 5167 | diff --git a/kimap/searchjob.h b/kimap/searchjob.h |
paul@0 | 5168 | index 077e8d4..1b53c1e 100644 |
paul@0 | 5169 | --- a/kimap/searchjob.h |
paul@0 | 5170 | +++ b/kimap/searchjob.h |
paul@0 | 5171 | @@ -35,7 +35,7 @@ class SearchJobPrivate; |
paul@0 | 5172 | class KIMAP_EXPORT SearchJob : public Job |
paul@0 | 5173 | { |
paul@0 | 5174 | Q_OBJECT |
paul@0 | 5175 | - Q_DECLARE_PRIVATE(SearchJob) |
paul@0 | 5176 | + Q_DECLARE_PRIVATE( SearchJob ) |
paul@0 | 5177 | |
paul@0 | 5178 | friend class SessionPrivate; |
paul@0 | 5179 | |
paul@0 | 5180 | diff --git a/kimap/selectjob.cpp b/kimap/selectjob.cpp |
paul@0 | 5181 | index b18130d..bcc65c6 100644 |
paul@0 | 5182 | --- a/kimap/selectjob.cpp |
paul@0 | 5183 | +++ b/kimap/selectjob.cpp |
paul@0 | 5184 | @@ -19,7 +19,8 @@ |
paul@0 | 5185 | |
paul@0 | 5186 | #include "selectjob.h" |
paul@0 | 5187 | |
paul@0 | 5188 | -#include <klocale.h> |
paul@0 | 5189 | +#include <KDE/KLocalizedString> |
paul@0 | 5190 | +#include <kdebug.h> |
paul@0 | 5191 | |
paul@0 | 5192 | #include "job_p.h" |
paul@0 | 5193 | #include "message_p.h" |
paul@0 | 5194 | @@ -32,8 +33,8 @@ namespace KIMAP |
paul@0 | 5195 | { |
paul@0 | 5196 | public: |
paul@0 | 5197 | SelectJobPrivate( Session *session, const QString& name ) |
paul@0 | 5198 | - : JobPrivate(session, name), readOnly(false), messageCount(-1), recentCount(-1), |
paul@0 | 5199 | - firstUnseenIndex(-1), uidValidity(-1), nextUid(-1) { } |
paul@0 | 5200 | + : JobPrivate( session, name ), readOnly( false ), messageCount( -1 ), recentCount( -1 ), |
paul@0 | 5201 | + firstUnseenIndex( -1 ), uidValidity( -1 ), nextUid( -1 ) { } |
paul@0 | 5202 | ~SelectJobPrivate() { } |
paul@0 | 5203 | |
paul@0 | 5204 | QString mailBox; |
paul@0 | 5205 | @@ -52,7 +53,7 @@ namespace KIMAP |
paul@0 | 5206 | using namespace KIMAP; |
paul@0 | 5207 | |
paul@0 | 5208 | SelectJob::SelectJob( Session *session ) |
paul@0 | 5209 | - : Job( *new SelectJobPrivate(session, i18nc("name of the select job", "Select")) ) |
paul@0 | 5210 | + : Job( *new SelectJobPrivate( session, i18nc( "name of the select job", "Select" ) ) ) |
paul@0 | 5211 | { |
paul@0 | 5212 | } |
paul@0 | 5213 | |
paul@0 | 5214 | @@ -62,73 +63,73 @@ SelectJob::~SelectJob() |
paul@0 | 5215 | |
paul@0 | 5216 | void SelectJob::setMailBox( const QString &mailBox ) |
paul@0 | 5217 | { |
paul@0 | 5218 | - Q_D(SelectJob); |
paul@0 | 5219 | + Q_D( SelectJob ); |
paul@0 | 5220 | d->mailBox = mailBox; |
paul@0 | 5221 | } |
paul@0 | 5222 | |
paul@0 | 5223 | QString SelectJob::mailBox() const |
paul@0 | 5224 | { |
paul@0 | 5225 | - Q_D(const SelectJob); |
paul@0 | 5226 | + Q_D( const SelectJob ); |
paul@0 | 5227 | return d->mailBox; |
paul@0 | 5228 | } |
paul@0 | 5229 | |
paul@0 | 5230 | void SelectJob::setOpenReadOnly( bool readOnly ) |
paul@0 | 5231 | { |
paul@0 | 5232 | - Q_D(SelectJob); |
paul@0 | 5233 | + Q_D( SelectJob ); |
paul@0 | 5234 | d->readOnly = readOnly; |
paul@0 | 5235 | } |
paul@0 | 5236 | |
paul@0 | 5237 | bool SelectJob::isOpenReadOnly() const |
paul@0 | 5238 | { |
paul@0 | 5239 | - Q_D(const SelectJob); |
paul@0 | 5240 | + Q_D( const SelectJob ); |
paul@0 | 5241 | return d->readOnly; |
paul@0 | 5242 | } |
paul@0 | 5243 | |
paul@0 | 5244 | QList<QByteArray> SelectJob::flags() const |
paul@0 | 5245 | { |
paul@0 | 5246 | - Q_D(const SelectJob); |
paul@0 | 5247 | + Q_D( const SelectJob ); |
paul@0 | 5248 | return d->flags; |
paul@0 | 5249 | } |
paul@0 | 5250 | |
paul@0 | 5251 | QList<QByteArray> SelectJob::permanentFlags() const |
paul@0 | 5252 | { |
paul@0 | 5253 | - Q_D(const SelectJob); |
paul@0 | 5254 | + Q_D( const SelectJob ); |
paul@0 | 5255 | return d->permanentFlags; |
paul@0 | 5256 | } |
paul@0 | 5257 | |
paul@0 | 5258 | int SelectJob::messageCount() const |
paul@0 | 5259 | { |
paul@0 | 5260 | - Q_D(const SelectJob); |
paul@0 | 5261 | + Q_D( const SelectJob ); |
paul@0 | 5262 | return d->messageCount; |
paul@0 | 5263 | } |
paul@0 | 5264 | |
paul@0 | 5265 | int SelectJob::recentCount() const |
paul@0 | 5266 | { |
paul@0 | 5267 | - Q_D(const SelectJob); |
paul@0 | 5268 | + Q_D( const SelectJob ); |
paul@0 | 5269 | return d->recentCount; |
paul@0 | 5270 | } |
paul@0 | 5271 | |
paul@0 | 5272 | int SelectJob::firstUnseenIndex() const |
paul@0 | 5273 | { |
paul@0 | 5274 | - Q_D(const SelectJob); |
paul@0 | 5275 | + Q_D( const SelectJob ); |
paul@0 | 5276 | return d->firstUnseenIndex; |
paul@0 | 5277 | } |
paul@0 | 5278 | |
paul@0 | 5279 | qint64 SelectJob::uidValidity() const |
paul@0 | 5280 | { |
paul@0 | 5281 | - Q_D(const SelectJob); |
paul@0 | 5282 | + Q_D( const SelectJob ); |
paul@0 | 5283 | return d->uidValidity; |
paul@0 | 5284 | } |
paul@0 | 5285 | |
paul@0 | 5286 | qint64 SelectJob::nextUid() const |
paul@0 | 5287 | { |
paul@0 | 5288 | - Q_D(const SelectJob); |
paul@0 | 5289 | + Q_D( const SelectJob ); |
paul@0 | 5290 | return d->nextUid; |
paul@0 | 5291 | } |
paul@0 | 5292 | |
paul@0 | 5293 | void SelectJob::doStart() |
paul@0 | 5294 | { |
paul@0 | 5295 | - Q_D(SelectJob); |
paul@0 | 5296 | + Q_D( SelectJob ); |
paul@0 | 5297 | |
paul@0 | 5298 | QByteArray command = "SELECT"; |
paul@0 | 5299 | if ( d->readOnly ) { |
paul@0 | 5300 | @@ -140,56 +141,65 @@ void SelectJob::doStart() |
paul@0 | 5301 | |
paul@0 | 5302 | void SelectJob::handleResponse( const Message &response ) |
paul@0 | 5303 | { |
paul@0 | 5304 | - Q_D(SelectJob); |
paul@0 | 5305 | + Q_D( SelectJob ); |
paul@0 | 5306 | |
paul@0 | 5307 | - if ( handleErrorReplies(response) == NotHandled) { |
paul@0 | 5308 | + if ( handleErrorReplies( response ) == NotHandled ) { |
paul@0 | 5309 | if ( response.content.size() >= 2 ) { |
paul@0 | 5310 | QByteArray code = response.content[1].toString(); |
paul@0 | 5311 | |
paul@0 | 5312 | - if ( code=="OK" ) { |
paul@0 | 5313 | - if ( response.responseCode.size() < 2 ) return; |
paul@0 | 5314 | + if ( code == "OK" ) { |
paul@0 | 5315 | + if ( response.responseCode.size() < 2 ) { |
paul@0 | 5316 | + return; |
paul@0 | 5317 | + } |
paul@0 | 5318 | |
paul@0 | 5319 | code = response.responseCode[0].toString(); |
paul@0 | 5320 | |
paul@0 | 5321 | - if ( code=="PERMANENTFLAGS" ) { |
paul@0 | 5322 | + if ( code == "PERMANENTFLAGS" ) { |
paul@0 | 5323 | d->permanentFlags = response.responseCode[1].toList(); |
paul@0 | 5324 | } else { |
paul@0 | 5325 | bool isInt; |
paul@0 | 5326 | |
paul@0 | 5327 | - if ( code=="UIDVALIDITY" ) { |
paul@0 | 5328 | - qint64 value = response.responseCode[1].toString().toLongLong(&isInt); |
paul@0 | 5329 | - if ( !isInt ) return; |
paul@0 | 5330 | + if ( code == "UIDVALIDITY" ) { |
paul@0 | 5331 | + qint64 value = response.responseCode[1].toString().toLongLong( &isInt ); |
paul@0 | 5332 | + if ( !isInt ) { |
paul@0 | 5333 | + return; |
paul@0 | 5334 | + } |
paul@0 | 5335 | d->uidValidity = value; |
paul@0 | 5336 | } else { |
paul@0 | 5337 | - qint64 value = response.responseCode[1].toString().toLongLong(&isInt); |
paul@0 | 5338 | - if ( !isInt ) return; |
paul@0 | 5339 | - if ( code=="UNSEEN" ) { |
paul@0 | 5340 | + qint64 value = response.responseCode[1].toString().toLongLong( &isInt ); |
paul@0 | 5341 | + if ( !isInt ) { |
paul@0 | 5342 | + return; |
paul@0 | 5343 | + } |
paul@0 | 5344 | + if ( code == "UNSEEN" ) { |
paul@0 | 5345 | d->firstUnseenIndex = value; |
paul@0 | 5346 | - } else if ( code=="UIDNEXT" ) { |
paul@0 | 5347 | + } else if ( code == "UIDNEXT" ) { |
paul@0 | 5348 | d->nextUid = value; |
paul@0 | 5349 | } |
paul@0 | 5350 | } |
paul@0 | 5351 | } |
paul@0 | 5352 | - } else if ( code=="FLAGS" ) { |
paul@0 | 5353 | + } else if ( code == "FLAGS" ) { |
paul@0 | 5354 | d->flags = response.content[2].toList(); |
paul@0 | 5355 | } else { |
paul@0 | 5356 | bool isInt; |
paul@0 | 5357 | - int value = response.content[1].toString().toInt(&isInt); |
paul@0 | 5358 | - if ( !isInt || response.content.size()<3 ) return; |
paul@0 | 5359 | + int value = response.content[1].toString().toInt( &isInt ); |
paul@0 | 5360 | + if ( !isInt || response.content.size() < 3 ) { |
paul@0 | 5361 | + return; |
paul@0 | 5362 | + } |
paul@0 | 5363 | |
paul@0 | 5364 | code = response.content[2].toString(); |
paul@0 | 5365 | - if ( code=="EXISTS" ) { |
paul@0 | 5366 | + if ( code == "EXISTS" ) { |
paul@0 | 5367 | d->messageCount = value; |
paul@0 | 5368 | - } else if ( code=="RECENT" ) { |
paul@0 | 5369 | + } else if ( code == "RECENT" ) { |
paul@0 | 5370 | d->recentCount = value; |
paul@0 | 5371 | } |
paul@0 | 5372 | } |
paul@0 | 5373 | } else { |
paul@0 | 5374 | - qDebug("%s", response.toString().constData()); |
paul@0 | 5375 | + kDebug() << response.toString(); |
paul@0 | 5376 | } |
paul@0 | 5377 | } else { |
paul@0 | 5378 | Q_ASSERT( error() || d->m_session->selectedMailBox() == d->mailBox ); |
paul@0 | 5379 | } |
paul@0 | 5380 | } |
paul@0 | 5381 | |
paul@0 | 5382 | -#include "selectjob.moc" |
paul@0 | 5383 | \ No newline at end of file |
paul@0 | 5384 | +#include "selectjob.moc" |
paul@0 | 5385 | + |
paul@0 | 5386 | diff --git a/kimap/selectjob.h b/kimap/selectjob.h |
paul@0 | 5387 | index c67d28c..87157b5 100644 |
paul@0 | 5388 | --- a/kimap/selectjob.h |
paul@0 | 5389 | +++ b/kimap/selectjob.h |
paul@0 | 5390 | @@ -33,7 +33,7 @@ class SelectJobPrivate; |
paul@0 | 5391 | class KIMAP_EXPORT SelectJob : public Job |
paul@0 | 5392 | { |
paul@0 | 5393 | Q_OBJECT |
paul@0 | 5394 | - Q_DECLARE_PRIVATE(SelectJob) |
paul@0 | 5395 | + Q_DECLARE_PRIVATE( SelectJob ) |
paul@0 | 5396 | |
paul@0 | 5397 | friend class SessionPrivate; |
paul@0 | 5398 | |
paul@0 | 5399 | diff --git a/kimap/session.cpp b/kimap/session.cpp |
paul@0 | 5400 | index 031508b..2b23adc 100644 |
paul@0 | 5401 | --- a/kimap/session.cpp |
paul@0 | 5402 | +++ b/kimap/session.cpp |
paul@0 | 5403 | @@ -27,7 +27,8 @@ |
paul@0 | 5404 | #include <QtCore/QDebug> |
paul@0 | 5405 | #include <QtCore/QTimer> |
paul@0 | 5406 | |
paul@0 | 5407 | -#include <klocale.h> |
paul@0 | 5408 | +#include <KDebug> |
paul@0 | 5409 | +#include <KDE/KLocalizedString> |
paul@0 | 5410 | |
paul@0 | 5411 | #include "job.h" |
paul@0 | 5412 | #include "loginjob.h" |
paul@0 | 5413 | @@ -36,14 +37,14 @@ |
paul@0 | 5414 | #include "sessionthread_p.h" |
paul@0 | 5415 | #include "rfccodecs.h" |
paul@0 | 5416 | |
paul@0 | 5417 | -Q_DECLARE_METATYPE(KTcpSocket::SslVersion) |
paul@0 | 5418 | -Q_DECLARE_METATYPE(QSslSocket::SslMode) |
paul@0 | 5419 | +Q_DECLARE_METATYPE( KTcpSocket::SslVersion ) |
paul@0 | 5420 | +Q_DECLARE_METATYPE( QSslSocket::SslMode ) |
paul@0 | 5421 | static const int _kimap_sslVersionId = qRegisterMetaType<KTcpSocket::SslVersion>(); |
paul@0 | 5422 | |
paul@0 | 5423 | using namespace KIMAP; |
paul@0 | 5424 | |
paul@0 | 5425 | Session::Session( const QString &hostName, quint16 port, QObject *parent) |
paul@0 | 5426 | - : QObject(parent), d(new SessionPrivate(this)) |
paul@0 | 5427 | + : QObject( parent ), d( new SessionPrivate( this ) ) |
paul@0 | 5428 | { |
paul@0 | 5429 | if ( !qgetenv( "KIMAP_LOGFILE" ).isEmpty() ) { |
paul@0 | 5430 | d->logger = new SessionLogger; |
paul@0 | 5431 | @@ -53,13 +54,23 @@ Session::Session( const QString &hostName, quint16 port, QObject *parent) |
paul@0 | 5432 | d->state = Disconnected; |
paul@0 | 5433 | d->jobRunning = false; |
paul@0 | 5434 | |
paul@0 | 5435 | - d->thread = new SessionThread(hostName, port, this); |
paul@0 | 5436 | - connect(d->thread, SIGNAL(encryptionNegotiationResult(bool,KTcpSocket::SslVersion)), |
paul@0 | 5437 | - d, SLOT(onEncryptionNegotiationResult(bool,KTcpSocket::SslVersion))); |
paul@0 | 5438 | - connect(d->thread, SIGNAL(sslError(KSslErrorUiData)), this, SLOT(handleSslError(KSslErrorUiData))); |
paul@0 | 5439 | + d->thread = new SessionThread( hostName, port ); |
paul@0 | 5440 | + connect( d->thread, SIGNAL(encryptionNegotiationResult(bool,KTcpSocket::SslVersion)), |
paul@0 | 5441 | + d, SLOT(onEncryptionNegotiationResult(bool,KTcpSocket::SslVersion)) ); |
paul@0 | 5442 | + connect( d->thread, SIGNAL(sslError(KSslErrorUiData)), |
paul@0 | 5443 | + d, SLOT(handleSslError(KSslErrorUiData)) ); |
paul@0 | 5444 | + connect( d->thread, SIGNAL(socketDisconnected()), |
paul@0 | 5445 | + d, SLOT(socketDisconnected()) ); |
paul@0 | 5446 | + connect( d->thread, SIGNAL(responseReceived(KIMAP::Message)), |
paul@0 | 5447 | + d, SLOT(responseReceived(KIMAP::Message)) ); |
paul@0 | 5448 | + connect( d->thread, SIGNAL(socketConnected()), |
paul@0 | 5449 | + d, SLOT(socketConnected()) ); |
paul@0 | 5450 | + connect( d->thread, SIGNAL(socketActivity()), |
paul@0 | 5451 | + d, SLOT(socketActivity()) ); |
paul@0 | 5452 | + connect( d->thread, SIGNAL(socketError()), |
paul@0 | 5453 | + d, SLOT(socketError()) ); |
paul@0 | 5454 | |
paul@0 | 5455 | d->startSocketTimer(); |
paul@0 | 5456 | - d->thread->start(); |
paul@0 | 5457 | } |
paul@0 | 5458 | |
paul@0 | 5459 | Session::~Session() |
paul@0 | 5460 | @@ -114,22 +125,19 @@ void KIMAP::Session::close() |
paul@0 | 5461 | |
paul@0 | 5462 | void SessionPrivate::handleSslError(const KSslErrorUiData& errorData) |
paul@0 | 5463 | { |
paul@0 | 5464 | - if (uiProxy && uiProxy->ignoreSslError(errorData)) { |
paul@0 | 5465 | - QMetaObject::invokeMethod( thread, "sslErrorHandlerResponse", Q_ARG(bool, true) ); |
paul@0 | 5466 | - } else { |
paul@0 | 5467 | - QMetaObject::invokeMethod( thread, "sslErrorHandlerResponse", Q_ARG(bool, false) ); |
paul@0 | 5468 | - } |
paul@0 | 5469 | + const bool ignoreSslError = uiProxy && uiProxy->ignoreSslError( errorData ); |
paul@0 | 5470 | + thread->sslErrorHandlerResponse(ignoreSslError); |
paul@0 | 5471 | } |
paul@0 | 5472 | |
paul@0 | 5473 | SessionPrivate::SessionPrivate( Session *session ) |
paul@0 | 5474 | : QObject( session ), |
paul@0 | 5475 | - q(session), |
paul@0 | 5476 | - state(Session::Disconnected), |
paul@0 | 5477 | - logger(0), |
paul@0 | 5478 | - currentJob(0), |
paul@0 | 5479 | - tagCount(0), |
paul@0 | 5480 | - sslVersion(KTcpSocket::UnknownSslVersion), |
paul@0 | 5481 | - socketTimerInterval(30000) // By default timeouts on 30s |
paul@0 | 5482 | + q( session ), |
paul@0 | 5483 | + state( Session::Disconnected ), |
paul@0 | 5484 | + logger( 0 ), |
paul@0 | 5485 | + currentJob( 0 ), |
paul@0 | 5486 | + tagCount( 0 ), |
paul@0 | 5487 | + sslVersion( KTcpSocket::UnknownSslVersion ), |
paul@0 | 5488 | + socketTimerInterval( 30000 ) // By default timeouts on 30s |
paul@0 | 5489 | { |
paul@0 | 5490 | } |
paul@0 | 5491 | |
paul@0 | 5492 | @@ -140,20 +148,20 @@ SessionPrivate::~SessionPrivate() |
paul@0 | 5493 | |
paul@0 | 5494 | void SessionPrivate::addJob(Job *job) |
paul@0 | 5495 | { |
paul@0 | 5496 | - queue.append(job); |
paul@0 | 5497 | + queue.append( job ); |
paul@0 | 5498 | emit q->jobQueueSizeChanged( q->jobQueueSize() ); |
paul@0 | 5499 | |
paul@0 | 5500 | - QObject::connect( job, SIGNAL(result(KJob*)), q, SLOT(jobDone(KJob*)) ); |
paul@0 | 5501 | - QObject::connect( job, SIGNAL(destroyed(QObject*)), q, SLOT(jobDestroyed(QObject*)) ); |
paul@0 | 5502 | + QObject::connect( job, SIGNAL(result(KJob*)), this, SLOT(jobDone(KJob*)) ); |
paul@0 | 5503 | + QObject::connect( job, SIGNAL(destroyed(QObject*)), this, SLOT(jobDestroyed(QObject*)) ); |
paul@0 | 5504 | |
paul@0 | 5505 | - if ( state!=Session::Disconnected ) { |
paul@0 | 5506 | + if ( state != Session::Disconnected ) { |
paul@0 | 5507 | startNext(); |
paul@0 | 5508 | } |
paul@0 | 5509 | } |
paul@0 | 5510 | |
paul@0 | 5511 | void SessionPrivate::startNext() |
paul@0 | 5512 | { |
paul@0 | 5513 | - QTimer::singleShot( 0, q, SLOT(doStartNext()) ); |
paul@0 | 5514 | + QMetaObject::invokeMethod( this, "doStartNext" ); |
paul@0 | 5515 | } |
paul@0 | 5516 | |
paul@0 | 5517 | void SessionPrivate::doStartNext() |
paul@0 | 5518 | @@ -190,13 +198,14 @@ void SessionPrivate::jobDone( KJob *job ) |
paul@0 | 5519 | void SessionPrivate::jobDestroyed( QObject *job ) |
paul@0 | 5520 | { |
paul@0 | 5521 | queue.removeAll( static_cast<KIMAP::Job*>( job ) ); |
paul@0 | 5522 | - if ( currentJob == job ) |
paul@0 | 5523 | + if ( currentJob == job ) { |
paul@0 | 5524 | currentJob = 0; |
paul@0 | 5525 | + } |
paul@0 | 5526 | } |
paul@0 | 5527 | |
paul@0 | 5528 | void SessionPrivate::responseReceived( const Message &response ) |
paul@0 | 5529 | { |
paul@0 | 5530 | - if ( logger && ( state==Session::Authenticated || state==Session::Selected ) ) { |
paul@0 | 5531 | + if ( logger && ( state == Session::Authenticated || state == Session::Selected ) ) { |
paul@0 | 5532 | logger->dataReceived( response.toString() ); |
paul@0 | 5533 | } |
paul@0 | 5534 | |
paul@0 | 5535 | @@ -213,11 +222,11 @@ void SessionPrivate::responseReceived( const Message &response ) |
paul@0 | 5536 | |
paul@0 | 5537 | switch ( state ) { |
paul@0 | 5538 | case Session::Disconnected: |
paul@0 | 5539 | - if (socketTimer.isActive()) { |
paul@0 | 5540 | + if ( socketTimer.isActive() ) { |
paul@0 | 5541 | stopSocketTimer(); |
paul@0 | 5542 | } |
paul@0 | 5543 | - if ( code=="OK" ) { |
paul@0 | 5544 | - setState(Session::NotAuthenticated); |
paul@0 | 5545 | + if ( code == "OK" ) { |
paul@0 | 5546 | + setState( Session::NotAuthenticated ); |
paul@0 | 5547 | |
paul@0 | 5548 | Message simplified = response; |
paul@0 | 5549 | simplified.content.removeFirst(); // Strip the tag |
paul@0 | 5550 | @@ -225,8 +234,8 @@ void SessionPrivate::responseReceived( const Message &response ) |
paul@0 | 5551 | greeting = simplified.toString().trimmed(); // Save the server greeting |
paul@0 | 5552 | |
paul@0 | 5553 | startNext(); |
paul@0 | 5554 | - } else if ( code=="PREAUTH" ) { |
paul@0 | 5555 | - setState(Session::Authenticated); |
paul@0 | 5556 | + } else if ( code == "PREAUTH" ) { |
paul@0 | 5557 | + setState( Session::Authenticated ); |
paul@0 | 5558 | |
paul@0 | 5559 | Message simplified = response; |
paul@0 | 5560 | simplified.content.removeFirst(); // Strip the tag |
paul@0 | 5561 | @@ -239,74 +248,79 @@ void SessionPrivate::responseReceived( const Message &response ) |
paul@0 | 5562 | } |
paul@0 | 5563 | return; |
paul@0 | 5564 | case Session::NotAuthenticated: |
paul@0 | 5565 | - if ( code=="OK" && tag==authTag ) { |
paul@0 | 5566 | - setState(Session::Authenticated); |
paul@0 | 5567 | + if ( code == "OK" && tag == authTag ) { |
paul@0 | 5568 | + setState( Session::Authenticated ); |
paul@0 | 5569 | } |
paul@0 | 5570 | break; |
paul@0 | 5571 | case Session::Authenticated: |
paul@0 | 5572 | - if ( code=="OK" && tag==selectTag ) { |
paul@0 | 5573 | - setState(Session::Selected); |
paul@0 | 5574 | + if ( code == "OK" && tag == selectTag ) { |
paul@0 | 5575 | + setState( Session::Selected ); |
paul@0 | 5576 | currentMailBox = upcomingMailBox; |
paul@0 | 5577 | } |
paul@0 | 5578 | break; |
paul@0 | 5579 | case Session::Selected: |
paul@0 | 5580 | - if ( ( code=="OK" && tag==closeTag ) |
paul@0 | 5581 | - || ( code!="OK" && tag==selectTag) ) { |
paul@0 | 5582 | - setState(Session::Authenticated); |
paul@0 | 5583 | + if ( ( code == "OK" && tag == closeTag ) || |
paul@0 | 5584 | + ( code != "OK" && tag == selectTag ) ) { |
paul@0 | 5585 | + setState( Session::Authenticated ); |
paul@0 | 5586 | currentMailBox = QByteArray(); |
paul@0 | 5587 | - } else if ( code=="OK" && tag==selectTag ) { |
paul@0 | 5588 | + } else if ( code == "OK" && tag == selectTag ) { |
paul@0 | 5589 | currentMailBox = upcomingMailBox; |
paul@0 | 5590 | } |
paul@0 | 5591 | break; |
paul@0 | 5592 | } |
paul@0 | 5593 | |
paul@0 | 5594 | - if (tag==authTag) authTag.clear(); |
paul@0 | 5595 | - if (tag==selectTag) selectTag.clear(); |
paul@0 | 5596 | - if (tag==closeTag) closeTag.clear(); |
paul@0 | 5597 | + if ( tag == authTag ) { |
paul@0 | 5598 | + authTag.clear(); |
paul@0 | 5599 | + } |
paul@0 | 5600 | + if ( tag == selectTag ) { |
paul@0 | 5601 | + selectTag.clear(); |
paul@0 | 5602 | + } |
paul@0 | 5603 | + if ( tag == closeTag ) { |
paul@0 | 5604 | + closeTag.clear(); |
paul@0 | 5605 | + } |
paul@0 | 5606 | |
paul@0 | 5607 | // If a job is running forward it the response |
paul@0 | 5608 | - if ( currentJob!=0 ) { |
paul@0 | 5609 | + if ( currentJob != 0 ) { |
paul@0 | 5610 | restartSocketTimer(); |
paul@0 | 5611 | currentJob->handleResponse( response ); |
paul@0 | 5612 | } else { |
paul@0 | 5613 | qWarning() << "A message was received from the server with no job to handle it:" |
paul@0 | 5614 | << response.toString() |
paul@0 | 5615 | - << '('+response.toString().toHex()+')'; |
paul@0 | 5616 | + << '(' + response.toString().toHex() + ')'; |
paul@0 | 5617 | } |
paul@0 | 5618 | } |
paul@0 | 5619 | |
paul@0 | 5620 | void SessionPrivate::setState(Session::State s) |
paul@0 | 5621 | { |
paul@0 | 5622 | - if (s != state) { |
paul@0 | 5623 | + if ( s != state ) { |
paul@0 | 5624 | Session::State oldState = state; |
paul@0 | 5625 | state = s; |
paul@0 | 5626 | - emit q->stateChanged(state, oldState); |
paul@0 | 5627 | + emit q->stateChanged( state, oldState ); |
paul@0 | 5628 | } |
paul@0 | 5629 | } |
paul@0 | 5630 | |
paul@0 | 5631 | QByteArray SessionPrivate::sendCommand( const QByteArray &command, const QByteArray &args ) |
paul@0 | 5632 | { |
paul@0 | 5633 | - QByteArray tag = 'A' + QByteArray::number(++tagCount).rightJustified(6, '0'); |
paul@0 | 5634 | + QByteArray tag = 'A' + QByteArray::number( ++tagCount ).rightJustified( 6, '0' ); |
paul@0 | 5635 | |
paul@0 | 5636 | - QByteArray payload = tag+' '+command; |
paul@0 | 5637 | + QByteArray payload = tag + ' ' + command; |
paul@0 | 5638 | if ( !args.isEmpty() ) { |
paul@0 | 5639 | - payload+= ' '+args; |
paul@0 | 5640 | + payload += ' ' + args; |
paul@0 | 5641 | } |
paul@0 | 5642 | |
paul@0 | 5643 | sendData( payload ); |
paul@0 | 5644 | |
paul@0 | 5645 | - if ( command=="LOGIN" || command=="AUTHENTICATE" ) { |
paul@0 | 5646 | + if ( command == "LOGIN" || command == "AUTHENTICATE" ) { |
paul@0 | 5647 | authTag = tag; |
paul@0 | 5648 | - } else if ( command=="SELECT" || command=="EXAMINE" ) { |
paul@0 | 5649 | + } else if ( command == "SELECT" || command == "EXAMINE" ) { |
paul@0 | 5650 | selectTag = tag; |
paul@0 | 5651 | upcomingMailBox = args; |
paul@0 | 5652 | upcomingMailBox.remove( 0, 1 ); |
paul@0 | 5653 | upcomingMailBox.chop( 1 ); |
paul@0 | 5654 | upcomingMailBox = KIMAP::decodeImapFolderName( upcomingMailBox ); |
paul@0 | 5655 | - } else if ( command=="CLOSE" ) { |
paul@0 | 5656 | + } else if ( command == "CLOSE" ) { |
paul@0 | 5657 | closeTag = tag; |
paul@0 | 5658 | } |
paul@0 | 5659 | - |
paul@0 | 5660 | return tag; |
paul@0 | 5661 | } |
paul@0 | 5662 | |
paul@0 | 5663 | @@ -314,11 +328,11 @@ void SessionPrivate::sendData( const QByteArray &data ) |
paul@0 | 5664 | { |
paul@0 | 5665 | restartSocketTimer(); |
paul@0 | 5666 | |
paul@0 | 5667 | - if ( logger && ( state==Session::Authenticated || state==Session::Selected ) ) { |
paul@0 | 5668 | + if ( logger && ( state == Session::Authenticated || state == Session::Selected ) ) { |
paul@0 | 5669 | logger->dataSent( data ); |
paul@0 | 5670 | } |
paul@0 | 5671 | |
paul@0 | 5672 | - thread->sendData(data+"\r\n"); |
paul@0 | 5673 | + thread->sendData( data + "\r\n" ); |
paul@0 | 5674 | } |
paul@0 | 5675 | |
paul@0 | 5676 | void SessionPrivate::socketConnected() |
paul@0 | 5677 | @@ -330,10 +344,10 @@ void SessionPrivate::socketConnected() |
paul@0 | 5678 | if ( !queue.isEmpty() ) { |
paul@0 | 5679 | KIMAP::LoginJob *login = qobject_cast<KIMAP::LoginJob*>( queue.first() ); |
paul@0 | 5680 | if ( login ) { |
paul@0 | 5681 | - willUseSsl = ( login->encryptionMode() == KIMAP::LoginJob::SslV2 ) |
paul@0 | 5682 | - || ( login->encryptionMode() == KIMAP::LoginJob::SslV3 ) |
paul@0 | 5683 | - || ( login->encryptionMode() == KIMAP::LoginJob::SslV3_1 ) |
paul@0 | 5684 | - || ( login->encryptionMode() == KIMAP::LoginJob::AnySslVersion ); |
paul@0 | 5685 | + willUseSsl = ( login->encryptionMode() == KIMAP::LoginJob::SslV2 ) || |
paul@0 | 5686 | + ( login->encryptionMode() == KIMAP::LoginJob::SslV3 ) || |
paul@0 | 5687 | + ( login->encryptionMode() == KIMAP::LoginJob::SslV3_1 ) || |
paul@0 | 5688 | + ( login->encryptionMode() == KIMAP::LoginJob::AnySslVersion ); |
paul@0 | 5689 | |
paul@0 | 5690 | userName = login->userName(); |
paul@0 | 5691 | } |
paul@0 | 5692 | @@ -348,16 +362,16 @@ void SessionPrivate::socketConnected() |
paul@0 | 5693 | |
paul@0 | 5694 | void SessionPrivate::socketDisconnected() |
paul@0 | 5695 | { |
paul@0 | 5696 | - if (socketTimer.isActive()) { |
paul@0 | 5697 | + if ( socketTimer.isActive() ) { |
paul@0 | 5698 | stopSocketTimer(); |
paul@0 | 5699 | } |
paul@0 | 5700 | |
paul@0 | 5701 | - if ( logger && ( state==Session::Authenticated || state==Session::Selected ) ) { |
paul@0 | 5702 | + if ( logger && ( state == Session::Authenticated || state == Session::Selected ) ) { |
paul@0 | 5703 | logger->disconnectionOccured(); |
paul@0 | 5704 | } |
paul@0 | 5705 | |
paul@0 | 5706 | if ( state != Session::Disconnected ) { |
paul@0 | 5707 | - setState(Session::Disconnected); |
paul@0 | 5708 | + setState( Session::Disconnected ); |
paul@0 | 5709 | emit q->connectionLost(); |
paul@0 | 5710 | } else { |
paul@0 | 5711 | emit q->connectionFailed(); |
paul@0 | 5712 | @@ -375,7 +389,7 @@ void SessionPrivate::socketActivity() |
paul@0 | 5713 | |
paul@0 | 5714 | void SessionPrivate::socketError() |
paul@0 | 5715 | { |
paul@0 | 5716 | - if (socketTimer.isActive()) { |
paul@0 | 5717 | + if ( socketTimer.isActive() ) { |
paul@0 | 5718 | stopSocketTimer(); |
paul@0 | 5719 | } |
paul@0 | 5720 | |
paul@0 | 5721 | @@ -397,14 +411,15 @@ void SessionPrivate::clearJobQueue() |
paul@0 | 5722 | currentJob->connectionLost(); |
paul@0 | 5723 | } |
paul@0 | 5724 | |
paul@0 | 5725 | - qDeleteAll(queue); |
paul@0 | 5726 | + QQueue<Job*> queueCopy = queue; // copy because jobDestroyed calls removeAll |
paul@0 | 5727 | + qDeleteAll(queueCopy); |
paul@0 | 5728 | queue.clear(); |
paul@0 | 5729 | emit q->jobQueueSizeChanged( 0 ); |
paul@0 | 5730 | } |
paul@0 | 5731 | |
paul@0 | 5732 | void SessionPrivate::startSsl(const KTcpSocket::SslVersion &version) |
paul@0 | 5733 | { |
paul@0 | 5734 | - QMetaObject::invokeMethod( thread, "startSsl", Qt::QueuedConnection, Q_ARG(KTcpSocket::SslVersion, version) ); |
paul@0 | 5735 | + thread->startSsl( version ); |
paul@0 | 5736 | } |
paul@0 | 5737 | |
paul@0 | 5738 | QString Session::selectedMailBox() const |
paul@0 | 5739 | @@ -449,7 +464,7 @@ int SessionPrivate::socketTimeout() const |
paul@0 | 5740 | |
paul@0 | 5741 | void SessionPrivate::startSocketTimer() |
paul@0 | 5742 | { |
paul@0 | 5743 | - if ( socketTimerInterval<0 ) { |
paul@0 | 5744 | + if ( socketTimerInterval < 0 ) { |
paul@0 | 5745 | return; |
paul@0 | 5746 | } |
paul@0 | 5747 | Q_ASSERT( !socketTimer.isActive() ); |
paul@0 | 5748 | @@ -463,7 +478,7 @@ void SessionPrivate::startSocketTimer() |
paul@0 | 5749 | |
paul@0 | 5750 | void SessionPrivate::stopSocketTimer() |
paul@0 | 5751 | { |
paul@0 | 5752 | - if ( socketTimerInterval<0 ) { |
paul@0 | 5753 | + if ( socketTimerInterval < 0 ) { |
paul@0 | 5754 | return; |
paul@0 | 5755 | } |
paul@0 | 5756 | |
paul@0 | 5757 | @@ -483,7 +498,7 @@ void SessionPrivate::restartSocketTimer() |
paul@0 | 5758 | |
paul@0 | 5759 | void SessionPrivate::onSocketTimeout() |
paul@0 | 5760 | { |
paul@0 | 5761 | - qDebug() << "Socket timeout!"; |
paul@0 | 5762 | + kDebug() << "Socket timeout!"; |
paul@0 | 5763 | thread->closeSocket(); |
paul@0 | 5764 | } |
paul@0 | 5765 | |
paul@0 | 5766 | @@ -494,3 +509,4 @@ void Session::setTimeout( int timeout ) |
paul@0 | 5767 | |
paul@0 | 5768 | #include "session.moc" |
paul@0 | 5769 | #include "session_p.moc" |
paul@0 | 5770 | + |
paul@0 | 5771 | diff --git a/kimap/session.h b/kimap/session.h |
paul@0 | 5772 | index e23fbc4..b745246 100644 |
paul@0 | 5773 | --- a/kimap/session.h |
paul@0 | 5774 | +++ b/kimap/session.h |
paul@0 | 5775 | @@ -37,7 +37,7 @@ struct Message; |
paul@0 | 5776 | class KIMAP_EXPORT Session : public QObject |
paul@0 | 5777 | { |
paul@0 | 5778 | Q_OBJECT |
paul@0 | 5779 | - Q_ENUMS(State) |
paul@0 | 5780 | + Q_ENUMS( State ) |
paul@0 | 5781 | |
paul@0 | 5782 | friend class JobPrivate; |
paul@0 | 5783 | |
paul@0 | 5784 | @@ -135,18 +135,6 @@ class KIMAP_EXPORT Session : public QObject |
paul@0 | 5785 | void stateChanged(KIMAP::Session::State newState, KIMAP::Session::State oldState); |
paul@0 | 5786 | |
paul@0 | 5787 | private: |
paul@0 | 5788 | - Q_PRIVATE_SLOT( d, void doStartNext() ) |
paul@0 | 5789 | - Q_PRIVATE_SLOT( d, void jobDone( KJob* ) ) |
paul@0 | 5790 | - Q_PRIVATE_SLOT( d, void jobDestroyed( QObject* ) ) |
paul@0 | 5791 | - Q_PRIVATE_SLOT( d, void responseReceived( const KIMAP::Message& ) ) |
paul@0 | 5792 | - |
paul@0 | 5793 | - Q_PRIVATE_SLOT( d, void socketConnected() ) |
paul@0 | 5794 | - Q_PRIVATE_SLOT( d, void socketDisconnected() ) |
paul@0 | 5795 | - Q_PRIVATE_SLOT( d, void socketError() ) |
paul@0 | 5796 | - Q_PRIVATE_SLOT( d, void socketActivity() ) |
paul@0 | 5797 | - |
paul@0 | 5798 | - Q_PRIVATE_SLOT( d, void handleSslError( const KSslErrorUiData &errorData ) ) |
paul@0 | 5799 | - |
paul@0 | 5800 | friend class SessionPrivate; |
paul@0 | 5801 | SessionPrivate *const d; |
paul@0 | 5802 | }; |
paul@0 | 5803 | diff --git a/kimap/session_p.h b/kimap/session_p.h |
paul@0 | 5804 | index 37bfd57..fd5101b 100644 |
paul@0 | 5805 | --- a/kimap/session_p.h |
paul@0 | 5806 | +++ b/kimap/session_p.h |
paul@0 | 5807 | @@ -46,7 +46,7 @@ class KIMAP_EXPORT SessionPrivate : public QObject |
paul@0 | 5808 | friend class Session; |
paul@0 | 5809 | |
paul@0 | 5810 | public: |
paul@0 | 5811 | - SessionPrivate( Session *session ); |
paul@0 | 5812 | + explicit SessionPrivate( Session *session ); |
paul@0 | 5813 | virtual ~SessionPrivate(); |
paul@0 | 5814 | |
paul@0 | 5815 | void addJob(Job *job); |
paul@0 | 5816 | @@ -54,8 +54,6 @@ class KIMAP_EXPORT SessionPrivate : public QObject |
paul@0 | 5817 | void startSsl(const KTcpSocket::SslVersion &version); |
paul@0 | 5818 | void sendData( const QByteArray &data ); |
paul@0 | 5819 | |
paul@0 | 5820 | - void handleSslError( const KSslErrorUiData &errorData ); |
paul@0 | 5821 | - |
paul@0 | 5822 | KTcpSocket::SslVersion negotiatedEncryption() const; |
paul@0 | 5823 | |
paul@0 | 5824 | void setSocketTimeout( int ms ); |
paul@0 | 5825 | @@ -68,20 +66,23 @@ class KIMAP_EXPORT SessionPrivate : public QObject |
paul@0 | 5826 | void onEncryptionNegotiationResult(bool isEncrypted, KTcpSocket::SslVersion sslVersion); |
paul@0 | 5827 | void onSocketTimeout(); |
paul@0 | 5828 | |
paul@0 | 5829 | - private: |
paul@0 | 5830 | - void startNext(); |
paul@0 | 5831 | void doStartNext(); |
paul@0 | 5832 | - void jobDone( KJob *job ); |
paul@0 | 5833 | - void jobDestroyed( QObject *job ); |
paul@0 | 5834 | - void clearJobQueue(); |
paul@0 | 5835 | - void responseReceived( const KIMAP::Message &response ); |
paul@0 | 5836 | - void setState(Session::State state); |
paul@0 | 5837 | + void jobDone( KJob* ); |
paul@0 | 5838 | + void jobDestroyed( QObject* ); |
paul@0 | 5839 | + void responseReceived( const KIMAP::Message& ); |
paul@0 | 5840 | |
paul@0 | 5841 | void socketConnected(); |
paul@0 | 5842 | void socketDisconnected(); |
paul@0 | 5843 | void socketError(); |
paul@0 | 5844 | void socketActivity(); |
paul@0 | 5845 | |
paul@0 | 5846 | + void handleSslError( const KSslErrorUiData &errorData ); |
paul@0 | 5847 | + |
paul@0 | 5848 | + private: |
paul@0 | 5849 | + void startNext(); |
paul@0 | 5850 | + void clearJobQueue(); |
paul@0 | 5851 | + void setState(Session::State state); |
paul@0 | 5852 | + |
paul@0 | 5853 | void startSocketTimer(); |
paul@0 | 5854 | void stopSocketTimer(); |
paul@0 | 5855 | void restartSocketTimer(); |
paul@0 | 5856 | diff --git a/kimap/sessionlogger.cpp b/kimap/sessionlogger.cpp |
paul@0 | 5857 | index 715a5da..2c4bd07 100644 |
paul@0 | 5858 | --- a/kimap/sessionlogger.cpp |
paul@0 | 5859 | +++ b/kimap/sessionlogger.cpp |
paul@0 | 5860 | @@ -20,6 +20,8 @@ |
paul@0 | 5861 | |
paul@0 | 5862 | #include "sessionlogger_p.h" |
paul@0 | 5863 | |
paul@0 | 5864 | +#include <KDebug> |
paul@0 | 5865 | + |
paul@0 | 5866 | #include <unistd.h> |
paul@0 | 5867 | |
paul@0 | 5868 | using namespace KIMAP; |
paul@0 | 5869 | @@ -33,7 +35,9 @@ SessionLogger::SessionLogger() |
paul@0 | 5870 | m_file.setFileName( qgetenv( "KIMAP_LOGFILE" ) |
paul@0 | 5871 | + '.' + QString::number( getpid() ) |
paul@0 | 5872 | + '.' + QString::number( m_id ) ); |
paul@0 | 5873 | - m_file.open( QFile::WriteOnly ); |
paul@0 | 5874 | + if (!m_file.open( QFile::WriteOnly )) { |
paul@0 | 5875 | + kDebug()<<" m_file can be open in write only"; |
paul@0 | 5876 | + } |
paul@0 | 5877 | } |
paul@0 | 5878 | |
paul@0 | 5879 | SessionLogger::~SessionLogger() |
paul@0 | 5880 | @@ -57,6 +61,3 @@ void SessionLogger::disconnectionOccured() |
paul@0 | 5881 | { |
paul@0 | 5882 | m_file.write( "X\n" ); |
paul@0 | 5883 | } |
paul@0 | 5884 | - |
paul@0 | 5885 | - |
paul@0 | 5886 | - |
paul@0 | 5887 | diff --git a/kimap/sessionthread.cpp b/kimap/sessionthread.cpp |
paul@0 | 5888 | index b7a1cb9..36e2c83 100644 |
paul@0 | 5889 | --- a/kimap/sessionthread.cpp |
paul@0 | 5890 | +++ b/kimap/sessionthread.cpp |
paul@0 | 5891 | @@ -20,65 +20,73 @@ |
paul@0 | 5892 | #include "sessionthread_p.h" |
paul@0 | 5893 | |
paul@0 | 5894 | #include <QtCore/QDebug> |
paul@0 | 5895 | -#include <QtCore/QTimer> |
paul@0 | 5896 | +#include <QtCore/QThread> |
paul@0 | 5897 | |
paul@0 | 5898 | -#include <kdebug.h> |
paul@0 | 5899 | +#include <KDE/KDebug> |
paul@0 | 5900 | |
paul@0 | 5901 | #include "imapstreamparser.h" |
paul@0 | 5902 | #include "message_p.h" |
paul@0 | 5903 | -#include "session.h" |
paul@0 | 5904 | |
paul@0 | 5905 | using namespace KIMAP; |
paul@0 | 5906 | |
paul@0 | 5907 | -Q_DECLARE_METATYPE(KTcpSocket::Error) |
paul@0 | 5908 | -Q_DECLARE_METATYPE(KSslErrorUiData) |
paul@0 | 5909 | +Q_DECLARE_METATYPE( KTcpSocket::Error ) |
paul@0 | 5910 | +Q_DECLARE_METATYPE( KSslErrorUiData ) |
paul@0 | 5911 | static const int _kimap_socketErrorTypeId = qRegisterMetaType<KTcpSocket::Error>(); |
paul@0 | 5912 | static const int _kimap_sslErrorUiData = qRegisterMetaType<KSslErrorUiData>(); |
paul@0 | 5913 | |
paul@0 | 5914 | -SessionThread::SessionThread( const QString &hostName, quint16 port, Session *parent ) |
paul@0 | 5915 | - : QThread(), m_hostName(hostName), m_port(port), |
paul@0 | 5916 | - m_session(parent), m_socket(0), m_stream(0), m_encryptedMode(false) |
paul@0 | 5917 | +SessionThread::SessionThread( const QString &hostName, quint16 port ) |
paul@0 | 5918 | + : QObject(), m_hostName( hostName ), m_port( port ), |
paul@0 | 5919 | + m_socket( 0 ), m_stream( 0 ), m_mutex(), |
paul@0 | 5920 | + m_encryptedMode( false ), |
paul@0 | 5921 | + triedSslVersions( 0 ), doSslFallback( false ) |
paul@0 | 5922 | { |
paul@0 | 5923 | - // Yeah, sounds weird, but QThread object is linked to the parent |
paul@0 | 5924 | - // thread not to itself, and I'm too lazy to introduce yet another |
paul@0 | 5925 | - // internal QObject |
paul@0 | 5926 | - moveToThread(this); |
paul@0 | 5927 | + // Just like the Qt docs now recommend, for event-driven threads: |
paul@0 | 5928 | + // don't derive from QThread, create one directly and move the object to it. |
paul@0 | 5929 | + QThread* thread = new QThread(); |
paul@0 | 5930 | + moveToThread( thread ); |
paul@0 | 5931 | + thread->start(); |
paul@0 | 5932 | + QMetaObject::invokeMethod( this, "threadInit" ); |
paul@0 | 5933 | } |
paul@0 | 5934 | |
paul@0 | 5935 | SessionThread::~SessionThread() |
paul@0 | 5936 | { |
paul@0 | 5937 | - // don't call quit() directly, this will deadlock in wait() if exec() hasn't run yet |
paul@0 | 5938 | - QMetaObject::invokeMethod( this, "quit" ); |
paul@0 | 5939 | - if ( !wait( 10 * 1000 ) ) { |
paul@0 | 5940 | + QMetaObject::invokeMethod( this, "threadQuit" ); |
paul@0 | 5941 | + if ( !thread()->wait( 10 * 1000 ) ) { |
paul@0 | 5942 | kWarning() << "Session thread refuses to die, killing harder..."; |
paul@0 | 5943 | - terminate(); |
paul@0 | 5944 | + thread()->terminate(); |
paul@0 | 5945 | // Make sure to wait until it's done, otherwise it can crash when the pthread callback is called |
paul@0 | 5946 | - wait(); |
paul@0 | 5947 | + thread()->wait(); |
paul@0 | 5948 | } |
paul@0 | 5949 | + delete thread(); |
paul@0 | 5950 | } |
paul@0 | 5951 | |
paul@0 | 5952 | +// Called in primary thread |
paul@0 | 5953 | void SessionThread::sendData( const QByteArray &payload ) |
paul@0 | 5954 | { |
paul@0 | 5955 | - QMutexLocker locker(&m_mutex); |
paul@0 | 5956 | + QMutexLocker locker( &m_mutex ); |
paul@0 | 5957 | |
paul@0 | 5958 | m_dataQueue.enqueue( payload ); |
paul@0 | 5959 | - QTimer::singleShot( 0, this, SLOT(writeDataQueue()) ); |
paul@0 | 5960 | + QMetaObject::invokeMethod( this, "writeDataQueue" ); |
paul@0 | 5961 | } |
paul@0 | 5962 | |
paul@0 | 5963 | +// Called in secondary thread |
paul@0 | 5964 | void SessionThread::writeDataQueue() |
paul@0 | 5965 | { |
paul@0 | 5966 | - QMutexLocker locker(&m_mutex); |
paul@0 | 5967 | + Q_ASSERT( QThread::currentThread() == thread() ); |
paul@0 | 5968 | + if ( !m_socket ) |
paul@0 | 5969 | + return; |
paul@0 | 5970 | + QMutexLocker locker( &m_mutex ); |
paul@0 | 5971 | |
paul@0 | 5972 | while ( !m_dataQueue.isEmpty() ) { |
paul@0 | 5973 | m_socket->write( m_dataQueue.dequeue() ); |
paul@0 | 5974 | } |
paul@0 | 5975 | } |
paul@0 | 5976 | |
paul@0 | 5977 | +// Called in secondary thread |
paul@0 | 5978 | void SessionThread::readMessage() |
paul@0 | 5979 | { |
paul@0 | 5980 | - QMutexLocker locker(&m_mutex); |
paul@0 | 5981 | - |
paul@0 | 5982 | - if ( m_stream->availableDataSize()==0 ) { |
paul@0 | 5983 | + Q_ASSERT( QThread::currentThread() == thread() ); |
paul@0 | 5984 | + if ( !m_stream || m_stream->availableDataSize() == 0 ) { |
paul@0 | 5985 | return; |
paul@0 | 5986 | } |
paul@0 | 5987 | |
paul@0 | 5988 | @@ -92,10 +100,10 @@ void SessionThread::readMessage() |
paul@0 | 5989 | if ( string == "NIL" ) { |
paul@0 | 5990 | *payload << Message::Part( QList<QByteArray>() ); |
paul@0 | 5991 | } else { |
paul@0 | 5992 | - *payload << Message::Part(string); |
paul@0 | 5993 | + *payload << Message::Part( string ); |
paul@0 | 5994 | } |
paul@0 | 5995 | } else if ( m_stream->hasList() ) { |
paul@0 | 5996 | - *payload << Message::Part(m_stream->readParenthesizedList()); |
paul@0 | 5997 | + *payload << Message::Part( m_stream->readParenthesizedList() ); |
paul@0 | 5998 | } else if ( m_stream->hasResponseCode() ) { |
paul@0 | 5999 | payload = &message.responseCode; |
paul@0 | 6000 | } else if ( m_stream->atResponseCodeEnd() ) { |
paul@0 | 6001 | @@ -103,128 +111,213 @@ void SessionThread::readMessage() |
paul@0 | 6002 | } else if ( m_stream->hasLiteral() ) { |
paul@0 | 6003 | QByteArray literal; |
paul@0 | 6004 | while ( !m_stream->atLiteralEnd() ) { |
paul@0 | 6005 | - literal+= m_stream->readLiteralPart(); |
paul@0 | 6006 | + literal += m_stream->readLiteralPart(); |
paul@0 | 6007 | } |
paul@0 | 6008 | - *payload << Message::Part(literal); |
paul@0 | 6009 | + *payload << Message::Part( literal ); |
paul@0 | 6010 | } else { |
paul@0 | 6011 | - // Oops! Something really bad happened |
paul@0 | 6012 | - throw ImapParserException( "Inconsistent state, probably due to some packet loss" ); |
paul@0 | 6013 | + // Oops! Something really bad happened, we won't be able to recover |
paul@0 | 6014 | + // so close the socket immediately |
paul@0 | 6015 | + qWarning( "Inconsistent state, probably due to some packet loss" ); |
paul@0 | 6016 | + doCloseSocket(); |
paul@0 | 6017 | + return; |
paul@0 | 6018 | } |
paul@0 | 6019 | } |
paul@0 | 6020 | |
paul@0 | 6021 | - emit responseReceived(message); |
paul@0 | 6022 | + emit responseReceived( message ); |
paul@0 | 6023 | |
paul@0 | 6024 | - } catch (KIMAP::ImapParserException e) { |
paul@0 | 6025 | + } catch ( KIMAP::ImapParserException e ) { |
paul@0 | 6026 | qWarning() << "The stream parser raised an exception:" << e.what(); |
paul@0 | 6027 | } |
paul@0 | 6028 | |
paul@0 | 6029 | - if ( m_stream->availableDataSize()>1 ) { |
paul@0 | 6030 | - QTimer::singleShot( 0, this, SLOT(readMessage()) ); |
paul@0 | 6031 | + if ( m_stream->availableDataSize() > 1 ) { |
paul@0 | 6032 | + QMetaObject::invokeMethod( this, "readMessage", Qt::QueuedConnection ); |
paul@0 | 6033 | } |
paul@0 | 6034 | |
paul@0 | 6035 | } |
paul@0 | 6036 | |
paul@0 | 6037 | +// Called in main thread |
paul@0 | 6038 | void SessionThread::closeSocket() |
paul@0 | 6039 | { |
paul@0 | 6040 | - QTimer::singleShot( 0, this, SLOT(doCloseSocket()) ); |
paul@0 | 6041 | + QMetaObject::invokeMethod( this, "doCloseSocket", Qt::QueuedConnection ); |
paul@0 | 6042 | } |
paul@0 | 6043 | |
paul@0 | 6044 | +// Called in secondary thread |
paul@0 | 6045 | void SessionThread::doCloseSocket() |
paul@0 | 6046 | { |
paul@0 | 6047 | + Q_ASSERT( QThread::currentThread() == thread() ); |
paul@0 | 6048 | + if ( !m_socket ) |
paul@0 | 6049 | + return; |
paul@0 | 6050 | m_encryptedMode = false; |
paul@0 | 6051 | + kDebug() << "close"; |
paul@0 | 6052 | m_socket->close(); |
paul@0 | 6053 | } |
paul@0 | 6054 | |
paul@0 | 6055 | +// Called in secondary thread |
paul@0 | 6056 | void SessionThread::reconnect() |
paul@0 | 6057 | { |
paul@0 | 6058 | - QMutexLocker locker(&m_mutex); |
paul@0 | 6059 | - |
paul@0 | 6060 | + Q_ASSERT( QThread::currentThread() == thread() ); |
paul@0 | 6061 | + if ( m_socket == 0 ) // threadQuit already called |
paul@0 | 6062 | + return; |
paul@0 | 6063 | if ( m_socket->state() != SessionSocket::ConnectedState && |
paul@0 | 6064 | m_socket->state() != SessionSocket::ConnectingState ) { |
paul@0 | 6065 | - if (m_encryptedMode) { |
paul@0 | 6066 | - m_socket->connectToHostEncrypted(m_hostName, m_port); |
paul@0 | 6067 | + if ( m_encryptedMode ) { |
paul@0 | 6068 | + kDebug() << "connectToHostEncrypted" << m_hostName << m_port; |
paul@0 | 6069 | + m_socket->connectToHostEncrypted( m_hostName, m_port ); |
paul@0 | 6070 | } else { |
paul@0 | 6071 | - m_socket->connectToHost(m_hostName, m_port); |
paul@0 | 6072 | + kDebug() << "connectToHost" << m_hostName << m_port; |
paul@0 | 6073 | + m_socket->connectToHost( m_hostName, m_port ); |
paul@0 | 6074 | } |
paul@0 | 6075 | } |
paul@0 | 6076 | } |
paul@0 | 6077 | |
paul@0 | 6078 | -void SessionThread::run() |
paul@0 | 6079 | +// Called in secondary thread |
paul@0 | 6080 | +void SessionThread::threadInit() |
paul@0 | 6081 | { |
paul@0 | 6082 | + Q_ASSERT( QThread::currentThread() == thread() ); |
paul@0 | 6083 | m_socket = new SessionSocket; |
paul@0 | 6084 | m_stream = new ImapStreamParser( m_socket ); |
paul@0 | 6085 | connect( m_socket, SIGNAL(readyRead()), |
paul@0 | 6086 | this, SLOT(readMessage()), Qt::QueuedConnection ); |
paul@0 | 6087 | |
paul@0 | 6088 | + // Delay the call to slotSocketDisconnected so that it finishes disconnecting before we call reconnect() |
paul@0 | 6089 | connect( m_socket, SIGNAL(disconnected()), |
paul@0 | 6090 | - m_session, SLOT(socketDisconnected()) ); |
paul@0 | 6091 | + this, SLOT(slotSocketDisconnected()), Qt::QueuedConnection ); |
paul@0 | 6092 | connect( m_socket, SIGNAL(connected()), |
paul@0 | 6093 | - m_session, SLOT(socketConnected()) ); |
paul@0 | 6094 | + this, SIGNAL(socketConnected()) ); |
paul@0 | 6095 | connect( m_socket, SIGNAL(error(KTcpSocket::Error)), |
paul@0 | 6096 | - m_session, SLOT(socketError()) ); |
paul@0 | 6097 | + this, SLOT(socketError(KTcpSocket::Error)) ); |
paul@0 | 6098 | connect( m_socket, SIGNAL(bytesWritten(qint64)), |
paul@0 | 6099 | - m_session, SLOT(socketActivity()) ); |
paul@0 | 6100 | - if ( m_socket->metaObject()->indexOfSignal("encryptedBytesWritten(qint64)" ) > -1 ) { |
paul@0 | 6101 | + this, SIGNAL(socketActivity()) ); |
paul@0 | 6102 | + if ( m_socket->metaObject()->indexOfSignal( "encryptedBytesWritten(qint64)" ) > -1 ) { |
paul@0 | 6103 | connect( m_socket, SIGNAL(encryptedBytesWritten(qint64)), // needs kdelibs > 4.8 |
paul@0 | 6104 | - m_session, SLOT(socketActivity()) ); |
paul@0 | 6105 | + this, SIGNAL(socketActivity()) ); |
paul@0 | 6106 | } |
paul@0 | 6107 | connect( m_socket, SIGNAL(readyRead()), |
paul@0 | 6108 | - m_session, SLOT(socketActivity()) ); |
paul@0 | 6109 | - |
paul@0 | 6110 | - connect( this, SIGNAL(responseReceived(KIMAP::Message)), |
paul@0 | 6111 | - m_session, SLOT(responseReceived(KIMAP::Message)) ); |
paul@0 | 6112 | + this, SIGNAL(socketActivity()) ); |
paul@0 | 6113 | |
paul@0 | 6114 | - QTimer::singleShot( 0, this, SLOT(reconnect()) ); |
paul@0 | 6115 | - exec(); |
paul@0 | 6116 | + QMetaObject::invokeMethod(this, "reconnect", Qt::QueuedConnection); |
paul@0 | 6117 | +} |
paul@0 | 6118 | |
paul@0 | 6119 | +// Called in secondary thread |
paul@0 | 6120 | +void SessionThread::threadQuit() |
paul@0 | 6121 | +{ |
paul@0 | 6122 | + Q_ASSERT( QThread::currentThread() == thread() ); |
paul@0 | 6123 | delete m_stream; |
paul@0 | 6124 | + m_stream = 0; |
paul@0 | 6125 | delete m_socket; |
paul@0 | 6126 | + m_socket = 0; |
paul@0 | 6127 | + thread()->quit(); |
paul@0 | 6128 | } |
paul@0 | 6129 | |
paul@0 | 6130 | -void SessionThread::startSsl(const KTcpSocket::SslVersion &version) |
paul@0 | 6131 | +// Called in primary thread |
paul@0 | 6132 | +void SessionThread::startSsl( KTcpSocket::SslVersion version ) |
paul@0 | 6133 | { |
paul@0 | 6134 | - QMutexLocker locker(&m_mutex); |
paul@0 | 6135 | + QMetaObject::invokeMethod( this, "doStartSsl", Q_ARG(KTcpSocket::SslVersion, version) ); |
paul@0 | 6136 | +} |
paul@0 | 6137 | + |
paul@0 | 6138 | +// Called in secondary thread (via invokeMethod) |
paul@0 | 6139 | +void SessionThread::doStartSsl( KTcpSocket::SslVersion version ) |
paul@0 | 6140 | +{ |
paul@0 | 6141 | + Q_ASSERT( QThread::currentThread() == thread() ); |
paul@0 | 6142 | + if ( !m_socket ) |
paul@0 | 6143 | + return; |
paul@0 | 6144 | + if ( version == KTcpSocket::AnySslVersion ) { |
paul@0 | 6145 | + doSslFallback = true; |
paul@0 | 6146 | + if ( m_socket->advertisedSslVersion() == KTcpSocket::UnknownSslVersion ) { |
paul@0 | 6147 | + m_socket->setAdvertisedSslVersion( KTcpSocket::AnySslVersion ); |
paul@0 | 6148 | + } else if ( !( triedSslVersions & KTcpSocket::TlsV1 ) ) { |
paul@0 | 6149 | + triedSslVersions |= KTcpSocket::TlsV1; |
paul@0 | 6150 | + m_socket->setAdvertisedSslVersion( KTcpSocket::TlsV1 ); |
paul@0 | 6151 | + } else if ( !( triedSslVersions & KTcpSocket::SslV3 ) ) { |
paul@0 | 6152 | + triedSslVersions |= KTcpSocket::SslV3; |
paul@0 | 6153 | + m_socket->setAdvertisedSslVersion( KTcpSocket::SslV3 ); |
paul@0 | 6154 | + } else if ( !( triedSslVersions & KTcpSocket::SslV2 ) ) { |
paul@0 | 6155 | + triedSslVersions |= KTcpSocket::SslV2; |
paul@0 | 6156 | + m_socket->setAdvertisedSslVersion( KTcpSocket::SslV2 ); |
paul@0 | 6157 | + doSslFallback = false; |
paul@0 | 6158 | + } |
paul@0 | 6159 | + } else { |
paul@0 | 6160 | + m_socket->setAdvertisedSslVersion( version ); |
paul@0 | 6161 | + } |
paul@0 | 6162 | |
paul@0 | 6163 | - m_socket->setAdvertisedSslVersion(version); |
paul@0 | 6164 | m_socket->ignoreSslErrors(); |
paul@0 | 6165 | - connect(m_socket, SIGNAL(encrypted()), this, SLOT(sslConnected())); |
paul@0 | 6166 | + connect( m_socket, SIGNAL(encrypted()), this, SLOT(sslConnected()) ); |
paul@0 | 6167 | m_socket->startClientEncryption(); |
paul@0 | 6168 | } |
paul@0 | 6169 | |
paul@0 | 6170 | +// Called in secondary thread |
paul@0 | 6171 | +void SessionThread::slotSocketDisconnected() |
paul@0 | 6172 | +{ |
paul@0 | 6173 | + Q_ASSERT( QThread::currentThread() == thread() ); |
paul@0 | 6174 | + if ( doSslFallback ) { |
paul@0 | 6175 | + reconnect(); |
paul@0 | 6176 | + } else { |
paul@0 | 6177 | + emit socketDisconnected(); |
paul@0 | 6178 | + } |
paul@0 | 6179 | +} |
paul@0 | 6180 | + |
paul@0 | 6181 | +// Called in secondary thread |
paul@0 | 6182 | +void SessionThread::socketError(KTcpSocket::Error error) |
paul@0 | 6183 | +{ |
paul@0 | 6184 | + Q_ASSERT( QThread::currentThread() == thread() ); |
paul@0 | 6185 | + if ( !m_socket ) |
paul@0 | 6186 | + return; |
paul@0 | 6187 | + Q_UNUSED( error ); // can be used for debugging |
paul@0 | 6188 | + if ( doSslFallback ) { |
paul@0 | 6189 | + //do not call m_socket->disconnectFromHost() here, as that can trigger an error again (resulting in an endless loop). |
paul@0 | 6190 | + m_socket->abort(); |
paul@0 | 6191 | + } else { |
paul@0 | 6192 | + emit socketError(); |
paul@0 | 6193 | + } |
paul@0 | 6194 | +} |
paul@0 | 6195 | + |
paul@0 | 6196 | +// Called in secondary thread |
paul@0 | 6197 | void SessionThread::sslConnected() |
paul@0 | 6198 | { |
paul@0 | 6199 | - QMutexLocker locker(&m_mutex); |
paul@0 | 6200 | + Q_ASSERT( QThread::currentThread() == thread() ); |
paul@0 | 6201 | + if ( !m_socket ) |
paul@0 | 6202 | + return; |
paul@0 | 6203 | KSslCipher cipher = m_socket->sessionCipher(); |
paul@0 | 6204 | |
paul@0 | 6205 | - if ( m_socket->sslErrors().count() > 0 || m_socket->encryptionMode() != KTcpSocket::SslClientMode |
paul@0 | 6206 | - || cipher.isNull() || cipher.usedBits() == 0) { |
paul@0 | 6207 | - qDebug() << "Initial SSL handshake failed. cipher.isNull() is" << cipher.isNull() |
paul@0 | 6208 | - << ", cipher.usedBits() is" << cipher.usedBits() |
paul@0 | 6209 | - << ", the socket says:" << m_socket->errorString() |
paul@0 | 6210 | - << "and the list of SSL errors contains" |
paul@0 | 6211 | - << m_socket->sslErrors().count() << "items."; |
paul@0 | 6212 | - KSslErrorUiData errorData(m_socket); |
paul@0 | 6213 | - emit sslError(errorData); |
paul@0 | 6214 | + if ( m_socket->sslErrors().count() > 0 || |
paul@0 | 6215 | + m_socket->encryptionMode() != KTcpSocket::SslClientMode || |
paul@0 | 6216 | + cipher.isNull() || cipher.usedBits() == 0 ) { |
paul@0 | 6217 | + kDebug() << "Initial SSL handshake failed. cipher.isNull() is" << cipher.isNull() |
paul@0 | 6218 | + << ", cipher.usedBits() is" << cipher.usedBits() |
paul@0 | 6219 | + << ", the socket says:" << m_socket->errorString() |
paul@0 | 6220 | + << "and the list of SSL errors contains" |
paul@0 | 6221 | + << m_socket->sslErrors().count() << "items."; |
paul@0 | 6222 | + KSslErrorUiData errorData( m_socket ); |
paul@0 | 6223 | + emit sslError( errorData ); |
paul@0 | 6224 | } else { |
paul@0 | 6225 | - qDebug() << "TLS negotiation done."; |
paul@0 | 6226 | + doSslFallback = false; |
paul@0 | 6227 | + kDebug() << "TLS negotiation done."; |
paul@0 | 6228 | m_encryptedMode = true; |
paul@0 | 6229 | - emit encryptionNegotiationResult(true, m_socket->negotiatedSslVersion()); |
paul@0 | 6230 | + emit encryptionNegotiationResult( true, m_socket->negotiatedSslVersion() ); |
paul@0 | 6231 | } |
paul@0 | 6232 | } |
paul@0 | 6233 | |
paul@0 | 6234 | void SessionThread::sslErrorHandlerResponse(bool response) |
paul@0 | 6235 | { |
paul@0 | 6236 | - QMutexLocker locker(&m_mutex); |
paul@0 | 6237 | - if (response) { |
paul@0 | 6238 | + QMetaObject::invokeMethod(this, "doSslErrorHandlerResponse", Q_ARG(bool, response)); |
paul@0 | 6239 | +} |
paul@0 | 6240 | + |
paul@0 | 6241 | +// Called in secondary thread (via invokeMethod) |
paul@0 | 6242 | +void SessionThread::doSslErrorHandlerResponse(bool response) |
paul@0 | 6243 | +{ |
paul@0 | 6244 | + Q_ASSERT( QThread::currentThread() == thread() ); |
paul@0 | 6245 | + if ( !m_socket ) |
paul@0 | 6246 | + return; |
paul@0 | 6247 | + if ( response ) { |
paul@0 | 6248 | m_encryptedMode = true; |
paul@0 | 6249 | - emit encryptionNegotiationResult(true, m_socket->negotiatedSslVersion()); |
paul@0 | 6250 | + emit encryptionNegotiationResult( true, m_socket->negotiatedSslVersion() ); |
paul@0 | 6251 | } else { |
paul@0 | 6252 | m_encryptedMode = false; |
paul@0 | 6253 | //reconnect in unencrypted mode, so new commands can be issued |
paul@0 | 6254 | m_socket->disconnectFromHost(); |
paul@0 | 6255 | m_socket->waitForDisconnected(); |
paul@0 | 6256 | - m_socket->connectToHost(m_hostName, m_port); |
paul@0 | 6257 | - emit encryptionNegotiationResult(false, KTcpSocket::UnknownSslVersion); |
paul@0 | 6258 | + m_socket->connectToHost( m_hostName, m_port ); |
paul@0 | 6259 | + emit encryptionNegotiationResult( false, KTcpSocket::UnknownSslVersion ); |
paul@0 | 6260 | } |
paul@0 | 6261 | } |
paul@0 | 6262 | |
paul@0 | 6263 | diff --git a/kimap/sessionthread_p.h b/kimap/sessionthread_p.h |
paul@0 | 6264 | index 672c418..47a94fb 100644 |
paul@0 | 6265 | --- a/kimap/sessionthread_p.h |
paul@0 | 6266 | +++ b/kimap/sessionthread_p.h |
paul@0 | 6267 | @@ -22,7 +22,6 @@ |
paul@0 | 6268 | |
paul@0 | 6269 | #include <QtCore/QMutex> |
paul@0 | 6270 | #include <QtCore/QQueue> |
paul@0 | 6271 | -#include <QtCore/QThread> |
paul@0 | 6272 | |
paul@0 | 6273 | #include <ktcpsocket.h> |
paul@0 | 6274 | |
paul@0 | 6275 | @@ -32,52 +31,62 @@ namespace KIMAP { |
paul@0 | 6276 | |
paul@0 | 6277 | class ImapStreamParser; |
paul@0 | 6278 | struct Message; |
paul@0 | 6279 | -class Session; |
paul@0 | 6280 | |
paul@0 | 6281 | -class SessionThread : public QThread |
paul@0 | 6282 | +class SessionThread : public QObject |
paul@0 | 6283 | { |
paul@0 | 6284 | Q_OBJECT |
paul@0 | 6285 | |
paul@0 | 6286 | public: |
paul@0 | 6287 | - explicit SessionThread( const QString &hostName, quint16 port, Session *parent ); |
paul@0 | 6288 | + explicit SessionThread( const QString &hostName, quint16 port ); |
paul@0 | 6289 | ~SessionThread(); |
paul@0 | 6290 | |
paul@0 | 6291 | inline QString hostName() { return m_hostName; } |
paul@0 | 6292 | inline quint16 port() { return m_port; } |
paul@0 | 6293 | |
paul@0 | 6294 | void sendData( const QByteArray &payload ); |
paul@0 | 6295 | - void run(); |
paul@0 | 6296 | |
paul@0 | 6297 | public slots: |
paul@0 | 6298 | void closeSocket(); |
paul@0 | 6299 | - void reconnect(); |
paul@0 | 6300 | - void startSsl(const KTcpSocket::SslVersion &version); |
paul@0 | 6301 | + void startSsl(KTcpSocket::SslVersion version); |
paul@0 | 6302 | + void sslErrorHandlerResponse(bool result); |
paul@0 | 6303 | |
paul@0 | 6304 | signals: |
paul@0 | 6305 | + void socketConnected(); |
paul@0 | 6306 | + void socketDisconnected(); |
paul@0 | 6307 | + void socketActivity(); |
paul@0 | 6308 | + void socketError(); |
paul@0 | 6309 | void responseReceived(const KIMAP::Message &response); |
paul@0 | 6310 | void encryptionNegotiationResult(bool, KTcpSocket::SslVersion); |
paul@0 | 6311 | void sslError(const KSslErrorUiData&); |
paul@0 | 6312 | |
paul@0 | 6313 | private slots: |
paul@0 | 6314 | + void reconnect(); |
paul@0 | 6315 | + void threadInit(); |
paul@0 | 6316 | + void threadQuit(); |
paul@0 | 6317 | void readMessage(); |
paul@0 | 6318 | void writeDataQueue(); |
paul@0 | 6319 | void sslConnected(); |
paul@0 | 6320 | - void sslErrorHandlerResponse(bool result); |
paul@0 | 6321 | void doCloseSocket(); |
paul@0 | 6322 | + void socketError(KTcpSocket::Error); |
paul@0 | 6323 | + void slotSocketDisconnected(); |
paul@0 | 6324 | + void doStartSsl(KTcpSocket::SslVersion); |
paul@0 | 6325 | + void doSslErrorHandlerResponse(bool result); |
paul@0 | 6326 | |
paul@0 | 6327 | private: |
paul@0 | 6328 | QString m_hostName; |
paul@0 | 6329 | quint16 m_port; |
paul@0 | 6330 | |
paul@0 | 6331 | - Session *m_session; |
paul@0 | 6332 | SessionSocket *m_socket; |
paul@0 | 6333 | ImapStreamParser *m_stream; |
paul@0 | 6334 | |
paul@0 | 6335 | QQueue<QByteArray> m_dataQueue; |
paul@0 | 6336 | |
paul@0 | 6337 | + // Protects m_dataQueue |
paul@0 | 6338 | QMutex m_mutex; |
paul@0 | 6339 | |
paul@0 | 6340 | bool m_encryptedMode; |
paul@0 | 6341 | + KTcpSocket::SslVersions triedSslVersions; |
paul@0 | 6342 | + bool doSslFallback; |
paul@0 | 6343 | }; |
paul@0 | 6344 | |
paul@0 | 6345 | } |
paul@0 | 6346 | diff --git a/kimap/setacljob.cpp b/kimap/setacljob.cpp |
paul@0 | 6347 | index dea3d81..bb3841d 100644 |
paul@0 | 6348 | --- a/kimap/setacljob.cpp |
paul@0 | 6349 | +++ b/kimap/setacljob.cpp |
paul@0 | 6350 | @@ -19,8 +19,8 @@ |
paul@0 | 6351 | |
paul@0 | 6352 | #include "setacljob.h" |
paul@0 | 6353 | |
paul@0 | 6354 | -#include <klocale.h> |
paul@0 | 6355 | -#include <kdebug.h> |
paul@0 | 6356 | +#include <KDE/KLocalizedString> |
paul@0 | 6357 | +#include <KDE/KDebug> |
paul@0 | 6358 | |
paul@0 | 6359 | #include "acljobbase_p.h" |
paul@0 | 6360 | #include "message_p.h" |
paul@0 | 6361 | @@ -32,7 +32,7 @@ namespace KIMAP |
paul@0 | 6362 | class SetAclJobPrivate : public AclJobBasePrivate |
paul@0 | 6363 | { |
paul@0 | 6364 | public: |
paul@0 | 6365 | - SetAclJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate(session, name) {} |
paul@0 | 6366 | + SetAclJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate( session, name ) {} |
paul@0 | 6367 | ~SetAclJobPrivate() { } |
paul@0 | 6368 | }; |
paul@0 | 6369 | } |
paul@0 | 6370 | @@ -40,9 +40,8 @@ namespace KIMAP |
paul@0 | 6371 | using namespace KIMAP; |
paul@0 | 6372 | |
paul@0 | 6373 | SetAclJob::SetAclJob( Session *session ) |
paul@0 | 6374 | - : AclJobBase(*new SetAclJobPrivate(session, i18n("SetAcl"))) |
paul@0 | 6375 | + : AclJobBase( *new SetAclJobPrivate( session, i18n( "SetAcl" ) ) ) |
paul@0 | 6376 | { |
paul@0 | 6377 | - |
paul@0 | 6378 | } |
paul@0 | 6379 | |
paul@0 | 6380 | SetAclJob::~SetAclJob() |
paul@0 | 6381 | @@ -51,32 +50,33 @@ SetAclJob::~SetAclJob() |
paul@0 | 6382 | |
paul@0 | 6383 | void SetAclJob::doStart() |
paul@0 | 6384 | { |
paul@0 | 6385 | - Q_D(SetAclJob); |
paul@0 | 6386 | + Q_D( SetAclJob ); |
paul@0 | 6387 | QByteArray r = Acl::rightsToString( d->rightList ); |
paul@0 | 6388 | - if (d->modifier == Add) { |
paul@0 | 6389 | - r.prepend('+'); |
paul@0 | 6390 | - } else if (d->modifier == Remove) { |
paul@0 | 6391 | - r.prepend('-'); |
paul@0 | 6392 | + if ( d->modifier == Add ) { |
paul@0 | 6393 | + r.prepend( '+' ); |
paul@0 | 6394 | + } else if ( d->modifier == Remove ) { |
paul@0 | 6395 | + r.prepend( '-' ); |
paul@0 | 6396 | } |
paul@0 | 6397 | - d->tags << d->sessionInternal()->sendCommand( "SETACL", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + "\" \"" + d->id + "\" \"" + r +'\"'); |
paul@0 | 6398 | + d->tags << d->sessionInternal()->sendCommand( "SETACL", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + "\" \"" + d->id + "\" \"" + r + '\"' ); |
paul@0 | 6399 | } |
paul@0 | 6400 | |
paul@0 | 6401 | void SetAclJob::setRights(AclModifier modifier, Acl::Rights rights) |
paul@0 | 6402 | { |
paul@0 | 6403 | - Q_D(SetAclJob); |
paul@0 | 6404 | - d->setRights(modifier, rights); |
paul@0 | 6405 | + Q_D( SetAclJob ); |
paul@0 | 6406 | + d->setRights( modifier, rights ); |
paul@0 | 6407 | } |
paul@0 | 6408 | |
paul@0 | 6409 | void SetAclJob::setIdentifier( const QByteArray &identifier ) |
paul@0 | 6410 | { |
paul@0 | 6411 | - Q_D(SetAclJob); |
paul@0 | 6412 | - d->setIdentifier(identifier); |
paul@0 | 6413 | + Q_D( SetAclJob ); |
paul@0 | 6414 | + d->setIdentifier( identifier ); |
paul@0 | 6415 | } |
paul@0 | 6416 | |
paul@0 | 6417 | QByteArray SetAclJob::identifier() |
paul@0 | 6418 | { |
paul@0 | 6419 | - Q_D(SetAclJob); |
paul@0 | 6420 | + Q_D( SetAclJob ); |
paul@0 | 6421 | return d->identifier(); |
paul@0 | 6422 | } |
paul@0 | 6423 | |
paul@0 | 6424 | #include "setacljob.moc" |
paul@0 | 6425 | + |
paul@0 | 6426 | diff --git a/kimap/setacljob.h b/kimap/setacljob.h |
paul@0 | 6427 | index 33df18d..c2496c3 100644 |
paul@0 | 6428 | --- a/kimap/setacljob.h |
paul@0 | 6429 | +++ b/kimap/setacljob.h |
paul@0 | 6430 | @@ -30,7 +30,6 @@ class Session; |
paul@0 | 6431 | struct Message; |
paul@0 | 6432 | class SetAclJobPrivate; |
paul@0 | 6433 | |
paul@0 | 6434 | - |
paul@0 | 6435 | /** |
paul@0 | 6436 | * Sets the rights that correspond to an identifier on a mailbox |
paul@0 | 6437 | * |
paul@0 | 6438 | @@ -44,7 +43,7 @@ class SetAclJobPrivate; |
paul@0 | 6439 | class KIMAP_EXPORT SetAclJob : public AclJobBase |
paul@0 | 6440 | { |
paul@0 | 6441 | Q_OBJECT |
paul@0 | 6442 | - Q_DECLARE_PRIVATE(SetAclJob) |
paul@0 | 6443 | + Q_DECLARE_PRIVATE( SetAclJob ) |
paul@0 | 6444 | |
paul@0 | 6445 | friend class SessionPrivate; |
paul@0 | 6446 | |
paul@0 | 6447 | @@ -96,6 +95,7 @@ class KIMAP_EXPORT SetAclJob : public AclJobBase |
paul@0 | 6448 | * Note that negative rights override positive rights: if |
paul@0 | 6449 | * "fred" and "-fred" are both assigned the 'w' right, the |
paul@0 | 6450 | * user "fred" will not have the 'w' right. |
paul@0 | 6451 | + * @param identifier the identifier to set |
paul@0 | 6452 | */ |
paul@0 | 6453 | void setIdentifier( const QByteArray &identifier ); |
paul@0 | 6454 | /** |
paul@0 | 6455 | diff --git a/kimap/setmetadatajob.cpp b/kimap/setmetadatajob.cpp |
paul@0 | 6456 | index c279812..80e46f9 100644 |
paul@0 | 6457 | --- a/kimap/setmetadatajob.cpp |
paul@0 | 6458 | +++ b/kimap/setmetadatajob.cpp |
paul@0 | 6459 | @@ -19,8 +19,8 @@ |
paul@0 | 6460 | |
paul@0 | 6461 | #include "setmetadatajob.h" |
paul@0 | 6462 | |
paul@0 | 6463 | -#include <klocale.h> |
paul@0 | 6464 | -#include <kdebug.h> |
paul@0 | 6465 | +#include <KDE/KLocalizedString> |
paul@0 | 6466 | +#include <KDE/KDebug> |
paul@0 | 6467 | |
paul@0 | 6468 | #include "metadatajobbase_p.h" |
paul@0 | 6469 | #include "message_p.h" |
paul@0 | 6470 | @@ -32,7 +32,7 @@ namespace KIMAP |
paul@0 | 6471 | class SetMetaDataJobPrivate : public MetaDataJobBasePrivate |
paul@0 | 6472 | { |
paul@0 | 6473 | public: |
paul@0 | 6474 | - SetMetaDataJobPrivate( Session *session, const QString& name ) : MetaDataJobBasePrivate(session, name), metaDataErrors(0), maxAcceptedSize(-1) { } |
paul@0 | 6475 | + SetMetaDataJobPrivate( Session *session, const QString& name ) : MetaDataJobBasePrivate( session, name ), metaDataErrors( 0 ), maxAcceptedSize( -1 ) { } |
paul@0 | 6476 | ~SetMetaDataJobPrivate() { } |
paul@0 | 6477 | |
paul@0 | 6478 | QMap<QByteArray, QByteArray> entries; |
paul@0 | 6479 | @@ -46,7 +46,7 @@ namespace KIMAP |
paul@0 | 6480 | using namespace KIMAP; |
paul@0 | 6481 | |
paul@0 | 6482 | SetMetaDataJob::SetMetaDataJob( Session *session ) |
paul@0 | 6483 | - : MetaDataJobBase( *new SetMetaDataJobPrivate(session, i18n("SetMetaData")) ) |
paul@0 | 6484 | + : MetaDataJobBase( *new SetMetaDataJobPrivate( session, i18n( "SetMetaData" ) ) ) |
paul@0 | 6485 | { |
paul@0 | 6486 | } |
paul@0 | 6487 | |
paul@0 | 6488 | @@ -56,99 +56,102 @@ SetMetaDataJob::~SetMetaDataJob() |
paul@0 | 6489 | |
paul@0 | 6490 | void SetMetaDataJob::doStart() |
paul@0 | 6491 | { |
paul@0 | 6492 | - Q_D(SetMetaDataJob); |
paul@0 | 6493 | + Q_D( SetMetaDataJob ); |
paul@0 | 6494 | QByteArray parameters; |
paul@0 | 6495 | parameters = '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + "\" "; |
paul@0 | 6496 | d->entriesIt = d->entries.constBegin(); |
paul@0 | 6497 | |
paul@0 | 6498 | QByteArray command = "SETMETADATA"; |
paul@0 | 6499 | - if (d->serverCapability == Annotatemore) { |
paul@0 | 6500 | + if ( d->serverCapability == Annotatemore ) { |
paul@0 | 6501 | command = "SETANNOTATION"; |
paul@0 | 6502 | parameters += '\"' + d->entryName + "\" ("; |
paul@0 | 6503 | - d->m_name = i18n("SetAnnotation"); |
paul@0 | 6504 | - if (!d->entries.isEmpty()) { |
paul@0 | 6505 | - for (; d->entriesIt != d->entries.constEnd(); ++d->entriesIt) { |
paul@0 | 6506 | - parameters += '\"' + d->entriesIt.key() + "\" \"" + d->entriesIt.value() + "\" "; |
paul@0 | 6507 | + d->m_name = i18n( "SetAnnotation" ); |
paul@0 | 6508 | + if ( !d->entries.isEmpty() ) { |
paul@0 | 6509 | + for ( ; d->entriesIt != d->entries.constEnd(); ++d->entriesIt ) { |
paul@0 | 6510 | + parameters += '\"' + d->entriesIt.key() + "\" \"" + d->entriesIt.value() + "\" "; |
paul@0 | 6511 | } |
paul@0 | 6512 | parameters[parameters.length() - 1] = ')'; |
paul@0 | 6513 | } |
paul@0 | 6514 | } else { |
paul@0 | 6515 | parameters += '('; |
paul@0 | 6516 | - if (!d->entries.isEmpty()) { |
paul@0 | 6517 | + if ( !d->entries.isEmpty() ) { |
paul@0 | 6518 | parameters += '\"' + d->entriesIt.key() + '\"'; |
paul@0 | 6519 | parameters += ' '; |
paul@0 | 6520 | - parameters +=" {" + QByteArray::number(d->entriesIt.value().size()) + '}'; |
paul@0 | 6521 | + parameters += " {" + QByteArray::number( d->entriesIt.value().size() ) + '}'; |
paul@0 | 6522 | } |
paul@0 | 6523 | } |
paul@0 | 6524 | |
paul@0 | 6525 | - if (d->entries.isEmpty()) { |
paul@0 | 6526 | + if ( d->entries.isEmpty() ) { |
paul@0 | 6527 | parameters += ')'; |
paul@0 | 6528 | } |
paul@0 | 6529 | |
paul@0 | 6530 | d->tags << d->sessionInternal()->sendCommand( command, parameters ); |
paul@0 | 6531 | -// qDebug() << "SENT: " << command << " " << parameters; |
paul@0 | 6532 | +// kDebug() << "SENT: " << command << " " << parameters; |
paul@0 | 6533 | } |
paul@0 | 6534 | |
paul@0 | 6535 | void SetMetaDataJob::handleResponse( const Message &response ) |
paul@0 | 6536 | { |
paul@0 | 6537 | - Q_D(SetMetaDataJob); |
paul@0 | 6538 | + Q_D( SetMetaDataJob ); |
paul@0 | 6539 | |
paul@0 | 6540 | //TODO: Test if a server can really return more then one untagged NO response. If not, no need to OR the error codes |
paul@0 | 6541 | - if ( !response.content.isEmpty() |
paul@0 | 6542 | - && d->tags.contains( response.content.first().toString() ) ) { |
paul@0 | 6543 | + if ( !response.content.isEmpty() && |
paul@0 | 6544 | + d->tags.contains( response.content.first().toString() ) ) { |
paul@0 | 6545 | if ( response.content[1].toString() == "NO" ) { |
paul@0 | 6546 | setError( UserDefinedError ); |
paul@0 | 6547 | - setErrorText( i18n("%1 failed, server replied: %2", d->m_name, response.toString().constData()) ); |
paul@0 | 6548 | - if (response.content[2].toString() == "[ANNOTATEMORE TOOMANY]" || response.content[2].toString() == "[METADATA TOOMANY]") { |
paul@0 | 6549 | + setErrorText( i18n( "%1 failed, server replied: %2", d->m_name, response.toString().constData() ) ); |
paul@0 | 6550 | + if ( response.content[2].toString() == "[ANNOTATEMORE TOOMANY]" || |
paul@0 | 6551 | + response.content[2].toString() == "[METADATA TOOMANY]" ) { |
paul@0 | 6552 | d->metaDataErrors |= TooMany; |
paul@0 | 6553 | - } else if (response.content[2].toString() == "[ANNOTATEMORE TOOBIG]" || response.content[2].toString().startsWith("[METADATA MAXSIZE")) { |
paul@0 | 6554 | + } else if ( response.content[2].toString() == "[ANNOTATEMORE TOOBIG]" || |
paul@0 | 6555 | + response.content[2].toString().startsWith( "[METADATA MAXSIZE" ) ) { //krazy:exclude=strings |
paul@0 | 6556 | d->metaDataErrors |= TooBig; |
paul@0 | 6557 | d->maxAcceptedSize = -1; |
paul@0 | 6558 | - if (response.content[2].toString().startsWith("[METADATA MAXSIZE")) { //krazy:exclude=strings |
paul@0 | 6559 | + if ( response.content[2].toString().startsWith( "[METADATA MAXSIZE" ) ) { //krazy:exclude=strings |
paul@0 | 6560 | QByteArray max = response.content[2].toString(); |
paul@0 | 6561 | - max.replace("[METADATA MAXSIZE",""); //krazy:exclude=doublequote_chars |
paul@0 | 6562 | - max.replace("]", ""); //krazy:exclude=doublequote_chars |
paul@0 | 6563 | + max.replace( "[METADATA MAXSIZE", "" ); //krazy:exclude=doublequote_chars |
paul@0 | 6564 | + max.replace( "]", "" ); //krazy:exclude=doublequote_chars |
paul@0 | 6565 | d->maxAcceptedSize = max.toLongLong(); |
paul@0 | 6566 | } |
paul@0 | 6567 | - } else if (response.content[2].toString() == "[METADATA NOPRIVATE]") { |
paul@0 | 6568 | + } else if ( response.content[2].toString() == "[METADATA NOPRIVATE]" ) { |
paul@0 | 6569 | d->metaDataErrors |= NoPrivate; |
paul@0 | 6570 | } |
paul@0 | 6571 | } else if ( response.content.size() < 2 ) { |
paul@0 | 6572 | - setErrorText( i18n("%1 failed, malformed reply from the server.", d->m_name) ); |
paul@0 | 6573 | + setErrorText( i18n( "%1 failed, malformed reply from the server.", d->m_name ) ); |
paul@0 | 6574 | } else if ( response.content[1].toString() != "OK" ) { |
paul@0 | 6575 | setError( UserDefinedError ); |
paul@0 | 6576 | - setErrorText( i18n("%1 failed, server replied: %2", d->m_name, response.toString().constData()) ); |
paul@0 | 6577 | + setErrorText( i18n( "%1 failed, server replied: %2", d->m_name, response.toString().constData() ) ); |
paul@0 | 6578 | } |
paul@0 | 6579 | emitResult(); |
paul@0 | 6580 | } else if ( d->serverCapability == Metadata && response.content[0].toString() == "+" ) { |
paul@0 | 6581 | QByteArray content = d->entriesIt.value(); |
paul@0 | 6582 | ++d->entriesIt; |
paul@0 | 6583 | - if (d->entriesIt == d->entries.constEnd()) { |
paul@0 | 6584 | + if ( d->entriesIt == d->entries.constEnd() ) { |
paul@0 | 6585 | content += ')'; |
paul@0 | 6586 | } else { |
paul@0 | 6587 | - content +=" {" + QByteArray::number(d->entriesIt.value().size()) + '}'; |
paul@0 | 6588 | + content += " {" + QByteArray::number( d->entriesIt.value().size() ) + '}'; |
paul@0 | 6589 | } |
paul@0 | 6590 | -// qDebug() << "SENT: " << content; |
paul@0 | 6591 | +// kDebug() << "SENT: " << content; |
paul@0 | 6592 | d->sessionInternal()->sendData( content ); |
paul@0 | 6593 | } |
paul@0 | 6594 | } |
paul@0 | 6595 | |
paul@0 | 6596 | void SetMetaDataJob::addMetaData(const QByteArray &name, const QByteArray &value) |
paul@0 | 6597 | { |
paul@0 | 6598 | - Q_D(SetMetaDataJob); |
paul@0 | 6599 | + Q_D( SetMetaDataJob ); |
paul@0 | 6600 | d->entries[name] = value; |
paul@0 | 6601 | } |
paul@0 | 6602 | |
paul@0 | 6603 | void SetMetaDataJob::setEntry(const QByteArray &entry) |
paul@0 | 6604 | { |
paul@0 | 6605 | - Q_D(SetMetaDataJob); |
paul@0 | 6606 | + Q_D( SetMetaDataJob ); |
paul@0 | 6607 | d->entryName = entry; |
paul@0 | 6608 | } |
paul@0 | 6609 | |
paul@0 | 6610 | SetMetaDataJob::MetaDataErrors SetMetaDataJob::metaDataErrors() const |
paul@0 | 6611 | { |
paul@0 | 6612 | - Q_D(const SetMetaDataJob); |
paul@0 | 6613 | + Q_D( const SetMetaDataJob ); |
paul@0 | 6614 | return d->metaDataErrors; |
paul@0 | 6615 | } |
paul@0 | 6616 | |
paul@0 | 6617 | #include "setmetadatajob.moc" |
paul@0 | 6618 | + |
paul@0 | 6619 | diff --git a/kimap/setmetadatajob.h b/kimap/setmetadatajob.h |
paul@0 | 6620 | index 1391ecc..3736539 100644 |
paul@0 | 6621 | --- a/kimap/setmetadatajob.h |
paul@0 | 6622 | +++ b/kimap/setmetadatajob.h |
paul@0 | 6623 | @@ -68,7 +68,7 @@ class SetMetaDataJobPrivate; |
paul@0 | 6624 | class KIMAP_EXPORT SetMetaDataJob : public MetaDataJobBase |
paul@0 | 6625 | { |
paul@0 | 6626 | Q_OBJECT |
paul@0 | 6627 | - Q_DECLARE_PRIVATE(SetMetaDataJob) |
paul@0 | 6628 | + Q_DECLARE_PRIVATE( SetMetaDataJob ) |
paul@0 | 6629 | |
paul@0 | 6630 | friend class SessionPrivate; |
paul@0 | 6631 | |
paul@0 | 6632 | @@ -184,7 +184,7 @@ class KIMAP_EXPORT SetMetaDataJob : public MetaDataJobBase |
paul@0 | 6633 | }; |
paul@0 | 6634 | |
paul@0 | 6635 | // Q_DECLARE_WHATEVER_THAT_WAS missing |
paul@0 | 6636 | - Q_DECLARE_FLAGS(MetaDataErrors, MetaDataError) |
paul@0 | 6637 | + Q_DECLARE_FLAGS( MetaDataErrors, MetaDataError ) |
paul@0 | 6638 | |
paul@0 | 6639 | /** |
paul@0 | 6640 | * The metadata errors received from the server. |
paul@0 | 6641 | diff --git a/kimap/setquotajob.cpp b/kimap/setquotajob.cpp |
paul@0 | 6642 | index 9dedddd..347aeee 100644 |
paul@0 | 6643 | --- a/kimap/setquotajob.cpp |
paul@0 | 6644 | +++ b/kimap/setquotajob.cpp |
paul@0 | 6645 | @@ -19,8 +19,8 @@ |
paul@0 | 6646 | |
paul@0 | 6647 | #include "setquotajob.h" |
paul@0 | 6648 | |
paul@0 | 6649 | -#include <klocale.h> |
paul@0 | 6650 | -#include <kdebug.h> |
paul@0 | 6651 | +#include <KDE/KLocalizedString> |
paul@0 | 6652 | +#include <KDE/KDebug> |
paul@0 | 6653 | |
paul@0 | 6654 | #include "quotajobbase_p.h" |
paul@0 | 6655 | #include "message_p.h" |
paul@0 | 6656 | @@ -31,7 +31,7 @@ namespace KIMAP |
paul@0 | 6657 | class SetQuotaJobPrivate : public QuotaJobBasePrivate |
paul@0 | 6658 | { |
paul@0 | 6659 | public: |
paul@0 | 6660 | - SetQuotaJobPrivate( Session *session, const QString& name ) : QuotaJobBasePrivate(session, name) { } |
paul@0 | 6661 | + SetQuotaJobPrivate( Session *session, const QString& name ) : QuotaJobBasePrivate( session, name ) { } |
paul@0 | 6662 | ~SetQuotaJobPrivate() { } |
paul@0 | 6663 | |
paul@0 | 6664 | QMap<QByteArray, qint64> setList; |
paul@0 | 6665 | @@ -42,7 +42,7 @@ namespace KIMAP |
paul@0 | 6666 | using namespace KIMAP; |
paul@0 | 6667 | |
paul@0 | 6668 | SetQuotaJob::SetQuotaJob( Session *session ) |
paul@0 | 6669 | - : QuotaJobBase( *new SetQuotaJobPrivate(session, i18n("SetQuota")) ) |
paul@0 | 6670 | + : QuotaJobBase( *new SetQuotaJobPrivate( session, i18n( "SetQuota" ) ) ) |
paul@0 | 6671 | { |
paul@0 | 6672 | } |
paul@0 | 6673 | |
paul@0 | 6674 | @@ -52,54 +52,54 @@ SetQuotaJob::~SetQuotaJob() |
paul@0 | 6675 | |
paul@0 | 6676 | void SetQuotaJob::doStart() |
paul@0 | 6677 | { |
paul@0 | 6678 | - Q_D(SetQuotaJob); |
paul@0 | 6679 | + Q_D( SetQuotaJob ); |
paul@0 | 6680 | QByteArray s; |
paul@0 | 6681 | s += '('; |
paul@0 | 6682 | - for (QMap<QByteArray, qint64>::ConstIterator it = d->setList.constBegin(); it != d->setList.constEnd(); ++it ) { |
paul@0 | 6683 | - s += it.key() + ' ' + QByteArray::number(it.value()) + ' '; |
paul@0 | 6684 | + for ( QMap<QByteArray, qint64>::ConstIterator it = d->setList.constBegin(); it != d->setList.constEnd(); ++it ) { |
paul@0 | 6685 | + s += it.key() + ' ' + QByteArray::number( it.value() ) + ' '; |
paul@0 | 6686 | } |
paul@0 | 6687 | - if (d->setList.isEmpty()) { |
paul@0 | 6688 | + if ( d->setList.isEmpty() ) { |
paul@0 | 6689 | s += ')'; |
paul@0 | 6690 | } else { |
paul@0 | 6691 | s[s.length() - 1] = ')'; |
paul@0 | 6692 | } |
paul@0 | 6693 | |
paul@0 | 6694 | - qDebug() << "SETQUOTA " << '\"' + d->root + "\" " + s; |
paul@0 | 6695 | + kDebug() << "SETQUOTA " << '\"' + d->root + "\" " + s; |
paul@0 | 6696 | //XXX: [alexmerry, 2010-07-24]: should d->root be quoted properly? |
paul@0 | 6697 | - d->tags << d->sessionInternal()->sendCommand( "SETQUOTA", '\"' + d->root + "\" " + s); |
paul@0 | 6698 | + d->tags << d->sessionInternal()->sendCommand( "SETQUOTA", '\"' + d->root + "\" " + s ); |
paul@0 | 6699 | } |
paul@0 | 6700 | |
paul@0 | 6701 | void SetQuotaJob::handleResponse(const Message &response) |
paul@0 | 6702 | { |
paul@0 | 6703 | - Q_D(SetQuotaJob); |
paul@0 | 6704 | - if (handleErrorReplies(response) == NotHandled) { |
paul@0 | 6705 | - if ( response.content.size() >= 4 |
paul@0 | 6706 | - && response.content[1].toString() == "QUOTA" ) { |
paul@0 | 6707 | - d->quota = d->readQuota(response.content[3]); |
paul@0 | 6708 | + Q_D( SetQuotaJob ); |
paul@0 | 6709 | + if ( handleErrorReplies( response ) == NotHandled ) { |
paul@0 | 6710 | + if ( response.content.size() >= 4 && |
paul@0 | 6711 | + response.content[1].toString() == "QUOTA" ) { |
paul@0 | 6712 | + d->quota = d->readQuota( response.content[3] ); |
paul@0 | 6713 | } |
paul@0 | 6714 | } |
paul@0 | 6715 | } |
paul@0 | 6716 | |
paul@0 | 6717 | - |
paul@0 | 6718 | void SetQuotaJob::setQuota(const QByteArray &resource, qint64 limit) |
paul@0 | 6719 | { |
paul@0 | 6720 | - Q_D(SetQuotaJob); |
paul@0 | 6721 | + Q_D( SetQuotaJob ); |
paul@0 | 6722 | |
paul@0 | 6723 | d->setList[resource.toUpper()] = limit; |
paul@0 | 6724 | } |
paul@0 | 6725 | |
paul@0 | 6726 | void SetQuotaJob::setRoot(const QByteArray& root) |
paul@0 | 6727 | { |
paul@0 | 6728 | - Q_D(SetQuotaJob); |
paul@0 | 6729 | + Q_D( SetQuotaJob ); |
paul@0 | 6730 | |
paul@0 | 6731 | d->root = root; |
paul@0 | 6732 | } |
paul@0 | 6733 | |
paul@0 | 6734 | QByteArray SetQuotaJob::root() const |
paul@0 | 6735 | { |
paul@0 | 6736 | - Q_D(const SetQuotaJob); |
paul@0 | 6737 | + Q_D( const SetQuotaJob ); |
paul@0 | 6738 | |
paul@0 | 6739 | return d->root; |
paul@0 | 6740 | } |
paul@0 | 6741 | |
paul@0 | 6742 | #include "setquotajob.moc" |
paul@0 | 6743 | + |
paul@0 | 6744 | diff --git a/kimap/setquotajob.h b/kimap/setquotajob.h |
paul@0 | 6745 | index f3fac37..ff21a29 100644 |
paul@0 | 6746 | --- a/kimap/setquotajob.h |
paul@0 | 6747 | +++ b/kimap/setquotajob.h |
paul@0 | 6748 | @@ -84,6 +84,7 @@ class KIMAP_EXPORT SetQuotaJob : public QuotaJobBase |
paul@0 | 6749 | * may create it and change the quota roots for any number of |
paul@0 | 6750 | * existing mailboxes in an implementation-defined manner. |
paul@0 | 6751 | * |
paul@0 | 6752 | + * @param root the quota root to set, in bytes |
paul@0 | 6753 | * @see GetQuotaRootJob |
paul@0 | 6754 | */ |
paul@0 | 6755 | void setRoot( const QByteArray &root ); |
paul@0 | 6756 | diff --git a/kimap/storejob.cpp b/kimap/storejob.cpp |
paul@0 | 6757 | index cf70503..0118000 100644 |
paul@0 | 6758 | --- a/kimap/storejob.cpp |
paul@0 | 6759 | +++ b/kimap/storejob.cpp |
paul@0 | 6760 | @@ -19,8 +19,8 @@ |
paul@0 | 6761 | |
paul@0 | 6762 | #include "storejob.h" |
paul@0 | 6763 | |
paul@0 | 6764 | -#include <kdebug.h> |
paul@0 | 6765 | -#include <klocale.h> |
paul@0 | 6766 | +#include <KDE/KDebug> |
paul@0 | 6767 | +#include <KDE/KLocalizedString> |
paul@0 | 6768 | |
paul@0 | 6769 | #include "job_p.h" |
paul@0 | 6770 | #include "message_p.h" |
paul@0 | 6771 | @@ -46,9 +46,9 @@ namespace KIMAP |
paul@0 | 6772 | using namespace KIMAP; |
paul@0 | 6773 | |
paul@0 | 6774 | StoreJob::StoreJob( Session *session ) |
paul@0 | 6775 | - : Job( *new StoreJobPrivate(session, i18n("Store")) ) |
paul@0 | 6776 | + : Job( *new StoreJobPrivate( session, i18n( "Store" ) ) ) |
paul@0 | 6777 | { |
paul@0 | 6778 | - Q_D(StoreJob); |
paul@0 | 6779 | + Q_D( StoreJob ); |
paul@0 | 6780 | d->uidBased = false; |
paul@0 | 6781 | d->mode = SetFlags; |
paul@0 | 6782 | } |
paul@0 | 6783 | @@ -59,84 +59,86 @@ StoreJob::~StoreJob() |
paul@0 | 6784 | |
paul@0 | 6785 | void StoreJob::setSequenceSet( const ImapSet &set ) |
paul@0 | 6786 | { |
paul@0 | 6787 | - Q_D(StoreJob); |
paul@0 | 6788 | + Q_D( StoreJob ); |
paul@0 | 6789 | d->set = set; |
paul@0 | 6790 | } |
paul@0 | 6791 | |
paul@0 | 6792 | ImapSet StoreJob::sequenceSet() const |
paul@0 | 6793 | { |
paul@0 | 6794 | - Q_D(const StoreJob); |
paul@0 | 6795 | + Q_D( const StoreJob ); |
paul@0 | 6796 | return d->set; |
paul@0 | 6797 | } |
paul@0 | 6798 | |
paul@0 | 6799 | void StoreJob::setUidBased(bool uidBased) |
paul@0 | 6800 | { |
paul@0 | 6801 | - Q_D(StoreJob); |
paul@0 | 6802 | + Q_D( StoreJob ); |
paul@0 | 6803 | d->uidBased = uidBased; |
paul@0 | 6804 | } |
paul@0 | 6805 | |
paul@0 | 6806 | bool StoreJob::isUidBased() const |
paul@0 | 6807 | { |
paul@0 | 6808 | - Q_D(const StoreJob); |
paul@0 | 6809 | + Q_D( const StoreJob ); |
paul@0 | 6810 | return d->uidBased; |
paul@0 | 6811 | } |
paul@0 | 6812 | |
paul@0 | 6813 | void StoreJob::setFlags( const MessageFlags &flags ) |
paul@0 | 6814 | { |
paul@0 | 6815 | - Q_D(StoreJob); |
paul@0 | 6816 | + Q_D( StoreJob ); |
paul@0 | 6817 | d->flags = flags; |
paul@0 | 6818 | } |
paul@0 | 6819 | |
paul@0 | 6820 | MessageFlags StoreJob::flags() const |
paul@0 | 6821 | { |
paul@0 | 6822 | - Q_D(const StoreJob); |
paul@0 | 6823 | + Q_D( const StoreJob ); |
paul@0 | 6824 | return d->flags; |
paul@0 | 6825 | } |
paul@0 | 6826 | |
paul@0 | 6827 | void StoreJob::setMode( StoreMode mode ) |
paul@0 | 6828 | { |
paul@0 | 6829 | - Q_D(StoreJob); |
paul@0 | 6830 | + Q_D( StoreJob ); |
paul@0 | 6831 | d->mode = mode; |
paul@0 | 6832 | } |
paul@0 | 6833 | |
paul@0 | 6834 | StoreJob::StoreMode StoreJob::mode() const |
paul@0 | 6835 | { |
paul@0 | 6836 | - Q_D(const StoreJob); |
paul@0 | 6837 | + Q_D( const StoreJob ); |
paul@0 | 6838 | return d->mode; |
paul@0 | 6839 | } |
paul@0 | 6840 | |
paul@0 | 6841 | QMap<int, MessageFlags> StoreJob::resultingFlags() const |
paul@0 | 6842 | { |
paul@0 | 6843 | - Q_D(const StoreJob); |
paul@0 | 6844 | + Q_D( const StoreJob ); |
paul@0 | 6845 | return d->resultingFlags; |
paul@0 | 6846 | } |
paul@0 | 6847 | |
paul@0 | 6848 | void StoreJob::doStart() |
paul@0 | 6849 | { |
paul@0 | 6850 | - Q_D(StoreJob); |
paul@0 | 6851 | + Q_D( StoreJob ); |
paul@0 | 6852 | |
paul@0 | 6853 | QByteArray parameters = d->set.toImapSequenceSet()+' '; |
paul@0 | 6854 | |
paul@0 | 6855 | switch ( d->mode ) { |
paul@0 | 6856 | case SetFlags: |
paul@0 | 6857 | - parameters+= "FLAGS"; |
paul@0 | 6858 | + parameters += "FLAGS"; |
paul@0 | 6859 | break; |
paul@0 | 6860 | case AppendFlags: |
paul@0 | 6861 | - parameters+= "+FLAGS"; |
paul@0 | 6862 | + parameters += "+FLAGS"; |
paul@0 | 6863 | break; |
paul@0 | 6864 | case RemoveFlags: |
paul@0 | 6865 | - parameters+= "-FLAGS"; |
paul@0 | 6866 | + parameters += "-FLAGS"; |
paul@0 | 6867 | break; |
paul@0 | 6868 | } |
paul@0 | 6869 | |
paul@0 | 6870 | - parameters+=" ("; |
paul@0 | 6871 | + parameters += " ("; |
paul@0 | 6872 | foreach ( const QByteArray &flag, d->flags ) { |
paul@0 | 6873 | - parameters+=flag+' '; |
paul@0 | 6874 | + parameters += flag + ' '; |
paul@0 | 6875 | } |
paul@0 | 6876 | - if (!d->flags.isEmpty()) parameters.chop(1); |
paul@0 | 6877 | - parameters+=')'; |
paul@0 | 6878 | + if ( !d->flags.isEmpty() ) { |
paul@0 | 6879 | + parameters.chop( 1 ); |
paul@0 | 6880 | + } |
paul@0 | 6881 | + parameters += ')'; |
paul@0 | 6882 | |
paul@0 | 6883 | - qDebug("%s", parameters.constData()); |
paul@0 | 6884 | + kDebug() << parameters; |
paul@0 | 6885 | |
paul@0 | 6886 | QByteArray command = "STORE"; |
paul@0 | 6887 | if ( d->uidBased ) { |
paul@0 | 6888 | @@ -148,12 +150,12 @@ void StoreJob::doStart() |
paul@0 | 6889 | |
paul@0 | 6890 | void StoreJob::handleResponse( const Message &response ) |
paul@0 | 6891 | { |
paul@0 | 6892 | - Q_D(StoreJob); |
paul@0 | 6893 | + Q_D( StoreJob ); |
paul@0 | 6894 | |
paul@0 | 6895 | - if (handleErrorReplies(response) == NotHandled ) { |
paul@0 | 6896 | - if ( response.content.size() == 4 |
paul@0 | 6897 | - && response.content[2].toString()=="FETCH" |
paul@0 | 6898 | - && response.content[3].type()==Message::Part::List ) { |
paul@0 | 6899 | + if ( handleErrorReplies( response ) == NotHandled ) { |
paul@0 | 6900 | + if ( response.content.size() == 4 && |
paul@0 | 6901 | + response.content[2].toString() == "FETCH" && |
paul@0 | 6902 | + response.content[3].type() == Message::Part::List ) { |
paul@0 | 6903 | |
paul@0 | 6904 | int id = response.content[1].toString().toInt(); |
paul@0 | 6905 | qint64 uid = 0; |
paul@0 | 6906 | @@ -163,21 +165,21 @@ void StoreJob::handleResponse( const Message &response ) |
paul@0 | 6907 | QList<QByteArray> content = response.content[3].toList(); |
paul@0 | 6908 | |
paul@0 | 6909 | for ( QList<QByteArray>::ConstIterator it = content.constBegin(); |
paul@0 | 6910 | - it!=content.constEnd(); ++it ) { |
paul@0 | 6911 | + it != content.constEnd(); ++it ) { |
paul@0 | 6912 | QByteArray str = *it; |
paul@0 | 6913 | ++it; |
paul@0 | 6914 | |
paul@0 | 6915 | - if ( str=="FLAGS" ) { |
paul@0 | 6916 | - if ( (*it).startsWith('(') && (*it).endsWith(')') ) { |
paul@0 | 6917 | + if ( str == "FLAGS" ) { |
paul@0 | 6918 | + if ( ( *it ).startsWith( '(' ) && ( *it ).endsWith( ')' ) ) { |
paul@0 | 6919 | QByteArray str = *it; |
paul@0 | 6920 | - str.chop(1); |
paul@0 | 6921 | - str.remove(0, 1); |
paul@0 | 6922 | - resultingFlags = str.split(' '); |
paul@0 | 6923 | + str.chop( 1 ); |
paul@0 | 6924 | + str.remove( 0, 1 ); |
paul@0 | 6925 | + resultingFlags = str.split( ' ' ); |
paul@0 | 6926 | } else { |
paul@0 | 6927 | resultingFlags << *it; |
paul@0 | 6928 | } |
paul@0 | 6929 | - } else if ( str=="UID" ) { |
paul@0 | 6930 | - uid = it->toLongLong(&uidFound); |
paul@0 | 6931 | + } else if ( str == "UID" ) { |
paul@0 | 6932 | + uid = it->toLongLong( &uidFound ); |
paul@0 | 6933 | } |
paul@0 | 6934 | } |
paul@0 | 6935 | |
paul@0 | 6936 | @@ -192,4 +194,5 @@ void StoreJob::handleResponse( const Message &response ) |
paul@0 | 6937 | } |
paul@0 | 6938 | } |
paul@0 | 6939 | |
paul@0 | 6940 | -#include "storejob.moc" |
paul@0 | 6941 | \ No newline at end of file |
paul@0 | 6942 | +#include "storejob.moc" |
paul@0 | 6943 | + |
paul@0 | 6944 | diff --git a/kimap/storejob.h b/kimap/storejob.h |
paul@0 | 6945 | index 7c41d90..4de2f76 100644 |
paul@0 | 6946 | --- a/kimap/storejob.h |
paul@0 | 6947 | +++ b/kimap/storejob.h |
paul@0 | 6948 | @@ -36,13 +36,12 @@ typedef QList<QByteArray> MessageFlags; |
paul@0 | 6949 | class KIMAP_EXPORT StoreJob : public Job |
paul@0 | 6950 | { |
paul@0 | 6951 | Q_OBJECT |
paul@0 | 6952 | - Q_DECLARE_PRIVATE(StoreJob) |
paul@0 | 6953 | + Q_DECLARE_PRIVATE( StoreJob ) |
paul@0 | 6954 | |
paul@0 | 6955 | friend class SessionPrivate; |
paul@0 | 6956 | |
paul@0 | 6957 | public: |
paul@0 | 6958 | - enum StoreMode |
paul@0 | 6959 | - { |
paul@0 | 6960 | + enum StoreMode { |
paul@0 | 6961 | SetFlags, |
paul@0 | 6962 | AppendFlags, |
paul@0 | 6963 | RemoveFlags |
paul@0 | 6964 | diff --git a/kimap/subscribejob.cpp b/kimap/subscribejob.cpp |
paul@0 | 6965 | index 880f977..5317f73 100644 |
paul@0 | 6966 | --- a/kimap/subscribejob.cpp |
paul@0 | 6967 | +++ b/kimap/subscribejob.cpp |
paul@0 | 6968 | @@ -19,8 +19,8 @@ |
paul@0 | 6969 | |
paul@0 | 6970 | #include "subscribejob.h" |
paul@0 | 6971 | |
paul@0 | 6972 | -#include <klocale.h> |
paul@0 | 6973 | -#include <kdebug.h> |
paul@0 | 6974 | +#include <KDE/KLocalizedString> |
paul@0 | 6975 | +#include <KDE/KDebug> |
paul@0 | 6976 | |
paul@0 | 6977 | #include "job_p.h" |
paul@0 | 6978 | #include "message_p.h" |
paul@0 | 6979 | @@ -32,7 +32,7 @@ namespace KIMAP |
paul@0 | 6980 | class SubscribeJobPrivate : public JobPrivate |
paul@0 | 6981 | { |
paul@0 | 6982 | public: |
paul@0 | 6983 | - SubscribeJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { } |
paul@0 | 6984 | + SubscribeJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { } |
paul@0 | 6985 | ~SubscribeJobPrivate() { } |
paul@0 | 6986 | |
paul@0 | 6987 | QString mailBox; |
paul@0 | 6988 | @@ -42,7 +42,7 @@ namespace KIMAP |
paul@0 | 6989 | using namespace KIMAP; |
paul@0 | 6990 | |
paul@0 | 6991 | SubscribeJob::SubscribeJob( Session *session ) |
paul@0 | 6992 | - : Job( *new SubscribeJobPrivate(session, i18n("Subscribe")) ) |
paul@0 | 6993 | + : Job( *new SubscribeJobPrivate( session, i18n( "Subscribe" ) ) ) |
paul@0 | 6994 | { |
paul@0 | 6995 | } |
paul@0 | 6996 | |
paul@0 | 6997 | @@ -52,20 +52,21 @@ SubscribeJob::~SubscribeJob() |
paul@0 | 6998 | |
paul@0 | 6999 | void SubscribeJob::doStart() |
paul@0 | 7000 | { |
paul@0 | 7001 | - Q_D(SubscribeJob); |
paul@0 | 7002 | - d->tags << d->sessionInternal()->sendCommand( "SUBSCRIBE", '\"'+KIMAP::encodeImapFolderName( d->mailBox.toUtf8() )+'\"' ); |
paul@0 | 7003 | + Q_D( SubscribeJob ); |
paul@0 | 7004 | + d->tags << d->sessionInternal()->sendCommand( "SUBSCRIBE", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"' ); |
paul@0 | 7005 | } |
paul@0 | 7006 | |
paul@0 | 7007 | void SubscribeJob::setMailBox( const QString &mailBox ) |
paul@0 | 7008 | { |
paul@0 | 7009 | - Q_D(SubscribeJob); |
paul@0 | 7010 | + Q_D( SubscribeJob ); |
paul@0 | 7011 | d->mailBox = mailBox; |
paul@0 | 7012 | } |
paul@0 | 7013 | |
paul@0 | 7014 | QString SubscribeJob::mailBox() const |
paul@0 | 7015 | { |
paul@0 | 7016 | - Q_D(const SubscribeJob); |
paul@0 | 7017 | + Q_D( const SubscribeJob ); |
paul@0 | 7018 | return d->mailBox; |
paul@0 | 7019 | } |
paul@0 | 7020 | |
paul@0 | 7021 | #include "subscribejob.moc" |
paul@0 | 7022 | + |
paul@0 | 7023 | diff --git a/kimap/subscribejob.h b/kimap/subscribejob.h |
paul@0 | 7024 | index f0db503..e54cf9f 100644 |
paul@0 | 7025 | --- a/kimap/subscribejob.h |
paul@0 | 7026 | +++ b/kimap/subscribejob.h |
paul@0 | 7027 | @@ -32,7 +32,7 @@ class SubscribeJobPrivate; |
paul@0 | 7028 | class KIMAP_EXPORT SubscribeJob : public Job |
paul@0 | 7029 | { |
paul@0 | 7030 | Q_OBJECT |
paul@0 | 7031 | - Q_DECLARE_PRIVATE(SubscribeJob) |
paul@0 | 7032 | + Q_DECLARE_PRIVATE( SubscribeJob ) |
paul@0 | 7033 | |
paul@0 | 7034 | friend class SessionPrivate; |
paul@0 | 7035 | |
paul@0 | 7036 | diff --git a/kimap/unsubscribejob.cpp b/kimap/unsubscribejob.cpp |
paul@0 | 7037 | index f570987..06f0900 100644 |
paul@0 | 7038 | --- a/kimap/unsubscribejob.cpp |
paul@0 | 7039 | +++ b/kimap/unsubscribejob.cpp |
paul@0 | 7040 | @@ -19,8 +19,8 @@ |
paul@0 | 7041 | |
paul@0 | 7042 | #include "unsubscribejob.h" |
paul@0 | 7043 | |
paul@0 | 7044 | -#include <klocale.h> |
paul@0 | 7045 | -#include <kdebug.h> |
paul@0 | 7046 | +#include <KDE/KLocalizedString> |
paul@0 | 7047 | +#include <KDE/KDebug> |
paul@0 | 7048 | |
paul@0 | 7049 | #include "job_p.h" |
paul@0 | 7050 | #include "message_p.h" |
paul@0 | 7051 | @@ -32,7 +32,7 @@ namespace KIMAP |
paul@0 | 7052 | class UnsubscribeJobPrivate : public JobPrivate |
paul@0 | 7053 | { |
paul@0 | 7054 | public: |
paul@0 | 7055 | - UnsubscribeJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { } |
paul@0 | 7056 | + UnsubscribeJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { } |
paul@0 | 7057 | ~UnsubscribeJobPrivate() { } |
paul@0 | 7058 | |
paul@0 | 7059 | QString mailBox; |
paul@0 | 7060 | @@ -42,7 +42,7 @@ namespace KIMAP |
paul@0 | 7061 | using namespace KIMAP; |
paul@0 | 7062 | |
paul@0 | 7063 | UnsubscribeJob::UnsubscribeJob( Session *session ) |
paul@0 | 7064 | - : Job( *new UnsubscribeJobPrivate(session, i18n("Unsubscribe")) ) |
paul@0 | 7065 | + : Job( *new UnsubscribeJobPrivate( session, i18n( "Unsubscribe" ) ) ) |
paul@0 | 7066 | { |
paul@0 | 7067 | } |
paul@0 | 7068 | |
paul@0 | 7069 | @@ -52,20 +52,21 @@ UnsubscribeJob::~UnsubscribeJob() |
paul@0 | 7070 | |
paul@0 | 7071 | void UnsubscribeJob::doStart() |
paul@0 | 7072 | { |
paul@0 | 7073 | - Q_D(UnsubscribeJob); |
paul@0 | 7074 | - d->tags << d->sessionInternal()->sendCommand( "UNSUBSCRIBE", '\"'+KIMAP::encodeImapFolderName( d->mailBox.toUtf8() )+'\"' ); |
paul@0 | 7075 | + Q_D( UnsubscribeJob ); |
paul@0 | 7076 | + d->tags << d->sessionInternal()->sendCommand( "UNSUBSCRIBE", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"' ); |
paul@0 | 7077 | } |
paul@0 | 7078 | |
paul@0 | 7079 | void UnsubscribeJob::setMailBox( const QString &mailBox ) |
paul@0 | 7080 | { |
paul@0 | 7081 | - Q_D(UnsubscribeJob); |
paul@0 | 7082 | + Q_D( UnsubscribeJob ); |
paul@0 | 7083 | d->mailBox = mailBox; |
paul@0 | 7084 | } |
paul@0 | 7085 | |
paul@0 | 7086 | QString UnsubscribeJob::mailBox() const |
paul@0 | 7087 | { |
paul@0 | 7088 | - Q_D(const UnsubscribeJob); |
paul@0 | 7089 | + Q_D( const UnsubscribeJob ); |
paul@0 | 7090 | return d->mailBox; |
paul@0 | 7091 | } |
paul@0 | 7092 | |
paul@0 | 7093 | #include "unsubscribejob.moc" |
paul@0 | 7094 | + |
paul@0 | 7095 | diff --git a/kimap/unsubscribejob.h b/kimap/unsubscribejob.h |
paul@0 | 7096 | index f03875e..1ef8ceb 100644 |
paul@0 | 7097 | --- a/kimap/unsubscribejob.h |
paul@0 | 7098 | +++ b/kimap/unsubscribejob.h |
paul@0 | 7099 | @@ -32,7 +32,7 @@ class UnsubscribeJobPrivate; |
paul@0 | 7100 | class KIMAP_EXPORT UnsubscribeJob : public Job |
paul@0 | 7101 | { |
paul@0 | 7102 | Q_OBJECT |
paul@0 | 7103 | - Q_DECLARE_PRIVATE(UnsubscribeJob) |
paul@0 | 7104 | + Q_DECLARE_PRIVATE( UnsubscribeJob ) |
paul@0 | 7105 | |
paul@0 | 7106 | friend class SessionPrivate; |
paul@0 | 7107 | |