1 commit 9b09d89342ea522cf356d90649465e93ec743ba4 2 Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> 3 Date: Mon Oct 14 17:45:31 2013 +0200 4 5 Fix imap lockups.patch 6 7 diff --git a/kdecore/CMakeLists.txt b/kdecore/CMakeLists.txt 8 index f543f0e..7cdff03 100644 9 --- a/kdecore/CMakeLists.txt 10 +++ b/kdecore/CMakeLists.txt 11 @@ -721,3 +721,5 @@ install(FILES 12 # DESTINATION ${SERVICETYPES_INSTALL_DIR} 13 # ) 14 15 +add_subdirectory(includes) 16 + 17 diff --git a/kdecore/includes/CMakeLists.txt b/kdecore/includes/CMakeLists.txt 18 new file mode 100644 19 index 0000000..2a10c50 20 --- /dev/null 21 +++ b/kdecore/includes/CMakeLists.txt 22 @@ -0,0 +1,34 @@ 23 + 24 +macro(install_headers _dir) 25 + install( DIRECTORY ${_dir} DESTINATION ${INCLUDE_INSTALL_DIR} ) 26 +endmacro() 27 + 28 +macro(create_header _file _path _header) 29 + #For installation 30 + set(CAMELCASE_INCLUDE_PATH "../${_header}") 31 + configure_file(config-CamelCaseInclude.cmake ${CMAKE_CURRENT_BINARY_DIR}/KDE/${_file}) 32 + #For including from the kdepimlibs stuff 33 + set(CAMELCASE_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../${_path}/${_header}") 34 + configure_file(config-CamelCaseInclude.cmake ${CMAKE_CURRENT_BINARY_DIR}/includes/KDE/${_file}) 35 +endmacro() 36 + 37 +create_header(KCalendarSystem date kcalendarsystem.h) 38 +create_header(KConfig config kconfig.h) 39 +create_header(KCodecs text kcodecs.h) 40 +create_header(KConfigGroup config kconfiggroup.h) 41 +create_header(KDateTime date kdatetime.h) 42 +create_header(KDebug io kdebug.h) 43 +create_header(KGlobal kernel kglobal.h) 44 +create_header(KJob jobs kjob.h) 45 +create_header(KLocale localization klocale.h) 46 +create_header(KMimeType services kmimetype.h) 47 +create_header(KRandom util krandom.h) 48 +create_header(KSaveFile io ksavefile.h) 49 +create_header(KStandardDirs kernel kstandarddirs.h) 50 +create_header(KSystemTimeZone date ksystemtimezone.h) 51 +create_header(KTemporaryFile io ktemporaryfile.h) 52 +create_header(KTimeZone date ktimezone.h) 53 +create_header(KUrl io kurl.h) 54 +create_header(KLocalizedString localization klocalizedstring.h) 55 + 56 +install_headers(${CMAKE_CURRENT_BINARY_DIR}/KDE) 57 diff --git a/kdecore/includes/config-CamelCaseInclude.cmake b/kdecore/includes/config-CamelCaseInclude.cmake 58 new file mode 100644 59 index 0000000..b6bb3e9 60 --- /dev/null 61 +++ b/kdecore/includes/config-CamelCaseInclude.cmake 62 @@ -0,0 +1,2 @@ 63 +#include "${CAMELCASE_INCLUDE_PATH}" 64 + 65 diff --git a/kdecore/network/ktcpsocket.cpp b/kdecore/network/ktcpsocket.cpp 66 index 17b84d1..cdffccf 100644 67 --- a/kdecore/network/ktcpsocket.cpp 68 +++ b/kdecore/network/ktcpsocket.cpp 69 @@ -63,7 +63,12 @@ static QSsl::SslProtocol qSslProtocolFromK(KTcpSocket::SslVersion sslVersion) 70 return QSsl::AnyProtocol; 71 } 72 //does it contain any valid protocol? 73 - if (!(sslVersion & (KTcpSocket::SslV2 | KTcpSocket::SslV3 | KTcpSocket::TlsV1))) { 74 + KTcpSocket::SslVersions validVersions (KTcpSocket::SslV2 | KTcpSocket::SslV3 | KTcpSocket::TlsV1); 75 +#if QT_VERSION >= 0x040800 76 + validVersions |= KTcpSocket::TlsV1SslV3; 77 + validVersions |= KTcpSocket::SecureProtocols; 78 +#endif 79 + if (!(sslVersion & validVersions)) { 80 return QSsl::UnknownProtocol; 81 } 82 83 @@ -316,6 +321,8 @@ public: 84 return KTcpSocket::NetworkError; 85 case QAbstractSocket::UnsupportedSocketOperationError: 86 return KTcpSocket::UnsupportedSocketOperationError; 87 + case QAbstractSocket::SslHandshakeFailedError: 88 + return KTcpSocket::SslHandshakeFailedError; 89 case QAbstractSocket::DatagramTooLargeError: 90 //we don't do UDP 91 case QAbstractSocket::AddressInUseError: 92 diff --git a/kdecore/network/ktcpsocket.h b/kdecore/network/ktcpsocket.h 93 index 58dfa2c..c281b3e 100644 94 --- a/kdecore/network/ktcpsocket.h 95 +++ b/kdecore/network/ktcpsocket.h 96 @@ -175,7 +175,8 @@ public: 97 SocketResourceError, 98 SocketTimeoutError, 99 NetworkError, 100 - UnsupportedSocketOperationError 101 + UnsupportedSocketOperationError, 102 + SslHandshakeFailedError 103 }; 104 /* 105 The following is based on reading the OpenSSL interface code of both QSslSocket 106 diff --git a/kimap/CMakeLists.txt b/kimap/CMakeLists.txt 107 index e8a7b79..978c5ac 100644 108 --- a/kimap/CMakeLists.txt 109 +++ b/kimap/CMakeLists.txt 110 @@ -41,7 +41,12 @@ include_directories(${QT_INCLUDES}) 111 #include(GenerateExportHeader) 112 113 114 -include_directories( ../kdecore ../ ${CMAKE_CURRENT_BINARY_DIR}) 115 +include_directories( ../kdecore 116 + ${CMAKE_CURRENT_BINARY_DIR}/../kdecore/includes/includes 117 + ${CMAKE_CURRENT_BINARY_DIR}/../kdecore/includes/includes/KDE 118 + ../ 119 + ${CMAKE_CURRENT_BINARY_DIR} 120 +) 121 122 123 124 diff --git a/kimap/acl.cpp b/kimap/acl.cpp 125 index 980538b..d0bf3e2 100644 126 --- a/kimap/acl.cpp 127 +++ b/kimap/acl.cpp 128 @@ -21,7 +21,7 @@ 129 130 #include <QtCore/QByteArray> 131 #include <QtCore/QMap> 132 -#include <kglobal.h> 133 +#include <KDE/KGlobal> 134 135 namespace KIMAP { 136 namespace Acl { 137 @@ -29,8 +29,7 @@ namespace Acl { 138 class RightsMap 139 { 140 public: 141 - RightsMap() 142 - { 143 + RightsMap() { 144 map['l'] = Lookup; 145 map['r'] = Read; 146 map['s'] = KeepSeen; 147 @@ -60,7 +59,7 @@ class RightsMap 148 QMap<char, Right> map; 149 }; 150 151 -Q_GLOBAL_STATIC(RightsMap, globalRights) 152 +K_GLOBAL_STATIC( RightsMap, globalRights ) 153 154 } 155 } 156 @@ -69,17 +68,18 @@ KIMAP::Acl::Rights KIMAP::Acl::rightsFromString( const QByteArray &string ) 157 { 158 Rights result; 159 160 - if ( string.isEmpty() ) 161 + if ( string.isEmpty() ) { 162 return result; 163 + } 164 165 int pos = 0; 166 - if ( string[0] == '+' || string[0]== '-') { // Skip modifier if any 167 + if ( string[0] == '+' || string[0] == '-' ) { // Skip modifier if any 168 pos++; 169 } 170 171 for ( int i = pos; i < string.size(); i++ ) { 172 - if ( globalRights()->map.contains( string[i] ) ) { 173 - result|= globalRights()->map[string[i]]; 174 + if ( globalRights->map.contains( string[i] ) ) { 175 + result|= globalRights->map[string[i]]; 176 } 177 } 178 179 @@ -90,9 +90,9 @@ QByteArray KIMAP::Acl::rightsToString( Rights rights ) 180 { 181 QByteArray result; 182 183 - for ( int right = Lookup; right<=Custom9; right<<=1 ) { 184 + for ( int right = Lookup; right <= Custom9; right <<= 1 ) { 185 if ( rights & right ) { 186 - result+= globalRights()->map.key( (Right)right ); 187 + result += globalRights->map.key( (Right)right ); 188 } 189 } 190 191 @@ -125,3 +125,5 @@ KIMAP::Acl::Rights KIMAP::Acl::denormalizedRights( KIMAP::Acl::Rights rights ) 192 return denormalized; 193 } 194 195 +#include "acl.moc" 196 + 197 diff --git a/kimap/acl.h b/kimap/acl.h 198 index 40e738f..2df610c 100644 199 --- a/kimap/acl.h 200 +++ b/kimap/acl.h 201 @@ -89,17 +89,19 @@ enum Right { 202 Custom9 = 0x800000 /**< Server-specific right 9 */ 203 }; 204 205 -Q_DECLARE_FLAGS(Rights, Right) 206 +Q_DECLARE_FLAGS( Rights, Right ) 207 208 /** 209 * Returns a rights mask that has no obsolete members anymore, i.e. obsolete flags are removed and 210 * replaced by their successors. 211 + * @param rights set of #Rights flags to normalize 212 * @since 4.6 213 */ 214 KIMAP_EXPORT Rights normalizedRights( Rights rights ); 215 216 /** 217 * Returns a rights mask that contains both obsolete and new flags if one of them is set. 218 + * @param rights set of #Rights flags to augment 219 * @since 4.6 220 */ 221 KIMAP_EXPORT Rights denormalizedRights( Rights rights ); 222 diff --git a/kimap/acljobbase.cpp b/kimap/acljobbase.cpp 223 index 9bfe29a..5df4420 100644 224 --- a/kimap/acljobbase.cpp 225 +++ b/kimap/acljobbase.cpp 226 @@ -22,8 +22,8 @@ 227 #include "message_p.h" 228 #include "session_p.h" 229 230 -#include <klocale.h> 231 -#include <kdebug.h> 232 +#include <KDE/KLocalizedString> 233 +#include <KDE/KDebug> 234 235 using namespace KIMAP; 236 237 @@ -56,7 +56,7 @@ void AclJobBasePrivate::setRights(const QByteArray& rights) 238 break; 239 } 240 241 - rightList = Acl::rightsFromString(rights); 242 + rightList = Acl::rightsFromString( rights ); 243 } 244 245 void AclJobBasePrivate::setRights(AclJobBase::AclModifier _modifier, Acl::Rights rights) 246 @@ -66,16 +66,13 @@ void AclJobBasePrivate::setRights(AclJobBase::AclModifier _modifier, Acl::Rights 247 rightList|= rights; 248 } 249 250 - 251 - 252 AclJobBase::AclJobBase( Session *session ) 253 - : Job( *new AclJobBasePrivate(session, i18n("AclJobBase")) ) 254 + : Job( *new AclJobBasePrivate( session, i18n( "AclJobBase" ) ) ) 255 { 256 } 257 258 - 259 AclJobBase::AclJobBase( JobPrivate &dd ) 260 - : Job(dd) 261 + : Job( dd ) 262 { 263 264 } 265 @@ -84,17 +81,17 @@ AclJobBase::~AclJobBase() 266 { 267 } 268 269 - 270 void AclJobBase::setMailBox( const QString &mailBox ) 271 { 272 - Q_D(AclJobBase); 273 + Q_D( AclJobBase ); 274 d->mailBox = mailBox; 275 } 276 277 QString AclJobBase::mailBox() const 278 { 279 - Q_D(const AclJobBase); 280 + Q_D( const AclJobBase ); 281 return d->mailBox; 282 } 283 284 -#include "acljobbase.moc" 285 \ No newline at end of file 286 +#include "acljobbase.moc" 287 + 288 diff --git a/kimap/acljobbase.h b/kimap/acljobbase.h 289 index 39616a2..fe67319 100644 290 --- a/kimap/acljobbase.h 291 +++ b/kimap/acljobbase.h 292 @@ -43,7 +43,7 @@ class AclJobBasePrivate; 293 class KIMAP_EXPORT AclJobBase : public Job 294 { 295 Q_OBJECT 296 - Q_DECLARE_PRIVATE(AclJobBase) 297 + Q_DECLARE_PRIVATE( AclJobBase ) 298 299 friend class SessionPrivate; 300 301 diff --git a/kimap/acljobbase_p.h b/kimap/acljobbase_p.h 302 index 7550489..45345bd 100644 303 --- a/kimap/acljobbase_p.h 304 +++ b/kimap/acljobbase_p.h 305 @@ -23,14 +23,14 @@ 306 #include "acljobbase.h" 307 #include "job_p.h" 308 #include "session.h" 309 -#include <klocale.h> 310 +#include <KDE/KLocalizedString> 311 312 namespace KIMAP 313 { 314 class AclJobBasePrivate : public JobPrivate 315 { 316 public: 317 - AclJobBasePrivate( Session *session, const QString& name ) : JobPrivate(session, name), rightList(Acl::None), modifier(AclJobBase::Change) 318 + AclJobBasePrivate( Session *session, const QString& name ) : JobPrivate( session, name ), rightList( Acl::None ), modifier( AclJobBase::Change ) 319 { 320 } 321 ~AclJobBasePrivate() { } 322 diff --git a/kimap/appendjob.cpp b/kimap/appendjob.cpp 323 index b0e5c83..bda3904 100644 324 --- a/kimap/appendjob.cpp 325 +++ b/kimap/appendjob.cpp 326 @@ -19,7 +19,7 @@ 327 328 #include "appendjob.h" 329 330 -#include <klocale.h> 331 +#include <KDE/KLocalizedString> 332 333 #include "job_p.h" 334 #include "message_p.h" 335 @@ -44,7 +44,7 @@ namespace KIMAP 336 using namespace KIMAP; 337 338 AppendJob::AppendJob( Session *session ) 339 - : Job( *new AppendJobPrivate(session, i18n("Append")) ) 340 + : Job( *new AppendJobPrivate( session, i18n( "Append" ) ) ) 341 { 342 } 343 344 @@ -54,73 +54,73 @@ AppendJob::~AppendJob() 345 346 void AppendJob::setMailBox( const QString &mailBox ) 347 { 348 - Q_D(AppendJob); 349 + Q_D( AppendJob ); 350 d->mailBox = mailBox; 351 } 352 353 QString AppendJob::mailBox() const 354 { 355 - Q_D(const AppendJob); 356 + Q_D( const AppendJob ); 357 return d->mailBox; 358 } 359 360 void AppendJob::setFlags( const QList<QByteArray> &flags) 361 { 362 - Q_D(AppendJob); 363 + Q_D( AppendJob ); 364 d->flags = flags; 365 } 366 367 QList<QByteArray> AppendJob::flags() const 368 { 369 - Q_D(const AppendJob); 370 + Q_D( const AppendJob ); 371 return d->flags; 372 } 373 374 void AppendJob::setContent( const QByteArray &content ) 375 { 376 - Q_D(AppendJob); 377 + Q_D( AppendJob ); 378 d->content = content; 379 } 380 381 QByteArray AppendJob::content() const 382 { 383 - Q_D(const AppendJob); 384 + Q_D( const AppendJob ); 385 return d->content; 386 } 387 388 qint64 AppendJob::uid() const 389 { 390 - Q_D(const AppendJob); 391 + Q_D( const AppendJob ); 392 return d->uid; 393 } 394 395 void AppendJob::doStart() 396 { 397 - Q_D(AppendJob); 398 + Q_D( AppendJob ); 399 400 - QByteArray parameters = '\"'+KIMAP::encodeImapFolderName( d->mailBox.toUtf8() )+'\"'; 401 + QByteArray parameters = '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"'; 402 403 if ( !d->flags.isEmpty() ) { 404 - parameters+=" ("; 405 + parameters += " ("; 406 foreach ( const QByteArray &flag, d->flags ) { 407 - parameters+= flag+' '; 408 + parameters+= flag + ' '; 409 } 410 - parameters.chop(1); 411 - parameters+=')'; 412 + parameters.chop( 1 ); 413 + parameters += ')'; 414 } 415 416 - parameters+=" {"+QByteArray::number(d->content.size())+'}'; 417 + parameters += " {" + QByteArray::number( d->content.size() ) + '}'; 418 419 d->tags << d->sessionInternal()->sendCommand( "APPEND", parameters ); 420 } 421 422 void AppendJob::handleResponse( const Message &response ) 423 { 424 - Q_D(AppendJob); 425 + Q_D( AppendJob ); 426 427 for ( QList<Message::Part>::ConstIterator it = response.responseCode.begin(); 428 it != response.responseCode.end(); ++it ) { 429 - if ( it->toString()=="APPENDUID" ) { 430 + if ( it->toString() == "APPENDUID" ) { 431 it = it + 2; 432 if ( it != response.responseCode.end() ) { 433 d->uid = it->toString().toLongLong(); 434 @@ -129,7 +129,7 @@ void AppendJob::handleResponse( const Message &response ) 435 } 436 } 437 438 - if (handleErrorReplies(response) == NotHandled ) { 439 + if ( handleErrorReplies( response ) == NotHandled ) { 440 if ( response.content[0].toString() == "+" ) { 441 d->sessionInternal()->sendData( d->content ); 442 } 443 @@ -137,3 +137,4 @@ void AppendJob::handleResponse( const Message &response ) 444 } 445 446 #include "appendjob.moc" 447 + 448 diff --git a/kimap/appendjob.h b/kimap/appendjob.h 449 index 9fdc2bd..d01f4f2 100644 450 --- a/kimap/appendjob.h 451 +++ b/kimap/appendjob.h 452 @@ -42,7 +42,7 @@ class AppendJobPrivate; 453 class KIMAP_EXPORT AppendJob : public Job 454 { 455 Q_OBJECT 456 - Q_DECLARE_PRIVATE(AppendJob) 457 + Q_DECLARE_PRIVATE( AppendJob ) 458 459 friend class SessionPrivate; 460 461 diff --git a/kimap/capabilitiesjob.cpp b/kimap/capabilitiesjob.cpp 462 index b07e1b9..a9b52dc 100644 463 --- a/kimap/capabilitiesjob.cpp 464 +++ b/kimap/capabilitiesjob.cpp 465 @@ -19,7 +19,7 @@ 466 467 #include "capabilitiesjob.h" 468 469 -#include <klocale.h> 470 +#include <KDE/KLocalizedString> 471 472 #include "job_p.h" 473 #include "message_p.h" 474 @@ -30,7 +30,7 @@ namespace KIMAP 475 class CapabilitiesJobPrivate : public JobPrivate 476 { 477 public: 478 - CapabilitiesJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { } 479 + CapabilitiesJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { } 480 ~CapabilitiesJobPrivate() { } 481 482 QStringList capabilities; 483 @@ -40,7 +40,7 @@ namespace KIMAP 484 using namespace KIMAP; 485 486 CapabilitiesJob::CapabilitiesJob( Session *session ) 487 - : Job( *new CapabilitiesJobPrivate(session, i18n("Capabilities")) ) 488 + : Job( *new CapabilitiesJobPrivate( session, i18n( "Capabilities" ) ) ) 489 { 490 } 491 492 @@ -50,29 +50,30 @@ CapabilitiesJob::~CapabilitiesJob() 493 494 QStringList CapabilitiesJob::capabilities() const 495 { 496 - Q_D(const CapabilitiesJob); 497 + Q_D( const CapabilitiesJob ); 498 return d->capabilities; 499 } 500 501 void CapabilitiesJob::doStart() 502 { 503 - Q_D(CapabilitiesJob); 504 + Q_D( CapabilitiesJob ); 505 d->tags << d->sessionInternal()->sendCommand( "CAPABILITY" ); 506 } 507 508 void CapabilitiesJob::handleResponse( const Message &response ) 509 { 510 511 - Q_D(CapabilitiesJob); 512 - if (handleErrorReplies(response) == NotHandled) { 513 - if ( response.content.size() >= 2 514 - && response.content[1].toString()=="CAPABILITY" ) { 515 - for (int i=2; i<response.content.size(); ++i) { 516 + Q_D( CapabilitiesJob ); 517 + if ( handleErrorReplies( response ) == NotHandled ) { 518 + if ( response.content.size() >= 2 && 519 + response.content[1].toString() == "CAPABILITY" ) { 520 + for ( int i = 2; i < response.content.size(); ++i ) { 521 d->capabilities << response.content[i].toString().toUpper(); 522 } 523 - emit capabilitiesReceived(d->capabilities); 524 + emit capabilitiesReceived( d->capabilities ); 525 } 526 } 527 } 528 529 #include "capabilitiesjob.moc" 530 + 531 diff --git a/kimap/capabilitiesjob.h b/kimap/capabilitiesjob.h 532 index 0306f26..42ab3b1 100644 533 --- a/kimap/capabilitiesjob.h 534 +++ b/kimap/capabilitiesjob.h 535 @@ -45,7 +45,7 @@ class CapabilitiesJobPrivate; 536 class KIMAP_EXPORT CapabilitiesJob : public Job 537 { 538 Q_OBJECT 539 - Q_DECLARE_PRIVATE(CapabilitiesJob) 540 + Q_DECLARE_PRIVATE( CapabilitiesJob ) 541 542 friend class SessionPrivate; 543 544 diff --git a/kimap/closejob.cpp b/kimap/closejob.cpp 545 index ea6416f..a59f386 100644 546 --- a/kimap/closejob.cpp 547 +++ b/kimap/closejob.cpp 548 @@ -19,7 +19,7 @@ 549 550 #include "closejob.h" 551 552 -#include <klocale.h> 553 +#include <KDE/KLocalizedString> 554 555 #include "job_p.h" 556 #include "message_p.h" 557 @@ -30,7 +30,7 @@ namespace KIMAP 558 class CloseJobPrivate : public JobPrivate 559 { 560 public: 561 - CloseJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { } 562 + CloseJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { } 563 ~CloseJobPrivate() { } 564 }; 565 } 566 @@ -38,7 +38,7 @@ namespace KIMAP 567 using namespace KIMAP; 568 569 CloseJob::CloseJob( Session *session ) 570 - : Job( *new CloseJobPrivate(session, i18n("Close")) ) 571 + : Job( *new CloseJobPrivate( session, i18n( "Close" ) ) ) 572 { 573 } 574 575 @@ -48,8 +48,9 @@ CloseJob::~CloseJob() 576 577 void CloseJob::doStart() 578 { 579 - Q_D(CloseJob); 580 + Q_D( CloseJob ); 581 d->tags << d->sessionInternal()->sendCommand( "CLOSE" ); 582 } 583 584 #include "closejob.moc" 585 + 586 diff --git a/kimap/closejob.h b/kimap/closejob.h 587 index 3cadc72..35d64bd 100644 588 --- a/kimap/closejob.h 589 +++ b/kimap/closejob.h 590 @@ -52,7 +52,7 @@ class CloseJobPrivate; 591 class KIMAP_EXPORT CloseJob : public Job 592 { 593 Q_OBJECT 594 - Q_DECLARE_PRIVATE(CloseJob) 595 + Q_DECLARE_PRIVATE( CloseJob ) 596 597 friend class SessionPrivate; 598 599 diff --git a/kimap/copyjob.cpp b/kimap/copyjob.cpp 600 index 05f2efb..a07d509 100644 601 --- a/kimap/copyjob.cpp 602 +++ b/kimap/copyjob.cpp 603 @@ -19,8 +19,8 @@ 604 605 #include "copyjob.h" 606 607 -#include <klocale.h> 608 -#include <kdebug.h> 609 +#include <KDE/KLocalizedString> 610 +#include <KDE/KDebug> 611 612 #include "job_p.h" 613 #include "message_p.h" 614 @@ -34,7 +34,7 @@ namespace KIMAP 615 class CopyJobPrivate : public JobPrivate 616 { 617 public: 618 - CopyJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { } 619 + CopyJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { } 620 ~CopyJobPrivate() { } 621 622 QString mailBox; 623 @@ -47,9 +47,9 @@ namespace KIMAP 624 using namespace KIMAP; 625 626 CopyJob::CopyJob( Session *session ) 627 - : Job( *new CopyJobPrivate(session, i18n("Copy")) ) 628 + : Job( *new CopyJobPrivate( session, i18n( "Copy" ) ) ) 629 { 630 - Q_D(CopyJob); 631 + Q_D( CopyJob ); 632 d->uidBased = false; 633 } 634 635 @@ -59,53 +59,52 @@ CopyJob::~CopyJob() 636 637 void CopyJob::setMailBox( const QString &mailBox ) 638 { 639 - Q_D(CopyJob); 640 + Q_D( CopyJob ); 641 d->mailBox = mailBox; 642 } 643 644 QString CopyJob::mailBox() const 645 { 646 - Q_D(const CopyJob); 647 + Q_D( const CopyJob ); 648 return d->mailBox; 649 } 650 651 void CopyJob::setSequenceSet( const ImapSet &set ) 652 { 653 - Q_D(CopyJob); 654 + Q_D( CopyJob ); 655 d->set = set; 656 } 657 658 ImapSet CopyJob::sequenceSet() const 659 { 660 - Q_D(const CopyJob); 661 + Q_D( const CopyJob ); 662 return d->set; 663 } 664 665 - 666 void CopyJob::setUidBased( bool uidBased ) 667 { 668 - Q_D(CopyJob); 669 + Q_D( CopyJob ); 670 d->uidBased = uidBased; 671 } 672 673 bool CopyJob::isUidBased() const 674 { 675 - Q_D(const CopyJob); 676 + Q_D( const CopyJob ); 677 return d->uidBased; 678 } 679 680 ImapSet CopyJob::resultingUids() const 681 { 682 - Q_D(const CopyJob); 683 + Q_D( const CopyJob ); 684 return d->resultingUids; 685 } 686 687 void CopyJob::doStart() 688 { 689 - Q_D(CopyJob); 690 + Q_D( CopyJob ); 691 692 QByteArray parameters = d->set.toImapSequenceSet()+' '; 693 - parameters+= '\"'+KIMAP::encodeImapFolderName( d->mailBox.toUtf8() )+'\"'; 694 + parameters += '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"'; 695 696 QByteArray command = "COPY"; 697 if ( d->uidBased ) { 698 @@ -117,11 +116,11 @@ void CopyJob::doStart() 699 700 void CopyJob::handleResponse( const Message &response ) 701 { 702 - Q_D(CopyJob); 703 + Q_D( CopyJob ); 704 705 for ( QList<Message::Part>::ConstIterator it = response.responseCode.begin(); 706 it != response.responseCode.end(); ++it ) { 707 - if ( it->toString()=="COPYUID" ) { 708 + if ( it->toString() == "COPYUID" ) { 709 it = it + 3; 710 if ( it < response.responseCode.end() ) { 711 d->resultingUids = ImapSet::fromImapSequenceSet( it->toString() ); 712 @@ -134,3 +133,4 @@ void CopyJob::handleResponse( const Message &response ) 713 } 714 715 #include "copyjob.moc" 716 + 717 diff --git a/kimap/copyjob.h b/kimap/copyjob.h 718 index 5e75fdc..c64bcbf 100644 719 --- a/kimap/copyjob.h 720 +++ b/kimap/copyjob.h 721 @@ -46,7 +46,7 @@ class CopyJobPrivate; 722 class KIMAP_EXPORT CopyJob : public Job 723 { 724 Q_OBJECT 725 - Q_DECLARE_PRIVATE(CopyJob) 726 + Q_DECLARE_PRIVATE( CopyJob ) 727 728 friend class SessionPrivate; 729 730 diff --git a/kimap/createjob.cpp b/kimap/createjob.cpp 731 index 6f25e0a..b6d486f 100644 732 --- a/kimap/createjob.cpp 733 +++ b/kimap/createjob.cpp 734 @@ -19,8 +19,8 @@ 735 736 #include "createjob.h" 737 738 -#include <klocale.h> 739 -#include <kdebug.h> 740 +#include <KDE/KLocalizedString> 741 +#include <KDE/KDebug> 742 743 #include "job_p.h" 744 #include "message_p.h" 745 @@ -32,7 +32,7 @@ namespace KIMAP 746 class CreateJobPrivate : public JobPrivate 747 { 748 public: 749 - CreateJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { } 750 + CreateJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { } 751 ~CreateJobPrivate() { } 752 753 QString mailBox; 754 @@ -42,7 +42,7 @@ namespace KIMAP 755 using namespace KIMAP; 756 757 CreateJob::CreateJob( Session *session ) 758 - : Job( *new CreateJobPrivate(session, i18n("Create")) ) 759 + : Job( *new CreateJobPrivate( session, i18n( "Create" ) ) ) 760 { 761 } 762 763 @@ -52,20 +52,21 @@ CreateJob::~CreateJob() 764 765 void CreateJob::doStart() 766 { 767 - Q_D(CreateJob); 768 - d->tags << d->sessionInternal()->sendCommand( "CREATE", '\"'+KIMAP::encodeImapFolderName( d->mailBox.toUtf8() )+'\"' ); 769 + Q_D( CreateJob ); 770 + d->tags << d->sessionInternal()->sendCommand( "CREATE", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"' ); 771 } 772 773 void CreateJob::setMailBox( const QString &mailBox ) 774 { 775 - Q_D(CreateJob); 776 + Q_D( CreateJob ); 777 d->mailBox = mailBox; 778 } 779 780 QString CreateJob::mailBox() const 781 { 782 - Q_D(const CreateJob); 783 + Q_D( const CreateJob ); 784 return d->mailBox; 785 } 786 787 #include "createjob.moc" 788 + 789 diff --git a/kimap/createjob.h b/kimap/createjob.h 790 index daab478..9977898 100644 791 --- a/kimap/createjob.h 792 +++ b/kimap/createjob.h 793 @@ -47,7 +47,7 @@ class CreateJobPrivate; 794 class KIMAP_EXPORT CreateJob : public Job 795 { 796 Q_OBJECT 797 - Q_DECLARE_PRIVATE(CreateJob) 798 + Q_DECLARE_PRIVATE( CreateJob ) 799 800 friend class SessionPrivate; 801 802 diff --git a/kimap/deleteacljob.cpp b/kimap/deleteacljob.cpp 803 index b5ea9a9..ca3a206 100644 804 --- a/kimap/deleteacljob.cpp 805 +++ b/kimap/deleteacljob.cpp 806 @@ -19,8 +19,8 @@ 807 808 #include "deleteacljob.h" 809 810 -#include <klocale.h> 811 -#include <kdebug.h> 812 +#include <KDE/KLocalizedString> 813 +#include <KDE/KDebug> 814 815 #include "acljobbase_p.h" 816 #include "message_p.h" 817 @@ -32,7 +32,7 @@ namespace KIMAP 818 class DeleteAclJobPrivate : public AclJobBasePrivate 819 { 820 public: 821 - DeleteAclJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate(session, name) {} 822 + DeleteAclJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate( session, name ) {} 823 ~DeleteAclJobPrivate() { } 824 }; 825 } 826 @@ -42,8 +42,8 @@ using namespace KIMAP; 827 DeleteAclJob::DeleteAclJob( Session *session ) 828 : AclJobBase( session ) 829 { 830 - Q_D(DeleteAclJob); 831 - d->m_name = i18n("DeleteAclJob"); 832 + Q_D( DeleteAclJob ); 833 + d->m_name = i18n( "DeleteAclJob" ); 834 } 835 836 DeleteAclJob::~DeleteAclJob() 837 @@ -52,21 +52,22 @@ DeleteAclJob::~DeleteAclJob() 838 839 void DeleteAclJob::doStart() 840 { 841 - Q_D(DeleteAclJob); 842 + Q_D( DeleteAclJob ); 843 844 - d->tags << d->sessionInternal()->sendCommand( "DELETEACL", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + "\" \"" + d->id); 845 + d->tags << d->sessionInternal()->sendCommand( "DELETEACL", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + "\" \"" + d->id ); 846 } 847 848 void DeleteAclJob::setIdentifier( const QByteArray &identifier ) 849 { 850 - Q_D(DeleteAclJob); 851 - d->setIdentifier(identifier); 852 + Q_D( DeleteAclJob ); 853 + d->setIdentifier( identifier ); 854 } 855 856 QByteArray DeleteAclJob::identifier() 857 { 858 - Q_D(DeleteAclJob); 859 + Q_D( DeleteAclJob ); 860 return d->identifier(); 861 } 862 863 #include "deleteacljob.moc" 864 + 865 diff --git a/kimap/deleteacljob.h b/kimap/deleteacljob.h 866 index 0f06055..7beed89 100644 867 --- a/kimap/deleteacljob.h 868 +++ b/kimap/deleteacljob.h 869 @@ -47,7 +47,7 @@ class DeleteAclJobPrivate; 870 class KIMAP_EXPORT DeleteAclJob : public AclJobBase 871 { 872 Q_OBJECT 873 - Q_DECLARE_PRIVATE(DeleteAclJob) 874 + Q_DECLARE_PRIVATE( DeleteAclJob ) 875 876 friend class SessionPrivate; 877 878 diff --git a/kimap/deletejob.cpp b/kimap/deletejob.cpp 879 index 59201ff..c1149ca 100644 880 --- a/kimap/deletejob.cpp 881 +++ b/kimap/deletejob.cpp 882 @@ -19,8 +19,8 @@ 883 884 #include "deletejob.h" 885 886 -#include <klocale.h> 887 -#include <kdebug.h> 888 +#include <KDE/KLocalizedString> 889 +#include <KDE/KDebug> 890 891 #include "job_p.h" 892 #include "message_p.h" 893 @@ -32,7 +32,7 @@ namespace KIMAP 894 class DeleteJobPrivate : public JobPrivate 895 { 896 public: 897 - DeleteJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { } 898 + DeleteJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { } 899 ~DeleteJobPrivate() { } 900 901 QString mailBox; 902 @@ -42,7 +42,7 @@ namespace KIMAP 903 using namespace KIMAP; 904 905 DeleteJob::DeleteJob( Session *session ) 906 - : Job( *new DeleteJobPrivate(session, i18n("Delete")) ) 907 + : Job( *new DeleteJobPrivate( session, i18n( "Delete" ) ) ) 908 { 909 } 910 911 @@ -52,20 +52,21 @@ DeleteJob::~DeleteJob() 912 913 void DeleteJob::doStart() 914 { 915 - Q_D(DeleteJob); 916 - d->tags << d->sessionInternal()->sendCommand( "DELETE", '\"'+KIMAP::encodeImapFolderName( d->mailBox.toUtf8() )+'\"' ); 917 + Q_D( DeleteJob ); 918 + d->tags << d->sessionInternal()->sendCommand( "DELETE", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"' ); 919 } 920 921 void DeleteJob::setMailBox( const QString &mailBox ) 922 { 923 - Q_D(DeleteJob); 924 + Q_D( DeleteJob ); 925 d->mailBox = mailBox; 926 } 927 928 QString DeleteJob::mailBox() const 929 { 930 - Q_D(const DeleteJob); 931 + Q_D( const DeleteJob ); 932 return d->mailBox; 933 } 934 935 -#include "deletejob.moc" 936 \ No newline at end of file 937 +#include "deletejob.moc" 938 + 939 diff --git a/kimap/deletejob.h b/kimap/deletejob.h 940 index 2876a90..926ee3c 100644 941 --- a/kimap/deletejob.h 942 +++ b/kimap/deletejob.h 943 @@ -46,7 +46,7 @@ class DeleteJobPrivate; 944 class KIMAP_EXPORT DeleteJob : public Job 945 { 946 Q_OBJECT 947 - Q_DECLARE_PRIVATE(DeleteJob) 948 + Q_DECLARE_PRIVATE( DeleteJob ) 949 950 friend class SessionPrivate; 951 952 diff --git a/kimap/expungejob.cpp b/kimap/expungejob.cpp 953 index 8da8285..63bed80 100644 954 --- a/kimap/expungejob.cpp 955 +++ b/kimap/expungejob.cpp 956 @@ -19,8 +19,8 @@ 957 958 #include "expungejob.h" 959 960 -#include <klocale.h> 961 -#include <kdebug.h> 962 +#include <KDE/KLocalizedString> 963 +#include <KDE/KDebug> 964 965 #include "job_p.h" 966 #include "message_p.h" 967 @@ -31,7 +31,7 @@ namespace KIMAP 968 class ExpungeJobPrivate : public JobPrivate 969 { 970 public: 971 - ExpungeJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { } 972 + ExpungeJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { } 973 ~ExpungeJobPrivate() { } 974 #if 0 975 QList< int > items; 976 @@ -42,7 +42,7 @@ namespace KIMAP 977 using namespace KIMAP; 978 979 ExpungeJob::ExpungeJob( Session *session ) 980 - : Job( *new ExpungeJobPrivate(session, i18n("Expunge")) ) 981 + : Job( *new ExpungeJobPrivate( session, i18n( "Expunge" ) ) ) 982 { 983 } 984 985 @@ -52,7 +52,7 @@ ExpungeJob::~ExpungeJob() 986 987 void ExpungeJob::doStart() 988 { 989 - Q_D(ExpungeJob); 990 + Q_D( ExpungeJob ); 991 d->tags << d->sessionInternal()->sendCommand( "EXPUNGE" ); 992 } 993 994 @@ -60,25 +60,26 @@ void ExpungeJob::handleResponse( const Message &response ) 995 { 996 // Q_D(ExpungeJob); 997 998 - if (handleErrorReplies(response) == NotHandled) { 999 + if ( handleErrorReplies( response ) == NotHandled ) { 1000 if ( response.content.size() >= 2 ) { 1001 QByteArray code = response.content[2].toString(); 1002 - if (code == "EXPUNGE") { 1003 + if ( code == "EXPUNGE" ) { 1004 #if 0 1005 QByteArray s = response.content[1].toString(); 1006 bool ok = true; 1007 - int id = s.toInt(&ok); 1008 - if (ok) { 1009 - d->items.append(id); 1010 + int id = s.toInt( &ok ); 1011 + if ( ok ) { 1012 + d->items.append( id ); 1013 } 1014 //TODO error handling 1015 #endif 1016 return; 1017 } 1018 } 1019 - qDebug() << "Unhandled response: " << response.toString().constData(); 1020 + kDebug() << "Unhandled response: " << response.toString().constData(); 1021 1022 } 1023 } 1024 1025 #include "expungejob.moc" 1026 + 1027 diff --git a/kimap/expungejob.h b/kimap/expungejob.h 1028 index 9862f59..7e2918b 100644 1029 --- a/kimap/expungejob.h 1030 +++ b/kimap/expungejob.h 1031 @@ -45,7 +45,7 @@ class ExpungeJobPrivate; 1032 class KIMAP_EXPORT ExpungeJob : public Job 1033 { 1034 Q_OBJECT 1035 - Q_DECLARE_PRIVATE(ExpungeJob) 1036 + Q_DECLARE_PRIVATE( ExpungeJob ) 1037 1038 friend class SessionPrivate; 1039 1040 diff --git a/kimap/fetchjob.cpp b/kimap/fetchjob.cpp 1041 index 32582b2..bbb12a4 100644 1042 --- a/kimap/fetchjob.cpp 1043 +++ b/kimap/fetchjob.cpp 1044 @@ -20,8 +20,8 @@ 1045 #include "fetchjob.h" 1046 1047 #include <QtCore/QTimer> 1048 -#include <kdebug.h> 1049 -#include <klocale.h> 1050 +#include <KDE/KDebug> 1051 +#include <KDE/KLocalizedString> 1052 1053 #include "job_p.h" 1054 #include "message_p.h" 1055 @@ -32,7 +32,7 @@ namespace KIMAP 1056 class FetchJobPrivate : public JobPrivate 1057 { 1058 public: 1059 - FetchJobPrivate( FetchJob *job, Session *session, const QString& name ) : JobPrivate( session, name ), q(job), uidBased(false) { } 1060 + FetchJobPrivate( FetchJob *job, Session *session, const QString& name ) : JobPrivate( session, name ), q( job ), uidBased( false ) { } 1061 ~FetchJobPrivate() { } 1062 1063 void parseBodyStructure( const QByteArray &structure, int &pos, KMime::Content *content ); 1064 @@ -87,9 +87,9 @@ namespace KIMAP 1065 using namespace KIMAP; 1066 1067 FetchJob::FetchJob( Session *session ) 1068 - : Job( *new FetchJobPrivate(this, session, i18n("Fetch")) ) 1069 + : Job( *new FetchJobPrivate( this, session, i18n( "Fetch" ) ) ) 1070 { 1071 - Q_D(FetchJob); 1072 + Q_D( FetchJob ); 1073 d->scope.mode = FetchScope::Content; 1074 connect( &d->emitPendingsTimer, SIGNAL(timeout()), 1075 this, SLOT(emitPendings()) ); 1076 @@ -101,38 +101,38 @@ FetchJob::~FetchJob() 1077 1078 void FetchJob::setSequenceSet( const ImapSet &set ) 1079 { 1080 - Q_D(FetchJob); 1081 + Q_D( FetchJob ); 1082 Q_ASSERT( !set.toImapSequenceSet().trimmed().isEmpty() ); 1083 d->set = set; 1084 } 1085 1086 ImapSet FetchJob::sequenceSet() const 1087 { 1088 - Q_D(const FetchJob); 1089 + Q_D( const FetchJob ); 1090 return d->set; 1091 } 1092 1093 void FetchJob::setUidBased(bool uidBased) 1094 { 1095 - Q_D(FetchJob); 1096 + Q_D( FetchJob ); 1097 d->uidBased = uidBased; 1098 } 1099 1100 bool FetchJob::isUidBased() const 1101 { 1102 - Q_D(const FetchJob); 1103 + Q_D( const FetchJob ); 1104 return d->uidBased; 1105 } 1106 1107 void FetchJob::setScope( const FetchScope &scope ) 1108 { 1109 - Q_D(FetchJob); 1110 + Q_D( FetchJob ); 1111 d->scope = scope; 1112 } 1113 1114 FetchJob::FetchScope FetchJob::scope() const 1115 { 1116 - Q_D(const FetchJob); 1117 + Q_D( const FetchJob ); 1118 return d->scope; 1119 } 1120 1121 @@ -163,7 +163,7 @@ QMap<qint64, qint64> FetchJob::uids() const 1122 1123 void FetchJob::doStart() 1124 { 1125 - Q_D(FetchJob); 1126 + Q_D( FetchJob ); 1127 1128 QByteArray parameters = d->set.toImapSequenceSet()+' '; 1129 Q_ASSERT( !parameters.trimmed().isEmpty() ); 1130 @@ -171,51 +171,51 @@ void FetchJob::doStart() 1131 switch ( d->scope.mode ) { 1132 case FetchScope::Headers: 1133 if ( d->scope.parts.isEmpty() ) { 1134 - parameters+="(RFC822.SIZE INTERNALDATE BODY.PEEK[HEADER.FIELDS (TO FROM MESSAGE-ID REFERENCES IN-REPLY-TO SUBJECT DATE)] FLAGS UID)"; 1135 + parameters += "(RFC822.SIZE INTERNALDATE BODY.PEEK[HEADER.FIELDS (TO FROM MESSAGE-ID REFERENCES IN-REPLY-TO SUBJECT DATE)] FLAGS UID)"; 1136 } else { 1137 - parameters+='('; 1138 + parameters += '('; 1139 foreach ( const QByteArray &part, d->scope.parts ) { 1140 - parameters+="BODY.PEEK["+part+".MIME] "; 1141 + parameters += "BODY.PEEK[" + part + ".MIME] "; 1142 } 1143 - parameters+="UID)"; 1144 + parameters += "UID)"; 1145 } 1146 break; 1147 case FetchScope::Flags: 1148 - parameters+="(FLAGS UID)"; 1149 + parameters += "(FLAGS UID)"; 1150 break; 1151 case FetchScope::Structure: 1152 - parameters+="(BODYSTRUCTURE UID)"; 1153 + parameters += "(BODYSTRUCTURE UID)"; 1154 break; 1155 case FetchScope::Content: 1156 if ( d->scope.parts.isEmpty() ) { 1157 - parameters+="(BODY.PEEK[] UID)"; 1158 + parameters += "(BODY.PEEK[] UID)"; 1159 } else { 1160 - parameters+='('; 1161 + parameters += '('; 1162 foreach ( const QByteArray &part, d->scope.parts ) { 1163 - parameters+="BODY.PEEK["+part+"] "; 1164 + parameters += "BODY.PEEK[" + part + "] "; 1165 } 1166 - parameters+="UID)"; 1167 + parameters += "UID)"; 1168 } 1169 break; 1170 case FetchScope::Full: 1171 - parameters+="(RFC822.SIZE INTERNALDATE BODY.PEEK[] FLAGS UID)"; 1172 + parameters += "(RFC822.SIZE INTERNALDATE BODY.PEEK[] FLAGS UID)"; 1173 break; 1174 case FetchScope::HeaderAndContent: 1175 if ( d->scope.parts.isEmpty() ) { 1176 - parameters+="(BODY.PEEK[] FLAGS UID)"; 1177 + parameters += "(BODY.PEEK[] FLAGS UID)"; 1178 } else { 1179 - parameters+="(BODY.PEEK[HEADER.FIELDS (TO FROM MESSAGE-ID REFERENCES IN-REPLY-TO SUBJECT DATE)]"; 1180 + parameters += "(BODY.PEEK[HEADER.FIELDS (TO FROM MESSAGE-ID REFERENCES IN-REPLY-TO SUBJECT DATE)]"; 1181 foreach ( const QByteArray &part, d->scope.parts ) { 1182 - parameters+=" BODY.PEEK["+part+".MIME] BODY.PEEK["+part+"]"; //krazy:exclude=doublequote_chars 1183 + parameters += " BODY.PEEK[" + part + ".MIME] BODY.PEEK[" + part + "]"; //krazy:exclude=doublequote_chars 1184 } 1185 - parameters+=" FLAGS UID)"; 1186 + parameters += " FLAGS UID)"; 1187 } 1188 break; 1189 } 1190 1191 QByteArray command = "FETCH"; 1192 if ( d->uidBased ) { 1193 - command = "UID "+command; 1194 + command = "UID " + command; 1195 } 1196 1197 d->emitPendingsTimer.start( 100 ); 1198 @@ -225,21 +225,21 @@ void FetchJob::doStart() 1199 1200 void FetchJob::handleResponse( const Message &response ) 1201 { 1202 - Q_D(FetchJob); 1203 + Q_D( FetchJob ); 1204 1205 // We can predict it'll be handled by handleErrorReplies() so stop 1206 // the timer now so that result() will really be the last emitted signal. 1207 - if ( !response.content.isEmpty() 1208 - && d->tags.size() == 1 1209 - && d->tags.contains( response.content.first().toString() ) ) { 1210 + if ( !response.content.isEmpty() && 1211 + d->tags.size() == 1 && 1212 + d->tags.contains( response.content.first().toString() ) ) { 1213 d->emitPendingsTimer.stop(); 1214 d->emitPendings(); 1215 } 1216 1217 - if (handleErrorReplies(response) == NotHandled ) { 1218 - if ( response.content.size() == 4 1219 - && response.content[2].toString()=="FETCH" 1220 - && response.content[3].type()==Message::Part::List ) { 1221 + if ( handleErrorReplies( response ) == NotHandled ) { 1222 + if ( response.content.size() == 4 && 1223 + response.content[2].toString() == "FETCH" && 1224 + response.content[3].type() == Message::Part::List ) { 1225 1226 qint64 id = response.content[1].toString().toLongLong(); 1227 QList<QByteArray> content = response.content[3].toList(); 1228 @@ -249,67 +249,69 @@ void FetchJob::handleResponse( const Message &response ) 1229 MessageParts parts; 1230 1231 for ( QList<QByteArray>::ConstIterator it = content.constBegin(); 1232 - it!=content.constEnd(); ++it ) { 1233 + it != content.constEnd(); ++it ) { 1234 QByteArray str = *it; 1235 ++it; 1236 1237 - if ( it==content.constEnd() ) { // Uh oh, message was truncated? 1238 + if ( it == content.constEnd() ) { // Uh oh, message was truncated? 1239 kWarning() << "FETCH reply got truncated, skipping."; 1240 break; 1241 } 1242 1243 - if ( str=="UID" ) { 1244 + if ( str == "UID" ) { 1245 d->pendingUids[id] = it->toLongLong(); 1246 - } else if ( str=="RFC822.SIZE" ) { 1247 + } else if ( str == "RFC822.SIZE" ) { 1248 d->pendingSizes[id] = it->toLongLong(); 1249 - } else if ( str=="INTERNALDATE" ) { 1250 + } else if ( str == "INTERNALDATE" ) { 1251 message->date()->setDateTime( KDateTime::fromString( *it, KDateTime::RFCDate ) ); 1252 - } else if ( str=="FLAGS" ) { 1253 - if ( (*it).startsWith('(') && (*it).endsWith(')') ) { 1254 + } else if ( str == "FLAGS" ) { 1255 + if ( ( *it ).startsWith( '(' ) && ( *it ).endsWith( ')' ) ) { 1256 QByteArray str = *it; 1257 - str.chop(1); 1258 - str.remove(0, 1); 1259 - d->pendingFlags[id] = str.split(' '); 1260 + str.chop( 1 ); 1261 + str.remove( 0, 1 ); 1262 + d->pendingFlags[id] = str.split( ' ' ); 1263 } else { 1264 d->pendingFlags[id] << *it; 1265 } 1266 - } else if ( str=="BODYSTRUCTURE" ) { 1267 + } else if ( str == "BODYSTRUCTURE" ) { 1268 int pos = 0; 1269 - d->parseBodyStructure(*it, pos, message.get()); 1270 + d->parseBodyStructure( *it, pos, message.get() ); 1271 message->assemble(); 1272 d->pendingMessages[id] = message; 1273 - } else if ( str.startsWith( "BODY[") ) { //krazy:exclude=strings 1274 - if ( !str.endsWith(']') ) { // BODY[ ... ] might have been split, skip until we find the ] 1275 - while ( !(*it).endsWith(']') ) ++it; 1276 + } else if ( str.startsWith( "BODY[" ) ) { //krazy:exclude=strings 1277 + if ( !str.endsWith( ']' ) ) { // BODY[ ... ] might have been split, skip until we find the ] 1278 + while ( !( *it ).endsWith( ']' ) ) { 1279 + ++it; 1280 + } 1281 ++it; 1282 } 1283 1284 int index; 1285 - if ( (index=str.indexOf("HEADER"))>0 || (index=str.indexOf("MIME"))>0 ) { // headers 1286 - if ( str[index-1]=='.' ) { 1287 - QByteArray partId = str.mid( 5, index-6 ); 1288 + if ( ( index = str.indexOf( "HEADER" ) ) > 0 || ( index = str.indexOf( "MIME" ) ) > 0 ) { // headers 1289 + if ( str[index-1] == '.' ) { 1290 + QByteArray partId = str.mid( 5, index - 6 ); 1291 if ( !parts.contains( partId ) ) { 1292 parts[partId] = ContentPtr( new KMime::Content ); 1293 } 1294 - parts[partId]->setHead(*it); 1295 + parts[partId]->setHead( *it ); 1296 parts[partId]->parse(); 1297 d->pendingParts[id] = parts; 1298 } else { 1299 - message->setHead(*it); 1300 + message->setHead( *it ); 1301 shouldParseMessage = true; 1302 } 1303 } else { // full payload 1304 - if ( str=="BODY[]" ) { 1305 - message->setContent( KMime::CRLFtoLF(*it) ); 1306 + if ( str == "BODY[]" ) { 1307 + message->setContent( KMime::CRLFtoLF( *it ) ); 1308 shouldParseMessage = true; 1309 1310 d->pendingMessages[id] = message; 1311 } else { 1312 - QByteArray partId = str.mid( 5, str.size()-6 ); 1313 + QByteArray partId = str.mid( 5, str.size() - 6 ); 1314 if ( !parts.contains( partId ) ) { 1315 parts[partId] = ContentPtr( new KMime::Content ); 1316 } 1317 - parts[partId]->setBody(*it); 1318 + parts[partId]->setBody( *it ); 1319 parts[partId]->parse(); 1320 1321 d->pendingParts[id] = parts; 1322 @@ -334,21 +336,20 @@ void FetchJob::handleResponse( const Message &response ) 1323 1324 void FetchJobPrivate::parseBodyStructure(const QByteArray &structure, int &pos, KMime::Content *content) 1325 { 1326 - skipLeadingSpaces(structure, pos); 1327 + skipLeadingSpaces( structure, pos ); 1328 1329 - if ( structure[pos]!='(' ) { 1330 + if ( structure[pos] != '(' ) { 1331 return; 1332 } 1333 1334 pos++; 1335 1336 - 1337 - if ( structure[pos]!='(' ) { // simple part 1338 + if ( structure[pos] != '(' ) { // simple part 1339 pos--; 1340 parsePart( structure, pos, content ); 1341 } else { // multi part 1342 - content->contentType()->setMimeType("MULTIPART/MIXED"); 1343 - while ( pos<structure.size() && structure[pos]=='(' ) { 1344 + content->contentType()->setMimeType( "MULTIPART/MIXED" ); 1345 + while ( pos < structure.size() && structure[pos] == '(' ) { 1346 KMime::Content *child = new KMime::Content; 1347 content->addContent( child ); 1348 parseBodyStructure( structure, pos, child ); 1349 @@ -356,17 +357,17 @@ void FetchJobPrivate::parseBodyStructure(const QByteArray &structure, int &pos, 1350 } 1351 1352 QByteArray subType = parseString( structure, pos ); 1353 - content->contentType()->setMimeType( "MULTIPART/"+subType ); 1354 + content->contentType()->setMimeType( "MULTIPART/" + subType ); 1355 1356 QByteArray parameters = parseSentence( structure, pos ); // FIXME: Read the charset 1357 - if (parameters.contains("BOUNDARY") ) { 1358 - content->contentType()->setBoundary(parameters.remove(0, parameters.indexOf("BOUNDARY") + 11).split('\"')[0]); 1359 + if ( parameters.contains( "BOUNDARY" ) ) { 1360 + content->contentType()->setBoundary( parameters.remove( 0, parameters.indexOf( "BOUNDARY" ) + 11 ).split( '\"' )[0] ); 1361 } 1362 1363 QByteArray disposition = parseSentence( structure, pos ); 1364 - if ( disposition.contains("INLINE") ) { 1365 + if ( disposition.contains( "INLINE" ) ) { 1366 content->contentDisposition()->setDisposition( KMime::Headers::CDinline ); 1367 - } else if ( disposition.contains("ATTACHMENT") ) { 1368 + } else if ( disposition.contains( "ATTACHMENT" ) ) { 1369 content->contentDisposition()->setDisposition( KMime::Headers::CDattachment ); 1370 } 1371 1372 @@ -374,7 +375,7 @@ void FetchJobPrivate::parseBodyStructure(const QByteArray &structure, int &pos, 1373 } 1374 1375 // Consume what's left 1376 - while ( pos<structure.size() && structure[pos]!=')' ) { 1377 + while ( pos < structure.size() && structure[pos] != ')' ) { 1378 skipLeadingSpaces( structure, pos ); 1379 parseSentence( structure, pos ); 1380 skipLeadingSpaces( structure, pos ); 1381 @@ -385,7 +386,7 @@ void FetchJobPrivate::parseBodyStructure(const QByteArray &structure, int &pos, 1382 1383 void FetchJobPrivate::parsePart( const QByteArray &structure, int &pos, KMime::Content *content ) 1384 { 1385 - if ( structure[pos]!='(' ) { 1386 + if ( structure[pos] != '(' ) { 1387 return; 1388 } 1389 1390 @@ -394,7 +395,7 @@ void FetchJobPrivate::parsePart( const QByteArray &structure, int &pos, KMime::C 1391 QByteArray mainType = parseString( structure, pos ); 1392 QByteArray subType = parseString( structure, pos ); 1393 1394 - content->contentType()->setMimeType( mainType+'/'+subType ); 1395 + content->contentType()->setMimeType( mainType + '/' + subType ); 1396 1397 parseSentence( structure, pos ); // Ditch the parameters... FIXME: Read it to get charset and name 1398 parseString( structure, pos ); // ... and the id 1399 @@ -406,20 +407,20 @@ void FetchJobPrivate::parsePart( const QByteArray &structure, int &pos, KMime::C 1400 parseString( structure, pos ); // ... and the line count 1401 1402 QByteArray disposition = parseSentence( structure, pos ); 1403 - if ( disposition.contains("INLINE") ) { 1404 + if ( disposition.contains( "INLINE" ) ) { 1405 content->contentDisposition()->setDisposition( KMime::Headers::CDinline ); 1406 - } else if ( disposition.contains("ATTACHMENT") ) { 1407 + } else if ( disposition.contains( "ATTACHMENT" ) ) { 1408 content->contentDisposition()->setDisposition( KMime::Headers::CDattachment ); 1409 } 1410 - if ( (content->contentDisposition()->disposition() == KMime::Headers::CDattachment 1411 - || content->contentDisposition()->disposition() == KMime::Headers::CDinline) 1412 - && disposition.contains("FILENAME") ) { 1413 - QByteArray filename = disposition.remove(0, disposition.indexOf("FILENAME") + 11).split('\"')[0]; 1414 + if ( ( content->contentDisposition()->disposition() == KMime::Headers::CDattachment || 1415 + content->contentDisposition()->disposition() == KMime::Headers::CDinline ) && 1416 + disposition.contains( "FILENAME" ) ) { 1417 + QByteArray filename = disposition.remove( 0, disposition.indexOf( "FILENAME" ) + 11 ).split( '\"' )[0]; 1418 content->contentDisposition()->setFilename( filename ); 1419 } 1420 1421 // Consume what's left 1422 - while ( pos<structure.size() && structure[pos]!=')' ) { 1423 + while ( pos < structure.size() && structure[pos] != ')' ) { 1424 skipLeadingSpaces( structure, pos ); 1425 parseSentence( structure, pos ); 1426 skipLeadingSpaces( structure, pos ); 1427 @@ -433,7 +434,7 @@ QByteArray FetchJobPrivate::parseSentence( const QByteArray &structure, int &pos 1428 1429 skipLeadingSpaces( structure, pos ); 1430 1431 - if ( structure[pos]!='(' ) { 1432 + if ( structure[pos] != '(' ) { 1433 return parseString( structure, pos ); 1434 } 1435 1436 @@ -458,12 +459,12 @@ QByteArray FetchJobPrivate::parseSentence( const QByteArray &structure, int &pos 1437 stack--; 1438 break; 1439 default: 1440 - skipLeadingSpaces(structure, pos); 1441 - parseString(structure, pos); 1442 - skipLeadingSpaces(structure, pos); 1443 + skipLeadingSpaces( structure, pos ); 1444 + parseString( structure, pos ); 1445 + skipLeadingSpaces( structure, pos ); 1446 break; 1447 } 1448 - } while ( pos<structure.size() && stack!=0 ); 1449 + } while ( pos < structure.size() && stack != 0 ); 1450 1451 result = structure.mid( start, pos - start ); 1452 1453 @@ -484,12 +485,12 @@ QByteArray FetchJobPrivate::parseString( const QByteArray &structure, int &pos ) 1454 pos++; 1455 Q_FOREVER { 1456 if ( structure[pos] == '\\' ) { 1457 - pos+= 2; 1458 + pos += 2; 1459 foundSlash = true; 1460 continue; 1461 } 1462 if ( structure[pos] == '"' ) { 1463 - result = structure.mid( start+1, pos - start - 1); 1464 + result = structure.mid( start + 1, pos - start - 1 ); 1465 pos++; 1466 break; 1467 } 1468 @@ -497,27 +498,38 @@ QByteArray FetchJobPrivate::parseString( const QByteArray &structure, int &pos ) 1469 } 1470 } else { // unquoted string 1471 Q_FOREVER { 1472 - if ( structure[pos] == ' ' || structure[pos] == '(' || structure[pos] == ')' || structure[pos] == '[' || structure[pos] == ']' || structure[pos] == '\n' || structure[pos] == '\r' || structure[pos] == '"') { 1473 + if ( structure[pos] == ' ' || 1474 + structure[pos] == '(' || 1475 + structure[pos] == ')' || 1476 + structure[pos] == '[' || 1477 + structure[pos] == ']' || 1478 + structure[pos] == '\n' || 1479 + structure[pos] == '\r' || 1480 + structure[pos] == '"' ) { 1481 break; 1482 } 1483 - if (structure[pos] == '\\') 1484 + if ( structure[pos] == '\\' ) { 1485 foundSlash = true; 1486 + } 1487 pos++; 1488 } 1489 1490 result = structure.mid( start, pos - start ); 1491 1492 // transform unquoted NIL 1493 - if ( result == "NIL" ) 1494 + if ( result == "NIL" ) { 1495 result.clear(); 1496 + } 1497 } 1498 1499 // simplify slashes 1500 if ( foundSlash ) { 1501 - while ( result.contains( "\\\"" ) ) 1502 + while ( result.contains( "\\\"" ) ) { 1503 result.replace( "\\\"", "\"" ); 1504 - while ( result.contains( "\\\\" ) ) 1505 + } 1506 + while ( result.contains( "\\\\" ) ) { 1507 result.replace( "\\\\", "\\" ); 1508 + } 1509 } 1510 1511 return result; 1512 @@ -525,7 +537,10 @@ QByteArray FetchJobPrivate::parseString( const QByteArray &structure, int &pos ) 1513 1514 void FetchJobPrivate::skipLeadingSpaces( const QByteArray &structure, int &pos ) 1515 { 1516 - while ( structure[pos]==' ' && pos<structure.size() ) pos++; 1517 + while ( pos < structure.size() && structure[pos] == ' ' ) { 1518 + pos++; 1519 + } 1520 } 1521 1522 #include "fetchjob.moc" 1523 + 1524 diff --git a/kimap/fetchjob.h b/kimap/fetchjob.h 1525 index aa31d2d..75fe6b6 100644 1526 --- a/kimap/fetchjob.h 1527 +++ b/kimap/fetchjob.h 1528 @@ -56,7 +56,7 @@ typedef QList<QByteArray> MessageFlags; 1529 class KIMAP_EXPORT FetchJob : public Job 1530 { 1531 Q_OBJECT 1532 - Q_DECLARE_PRIVATE(FetchJob) 1533 + Q_DECLARE_PRIVATE( FetchJob ) 1534 1535 friend class SessionPrivate; 1536 1537 diff --git a/kimap/getacljob.cpp b/kimap/getacljob.cpp 1538 index fbe8d80..b218776 100644 1539 --- a/kimap/getacljob.cpp 1540 +++ b/kimap/getacljob.cpp 1541 @@ -19,8 +19,8 @@ 1542 1543 #include "getacljob.h" 1544 1545 -#include <klocale.h> 1546 -#include <kdebug.h> 1547 +#include <KDE/KLocalizedString> 1548 +#include <KDE/KDebug> 1549 1550 #include "acljobbase_p.h" 1551 #include "message_p.h" 1552 @@ -32,7 +32,7 @@ namespace KIMAP 1553 class GetAclJobPrivate : public AclJobBasePrivate 1554 { 1555 public: 1556 - GetAclJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate(session, name) {} 1557 + GetAclJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate( session, name ) {} 1558 ~GetAclJobPrivate() { } 1559 1560 QMap<QByteArray, Acl::Rights> userRights; 1561 @@ -42,7 +42,7 @@ namespace KIMAP 1562 using namespace KIMAP; 1563 1564 GetAclJob::GetAclJob( Session *session ) 1565 - : AclJobBase( *new GetAclJobPrivate(session, i18n("GetAcl") )) 1566 + : AclJobBase( *new GetAclJobPrivate( session, i18n( "GetAcl" ) ) ) 1567 { 1568 } 1569 1570 @@ -52,24 +52,24 @@ GetAclJob::~GetAclJob() 1571 1572 void GetAclJob::doStart() 1573 { 1574 - Q_D(GetAclJob); 1575 + Q_D( GetAclJob ); 1576 1577 - d->tags << d->sessionInternal()->sendCommand( "GETACL", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"'); 1578 + d->tags << d->sessionInternal()->sendCommand( "GETACL", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"' ); 1579 } 1580 1581 void GetAclJob::handleResponse( const Message &response ) 1582 { 1583 - Q_D(GetAclJob); 1584 -// qDebug() << response.toString(); 1585 + Q_D( GetAclJob ); 1586 +// kDebug() << response.toString(); 1587 1588 - if (handleErrorReplies(response) == NotHandled) { 1589 - if ( response.content.size() >= 4 1590 - && response.content[1].toString() == "ACL" ) { 1591 + if ( handleErrorReplies( response ) == NotHandled ) { 1592 + if ( response.content.size() >= 4 && 1593 + response.content[1].toString() == "ACL" ) { 1594 int i = 3; 1595 while ( i < response.content.size() - 1 ) { 1596 QByteArray id = response.content[i].toString(); 1597 QByteArray rights = response.content[i + 1].toString(); 1598 - d->userRights[id] = Acl::rightsFromString(rights); 1599 + d->userRights[id] = Acl::rightsFromString( rights ); 1600 i += 2; 1601 } 1602 } 1603 @@ -78,15 +78,14 @@ void GetAclJob::handleResponse( const Message &response ) 1604 1605 QList<QByteArray> GetAclJob::identifiers() const 1606 { 1607 - Q_D(const GetAclJob); 1608 + Q_D( const GetAclJob ); 1609 return d->userRights.keys(); 1610 } 1611 1612 bool GetAclJob::hasRightEnabled(const QByteArray &identifier, Acl::Right right) const 1613 { 1614 - Q_D(const GetAclJob); 1615 - if (d->userRights.contains(identifier)) 1616 - { 1617 + Q_D( const GetAclJob ); 1618 + if ( d->userRights.contains( identifier ) ) { 1619 Acl::Rights rights = d->userRights[identifier]; 1620 return rights & right; 1621 } 1622 @@ -96,10 +95,9 @@ bool GetAclJob::hasRightEnabled(const QByteArray &identifier, Acl::Right right) 1623 1624 Acl::Rights GetAclJob::rights(const QByteArray &identifier) const 1625 { 1626 - Q_D(const GetAclJob); 1627 + Q_D( const GetAclJob ); 1628 Acl::Rights result; 1629 - if (d->userRights.contains(identifier)) 1630 - { 1631 + if ( d->userRights.contains( identifier ) ) { 1632 result = d->userRights[identifier]; 1633 } 1634 return result; 1635 @@ -107,8 +105,9 @@ Acl::Rights GetAclJob::rights(const QByteArray &identifier) const 1636 1637 QMap<QByteArray, Acl::Rights> GetAclJob::allRights() const 1638 { 1639 - Q_D(const GetAclJob); 1640 + Q_D( const GetAclJob ); 1641 return d->userRights; 1642 } 1643 1644 -#include "getacljob.moc" 1645 \ No newline at end of file 1646 +#include "getacljob.moc" 1647 + 1648 diff --git a/kimap/getacljob.h b/kimap/getacljob.h 1649 index dd652d2..77a6648 100644 1650 --- a/kimap/getacljob.h 1651 +++ b/kimap/getacljob.h 1652 @@ -30,7 +30,6 @@ class Session; 1653 struct Message; 1654 class GetAclJobPrivate; 1655 1656 - 1657 /** 1658 * Gets the ACL for a mailbox 1659 * 1660 @@ -63,7 +62,7 @@ class GetAclJobPrivate; 1661 class KIMAP_EXPORT GetAclJob : public AclJobBase 1662 { 1663 Q_OBJECT 1664 - Q_DECLARE_PRIVATE(GetAclJob) 1665 + Q_DECLARE_PRIVATE( GetAclJob ) 1666 1667 friend class SessionPrivate; 1668 1669 diff --git a/kimap/getmetadatajob.cpp b/kimap/getmetadatajob.cpp 1670 index 69be41d..4dddce3 100644 1671 --- a/kimap/getmetadatajob.cpp 1672 +++ b/kimap/getmetadatajob.cpp 1673 @@ -19,8 +19,8 @@ 1674 1675 #include "getmetadatajob.h" 1676 1677 -#include <klocale.h> 1678 -#include <kdebug.h> 1679 +#include <KDE/KLocalizedString> 1680 +#include <KDE/KDebug> 1681 1682 #include "metadatajobbase_p.h" 1683 #include "message_p.h" 1684 @@ -32,7 +32,7 @@ namespace KIMAP 1685 class GetMetaDataJobPrivate : public MetaDataJobBasePrivate 1686 { 1687 public: 1688 - GetMetaDataJobPrivate( Session *session, const QString& name ) : MetaDataJobBasePrivate(session, name), maxSize(-1), depth("0") { } 1689 + GetMetaDataJobPrivate( Session *session, const QString& name ) : MetaDataJobBasePrivate( session, name ), maxSize( -1 ), depth( "0" ) { } 1690 ~GetMetaDataJobPrivate() { } 1691 1692 qint64 maxSize; 1693 @@ -47,7 +47,7 @@ namespace KIMAP 1694 using namespace KIMAP; 1695 1696 GetMetaDataJob::GetMetaDataJob( Session *session ) 1697 - : MetaDataJobBase( *new GetMetaDataJobPrivate(session, i18n("GetMetaData")) ) 1698 + : MetaDataJobBase( *new GetMetaDataJobPrivate( session, i18n( "GetMetaData" ) ) ) 1699 { 1700 } 1701 1702 @@ -57,94 +57,100 @@ GetMetaDataJob::~GetMetaDataJob() 1703 1704 void GetMetaDataJob::doStart() 1705 { 1706 - Q_D(GetMetaDataJob); 1707 + Q_D( GetMetaDataJob ); 1708 QByteArray parameters; 1709 parameters = '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + "\" "; 1710 1711 QByteArray command = "GETMETADATA"; 1712 - if (d->serverCapability == Annotatemore) { 1713 - d->m_name = i18n("GetAnnotation"); 1714 + if ( d->serverCapability == Annotatemore ) { 1715 + d->m_name = i18n( "GetAnnotation" ); 1716 command = "GETANNOTATION"; 1717 - if (d->entries.size() > 1) 1718 + if ( d->entries.size() > 1 ) { 1719 parameters += '('; 1720 - Q_FOREACH(const QByteArray &entry, d->entries) { 1721 + } 1722 + Q_FOREACH ( const QByteArray &entry, d->entries ) { 1723 parameters += '\"' + entry + "\" "; 1724 } 1725 - if (d->entries.size() > 1) 1726 - parameters[parameters.length() -1 ] = ')'; 1727 - else 1728 - parameters.truncate(parameters.length() -1); 1729 + if ( d->entries.size() > 1 ) { 1730 + parameters[parameters.length() - 1 ] = ')'; 1731 + } else { 1732 + parameters.truncate( parameters.length() - 1 ); 1733 + } 1734 1735 parameters += ' '; 1736 1737 - if (d->attributes.size() > 1) 1738 + if ( d->attributes.size() > 1 ) { 1739 parameters += '('; 1740 - Q_FOREACH(const QByteArray &attribute, d->attributes) { 1741 + } 1742 + Q_FOREACH ( const QByteArray &attribute, d->attributes ) { 1743 parameters += '\"' + attribute + "\" "; 1744 } 1745 - if (d->attributes.size() > 1) 1746 - parameters[parameters.length() -1 ] = ')'; 1747 - else 1748 - parameters.truncate(parameters.length() -1); 1749 + if ( d->attributes.size() > 1 ) { 1750 + parameters[parameters.length() - 1 ] = ')'; 1751 + } else { 1752 + parameters.truncate( parameters.length() - 1 ); 1753 + } 1754 1755 } else { 1756 - if (d->depth != "0") { 1757 + if ( d->depth != "0" ) { 1758 parameters += "(DEPTH " + d->depth; 1759 } 1760 - if (d->maxSize != -1) { 1761 - parameters += "(MAXSIZE " + QByteArray::number(d->maxSize) + ')'; 1762 + if ( d->maxSize != -1 ) { 1763 + parameters += "(MAXSIZE " + QByteArray::number( d->maxSize ) + ')'; 1764 } 1765 - if (d->depth != "0") { 1766 + if ( d->depth != "0" ) { 1767 parameters += " )"; 1768 } 1769 1770 - if (d->entries.size() > 1) 1771 + if ( d->entries.size() > 1 ) { 1772 parameters += '('; 1773 - Q_FOREACH(const QByteArray &entry, d->entries) { 1774 + } 1775 + Q_FOREACH ( const QByteArray &entry, d->entries ) { 1776 parameters += '\"' + entry + "\" "; 1777 } 1778 - if (d->entries.size() > 1) 1779 - parameters[parameters.length() -1 ] = ')'; 1780 + if ( d->entries.size() > 1 ) { 1781 + parameters[parameters.length() - 1 ] = ')'; 1782 + } 1783 } 1784 1785 - if (d->entries.isEmpty()) { 1786 + if ( d->entries.isEmpty() ) { { 1787 parameters += ')'; 1788 } 1789 + } 1790 1791 d->tags << d->sessionInternal()->sendCommand( command, parameters ); 1792 -// qDebug() << "SENT: " << command << " " << parameters; 1793 +// kDebug() << "SENT: " << command << " " << parameters; 1794 } 1795 1796 void GetMetaDataJob::handleResponse( const Message &response ) 1797 { 1798 - Q_D(GetMetaDataJob); 1799 -// qDebug() << "GOT: " << response.toString(); 1800 + Q_D( GetMetaDataJob ); 1801 +// kDebug() << "GOT: " << response.toString(); 1802 1803 //TODO: handle NO error messages having [METADATA MAXSIZE NNN], [METADATA TOOMANY], [METADATA NOPRIVATE] (see rfc5464) 1804 // or [ANNOTATEMORE TOOBIG], [ANNOTATEMORE TOOMANY] respectively 1805 - if (handleErrorReplies(response) == NotHandled ) { 1806 + if ( handleErrorReplies( response ) == NotHandled ) { 1807 if ( response.content.size() >= 4 ) { 1808 - if (d->serverCapability == Annotatemore && response.content[1].toString() == "ANNOTATION" ) { 1809 + if ( d->serverCapability == Annotatemore && response.content[1].toString() == "ANNOTATION" ) { 1810 QString mailBox = QString::fromUtf8( KIMAP::decodeImapFolderName( response.content[2].toString() ) ); 1811 1812 int i = 3; 1813 - while (i < response.content.size() - 1) { 1814 + while ( i < response.content.size() - 1 ) { 1815 QByteArray entry = response.content[i].toString(); 1816 QList<QByteArray> attributes = response.content[i + 1].toList(); 1817 int j = 0; 1818 - while ( j < attributes.size() - 1) { 1819 + while ( j < attributes.size() - 1 ) { 1820 d->metadata[mailBox][entry][attributes[j]] = attributes[j + 1]; 1821 j += 2; 1822 } 1823 i += 2; 1824 } 1825 - } else 1826 - if (d->serverCapability == Metadata && response.content[1].toString() == "METADATA" ) { 1827 + } else if ( d->serverCapability == Metadata && response.content[1].toString() == "METADATA" ) { 1828 QString mailBox = QString::fromUtf8( KIMAP::decodeImapFolderName( response.content[2].toString() ) ); 1829 1830 QList<QByteArray> entries = response.content[3].toList(); 1831 int i = 0; 1832 - while ( i < entries.size() - 1) { 1833 + while ( i < entries.size() - 1 ) { 1834 d->metadata[mailBox][entries[i]][""] = entries[i + 1]; 1835 i += 2; 1836 } 1837 @@ -155,25 +161,25 @@ void GetMetaDataJob::handleResponse( const Message &response ) 1838 1839 void GetMetaDataJob::addEntry(const QByteArray &entry, const QByteArray &attribute) 1840 { 1841 - Q_D(GetMetaDataJob); 1842 - if (d->serverCapability == Annotatemore && attribute.isNull()) 1843 + Q_D( GetMetaDataJob ); 1844 + if ( d->serverCapability == Annotatemore && attribute.isNull() ) { 1845 qWarning() << "In ANNOTATEMORE mode an attribute must be specified with addEntry!"; 1846 - d->entries.append(entry); 1847 - d->attributes.append(attribute); 1848 + } 1849 + d->entries.append( entry ); 1850 + d->attributes.append( attribute ); 1851 } 1852 1853 void GetMetaDataJob::setMaximumSize(qint64 size) 1854 { 1855 - Q_D(GetMetaDataJob); 1856 + Q_D( GetMetaDataJob ); 1857 d->maxSize = size; 1858 } 1859 1860 void GetMetaDataJob::setDepth(Depth depth) 1861 { 1862 - Q_D(GetMetaDataJob); 1863 + Q_D( GetMetaDataJob ); 1864 1865 - switch (depth) 1866 - { 1867 + switch ( depth ) { 1868 case OneLevel: 1869 d->depth = "1"; //krazy:exclude=doublequote_chars 1870 break; 1871 @@ -187,26 +193,27 @@ void GetMetaDataJob::setDepth(Depth depth) 1872 1873 QByteArray GetMetaDataJob::metaData(const QString &mailBox, const QByteArray &entry, const QByteArray &attribute) const 1874 { 1875 - Q_D(const GetMetaDataJob); 1876 + Q_D( const GetMetaDataJob ); 1877 QByteArray attr = attribute; 1878 1879 - if (d->serverCapability == Metadata) 1880 + if ( d->serverCapability == Metadata ) { 1881 attr = ""; 1882 + } 1883 1884 QByteArray result; 1885 - if (d->metadata.contains(mailBox)) { 1886 - if (d->metadata[mailBox].contains(entry)) { 1887 - result = d->metadata[mailBox][entry].value(attr); 1888 + if ( d->metadata.contains( mailBox ) ) { 1889 + if ( d->metadata[mailBox].contains( entry ) ) { 1890 + result = d->metadata[mailBox][entry].value( attr ); 1891 } 1892 } 1893 - 1894 return result; 1895 } 1896 1897 QMap<QByteArray, QMap<QByteArray, QByteArray> > GetMetaDataJob::allMetaData(const QString &mailBox) const 1898 { 1899 - Q_D(const GetMetaDataJob); 1900 + Q_D( const GetMetaDataJob ); 1901 return d->metadata[mailBox]; 1902 } 1903 1904 -#include "getmetadatajob.moc" 1905 \ No newline at end of file 1906 +#include "getmetadatajob.moc" 1907 + 1908 diff --git a/kimap/getquotajob.cpp b/kimap/getquotajob.cpp 1909 index 9d1efb0..35d901e 100644 1910 --- a/kimap/getquotajob.cpp 1911 +++ b/kimap/getquotajob.cpp 1912 @@ -19,8 +19,8 @@ 1913 1914 #include "getquotajob.h" 1915 1916 -#include <klocale.h> 1917 -#include <kdebug.h> 1918 +#include <KDE/KLocalizedString> 1919 +#include <KDE/KDebug> 1920 1921 #include "quotajobbase_p.h" 1922 #include "message_p.h" 1923 @@ -31,7 +31,7 @@ namespace KIMAP 1924 class GetQuotaJobPrivate : public QuotaJobBasePrivate 1925 { 1926 public: 1927 - GetQuotaJobPrivate( Session *session, const QString& name ) : QuotaJobBasePrivate(session, name) { } 1928 + GetQuotaJobPrivate( Session *session, const QString& name ) : QuotaJobBasePrivate( session, name ) { } 1929 ~GetQuotaJobPrivate() { } 1930 1931 QByteArray root; 1932 @@ -41,7 +41,7 @@ namespace KIMAP 1933 using namespace KIMAP; 1934 1935 GetQuotaJob::GetQuotaJob( Session *session ) 1936 - : QuotaJobBase( *new GetQuotaJobPrivate(session, i18n("GetQuota")) ) 1937 + : QuotaJobBase( *new GetQuotaJobPrivate( session, i18n( "GetQuota" ) ) ) 1938 { 1939 } 1940 1941 @@ -51,34 +51,33 @@ GetQuotaJob::~GetQuotaJob() 1942 1943 void GetQuotaJob::doStart() 1944 { 1945 - Q_D(GetQuotaJob); 1946 + Q_D( GetQuotaJob ); 1947 //XXX: [alexmerry, 2010-07-24]: should d->root be quoted properly? 1948 - d->tags << d->sessionInternal()->sendCommand( "GETQUOTA", '\"' + d->root + '\"'); 1949 + d->tags << d->sessionInternal()->sendCommand( "GETQUOTA", '\"' + d->root + '\"' ); 1950 } 1951 1952 void GetQuotaJob::handleResponse(const Message &response) 1953 { 1954 - Q_D(GetQuotaJob); 1955 - if (handleErrorReplies(response) == NotHandled) { 1956 - if ( response.content.size() >= 4 1957 - && response.content[1].toString() == "QUOTA" ) { 1958 - d->quota = d->readQuota(response.content[3]); 1959 + Q_D( GetQuotaJob ); 1960 + if ( handleErrorReplies( response ) == NotHandled ) { 1961 + if ( response.content.size() >= 4 && 1962 + response.content[1].toString() == "QUOTA" ) { 1963 + d->quota = d->readQuota( response.content[3] ); 1964 } 1965 } 1966 } 1967 1968 void GetQuotaJob::setRoot(const QByteArray& root) 1969 { 1970 - Q_D(GetQuotaJob); 1971 - 1972 + Q_D( GetQuotaJob ); 1973 d->root = root; 1974 } 1975 1976 QByteArray GetQuotaJob::root() const 1977 { 1978 - Q_D(const GetQuotaJob); 1979 - 1980 + Q_D( const GetQuotaJob ); 1981 return d->root; 1982 } 1983 1984 -#include "getquotajob.moc" 1985 \ No newline at end of file 1986 +#include "getquotajob.moc" 1987 + 1988 diff --git a/kimap/getquotajob.h b/kimap/getquotajob.h 1989 index 01231ea..698450a 100644 1990 --- a/kimap/getquotajob.h 1991 +++ b/kimap/getquotajob.h 1992 @@ -50,7 +50,7 @@ class GetQuotaJobPrivate; 1993 class KIMAP_EXPORT GetQuotaJob : public QuotaJobBase 1994 { 1995 Q_OBJECT 1996 - Q_DECLARE_PRIVATE(GetQuotaJob) 1997 + Q_DECLARE_PRIVATE( GetQuotaJob ) 1998 1999 friend class SessionPrivate; 2000 2001 @@ -60,7 +60,7 @@ class KIMAP_EXPORT GetQuotaJob : public QuotaJobBase 2002 2003 /** 2004 * Set the quota root to get the resource limits for. 2005 - * 2006 + * @param root the quota root to set 2007 * @see GetQuotaRootJob 2008 */ 2009 void setRoot(const QByteArray &root); 2010 diff --git a/kimap/getquotarootjob.cpp b/kimap/getquotarootjob.cpp 2011 index ee438a3..49e7bef 100644 2012 --- a/kimap/getquotarootjob.cpp 2013 +++ b/kimap/getquotarootjob.cpp 2014 @@ -19,8 +19,8 @@ 2015 2016 #include "getquotarootjob.h" 2017 2018 -#include <klocale.h> 2019 -#include <kdebug.h> 2020 +#include <KDE/KLocalizedString> 2021 +#include <KDE/KDebug> 2022 2023 #include "quotajobbase_p.h" 2024 #include "message_p.h" 2025 @@ -32,7 +32,7 @@ namespace KIMAP 2026 class GetQuotaRootJobPrivate : public QuotaJobBasePrivate 2027 { 2028 public: 2029 - GetQuotaRootJobPrivate( Session *session, const QString& name ) : QuotaJobBasePrivate(session, name) { } 2030 + GetQuotaRootJobPrivate( Session *session, const QString& name ) : QuotaJobBasePrivate( session, name ) { } 2031 ~GetQuotaRootJobPrivate() { } 2032 2033 QString mailBox; 2034 @@ -44,7 +44,7 @@ namespace KIMAP 2035 using namespace KIMAP; 2036 2037 GetQuotaRootJob::GetQuotaRootJob( Session *session ) 2038 - : QuotaJobBase( *new GetQuotaRootJobPrivate(session, i18n("GetQuotaRoot")) ) 2039 + : QuotaJobBase( *new GetQuotaRootJobPrivate( session, i18n( "GetQuotaRoot" ) ) ) 2040 { 2041 } 2042 2043 @@ -54,43 +54,41 @@ GetQuotaRootJob::~GetQuotaRootJob() 2044 2045 void GetQuotaRootJob::doStart() 2046 { 2047 - Q_D(GetQuotaRootJob); 2048 - d->tags << d->sessionInternal()->sendCommand( "GETQUOTAROOT", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"'); 2049 + Q_D( GetQuotaRootJob ); 2050 + d->tags << d->sessionInternal()->sendCommand( "GETQUOTAROOT", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"' ); 2051 } 2052 2053 void GetQuotaRootJob::handleResponse(const Message &response) 2054 { 2055 - Q_D(GetQuotaRootJob); 2056 - if (handleErrorReplies(response) == NotHandled) { 2057 + Q_D( GetQuotaRootJob ); 2058 + if ( handleErrorReplies( response ) == NotHandled ) { 2059 if ( response.content.size() >= 3 ) { 2060 - if (response.content[1].toString() == "QUOTAROOT" ) { 2061 + if ( response.content[1].toString() == "QUOTAROOT" ) { 2062 d->rootList.clear(); 2063 //some impls don't give the root a name which for us seems as if 2064 //there were no message part 2065 if ( response.content.size() == 3 ) { 2066 - d->rootList.append(""); 2067 + d->rootList.append( "" ); 2068 } else { 2069 int i = 3; 2070 - while ( i < response.content.size()) 2071 - { 2072 - d->rootList.append(response.content[i].toString()); 2073 + while ( i < response.content.size() ) { 2074 + d->rootList.append( response.content[i].toString() ); 2075 i++; 2076 } 2077 } 2078 - } else 2079 - if (response.content[1].toString() == "QUOTA" ) { 2080 + } else if ( response.content[1].toString() == "QUOTA" ) { 2081 QByteArray rootName; 2082 int quotaContentIndex = 3; 2083 //some impls don't give the root a name in the response 2084 - if (response.content.size() == 3 ) { 2085 + if ( response.content.size() == 3 ) { 2086 quotaContentIndex = 2; 2087 } else { 2088 rootName = response.content[2].toString(); 2089 - } 2090 + } 2091 2092 const QMap<QByteArray, QPair<qint64, qint64> >& quota = d->readQuota(response.content[quotaContentIndex]); 2093 - if (d->quotas.contains(rootName)) { 2094 - d->quotas[ rootName ].unite(quota); 2095 + if ( d->quotas.contains( rootName ) ) { 2096 + d->quotas[ rootName ].unite( quota ); 2097 } else { 2098 d->quotas[ rootName ] = quota; 2099 } 2100 @@ -99,61 +97,54 @@ void GetQuotaRootJob::handleResponse(const Message &response) 2101 } 2102 } 2103 2104 - 2105 void GetQuotaRootJob::setMailBox(const QString& mailBox) 2106 { 2107 - Q_D(GetQuotaRootJob); 2108 - 2109 + Q_D( GetQuotaRootJob ); 2110 d->mailBox = mailBox; 2111 } 2112 2113 QString GetQuotaRootJob::mailBox() const 2114 { 2115 - Q_D(const GetQuotaRootJob); 2116 - 2117 + Q_D( const GetQuotaRootJob ); 2118 return d->mailBox; 2119 } 2120 2121 QList<QByteArray> GetQuotaRootJob::roots() const 2122 { 2123 - Q_D(const GetQuotaRootJob); 2124 - 2125 + Q_D( const GetQuotaRootJob ); 2126 return d->rootList; 2127 } 2128 2129 qint64 GetQuotaRootJob::usage(const QByteArray &root, const QByteArray &resource) const 2130 { 2131 - Q_D(const GetQuotaRootJob); 2132 - 2133 + Q_D( const GetQuotaRootJob ); 2134 QByteArray r = resource.toUpper(); 2135 2136 - if (d->quotas.contains(root) && d->quotas[root].contains(r)) { 2137 + if ( d->quotas.contains( root ) && d->quotas[root].contains( r ) ) { 2138 return d->quotas[root][r].first; 2139 } 2140 - 2141 return -1; 2142 } 2143 2144 qint64 GetQuotaRootJob::limit(const QByteArray &root, const QByteArray &resource) const 2145 { 2146 - Q_D(const GetQuotaRootJob); 2147 + Q_D( const GetQuotaRootJob ); 2148 2149 QByteArray r = resource.toUpper(); 2150 2151 - if (d->quotas.contains(root) && d->quotas[root].contains(r)) { 2152 + if ( d->quotas.contains( root ) && d->quotas[root].contains( r ) ) { 2153 return d->quotas[root][r].second; 2154 } 2155 - 2156 return -1; 2157 } 2158 2159 QMap<QByteArray, qint64> GetQuotaRootJob::allUsages(const QByteArray &root) const 2160 { 2161 - Q_D(const GetQuotaRootJob); 2162 + Q_D( const GetQuotaRootJob ); 2163 2164 QMap<QByteArray, qint64> result; 2165 2166 - if (d->quotas.contains(root)) { 2167 + if ( d->quotas.contains( root ) ) { 2168 const QMap< QByteArray, QPair<qint64, qint64> > quota = d->quotas[root]; 2169 QMapIterator<QByteArray, QPair<qint64, qint64> > it( quota ); 2170 while ( it.hasNext() ) { 2171 @@ -161,17 +152,16 @@ QMap<QByteArray, qint64> GetQuotaRootJob::allUsages(const QByteArray &root) cons 2172 result[it.key()] = it.value().first; 2173 } 2174 } 2175 - 2176 return result; 2177 } 2178 2179 QMap<QByteArray, qint64> GetQuotaRootJob::allLimits(const QByteArray &root) const 2180 { 2181 - Q_D(const GetQuotaRootJob); 2182 + Q_D( const GetQuotaRootJob ); 2183 2184 QMap<QByteArray, qint64> result; 2185 2186 - if (d->quotas.contains(root)) { 2187 + if ( d->quotas.contains( root ) ) { 2188 const QMap< QByteArray, QPair<qint64, qint64> > quota = d->quotas[root]; 2189 QMapIterator<QByteArray, QPair<qint64, qint64> > it( quota ); 2190 while ( it.hasNext() ) { 2191 @@ -179,8 +169,8 @@ QMap<QByteArray, qint64> GetQuotaRootJob::allLimits(const QByteArray &root) cons 2192 result[it.key()] = it.value().second; 2193 } 2194 } 2195 - 2196 return result; 2197 } 2198 2199 #include "getquotarootjob.moc" 2200 + 2201 diff --git a/kimap/getquotarootjob.h b/kimap/getquotarootjob.h 2202 index b1fa49e..3541e18 100644 2203 --- a/kimap/getquotarootjob.h 2204 +++ b/kimap/getquotarootjob.h 2205 @@ -50,7 +50,7 @@ class GetQuotaRootJobPrivate; 2206 class KIMAP_EXPORT GetQuotaRootJob : public QuotaJobBase 2207 { 2208 Q_OBJECT 2209 - Q_DECLARE_PRIVATE(GetQuotaRootJob) 2210 + Q_DECLARE_PRIVATE( GetQuotaRootJob ) 2211 2212 friend class SessionPrivate; 2213 2214 diff --git a/kimap/idlejob.cpp b/kimap/idlejob.cpp 2215 index 0248697..5f75429 100644 2216 --- a/kimap/idlejob.cpp 2217 +++ b/kimap/idlejob.cpp 2218 @@ -20,7 +20,7 @@ 2219 #include "idlejob.h" 2220 2221 #include <QtCore/QTimer> 2222 -#include <klocale.h> 2223 +#include <KDE/KLocalizedString> 2224 2225 #include "job_p.h" 2226 #include "message_p.h" 2227 @@ -32,7 +32,7 @@ namespace KIMAP 2228 { 2229 public: 2230 IdleJobPrivate( IdleJob *job, Session *session, const QString& name ) 2231 - : JobPrivate( session, name ), q(job), 2232 + : JobPrivate( session, name ), q( job ), 2233 messageCount( -1 ), recentCount( -1 ), 2234 lastMessageCount( -1 ), lastRecentCount( -1 ), 2235 originalSocketTimeout( -1 ) { } 2236 @@ -42,8 +42,8 @@ namespace KIMAP 2237 { 2238 emitStatsTimer.stop(); 2239 2240 - emit q->mailBoxStats(q, m_session->selectedMailBox(), 2241 - messageCount, recentCount); 2242 + emit q->mailBoxStats( q, m_session->selectedMailBox(), 2243 + messageCount, recentCount ); 2244 2245 lastMessageCount = messageCount; 2246 lastRecentCount = recentCount; 2247 @@ -69,9 +69,9 @@ namespace KIMAP 2248 using namespace KIMAP; 2249 2250 IdleJob::IdleJob( Session *session ) 2251 - : Job( *new IdleJobPrivate(this, session, i18nc("name of the idle job", "Idle")) ) 2252 + : Job( *new IdleJobPrivate( this, session, i18nc( "name of the idle job", "Idle" ) ) ) 2253 { 2254 - Q_D(IdleJob); 2255 + Q_D( IdleJob ); 2256 connect( &d->emitStatsTimer, SIGNAL(timeout()), 2257 this, SLOT(emitStats()) ); 2258 } 2259 @@ -82,14 +82,14 @@ IdleJob::~IdleJob() 2260 2261 void KIMAP::IdleJob::stop() 2262 { 2263 - Q_D(IdleJob); 2264 + Q_D( IdleJob ); 2265 d->sessionInternal()->setSocketTimeout( d->originalSocketTimeout ); 2266 d->sessionInternal()->sendData( "DONE" ); 2267 } 2268 2269 void IdleJob::doStart() 2270 { 2271 - Q_D(IdleJob); 2272 + Q_D( IdleJob ); 2273 d->originalSocketTimeout = d->sessionInternal()->socketTimeout(); 2274 d->sessionInternal()->setSocketTimeout( -1 ); 2275 d->tags << d->sessionInternal()->sendCommand( "IDLE" ); 2276 @@ -97,33 +97,32 @@ void IdleJob::doStart() 2277 2278 void IdleJob::handleResponse( const Message &response ) 2279 { 2280 - Q_D(IdleJob); 2281 + Q_D( IdleJob ); 2282 2283 // We can predict it'll be handled by handleErrorReplies() so emit 2284 // pending signals now (if needed) so that result() will really be 2285 // the last emitted signal. 2286 - if ( !response.content.isEmpty() 2287 - && d->tags.size() == 1 2288 - && d->tags.contains( response.content.first().toString() ) 2289 - && ( d->messageCount>=0 || d->recentCount>=0 ) ) { 2290 + if ( !response.content.isEmpty() && 2291 + d->tags.size() == 1 && 2292 + d->tags.contains( response.content.first().toString() ) && 2293 + ( d->messageCount >= 0 || d->recentCount >= 0 ) ) { 2294 d->emitStats(); 2295 } 2296 2297 - 2298 - if (handleErrorReplies(response) == NotHandled ) { 2299 - if ( response.content.size() > 0 && response.content[0].toString()=="+" ) { 2300 + if ( handleErrorReplies( response ) == NotHandled ) { 2301 + if ( response.content.size() > 0 && response.content[0].toString() == "+" ) { 2302 // Got the continuation all is fine 2303 return; 2304 2305 } else if ( response.content.size() > 2 ) { 2306 - if ( response.content[2].toString()=="EXISTS" ) { 2307 - if ( d->messageCount>=0 ) { 2308 + if ( response.content[2].toString() == "EXISTS" ) { 2309 + if ( d->messageCount >= 0 ) { 2310 d->emitStats(); 2311 } 2312 2313 d->messageCount = response.content[1].toString().toInt(); 2314 - } else if ( response.content[2].toString()=="RECENT" ) { 2315 - if ( d->recentCount>=0 ) { 2316 + } else if ( response.content[2].toString() == "RECENT" ) { 2317 + if ( d->recentCount >= 0 ) { 2318 d->emitStats(); 2319 } 2320 2321 @@ -141,20 +140,21 @@ void IdleJob::handleResponse( const Message &response ) 2322 2323 QString KIMAP::IdleJob::lastMailBox() const 2324 { 2325 - Q_D(const IdleJob); 2326 + Q_D( const IdleJob ); 2327 return d->m_session->selectedMailBox(); 2328 } 2329 2330 int KIMAP::IdleJob::lastMessageCount() const 2331 { 2332 - Q_D(const IdleJob); 2333 + Q_D( const IdleJob ); 2334 return d->lastMessageCount; 2335 } 2336 2337 int KIMAP::IdleJob::lastRecentCount() const 2338 { 2339 - Q_D(const IdleJob); 2340 + Q_D( const IdleJob ); 2341 return d->lastRecentCount; 2342 } 2343 2344 #include "idlejob.moc" 2345 + 2346 diff --git a/kimap/idlejob.h b/kimap/idlejob.h 2347 index 3a0917b..784155a 100644 2348 --- a/kimap/idlejob.h 2349 +++ b/kimap/idlejob.h 2350 @@ -63,7 +63,7 @@ class IdleJobPrivate; 2351 class KIMAP_EXPORT IdleJob : public Job 2352 { 2353 Q_OBJECT 2354 - Q_DECLARE_PRIVATE(IdleJob) 2355 + Q_DECLARE_PRIVATE( IdleJob ) 2356 2357 public: 2358 explicit IdleJob( Session *session ); 2359 diff --git a/kimap/imapset.cpp b/kimap/imapset.cpp 2360 index 8588452..6c4e9ea 100644 2361 --- a/kimap/imapset.cpp 2362 +++ b/kimap/imapset.cpp 2363 @@ -56,7 +56,6 @@ class ImapSet::Private : public QSharedData 2364 ImapInterval::List intervals; 2365 }; 2366 2367 - 2368 ImapInterval::ImapInterval() : 2369 d( new Private ) 2370 { 2371 @@ -80,8 +79,9 @@ ImapInterval::~ ImapInterval() 2372 2373 ImapInterval& ImapInterval::operator =(const ImapInterval & other) 2374 { 2375 - if ( this != & other ) 2376 + if ( this != &other ) { 2377 d = other.d; 2378 + } 2379 return *this; 2380 } 2381 2382 @@ -92,10 +92,12 @@ bool ImapInterval::operator ==(const ImapInterval & other) const 2383 2384 ImapInterval::Id ImapInterval::size() const 2385 { 2386 - if ( !d->begin && !d->end ) 2387 + if ( !d->begin && !d->end ) { 2388 return 0; 2389 - if ( d->begin && !d->end ) 2390 + } 2391 + if ( d->begin && !d->end ) { 2392 return Q_INT64_C( 0x7FFFFFFFFFFFFFFF ) - d->begin + 1; 2393 + } 2394 return d->end - d->begin + 1; 2395 } 2396 2397 @@ -116,8 +118,9 @@ bool ImapInterval::hasDefinedEnd() const 2398 2399 ImapInterval::Id ImapInterval::end() const 2400 { 2401 - if ( hasDefinedEnd() ) 2402 + if ( hasDefinedEnd() ) { 2403 return d->end; 2404 + } 2405 return 0xFFFFFFFF; // should be INT_MAX, but where is that defined again? 2406 } 2407 2408 @@ -137,16 +140,19 @@ void ImapInterval::setEnd(Id value) 2409 2410 QByteArray ImapInterval::toImapSequence() const 2411 { 2412 - if ( size() == 0 ) 2413 + if ( size() == 0 ) { 2414 return QByteArray(); 2415 - if ( size() == 1 ) 2416 + } 2417 + if ( size() == 1 ) { 2418 return QByteArray::number( d->begin ); 2419 + } 2420 QByteArray rv; 2421 rv += QByteArray::number( d->begin ) + ':'; 2422 - if ( hasDefinedEnd() ) 2423 + if ( hasDefinedEnd() ) { 2424 rv += QByteArray::number( d->end ); 2425 - else 2426 + } else { 2427 rv += '*'; 2428 + } 2429 return rv; 2430 } 2431 2432 @@ -158,7 +164,7 @@ ImapInterval ImapInterval::fromImapSequence( const QByteArray &sequence ) 2433 } 2434 2435 bool ok = false; 2436 - Id begin = values[0].toLongLong(&ok); 2437 + Id begin = values[0].toLongLong( &ok ); 2438 2439 if ( !ok ) { 2440 return ImapInterval(); 2441 @@ -172,7 +178,7 @@ ImapInterval ImapInterval::fromImapSequence( const QByteArray &sequence ) 2442 end = 0; 2443 } else { 2444 ok = false; 2445 - end = values[1].toLongLong(&ok); 2446 + end = values[1].toLongLong( &ok ); 2447 if ( !ok ) { 2448 return ImapInterval(); 2449 } 2450 @@ -209,8 +215,9 @@ ImapSet::~ImapSet() 2451 2452 ImapSet & ImapSet::operator =(const ImapSet & other) 2453 { 2454 - if ( this != &other ) 2455 + if ( this != &other ) { 2456 d = other.d; 2457 + } 2458 return *this; 2459 } 2460 2461 @@ -238,7 +245,7 @@ void ImapSet::add(const QList<Id> & values) 2462 { 2463 QList<Id> vals = values; 2464 qSort( vals ); 2465 - for( int i = 0; i < vals.count(); ++i ) { 2466 + for ( int i = 0; i < vals.count(); ++i ) { 2467 const int begin = vals[i]; 2468 Q_ASSERT( begin >= 0 ); 2469 if ( i == vals.count() - 1 ) { 2470 @@ -248,7 +255,7 @@ void ImapSet::add(const QList<Id> & values) 2471 do { 2472 ++i; 2473 Q_ASSERT( vals[i] >= 0 ); 2474 - if ( vals[i] != (vals[i - 1] + 1) ) { 2475 + if ( vals[i] != ( vals[i - 1] + 1 ) ) { 2476 --i; 2477 break; 2478 } 2479 @@ -276,7 +283,7 @@ QByteArray ImapSet::toImapSequenceSet() const 2480 QList<QByteArray>::ConstIterator it = rv.constBegin(); 2481 ++it; 2482 for ( ; it != rv.constEnd(); ++it ) { 2483 - result += ',' + (*it); 2484 + result += ',' + ( *it ); 2485 } 2486 } 2487 2488 @@ -289,7 +296,7 @@ ImapSet ImapSet::fromImapSequenceSet( const QByteArray &sequence ) 2489 2490 QList<QByteArray> intervals = sequence.split( ',' ); 2491 2492 - foreach( const QByteArray &interval, intervals ) { 2493 + foreach ( const QByteArray &interval, intervals ) { 2494 if ( !interval.isEmpty() ) { 2495 result.add( ImapInterval::fromImapSequence( interval ) ); 2496 } 2497 @@ -319,4 +326,3 @@ QDebug& operator<<( QDebug &d, const ImapSet &set ) 2498 d << set.toImapSequenceSet(); 2499 return d; 2500 } 2501 - 2502 diff --git a/kimap/imapset.h b/kimap/imapset.h 2503 index a3417ac..a217251 100644 2504 --- a/kimap/imapset.h 2505 +++ b/kimap/imapset.h 2506 @@ -199,6 +199,7 @@ class KIMAP_EXPORT ImapSet 2507 /** 2508 Adds the given ImapInterval to this set. 2509 No interval merging is performed. 2510 + @param interval the interval to add 2511 */ 2512 void add( const ImapInterval &interval ); 2513 2514 diff --git a/kimap/imapstreamparser.cpp b/kimap/imapstreamparser.cpp 2515 index 50a8552..37bf691 100644 2516 --- a/kimap/imapstreamparser.cpp 2517 +++ b/kimap/imapstreamparser.cpp 2518 @@ -48,20 +48,21 @@ QString ImapStreamParser::readUtf8String() 2519 return result; 2520 } 2521 2522 - 2523 QByteArray ImapStreamParser::readString() 2524 { 2525 QByteArray result; 2526 - if ( !waitForMoreData( m_data.length() == 0 ) ) 2527 - throw ImapParserException("Unable to read more data"); 2528 + if ( !waitForMoreData( m_data.length() == 0 ) ) { 2529 + throw ImapParserException( "Unable to read more data" ); 2530 + } 2531 stripLeadingSpaces(); 2532 - if ( !waitForMoreData( m_position >= m_data.length() ) ) 2533 - throw ImapParserException("Unable to read more data"); 2534 + if ( !waitForMoreData( m_position >= m_data.length() ) ) { 2535 + throw ImapParserException( "Unable to read more data" ); 2536 + } 2537 2538 // literal string 2539 // TODO: error handling 2540 if ( hasLiteral() ) { 2541 - while (!atLiteralEnd()) { 2542 + while ( !atLiteralEnd() ) { 2543 result += readLiteralPart(); 2544 } 2545 return result; 2546 @@ -73,58 +74,65 @@ QByteArray ImapStreamParser::readString() 2547 2548 bool ImapStreamParser::hasString() 2549 { 2550 - if ( !waitForMoreData( m_position >= m_data.length() ) ) 2551 - throw ImapParserException("Unable to read more data"); 2552 + if ( !waitForMoreData( m_position >= m_data.length() ) ) { 2553 + throw ImapParserException( "Unable to read more data" ); 2554 + } 2555 int savedPos = m_position; 2556 stripLeadingSpaces(); 2557 int pos = m_position; 2558 m_position = savedPos; 2559 - if ( m_data.at(pos) == '{' ) 2560 + if ( m_data.at( pos ) == '{' ) { 2561 return true; //literal string 2562 - if (m_data.at(pos) == '"' ) 2563 + } 2564 + if ( m_data.at( pos ) == '"' ) { 2565 return true; //quoted string 2566 - if ( m_data.at(pos) != ' ' && 2567 - m_data.at(pos) != '(' && 2568 - m_data.at(pos) != ')' && 2569 - m_data.at(pos) != '[' && 2570 - m_data.at(pos) != ']' && 2571 - m_data.at(pos) != '\n' && 2572 - m_data.at(pos) != '\r' ) 2573 + } 2574 + if ( m_data.at( pos ) != ' ' && 2575 + m_data.at( pos ) != '(' && 2576 + m_data.at( pos ) != ')' && 2577 + m_data.at( pos ) != '[' && 2578 + m_data.at( pos ) != ']' && 2579 + m_data.at( pos ) != '\n' && 2580 + m_data.at( pos ) != '\r' ) { 2581 return true; //unquoted string 2582 + } 2583 2584 return false; //something else, not a string 2585 } 2586 2587 bool ImapStreamParser::hasLiteral() 2588 { 2589 - if ( !waitForMoreData( m_position >= m_data.length() ) ) 2590 - throw ImapParserException("Unable to read more data"); 2591 + if ( !waitForMoreData( m_position >= m_data.length() ) ) { 2592 + throw ImapParserException( "Unable to read more data" ); 2593 + } 2594 int savedPos = m_position; 2595 stripLeadingSpaces(); 2596 - if ( m_data.at(m_position) == '{' ) 2597 - { 2598 + if ( m_data.at( m_position ) == '{' ) { 2599 int end = -1; 2600 do { 2601 end = m_data.indexOf( '}', m_position ); 2602 - if ( !waitForMoreData( end == -1 ) ) 2603 - throw ImapParserException("Unable to read more data"); 2604 - } while (end == -1); 2605 + if ( !waitForMoreData( end == -1 ) ) { 2606 + throw ImapParserException( "Unable to read more data" ); 2607 + } 2608 + } while ( end == -1 ); 2609 Q_ASSERT( end > m_position ); 2610 m_literalSize = m_data.mid( m_position + 1, end - m_position - 1 ).toInt(); 2611 // strip CRLF 2612 m_position = end + 1; 2613 2614 - if ( m_position < m_data.length() && m_data.at(m_position) == '\r' ) 2615 + if ( m_position < m_data.length() && m_data.at( m_position ) == '\r' ) { 2616 ++m_position; 2617 - if ( m_position < m_data.length() && m_data.at(m_position) == '\n' ) 2618 + } 2619 + if ( m_position < m_data.length() && m_data.at( m_position ) == '\n' ) { 2620 ++m_position; 2621 + } 2622 2623 //FIXME: Makes sense only on the server side? 2624 - if (m_isServerModeEnabled && m_literalSize > 0) 2625 + if ( m_isServerModeEnabled && m_literalSize > 0 ) { 2626 sendContinuationResponse( m_literalSize ); 2627 + } 2628 return true; 2629 - } else 2630 - { 2631 + } else { 2632 m_position = savedPos; 2633 return false; 2634 } 2635 @@ -132,7 +140,7 @@ bool ImapStreamParser::hasLiteral() 2636 2637 bool ImapStreamParser::atLiteralEnd() const 2638 { 2639 - return (m_literalSize == 0); 2640 + return ( m_literalSize == 0 ); 2641 } 2642 2643 QByteArray ImapStreamParser::readLiteralPart() 2644 @@ -140,18 +148,19 @@ QByteArray ImapStreamParser::readLiteralPart() 2645 static qint64 maxLiteralPartSize = 4096; 2646 int size = qMin(maxLiteralPartSize, m_literalSize); 2647 2648 - if ( !waitForMoreData( m_data.length() < m_position + size ) ) 2649 - throw ImapParserException("Unable to read more data"); 2650 + if ( !waitForMoreData( m_data.length() < m_position + size ) ) { 2651 + throw ImapParserException( "Unable to read more data" ); 2652 + } 2653 2654 if ( m_data.length() < m_position + size ) { // Still not enough data 2655 // Take what's already there 2656 size = m_data.length() - m_position; 2657 } 2658 2659 - QByteArray result = m_data.mid(m_position, size); 2660 + QByteArray result = m_data.mid( m_position, size ); 2661 m_position += size; 2662 m_literalSize -= size; 2663 - Q_ASSERT(m_literalSize >= 0); 2664 + Q_ASSERT( m_literalSize >= 0 ); 2665 trimBuffer(); 2666 2667 return result; 2668 @@ -159,80 +168,81 @@ QByteArray ImapStreamParser::readLiteralPart() 2669 2670 bool ImapStreamParser::hasList() 2671 { 2672 - if ( !waitForMoreData( m_position >= m_data.length() ) ) 2673 - throw ImapParserException("Unable to read more data"); 2674 + if ( !waitForMoreData( m_position >= m_data.length() ) ) { 2675 + throw ImapParserException( "Unable to read more data" ); 2676 + } 2677 int savedPos = m_position; 2678 stripLeadingSpaces(); 2679 int pos = m_position; 2680 m_position = savedPos; 2681 - if ( m_data.at(pos) == '(' ) 2682 - { 2683 + if ( m_data.at( pos ) == '(' ) { 2684 return true; 2685 } 2686 - 2687 return false; 2688 } 2689 2690 bool ImapStreamParser::atListEnd() 2691 { 2692 - if ( !waitForMoreData( m_position >= m_data.length() ) ) 2693 - throw ImapParserException("Unable to read more data"); 2694 + if ( !waitForMoreData( m_position >= m_data.length() ) ) { 2695 + throw ImapParserException( "Unable to read more data" ); 2696 + } 2697 int savedPos = m_position; 2698 stripLeadingSpaces(); 2699 int pos = m_position; 2700 m_position = savedPos; 2701 - if ( m_data.at(pos) == ')' ) 2702 - { 2703 + if ( m_data.at( pos ) == ')' ) { 2704 m_position = pos + 1; 2705 return true; 2706 } 2707 - 2708 return false; 2709 } 2710 2711 QList<QByteArray> ImapStreamParser::readParenthesizedList() 2712 { 2713 QList<QByteArray> result; 2714 - if (! waitForMoreData( m_data.length() <= m_position ) ) 2715 - throw ImapParserException("Unable to read more data"); 2716 + if ( !waitForMoreData( m_data.length() <= m_position ) ) { 2717 + throw ImapParserException( "Unable to read more data" ); 2718 + } 2719 2720 stripLeadingSpaces(); 2721 - if ( m_data.at(m_position) != '(' ) 2722 + if ( m_data.at( m_position ) != '(' ) { 2723 return result; //no list found 2724 + } 2725 2726 bool concatToLast = false; 2727 int count = 0; 2728 int sublistbegin = m_position; 2729 int i = m_position + 1; 2730 Q_FOREVER { 2731 - if ( !waitForMoreData( m_data.length() <= i ) ) 2732 - { 2733 + if ( !waitForMoreData( m_data.length() <= i ) ) { 2734 m_position = i; 2735 - throw ImapParserException("Unable to read more data"); 2736 + throw ImapParserException( "Unable to read more data" ); 2737 } 2738 - if ( m_data.at(i) == '(' ) { 2739 + if ( m_data.at( i ) == '(' ) { 2740 ++count; 2741 - if ( count == 1 ) 2742 + if ( count == 1 ) { 2743 sublistbegin = i; 2744 + } 2745 ++i; 2746 continue; 2747 } 2748 - if ( m_data.at(i) == ')' ) { 2749 + if ( m_data.at( i ) == ')' ) { 2750 if ( count <= 0 ) { 2751 m_position = i + 1; 2752 return result; 2753 } 2754 - if ( count == 1 ) 2755 + if ( count == 1 ) { 2756 result.append( m_data.mid( sublistbegin, i - sublistbegin + 1 ) ); 2757 + } 2758 --count; 2759 ++i; 2760 continue; 2761 } 2762 - if ( m_data.at(i) == ' ' ) { 2763 + if ( m_data.at( i ) == ' ' ) { 2764 ++i; 2765 continue; 2766 } 2767 - if ( m_data.at(i) == '"' ) { 2768 + if ( m_data.at( i ) == '"' ) { 2769 if ( count > 0 ) { 2770 m_position = i; 2771 parseQuotedString(); 2772 @@ -240,27 +250,27 @@ QList<QByteArray> ImapStreamParser::readParenthesizedList() 2773 continue; 2774 } 2775 } 2776 - if ( m_data.at(i) == '[' ) { 2777 + if ( m_data.at( i ) == '[' ) { 2778 concatToLast = true; 2779 if ( result.isEmpty() ) { 2780 result.append( QByteArray() ); 2781 } 2782 - result.last()+='['; 2783 + result.last() += '['; 2784 ++i; 2785 continue; 2786 } 2787 - if ( m_data.at(i) == ']' ) { 2788 + if ( m_data.at( i ) == ']' ) { 2789 concatToLast = false; 2790 - result.last()+=']'; 2791 + result.last() += ']'; 2792 ++i; 2793 continue; 2794 } 2795 if ( count == 0 ) { 2796 m_position = i; 2797 QByteArray ba; 2798 - if (hasLiteral()) { 2799 - while (!atLiteralEnd()) { 2800 - ba+=readLiteralPart(); 2801 + if ( hasLiteral() ) { 2802 + while ( !atLiteralEnd() ) { 2803 + ba += readLiteralPart(); 2804 } 2805 } else { 2806 ba = readString(); 2807 @@ -268,13 +278,14 @@ QList<QByteArray> ImapStreamParser::readParenthesizedList() 2808 2809 // We might sometime get some unwanted CRLF, but we're still not at the end 2810 // of the list, would make further string reads fail so eat the CRLFs. 2811 - while ( ( m_position < m_data.size() ) && ( m_data.at(m_position) == '\r' || m_data.at(m_position) == '\n' ) ) { 2812 + while ( ( m_position < m_data.size() ) && 2813 + ( m_data.at( m_position ) == '\r' || m_data.at( m_position ) == '\n' ) ) { 2814 m_position++; 2815 } 2816 2817 i = m_position - 1; 2818 - if (concatToLast) { 2819 - result.last()+=ba; 2820 + if ( concatToLast ) { 2821 + result.last() += ba; 2822 } else { 2823 result.append( ba ); 2824 } 2825 @@ -287,68 +298,68 @@ QList<QByteArray> ImapStreamParser::readParenthesizedList() 2826 2827 bool ImapStreamParser::hasResponseCode() 2828 { 2829 - if ( !waitForMoreData( m_position >= m_data.length() ) ) 2830 - throw ImapParserException("Unable to read more data"); 2831 + if ( !waitForMoreData( m_position >= m_data.length() ) ) { 2832 + throw ImapParserException( "Unable to read more data" ); 2833 + } 2834 int savedPos = m_position; 2835 stripLeadingSpaces(); 2836 int pos = m_position; 2837 m_position = savedPos; 2838 - if ( m_data.at(pos) == '[' ) 2839 - { 2840 + if ( m_data.at( pos ) == '[' ) { 2841 m_position = pos + 1; 2842 return true; 2843 } 2844 - 2845 return false; 2846 } 2847 2848 bool ImapStreamParser::atResponseCodeEnd() 2849 { 2850 - if ( !waitForMoreData( m_position >= m_data.length() ) ) 2851 - throw ImapParserException("Unable to read more data"); 2852 + if ( !waitForMoreData( m_position >= m_data.length() ) ) { 2853 + throw ImapParserException( "Unable to read more data" ); 2854 + } 2855 int savedPos = m_position; 2856 stripLeadingSpaces(); 2857 int pos = m_position; 2858 m_position = savedPos; 2859 - if ( m_data.at(pos) == ']' ) 2860 - { 2861 + if ( m_data.at( pos ) == ']' ) { 2862 m_position = pos + 1; 2863 return true; 2864 } 2865 - 2866 return false; 2867 } 2868 2869 QByteArray ImapStreamParser::parseQuotedString() 2870 { 2871 QByteArray result; 2872 - if (! waitForMoreData( m_data.length() == 0 ) ) 2873 - throw ImapParserException("Unable to read more data"); 2874 + if ( !waitForMoreData( m_data.length() == 0 ) ) { 2875 + throw ImapParserException( "Unable to read more data" ); 2876 + } 2877 stripLeadingSpaces(); 2878 int end = m_position; 2879 result.clear(); 2880 - if ( !waitForMoreData( m_position >= m_data.length() ) ) 2881 - throw ImapParserException("Unable to read more data"); 2882 - if ( !waitForMoreData( m_position >= m_data.length() ) ) 2883 - throw ImapParserException("Unable to read more data"); 2884 + if ( !waitForMoreData( m_position >= m_data.length() ) ) { 2885 + throw ImapParserException( "Unable to read more data" ); 2886 + } 2887 + if ( !waitForMoreData( m_position >= m_data.length() ) ) { 2888 + throw ImapParserException( "Unable to read more data" ); 2889 + } 2890 2891 bool foundSlash = false; 2892 // quoted string 2893 - if ( m_data.at(m_position) == '"' ) { 2894 + if ( m_data.at( m_position ) == '"' ) { 2895 ++m_position; 2896 int i = m_position; 2897 Q_FOREVER { 2898 - if ( !waitForMoreData( m_data.length() <= i ) ) 2899 - { 2900 + if ( !waitForMoreData( m_data.length() <= i ) ) { 2901 m_position = i; 2902 - throw ImapParserException("Unable to read more data"); 2903 + throw ImapParserException( "Unable to read more data" ); 2904 } 2905 - if ( m_data.at(i) == '\\' ) { 2906 + if ( m_data.at( i ) == '\\' ) { 2907 i += 2; 2908 foundSlash = true; 2909 continue; 2910 } 2911 - if ( m_data.at(i) == '"' ) { 2912 + if ( m_data.at( i ) == '"' ) { 2913 result = m_data.mid( m_position, i - m_position ); 2914 end = i + 1; // skip the '"' 2915 break; 2916 @@ -362,32 +373,42 @@ QByteArray ImapStreamParser::parseQuotedString() 2917 bool reachedInputEnd = true; 2918 int i = m_position; 2919 Q_FOREVER { 2920 - if ( !waitForMoreData( m_data.length() <= i ) ) 2921 - { 2922 + if ( !waitForMoreData( m_data.length() <= i ) ) { 2923 m_position = i; 2924 - throw ImapParserException("Unable to read more data"); 2925 + throw ImapParserException( "Unable to read more data" ); 2926 } 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) == '"') { 2928 + if ( m_data.at( i ) == ' ' || 2929 + m_data.at( i ) == '(' || 2930 + m_data.at( i ) == ')' || 2931 + m_data.at( i ) == '[' || 2932 + m_data.at( i ) == ']' || 2933 + m_data.at( i ) == '\n' || 2934 + m_data.at( i ) == '\r' || 2935 + m_data.at( i ) == '"' ) { 2936 end = i; 2937 reachedInputEnd = false; 2938 break; 2939 } 2940 - if (m_data.at(i) == '\\') 2941 + if ( m_data.at( i ) == '\\' ) { 2942 foundSlash = true; 2943 + } 2944 i++; 2945 } 2946 - if ( reachedInputEnd ) //FIXME: how can it get here? 2947 + if ( reachedInputEnd ) { //FIXME: how can it get here? 2948 end = m_data.length(); 2949 + } 2950 2951 result = m_data.mid( m_position, end - m_position ); 2952 } 2953 2954 // strip quotes 2955 if ( foundSlash ) { 2956 - while ( result.contains( "\\\"" ) ) 2957 + while ( result.contains( "\\\"" ) ) { 2958 result.replace( "\\\"", "\"" ); 2959 - while ( result.contains( "\\\\" ) ) 2960 + } 2961 + while ( result.contains( "\\\\" ) ) { 2962 result.replace( "\\\\", "\\" ); 2963 + } 2964 } 2965 m_position = end; 2966 return result; 2967 @@ -396,24 +417,28 @@ QByteArray ImapStreamParser::parseQuotedString() 2968 qint64 ImapStreamParser::readNumber( bool * ok ) 2969 { 2970 qint64 result; 2971 - if ( ok ) 2972 + if ( ok ) { 2973 *ok = false; 2974 - if (! waitForMoreData( m_data.length() == 0 ) ) 2975 - throw ImapParserException("Unable to read more data"); 2976 + } 2977 + if ( !waitForMoreData( m_data.length() == 0 ) ) { 2978 + throw ImapParserException( "Unable to read more data" ); 2979 + } 2980 stripLeadingSpaces(); 2981 - if ( !waitForMoreData( m_position >= m_data.length() ) ) 2982 - throw ImapParserException("Unable to read more data"); 2983 - if ( m_position >= m_data.length() ) 2984 - throw ImapParserException("Unable to read more data"); 2985 + if ( !waitForMoreData( m_position >= m_data.length() ) ) { 2986 + throw ImapParserException( "Unable to read more data" ); 2987 + } 2988 + if ( m_position >= m_data.length() ) { 2989 + throw ImapParserException( "Unable to read more data" ); 2990 + } 2991 int i = m_position; 2992 Q_FOREVER { 2993 - if ( !waitForMoreData( m_data.length() <= i ) ) 2994 - { 2995 + if ( !waitForMoreData( m_data.length() <= i ) ) { 2996 m_position = i; 2997 - throw ImapParserException("Unable to read more data"); 2998 + throw ImapParserException( "Unable to read more data" ); 2999 } 3000 - if ( !isdigit( m_data.at( i ) ) ) 3001 + if ( !isdigit( m_data.at( i ) ) ) { 3002 break; 3003 + } 3004 ++i; 3005 } 3006 const QByteArray tmp = m_data.mid( m_position, i - m_position ); 3007 @@ -425,8 +450,7 @@ qint64 ImapStreamParser::readNumber( bool * ok ) 3008 void ImapStreamParser::stripLeadingSpaces() 3009 { 3010 for ( int i = m_position; i < m_data.length(); ++i ) { 3011 - if ( m_data.at(i) != ' ' ) 3012 - { 3013 + if ( m_data.at( i ) != ' ' ) { 3014 m_position = i; 3015 return; 3016 } 3017 @@ -438,10 +462,9 @@ bool ImapStreamParser::waitForMoreData( bool wait ) 3018 { 3019 if ( wait ) { 3020 if ( m_socket->bytesAvailable() > 0 || 3021 - m_socket->waitForReadyRead(30000) ) { 3022 + m_socket->waitForReadyRead( 30000 ) ) { 3023 m_data.append( m_socket->readAll() ); 3024 - } else 3025 - { 3026 + } else { 3027 return false; 3028 } 3029 } 3030 @@ -455,28 +478,31 @@ void ImapStreamParser::setData( const QByteArray &data ) 3031 3032 QByteArray ImapStreamParser::readRemainingData() 3033 { 3034 - return m_data.mid(m_position); 3035 + return m_data.mid( m_position ); 3036 } 3037 3038 int ImapStreamParser::availableDataSize() const 3039 { 3040 - return m_socket->bytesAvailable()+m_data.size()-m_position; 3041 + return m_socket->bytesAvailable() + m_data.size() - m_position; 3042 } 3043 3044 bool ImapStreamParser::atCommandEnd() 3045 { 3046 int savedPos = m_position; 3047 do { 3048 - if ( !waitForMoreData( m_position >= m_data.length() ) ) 3049 - throw ImapParserException("Unable to read more data"); 3050 + if ( !waitForMoreData( m_position >= m_data.length() ) ) { 3051 + throw ImapParserException( "Unable to read more data" ); 3052 + } 3053 stripLeadingSpaces(); 3054 } while ( m_position >= m_data.size() ); 3055 3056 - if ( m_data.at(m_position) == '\n' || m_data.at(m_position) == '\r') { 3057 - if ( m_data.at(m_position) == '\r' ) 3058 + if ( m_data.at( m_position ) == '\n' || m_data.at( m_position ) == '\r' ) { 3059 + if ( m_data.at( m_position ) == '\r' ) { 3060 ++m_position; 3061 - if ( m_position < m_data.length() && m_data.at(m_position) == '\n' ) 3062 + } 3063 + if ( m_position < m_data.length() && m_data.at( m_position ) == '\n' ) { 3064 ++m_position; 3065 + } 3066 3067 // We'd better empty m_data from time to time before it grows out of control 3068 trimBuffer(); 3069 @@ -493,29 +519,30 @@ QByteArray ImapStreamParser::readUntilCommandEnd() 3070 int i = m_position; 3071 int paranthesisBalance = 0; 3072 Q_FOREVER { 3073 - if ( !waitForMoreData( m_data.length() <= i ) ) 3074 - { 3075 + if ( !waitForMoreData( m_data.length() <= i ) ) { 3076 m_position = i; 3077 - throw ImapParserException("Unable to read more data"); 3078 + throw ImapParserException( "Unable to read more data" ); 3079 } 3080 - if ( m_data.at(i) == '{' ) 3081 - { 3082 + if ( m_data.at( i ) == '{' ) { 3083 m_position = i - 1; 3084 hasLiteral(); //init literal size 3085 - result.append(m_data.mid(i-1, m_position - i +1)); 3086 - while (!atLiteralEnd()) 3087 - { 3088 + result.append( m_data.mid( i - 1, m_position - i + 1 ) ); 3089 + while ( !atLiteralEnd() ) { 3090 result.append( readLiteralPart() ); 3091 } 3092 i = m_position; 3093 } 3094 - if ( m_data.at(i) == '(' ) 3095 + if ( m_data.at( i ) == '(' ) { 3096 paranthesisBalance++; 3097 - if ( m_data.at(i) == ')' ) 3098 + } 3099 + if ( m_data.at( i ) == ')' ) { 3100 paranthesisBalance--; 3101 - if ( ( i == m_data.length() && paranthesisBalance == 0 ) || m_data.at(i) == '\n' || m_data.at(i) == '\r') 3102 + } 3103 + if ( ( i == m_data.length() && paranthesisBalance == 0 ) || 3104 + m_data.at( i ) == '\n' || m_data.at( i ) == '\r') { 3105 break; //command end 3106 - result.append( m_data.at(i) ); 3107 + } 3108 + result.append( m_data.at( i ) ); 3109 ++i; 3110 } 3111 m_position = i; 3112 @@ -525,16 +552,17 @@ QByteArray ImapStreamParser::readUntilCommandEnd() 3113 3114 void ImapStreamParser::sendContinuationResponse( qint64 size ) 3115 { 3116 - QByteArray block = "+ Ready for literal data (expecting " 3117 - + QByteArray::number( size ) + " bytes)\r\n"; 3118 - m_socket->write(block); 3119 - m_socket->waitForBytesWritten(30000); 3120 + QByteArray block = "+ Ready for literal data (expecting " + 3121 + QByteArray::number( size ) + " bytes)\r\n"; 3122 + m_socket->write( block ); 3123 + m_socket->waitForBytesWritten( 30000 ); 3124 } 3125 3126 void ImapStreamParser::trimBuffer() 3127 { 3128 - if ( m_position < 4096 ) // right() is expensive, so don't do it for every line 3129 + if ( m_position < 4096 ) { // right() is expensive, so don't do it for every line 3130 return; 3131 - m_data = m_data.right(m_data.size()-m_position); 3132 + } 3133 + m_data = m_data.right( m_data.size() - m_position ); 3134 m_position = 0; 3135 } 3136 diff --git a/kimap/imapstreamparser.h b/kimap/imapstreamparser.h 3137 index 7c43d1d..12e97b0 100644 3138 --- a/kimap/imapstreamparser.h 3139 +++ b/kimap/imapstreamparser.h 3140 @@ -36,9 +36,9 @@ namespace KIMAP { 3141 class ImapParserException : public std::exception 3142 { 3143 public: 3144 - ImapParserException( const char *what ) throw() : mWhat( what ) {} 3145 - ImapParserException( const QByteArray &what ) throw() : mWhat( what ) {} 3146 - ImapParserException( const QString &what ) throw() : mWhat( what.toUtf8() ) {} 3147 + explicit ImapParserException( const char *what ) throw() : mWhat( what ) {} 3148 + explicit ImapParserException( const QByteArray &what ) throw() : mWhat( what ) {} 3149 + explicit ImapParserException( const QString &what ) throw() : mWhat( what.toUtf8() ) {} 3150 ImapParserException( const ImapParserException &other ) throw() : std::exception( other ), mWhat( other.what() ) {} 3151 virtual ~ImapParserException() throw() {} 3152 const char *what() const throw() { return mWhat.constData(); } 3153 @@ -86,7 +86,6 @@ class KIMAP_EXPORT ImapStreamParser 3154 */ 3155 QList<QByteArray> readParenthesizedList(); 3156 3157 - 3158 /** 3159 * Get the next data as a number. This call might block. 3160 * @param ok true if the data found was a number 3161 @@ -181,7 +180,6 @@ class KIMAP_EXPORT ImapStreamParser 3162 3163 void setData( const QByteArray &data ); 3164 3165 - 3166 private: 3167 void stripLeadingSpaces(); 3168 QByteArray parseQuotedString(); 3169 diff --git a/kimap/job.cpp b/kimap/job.cpp 3170 index cd30eec..938c941 100644 3171 --- a/kimap/job.cpp 3172 +++ b/kimap/job.cpp 3173 @@ -22,21 +22,19 @@ 3174 #include "message_p.h" 3175 #include "session_p.h" 3176 3177 -#include <klocale.h> 3178 -#include <kdebug.h> 3179 +#include <KDE/KLocalizedString> 3180 +#include <KDE/KDebug> 3181 3182 using namespace KIMAP; 3183 3184 Job::Job( Session *session ) 3185 - : KJob( session ), d_ptr(new JobPrivate(session, i18n("Job"))) 3186 + : KJob( session ), d_ptr( new JobPrivate( session, i18n( "Job" ) ) ) 3187 { 3188 - 3189 } 3190 3191 Job::Job( JobPrivate &dd ) 3192 - : KJob( dd.m_session ), d_ptr(&dd) 3193 + : KJob( dd.m_session ), d_ptr( &dd ) 3194 { 3195 - 3196 } 3197 3198 Job::~Job() 3199 @@ -46,40 +44,40 @@ Job::~Job() 3200 3201 Session *Job::session() const 3202 { 3203 - Q_D(const Job); 3204 + Q_D( const Job ); 3205 return d->m_session; 3206 } 3207 3208 void Job::start() 3209 { 3210 - Q_D(Job); 3211 - d->sessionInternal()->addJob(this); 3212 + Q_D( Job ); 3213 + d->sessionInternal()->addJob( this ); 3214 } 3215 3216 void Job::handleResponse(const Message &response) 3217 { 3218 - handleErrorReplies(response); 3219 + handleErrorReplies( response ); 3220 } 3221 3222 void Job::connectionLost() 3223 { 3224 setError( KJob::UserDefinedError ); 3225 - setErrorText( i18n("Connection to server lost.") ); 3226 + setErrorText( i18n( "Connection to server lost." ) ); 3227 emitResult(); 3228 } 3229 3230 Job::HandlerResponse Job::handleErrorReplies(const Message &response) 3231 { 3232 - Q_D(Job); 3233 -// qDebug() << response.toString(); 3234 + Q_D( Job ); 3235 +// kDebug() << response.toString(); 3236 3237 - if ( !response.content.isEmpty() 3238 - && d->tags.contains( response.content.first().toString() ) ) { 3239 + if ( !response.content.isEmpty() && 3240 + d->tags.contains( response.content.first().toString() ) ) { 3241 if ( response.content.size() < 2 ) { 3242 - setErrorText( i18n("%1 failed, malformed reply from the server.", d->m_name) ); 3243 + setErrorText( i18n( "%1 failed, malformed reply from the server.", d->m_name ) ); 3244 } else if ( response.content[1].toString() != "OK" ) { 3245 setError( UserDefinedError ); 3246 - setErrorText( i18n("%1 failed, server replied: %2", d->m_name, response.toString().constData()) ); 3247 + setErrorText( i18n( "%1 failed, server replied: %2", d->m_name, response.toString().constData() ) ); 3248 } 3249 d->tags.removeAll( response.content.first().toString() ); 3250 if ( d->tags.isEmpty() ) { // Only emit result when the last command returned 3251 @@ -92,3 +90,4 @@ Job::HandlerResponse Job::handleErrorReplies(const Message &response) 3252 } 3253 3254 #include "job.moc" 3255 + 3256 diff --git a/kimap/job.h b/kimap/job.h 3257 index 79dd9a6..6bb5670 100644 3258 --- a/kimap/job.h 3259 +++ b/kimap/job.h 3260 @@ -22,7 +22,7 @@ 3261 3262 #include "kimap_export.h" 3263 3264 -#include <kjob.h> 3265 +#include <KDE/KJob> 3266 3267 namespace KIMAP { 3268 3269 @@ -34,7 +34,7 @@ struct Message; 3270 class KIMAP_EXPORT Job : public KJob 3271 { 3272 Q_OBJECT 3273 - Q_DECLARE_PRIVATE(Job) 3274 + Q_DECLARE_PRIVATE( Job ) 3275 3276 friend class SessionPrivate; 3277 3278 diff --git a/kimap/job_p.h b/kimap/job_p.h 3279 index b04cf9c..6e4b717 100644 3280 --- a/kimap/job_p.h 3281 +++ b/kimap/job_p.h 3282 @@ -21,7 +21,7 @@ 3283 #define KIMAP_JOB_P_H 3284 3285 #include "session.h" 3286 -#include <klocale.h> 3287 +#include <KDE/KLocalizedString> 3288 3289 namespace KIMAP { 3290 3291 @@ -30,7 +30,7 @@ class SessionPrivate; 3292 class JobPrivate 3293 { 3294 public: 3295 - JobPrivate( Session *session, const QString& name ) : m_session(session) { 3296 + JobPrivate( Session *session, const QString& name ) : m_session( session ) { 3297 m_name = name; 3298 } 3299 virtual ~JobPrivate() { } 3300 diff --git a/kimap/listjob.cpp b/kimap/listjob.cpp 3301 index 60f8071..322fc37 100644 3302 --- a/kimap/listjob.cpp 3303 +++ b/kimap/listjob.cpp 3304 @@ -21,7 +21,7 @@ 3305 3306 #include <boost/bind.hpp> 3307 #include <QtCore/QTimer> 3308 -#include <klocale.h> 3309 +#include <KDE/KLocalizedString> 3310 3311 #include "job_p.h" 3312 #include "message_p.h" 3313 @@ -33,7 +33,7 @@ namespace KIMAP 3314 class ListJobPrivate : public JobPrivate 3315 { 3316 public: 3317 - ListJobPrivate( ListJob *job, Session *session, const QString& name ) : JobPrivate(session, name), q(job), option(ListJob::NoOption) { } 3318 + ListJobPrivate( ListJob *job, Session *session, const QString& name ) : JobPrivate( session, name ), q( job ), option( ListJob::NoOption ) { } 3319 ~ListJobPrivate() { } 3320 3321 void emitPendings() 3322 @@ -63,9 +63,9 @@ namespace KIMAP 3323 using namespace KIMAP; 3324 3325 ListJob::ListJob( Session *session ) 3326 - : Job( *new ListJobPrivate(this, session, i18n("List")) ) 3327 + : Job( *new ListJobPrivate( this, session, i18n( "List" ) ) ) 3328 { 3329 - Q_D(ListJob); 3330 + Q_D( ListJob ); 3331 connect( &d->emitPendingsTimer, SIGNAL(timeout()), 3332 this, SLOT(emitPendings()) ); 3333 } 3334 @@ -76,8 +76,8 @@ ListJob::~ListJob() 3335 3336 void ListJob::setIncludeUnsubscribed( bool include ) 3337 { 3338 - Q_D(ListJob); 3339 - if (include) { 3340 + Q_D( ListJob ); 3341 + if ( include ) { 3342 d->option = ListJob::IncludeUnsubscribed; 3343 } else { 3344 d->option = ListJob::NoOption; 3345 @@ -86,31 +86,31 @@ void ListJob::setIncludeUnsubscribed( bool include ) 3346 3347 bool ListJob::isIncludeUnsubscribed() const 3348 { 3349 - Q_D(const ListJob); 3350 + Q_D( const ListJob ); 3351 return ( d->option == ListJob::IncludeUnsubscribed ); 3352 } 3353 3354 void ListJob::setOption( Option option ) 3355 { 3356 - Q_D(ListJob); 3357 + Q_D( ListJob ); 3358 d->option = option; 3359 } 3360 3361 ListJob::Option ListJob::option() const 3362 { 3363 - Q_D(const ListJob); 3364 + Q_D( const ListJob ); 3365 return d->option; 3366 } 3367 3368 void ListJob::setQueriedNamespaces( const QList<MailBoxDescriptor> &namespaces ) 3369 { 3370 - Q_D(ListJob); 3371 + Q_D( ListJob ); 3372 d->namespaces = namespaces; 3373 } 3374 3375 QList<MailBoxDescriptor> ListJob::queriedNamespaces() const 3376 { 3377 - Q_D(const ListJob); 3378 + Q_D( const ListJob ); 3379 return d->namespaces; 3380 } 3381 3382 @@ -126,9 +126,9 @@ QMap< MailBoxDescriptor, QList<QByteArray> > ListJob::flags() const 3383 3384 void ListJob::doStart() 3385 { 3386 - Q_D(ListJob); 3387 + Q_D( ListJob ); 3388 3389 - switch (d->option) { 3390 + switch ( d->option ) { 3391 break; 3392 case IncludeUnsubscribed: 3393 d->command = "LIST"; 3394 @@ -157,20 +157,20 @@ void ListJob::doStart() 3395 } 3396 3397 d->tags << d->sessionInternal()->sendCommand( d->command, 3398 - parameters.arg( descriptor.name+'*' ).toUtf8() ); 3399 + parameters.arg( descriptor.name + '*' ).toUtf8() ); 3400 } 3401 } 3402 } 3403 3404 void ListJob::handleResponse( const Message &response ) 3405 { 3406 - Q_D(ListJob); 3407 + Q_D( ListJob ); 3408 3409 // We can predict it'll be handled by handleErrorReplies() so stop 3410 // the timer now so that result() will really be the last emitted signal. 3411 - if ( !response.content.isEmpty() 3412 - && d->tags.size() == 1 3413 - && d->tags.contains( response.content.first().toString() ) ) { 3414 + if ( !response.content.isEmpty() && 3415 + d->tags.size() == 1 && 3416 + d->tags.contains( response.content.first().toString() ) ) { 3417 d->emitPendingsTimer.stop(); 3418 d->emitPendings(); 3419 } 3420 @@ -178,7 +178,7 @@ void ListJob::handleResponse( const Message &response ) 3421 if ( handleErrorReplies( response ) == NotHandled ) { 3422 if ( response.content.size() >= 5 && response.content[1].toString() == d->command ) { 3423 QList<QByteArray> flags = response.content[2].toList(); 3424 - std::transform( flags.begin(), flags.end(), flags.begin(), boost::bind(&QByteArray::toLower, _1) ); 3425 + std::transform( flags.begin(), flags.end(), flags.begin(), boost::bind( &QByteArray::toLower, _1 ) ); 3426 QByteArray separator = response.content[3].toString(); 3427 if ( separator.isEmpty() ) { 3428 // Defaults to / for servers reporting an empty list 3429 @@ -186,7 +186,7 @@ void ListJob::handleResponse( const Message &response ) 3430 // only do it for mailboxes with no child. 3431 separator = "/"; //krazy:exclude=doublequote_chars since a QByteArray 3432 } 3433 - Q_ASSERT(separator.size()==1); 3434 + Q_ASSERT( separator.size() == 1 ); 3435 QByteArray fullName; 3436 for ( int i=4; i<response.content.size(); i++ ) { 3437 fullName += response.content[i].toString() + ' '; 3438 @@ -209,12 +209,16 @@ void ListJob::handleResponse( const Message &response ) 3439 void ListJob::convertInboxName(KIMAP::MailBoxDescriptor& descriptor) 3440 { 3441 //Inbox must be case sensitive, according to the RFC, so make it always uppercase 3442 - QStringList pathParts = descriptor.name.split(descriptor.separator); 3443 - if ( !pathParts.isEmpty() && pathParts[0].compare( QLatin1String("INBOX"), Qt::CaseInsensitive ) == 0 ) { 3444 - pathParts.removeAt(0); 3445 - descriptor.name = QLatin1String("INBOX"); 3446 - if ( !pathParts.isEmpty() ) 3447 + QStringList pathParts = descriptor.name.split( descriptor.separator ); 3448 + if ( !pathParts.isEmpty() && 3449 + pathParts[0].compare( QLatin1String( "INBOX" ), Qt::CaseInsensitive ) == 0 ) { 3450 + pathParts.removeAt( 0 ); 3451 + descriptor.name = QLatin1String( "INBOX" ); 3452 + if ( !pathParts.isEmpty() ) { 3453 descriptor.name += descriptor.separator + pathParts.join( descriptor.separator ); 3454 + } 3455 } 3456 } 3457 + 3458 #include "listjob.moc" 3459 + 3460 diff --git a/kimap/listjob.h b/kimap/listjob.h 3461 index c90cea6..4d87018 100644 3462 --- a/kimap/listjob.h 3463 +++ b/kimap/listjob.h 3464 @@ -37,19 +37,19 @@ struct KIMAP_EXPORT MailBoxDescriptor 3465 3466 inline bool operator==(const MailBoxDescriptor &other) const 3467 { 3468 - return other.name==name && other.separator==separator; 3469 + return other.name == name && other.separator == separator; 3470 } 3471 3472 inline bool operator<(const MailBoxDescriptor &other) const 3473 { 3474 - return other.name<name || (other.name==name && other.separator<separator); 3475 + return other.name < name || ( other.name == name && other.separator < separator ); 3476 } 3477 }; 3478 3479 class KIMAP_EXPORT ListJob : public Job 3480 { 3481 Q_OBJECT 3482 - Q_DECLARE_PRIVATE(ListJob) 3483 + Q_DECLARE_PRIVATE( ListJob ) 3484 3485 friend class SessionPrivate; 3486 3487 diff --git a/kimap/listrightsjob.cpp b/kimap/listrightsjob.cpp 3488 index 4e79aec..bde9ff0 100644 3489 --- a/kimap/listrightsjob.cpp 3490 +++ b/kimap/listrightsjob.cpp 3491 @@ -19,8 +19,8 @@ 3492 3493 #include "listrightsjob.h" 3494 3495 -#include <klocale.h> 3496 -#include <kdebug.h> 3497 +#include <KDE/KLocalizedString> 3498 +#include <KDE/KDebug> 3499 3500 #include "acljobbase_p.h" 3501 #include "message_p.h" 3502 @@ -32,7 +32,7 @@ namespace KIMAP 3503 class ListRightsJobPrivate : public AclJobBasePrivate 3504 { 3505 public: 3506 - ListRightsJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate(session, name), defaultRights(Acl::None) {} 3507 + ListRightsJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate( session, name ), defaultRights( Acl::None ) {} 3508 ~ListRightsJobPrivate() { } 3509 3510 Acl::Rights defaultRights; 3511 @@ -44,7 +44,7 @@ namespace KIMAP 3512 using namespace KIMAP; 3513 3514 ListRightsJob::ListRightsJob( Session *session ) 3515 - : AclJobBase(*new ListRightsJobPrivate(session, i18n("ListRights"))) 3516 + : AclJobBase( *new ListRightsJobPrivate( session, i18n( "ListRights" ) ) ) 3517 { 3518 3519 } 3520 @@ -55,53 +55,53 @@ ListRightsJob::~ListRightsJob() 3521 3522 void ListRightsJob::doStart() 3523 { 3524 - Q_D(ListRightsJob); 3525 + Q_D( ListRightsJob ); 3526 3527 d->tags << d->sessionInternal()->sendCommand( "LISTRIGHTS", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + "\" \"" + d->id + "\"" ); 3528 } 3529 3530 void ListRightsJob::handleResponse( const Message &response ) 3531 { 3532 - Q_D(ListRightsJob); 3533 + Q_D( ListRightsJob ); 3534 3535 - if (handleErrorReplies(response) == NotHandled) { 3536 - if ( response.content.size() >= 4 3537 - && response.content[1].toString() == "LISTRIGHTS" ) { 3538 + if ( handleErrorReplies( response ) == NotHandled ) { 3539 + if ( response.content.size() >= 4 && 3540 + response.content[1].toString() == "LISTRIGHTS" ) { 3541 QByteArray s = response.content[4].toString(); 3542 - d->defaultRights = Acl::rightsFromString(s); 3543 + d->defaultRights = Acl::rightsFromString( s ); 3544 int i = 5; 3545 - while ( i < response.content.size()) { 3546 + while ( i < response.content.size() ) { 3547 s = response.content[i].toString(); 3548 - d->possibleRights.append(Acl::rightsFromString(s)); 3549 + d->possibleRights.append( Acl::rightsFromString( s ) ); 3550 i++; 3551 } 3552 } 3553 } 3554 } 3555 3556 - 3557 void ListRightsJob::setIdentifier( const QByteArray &identifier ) 3558 { 3559 - Q_D(ListRightsJob); 3560 - d->setIdentifier(identifier); 3561 + Q_D( ListRightsJob ); 3562 + d->setIdentifier( identifier ); 3563 } 3564 3565 QByteArray ListRightsJob::identifier() 3566 { 3567 - Q_D(ListRightsJob); 3568 + Q_D( ListRightsJob ); 3569 return d->identifier(); 3570 } 3571 3572 Acl::Rights ListRightsJob::defaultRights() 3573 { 3574 - Q_D(ListRightsJob); 3575 + Q_D( ListRightsJob ); 3576 return d->defaultRights; 3577 } 3578 3579 QList<Acl::Rights> ListRightsJob::possibleRights() 3580 { 3581 - Q_D(ListRightsJob); 3582 + Q_D( ListRightsJob ); 3583 return d->possibleRights; 3584 } 3585 3586 #include "listrightsjob.moc" 3587 + 3588 diff --git a/kimap/listrightsjob.h b/kimap/listrightsjob.h 3589 index ed4850d..edff595 100644 3590 --- a/kimap/listrightsjob.h 3591 +++ b/kimap/listrightsjob.h 3592 @@ -30,7 +30,6 @@ class Session; 3593 struct Message; 3594 class ListRightsJobPrivate; 3595 3596 - 3597 /** 3598 * Lists the possible and automatic rights for 3599 * an identifier on a mailbox 3600 @@ -49,7 +48,7 @@ class ListRightsJobPrivate; 3601 class KIMAP_EXPORT ListRightsJob : public AclJobBase 3602 { 3603 Q_OBJECT 3604 - Q_DECLARE_PRIVATE(ListRightsJob) 3605 + Q_DECLARE_PRIVATE( ListRightsJob ) 3606 3607 friend class SessionPrivate; 3608 3609 diff --git a/kimap/loginjob.cpp b/kimap/loginjob.cpp 3610 index da869be..02634b0 100644 3611 --- a/kimap/loginjob.cpp 3612 +++ b/kimap/loginjob.cpp 3613 @@ -2,7 +2,6 @@ 3614 Copyright (c) 2009 Kevin Ottens <ervin@kde.org> 3615 Copyright (c) 2009 Andras Mantia <amantia@kde.org> 3616 3617 - 3618 This library is free software; you can redistribute it and/or modify it 3619 under the terms of the GNU Library General Public License as published by 3620 the Free Software Foundation; either version 2 of the License, or (at your 3621 @@ -21,8 +20,8 @@ 3622 3623 #include "loginjob.h" 3624 3625 -#include <klocale.h> 3626 -#include <kdebug.h> 3627 +#include <KDE/KLocalizedString> 3628 +#include <KDE/KDebug> 3629 #include <ktcpsocket.h> 3630 3631 #include "job_p.h" 3632 @@ -59,7 +58,7 @@ namespace KIMAP 3633 Authenticate 3634 }; 3635 3636 - LoginJobPrivate( LoginJob *job, Session *session, const QString& name ) : JobPrivate(session, name), q(job), encryptionMode(LoginJob::Unencrypted), authState(Login), plainLoginDisabled(false) { 3637 + LoginJobPrivate( LoginJob *job, Session *session, const QString& name ) : JobPrivate( session, name ), q( job ), encryptionMode( LoginJob::Unencrypted ), authState( Login ), plainLoginDisabled( false ) { 3638 conn = 0; 3639 client_interact = 0; 3640 } 3641 @@ -93,7 +92,7 @@ using namespace KIMAP; 3642 3643 bool LoginJobPrivate::sasl_interact() 3644 { 3645 - kDebug() <<"sasl_interact"; 3646 + kDebug() << "sasl_interact"; 3647 sasl_interact_t *interact = client_interact; 3648 3649 //some mechanisms do not require username && pass, so it doesn't need a popup 3650 @@ -107,23 +106,23 @@ bool LoginJobPrivate::sasl_interact() 3651 } 3652 3653 interact = client_interact; 3654 - while( interact->id != SASL_CB_LIST_END ) { 3655 - kDebug() <<"SASL_INTERACT id:" << interact->id; 3656 - switch( interact->id ) { 3657 + while ( interact->id != SASL_CB_LIST_END ) { 3658 + kDebug() << "SASL_INTERACT id:" << interact->id; 3659 + switch ( interact->id ) { 3660 case SASL_CB_AUTHNAME: 3661 if ( !authorizationName.isEmpty() ) { 3662 - kDebug() <<"SASL_CB_[AUTHNAME]: '" << authorizationName <<"'"; 3663 + kDebug() << "SASL_CB_[AUTHNAME]: '" << authorizationName << "'"; 3664 interact->result = strdup( authorizationName.toUtf8() ); 3665 interact->len = strlen( (const char *) interact->result ); 3666 break; 3667 } 3668 case SASL_CB_USER: 3669 - kDebug() <<"SASL_CB_[USER|AUTHNAME]: '" << userName <<"'"; 3670 + kDebug() << "SASL_CB_[USER|AUTHNAME]: '" << userName << "'"; 3671 interact->result = strdup( userName.toUtf8() ); 3672 interact->len = strlen( (const char *) interact->result ); 3673 break; 3674 case SASL_CB_PASS: 3675 - kDebug() <<"SASL_CB_PASS: [hidden]"; 3676 + kDebug() << "SASL_CB_PASS: [hidden]"; 3677 interact->result = strdup( password.toUtf8() ); 3678 interact->len = strlen( (const char *) interact->result ); 3679 break; 3680 @@ -137,62 +136,64 @@ bool LoginJobPrivate::sasl_interact() 3681 return true; 3682 } 3683 3684 - 3685 LoginJob::LoginJob( Session *session ) 3686 - : Job( *new LoginJobPrivate(this, session, i18n("Login")) ) 3687 + : Job( *new LoginJobPrivate( this, session, i18n( "Login" ) ) ) 3688 { 3689 - Q_D(LoginJob); 3690 - connect(d->sessionInternal(), SIGNAL(encryptionNegotiationResult(bool)), this, SLOT(sslResponse(bool))); 3691 + Q_D( LoginJob ); 3692 + connect( d->sessionInternal(), SIGNAL(encryptionNegotiationResult(bool)), this, SLOT(sslResponse(bool)) ); 3693 + kDebug() << this; 3694 } 3695 3696 LoginJob::~LoginJob() 3697 { 3698 + kDebug() << this; 3699 } 3700 3701 QString LoginJob::userName() const 3702 { 3703 - Q_D(const LoginJob); 3704 + Q_D( const LoginJob ); 3705 return d->userName; 3706 } 3707 3708 void LoginJob::setUserName( const QString &userName ) 3709 { 3710 - Q_D(LoginJob); 3711 + Q_D( LoginJob ); 3712 d->userName = userName; 3713 } 3714 3715 QString LoginJob::authorizationName() const 3716 { 3717 - Q_D(const LoginJob); 3718 + Q_D( const LoginJob ); 3719 return d->authorizationName; 3720 } 3721 3722 void LoginJob::setAuthorizationName( const QString& authorizationName ) 3723 { 3724 - Q_D(LoginJob); 3725 + Q_D( LoginJob ); 3726 d->authorizationName = authorizationName; 3727 } 3728 3729 QString LoginJob::password() const 3730 { 3731 - Q_D(const LoginJob); 3732 + Q_D( const LoginJob ); 3733 return d->password; 3734 } 3735 3736 void LoginJob::setPassword( const QString &password ) 3737 { 3738 - Q_D(LoginJob); 3739 + Q_D( LoginJob ); 3740 d->password = password; 3741 } 3742 3743 void LoginJob::doStart() 3744 { 3745 - Q_D(LoginJob); 3746 + Q_D( LoginJob ); 3747 3748 + kDebug() << this; 3749 // Don't authenticate on a session in the authenticated state 3750 if ( session()->state() == Session::Authenticated || session()->state() == Session::Selected ) { 3751 setError( UserDefinedError ); 3752 - setErrorText( i18n("IMAP session in the wrong state for authentication") ); 3753 + setErrorText( i18n( "IMAP session in the wrong state for authentication" ) ); 3754 emitResult(); 3755 return; 3756 } 3757 @@ -209,53 +210,57 @@ void LoginJob::doStart() 3758 // (so for instance we won't issue another STARTTLS for nothing if that's 3759 // not needed) 3760 case KTcpSocket::SslV2: 3761 - if ( encryptionMode==SslV2 ) { 3762 + if ( encryptionMode == SslV2 ) { 3763 encryptionMode = Unencrypted; 3764 } 3765 break; 3766 case KTcpSocket::SslV3: 3767 - if ( encryptionMode==SslV3 ) { 3768 + if ( encryptionMode == SslV3 ) { 3769 encryptionMode = Unencrypted; 3770 } 3771 break; 3772 case KTcpSocket::TlsV1: 3773 - if ( encryptionMode==TlsV1 ) { 3774 + if ( encryptionMode == TlsV1 ) { 3775 encryptionMode = Unencrypted; 3776 } 3777 break; 3778 case KTcpSocket::AnySslVersion: 3779 - if ( encryptionMode==AnySslVersion ) { 3780 + if ( encryptionMode == AnySslVersion ) { 3781 encryptionMode = Unencrypted; 3782 } 3783 break; 3784 } 3785 3786 - if (encryptionMode == SslV2 3787 - || encryptionMode == SslV3 3788 - || encryptionMode == SslV3_1 3789 - || encryptionMode == AnySslVersion) { 3790 + if ( encryptionMode == SslV2 || 3791 + encryptionMode == SslV3 || 3792 + encryptionMode == SslV3_1 || 3793 + encryptionMode == AnySslVersion ) { 3794 KTcpSocket::SslVersion version = KTcpSocket::SslV2; 3795 - if (encryptionMode == SslV3) 3796 + if ( encryptionMode == SslV3 ) { 3797 version = KTcpSocket::SslV3; 3798 - if (encryptionMode == SslV3_1) 3799 + } 3800 + if ( encryptionMode == SslV3_1 ) { 3801 version = KTcpSocket::SslV3_1; 3802 - if (encryptionMode == AnySslVersion) 3803 + } 3804 + if ( encryptionMode == AnySslVersion ) { 3805 version = KTcpSocket::AnySslVersion; 3806 - d->sessionInternal()->startSsl(version); 3807 + } 3808 + d->sessionInternal()->startSsl( version ); 3809 3810 - } else if (encryptionMode == TlsV1) { 3811 + } else if ( encryptionMode == TlsV1 ) { 3812 d->authState = LoginJobPrivate::StartTls; 3813 d->tags << d->sessionInternal()->sendCommand( "STARTTLS" ); 3814 3815 - } else if (encryptionMode == Unencrypted ) { 3816 - if (d->authMode.isEmpty()) { 3817 + } else if ( encryptionMode == Unencrypted ) { 3818 + if ( d->authMode.isEmpty() ) { 3819 d->authState = LoginJobPrivate::Login; 3820 + kDebug() << "sending LOGIN"; 3821 d->tags << d->sessionInternal()->sendCommand( "LOGIN", 3822 - '"'+quoteIMAP( d->userName ).toUtf8()+'"' 3823 - +' ' 3824 - +'"'+quoteIMAP(d->password ).toUtf8()+'"' ); 3825 + '"' + quoteIMAP( d->userName ).toUtf8() + '"' + 3826 + ' ' + 3827 + '"' + quoteIMAP( d->password ).toUtf8() + '"' ); 3828 } else { 3829 - if (!d->startAuthentication()) { 3830 + if ( !d->startAuthentication() ) { 3831 emitResult(); 3832 } 3833 } 3834 @@ -264,17 +269,18 @@ void LoginJob::doStart() 3835 3836 void LoginJob::handleResponse( const Message &response ) 3837 { 3838 - Q_D(LoginJob); 3839 + Q_D( LoginJob ); 3840 3841 - if ( response.content.isEmpty() ) 3842 + if ( response.content.isEmpty() ) { 3843 return; 3844 + } 3845 3846 //set the actual command name for standard responses 3847 - QString commandName = i18n("Login"); 3848 - if (d->authState == LoginJobPrivate::Capability) { 3849 - commandName = i18n("Capability"); 3850 - } else if (d->authState == LoginJobPrivate::StartTls) { 3851 - commandName = i18n("StartTls"); 3852 + QString commandName = i18n( "Login" ); 3853 + if ( d->authState == LoginJobPrivate::Capability ) { 3854 + commandName = i18n( "Capability" ); 3855 + } else if ( d->authState == LoginJobPrivate::StartTls ) { 3856 + commandName = i18n( "StartTls" ); 3857 } 3858 3859 enum ResponseCode { 3860 @@ -286,36 +292,41 @@ void LoginJob::handleResponse( const Message &response ) 3861 }; 3862 3863 QByteArray tag = response.content.first().toString(); 3864 - ResponseCode code; 3865 + ResponseCode code = OK; 3866 + 3867 + kDebug() << commandName << tag; 3868 3869 if ( tag == "+" ) { 3870 code = CONTINUATION; 3871 } else if ( tag == "*" ) { 3872 - if ( response.content.size() < 2 ) 3873 + if ( response.content.size() < 2 ) { 3874 code = MALFORMED; // Received empty untagged response 3875 - else 3876 + } else { 3877 code = UNTAGGED; 3878 - } else if ( d->tags.contains(tag) ) { 3879 - if ( response.content.size() < 2 ) 3880 + } 3881 + } else if ( d->tags.contains( tag ) ) { 3882 + if ( response.content.size() < 2 ) { 3883 code = MALFORMED; 3884 - else if ( response.content[1].toString() == "OK" ) 3885 + } else if ( response.content[1].toString() == "OK" ) { 3886 code = OK; 3887 - else 3888 + } else { 3889 code = ERR; 3890 + } 3891 } 3892 3893 - switch (code) { 3894 + switch ( code ) { 3895 case MALFORMED: 3896 // We'll handle it later 3897 break; 3898 3899 case ERR: 3900 //server replied with NO or BAD for SASL authentication 3901 - if (d->authState == LoginJobPrivate::Authenticate) 3902 + if ( d->authState == LoginJobPrivate::Authenticate ) { 3903 sasl_dispose( &d->conn ); 3904 + } 3905 3906 setError( UserDefinedError ); 3907 - setErrorText( i18n("%1 failed, server replied: %2", commandName, response.toString().constData()) ); 3908 + setErrorText( i18n( "%1 failed, server replied: %2", commandName, response.toString().constData() ) ); 3909 emitResult(); 3910 return; 3911 3912 @@ -323,11 +334,12 @@ void LoginJob::handleResponse( const Message &response ) 3913 // The only untagged response interesting for us here is CAPABILITY 3914 if ( response.content[1].toString() == "CAPABILITY" ) { 3915 QList<Message::Part>::const_iterator p = response.content.begin() + 2; 3916 - while (p != response.content.end()) { 3917 + while ( p != response.content.end() ) { 3918 QString capability = p->toString(); 3919 d->capabilities << capability; 3920 - if (capability == "LOGINDISABLED") 3921 + if ( capability == "LOGINDISABLED" ) { 3922 d->plainLoginDisabled = true; 3923 + } 3924 ++p; 3925 } 3926 kDebug() << "Capabilities updated: " << d->capabilities; 3927 @@ -335,7 +347,7 @@ void LoginJob::handleResponse( const Message &response ) 3928 break; 3929 3930 case CONTINUATION: 3931 - if (d->authState != LoginJobPrivate::Authenticate) { 3932 + if ( d->authState != LoginJobPrivate::Authenticate ) { 3933 // Received unexpected continuation response for something 3934 // other than AUTHENTICATE command 3935 code = MALFORMED; 3936 @@ -343,7 +355,7 @@ void LoginJob::handleResponse( const Message &response ) 3937 } 3938 3939 if ( d->authMode == QLatin1String( "PLAIN" ) ) { 3940 - if ( response.content.size()>1 && response.content.at( 1 ).toString()=="OK" ) { 3941 + if ( response.content.size()>1 && response.content.at( 1 ).toString() == "OK" ) { 3942 return; 3943 } 3944 QByteArray challengeResponse; 3945 @@ -357,7 +369,7 @@ void LoginJob::handleResponse( const Message &response ) 3946 challengeResponse = challengeResponse.toBase64(); 3947 d->sessionInternal()->sendData( challengeResponse ); 3948 } else if ( response.content.size() >= 2 ) { 3949 - if (!d->answerChallenge(QByteArray::fromBase64(response.content[1].toString()))) { 3950 + if ( !d->answerChallenge( QByteArray::fromBase64( response.content[1].toString() ) ) ) { 3951 emitResult(); //error, we're done 3952 } 3953 } else { 3954 @@ -368,41 +380,41 @@ void LoginJob::handleResponse( const Message &response ) 3955 3956 case OK: 3957 3958 - switch (d->authState) { 3959 + switch ( d->authState ) { 3960 case LoginJobPrivate::StartTls: 3961 - d->sessionInternal()->startSsl(KTcpSocket::TlsV1); 3962 + d->sessionInternal()->startSsl( KTcpSocket::TlsV1 ); 3963 break; 3964 3965 case LoginJobPrivate::Capability: 3966 //cleartext login, if enabled 3967 - if (d->authMode.isEmpty()) { 3968 - if (d->plainLoginDisabled) { 3969 + if ( d->authMode.isEmpty() ) { 3970 + if ( d->plainLoginDisabled ) { 3971 setError( UserDefinedError ); 3972 - setErrorText( i18n("Login failed, plain login is disabled by the server.") ); 3973 + setErrorText( i18n( "Login failed, plain login is disabled by the server." ) ); 3974 emitResult(); 3975 } else { 3976 d->authState = LoginJobPrivate::Login; 3977 d->tags << d->sessionInternal()->sendCommand( "LOGIN", 3978 - '"'+quoteIMAP( d->userName ).toUtf8()+'"' 3979 - +' ' 3980 - +'"'+quoteIMAP( d->password ).toUtf8()+'"'); 3981 + '"' + quoteIMAP( d->userName ).toUtf8() + '"' + 3982 + ' ' + 3983 + '"' + quoteIMAP( d->password ).toUtf8() + '"' ); 3984 } 3985 } else { 3986 bool authModeSupported = false; 3987 //find the selected SASL authentication method 3988 - Q_FOREACH(const QString &capability, d->capabilities) { 3989 - if (capability.startsWith(QLatin1String("AUTH="))) { 3990 - if (capability.mid(5) == d->authMode) { 3991 + Q_FOREACH ( const QString &capability, d->capabilities ) { 3992 + if ( capability.startsWith( QLatin1String( "AUTH=" ) ) ) { 3993 + if ( capability.mid( 5 ) == d->authMode ) { 3994 authModeSupported = true; 3995 break; 3996 } 3997 } 3998 } 3999 - if (!authModeSupported) { 4000 + if ( !authModeSupported ) { 4001 setError( UserDefinedError ); 4002 - setErrorText( i18n("Login failed, authentication mode %1 is not supported by the server.", d->authMode) ); 4003 + setErrorText( i18n( "Login failed, authentication mode %1 is not supported by the server.", d->authMode ) ); 4004 emitResult(); 4005 - } else if (!d->startAuthentication()) { 4006 + } else if ( !d->startAuthentication() ) { 4007 emitResult(); //problem, we're done 4008 } 4009 } 4010 @@ -421,7 +433,7 @@ void LoginJob::handleResponse( const Message &response ) 4011 } 4012 4013 if ( code == MALFORMED ) { 4014 - setErrorText( i18n("%1 failed, malformed reply from the server.", commandName) ); 4015 + setErrorText( i18n( "%1 failed, malformed reply from the server.", commandName ) ); 4016 emitResult(); 4017 } 4018 } 4019 @@ -429,9 +441,9 @@ void LoginJob::handleResponse( const Message &response ) 4020 bool LoginJobPrivate::startAuthentication() 4021 { 4022 //SASL authentication 4023 - if (!initSASL()) { 4024 + if ( !initSASL() ) { 4025 q->setError( LoginJob::UserDefinedError ); 4026 - q->setErrorText( i18n("Login failed, client cannot initialize the SASL library.") ); 4027 + q->setErrorText( i18n( "Login failed, client cannot initialize the SASL library." ) ); 4028 return false; 4029 } 4030 4031 @@ -442,14 +454,14 @@ bool LoginJobPrivate::startAuthentication() 4032 4033 int result = sasl_client_new( "imap", m_session->hostName().toLatin1(), 0, 0, callbacks, 0, &conn ); 4034 if ( result != SASL_OK ) { 4035 - kDebug() <<"sasl_client_new failed with:" << result; 4036 + kDebug() << "sasl_client_new failed with:" << result; 4037 q->setError( LoginJob::UserDefinedError ); 4038 q->setErrorText( QString::fromUtf8( sasl_errdetail( conn ) ) ); 4039 return false; 4040 } 4041 4042 do { 4043 - result = sasl_client_start(conn, authMode.toLatin1(), &client_interact, capabilities.contains("SASL-IR") ? &out : 0, &outlen, &mechusing); 4044 + result = sasl_client_start( conn, authMode.toLatin1(), &client_interact, capabilities.contains( "SASL-IR" ) ? &out : 0, &outlen, &mechusing ); 4045 4046 if ( result == SASL_INTERACT ) { 4047 if ( !sasl_interact() ) { 4048 @@ -461,7 +473,7 @@ bool LoginJobPrivate::startAuthentication() 4049 } while ( result == SASL_INTERACT ); 4050 4051 if ( result != SASL_CONTINUE && result != SASL_OK ) { 4052 - kDebug() <<"sasl_client_start failed with:" << result; 4053 + kDebug() << "sasl_client_start failed with:" << result; 4054 q->setError( LoginJob::UserDefinedError ); 4055 q->setErrorText( QString::fromUtf8( sasl_errdetail( conn ) ) ); 4056 sasl_dispose( &conn ); 4057 @@ -487,12 +499,12 @@ bool LoginJobPrivate::answerChallenge(const QByteArray &data) 4058 const char *out = 0; 4059 uint outlen = 0; 4060 do { 4061 - result = sasl_client_step(conn, challenge.isEmpty() ? 0 : challenge.data(), 4062 - challenge.size(), 4063 - &client_interact, 4064 - &out, &outlen); 4065 + result = sasl_client_step( conn, challenge.isEmpty() ? 0 : challenge.data(), 4066 + challenge.size(), 4067 + &client_interact, 4068 + &out, &outlen ); 4069 4070 - if (result == SASL_INTERACT) { 4071 + if ( result == SASL_INTERACT ) { 4072 if ( !sasl_interact() ) { 4073 q->setError( LoginJob::UserDefinedError ); //TODO: check up the actual error 4074 sasl_dispose( &conn ); 4075 @@ -502,7 +514,7 @@ bool LoginJobPrivate::answerChallenge(const QByteArray &data) 4076 } while ( result == SASL_INTERACT ); 4077 4078 if ( result != SASL_CONTINUE && result != SASL_OK ) { 4079 - kDebug() <<"sasl_client_step failed with:" << result; 4080 + kDebug() << "sasl_client_step failed with:" << result; 4081 q->setError( LoginJob::UserDefinedError ); //TODO: check up the actual error 4082 q->setErrorText( QString::fromUtf8( sasl_errdetail( conn ) ) ); 4083 sasl_dispose( &conn ); 4084 @@ -519,12 +531,12 @@ bool LoginJobPrivate::answerChallenge(const QByteArray &data) 4085 4086 void LoginJobPrivate::sslResponse(bool response) 4087 { 4088 - if (response) { 4089 + if ( response ) { 4090 authState = LoginJobPrivate::Capability; 4091 tags << sessionInternal()->sendCommand( "CAPABILITY" ); 4092 } else { 4093 q->setError( LoginJob::UserDefinedError ); 4094 - q->setErrorText( i18n("Login failed, TLS negotiation failed." )); 4095 + q->setErrorText( i18n( "Login failed, TLS negotiation failed." ) ); 4096 encryptionMode = LoginJob::Unencrypted; 4097 q->emitResult(); 4098 } 4099 @@ -532,21 +544,20 @@ void LoginJobPrivate::sslResponse(bool response) 4100 4101 void LoginJob::setEncryptionMode(EncryptionMode mode) 4102 { 4103 - Q_D(LoginJob); 4104 + Q_D( LoginJob ); 4105 d->encryptionMode = mode; 4106 } 4107 4108 LoginJob::EncryptionMode LoginJob::encryptionMode() 4109 { 4110 - Q_D(LoginJob); 4111 + Q_D( LoginJob ); 4112 return d->encryptionMode; 4113 } 4114 4115 void LoginJob::setAuthenticationMode(AuthenticationMode mode) 4116 { 4117 - Q_D(LoginJob); 4118 - switch (mode) 4119 - { 4120 + Q_D( LoginJob ); 4121 + switch ( mode ) { 4122 case ClearText: d->authMode = ""; 4123 break; 4124 case Login: d->authMode = "LOGIN"; 4125 @@ -568,13 +579,13 @@ void LoginJob::setAuthenticationMode(AuthenticationMode mode) 4126 4127 void LoginJob::connectionLost() 4128 { 4129 - Q_D(LoginJob); 4130 + Q_D( LoginJob ); 4131 4132 //don't emit the result if the connection was lost before getting the tls result, as it can mean 4133 //the TLS handshake failed and the socket was reconnected in normal mode 4134 - if (d->authState != LoginJobPrivate::StartTls) { 4135 + if ( d->authState != LoginJobPrivate::StartTls ) { 4136 setError( ERR_COULD_NOT_CONNECT ); 4137 - setErrorText( i18n("Connection to server lost.") ); 4138 + setErrorText( i18n( "Connection to server lost." ) ); 4139 emitResult(); 4140 } 4141 4142 @@ -585,25 +596,26 @@ void LoginJobPrivate::saveServerGreeting(const Message &response) 4143 // Concatenate the parts of the server response into a string, while dropping the first two parts 4144 // (the response tag and the "OK" code), and being careful not to add useless extra whitespace. 4145 4146 - for ( int i=2; i<response.content.size(); i++) { 4147 - if ( response.content.at(i).type()==Message::Part::List ) { 4148 - serverGreeting+='('; 4149 - foreach ( const QByteArray &item, response.content.at(i).toList() ) { 4150 - serverGreeting+=item+' '; 4151 + for ( int i = 2; i < response.content.size(); i++ ) { 4152 + if ( response.content.at( i ).type() == Message::Part::List ) { 4153 + serverGreeting += '('; 4154 + foreach ( const QByteArray &item, response.content.at( i ).toList() ) { 4155 + serverGreeting += item + ' '; 4156 } 4157 - serverGreeting.chop(1); 4158 - serverGreeting+=") "; 4159 + serverGreeting.chop( 1 ); 4160 + serverGreeting += ") "; 4161 } else { 4162 - serverGreeting+=response.content.at(i).toString()+' '; 4163 + serverGreeting+=response.content.at( i ).toString() + ' '; 4164 } 4165 } 4166 - serverGreeting.chop(1); 4167 + serverGreeting.chop( 1 ); 4168 } 4169 4170 QString LoginJob::serverGreeting() const 4171 { 4172 - Q_D(const LoginJob); 4173 + Q_D( const LoginJob ); 4174 return d->serverGreeting; 4175 } 4176 4177 #include "loginjob.moc" 4178 + 4179 diff --git a/kimap/loginjob.h b/kimap/loginjob.h 4180 index 6064214..2c6040a 100644 4181 --- a/kimap/loginjob.h 4182 +++ b/kimap/loginjob.h 4183 @@ -34,7 +34,7 @@ class LoginJobPrivate; 4184 class KIMAP_EXPORT LoginJob : public Job 4185 { 4186 Q_OBJECT 4187 - Q_DECLARE_PRIVATE(LoginJob) 4188 + Q_DECLARE_PRIVATE( LoginJob ) 4189 4190 friend class SessionPrivate; 4191 4192 diff --git a/kimap/logoutjob.cpp b/kimap/logoutjob.cpp 4193 index 9f191dd..5c9bc19 100644 4194 --- a/kimap/logoutjob.cpp 4195 +++ b/kimap/logoutjob.cpp 4196 @@ -19,7 +19,7 @@ 4197 4198 #include "logoutjob.h" 4199 4200 -#include <klocale.h> 4201 +#include <KDE/KLocalizedString> 4202 4203 #include "job_p.h" 4204 #include "message_p.h" 4205 @@ -30,7 +30,7 @@ namespace KIMAP 4206 class LogoutJobPrivate : public JobPrivate 4207 { 4208 public: 4209 - LogoutJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { } 4210 + LogoutJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { } 4211 ~LogoutJobPrivate() { } 4212 }; 4213 } 4214 @@ -38,7 +38,7 @@ namespace KIMAP 4215 using namespace KIMAP; 4216 4217 LogoutJob::LogoutJob( Session *session ) 4218 - : Job( *new LogoutJobPrivate(session, i18n("Logout")) ) 4219 + : Job( *new LogoutJobPrivate( session, i18n( "Logout" ) ) ) 4220 { 4221 } 4222 4223 @@ -48,7 +48,7 @@ LogoutJob::~LogoutJob() 4224 4225 void LogoutJob::doStart() 4226 { 4227 - Q_D(LogoutJob); 4228 + Q_D( LogoutJob ); 4229 d->tags << d->sessionInternal()->sendCommand( "LOGOUT" ); 4230 } 4231 4232 @@ -58,3 +58,4 @@ void LogoutJob::connectionLost() 4233 } 4234 4235 #include "logoutjob.moc" 4236 + 4237 diff --git a/kimap/logoutjob.h b/kimap/logoutjob.h 4238 index e3f6553..288400f 100644 4239 --- a/kimap/logoutjob.h 4240 +++ b/kimap/logoutjob.h 4241 @@ -32,7 +32,7 @@ class LogoutJobPrivate; 4242 class KIMAP_EXPORT LogoutJob : public Job 4243 { 4244 Q_OBJECT 4245 - Q_DECLARE_PRIVATE(LogoutJob) 4246 + Q_DECLARE_PRIVATE( LogoutJob ) 4247 4248 friend class SessionPrivate; 4249 4250 diff --git a/kimap/message_p.h b/kimap/message_p.h 4251 index 9d703bf..e6dd502 100644 4252 --- a/kimap/message_p.h 4253 +++ b/kimap/message_p.h 4254 @@ -34,9 +34,9 @@ struct Message 4255 enum Type { String = 0, List }; 4256 4257 explicit Part(const QByteArray &string) 4258 - : m_type(String), m_string(string) { } 4259 + : m_type( String ), m_string( string ) { } 4260 explicit Part(const QList<QByteArray> &list) 4261 - : m_type(List), m_list(list) { } 4262 + : m_type( List ), m_list( list ) { } 4263 4264 inline Type type() const { return m_type; } 4265 inline QByteArray toString() const { return m_string; } 4266 @@ -53,22 +53,22 @@ struct Message 4267 QByteArray result; 4268 4269 foreach ( const Part &part, content ) { 4270 - if ( part.type()==Part::List ) { 4271 - result+='('; 4272 + if ( part.type() == Part::List ) { 4273 + result += '('; 4274 foreach ( const QByteArray &item, part.toList() ) { 4275 - result+= ' '; 4276 - result+= item; 4277 + result += ' '; 4278 + result += item; 4279 } 4280 - result+=" ) "; 4281 + result += " ) "; 4282 } else { 4283 - result+= part.toString()+' '; 4284 + result += part.toString() + ' '; 4285 } 4286 } 4287 4288 if ( !responseCode.isEmpty() ) { 4289 result+="[ "; 4290 foreach ( const Part &part, responseCode ) { 4291 - if ( part.type()==Part::List ) { 4292 + if ( part.type() == Part::List ) { 4293 result+='('; 4294 foreach ( const QByteArray &item, part.toList() ) { 4295 result+= ' '; 4296 @@ -76,7 +76,7 @@ struct Message 4297 } 4298 result+=" ) "; 4299 } else { 4300 - result+= part.toString()+' '; 4301 + result+= part.toString() + ' '; 4302 } 4303 } 4304 result+=" ]"; 4305 @@ -91,7 +91,7 @@ struct Message 4306 4307 } 4308 4309 -Q_DECLARE_METATYPE(KIMAP::Message) 4310 +Q_DECLARE_METATYPE( KIMAP::Message ) 4311 static const int _kimap_messageTypeId = qRegisterMetaType<KIMAP::Message>(); 4312 4313 #endif 4314 diff --git a/kimap/metadatajobbase.cpp b/kimap/metadatajobbase.cpp 4315 index fa9dc53..bc7a8d5 100644 4316 --- a/kimap/metadatajobbase.cpp 4317 +++ b/kimap/metadatajobbase.cpp 4318 @@ -22,50 +22,48 @@ 4319 #include "message_p.h" 4320 #include "session_p.h" 4321 4322 -#include <klocale.h> 4323 -#include <kdebug.h> 4324 +#include <KDE/KLocalizedString> 4325 +#include <KDE/KDebug> 4326 4327 using namespace KIMAP; 4328 4329 MetaDataJobBase::MetaDataJobBase( Session *session ) 4330 - : Job( *new MetaDataJobBasePrivate(session, i18n("MetaDataJobBase")) ) 4331 + : Job( *new MetaDataJobBasePrivate( session, i18n( "MetaDataJobBase" ) ) ) 4332 { 4333 } 4334 4335 - 4336 MetaDataJobBase::MetaDataJobBase( JobPrivate &dd ) 4337 - : Job(dd) 4338 + : Job( dd ) 4339 { 4340 - 4341 } 4342 4343 MetaDataJobBase::~MetaDataJobBase() 4344 { 4345 } 4346 4347 - 4348 void MetaDataJobBase::setMailBox( const QString &mailBox ) 4349 { 4350 - Q_D(MetaDataJobBase); 4351 + Q_D( MetaDataJobBase ); 4352 d->mailBox = mailBox; 4353 } 4354 4355 QString MetaDataJobBase::mailBox() const 4356 { 4357 - Q_D(const MetaDataJobBase); 4358 + Q_D( const MetaDataJobBase ); 4359 return d->mailBox; 4360 } 4361 4362 void MetaDataJobBase::setServerCapability(const ServerCapability& capability) 4363 { 4364 - Q_D(MetaDataJobBase); 4365 + Q_D( MetaDataJobBase ); 4366 d->serverCapability = capability; 4367 } 4368 4369 MetaDataJobBase::ServerCapability MetaDataJobBase::serverCapability() const 4370 { 4371 - Q_D(const MetaDataJobBase); 4372 + Q_D( const MetaDataJobBase ); 4373 return d->serverCapability; 4374 } 4375 4376 #include "metadatajobbase.moc" 4377 + 4378 diff --git a/kimap/metadatajobbase.h b/kimap/metadatajobbase.h 4379 index f7ad6e2..de46736 100644 4380 --- a/kimap/metadatajobbase.h 4381 +++ b/kimap/metadatajobbase.h 4382 @@ -47,7 +47,7 @@ class MetaDataJobBasePrivate; 4383 class KIMAP_EXPORT MetaDataJobBase : public Job 4384 { 4385 Q_OBJECT 4386 - Q_DECLARE_PRIVATE(MetaDataJobBase) 4387 + Q_DECLARE_PRIVATE( MetaDataJobBase ) 4388 4389 friend class SessionPrivate; 4390 4391 diff --git a/kimap/metadatajobbase_p.h b/kimap/metadatajobbase_p.h 4392 index 983a344..140ef20 100644 4393 --- a/kimap/metadatajobbase_p.h 4394 +++ b/kimap/metadatajobbase_p.h 4395 @@ -30,7 +30,7 @@ namespace KIMAP 4396 class MetaDataJobBasePrivate : public JobPrivate 4397 { 4398 public: 4399 - MetaDataJobBasePrivate( Session *session, const QString& name ) : JobPrivate(session, name), serverCapability(MetaDataJobBase::Metadata) 4400 + MetaDataJobBasePrivate( Session *session, const QString& name ) : JobPrivate( session, name ), serverCapability( MetaDataJobBase::Metadata ) 4401 {} 4402 4403 ~MetaDataJobBasePrivate() { } 4404 diff --git a/kimap/myrightsjob.cpp b/kimap/myrightsjob.cpp 4405 index 46354ae..49790b3 100644 4406 --- a/kimap/myrightsjob.cpp 4407 +++ b/kimap/myrightsjob.cpp 4408 @@ -19,8 +19,8 @@ 4409 4410 #include "myrightsjob.h" 4411 4412 -#include <klocale.h> 4413 -#include <kdebug.h> 4414 +#include <KDE/KLocalizedString> 4415 +#include <KDE/KDebug> 4416 4417 #include "acljobbase_p.h" 4418 #include "message_p.h" 4419 @@ -32,7 +32,7 @@ namespace KIMAP 4420 class MyRightsJobPrivate : public AclJobBasePrivate 4421 { 4422 public: 4423 - MyRightsJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate(session, name), myRights(Acl::None) {} 4424 + MyRightsJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate( session, name ), myRights( Acl::None ) {} 4425 ~MyRightsJobPrivate() { } 4426 4427 Acl::Rights myRights; 4428 @@ -42,7 +42,7 @@ namespace KIMAP 4429 using namespace KIMAP; 4430 4431 MyRightsJob::MyRightsJob( Session *session ) 4432 - : AclJobBase( *new MyRightsJobPrivate(session, i18n("MyRights") )) 4433 + : AclJobBase( *new MyRightsJobPrivate( session, i18n( "MyRights" ) ) ) 4434 { 4435 } 4436 4437 @@ -52,18 +52,18 @@ MyRightsJob::~MyRightsJob() 4438 4439 void MyRightsJob::doStart() 4440 { 4441 - Q_D(MyRightsJob); 4442 + Q_D( MyRightsJob ); 4443 4444 - d->tags << d->sessionInternal()->sendCommand( "MYRIGHTS", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"'); 4445 + d->tags << d->sessionInternal()->sendCommand( "MYRIGHTS", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"' ); 4446 } 4447 4448 void MyRightsJob::handleResponse( const Message &response ) 4449 { 4450 - Q_D(MyRightsJob); 4451 + Q_D( MyRightsJob ); 4452 4453 - if (handleErrorReplies(response) == NotHandled) { 4454 - if ( response.content.size() == 4 4455 - && response.content[1].toString() == "MYRIGHTS" ) { 4456 + if ( handleErrorReplies( response ) == NotHandled ) { 4457 + if ( response.content.size() == 4 && 4458 + response.content[1].toString() == "MYRIGHTS" ) { 4459 d->myRights = Acl::rightsFromString( response.content[3].toString() ); 4460 } 4461 } 4462 @@ -71,14 +71,15 @@ void MyRightsJob::handleResponse( const Message &response ) 4463 4464 bool MyRightsJob::hasRightEnabled(Acl::Right right) 4465 { 4466 - Q_D(MyRightsJob); 4467 + Q_D( MyRightsJob ); 4468 return d->myRights & right; 4469 } 4470 4471 Acl::Rights MyRightsJob::rights() 4472 { 4473 - Q_D(MyRightsJob); 4474 + Q_D( MyRightsJob ); 4475 return d->myRights; 4476 } 4477 4478 #include "myrightsjob.moc" 4479 + 4480 diff --git a/kimap/myrightsjob.h b/kimap/myrightsjob.h 4481 index 4e57d0e..24973d5 100644 4482 --- a/kimap/myrightsjob.h 4483 +++ b/kimap/myrightsjob.h 4484 @@ -56,7 +56,7 @@ class MyRightsJobPrivate; 4485 class KIMAP_EXPORT MyRightsJob : public AclJobBase 4486 { 4487 Q_OBJECT 4488 - Q_DECLARE_PRIVATE(MyRightsJob) 4489 + Q_DECLARE_PRIVATE( MyRightsJob ) 4490 4491 friend class SessionPrivate; 4492 4493 diff --git a/kimap/namespacejob.cpp b/kimap/namespacejob.cpp 4494 index 639e55d..47b3930 100644 4495 --- a/kimap/namespacejob.cpp 4496 +++ b/kimap/namespacejob.cpp 4497 @@ -19,8 +19,8 @@ 4498 4499 #include "namespacejob.h" 4500 4501 -#include <kdebug.h> 4502 -#include <klocale.h> 4503 +#include <KDE/KDebug> 4504 +#include <KDE/KLocalizedString> 4505 4506 #include "job_p.h" 4507 #include "listjob.h" 4508 @@ -34,7 +34,7 @@ namespace KIMAP 4509 class NamespaceJobPrivate : public JobPrivate 4510 { 4511 public: 4512 - NamespaceJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { } 4513 + NamespaceJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { } 4514 ~NamespaceJobPrivate() { } 4515 4516 QList<MailBoxDescriptor> processNamespaceList( const QList<QByteArray> &namespaceList ) 4517 @@ -55,7 +55,7 @@ namespace KIMAP 4518 descriptor.separator = QChar( parts[1][0] ); 4519 4520 result << descriptor; 4521 - } catch (KIMAP::ImapParserException e) { 4522 + } catch ( KIMAP::ImapParserException e ) { 4523 qWarning() << "The stream parser raised an exception during namespace list parsing:" << e.what(); 4524 qWarning() << "namespacelist:" << namespaceList; 4525 } 4526 @@ -74,7 +74,7 @@ namespace KIMAP 4527 using namespace KIMAP; 4528 4529 NamespaceJob::NamespaceJob( Session *session ) 4530 - : Job( *new NamespaceJobPrivate(session, i18n("Namespace")) ) 4531 + : Job( *new NamespaceJobPrivate( session, i18n( "Namespace" ) ) ) 4532 { 4533 } 4534 4535 @@ -84,25 +84,25 @@ NamespaceJob::~NamespaceJob() 4536 4537 QList<MailBoxDescriptor> NamespaceJob::personalNamespaces() const 4538 { 4539 - Q_D(const NamespaceJob); 4540 + Q_D( const NamespaceJob ); 4541 return d->personalNamespaces; 4542 } 4543 4544 QList<MailBoxDescriptor> NamespaceJob::userNamespaces() const 4545 { 4546 - Q_D(const NamespaceJob); 4547 + Q_D( const NamespaceJob ); 4548 return d->userNamespaces; 4549 } 4550 4551 QList<MailBoxDescriptor> NamespaceJob::sharedNamespaces() const 4552 { 4553 - Q_D(const NamespaceJob); 4554 + Q_D( const NamespaceJob ); 4555 return d->sharedNamespaces; 4556 } 4557 4558 bool NamespaceJob::containsEmptyNamespace() const 4559 { 4560 - Q_D(const NamespaceJob); 4561 + Q_D( const NamespaceJob ); 4562 QList<MailBoxDescriptor> completeList = d->personalNamespaces 4563 + d->userNamespaces 4564 + d->sharedNamespaces; 4565 @@ -118,16 +118,16 @@ bool NamespaceJob::containsEmptyNamespace() const 4566 4567 void NamespaceJob::doStart() 4568 { 4569 - Q_D(NamespaceJob); 4570 + Q_D( NamespaceJob ); 4571 d->tags << d->sessionInternal()->sendCommand( "NAMESPACE" ); 4572 } 4573 4574 void NamespaceJob::handleResponse( const Message &response ) 4575 { 4576 - Q_D(NamespaceJob); 4577 - if (handleErrorReplies(response) == NotHandled) { 4578 - if ( response.content.size() >= 5 4579 - && response.content[1].toString()=="NAMESPACE" ) { 4580 + Q_D( NamespaceJob ); 4581 + if ( handleErrorReplies( response ) == NotHandled ) { 4582 + if ( response.content.size() >= 5 && 4583 + response.content[1].toString() == "NAMESPACE" ) { 4584 // Personal namespaces 4585 d->personalNamespaces = d->processNamespaceList( response.content[2].toList() ); 4586 4587 @@ -141,3 +141,4 @@ void NamespaceJob::handleResponse( const Message &response ) 4588 } 4589 4590 #include "namespacejob.moc" 4591 + 4592 diff --git a/kimap/namespacejob.h b/kimap/namespacejob.h 4593 index 130c788..429d1d8 100644 4594 --- a/kimap/namespacejob.h 4595 +++ b/kimap/namespacejob.h 4596 @@ -34,7 +34,7 @@ class NamespaceJobPrivate; 4597 class KIMAP_EXPORT NamespaceJob : public Job 4598 { 4599 Q_OBJECT 4600 - Q_DECLARE_PRIVATE(NamespaceJob) 4601 + Q_DECLARE_PRIVATE( NamespaceJob ) 4602 4603 friend class SessionPrivate; 4604 4605 diff --git a/kimap/quotajobbase.cpp b/kimap/quotajobbase.cpp 4606 index 16737ce..5ae6d56 100644 4607 --- a/kimap/quotajobbase.cpp 4608 +++ b/kimap/quotajobbase.cpp 4609 @@ -22,8 +22,8 @@ 4610 #include "message_p.h" 4611 #include "session_p.h" 4612 4613 -#include <klocale.h> 4614 -#include <kdebug.h> 4615 +#include <KDE/KLocalizedString> 4616 +#include <KDE/KDebug> 4617 4618 using namespace KIMAP; 4619 4620 @@ -37,7 +37,7 @@ QMap<QByteArray, QPair<qint64, qint64> > QuotaJobBasePrivate::readQuota( const M 4621 QByteArray resource = quotas[i].toUpper(); 4622 qint64 usage = quotas[i+1].toInt(); 4623 qint64 limit = quotas[i+2].toInt(); 4624 - quotaMap[resource] = qMakePair(usage, limit); 4625 + quotaMap[resource] = qMakePair( usage, limit ); 4626 i += 3; 4627 } 4628 4629 @@ -45,45 +45,40 @@ QMap<QByteArray, QPair<qint64, qint64> > QuotaJobBasePrivate::readQuota( const M 4630 } 4631 4632 QuotaJobBase::QuotaJobBase( Session *session ) 4633 - : Job( *new QuotaJobBasePrivate(session, i18n("QuotaJobBase")) ) 4634 + : Job( *new QuotaJobBasePrivate( session, i18n( "QuotaJobBase" ) ) ) 4635 { 4636 } 4637 4638 - 4639 QuotaJobBase::QuotaJobBase( JobPrivate &dd ) 4640 - : Job(dd) 4641 + : Job( dd ) 4642 { 4643 - 4644 } 4645 4646 QuotaJobBase::~QuotaJobBase() 4647 { 4648 } 4649 4650 - 4651 qint64 QuotaJobBase::usage(const QByteArray& resource) 4652 { 4653 - Q_D(QuotaJobBase); 4654 + Q_D( QuotaJobBase ); 4655 4656 QByteArray r = resource.toUpper(); 4657 4658 - if (d->quota.contains(r)) { 4659 + if ( d->quota.contains( r ) ) { 4660 return d->quota[r].first; 4661 } 4662 - 4663 return -1; 4664 } 4665 4666 qint64 QuotaJobBase::limit(const QByteArray& resource) 4667 { 4668 - Q_D(QuotaJobBase); 4669 + Q_D( QuotaJobBase ); 4670 4671 QByteArray r = resource.toUpper(); 4672 4673 - if (d->quota.contains(r)) { 4674 + if ( d->quota.contains( r ) ) { 4675 return d->quota[r].second; 4676 } 4677 - 4678 return -1; 4679 } 4680 4681 diff --git a/kimap/quotajobbase.h b/kimap/quotajobbase.h 4682 index 640ca0d..29b06bb 100644 4683 --- a/kimap/quotajobbase.h 4684 +++ b/kimap/quotajobbase.h 4685 @@ -42,7 +42,7 @@ class QuotaJobBasePrivate; 4686 class KIMAP_EXPORT QuotaJobBase : public Job 4687 { 4688 Q_OBJECT 4689 - Q_DECLARE_PRIVATE(QuotaJobBase) 4690 + Q_DECLARE_PRIVATE( QuotaJobBase ) 4691 4692 friend class SessionPrivate; 4693 4694 diff --git a/kimap/quotajobbase_p.h b/kimap/quotajobbase_p.h 4695 index aedc752..dc4313b 100644 4696 --- a/kimap/quotajobbase_p.h 4697 +++ b/kimap/quotajobbase_p.h 4698 @@ -24,12 +24,14 @@ 4699 #include "message_p.h" 4700 #include "session.h" 4701 4702 +#include <QMap> 4703 + 4704 namespace KIMAP 4705 { 4706 class QuotaJobBasePrivate : public JobPrivate 4707 { 4708 public: 4709 - QuotaJobBasePrivate( Session *session, const QString& name ) : JobPrivate(session, name) 4710 + QuotaJobBasePrivate( Session *session, const QString& name ) : JobPrivate( session, name ) 4711 {} 4712 4713 ~QuotaJobBasePrivate() { } 4714 diff --git a/kimap/renamejob.cpp b/kimap/renamejob.cpp 4715 index 1ec357d..a8c8505 100644 4716 --- a/kimap/renamejob.cpp 4717 +++ b/kimap/renamejob.cpp 4718 @@ -19,8 +19,8 @@ 4719 4720 #include "renamejob.h" 4721 4722 -#include <klocale.h> 4723 -#include <kdebug.h> 4724 +#include <KDE/KLocalizedString> 4725 +#include <KDE/KDebug> 4726 4727 #include "job_p.h" 4728 #include "message_p.h" 4729 @@ -32,7 +32,7 @@ namespace KIMAP 4730 class RenameJobPrivate : public JobPrivate 4731 { 4732 public: 4733 - RenameJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { } 4734 + RenameJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { } 4735 ~RenameJobPrivate() { } 4736 4737 QString sourceMailBox; 4738 @@ -43,7 +43,7 @@ namespace KIMAP 4739 using namespace KIMAP; 4740 4741 RenameJob::RenameJob( Session *session ) 4742 - : Job( *new RenameJobPrivate(session, i18n("Rename")) ) 4743 + : Job( *new RenameJobPrivate( session, i18n( "Rename" ) ) ) 4744 { 4745 } 4746 4747 @@ -53,33 +53,34 @@ RenameJob::~RenameJob() 4748 4749 void RenameJob::doStart() 4750 { 4751 - Q_D(RenameJob); 4752 - d->tags << d->sessionInternal()->sendCommand( "RENAME", '\"' + KIMAP::encodeImapFolderName( d->sourceMailBox.toUtf8() ) + "\" \"" 4753 - + KIMAP::encodeImapFolderName( d->destinationMailBox.toUtf8() )+ '\"' ); 4754 + Q_D( RenameJob ); 4755 + d->tags << d->sessionInternal()->sendCommand( "RENAME", '\"' + KIMAP::encodeImapFolderName( d->sourceMailBox.toUtf8() ) + 4756 + "\" \"" + KIMAP::encodeImapFolderName( d->destinationMailBox.toUtf8() ) + '\"' ); 4757 } 4758 4759 void RenameJob::setSourceMailBox( const QString &mailBox ) 4760 { 4761 - Q_D(RenameJob); 4762 + Q_D( RenameJob ); 4763 d->sourceMailBox = mailBox; 4764 } 4765 4766 QString RenameJob::sourceMailBox() const 4767 { 4768 - Q_D(const RenameJob); 4769 + Q_D( const RenameJob ); 4770 return d->sourceMailBox; 4771 } 4772 4773 void RenameJob::setDestinationMailBox( const QString &mailBox ) 4774 { 4775 - Q_D(RenameJob); 4776 + Q_D( RenameJob ); 4777 d->destinationMailBox = mailBox; 4778 } 4779 4780 QString RenameJob::destinationMailBox() const 4781 { 4782 - Q_D(const RenameJob); 4783 + Q_D( const RenameJob ); 4784 return d->destinationMailBox; 4785 } 4786 4787 #include "renamejob.moc" 4788 + 4789 diff --git a/kimap/renamejob.h b/kimap/renamejob.h 4790 index 84ae96a..28949f5 100644 4791 --- a/kimap/renamejob.h 4792 +++ b/kimap/renamejob.h 4793 @@ -32,7 +32,7 @@ class RenameJobPrivate; 4794 class KIMAP_EXPORT RenameJob : public Job 4795 { 4796 Q_OBJECT 4797 - Q_DECLARE_PRIVATE(RenameJob) 4798 + Q_DECLARE_PRIVATE( RenameJob ) 4799 4800 friend class SessionPrivate; 4801 4802 diff --git a/kimap/rfccodecs.cpp b/kimap/rfccodecs.cpp 4803 index f102514..04cc886 100644 4804 --- a/kimap/rfccodecs.cpp 4805 +++ b/kimap/rfccodecs.cpp 4806 @@ -331,7 +331,7 @@ const QString KIMAP::decodeRFC2047String( const QString &str, 4807 } 4808 4809 // FIXME get rid of the conversion? 4810 - QByteArray aStr = str.toAscii (); // QString.length() means Unicode chars 4811 + QByteArray aStr = str.toLatin1 (); // QString.length() means Unicode chars 4812 QByteArray result; 4813 char *pos, *beg, *end, *mid = 0; 4814 QByteArray cstr; 4815 @@ -353,8 +353,9 @@ const QString KIMAP::decodeRFC2047String( const QString &str, 4816 for ( i = 2, pos += 2; 4817 i < maxLen && 4818 ( *pos != '?' && ( ispunct( *pos ) || isalnum ( *pos ) ) ); 4819 - i++ ) 4820 + i++ ) { 4821 pos++; 4822 + } 4823 if ( *pos != '?' || i < 4 || i >= maxLen ) { 4824 valid = false; 4825 } else { 4826 @@ -376,7 +377,7 @@ const QString KIMAP::decodeRFC2047String( const QString &str, 4827 } 4828 pos += 3; 4829 i += 3; 4830 -// qDebug() << "Charset:" << charset << "- Language:" << language << "-'" << pos << "'"; 4831 +// kDebug() << "Charset:" << charset << "- Language:" << language << "-'" << pos << "'"; 4832 } 4833 if ( valid ) { 4834 mid = pos; 4835 @@ -401,10 +402,10 @@ const QString KIMAP::decodeRFC2047String( const QString &str, 4836 cstr[i] = ' '; 4837 } 4838 } 4839 -// qDebug() << "before QP '" 4840 +// kDebug() << "before QP '" 4841 // << cstr << "'"; 4842 cstr = KCodecs::quotedPrintableDecode( cstr ); 4843 -// qDebug() << "after QP '" 4844 +// kDebug() << "after QP '" 4845 // << cstr << "'"; 4846 } else { 4847 // decode base64 text 4848 @@ -418,7 +419,7 @@ const QString KIMAP::decodeRFC2047String( const QString &str, 4849 4850 pos = end - 1; 4851 } else { 4852 -// qDebug() << "invalid"; 4853 +// kDebug() << "invalid"; 4854 //result += "=?"; 4855 //pos = beg -1; // because pos gets increased shortly afterwards 4856 pos = beg - 2; 4857 @@ -427,9 +428,9 @@ const QString KIMAP::decodeRFC2047String( const QString &str, 4858 } 4859 } 4860 if ( !charset.isEmpty () ) { 4861 - QTextCodec *aCodec = codecForName( charset.toAscii () ); 4862 + QTextCodec *aCodec = codecForName( charset.toLatin1 () ); 4863 if ( aCodec ) { 4864 -// qDebug() << "Codec is" << aCodec->name(); 4865 +// kDebug() << "Codec is" << aCodec->name(); 4866 return aCodec->toUnicode( result ); 4867 } 4868 } 4869 @@ -636,7 +637,7 @@ const QString KIMAP::decodeRFC2231String( const QString &str ) 4870 QString st = str.mid ( l + 1 ); 4871 QString language = str.mid ( p + 1, l - p - 1 ); 4872 4873 - //qDebug() << "Charset:" << charset << "Language:" << language; 4874 + //kDebug() << "Charset:" << charset << "Language:" << language; 4875 4876 char ch, ch2; 4877 p = 0; 4878 diff --git a/kimap/searchjob.cpp b/kimap/searchjob.cpp 4879 index ede53a3..0e91010 100644 4880 --- a/kimap/searchjob.cpp 4881 +++ b/kimap/searchjob.cpp 4882 @@ -19,8 +19,8 @@ 4883 4884 #include "searchjob.h" 4885 4886 -#include <klocale.h> 4887 -#include <kdebug.h> 4888 +#include <KDE/KLocalizedString> 4889 +#include <KDE/KDebug> 4890 4891 #include <QtCore/QDate> 4892 4893 @@ -35,7 +35,7 @@ namespace KIMAP 4894 class SearchJobPrivate : public JobPrivate 4895 { 4896 public: 4897 - SearchJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name), logic(SearchJob::And) { 4898 + SearchJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ), logic( SearchJob::And ) { 4899 criteriaMap[SearchJob::All] = "ALL"; 4900 criteriaMap[SearchJob::Answered] = "ANSWERED"; 4901 criteriaMap[SearchJob::BCC] = "BCC"; 4902 @@ -89,7 +89,6 @@ namespace KIMAP 4903 } 4904 ~SearchJobPrivate() { } 4905 4906 - 4907 QByteArray charset; 4908 QList<QByteArray> criterias; 4909 QMap<SearchJob::SearchCriteria, QByteArray > criteriaMap; 4910 @@ -105,7 +104,7 @@ namespace KIMAP 4911 using namespace KIMAP; 4912 4913 SearchJob::SearchJob( Session *session ) 4914 - : Job( *new SearchJobPrivate(session, i18nc("Name of the search job", "Search")) ) 4915 + : Job( *new SearchJobPrivate( session, i18nc( "Name of the search job", "Search" ) ) ) 4916 { 4917 } 4918 4919 @@ -115,37 +114,41 @@ SearchJob::~SearchJob() 4920 4921 void SearchJob::doStart() 4922 { 4923 - Q_D(SearchJob); 4924 + Q_D( SearchJob ); 4925 4926 QByteArray searchKey; 4927 4928 - if (!d->charset.isEmpty()) { 4929 + if ( !d->charset.isEmpty() ) { 4930 searchKey = "CHARSET " + d->charset; 4931 } 4932 4933 - if (d->logic == SearchJob::Not) { 4934 - searchKey += "NOT"; 4935 - } else if (d->logic == SearchJob::Or) { 4936 - searchKey += "OR"; 4937 + if ( d->logic == SearchJob::Not ) { 4938 + searchKey += "NOT "; 4939 + } else if ( d->logic == SearchJob::Or && d->criterias.size() > 1 ) { 4940 + searchKey += "OR "; 4941 } 4942 4943 if ( d->logic == SearchJob::And ) { 4944 - for ( int i = 0; i<d->criterias.size(); i++ ) { 4945 + for ( int i = 0; i < d->criterias.size(); i++ ) { 4946 const QByteArray key = d->criterias.at( i ); 4947 - if ( i>0 ) searchKey+= ' '; 4948 + if ( i > 0 ) { 4949 + searchKey += ' '; 4950 + } 4951 searchKey += key; 4952 } 4953 } else { 4954 - for ( int i = 0; i<d->criterias.size(); i++ ) { 4955 + for ( int i = 0; i < d->criterias.size(); i++ ) { 4956 const QByteArray key = d->criterias.at( i ); 4957 - if ( i>0 ) searchKey+= ' '; 4958 + if ( i > 0 ) { 4959 + searchKey += ' '; 4960 + } 4961 searchKey += '(' + key + ')'; 4962 } 4963 } 4964 4965 QByteArray command = "SEARCH"; 4966 if ( d->uidBased ) { 4967 - command = "UID "+ command; 4968 + command = "UID " + command; 4969 } 4970 4971 d->tags << d->sessionInternal()->sendCommand( command, searchKey ); 4972 @@ -153,44 +156,43 @@ void SearchJob::doStart() 4973 4974 void SearchJob::handleResponse( const Message &response ) 4975 { 4976 - Q_D(SearchJob); 4977 + Q_D( SearchJob ); 4978 4979 - if (handleErrorReplies(response) == NotHandled ) { 4980 + if ( handleErrorReplies( response ) == NotHandled ) { 4981 if ( response.content[0].toString() == "+" ) { 4982 d->sessionInternal()->sendData( d->contents[d->nextContent] ); 4983 d->nextContent++; 4984 } else if ( response.content[1].toString() == "SEARCH" ) { 4985 - for(int i = 2; i < response.content.size(); i++) { 4986 - d->results.append(response.content[i].toString().toInt()); 4987 + for ( int i = 2; i < response.content.size(); i++ ) { 4988 + d->results.append( response.content[i].toString().toInt() ); 4989 } 4990 } 4991 } 4992 } 4993 4994 - 4995 void SearchJob::setCharset( const QByteArray &charset ) 4996 { 4997 - Q_D(SearchJob); 4998 + Q_D( SearchJob ); 4999 d->charset = charset; 5000 } 5001 5002 QByteArray SearchJob::charset() const 5003 { 5004 - Q_D(const SearchJob); 5005 + Q_D( const SearchJob ); 5006 return d->charset; 5007 } 5008 5009 void SearchJob::setSearchLogic( SearchLogic logic ) 5010 { 5011 - Q_D(SearchJob); 5012 + Q_D( SearchJob ); 5013 d->logic = logic; 5014 } 5015 5016 void SearchJob::addSearchCriteria( SearchCriteria criteria ) 5017 { 5018 - Q_D(SearchJob); 5019 + Q_D( SearchJob ); 5020 5021 - switch (criteria) { 5022 + switch ( criteria ) { 5023 case All: 5024 case Answered: 5025 case Deleted: 5026 @@ -205,36 +207,34 @@ void SearchJob::addSearchCriteria( SearchCriteria criteria ) 5027 case Undraft: 5028 case Unflagged: 5029 case Unseen: 5030 - d->criterias.append(d->criteriaMap[criteria]); 5031 + d->criterias.append( d->criteriaMap[criteria] ); 5032 break; 5033 default: 5034 //TODO Discuss if we keep error checking here, or accept anything, even if it is wrong 5035 - qDebug() << "Criteria " << d->criteriaMap[criteria] << " needs an argument, but none was specified."; 5036 + kDebug() << "Criteria " << d->criteriaMap[criteria] << " needs an argument, but none was specified."; 5037 break; 5038 } 5039 } 5040 5041 - 5042 void SearchJob::addSearchCriteria( SearchCriteria criteria, int argument ) 5043 { 5044 - Q_D(SearchJob); 5045 - switch (criteria) { 5046 + Q_D( SearchJob ); 5047 + switch ( criteria ) { 5048 case Larger: 5049 case Smaller: 5050 - d->criterias.append(d->criteriaMap[criteria] + ' ' + QByteArray::number(argument)); 5051 + d->criterias.append( d->criteriaMap[criteria] + ' ' + QByteArray::number( argument ) ); 5052 break; 5053 default: 5054 //TODO Discuss if we keep error checking here, or accept anything, even if it is wrong 5055 - qDebug() << "Criteria " << d->criteriaMap[criteria] << " doesn't accept an integer as an argument."; 5056 + kDebug() << "Criteria " << d->criteriaMap[criteria] << " doesn't accept an integer as an argument."; 5057 break; 5058 } 5059 } 5060 5061 - 5062 void SearchJob::addSearchCriteria( SearchCriteria criteria, const QByteArray &argument ) 5063 { 5064 - Q_D(SearchJob); 5065 - switch (criteria) { 5066 + Q_D( SearchJob ); 5067 + switch ( criteria ) { 5068 case BCC: 5069 case Body: 5070 case CC: 5071 @@ -242,71 +242,71 @@ void SearchJob::addSearchCriteria( SearchCriteria criteria, const QByteArray &ar 5072 case Subject: 5073 case Text: 5074 case To: 5075 - d->contents.append(argument); 5076 - d->criterias.append(d->criteriaMap[criteria] + " {" + QByteArray::number(argument.size()) + '}'); 5077 + d->contents.append( argument ); 5078 + d->criterias.append( d->criteriaMap[criteria] + " {" + QByteArray::number( argument.size() ) + '}' ); 5079 break; 5080 case Keyword: 5081 case Unkeyword: 5082 case Header: 5083 case Uid: 5084 - d->criterias.append(d->criteriaMap[criteria] + ' ' + argument); 5085 + d->criterias.append( d->criteriaMap[criteria] + ' ' + argument ); 5086 break; 5087 default: 5088 //TODO Discuss if we keep error checking here, or accept anything, even if it is wrong 5089 - qDebug() << "Criteria " << d->criteriaMap[criteria] << " doesn't accept any argument."; 5090 + kDebug() << "Criteria " << d->criteriaMap[criteria] << " doesn't accept any argument."; 5091 break; 5092 } 5093 } 5094 5095 void SearchJob::addSearchCriteria( SearchCriteria criteria, const QDate &argument ) 5096 { 5097 - Q_D(SearchJob); 5098 - switch (criteria) { 5099 + Q_D( SearchJob ); 5100 + switch ( criteria ) { 5101 case Before: 5102 case On: 5103 case SentBefore: 5104 case SentSince: 5105 case Since: { 5106 - QByteArray date = QByteArray::number(argument.day()) + '-'; 5107 + QByteArray date = QByteArray::number( argument.day() ) + '-'; 5108 date += d->months[argument.month()] + '-'; 5109 - date += QByteArray::number(argument.year()); 5110 - d->criterias.append(d->criteriaMap[criteria] + " \"" + date + '\"'); 5111 + date += QByteArray::number( argument.year() ); 5112 + d->criterias.append( d->criteriaMap[criteria] + " \"" + date + '\"' ); 5113 break; 5114 } 5115 default: 5116 //TODO Discuss if we keep error checking here, or accept anything, even if it is wrong 5117 - qDebug() << "Criteria " << d->criteriaMap[criteria] << " doesn't accept a date as argument."; 5118 + kDebug() << "Criteria " << d->criteriaMap[criteria] << " doesn't accept a date as argument."; 5119 break; 5120 } 5121 } 5122 5123 void SearchJob::addSearchCriteria( const QByteArray &searchCriteria ) 5124 { 5125 - Q_D(SearchJob); 5126 - d->criterias.append(searchCriteria); 5127 + Q_D( SearchJob ); 5128 + d->criterias.append( searchCriteria ); 5129 } 5130 5131 void SearchJob::setUidBased(bool uidBased) 5132 { 5133 - Q_D(SearchJob); 5134 + Q_D( SearchJob ); 5135 d->uidBased = uidBased; 5136 } 5137 5138 bool SearchJob::isUidBased() const 5139 { 5140 - Q_D(const SearchJob); 5141 + Q_D( const SearchJob ); 5142 return d->uidBased; 5143 } 5144 5145 QList<qint64> SearchJob::results() const 5146 { 5147 - Q_D(const SearchJob); 5148 + Q_D( const SearchJob ); 5149 return d->results; 5150 } 5151 5152 QList<int> SearchJob::foundItems() 5153 { 5154 - Q_D(const SearchJob); 5155 + Q_D( const SearchJob ); 5156 5157 QList<int> results; 5158 qCopy( d->results.begin(), d->results.end(), results.begin() ); 5159 @@ -314,4 +314,5 @@ QList<int> SearchJob::foundItems() 5160 return results; 5161 } 5162 5163 -#include "searchjob.moc" 5164 \ No newline at end of file 5165 +#include "searchjob.moc" 5166 + 5167 diff --git a/kimap/searchjob.h b/kimap/searchjob.h 5168 index 077e8d4..1b53c1e 100644 5169 --- a/kimap/searchjob.h 5170 +++ b/kimap/searchjob.h 5171 @@ -35,7 +35,7 @@ class SearchJobPrivate; 5172 class KIMAP_EXPORT SearchJob : public Job 5173 { 5174 Q_OBJECT 5175 - Q_DECLARE_PRIVATE(SearchJob) 5176 + Q_DECLARE_PRIVATE( SearchJob ) 5177 5178 friend class SessionPrivate; 5179 5180 diff --git a/kimap/selectjob.cpp b/kimap/selectjob.cpp 5181 index b18130d..bcc65c6 100644 5182 --- a/kimap/selectjob.cpp 5183 +++ b/kimap/selectjob.cpp 5184 @@ -19,7 +19,8 @@ 5185 5186 #include "selectjob.h" 5187 5188 -#include <klocale.h> 5189 +#include <KDE/KLocalizedString> 5190 +#include <kdebug.h> 5191 5192 #include "job_p.h" 5193 #include "message_p.h" 5194 @@ -32,8 +33,8 @@ namespace KIMAP 5195 { 5196 public: 5197 SelectJobPrivate( Session *session, const QString& name ) 5198 - : JobPrivate(session, name), readOnly(false), messageCount(-1), recentCount(-1), 5199 - firstUnseenIndex(-1), uidValidity(-1), nextUid(-1) { } 5200 + : JobPrivate( session, name ), readOnly( false ), messageCount( -1 ), recentCount( -1 ), 5201 + firstUnseenIndex( -1 ), uidValidity( -1 ), nextUid( -1 ) { } 5202 ~SelectJobPrivate() { } 5203 5204 QString mailBox; 5205 @@ -52,7 +53,7 @@ namespace KIMAP 5206 using namespace KIMAP; 5207 5208 SelectJob::SelectJob( Session *session ) 5209 - : Job( *new SelectJobPrivate(session, i18nc("name of the select job", "Select")) ) 5210 + : Job( *new SelectJobPrivate( session, i18nc( "name of the select job", "Select" ) ) ) 5211 { 5212 } 5213 5214 @@ -62,73 +63,73 @@ SelectJob::~SelectJob() 5215 5216 void SelectJob::setMailBox( const QString &mailBox ) 5217 { 5218 - Q_D(SelectJob); 5219 + Q_D( SelectJob ); 5220 d->mailBox = mailBox; 5221 } 5222 5223 QString SelectJob::mailBox() const 5224 { 5225 - Q_D(const SelectJob); 5226 + Q_D( const SelectJob ); 5227 return d->mailBox; 5228 } 5229 5230 void SelectJob::setOpenReadOnly( bool readOnly ) 5231 { 5232 - Q_D(SelectJob); 5233 + Q_D( SelectJob ); 5234 d->readOnly = readOnly; 5235 } 5236 5237 bool SelectJob::isOpenReadOnly() const 5238 { 5239 - Q_D(const SelectJob); 5240 + Q_D( const SelectJob ); 5241 return d->readOnly; 5242 } 5243 5244 QList<QByteArray> SelectJob::flags() const 5245 { 5246 - Q_D(const SelectJob); 5247 + Q_D( const SelectJob ); 5248 return d->flags; 5249 } 5250 5251 QList<QByteArray> SelectJob::permanentFlags() const 5252 { 5253 - Q_D(const SelectJob); 5254 + Q_D( const SelectJob ); 5255 return d->permanentFlags; 5256 } 5257 5258 int SelectJob::messageCount() const 5259 { 5260 - Q_D(const SelectJob); 5261 + Q_D( const SelectJob ); 5262 return d->messageCount; 5263 } 5264 5265 int SelectJob::recentCount() const 5266 { 5267 - Q_D(const SelectJob); 5268 + Q_D( const SelectJob ); 5269 return d->recentCount; 5270 } 5271 5272 int SelectJob::firstUnseenIndex() const 5273 { 5274 - Q_D(const SelectJob); 5275 + Q_D( const SelectJob ); 5276 return d->firstUnseenIndex; 5277 } 5278 5279 qint64 SelectJob::uidValidity() const 5280 { 5281 - Q_D(const SelectJob); 5282 + Q_D( const SelectJob ); 5283 return d->uidValidity; 5284 } 5285 5286 qint64 SelectJob::nextUid() const 5287 { 5288 - Q_D(const SelectJob); 5289 + Q_D( const SelectJob ); 5290 return d->nextUid; 5291 } 5292 5293 void SelectJob::doStart() 5294 { 5295 - Q_D(SelectJob); 5296 + Q_D( SelectJob ); 5297 5298 QByteArray command = "SELECT"; 5299 if ( d->readOnly ) { 5300 @@ -140,56 +141,65 @@ void SelectJob::doStart() 5301 5302 void SelectJob::handleResponse( const Message &response ) 5303 { 5304 - Q_D(SelectJob); 5305 + Q_D( SelectJob ); 5306 5307 - if ( handleErrorReplies(response) == NotHandled) { 5308 + if ( handleErrorReplies( response ) == NotHandled ) { 5309 if ( response.content.size() >= 2 ) { 5310 QByteArray code = response.content[1].toString(); 5311 5312 - if ( code=="OK" ) { 5313 - if ( response.responseCode.size() < 2 ) return; 5314 + if ( code == "OK" ) { 5315 + if ( response.responseCode.size() < 2 ) { 5316 + return; 5317 + } 5318 5319 code = response.responseCode[0].toString(); 5320 5321 - if ( code=="PERMANENTFLAGS" ) { 5322 + if ( code == "PERMANENTFLAGS" ) { 5323 d->permanentFlags = response.responseCode[1].toList(); 5324 } else { 5325 bool isInt; 5326 5327 - if ( code=="UIDVALIDITY" ) { 5328 - qint64 value = response.responseCode[1].toString().toLongLong(&isInt); 5329 - if ( !isInt ) return; 5330 + if ( code == "UIDVALIDITY" ) { 5331 + qint64 value = response.responseCode[1].toString().toLongLong( &isInt ); 5332 + if ( !isInt ) { 5333 + return; 5334 + } 5335 d->uidValidity = value; 5336 } else { 5337 - qint64 value = response.responseCode[1].toString().toLongLong(&isInt); 5338 - if ( !isInt ) return; 5339 - if ( code=="UNSEEN" ) { 5340 + qint64 value = response.responseCode[1].toString().toLongLong( &isInt ); 5341 + if ( !isInt ) { 5342 + return; 5343 + } 5344 + if ( code == "UNSEEN" ) { 5345 d->firstUnseenIndex = value; 5346 - } else if ( code=="UIDNEXT" ) { 5347 + } else if ( code == "UIDNEXT" ) { 5348 d->nextUid = value; 5349 } 5350 } 5351 } 5352 - } else if ( code=="FLAGS" ) { 5353 + } else if ( code == "FLAGS" ) { 5354 d->flags = response.content[2].toList(); 5355 } else { 5356 bool isInt; 5357 - int value = response.content[1].toString().toInt(&isInt); 5358 - if ( !isInt || response.content.size()<3 ) return; 5359 + int value = response.content[1].toString().toInt( &isInt ); 5360 + if ( !isInt || response.content.size() < 3 ) { 5361 + return; 5362 + } 5363 5364 code = response.content[2].toString(); 5365 - if ( code=="EXISTS" ) { 5366 + if ( code == "EXISTS" ) { 5367 d->messageCount = value; 5368 - } else if ( code=="RECENT" ) { 5369 + } else if ( code == "RECENT" ) { 5370 d->recentCount = value; 5371 } 5372 } 5373 } else { 5374 - qDebug("%s", response.toString().constData()); 5375 + kDebug() << response.toString(); 5376 } 5377 } else { 5378 Q_ASSERT( error() || d->m_session->selectedMailBox() == d->mailBox ); 5379 } 5380 } 5381 5382 -#include "selectjob.moc" 5383 \ No newline at end of file 5384 +#include "selectjob.moc" 5385 + 5386 diff --git a/kimap/selectjob.h b/kimap/selectjob.h 5387 index c67d28c..87157b5 100644 5388 --- a/kimap/selectjob.h 5389 +++ b/kimap/selectjob.h 5390 @@ -33,7 +33,7 @@ class SelectJobPrivate; 5391 class KIMAP_EXPORT SelectJob : public Job 5392 { 5393 Q_OBJECT 5394 - Q_DECLARE_PRIVATE(SelectJob) 5395 + Q_DECLARE_PRIVATE( SelectJob ) 5396 5397 friend class SessionPrivate; 5398 5399 diff --git a/kimap/session.cpp b/kimap/session.cpp 5400 index 031508b..2b23adc 100644 5401 --- a/kimap/session.cpp 5402 +++ b/kimap/session.cpp 5403 @@ -27,7 +27,8 @@ 5404 #include <QtCore/QDebug> 5405 #include <QtCore/QTimer> 5406 5407 -#include <klocale.h> 5408 +#include <KDebug> 5409 +#include <KDE/KLocalizedString> 5410 5411 #include "job.h" 5412 #include "loginjob.h" 5413 @@ -36,14 +37,14 @@ 5414 #include "sessionthread_p.h" 5415 #include "rfccodecs.h" 5416 5417 -Q_DECLARE_METATYPE(KTcpSocket::SslVersion) 5418 -Q_DECLARE_METATYPE(QSslSocket::SslMode) 5419 +Q_DECLARE_METATYPE( KTcpSocket::SslVersion ) 5420 +Q_DECLARE_METATYPE( QSslSocket::SslMode ) 5421 static const int _kimap_sslVersionId = qRegisterMetaType<KTcpSocket::SslVersion>(); 5422 5423 using namespace KIMAP; 5424 5425 Session::Session( const QString &hostName, quint16 port, QObject *parent) 5426 - : QObject(parent), d(new SessionPrivate(this)) 5427 + : QObject( parent ), d( new SessionPrivate( this ) ) 5428 { 5429 if ( !qgetenv( "KIMAP_LOGFILE" ).isEmpty() ) { 5430 d->logger = new SessionLogger; 5431 @@ -53,13 +54,23 @@ Session::Session( const QString &hostName, quint16 port, QObject *parent) 5432 d->state = Disconnected; 5433 d->jobRunning = false; 5434 5435 - d->thread = new SessionThread(hostName, port, this); 5436 - connect(d->thread, SIGNAL(encryptionNegotiationResult(bool,KTcpSocket::SslVersion)), 5437 - d, SLOT(onEncryptionNegotiationResult(bool,KTcpSocket::SslVersion))); 5438 - connect(d->thread, SIGNAL(sslError(KSslErrorUiData)), this, SLOT(handleSslError(KSslErrorUiData))); 5439 + d->thread = new SessionThread( hostName, port ); 5440 + connect( d->thread, SIGNAL(encryptionNegotiationResult(bool,KTcpSocket::SslVersion)), 5441 + d, SLOT(onEncryptionNegotiationResult(bool,KTcpSocket::SslVersion)) ); 5442 + connect( d->thread, SIGNAL(sslError(KSslErrorUiData)), 5443 + d, SLOT(handleSslError(KSslErrorUiData)) ); 5444 + connect( d->thread, SIGNAL(socketDisconnected()), 5445 + d, SLOT(socketDisconnected()) ); 5446 + connect( d->thread, SIGNAL(responseReceived(KIMAP::Message)), 5447 + d, SLOT(responseReceived(KIMAP::Message)) ); 5448 + connect( d->thread, SIGNAL(socketConnected()), 5449 + d, SLOT(socketConnected()) ); 5450 + connect( d->thread, SIGNAL(socketActivity()), 5451 + d, SLOT(socketActivity()) ); 5452 + connect( d->thread, SIGNAL(socketError()), 5453 + d, SLOT(socketError()) ); 5454 5455 d->startSocketTimer(); 5456 - d->thread->start(); 5457 } 5458 5459 Session::~Session() 5460 @@ -114,22 +125,19 @@ void KIMAP::Session::close() 5461 5462 void SessionPrivate::handleSslError(const KSslErrorUiData& errorData) 5463 { 5464 - if (uiProxy && uiProxy->ignoreSslError(errorData)) { 5465 - QMetaObject::invokeMethod( thread, "sslErrorHandlerResponse", Q_ARG(bool, true) ); 5466 - } else { 5467 - QMetaObject::invokeMethod( thread, "sslErrorHandlerResponse", Q_ARG(bool, false) ); 5468 - } 5469 + const bool ignoreSslError = uiProxy && uiProxy->ignoreSslError( errorData ); 5470 + thread->sslErrorHandlerResponse(ignoreSslError); 5471 } 5472 5473 SessionPrivate::SessionPrivate( Session *session ) 5474 : QObject( session ), 5475 - q(session), 5476 - state(Session::Disconnected), 5477 - logger(0), 5478 - currentJob(0), 5479 - tagCount(0), 5480 - sslVersion(KTcpSocket::UnknownSslVersion), 5481 - socketTimerInterval(30000) // By default timeouts on 30s 5482 + q( session ), 5483 + state( Session::Disconnected ), 5484 + logger( 0 ), 5485 + currentJob( 0 ), 5486 + tagCount( 0 ), 5487 + sslVersion( KTcpSocket::UnknownSslVersion ), 5488 + socketTimerInterval( 30000 ) // By default timeouts on 30s 5489 { 5490 } 5491 5492 @@ -140,20 +148,20 @@ SessionPrivate::~SessionPrivate() 5493 5494 void SessionPrivate::addJob(Job *job) 5495 { 5496 - queue.append(job); 5497 + queue.append( job ); 5498 emit q->jobQueueSizeChanged( q->jobQueueSize() ); 5499 5500 - QObject::connect( job, SIGNAL(result(KJob*)), q, SLOT(jobDone(KJob*)) ); 5501 - QObject::connect( job, SIGNAL(destroyed(QObject*)), q, SLOT(jobDestroyed(QObject*)) ); 5502 + QObject::connect( job, SIGNAL(result(KJob*)), this, SLOT(jobDone(KJob*)) ); 5503 + QObject::connect( job, SIGNAL(destroyed(QObject*)), this, SLOT(jobDestroyed(QObject*)) ); 5504 5505 - if ( state!=Session::Disconnected ) { 5506 + if ( state != Session::Disconnected ) { 5507 startNext(); 5508 } 5509 } 5510 5511 void SessionPrivate::startNext() 5512 { 5513 - QTimer::singleShot( 0, q, SLOT(doStartNext()) ); 5514 + QMetaObject::invokeMethod( this, "doStartNext" ); 5515 } 5516 5517 void SessionPrivate::doStartNext() 5518 @@ -190,13 +198,14 @@ void SessionPrivate::jobDone( KJob *job ) 5519 void SessionPrivate::jobDestroyed( QObject *job ) 5520 { 5521 queue.removeAll( static_cast<KIMAP::Job*>( job ) ); 5522 - if ( currentJob == job ) 5523 + if ( currentJob == job ) { 5524 currentJob = 0; 5525 + } 5526 } 5527 5528 void SessionPrivate::responseReceived( const Message &response ) 5529 { 5530 - if ( logger && ( state==Session::Authenticated || state==Session::Selected ) ) { 5531 + if ( logger && ( state == Session::Authenticated || state == Session::Selected ) ) { 5532 logger->dataReceived( response.toString() ); 5533 } 5534 5535 @@ -213,11 +222,11 @@ void SessionPrivate::responseReceived( const Message &response ) 5536 5537 switch ( state ) { 5538 case Session::Disconnected: 5539 - if (socketTimer.isActive()) { 5540 + if ( socketTimer.isActive() ) { 5541 stopSocketTimer(); 5542 } 5543 - if ( code=="OK" ) { 5544 - setState(Session::NotAuthenticated); 5545 + if ( code == "OK" ) { 5546 + setState( Session::NotAuthenticated ); 5547 5548 Message simplified = response; 5549 simplified.content.removeFirst(); // Strip the tag 5550 @@ -225,8 +234,8 @@ void SessionPrivate::responseReceived( const Message &response ) 5551 greeting = simplified.toString().trimmed(); // Save the server greeting 5552 5553 startNext(); 5554 - } else if ( code=="PREAUTH" ) { 5555 - setState(Session::Authenticated); 5556 + } else if ( code == "PREAUTH" ) { 5557 + setState( Session::Authenticated ); 5558 5559 Message simplified = response; 5560 simplified.content.removeFirst(); // Strip the tag 5561 @@ -239,74 +248,79 @@ void SessionPrivate::responseReceived( const Message &response ) 5562 } 5563 return; 5564 case Session::NotAuthenticated: 5565 - if ( code=="OK" && tag==authTag ) { 5566 - setState(Session::Authenticated); 5567 + if ( code == "OK" && tag == authTag ) { 5568 + setState( Session::Authenticated ); 5569 } 5570 break; 5571 case Session::Authenticated: 5572 - if ( code=="OK" && tag==selectTag ) { 5573 - setState(Session::Selected); 5574 + if ( code == "OK" && tag == selectTag ) { 5575 + setState( Session::Selected ); 5576 currentMailBox = upcomingMailBox; 5577 } 5578 break; 5579 case Session::Selected: 5580 - if ( ( code=="OK" && tag==closeTag ) 5581 - || ( code!="OK" && tag==selectTag) ) { 5582 - setState(Session::Authenticated); 5583 + if ( ( code == "OK" && tag == closeTag ) || 5584 + ( code != "OK" && tag == selectTag ) ) { 5585 + setState( Session::Authenticated ); 5586 currentMailBox = QByteArray(); 5587 - } else if ( code=="OK" && tag==selectTag ) { 5588 + } else if ( code == "OK" && tag == selectTag ) { 5589 currentMailBox = upcomingMailBox; 5590 } 5591 break; 5592 } 5593 5594 - if (tag==authTag) authTag.clear(); 5595 - if (tag==selectTag) selectTag.clear(); 5596 - if (tag==closeTag) closeTag.clear(); 5597 + if ( tag == authTag ) { 5598 + authTag.clear(); 5599 + } 5600 + if ( tag == selectTag ) { 5601 + selectTag.clear(); 5602 + } 5603 + if ( tag == closeTag ) { 5604 + closeTag.clear(); 5605 + } 5606 5607 // If a job is running forward it the response 5608 - if ( currentJob!=0 ) { 5609 + if ( currentJob != 0 ) { 5610 restartSocketTimer(); 5611 currentJob->handleResponse( response ); 5612 } else { 5613 qWarning() << "A message was received from the server with no job to handle it:" 5614 << response.toString() 5615 - << '('+response.toString().toHex()+')'; 5616 + << '(' + response.toString().toHex() + ')'; 5617 } 5618 } 5619 5620 void SessionPrivate::setState(Session::State s) 5621 { 5622 - if (s != state) { 5623 + if ( s != state ) { 5624 Session::State oldState = state; 5625 state = s; 5626 - emit q->stateChanged(state, oldState); 5627 + emit q->stateChanged( state, oldState ); 5628 } 5629 } 5630 5631 QByteArray SessionPrivate::sendCommand( const QByteArray &command, const QByteArray &args ) 5632 { 5633 - QByteArray tag = 'A' + QByteArray::number(++tagCount).rightJustified(6, '0'); 5634 + QByteArray tag = 'A' + QByteArray::number( ++tagCount ).rightJustified( 6, '0' ); 5635 5636 - QByteArray payload = tag+' '+command; 5637 + QByteArray payload = tag + ' ' + command; 5638 if ( !args.isEmpty() ) { 5639 - payload+= ' '+args; 5640 + payload += ' ' + args; 5641 } 5642 5643 sendData( payload ); 5644 5645 - if ( command=="LOGIN" || command=="AUTHENTICATE" ) { 5646 + if ( command == "LOGIN" || command == "AUTHENTICATE" ) { 5647 authTag = tag; 5648 - } else if ( command=="SELECT" || command=="EXAMINE" ) { 5649 + } else if ( command == "SELECT" || command == "EXAMINE" ) { 5650 selectTag = tag; 5651 upcomingMailBox = args; 5652 upcomingMailBox.remove( 0, 1 ); 5653 upcomingMailBox.chop( 1 ); 5654 upcomingMailBox = KIMAP::decodeImapFolderName( upcomingMailBox ); 5655 - } else if ( command=="CLOSE" ) { 5656 + } else if ( command == "CLOSE" ) { 5657 closeTag = tag; 5658 } 5659 - 5660 return tag; 5661 } 5662 5663 @@ -314,11 +328,11 @@ void SessionPrivate::sendData( const QByteArray &data ) 5664 { 5665 restartSocketTimer(); 5666 5667 - if ( logger && ( state==Session::Authenticated || state==Session::Selected ) ) { 5668 + if ( logger && ( state == Session::Authenticated || state == Session::Selected ) ) { 5669 logger->dataSent( data ); 5670 } 5671 5672 - thread->sendData(data+"\r\n"); 5673 + thread->sendData( data + "\r\n" ); 5674 } 5675 5676 void SessionPrivate::socketConnected() 5677 @@ -330,10 +344,10 @@ void SessionPrivate::socketConnected() 5678 if ( !queue.isEmpty() ) { 5679 KIMAP::LoginJob *login = qobject_cast<KIMAP::LoginJob*>( queue.first() ); 5680 if ( login ) { 5681 - willUseSsl = ( login->encryptionMode() == KIMAP::LoginJob::SslV2 ) 5682 - || ( login->encryptionMode() == KIMAP::LoginJob::SslV3 ) 5683 - || ( login->encryptionMode() == KIMAP::LoginJob::SslV3_1 ) 5684 - || ( login->encryptionMode() == KIMAP::LoginJob::AnySslVersion ); 5685 + willUseSsl = ( login->encryptionMode() == KIMAP::LoginJob::SslV2 ) || 5686 + ( login->encryptionMode() == KIMAP::LoginJob::SslV3 ) || 5687 + ( login->encryptionMode() == KIMAP::LoginJob::SslV3_1 ) || 5688 + ( login->encryptionMode() == KIMAP::LoginJob::AnySslVersion ); 5689 5690 userName = login->userName(); 5691 } 5692 @@ -348,16 +362,16 @@ void SessionPrivate::socketConnected() 5693 5694 void SessionPrivate::socketDisconnected() 5695 { 5696 - if (socketTimer.isActive()) { 5697 + if ( socketTimer.isActive() ) { 5698 stopSocketTimer(); 5699 } 5700 5701 - if ( logger && ( state==Session::Authenticated || state==Session::Selected ) ) { 5702 + if ( logger && ( state == Session::Authenticated || state == Session::Selected ) ) { 5703 logger->disconnectionOccured(); 5704 } 5705 5706 if ( state != Session::Disconnected ) { 5707 - setState(Session::Disconnected); 5708 + setState( Session::Disconnected ); 5709 emit q->connectionLost(); 5710 } else { 5711 emit q->connectionFailed(); 5712 @@ -375,7 +389,7 @@ void SessionPrivate::socketActivity() 5713 5714 void SessionPrivate::socketError() 5715 { 5716 - if (socketTimer.isActive()) { 5717 + if ( socketTimer.isActive() ) { 5718 stopSocketTimer(); 5719 } 5720 5721 @@ -397,14 +411,15 @@ void SessionPrivate::clearJobQueue() 5722 currentJob->connectionLost(); 5723 } 5724 5725 - qDeleteAll(queue); 5726 + QQueue<Job*> queueCopy = queue; // copy because jobDestroyed calls removeAll 5727 + qDeleteAll(queueCopy); 5728 queue.clear(); 5729 emit q->jobQueueSizeChanged( 0 ); 5730 } 5731 5732 void SessionPrivate::startSsl(const KTcpSocket::SslVersion &version) 5733 { 5734 - QMetaObject::invokeMethod( thread, "startSsl", Qt::QueuedConnection, Q_ARG(KTcpSocket::SslVersion, version) ); 5735 + thread->startSsl( version ); 5736 } 5737 5738 QString Session::selectedMailBox() const 5739 @@ -449,7 +464,7 @@ int SessionPrivate::socketTimeout() const 5740 5741 void SessionPrivate::startSocketTimer() 5742 { 5743 - if ( socketTimerInterval<0 ) { 5744 + if ( socketTimerInterval < 0 ) { 5745 return; 5746 } 5747 Q_ASSERT( !socketTimer.isActive() ); 5748 @@ -463,7 +478,7 @@ void SessionPrivate::startSocketTimer() 5749 5750 void SessionPrivate::stopSocketTimer() 5751 { 5752 - if ( socketTimerInterval<0 ) { 5753 + if ( socketTimerInterval < 0 ) { 5754 return; 5755 } 5756 5757 @@ -483,7 +498,7 @@ void SessionPrivate::restartSocketTimer() 5758 5759 void SessionPrivate::onSocketTimeout() 5760 { 5761 - qDebug() << "Socket timeout!"; 5762 + kDebug() << "Socket timeout!"; 5763 thread->closeSocket(); 5764 } 5765 5766 @@ -494,3 +509,4 @@ void Session::setTimeout( int timeout ) 5767 5768 #include "session.moc" 5769 #include "session_p.moc" 5770 + 5771 diff --git a/kimap/session.h b/kimap/session.h 5772 index e23fbc4..b745246 100644 5773 --- a/kimap/session.h 5774 +++ b/kimap/session.h 5775 @@ -37,7 +37,7 @@ struct Message; 5776 class KIMAP_EXPORT Session : public QObject 5777 { 5778 Q_OBJECT 5779 - Q_ENUMS(State) 5780 + Q_ENUMS( State ) 5781 5782 friend class JobPrivate; 5783 5784 @@ -135,18 +135,6 @@ class KIMAP_EXPORT Session : public QObject 5785 void stateChanged(KIMAP::Session::State newState, KIMAP::Session::State oldState); 5786 5787 private: 5788 - Q_PRIVATE_SLOT( d, void doStartNext() ) 5789 - Q_PRIVATE_SLOT( d, void jobDone( KJob* ) ) 5790 - Q_PRIVATE_SLOT( d, void jobDestroyed( QObject* ) ) 5791 - Q_PRIVATE_SLOT( d, void responseReceived( const KIMAP::Message& ) ) 5792 - 5793 - Q_PRIVATE_SLOT( d, void socketConnected() ) 5794 - Q_PRIVATE_SLOT( d, void socketDisconnected() ) 5795 - Q_PRIVATE_SLOT( d, void socketError() ) 5796 - Q_PRIVATE_SLOT( d, void socketActivity() ) 5797 - 5798 - Q_PRIVATE_SLOT( d, void handleSslError( const KSslErrorUiData &errorData ) ) 5799 - 5800 friend class SessionPrivate; 5801 SessionPrivate *const d; 5802 }; 5803 diff --git a/kimap/session_p.h b/kimap/session_p.h 5804 index 37bfd57..fd5101b 100644 5805 --- a/kimap/session_p.h 5806 +++ b/kimap/session_p.h 5807 @@ -46,7 +46,7 @@ class KIMAP_EXPORT SessionPrivate : public QObject 5808 friend class Session; 5809 5810 public: 5811 - SessionPrivate( Session *session ); 5812 + explicit SessionPrivate( Session *session ); 5813 virtual ~SessionPrivate(); 5814 5815 void addJob(Job *job); 5816 @@ -54,8 +54,6 @@ class KIMAP_EXPORT SessionPrivate : public QObject 5817 void startSsl(const KTcpSocket::SslVersion &version); 5818 void sendData( const QByteArray &data ); 5819 5820 - void handleSslError( const KSslErrorUiData &errorData ); 5821 - 5822 KTcpSocket::SslVersion negotiatedEncryption() const; 5823 5824 void setSocketTimeout( int ms ); 5825 @@ -68,20 +66,23 @@ class KIMAP_EXPORT SessionPrivate : public QObject 5826 void onEncryptionNegotiationResult(bool isEncrypted, KTcpSocket::SslVersion sslVersion); 5827 void onSocketTimeout(); 5828 5829 - private: 5830 - void startNext(); 5831 void doStartNext(); 5832 - void jobDone( KJob *job ); 5833 - void jobDestroyed( QObject *job ); 5834 - void clearJobQueue(); 5835 - void responseReceived( const KIMAP::Message &response ); 5836 - void setState(Session::State state); 5837 + void jobDone( KJob* ); 5838 + void jobDestroyed( QObject* ); 5839 + void responseReceived( const KIMAP::Message& ); 5840 5841 void socketConnected(); 5842 void socketDisconnected(); 5843 void socketError(); 5844 void socketActivity(); 5845 5846 + void handleSslError( const KSslErrorUiData &errorData ); 5847 + 5848 + private: 5849 + void startNext(); 5850 + void clearJobQueue(); 5851 + void setState(Session::State state); 5852 + 5853 void startSocketTimer(); 5854 void stopSocketTimer(); 5855 void restartSocketTimer(); 5856 diff --git a/kimap/sessionlogger.cpp b/kimap/sessionlogger.cpp 5857 index 715a5da..2c4bd07 100644 5858 --- a/kimap/sessionlogger.cpp 5859 +++ b/kimap/sessionlogger.cpp 5860 @@ -20,6 +20,8 @@ 5861 5862 #include "sessionlogger_p.h" 5863 5864 +#include <KDebug> 5865 + 5866 #include <unistd.h> 5867 5868 using namespace KIMAP; 5869 @@ -33,7 +35,9 @@ SessionLogger::SessionLogger() 5870 m_file.setFileName( qgetenv( "KIMAP_LOGFILE" ) 5871 + '.' + QString::number( getpid() ) 5872 + '.' + QString::number( m_id ) ); 5873 - m_file.open( QFile::WriteOnly ); 5874 + if (!m_file.open( QFile::WriteOnly )) { 5875 + kDebug()<<" m_file can be open in write only"; 5876 + } 5877 } 5878 5879 SessionLogger::~SessionLogger() 5880 @@ -57,6 +61,3 @@ void SessionLogger::disconnectionOccured() 5881 { 5882 m_file.write( "X\n" ); 5883 } 5884 - 5885 - 5886 - 5887 diff --git a/kimap/sessionthread.cpp b/kimap/sessionthread.cpp 5888 index b7a1cb9..36e2c83 100644 5889 --- a/kimap/sessionthread.cpp 5890 +++ b/kimap/sessionthread.cpp 5891 @@ -20,65 +20,73 @@ 5892 #include "sessionthread_p.h" 5893 5894 #include <QtCore/QDebug> 5895 -#include <QtCore/QTimer> 5896 +#include <QtCore/QThread> 5897 5898 -#include <kdebug.h> 5899 +#include <KDE/KDebug> 5900 5901 #include "imapstreamparser.h" 5902 #include "message_p.h" 5903 -#include "session.h" 5904 5905 using namespace KIMAP; 5906 5907 -Q_DECLARE_METATYPE(KTcpSocket::Error) 5908 -Q_DECLARE_METATYPE(KSslErrorUiData) 5909 +Q_DECLARE_METATYPE( KTcpSocket::Error ) 5910 +Q_DECLARE_METATYPE( KSslErrorUiData ) 5911 static const int _kimap_socketErrorTypeId = qRegisterMetaType<KTcpSocket::Error>(); 5912 static const int _kimap_sslErrorUiData = qRegisterMetaType<KSslErrorUiData>(); 5913 5914 -SessionThread::SessionThread( const QString &hostName, quint16 port, Session *parent ) 5915 - : QThread(), m_hostName(hostName), m_port(port), 5916 - m_session(parent), m_socket(0), m_stream(0), m_encryptedMode(false) 5917 +SessionThread::SessionThread( const QString &hostName, quint16 port ) 5918 + : QObject(), m_hostName( hostName ), m_port( port ), 5919 + m_socket( 0 ), m_stream( 0 ), m_mutex(), 5920 + m_encryptedMode( false ), 5921 + triedSslVersions( 0 ), doSslFallback( false ) 5922 { 5923 - // Yeah, sounds weird, but QThread object is linked to the parent 5924 - // thread not to itself, and I'm too lazy to introduce yet another 5925 - // internal QObject 5926 - moveToThread(this); 5927 + // Just like the Qt docs now recommend, for event-driven threads: 5928 + // don't derive from QThread, create one directly and move the object to it. 5929 + QThread* thread = new QThread(); 5930 + moveToThread( thread ); 5931 + thread->start(); 5932 + QMetaObject::invokeMethod( this, "threadInit" ); 5933 } 5934 5935 SessionThread::~SessionThread() 5936 { 5937 - // don't call quit() directly, this will deadlock in wait() if exec() hasn't run yet 5938 - QMetaObject::invokeMethod( this, "quit" ); 5939 - if ( !wait( 10 * 1000 ) ) { 5940 + QMetaObject::invokeMethod( this, "threadQuit" ); 5941 + if ( !thread()->wait( 10 * 1000 ) ) { 5942 kWarning() << "Session thread refuses to die, killing harder..."; 5943 - terminate(); 5944 + thread()->terminate(); 5945 // Make sure to wait until it's done, otherwise it can crash when the pthread callback is called 5946 - wait(); 5947 + thread()->wait(); 5948 } 5949 + delete thread(); 5950 } 5951 5952 +// Called in primary thread 5953 void SessionThread::sendData( const QByteArray &payload ) 5954 { 5955 - QMutexLocker locker(&m_mutex); 5956 + QMutexLocker locker( &m_mutex ); 5957 5958 m_dataQueue.enqueue( payload ); 5959 - QTimer::singleShot( 0, this, SLOT(writeDataQueue()) ); 5960 + QMetaObject::invokeMethod( this, "writeDataQueue" ); 5961 } 5962 5963 +// Called in secondary thread 5964 void SessionThread::writeDataQueue() 5965 { 5966 - QMutexLocker locker(&m_mutex); 5967 + Q_ASSERT( QThread::currentThread() == thread() ); 5968 + if ( !m_socket ) 5969 + return; 5970 + QMutexLocker locker( &m_mutex ); 5971 5972 while ( !m_dataQueue.isEmpty() ) { 5973 m_socket->write( m_dataQueue.dequeue() ); 5974 } 5975 } 5976 5977 +// Called in secondary thread 5978 void SessionThread::readMessage() 5979 { 5980 - QMutexLocker locker(&m_mutex); 5981 - 5982 - if ( m_stream->availableDataSize()==0 ) { 5983 + Q_ASSERT( QThread::currentThread() == thread() ); 5984 + if ( !m_stream || m_stream->availableDataSize() == 0 ) { 5985 return; 5986 } 5987 5988 @@ -92,10 +100,10 @@ void SessionThread::readMessage() 5989 if ( string == "NIL" ) { 5990 *payload << Message::Part( QList<QByteArray>() ); 5991 } else { 5992 - *payload << Message::Part(string); 5993 + *payload << Message::Part( string ); 5994 } 5995 } else if ( m_stream->hasList() ) { 5996 - *payload << Message::Part(m_stream->readParenthesizedList()); 5997 + *payload << Message::Part( m_stream->readParenthesizedList() ); 5998 } else if ( m_stream->hasResponseCode() ) { 5999 payload = &message.responseCode; 6000 } else if ( m_stream->atResponseCodeEnd() ) { 6001 @@ -103,128 +111,213 @@ void SessionThread::readMessage() 6002 } else if ( m_stream->hasLiteral() ) { 6003 QByteArray literal; 6004 while ( !m_stream->atLiteralEnd() ) { 6005 - literal+= m_stream->readLiteralPart(); 6006 + literal += m_stream->readLiteralPart(); 6007 } 6008 - *payload << Message::Part(literal); 6009 + *payload << Message::Part( literal ); 6010 } else { 6011 - // Oops! Something really bad happened 6012 - throw ImapParserException( "Inconsistent state, probably due to some packet loss" ); 6013 + // Oops! Something really bad happened, we won't be able to recover 6014 + // so close the socket immediately 6015 + qWarning( "Inconsistent state, probably due to some packet loss" ); 6016 + doCloseSocket(); 6017 + return; 6018 } 6019 } 6020 6021 - emit responseReceived(message); 6022 + emit responseReceived( message ); 6023 6024 - } catch (KIMAP::ImapParserException e) { 6025 + } catch ( KIMAP::ImapParserException e ) { 6026 qWarning() << "The stream parser raised an exception:" << e.what(); 6027 } 6028 6029 - if ( m_stream->availableDataSize()>1 ) { 6030 - QTimer::singleShot( 0, this, SLOT(readMessage()) ); 6031 + if ( m_stream->availableDataSize() > 1 ) { 6032 + QMetaObject::invokeMethod( this, "readMessage", Qt::QueuedConnection ); 6033 } 6034 6035 } 6036 6037 +// Called in main thread 6038 void SessionThread::closeSocket() 6039 { 6040 - QTimer::singleShot( 0, this, SLOT(doCloseSocket()) ); 6041 + QMetaObject::invokeMethod( this, "doCloseSocket", Qt::QueuedConnection ); 6042 } 6043 6044 +// Called in secondary thread 6045 void SessionThread::doCloseSocket() 6046 { 6047 + Q_ASSERT( QThread::currentThread() == thread() ); 6048 + if ( !m_socket ) 6049 + return; 6050 m_encryptedMode = false; 6051 + kDebug() << "close"; 6052 m_socket->close(); 6053 } 6054 6055 +// Called in secondary thread 6056 void SessionThread::reconnect() 6057 { 6058 - QMutexLocker locker(&m_mutex); 6059 - 6060 + Q_ASSERT( QThread::currentThread() == thread() ); 6061 + if ( m_socket == 0 ) // threadQuit already called 6062 + return; 6063 if ( m_socket->state() != SessionSocket::ConnectedState && 6064 m_socket->state() != SessionSocket::ConnectingState ) { 6065 - if (m_encryptedMode) { 6066 - m_socket->connectToHostEncrypted(m_hostName, m_port); 6067 + if ( m_encryptedMode ) { 6068 + kDebug() << "connectToHostEncrypted" << m_hostName << m_port; 6069 + m_socket->connectToHostEncrypted( m_hostName, m_port ); 6070 } else { 6071 - m_socket->connectToHost(m_hostName, m_port); 6072 + kDebug() << "connectToHost" << m_hostName << m_port; 6073 + m_socket->connectToHost( m_hostName, m_port ); 6074 } 6075 } 6076 } 6077 6078 -void SessionThread::run() 6079 +// Called in secondary thread 6080 +void SessionThread::threadInit() 6081 { 6082 + Q_ASSERT( QThread::currentThread() == thread() ); 6083 m_socket = new SessionSocket; 6084 m_stream = new ImapStreamParser( m_socket ); 6085 connect( m_socket, SIGNAL(readyRead()), 6086 this, SLOT(readMessage()), Qt::QueuedConnection ); 6087 6088 + // Delay the call to slotSocketDisconnected so that it finishes disconnecting before we call reconnect() 6089 connect( m_socket, SIGNAL(disconnected()), 6090 - m_session, SLOT(socketDisconnected()) ); 6091 + this, SLOT(slotSocketDisconnected()), Qt::QueuedConnection ); 6092 connect( m_socket, SIGNAL(connected()), 6093 - m_session, SLOT(socketConnected()) ); 6094 + this, SIGNAL(socketConnected()) ); 6095 connect( m_socket, SIGNAL(error(KTcpSocket::Error)), 6096 - m_session, SLOT(socketError()) ); 6097 + this, SLOT(socketError(KTcpSocket::Error)) ); 6098 connect( m_socket, SIGNAL(bytesWritten(qint64)), 6099 - m_session, SLOT(socketActivity()) ); 6100 - if ( m_socket->metaObject()->indexOfSignal("encryptedBytesWritten(qint64)" ) > -1 ) { 6101 + this, SIGNAL(socketActivity()) ); 6102 + if ( m_socket->metaObject()->indexOfSignal( "encryptedBytesWritten(qint64)" ) > -1 ) { 6103 connect( m_socket, SIGNAL(encryptedBytesWritten(qint64)), // needs kdelibs > 4.8 6104 - m_session, SLOT(socketActivity()) ); 6105 + this, SIGNAL(socketActivity()) ); 6106 } 6107 connect( m_socket, SIGNAL(readyRead()), 6108 - m_session, SLOT(socketActivity()) ); 6109 - 6110 - connect( this, SIGNAL(responseReceived(KIMAP::Message)), 6111 - m_session, SLOT(responseReceived(KIMAP::Message)) ); 6112 + this, SIGNAL(socketActivity()) ); 6113 6114 - QTimer::singleShot( 0, this, SLOT(reconnect()) ); 6115 - exec(); 6116 + QMetaObject::invokeMethod(this, "reconnect", Qt::QueuedConnection); 6117 +} 6118 6119 +// Called in secondary thread 6120 +void SessionThread::threadQuit() 6121 +{ 6122 + Q_ASSERT( QThread::currentThread() == thread() ); 6123 delete m_stream; 6124 + m_stream = 0; 6125 delete m_socket; 6126 + m_socket = 0; 6127 + thread()->quit(); 6128 } 6129 6130 -void SessionThread::startSsl(const KTcpSocket::SslVersion &version) 6131 +// Called in primary thread 6132 +void SessionThread::startSsl( KTcpSocket::SslVersion version ) 6133 { 6134 - QMutexLocker locker(&m_mutex); 6135 + QMetaObject::invokeMethod( this, "doStartSsl", Q_ARG(KTcpSocket::SslVersion, version) ); 6136 +} 6137 + 6138 +// Called in secondary thread (via invokeMethod) 6139 +void SessionThread::doStartSsl( KTcpSocket::SslVersion version ) 6140 +{ 6141 + Q_ASSERT( QThread::currentThread() == thread() ); 6142 + if ( !m_socket ) 6143 + return; 6144 + if ( version == KTcpSocket::AnySslVersion ) { 6145 + doSslFallback = true; 6146 + if ( m_socket->advertisedSslVersion() == KTcpSocket::UnknownSslVersion ) { 6147 + m_socket->setAdvertisedSslVersion( KTcpSocket::AnySslVersion ); 6148 + } else if ( !( triedSslVersions & KTcpSocket::TlsV1 ) ) { 6149 + triedSslVersions |= KTcpSocket::TlsV1; 6150 + m_socket->setAdvertisedSslVersion( KTcpSocket::TlsV1 ); 6151 + } else if ( !( triedSslVersions & KTcpSocket::SslV3 ) ) { 6152 + triedSslVersions |= KTcpSocket::SslV3; 6153 + m_socket->setAdvertisedSslVersion( KTcpSocket::SslV3 ); 6154 + } else if ( !( triedSslVersions & KTcpSocket::SslV2 ) ) { 6155 + triedSslVersions |= KTcpSocket::SslV2; 6156 + m_socket->setAdvertisedSslVersion( KTcpSocket::SslV2 ); 6157 + doSslFallback = false; 6158 + } 6159 + } else { 6160 + m_socket->setAdvertisedSslVersion( version ); 6161 + } 6162 6163 - m_socket->setAdvertisedSslVersion(version); 6164 m_socket->ignoreSslErrors(); 6165 - connect(m_socket, SIGNAL(encrypted()), this, SLOT(sslConnected())); 6166 + connect( m_socket, SIGNAL(encrypted()), this, SLOT(sslConnected()) ); 6167 m_socket->startClientEncryption(); 6168 } 6169 6170 +// Called in secondary thread 6171 +void SessionThread::slotSocketDisconnected() 6172 +{ 6173 + Q_ASSERT( QThread::currentThread() == thread() ); 6174 + if ( doSslFallback ) { 6175 + reconnect(); 6176 + } else { 6177 + emit socketDisconnected(); 6178 + } 6179 +} 6180 + 6181 +// Called in secondary thread 6182 +void SessionThread::socketError(KTcpSocket::Error error) 6183 +{ 6184 + Q_ASSERT( QThread::currentThread() == thread() ); 6185 + if ( !m_socket ) 6186 + return; 6187 + Q_UNUSED( error ); // can be used for debugging 6188 + if ( doSslFallback ) { 6189 + //do not call m_socket->disconnectFromHost() here, as that can trigger an error again (resulting in an endless loop). 6190 + m_socket->abort(); 6191 + } else { 6192 + emit socketError(); 6193 + } 6194 +} 6195 + 6196 +// Called in secondary thread 6197 void SessionThread::sslConnected() 6198 { 6199 - QMutexLocker locker(&m_mutex); 6200 + Q_ASSERT( QThread::currentThread() == thread() ); 6201 + if ( !m_socket ) 6202 + return; 6203 KSslCipher cipher = m_socket->sessionCipher(); 6204 6205 - if ( m_socket->sslErrors().count() > 0 || m_socket->encryptionMode() != KTcpSocket::SslClientMode 6206 - || cipher.isNull() || cipher.usedBits() == 0) { 6207 - qDebug() << "Initial SSL handshake failed. cipher.isNull() is" << cipher.isNull() 6208 - << ", cipher.usedBits() is" << cipher.usedBits() 6209 - << ", the socket says:" << m_socket->errorString() 6210 - << "and the list of SSL errors contains" 6211 - << m_socket->sslErrors().count() << "items."; 6212 - KSslErrorUiData errorData(m_socket); 6213 - emit sslError(errorData); 6214 + if ( m_socket->sslErrors().count() > 0 || 6215 + m_socket->encryptionMode() != KTcpSocket::SslClientMode || 6216 + cipher.isNull() || cipher.usedBits() == 0 ) { 6217 + kDebug() << "Initial SSL handshake failed. cipher.isNull() is" << cipher.isNull() 6218 + << ", cipher.usedBits() is" << cipher.usedBits() 6219 + << ", the socket says:" << m_socket->errorString() 6220 + << "and the list of SSL errors contains" 6221 + << m_socket->sslErrors().count() << "items."; 6222 + KSslErrorUiData errorData( m_socket ); 6223 + emit sslError( errorData ); 6224 } else { 6225 - qDebug() << "TLS negotiation done."; 6226 + doSslFallback = false; 6227 + kDebug() << "TLS negotiation done."; 6228 m_encryptedMode = true; 6229 - emit encryptionNegotiationResult(true, m_socket->negotiatedSslVersion()); 6230 + emit encryptionNegotiationResult( true, m_socket->negotiatedSslVersion() ); 6231 } 6232 } 6233 6234 void SessionThread::sslErrorHandlerResponse(bool response) 6235 { 6236 - QMutexLocker locker(&m_mutex); 6237 - if (response) { 6238 + QMetaObject::invokeMethod(this, "doSslErrorHandlerResponse", Q_ARG(bool, response)); 6239 +} 6240 + 6241 +// Called in secondary thread (via invokeMethod) 6242 +void SessionThread::doSslErrorHandlerResponse(bool response) 6243 +{ 6244 + Q_ASSERT( QThread::currentThread() == thread() ); 6245 + if ( !m_socket ) 6246 + return; 6247 + if ( response ) { 6248 m_encryptedMode = true; 6249 - emit encryptionNegotiationResult(true, m_socket->negotiatedSslVersion()); 6250 + emit encryptionNegotiationResult( true, m_socket->negotiatedSslVersion() ); 6251 } else { 6252 m_encryptedMode = false; 6253 //reconnect in unencrypted mode, so new commands can be issued 6254 m_socket->disconnectFromHost(); 6255 m_socket->waitForDisconnected(); 6256 - m_socket->connectToHost(m_hostName, m_port); 6257 - emit encryptionNegotiationResult(false, KTcpSocket::UnknownSslVersion); 6258 + m_socket->connectToHost( m_hostName, m_port ); 6259 + emit encryptionNegotiationResult( false, KTcpSocket::UnknownSslVersion ); 6260 } 6261 } 6262 6263 diff --git a/kimap/sessionthread_p.h b/kimap/sessionthread_p.h 6264 index 672c418..47a94fb 100644 6265 --- a/kimap/sessionthread_p.h 6266 +++ b/kimap/sessionthread_p.h 6267 @@ -22,7 +22,6 @@ 6268 6269 #include <QtCore/QMutex> 6270 #include <QtCore/QQueue> 6271 -#include <QtCore/QThread> 6272 6273 #include <ktcpsocket.h> 6274 6275 @@ -32,52 +31,62 @@ namespace KIMAP { 6276 6277 class ImapStreamParser; 6278 struct Message; 6279 -class Session; 6280 6281 -class SessionThread : public QThread 6282 +class SessionThread : public QObject 6283 { 6284 Q_OBJECT 6285 6286 public: 6287 - explicit SessionThread( const QString &hostName, quint16 port, Session *parent ); 6288 + explicit SessionThread( const QString &hostName, quint16 port ); 6289 ~SessionThread(); 6290 6291 inline QString hostName() { return m_hostName; } 6292 inline quint16 port() { return m_port; } 6293 6294 void sendData( const QByteArray &payload ); 6295 - void run(); 6296 6297 public slots: 6298 void closeSocket(); 6299 - void reconnect(); 6300 - void startSsl(const KTcpSocket::SslVersion &version); 6301 + void startSsl(KTcpSocket::SslVersion version); 6302 + void sslErrorHandlerResponse(bool result); 6303 6304 signals: 6305 + void socketConnected(); 6306 + void socketDisconnected(); 6307 + void socketActivity(); 6308 + void socketError(); 6309 void responseReceived(const KIMAP::Message &response); 6310 void encryptionNegotiationResult(bool, KTcpSocket::SslVersion); 6311 void sslError(const KSslErrorUiData&); 6312 6313 private slots: 6314 + void reconnect(); 6315 + void threadInit(); 6316 + void threadQuit(); 6317 void readMessage(); 6318 void writeDataQueue(); 6319 void sslConnected(); 6320 - void sslErrorHandlerResponse(bool result); 6321 void doCloseSocket(); 6322 + void socketError(KTcpSocket::Error); 6323 + void slotSocketDisconnected(); 6324 + void doStartSsl(KTcpSocket::SslVersion); 6325 + void doSslErrorHandlerResponse(bool result); 6326 6327 private: 6328 QString m_hostName; 6329 quint16 m_port; 6330 6331 - Session *m_session; 6332 SessionSocket *m_socket; 6333 ImapStreamParser *m_stream; 6334 6335 QQueue<QByteArray> m_dataQueue; 6336 6337 + // Protects m_dataQueue 6338 QMutex m_mutex; 6339 6340 bool m_encryptedMode; 6341 + KTcpSocket::SslVersions triedSslVersions; 6342 + bool doSslFallback; 6343 }; 6344 6345 } 6346 diff --git a/kimap/setacljob.cpp b/kimap/setacljob.cpp 6347 index dea3d81..bb3841d 100644 6348 --- a/kimap/setacljob.cpp 6349 +++ b/kimap/setacljob.cpp 6350 @@ -19,8 +19,8 @@ 6351 6352 #include "setacljob.h" 6353 6354 -#include <klocale.h> 6355 -#include <kdebug.h> 6356 +#include <KDE/KLocalizedString> 6357 +#include <KDE/KDebug> 6358 6359 #include "acljobbase_p.h" 6360 #include "message_p.h" 6361 @@ -32,7 +32,7 @@ namespace KIMAP 6362 class SetAclJobPrivate : public AclJobBasePrivate 6363 { 6364 public: 6365 - SetAclJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate(session, name) {} 6366 + SetAclJobPrivate( Session *session, const QString& name ) : AclJobBasePrivate( session, name ) {} 6367 ~SetAclJobPrivate() { } 6368 }; 6369 } 6370 @@ -40,9 +40,8 @@ namespace KIMAP 6371 using namespace KIMAP; 6372 6373 SetAclJob::SetAclJob( Session *session ) 6374 - : AclJobBase(*new SetAclJobPrivate(session, i18n("SetAcl"))) 6375 + : AclJobBase( *new SetAclJobPrivate( session, i18n( "SetAcl" ) ) ) 6376 { 6377 - 6378 } 6379 6380 SetAclJob::~SetAclJob() 6381 @@ -51,32 +50,33 @@ SetAclJob::~SetAclJob() 6382 6383 void SetAclJob::doStart() 6384 { 6385 - Q_D(SetAclJob); 6386 + Q_D( SetAclJob ); 6387 QByteArray r = Acl::rightsToString( d->rightList ); 6388 - if (d->modifier == Add) { 6389 - r.prepend('+'); 6390 - } else if (d->modifier == Remove) { 6391 - r.prepend('-'); 6392 + if ( d->modifier == Add ) { 6393 + r.prepend( '+' ); 6394 + } else if ( d->modifier == Remove ) { 6395 + r.prepend( '-' ); 6396 } 6397 - d->tags << d->sessionInternal()->sendCommand( "SETACL", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + "\" \"" + d->id + "\" \"" + r +'\"'); 6398 + d->tags << d->sessionInternal()->sendCommand( "SETACL", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + "\" \"" + d->id + "\" \"" + r + '\"' ); 6399 } 6400 6401 void SetAclJob::setRights(AclModifier modifier, Acl::Rights rights) 6402 { 6403 - Q_D(SetAclJob); 6404 - d->setRights(modifier, rights); 6405 + Q_D( SetAclJob ); 6406 + d->setRights( modifier, rights ); 6407 } 6408 6409 void SetAclJob::setIdentifier( const QByteArray &identifier ) 6410 { 6411 - Q_D(SetAclJob); 6412 - d->setIdentifier(identifier); 6413 + Q_D( SetAclJob ); 6414 + d->setIdentifier( identifier ); 6415 } 6416 6417 QByteArray SetAclJob::identifier() 6418 { 6419 - Q_D(SetAclJob); 6420 + Q_D( SetAclJob ); 6421 return d->identifier(); 6422 } 6423 6424 #include "setacljob.moc" 6425 + 6426 diff --git a/kimap/setacljob.h b/kimap/setacljob.h 6427 index 33df18d..c2496c3 100644 6428 --- a/kimap/setacljob.h 6429 +++ b/kimap/setacljob.h 6430 @@ -30,7 +30,6 @@ class Session; 6431 struct Message; 6432 class SetAclJobPrivate; 6433 6434 - 6435 /** 6436 * Sets the rights that correspond to an identifier on a mailbox 6437 * 6438 @@ -44,7 +43,7 @@ class SetAclJobPrivate; 6439 class KIMAP_EXPORT SetAclJob : public AclJobBase 6440 { 6441 Q_OBJECT 6442 - Q_DECLARE_PRIVATE(SetAclJob) 6443 + Q_DECLARE_PRIVATE( SetAclJob ) 6444 6445 friend class SessionPrivate; 6446 6447 @@ -96,6 +95,7 @@ class KIMAP_EXPORT SetAclJob : public AclJobBase 6448 * Note that negative rights override positive rights: if 6449 * "fred" and "-fred" are both assigned the 'w' right, the 6450 * user "fred" will not have the 'w' right. 6451 + * @param identifier the identifier to set 6452 */ 6453 void setIdentifier( const QByteArray &identifier ); 6454 /** 6455 diff --git a/kimap/setmetadatajob.cpp b/kimap/setmetadatajob.cpp 6456 index c279812..80e46f9 100644 6457 --- a/kimap/setmetadatajob.cpp 6458 +++ b/kimap/setmetadatajob.cpp 6459 @@ -19,8 +19,8 @@ 6460 6461 #include "setmetadatajob.h" 6462 6463 -#include <klocale.h> 6464 -#include <kdebug.h> 6465 +#include <KDE/KLocalizedString> 6466 +#include <KDE/KDebug> 6467 6468 #include "metadatajobbase_p.h" 6469 #include "message_p.h" 6470 @@ -32,7 +32,7 @@ namespace KIMAP 6471 class SetMetaDataJobPrivate : public MetaDataJobBasePrivate 6472 { 6473 public: 6474 - SetMetaDataJobPrivate( Session *session, const QString& name ) : MetaDataJobBasePrivate(session, name), metaDataErrors(0), maxAcceptedSize(-1) { } 6475 + SetMetaDataJobPrivate( Session *session, const QString& name ) : MetaDataJobBasePrivate( session, name ), metaDataErrors( 0 ), maxAcceptedSize( -1 ) { } 6476 ~SetMetaDataJobPrivate() { } 6477 6478 QMap<QByteArray, QByteArray> entries; 6479 @@ -46,7 +46,7 @@ namespace KIMAP 6480 using namespace KIMAP; 6481 6482 SetMetaDataJob::SetMetaDataJob( Session *session ) 6483 - : MetaDataJobBase( *new SetMetaDataJobPrivate(session, i18n("SetMetaData")) ) 6484 + : MetaDataJobBase( *new SetMetaDataJobPrivate( session, i18n( "SetMetaData" ) ) ) 6485 { 6486 } 6487 6488 @@ -56,99 +56,102 @@ SetMetaDataJob::~SetMetaDataJob() 6489 6490 void SetMetaDataJob::doStart() 6491 { 6492 - Q_D(SetMetaDataJob); 6493 + Q_D( SetMetaDataJob ); 6494 QByteArray parameters; 6495 parameters = '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + "\" "; 6496 d->entriesIt = d->entries.constBegin(); 6497 6498 QByteArray command = "SETMETADATA"; 6499 - if (d->serverCapability == Annotatemore) { 6500 + if ( d->serverCapability == Annotatemore ) { 6501 command = "SETANNOTATION"; 6502 parameters += '\"' + d->entryName + "\" ("; 6503 - d->m_name = i18n("SetAnnotation"); 6504 - if (!d->entries.isEmpty()) { 6505 - for (; d->entriesIt != d->entries.constEnd(); ++d->entriesIt) { 6506 - parameters += '\"' + d->entriesIt.key() + "\" \"" + d->entriesIt.value() + "\" "; 6507 + d->m_name = i18n( "SetAnnotation" ); 6508 + if ( !d->entries.isEmpty() ) { 6509 + for ( ; d->entriesIt != d->entries.constEnd(); ++d->entriesIt ) { 6510 + parameters += '\"' + d->entriesIt.key() + "\" \"" + d->entriesIt.value() + "\" "; 6511 } 6512 parameters[parameters.length() - 1] = ')'; 6513 } 6514 } else { 6515 parameters += '('; 6516 - if (!d->entries.isEmpty()) { 6517 + if ( !d->entries.isEmpty() ) { 6518 parameters += '\"' + d->entriesIt.key() + '\"'; 6519 parameters += ' '; 6520 - parameters +=" {" + QByteArray::number(d->entriesIt.value().size()) + '}'; 6521 + parameters += " {" + QByteArray::number( d->entriesIt.value().size() ) + '}'; 6522 } 6523 } 6524 6525 - if (d->entries.isEmpty()) { 6526 + if ( d->entries.isEmpty() ) { 6527 parameters += ')'; 6528 } 6529 6530 d->tags << d->sessionInternal()->sendCommand( command, parameters ); 6531 -// qDebug() << "SENT: " << command << " " << parameters; 6532 +// kDebug() << "SENT: " << command << " " << parameters; 6533 } 6534 6535 void SetMetaDataJob::handleResponse( const Message &response ) 6536 { 6537 - Q_D(SetMetaDataJob); 6538 + Q_D( SetMetaDataJob ); 6539 6540 //TODO: Test if a server can really return more then one untagged NO response. If not, no need to OR the error codes 6541 - if ( !response.content.isEmpty() 6542 - && d->tags.contains( response.content.first().toString() ) ) { 6543 + if ( !response.content.isEmpty() && 6544 + d->tags.contains( response.content.first().toString() ) ) { 6545 if ( response.content[1].toString() == "NO" ) { 6546 setError( UserDefinedError ); 6547 - setErrorText( i18n("%1 failed, server replied: %2", d->m_name, response.toString().constData()) ); 6548 - if (response.content[2].toString() == "[ANNOTATEMORE TOOMANY]" || response.content[2].toString() == "[METADATA TOOMANY]") { 6549 + setErrorText( i18n( "%1 failed, server replied: %2", d->m_name, response.toString().constData() ) ); 6550 + if ( response.content[2].toString() == "[ANNOTATEMORE TOOMANY]" || 6551 + response.content[2].toString() == "[METADATA TOOMANY]" ) { 6552 d->metaDataErrors |= TooMany; 6553 - } else if (response.content[2].toString() == "[ANNOTATEMORE TOOBIG]" || response.content[2].toString().startsWith("[METADATA MAXSIZE")) { 6554 + } else if ( response.content[2].toString() == "[ANNOTATEMORE TOOBIG]" || 6555 + response.content[2].toString().startsWith( "[METADATA MAXSIZE" ) ) { //krazy:exclude=strings 6556 d->metaDataErrors |= TooBig; 6557 d->maxAcceptedSize = -1; 6558 - if (response.content[2].toString().startsWith("[METADATA MAXSIZE")) { //krazy:exclude=strings 6559 + if ( response.content[2].toString().startsWith( "[METADATA MAXSIZE" ) ) { //krazy:exclude=strings 6560 QByteArray max = response.content[2].toString(); 6561 - max.replace("[METADATA MAXSIZE",""); //krazy:exclude=doublequote_chars 6562 - max.replace("]", ""); //krazy:exclude=doublequote_chars 6563 + max.replace( "[METADATA MAXSIZE", "" ); //krazy:exclude=doublequote_chars 6564 + max.replace( "]", "" ); //krazy:exclude=doublequote_chars 6565 d->maxAcceptedSize = max.toLongLong(); 6566 } 6567 - } else if (response.content[2].toString() == "[METADATA NOPRIVATE]") { 6568 + } else if ( response.content[2].toString() == "[METADATA NOPRIVATE]" ) { 6569 d->metaDataErrors |= NoPrivate; 6570 } 6571 } else if ( response.content.size() < 2 ) { 6572 - setErrorText( i18n("%1 failed, malformed reply from the server.", d->m_name) ); 6573 + setErrorText( i18n( "%1 failed, malformed reply from the server.", d->m_name ) ); 6574 } else if ( response.content[1].toString() != "OK" ) { 6575 setError( UserDefinedError ); 6576 - setErrorText( i18n("%1 failed, server replied: %2", d->m_name, response.toString().constData()) ); 6577 + setErrorText( i18n( "%1 failed, server replied: %2", d->m_name, response.toString().constData() ) ); 6578 } 6579 emitResult(); 6580 } else if ( d->serverCapability == Metadata && response.content[0].toString() == "+" ) { 6581 QByteArray content = d->entriesIt.value(); 6582 ++d->entriesIt; 6583 - if (d->entriesIt == d->entries.constEnd()) { 6584 + if ( d->entriesIt == d->entries.constEnd() ) { 6585 content += ')'; 6586 } else { 6587 - content +=" {" + QByteArray::number(d->entriesIt.value().size()) + '}'; 6588 + content += " {" + QByteArray::number( d->entriesIt.value().size() ) + '}'; 6589 } 6590 -// qDebug() << "SENT: " << content; 6591 +// kDebug() << "SENT: " << content; 6592 d->sessionInternal()->sendData( content ); 6593 } 6594 } 6595 6596 void SetMetaDataJob::addMetaData(const QByteArray &name, const QByteArray &value) 6597 { 6598 - Q_D(SetMetaDataJob); 6599 + Q_D( SetMetaDataJob ); 6600 d->entries[name] = value; 6601 } 6602 6603 void SetMetaDataJob::setEntry(const QByteArray &entry) 6604 { 6605 - Q_D(SetMetaDataJob); 6606 + Q_D( SetMetaDataJob ); 6607 d->entryName = entry; 6608 } 6609 6610 SetMetaDataJob::MetaDataErrors SetMetaDataJob::metaDataErrors() const 6611 { 6612 - Q_D(const SetMetaDataJob); 6613 + Q_D( const SetMetaDataJob ); 6614 return d->metaDataErrors; 6615 } 6616 6617 #include "setmetadatajob.moc" 6618 + 6619 diff --git a/kimap/setmetadatajob.h b/kimap/setmetadatajob.h 6620 index 1391ecc..3736539 100644 6621 --- a/kimap/setmetadatajob.h 6622 +++ b/kimap/setmetadatajob.h 6623 @@ -68,7 +68,7 @@ class SetMetaDataJobPrivate; 6624 class KIMAP_EXPORT SetMetaDataJob : public MetaDataJobBase 6625 { 6626 Q_OBJECT 6627 - Q_DECLARE_PRIVATE(SetMetaDataJob) 6628 + Q_DECLARE_PRIVATE( SetMetaDataJob ) 6629 6630 friend class SessionPrivate; 6631 6632 @@ -184,7 +184,7 @@ class KIMAP_EXPORT SetMetaDataJob : public MetaDataJobBase 6633 }; 6634 6635 // Q_DECLARE_WHATEVER_THAT_WAS missing 6636 - Q_DECLARE_FLAGS(MetaDataErrors, MetaDataError) 6637 + Q_DECLARE_FLAGS( MetaDataErrors, MetaDataError ) 6638 6639 /** 6640 * The metadata errors received from the server. 6641 diff --git a/kimap/setquotajob.cpp b/kimap/setquotajob.cpp 6642 index 9dedddd..347aeee 100644 6643 --- a/kimap/setquotajob.cpp 6644 +++ b/kimap/setquotajob.cpp 6645 @@ -19,8 +19,8 @@ 6646 6647 #include "setquotajob.h" 6648 6649 -#include <klocale.h> 6650 -#include <kdebug.h> 6651 +#include <KDE/KLocalizedString> 6652 +#include <KDE/KDebug> 6653 6654 #include "quotajobbase_p.h" 6655 #include "message_p.h" 6656 @@ -31,7 +31,7 @@ namespace KIMAP 6657 class SetQuotaJobPrivate : public QuotaJobBasePrivate 6658 { 6659 public: 6660 - SetQuotaJobPrivate( Session *session, const QString& name ) : QuotaJobBasePrivate(session, name) { } 6661 + SetQuotaJobPrivate( Session *session, const QString& name ) : QuotaJobBasePrivate( session, name ) { } 6662 ~SetQuotaJobPrivate() { } 6663 6664 QMap<QByteArray, qint64> setList; 6665 @@ -42,7 +42,7 @@ namespace KIMAP 6666 using namespace KIMAP; 6667 6668 SetQuotaJob::SetQuotaJob( Session *session ) 6669 - : QuotaJobBase( *new SetQuotaJobPrivate(session, i18n("SetQuota")) ) 6670 + : QuotaJobBase( *new SetQuotaJobPrivate( session, i18n( "SetQuota" ) ) ) 6671 { 6672 } 6673 6674 @@ -52,54 +52,54 @@ SetQuotaJob::~SetQuotaJob() 6675 6676 void SetQuotaJob::doStart() 6677 { 6678 - Q_D(SetQuotaJob); 6679 + Q_D( SetQuotaJob ); 6680 QByteArray s; 6681 s += '('; 6682 - for (QMap<QByteArray, qint64>::ConstIterator it = d->setList.constBegin(); it != d->setList.constEnd(); ++it ) { 6683 - s += it.key() + ' ' + QByteArray::number(it.value()) + ' '; 6684 + for ( QMap<QByteArray, qint64>::ConstIterator it = d->setList.constBegin(); it != d->setList.constEnd(); ++it ) { 6685 + s += it.key() + ' ' + QByteArray::number( it.value() ) + ' '; 6686 } 6687 - if (d->setList.isEmpty()) { 6688 + if ( d->setList.isEmpty() ) { 6689 s += ')'; 6690 } else { 6691 s[s.length() - 1] = ')'; 6692 } 6693 6694 - qDebug() << "SETQUOTA " << '\"' + d->root + "\" " + s; 6695 + kDebug() << "SETQUOTA " << '\"' + d->root + "\" " + s; 6696 //XXX: [alexmerry, 2010-07-24]: should d->root be quoted properly? 6697 - d->tags << d->sessionInternal()->sendCommand( "SETQUOTA", '\"' + d->root + "\" " + s); 6698 + d->tags << d->sessionInternal()->sendCommand( "SETQUOTA", '\"' + d->root + "\" " + s ); 6699 } 6700 6701 void SetQuotaJob::handleResponse(const Message &response) 6702 { 6703 - Q_D(SetQuotaJob); 6704 - if (handleErrorReplies(response) == NotHandled) { 6705 - if ( response.content.size() >= 4 6706 - && response.content[1].toString() == "QUOTA" ) { 6707 - d->quota = d->readQuota(response.content[3]); 6708 + Q_D( SetQuotaJob ); 6709 + if ( handleErrorReplies( response ) == NotHandled ) { 6710 + if ( response.content.size() >= 4 && 6711 + response.content[1].toString() == "QUOTA" ) { 6712 + d->quota = d->readQuota( response.content[3] ); 6713 } 6714 } 6715 } 6716 6717 - 6718 void SetQuotaJob::setQuota(const QByteArray &resource, qint64 limit) 6719 { 6720 - Q_D(SetQuotaJob); 6721 + Q_D( SetQuotaJob ); 6722 6723 d->setList[resource.toUpper()] = limit; 6724 } 6725 6726 void SetQuotaJob::setRoot(const QByteArray& root) 6727 { 6728 - Q_D(SetQuotaJob); 6729 + Q_D( SetQuotaJob ); 6730 6731 d->root = root; 6732 } 6733 6734 QByteArray SetQuotaJob::root() const 6735 { 6736 - Q_D(const SetQuotaJob); 6737 + Q_D( const SetQuotaJob ); 6738 6739 return d->root; 6740 } 6741 6742 #include "setquotajob.moc" 6743 + 6744 diff --git a/kimap/setquotajob.h b/kimap/setquotajob.h 6745 index f3fac37..ff21a29 100644 6746 --- a/kimap/setquotajob.h 6747 +++ b/kimap/setquotajob.h 6748 @@ -84,6 +84,7 @@ class KIMAP_EXPORT SetQuotaJob : public QuotaJobBase 6749 * may create it and change the quota roots for any number of 6750 * existing mailboxes in an implementation-defined manner. 6751 * 6752 + * @param root the quota root to set, in bytes 6753 * @see GetQuotaRootJob 6754 */ 6755 void setRoot( const QByteArray &root ); 6756 diff --git a/kimap/storejob.cpp b/kimap/storejob.cpp 6757 index cf70503..0118000 100644 6758 --- a/kimap/storejob.cpp 6759 +++ b/kimap/storejob.cpp 6760 @@ -19,8 +19,8 @@ 6761 6762 #include "storejob.h" 6763 6764 -#include <kdebug.h> 6765 -#include <klocale.h> 6766 +#include <KDE/KDebug> 6767 +#include <KDE/KLocalizedString> 6768 6769 #include "job_p.h" 6770 #include "message_p.h" 6771 @@ -46,9 +46,9 @@ namespace KIMAP 6772 using namespace KIMAP; 6773 6774 StoreJob::StoreJob( Session *session ) 6775 - : Job( *new StoreJobPrivate(session, i18n("Store")) ) 6776 + : Job( *new StoreJobPrivate( session, i18n( "Store" ) ) ) 6777 { 6778 - Q_D(StoreJob); 6779 + Q_D( StoreJob ); 6780 d->uidBased = false; 6781 d->mode = SetFlags; 6782 } 6783 @@ -59,84 +59,86 @@ StoreJob::~StoreJob() 6784 6785 void StoreJob::setSequenceSet( const ImapSet &set ) 6786 { 6787 - Q_D(StoreJob); 6788 + Q_D( StoreJob ); 6789 d->set = set; 6790 } 6791 6792 ImapSet StoreJob::sequenceSet() const 6793 { 6794 - Q_D(const StoreJob); 6795 + Q_D( const StoreJob ); 6796 return d->set; 6797 } 6798 6799 void StoreJob::setUidBased(bool uidBased) 6800 { 6801 - Q_D(StoreJob); 6802 + Q_D( StoreJob ); 6803 d->uidBased = uidBased; 6804 } 6805 6806 bool StoreJob::isUidBased() const 6807 { 6808 - Q_D(const StoreJob); 6809 + Q_D( const StoreJob ); 6810 return d->uidBased; 6811 } 6812 6813 void StoreJob::setFlags( const MessageFlags &flags ) 6814 { 6815 - Q_D(StoreJob); 6816 + Q_D( StoreJob ); 6817 d->flags = flags; 6818 } 6819 6820 MessageFlags StoreJob::flags() const 6821 { 6822 - Q_D(const StoreJob); 6823 + Q_D( const StoreJob ); 6824 return d->flags; 6825 } 6826 6827 void StoreJob::setMode( StoreMode mode ) 6828 { 6829 - Q_D(StoreJob); 6830 + Q_D( StoreJob ); 6831 d->mode = mode; 6832 } 6833 6834 StoreJob::StoreMode StoreJob::mode() const 6835 { 6836 - Q_D(const StoreJob); 6837 + Q_D( const StoreJob ); 6838 return d->mode; 6839 } 6840 6841 QMap<int, MessageFlags> StoreJob::resultingFlags() const 6842 { 6843 - Q_D(const StoreJob); 6844 + Q_D( const StoreJob ); 6845 return d->resultingFlags; 6846 } 6847 6848 void StoreJob::doStart() 6849 { 6850 - Q_D(StoreJob); 6851 + Q_D( StoreJob ); 6852 6853 QByteArray parameters = d->set.toImapSequenceSet()+' '; 6854 6855 switch ( d->mode ) { 6856 case SetFlags: 6857 - parameters+= "FLAGS"; 6858 + parameters += "FLAGS"; 6859 break; 6860 case AppendFlags: 6861 - parameters+= "+FLAGS"; 6862 + parameters += "+FLAGS"; 6863 break; 6864 case RemoveFlags: 6865 - parameters+= "-FLAGS"; 6866 + parameters += "-FLAGS"; 6867 break; 6868 } 6869 6870 - parameters+=" ("; 6871 + parameters += " ("; 6872 foreach ( const QByteArray &flag, d->flags ) { 6873 - parameters+=flag+' '; 6874 + parameters += flag + ' '; 6875 } 6876 - if (!d->flags.isEmpty()) parameters.chop(1); 6877 - parameters+=')'; 6878 + if ( !d->flags.isEmpty() ) { 6879 + parameters.chop( 1 ); 6880 + } 6881 + parameters += ')'; 6882 6883 - qDebug("%s", parameters.constData()); 6884 + kDebug() << parameters; 6885 6886 QByteArray command = "STORE"; 6887 if ( d->uidBased ) { 6888 @@ -148,12 +150,12 @@ void StoreJob::doStart() 6889 6890 void StoreJob::handleResponse( const Message &response ) 6891 { 6892 - Q_D(StoreJob); 6893 + Q_D( StoreJob ); 6894 6895 - if (handleErrorReplies(response) == NotHandled ) { 6896 - if ( response.content.size() == 4 6897 - && response.content[2].toString()=="FETCH" 6898 - && response.content[3].type()==Message::Part::List ) { 6899 + if ( handleErrorReplies( response ) == NotHandled ) { 6900 + if ( response.content.size() == 4 && 6901 + response.content[2].toString() == "FETCH" && 6902 + response.content[3].type() == Message::Part::List ) { 6903 6904 int id = response.content[1].toString().toInt(); 6905 qint64 uid = 0; 6906 @@ -163,21 +165,21 @@ void StoreJob::handleResponse( const Message &response ) 6907 QList<QByteArray> content = response.content[3].toList(); 6908 6909 for ( QList<QByteArray>::ConstIterator it = content.constBegin(); 6910 - it!=content.constEnd(); ++it ) { 6911 + it != content.constEnd(); ++it ) { 6912 QByteArray str = *it; 6913 ++it; 6914 6915 - if ( str=="FLAGS" ) { 6916 - if ( (*it).startsWith('(') && (*it).endsWith(')') ) { 6917 + if ( str == "FLAGS" ) { 6918 + if ( ( *it ).startsWith( '(' ) && ( *it ).endsWith( ')' ) ) { 6919 QByteArray str = *it; 6920 - str.chop(1); 6921 - str.remove(0, 1); 6922 - resultingFlags = str.split(' '); 6923 + str.chop( 1 ); 6924 + str.remove( 0, 1 ); 6925 + resultingFlags = str.split( ' ' ); 6926 } else { 6927 resultingFlags << *it; 6928 } 6929 - } else if ( str=="UID" ) { 6930 - uid = it->toLongLong(&uidFound); 6931 + } else if ( str == "UID" ) { 6932 + uid = it->toLongLong( &uidFound ); 6933 } 6934 } 6935 6936 @@ -192,4 +194,5 @@ void StoreJob::handleResponse( const Message &response ) 6937 } 6938 } 6939 6940 -#include "storejob.moc" 6941 \ No newline at end of file 6942 +#include "storejob.moc" 6943 + 6944 diff --git a/kimap/storejob.h b/kimap/storejob.h 6945 index 7c41d90..4de2f76 100644 6946 --- a/kimap/storejob.h 6947 +++ b/kimap/storejob.h 6948 @@ -36,13 +36,12 @@ typedef QList<QByteArray> MessageFlags; 6949 class KIMAP_EXPORT StoreJob : public Job 6950 { 6951 Q_OBJECT 6952 - Q_DECLARE_PRIVATE(StoreJob) 6953 + Q_DECLARE_PRIVATE( StoreJob ) 6954 6955 friend class SessionPrivate; 6956 6957 public: 6958 - enum StoreMode 6959 - { 6960 + enum StoreMode { 6961 SetFlags, 6962 AppendFlags, 6963 RemoveFlags 6964 diff --git a/kimap/subscribejob.cpp b/kimap/subscribejob.cpp 6965 index 880f977..5317f73 100644 6966 --- a/kimap/subscribejob.cpp 6967 +++ b/kimap/subscribejob.cpp 6968 @@ -19,8 +19,8 @@ 6969 6970 #include "subscribejob.h" 6971 6972 -#include <klocale.h> 6973 -#include <kdebug.h> 6974 +#include <KDE/KLocalizedString> 6975 +#include <KDE/KDebug> 6976 6977 #include "job_p.h" 6978 #include "message_p.h" 6979 @@ -32,7 +32,7 @@ namespace KIMAP 6980 class SubscribeJobPrivate : public JobPrivate 6981 { 6982 public: 6983 - SubscribeJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { } 6984 + SubscribeJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { } 6985 ~SubscribeJobPrivate() { } 6986 6987 QString mailBox; 6988 @@ -42,7 +42,7 @@ namespace KIMAP 6989 using namespace KIMAP; 6990 6991 SubscribeJob::SubscribeJob( Session *session ) 6992 - : Job( *new SubscribeJobPrivate(session, i18n("Subscribe")) ) 6993 + : Job( *new SubscribeJobPrivate( session, i18n( "Subscribe" ) ) ) 6994 { 6995 } 6996 6997 @@ -52,20 +52,21 @@ SubscribeJob::~SubscribeJob() 6998 6999 void SubscribeJob::doStart() 7000 { 7001 - Q_D(SubscribeJob); 7002 - d->tags << d->sessionInternal()->sendCommand( "SUBSCRIBE", '\"'+KIMAP::encodeImapFolderName( d->mailBox.toUtf8() )+'\"' ); 7003 + Q_D( SubscribeJob ); 7004 + d->tags << d->sessionInternal()->sendCommand( "SUBSCRIBE", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"' ); 7005 } 7006 7007 void SubscribeJob::setMailBox( const QString &mailBox ) 7008 { 7009 - Q_D(SubscribeJob); 7010 + Q_D( SubscribeJob ); 7011 d->mailBox = mailBox; 7012 } 7013 7014 QString SubscribeJob::mailBox() const 7015 { 7016 - Q_D(const SubscribeJob); 7017 + Q_D( const SubscribeJob ); 7018 return d->mailBox; 7019 } 7020 7021 #include "subscribejob.moc" 7022 + 7023 diff --git a/kimap/subscribejob.h b/kimap/subscribejob.h 7024 index f0db503..e54cf9f 100644 7025 --- a/kimap/subscribejob.h 7026 +++ b/kimap/subscribejob.h 7027 @@ -32,7 +32,7 @@ class SubscribeJobPrivate; 7028 class KIMAP_EXPORT SubscribeJob : public Job 7029 { 7030 Q_OBJECT 7031 - Q_DECLARE_PRIVATE(SubscribeJob) 7032 + Q_DECLARE_PRIVATE( SubscribeJob ) 7033 7034 friend class SessionPrivate; 7035 7036 diff --git a/kimap/unsubscribejob.cpp b/kimap/unsubscribejob.cpp 7037 index f570987..06f0900 100644 7038 --- a/kimap/unsubscribejob.cpp 7039 +++ b/kimap/unsubscribejob.cpp 7040 @@ -19,8 +19,8 @@ 7041 7042 #include "unsubscribejob.h" 7043 7044 -#include <klocale.h> 7045 -#include <kdebug.h> 7046 +#include <KDE/KLocalizedString> 7047 +#include <KDE/KDebug> 7048 7049 #include "job_p.h" 7050 #include "message_p.h" 7051 @@ -32,7 +32,7 @@ namespace KIMAP 7052 class UnsubscribeJobPrivate : public JobPrivate 7053 { 7054 public: 7055 - UnsubscribeJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { } 7056 + UnsubscribeJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { } 7057 ~UnsubscribeJobPrivate() { } 7058 7059 QString mailBox; 7060 @@ -42,7 +42,7 @@ namespace KIMAP 7061 using namespace KIMAP; 7062 7063 UnsubscribeJob::UnsubscribeJob( Session *session ) 7064 - : Job( *new UnsubscribeJobPrivate(session, i18n("Unsubscribe")) ) 7065 + : Job( *new UnsubscribeJobPrivate( session, i18n( "Unsubscribe" ) ) ) 7066 { 7067 } 7068 7069 @@ -52,20 +52,21 @@ UnsubscribeJob::~UnsubscribeJob() 7070 7071 void UnsubscribeJob::doStart() 7072 { 7073 - Q_D(UnsubscribeJob); 7074 - d->tags << d->sessionInternal()->sendCommand( "UNSUBSCRIBE", '\"'+KIMAP::encodeImapFolderName( d->mailBox.toUtf8() )+'\"' ); 7075 + Q_D( UnsubscribeJob ); 7076 + d->tags << d->sessionInternal()->sendCommand( "UNSUBSCRIBE", '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"' ); 7077 } 7078 7079 void UnsubscribeJob::setMailBox( const QString &mailBox ) 7080 { 7081 - Q_D(UnsubscribeJob); 7082 + Q_D( UnsubscribeJob ); 7083 d->mailBox = mailBox; 7084 } 7085 7086 QString UnsubscribeJob::mailBox() const 7087 { 7088 - Q_D(const UnsubscribeJob); 7089 + Q_D( const UnsubscribeJob ); 7090 return d->mailBox; 7091 } 7092 7093 #include "unsubscribejob.moc" 7094 + 7095 diff --git a/kimap/unsubscribejob.h b/kimap/unsubscribejob.h 7096 index f03875e..1ef8ceb 100644 7097 --- a/kimap/unsubscribejob.h 7098 +++ b/kimap/unsubscribejob.h 7099 @@ -32,7 +32,7 @@ class UnsubscribeJobPrivate; 7100 class KIMAP_EXPORT UnsubscribeJob : public Job 7101 { 7102 Q_OBJECT 7103 - Q_DECLARE_PRIVATE(UnsubscribeJob) 7104 + Q_DECLARE_PRIVATE( UnsubscribeJob ) 7105 7106 friend class SessionPrivate; 7107