Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 171346 | Differences between
and this patch

Collapse All | Expand All

(-)kmail/aboutdata.cpp (-1 / +1 lines)
Lines 212-218 Link Here
212
    : KAboutData( "kmail", I18N_NOOP("KMail"),KMAIL_VERSION,
212
    : KAboutData( "kmail", I18N_NOOP("KMail"),KMAIL_VERSION,
213
                  I18N_NOOP("KDE Email Client"), License_GPL,
213
                  I18N_NOOP("KDE Email Client"), License_GPL,
214
                  I18N_NOOP("(c) 1997-2005, The KMail developers"), 0,
214
                  I18N_NOOP("(c) 1997-2005, The KMail developers"), 0,
215
                  "http://kmail.kde.org" )
215
                  "http://kontact.kde.org/kmail/" )
216
  {
216
  {
217
    using KMail::authors;
217
    using KMail::authors;
218
    using KMail::credits;
218
    using KMail::credits;
(-)kmail/accountwizard.cpp (+3 lines)
Lines 491-497 Link Here
491
void AccountWizard::accountCreated()
491
void AccountWizard::accountCreated()
492
{
492
{
493
  if ( mAccount )
493
  if ( mAccount )
494
  {
494
    mKernel->acctMgr()->add( mAccount );
495
    mKernel->acctMgr()->add( mAccount );
496
    mKernel->cleanupImapFolders();
497
  }
495
498
496
  finished();
499
  finished();
497
}
500
}
(-)kmail/configuredialog.cpp (-2 / +23 lines)
Lines 1147-1152 Link Here
1147
           this, SLOT(slotEditNotifications()) );
1147
           this, SLOT(slotEditNotifications()) );
1148
}
1148
}
1149
1149
1150
AccountsPageReceivingTab::~AccountsPageReceivingTab()
1151
{
1152
  // When hitting Cancel or closing the dialog with the window-manager-button,
1153
  // we have a number of things to clean up:
1154
1155
  // The newly created accounts
1156
  QValueList< QGuardedPtr<KMAccount> >::Iterator it;
1157
  for (it = mNewAccounts.begin(); it != mNewAccounts.end(); ++it ) {
1158
    delete (*it);
1159
  }
1160
  mNewAccounts.clear();
1161
1162
  // The modified accounts
1163
  QValueList<ModifiedAccountsType*>::Iterator j;
1164
  for ( j = mModifiedAccounts.begin() ; j != mModifiedAccounts.end() ; ++j ) {
1165
    delete (*j)->newAccount;
1166
    delete (*j);
1167
  }
1168
  mModifiedAccounts.clear();
1169
1170
1171
}
1150
1172
1151
void AccountsPage::ReceivingTab::slotAccountSelected()
1173
void AccountsPage::ReceivingTab::slotAccountSelected()
1152
{
1174
{
Lines 1398-1405 Link Here
1398
  // Add accounts marked as new
1420
  // Add accounts marked as new
1399
  QValueList< QGuardedPtr<KMAccount> >::Iterator it;
1421
  QValueList< QGuardedPtr<KMAccount> >::Iterator it;
1400
  for (it = mNewAccounts.begin(); it != mNewAccounts.end(); ++it ) {
1422
  for (it = mNewAccounts.begin(); it != mNewAccounts.end(); ++it ) {
1401
    kmkernel->acctMgr()->add( *it );
1423
    kmkernel->acctMgr()->add( *it ); // calls installTimer too
1402
    (*it)->installTimer();
1403
  }
1424
  }
1404
1425
1405
  // Update accounts that have been modified
1426
  // Update accounts that have been modified
(-)kmail/configuredialog_p.h (-1 / +2 lines)
Lines 349-354 Link Here
349
  Q_OBJECT
349
  Q_OBJECT
350
public:
350
public:
351
  AccountsPageReceivingTab( QWidget * parent=0, const char * name=0 );
351
  AccountsPageReceivingTab( QWidget * parent=0, const char * name=0 );
352
  ~AccountsPageReceivingTab();
352
  QString helpAnchor() const;
353
  QString helpAnchor() const;
353
  void save();
354
  void save();
354
355
Lines 384-390 Link Here
384
    QGuardedPtr< KMAccount > oldAccount;
385
    QGuardedPtr< KMAccount > oldAccount;
385
    QGuardedPtr< KMAccount > newAccount;
386
    QGuardedPtr< KMAccount > newAccount;
386
  };
387
  };
387
  // ### make this a qptrlist:
388
  // ### make this value-based:
388
  QValueList< ModifiedAccountsType* >  mModifiedAccounts;
389
  QValueList< ModifiedAccountsType* >  mModifiedAccounts;
389
};
390
};
390
391
(-)kmail/customtemplates.cpp (-2 / +3 lines)
Lines 300-308 Link Here
300
  if ( mCurrentItem ) {
300
  if ( mCurrentItem ) {
301
    // mCurrentItem->setText( 0, indexToType( index ) );
301
    // mCurrentItem->setText( 0, indexToType( index ) );
302
    CustomTemplateItem *vitem = mItemList[ mCurrentItem->text( 1 ) ];
302
    CustomTemplateItem *vitem = mItemList[ mCurrentItem->text( 1 ) ];
303
    if ( vitem ) {
303
    if ( !vitem ) {
304
      vitem->mType = static_cast<Type>(index);
304
      return;
305
    }
305
    }
306
    vitem->mType = static_cast<Type>(index);
306
    switch ( vitem->mType ) {
307
    switch ( vitem->mType ) {
307
    case TReply:
308
    case TReply:
308
      mCurrentItem->setPixmap( 0, mReplyPix );
309
      mCurrentItem->setPixmap( 0, mReplyPix );
(-)kmail/expirejob.cpp (-4 / +4 lines)
Lines 73-79 Link Here
73
  Q_ASSERT( mCancellable );
73
  Q_ASSERT( mCancellable );
74
  // We must close the folder if we opened it and got interrupted
74
  // We must close the folder if we opened it and got interrupted
75
  if ( mFolderOpen && mSrcFolder && mSrcFolder->storage() )
75
  if ( mFolderOpen && mSrcFolder && mSrcFolder->storage() )
76
    mSrcFolder->storage()->close();
76
    mSrcFolder->storage()->close("expirejob");
77
  FolderJob::kill();
77
  FolderJob::kill();
78
}
78
}
79
79
Lines 102-108 Link Here
102
102
103
  FolderStorage* storage = mSrcFolder->storage();
103
  FolderStorage* storage = mSrcFolder->storage();
104
  mOpeningFolder = true; // Ignore open-notifications while opening the folder
104
  mOpeningFolder = true; // Ignore open-notifications while opening the folder
105
  storage->open();
105
  storage->open("expirejob");
106
  mOpeningFolder = false;
106
  mOpeningFolder = false;
107
  mFolderOpen = true;
107
  mFolderOpen = true;
108
  mCurrentIndex = storage->count()-1;
108
  mCurrentIndex = storage->count()-1;
Lines 196-202 Link Here
196
  group.writeEntry( "Current", -1 ); // i.e. make it invalid, the serial number will be used
196
  group.writeEntry( "Current", -1 ); // i.e. make it invalid, the serial number will be used
197
197
198
  if ( !moving ) {
198
  if ( !moving ) {
199
    mSrcFolder->storage()->close();
199
    mSrcFolder->storage()->close("expirejob");
200
    mFolderOpen = false;
200
    mFolderOpen = false;
201
    delete this;
201
    delete this;
202
  }
202
  }
Lines 204-210 Link Here
204
204
205
void ExpireJob::slotMessagesMoved( KMCommand *command )
205
void ExpireJob::slotMessagesMoved( KMCommand *command )
206
{
206
{
207
  mSrcFolder->storage()->close();
207
  mSrcFolder->storage()->close("expirejob");
208
  mFolderOpen = false;
208
  mFolderOpen = false;
209
  QString msg;
209
  QString msg;
210
  switch ( command->result() ) {
210
  switch ( command->result() ) {
(-)kmail/folderstorage.cpp (-18 / +20 lines)
Lines 584-597 Link Here
584
  KMFolder* msgParent = aMsg->parent();
584
  KMFolder* msgParent = aMsg->parent();
585
585
586
  if (msgParent)
586
  if (msgParent)
587
    msgParent->open();
587
    msgParent->open("moveMsgSrc");
588
588
589
  open();
589
  open("moveMsgDest");
590
  int rc = addMsg(aMsg, aIndex_ret);
590
  int rc = addMsg(aMsg, aIndex_ret);
591
  close();
591
  close("moveMsgDest");
592
592
593
  if (msgParent)
593
  if (msgParent)
594
    msgParent->close();
594
    msgParent->close("moveMsgSrc");
595
595
596
  return rc;
596
  return rc;
597
}
597
}
Lines 604-621 Link Here
604
  KMFolder* msgParent = aMsg->parent();
604
  KMFolder* msgParent = aMsg->parent();
605
605
606
  if (msgParent)
606
  if (msgParent)
607
    msgParent->open();
607
    msgParent->open("foldermovemsg");
608
608
609
  QValueList<int> index;
609
  QValueList<int> index;
610
  open();
610
  open("moveMsg");
611
  int rc = addMsg(msglist, index);
611
  int rc = addMsg(msglist, index);
612
  close();
612
  close("moveMsg");
613
  // FIXME: we want to have a QValueList to pass it back, so change this method
613
  // FIXME: we want to have a QValueList to pass it back, so change this method
614
  if ( !index.isEmpty() )
614
  if ( !index.isEmpty() )
615
    aIndex_ret = &index.first();
615
    aIndex_ret = &index.first();
616
616
617
  if (msgParent)
617
  if (msgParent)
618
    msgParent->close();
618
    msgParent->close("foldermovemsg");
619
619
620
  return rc;
620
  return rc;
621
}
621
}
Lines 638-644 Link Here
638
  oldIdsLoc =  KMMsgDict::instance()->getFolderIdsLocation( *this );
638
  oldIdsLoc =  KMMsgDict::instance()->getFolderIdsLocation( *this );
639
  QString oldConfigString = "Folder-" + folder()->idString();
639
  QString oldConfigString = "Folder-" + folder()->idString();
640
640
641
  close(true);
641
  close("rename", true);
642
642
643
  oldName = folder()->fileName();
643
  oldName = folder()->fileName();
644
  oldParent = folder()->parent();
644
  oldParent = folder()->parent();
Lines 699-705 Link Here
699
699
700
  if (openCount > 0)
700
  if (openCount > 0)
701
  {
701
  {
702
    open();
702
    open("rename");
703
    mOpenCount = openCount;
703
    mOpenCount = openCount;
704
  }
704
  }
705
  writeConfig();
705
  writeConfig();
Lines 721-730 Link Here
721
  assert(!folder()->name().isEmpty());
721
  assert(!folder()->name().isEmpty());
722
722
723
  clearIndex( true, mExportsSernums ); // delete and remove from dict if necessary
723
  clearIndex( true, mExportsSernums ); // delete and remove from dict if necessary
724
  close(true);
724
  close("remove", true);
725
725
726
  if ( mExportsSernums )
726
  if ( mExportsSernums ) {
727
    KMMsgDict::mutableInstance()->removeFolderIds( *this );
727
    KMMsgDict::mutableInstance()->removeFolderIds( *this );
728
    mExportsSernums = false;	// do not writeFolderIds after removal
729
  }
728
  unlink(QFile::encodeName(indexLocation()) + ".sorted");
730
  unlink(QFile::encodeName(indexLocation()) + ".sorted");
729
  unlink(QFile::encodeName(indexLocation()));
731
  unlink(QFile::encodeName(indexLocation()));
730
732
Lines 748-754 Link Here
748
  assert(!folder()->name().isEmpty());
750
  assert(!folder()->name().isEmpty());
749
751
750
  clearIndex( true, mExportsSernums );   // delete and remove from dict, if needed
752
  clearIndex( true, mExportsSernums );   // delete and remove from dict, if needed
751
  close( true );
753
  close( "expunge", true );
752
754
753
  if ( mExportsSernums )
755
  if ( mExportsSernums )
754
    KMMsgDict::mutableInstance()->removeFolderIds( *this );
756
    KMMsgDict::mutableInstance()->removeFolderIds( *this );
Lines 764-770 Link Here
764
766
765
  if (openCount > 0)
767
  if (openCount > 0)
766
  {
768
  {
767
    open();
769
    open("expunge");
768
    mOpenCount = openCount;
770
    mOpenCount = openCount;
769
  }
771
  }
770
772
Lines 806-814 Link Here
806
  if (mUnreadMsgs > -1)
808
  if (mUnreadMsgs > -1)
807
    return mUnreadMsgs;
809
    return mUnreadMsgs;
808
810
809
  open(); // will update unreadMsgs
811
  open("countunread"); // will update unreadMsgs
810
  int unread = mUnreadMsgs;
812
  int unread = mUnreadMsgs;
811
  close();
813
  close("countunread");
812
  return (unread > 0) ? unread : 0;
814
  return (unread > 0) ? unread : 0;
813
}
815
}
814
816
Lines 905-912 Link Here
905
//-----------------------------------------------------------------------------
907
//-----------------------------------------------------------------------------
906
void FolderStorage::correctUnreadMsgsCount()
908
void FolderStorage::correctUnreadMsgsCount()
907
{
909
{
908
  open();
910
  open("countunreadmsg");
909
  close();
911
  close("countunreadmsg");
910
  emit numUnreadMsgsChanged( folder() );
912
  emit numUnreadMsgsChanged( folder() );
911
}
913
}
912
914
(-)kmail/folderstorage.h (-2 / +2 lines)
Lines 251-257 Link Here
251
    call close() first.
251
    call close() first.
252
    Returns zero on success and an error code equal to the c-library
252
    Returns zero on success and an error code equal to the c-library
253
    fopen call otherwise (errno). */
253
    fopen call otherwise (errno). */
254
  virtual int open() = 0;
254
  virtual int open(const char *owner) = 0;
255
255
256
  /** Check folder for permissions
256
  /** Check folder for permissions
257
    Returns zero if readable and writable. */
257
    Returns zero if readable and writable. */
Lines 259-265 Link Here
259
259
260
  /** Close folder. If force is TRUE the files are closed even if
260
  /** Close folder. If force is TRUE the files are closed even if
261
    others still use it (e.g. other mail reader windows). */
261
    others still use it (e.g. other mail reader windows). */
262
  virtual void close(bool force=FALSE) = 0;
262
  virtual void close(const char * owner,bool force=FALSE) = 0;
263
263
264
  /** Try releasing @p folder if possible, something is attempting an exclusive access to it.
264
  /** Try releasing @p folder if possible, something is attempting an exclusive access to it.
265
      Currently used for KMFolderSearch and the background tasks like expiry. */
265
      Currently used for KMFolderSearch and the background tasks like expiry. */
(-)kmail/headerstrategy.cpp (-1 / +2 lines)
Lines 60-66 Link Here
60
60
61
  static const char * richHeaders[] = {
61
  static const char * richHeaders[] = {
62
    "subject", "date", "from", "cc", "bcc", "to",
62
    "subject", "date", "from", "cc", "bcc", "to",
63
    "organization", "organisation", "reply-to"
63
    "organization", "organisation", "reply-to",
64
    "user-agent", "x-mailer"
64
  };
65
  };
65
  static const int numRichHeaders = sizeof richHeaders / sizeof *richHeaders;
66
  static const int numRichHeaders = sizeof richHeaders / sizeof *richHeaders;
66
67
(-)kmail/headerstyle.cpp (-14 / +34 lines)
Lines 541-547 Link Here
541
        if ( facestring.length() < 993 ) {
541
        if ( facestring.length() < 993 ) {
542
          QByteArray facearray;
542
          QByteArray facearray;
543
          KCodecs::base64Decode(facestring, facearray);
543
          KCodecs::base64Decode(facestring, facearray);
544
    
544
545
          QImage faceimage;
545
          QImage faceimage;
546
          if ( faceimage.loadFromData( facearray, "png" ) ) {
546
          if ( faceimage.loadFromData( facearray, "png" ) ) {
547
            // Spec says image must be 48x48 pixels
547
            // Spec says image must be 48x48 pixels
Lines 659-688 Link Here
659
    // to line
659
    // to line
660
    if ( strategy->showHeader( "to" ) )
660
    if ( strategy->showHeader( "to" ) )
661
      headerStr.append(QString("<tr><th>%1</th>\n"
661
      headerStr.append(QString("<tr><th>%1</th>\n"
662
                   "<td>%2</td></tr>\n")
662
                               "<td>%2</td></tr>\n")
663
                            .arg(i18n("To: "))
663
                       .arg(i18n("To: "))
664
                            .arg(KMMessage::emailAddrAsAnchor(message->to(),FALSE)));
664
                       .arg(KMMessage::emailAddrAsAnchor(message->to(),FALSE)));
665
665
666
    // cc line, if any
666
    // cc line, if any
667
    if ( strategy->showHeader( "cc" ) && !message->cc().isEmpty())
667
    if ( strategy->showHeader( "cc" ) && !message->cc().isEmpty())
668
      headerStr.append(QString("<tr><th>%1</th>\n"
668
      headerStr.append(QString("<tr><th>%1</th>\n"
669
                   "<td>%2</td></tr>\n")
669
                               "<td>%2</td></tr>\n")
670
                              .arg(i18n("CC: "))
670
                       .arg(i18n("CC: "))
671
                              .arg(KMMessage::emailAddrAsAnchor(message->cc(),FALSE)));
671
                       .arg(KMMessage::emailAddrAsAnchor(message->cc(),FALSE)));
672
672
673
    // Bcc line, if any
673
    // Bcc line, if any
674
    if ( strategy->showHeader( "bcc" ) && !message->bcc().isEmpty())
674
    if ( strategy->showHeader( "bcc" ) && !message->bcc().isEmpty())
675
      headerStr.append(QString("<tr><th>%1</th>\n"
675
      headerStr.append(QString("<tr><th>%1</th>\n"
676
                   "<td>%2</td></tr>\n")
676
                               "<td>%2</td></tr>\n")
677
                              .arg(i18n("BCC: "))
677
                       .arg(i18n("BCC: "))
678
                              .arg(KMMessage::emailAddrAsAnchor(message->bcc(),FALSE)));
678
                       .arg(KMMessage::emailAddrAsAnchor(message->bcc(),FALSE)));
679
679
680
    if ( strategy->showHeader( "date" ) )
680
    if ( strategy->showHeader( "date" ) )
681
      headerStr.append(QString("<tr><th>%1</th>\n"
681
      headerStr.append(QString("<tr><th>%1</th>\n"
682
                   "<td dir=\"%2\">%3</td></tr>\n")
682
                               "<td dir=\"%2\">%3</td></tr>\n")
683
                            .arg(i18n("Date: "))
683
                       .arg(i18n("Date: "))
684
                    .arg( directionOf( message->dateStr() ) )
684
                       .arg( directionOf( message->dateStr() ) )
685
                            .arg(strToHtml(dateString)));
685
                       .arg(strToHtml(dateString)));
686
687
    if ( GlobalSettings::self()->showUserAgent() ) {
688
      if ( strategy->showHeader( "user-agent" ) ) {
689
        if ( !message->headerField("User-Agent").isEmpty() ) {
690
          headerStr.append(QString("<tr><th>%1</th>\n"
691
                                   "<td>%2</td></tr>\n")
692
                           .arg(i18n("User-Agent: "))
693
                           .arg( strToHtml( message->headerField("User-Agent") ) ) );
694
        }
695
      }
696
697
      if ( strategy->showHeader( "x-mailer" ) ) {
698
        if ( !message->headerField("X-Mailer").isEmpty() ) {
699
          headerStr.append(QString("<tr><th>%1</th>\n"
700
                                   "<td>%2</td></tr>\n")
701
                           .arg(i18n("X-Mailer: "))
702
                           .arg( strToHtml( message->headerField("X-Mailer") ) ) );
703
        }
704
      }
705
    }
686
706
687
    // FIXME: Show status in synthetic header style field.  Decide whether this or current in brackets style is best and remove one.
707
    // FIXME: Show status in synthetic header style field.  Decide whether this or current in brackets style is best and remove one.
688
    /*    if( strategy->showHeader( "status" ) )
708
    /*    if( strategy->showHeader( "status" ) )
(-)kmail/imapjob.cpp (-4 / +34 lines)
Lines 84-95 Link Here
84
  mDestFolder = folder? folder->folder() : 0;
84
  mDestFolder = folder? folder->folder() : 0;
85
  // refcount++
85
  // refcount++
86
  if (folder) {
86
  if (folder) {
87
    folder->open();
87
    folder->open("imapjobdest");
88
  }
88
  }
89
  KMFolder *msg_parent = msg->parent();
89
  KMFolder *msg_parent = msg->parent();
90
  if (msg_parent) {
90
  if (msg_parent) {
91
    if (!folder || folder!= msg_parent->storage()) {
91
    if (!folder || folder!= msg_parent->storage()) {
92
      msg_parent->open();
92
      msg_parent->open("imapjobsrc");
93
    }
93
    }
94
  }
94
  }
95
  mSrcFolder = msg_parent;
95
  mSrcFolder = msg_parent;
Lines 241-247 Link Here
241
      }
241
      }
242
      account->mJobList.remove( this );
242
      account->mJobList.remove( this );
243
    }
243
    }
244
    mDestFolder->close();
244
    mDestFolder->close("imapjobdest");
245
  }
245
  }
246
246
247
  if ( mSrcFolder ) {
247
  if ( mSrcFolder ) {
Lines 266-272 Link Here
266
        account->mJobList.remove( this ); // remove the folderjob
266
        account->mJobList.remove( this ); // remove the folderjob
267
      }
267
      }
268
    }
268
    }
269
    mSrcFolder->close();
269
    mSrcFolder->close("imapjobsrc");
270
  }
270
  }
271
}
271
}
272
272
Lines 502-507 Link Here
502
void ImapJob::slotPutMessageDataReq( KIO::Job *job, QByteArray &data )
502
void ImapJob::slotPutMessageDataReq( KIO::Job *job, QByteArray &data )
503
{
503
{
504
  KMAcctImap *account = static_cast<KMFolderImap*>(mDestFolder->storage())->account();
504
  KMAcctImap *account = static_cast<KMFolderImap*>(mDestFolder->storage())->account();
505
  if ( !account )
506
  {
507
    emit finished();
508
    deleteLater();
509
    return;
510
  }
505
  ImapAccountBase::JobIterator it = account->findJob( job );
511
  ImapAccountBase::JobIterator it = account->findJob( job );
506
  if ( it == account->jobsEnd() ) return;
512
  if ( it == account->jobsEnd() ) return;
507
513
Lines 522-527 Link Here
522
void ImapJob::slotPutMessageResult( KIO::Job *job )
528
void ImapJob::slotPutMessageResult( KIO::Job *job )
523
{
529
{
524
  KMAcctImap *account = static_cast<KMFolderImap*>(mDestFolder->storage())->account();
530
  KMAcctImap *account = static_cast<KMFolderImap*>(mDestFolder->storage())->account();
531
  if ( !account )
532
  {
533
    emit finished();
534
    deleteLater();
535
    return;
536
  }
525
  ImapAccountBase::JobIterator it = account->findJob( job );
537
  ImapAccountBase::JobIterator it = account->findJob( job );
526
  if ( it == account->jobsEnd() ) return;
538
  if ( it == account->jobsEnd() ) return;
527
  bool deleteMe = false;
539
  bool deleteMe = false;
Lines 562-567 Link Here
562
{
574
{
563
  KMFolderImap * imapFolder = static_cast<KMFolderImap*>(mDestFolder->storage());
575
  KMFolderImap * imapFolder = static_cast<KMFolderImap*>(mDestFolder->storage());
564
  KMAcctImap *account = imapFolder->account();
576
  KMAcctImap *account = imapFolder->account();
577
  if ( !account )
578
  {
579
    emit finished();
580
    deleteLater();
581
    return;
582
  }
565
  ImapAccountBase::JobIterator it = account->findJob( job );
583
  ImapAccountBase::JobIterator it = account->findJob( job );
566
  if ( it == account->jobsEnd() ) return;
584
  if ( it == account->jobsEnd() ) return;
567
585
Lines 595-600 Link Here
595
{
613
{
596
  KMFolderImap * imapFolder = static_cast<KMFolderImap*>(mDestFolder->storage());
614
  KMFolderImap * imapFolder = static_cast<KMFolderImap*>(mDestFolder->storage());
597
  KMAcctImap *account = imapFolder->account();
615
  KMAcctImap *account = imapFolder->account();
616
  if ( !account )
617
  {
618
    emit finished();
619
    deleteLater();
620
    return;
621
  }
598
  ImapAccountBase::JobIterator it = account->findJob( job );
622
  ImapAccountBase::JobIterator it = account->findJob( job );
599
  if ( it == account->jobsEnd() ) return;
623
  if ( it == account->jobsEnd() ) return;
600
624
Lines 613-618 Link Here
613
void ImapJob::slotCopyMessageResult( KIO::Job *job )
637
void ImapJob::slotCopyMessageResult( KIO::Job *job )
614
{
638
{
615
  KMAcctImap *account = static_cast<KMFolderImap*>(mDestFolder->storage())->account();
639
  KMAcctImap *account = static_cast<KMFolderImap*>(mDestFolder->storage())->account();
640
  if ( !account )
641
  {
642
    emit finished();
643
    deleteLater();
644
    return;
645
  }
616
  ImapAccountBase::JobIterator it = account->findJob( job );
646
  ImapAccountBase::JobIterator it = account->findJob( job );
617
  if ( it == account->jobsEnd() ) return;
647
  if ( it == account->jobsEnd() ) return;
618
648
(-)kmail/index.cpp (-19 / +20 lines)
Lines 4-15 Link Here
4
 * KMail is free software; you can redistribute it and/or modify it
4
 * KMail is free software; you can redistribute it and/or modify it
5
 * under the terms of the GNU General Public License, version 2, as
5
 * under the terms of the GNU General Public License, version 2, as
6
 * published by the Free Software Foundation.
6
 * published by the Free Software Foundation.
7
 * 
7
 *
8
 * KMail is distributed in the hope that it will be useful, but
8
 * KMail is distributed in the hope that it will be useful, but
9
 * WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11
 * General Public License for more details.
11
 * General Public License for more details.
12
 * 
12
 *
13
 * You should have received a copy of the GNU General Public License
13
 * You should have received a copy of the GNU General Public License
14
 * along with this program; if not, write to the Free Software
14
 * along with this program; if not, write to the Free Software
15
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
15
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
Lines 58-63 Link Here
58
const char* const folderIndexDisabledKey = "fulltextIndexDisabled";
58
const char* const folderIndexDisabledKey = "fulltextIndexDisabled";
59
}
59
}
60
60
61
#ifdef HAVE_INDEXLIB
61
static
62
static
62
QValueList<int> vectorToQValueList( const std::vector<Q_UINT32>& input ) {
63
QValueList<int> vectorToQValueList( const std::vector<Q_UINT32>& input ) {
63
	QValueList<int> res;
64
	QValueList<int> res;
Lines 65-71 Link Here
65
	return res;
66
	return res;
66
}
67
}
67
68
68
69
static
69
static
70
std::vector<Q_UINT32> QValueListToVector( const QValueList<int>& input ) {
70
std::vector<Q_UINT32> QValueListToVector( const QValueList<int>& input ) {
71
	std::vector<Q_UINT32> res;
71
	std::vector<Q_UINT32> res;
Lines 75-80 Link Here
75
	}
75
	}
76
	return res;
76
	return res;
77
}
77
}
78
#endif
78
79
79
KMMsgIndex::KMMsgIndex( QObject* parent ):
80
KMMsgIndex::KMMsgIndex( QObject* parent ):
80
	QObject( parent, "index" ),
81
	QObject( parent, "index" ),
Lines 89-99 Link Here
89
	//mSyncTimer( new QTimer( this ) ),
90
	//mSyncTimer( new QTimer( this ) ),
90
	mSlowDown( false ) {
91
	mSlowDown( false ) {
91
	kdDebug( 5006 ) << "KMMsgIndex::KMMsgIndex()" << endl;
92
	kdDebug( 5006 ) << "KMMsgIndex::KMMsgIndex()" << endl;
92
	
93
93
	connect( kmkernel->folderMgr(), SIGNAL( msgRemoved( KMFolder*, Q_UINT32 ) ), SLOT( slotRemoveMessage( KMFolder*, Q_UINT32 ) ) );
94
	connect( kmkernel->folderMgr(), SIGNAL( msgRemoved( KMFolder*, Q_UINT32 ) ), SLOT( slotRemoveMessage( Q_UINT32 ) ) );
94
	connect( kmkernel->folderMgr(), SIGNAL( msgAdded( KMFolder*, Q_UINT32 ) ), SLOT( slotAddMessage( KMFolder*, Q_UINT32 ) ) );
95
	connect( kmkernel->folderMgr(), SIGNAL( msgAdded( KMFolder*, Q_UINT32 ) ), SLOT( slotAddMessage( Q_UINT32 ) ) );
95
	connect( kmkernel->dimapFolderMgr(), SIGNAL( msgRemoved( KMFolder*, Q_UINT32 ) ), SLOT( slotRemoveMessage( KMFolder*, Q_UINT32 ) ) );
96
	connect( kmkernel->dimapFolderMgr(), SIGNAL( msgRemoved( KMFolder*, Q_UINT32 ) ), SLOT( slotRemoveMessage( Q_UINT32 ) ) );
96
	connect( kmkernel->dimapFolderMgr(), SIGNAL( msgAdded( KMFolder*, Q_UINT32 ) ), SLOT( slotAddMessage( KMFolder*, Q_UINT32 ) ) );
97
	connect( kmkernel->dimapFolderMgr(), SIGNAL( msgAdded( KMFolder*, Q_UINT32 ) ), SLOT( slotAddMessage( Q_UINT32 ) ) );
97
98
98
	connect( mTimer, SIGNAL( timeout() ), SLOT( act() ) );
99
	connect( mTimer, SIGNAL( timeout() ), SLOT( act() ) );
99
	//connect( mSyncTimer, SIGNAL( timeout() ), SLOT( syncIndex() ) );
100
	//connect( mSyncTimer, SIGNAL( timeout() ), SLOT( syncIndex() ) );
Lines 226-232 Link Here
226
				//else  fall-through
227
				//else  fall-through
227
			case s_idle:
228
			case s_idle:
228
			case s_processing:
229
			case s_processing:
229
				
230
230
			case s_error:
231
			case s_error:
231
			case s_disabled:
232
			case s_disabled:
232
				// nothing can be done
233
				// nothing can be done
Lines 250-256 Link Here
250
	mExisting.clear();
251
	mExisting.clear();
251
	mState = s_disabled;
252
	mState = s_disabled;
252
	for ( std::set<KMFolder*>::const_iterator first = mOpenedFolders.begin(), past = mOpenedFolders.end(); first != past; ++first ) {
253
	for ( std::set<KMFolder*>::const_iterator first = mOpenedFolders.begin(), past = mOpenedFolders.end(); first != past; ++first ) {
253
		( *first )->close();
254
		( *first )->close("msgindex");
254
	}
255
	}
255
	mOpenedFolders.clear();
256
	mOpenedFolders.clear();
256
	for ( std::vector<Search*>::const_iterator first = mSearches.begin(), past = mSearches.end(); first != past; ++first ) {
257
	for ( std::vector<Search*>::const_iterator first = mSearches.begin(), past = mSearches.end(); first != past; ++first ) {
Lines 284-290 Link Here
284
	if ( !folder || idx == -1 ) return -1;
285
	if ( !folder || idx == -1 ) return -1;
285
	if ( !mOpenedFolders.count( folder ) ) {
286
	if ( !mOpenedFolders.count( folder ) ) {
286
		mOpenedFolders.insert( folder );
287
		mOpenedFolders.insert( folder );
287
		folder->open();
288
		folder->open("msgindex");
288
	}
289
	}
289
	KMMessage* msg = folder->getMsg( idx );
290
	KMMessage* msg = folder->getMsg( idx );
290
	/* I still don't know whether we should allow decryption or not.
291
	/* I still don't know whether we should allow decryption or not.
Lines 324-330 Link Here
324
		mPendingFolders.pop_back();
325
		mPendingFolders.pop_back();
325
		if ( !mOpenedFolders.count( f ) ) {
326
		if ( !mOpenedFolders.count( f ) ) {
326
			mOpenedFolders.insert( f );
327
			mOpenedFolders.insert( f );
327
			f->open();
328
			f->open("msgindex");
328
		}
329
		}
329
		const KMMsgDict* dict = KMMsgDict::instance();
330
		const KMMsgDict* dict = KMMsgDict::instance();
330
		KConfig* config = KMKernel::config();
331
		KConfig* config = KMKernel::config();
Lines 344-350 Link Here
344
	for ( std::set<KMFolder*>::const_iterator first = mOpenedFolders.begin(), past = mOpenedFolders.end();
345
	for ( std::set<KMFolder*>::const_iterator first = mOpenedFolders.begin(), past = mOpenedFolders.end();
345
			first != past;
346
			first != past;
346
			++first ) {
347
			++first ) {
347
		( *first )->close();
348
		( *first )->close("msgindex");
348
	}
349
	}
349
	mOpenedFolders.clear();
350
	mOpenedFolders.clear();
350
	mState = s_idle;
351
	mState = s_idle;
Lines 367-373 Link Here
367
368
368
void KMMsgIndex::create() {
369
void KMMsgIndex::create() {
369
	kdDebug( 5006 ) << "KMMsgIndex::create()" << endl;
370
	kdDebug( 5006 ) << "KMMsgIndex::create()" << endl;
370
	
371
371
#ifdef HAVE_INDEXLIB
372
#ifdef HAVE_INDEXLIB
372
	if ( !QFileInfo( mIndexPath ).exists() ) {
373
	if ( !QFileInfo( mIndexPath ).exists() ) {
373
		::mkdir( mIndexPath, S_IRWXU );
374
		::mkdir( mIndexPath, S_IRWXU );
Lines 428-434 Link Here
428
//}
429
//}
429
//
430
//
430
//void KMMsgIndex::finishSync() {
431
//void KMMsgIndex::finishSync() {
431
//	
432
//
432
//}
433
//}
433
434
434
void KMMsgIndex::removeSearch( QObject* destroyed ) {
435
void KMMsgIndex::removeSearch( QObject* destroyed ) {
Lines 481-490 Link Here
481
	return false;
482
	return false;
482
}
483
}
483
484
484
void KMMsgIndex::slotAddMessage( KMFolder* folder, Q_UINT32 serNum ) {
485
void KMMsgIndex::slotAddMessage( Q_UINT32 serNum ) {
485
	kdDebug( 5006 ) << "KMMsgIndex::slotAddMessage( . , " << serNum << " )" << endl;
486
	kdDebug( 5006 ) << "KMMsgIndex::slotAddMessage( . , " << serNum << " )" << endl;
486
	if ( mState == s_error || mState == s_disabled ) return;
487
	if ( mState == s_error || mState == s_disabled ) return;
487
	
488
488
	if ( mState == s_creating ) mAddedMsgs.push_back( serNum );
489
	if ( mState == s_creating ) mAddedMsgs.push_back( serNum );
489
	else mPendingMsgs.push_back( serNum );
490
	else mPendingMsgs.push_back( serNum );
490
491
Lines 492-498 Link Here
492
	scheduleAction();
493
	scheduleAction();
493
}
494
}
494
495
495
void KMMsgIndex::slotRemoveMessage( KMFolder* folder, Q_UINT32 serNum ) {
496
void KMMsgIndex::slotRemoveMessage( Q_UINT32 serNum ) {
496
	kdDebug( 5006 ) << "KMMsgIndex::slotRemoveMessage( . , " << serNum << " )" << endl;
497
	kdDebug( 5006 ) << "KMMsgIndex::slotRemoveMessage( . , " << serNum << " )" << endl;
497
	if ( mState == s_error || mState == s_disabled ) return;
498
	if ( mState == s_error || mState == s_disabled ) return;
498
499
Lines 511-517 Link Here
511
void KMMsgIndex::removeMessage( Q_UINT32 serNum ) {
512
void KMMsgIndex::removeMessage( Q_UINT32 serNum ) {
512
	kdDebug( 5006 ) << "KMMsgIndex::removeMessage( " << serNum << " )" << endl;
513
	kdDebug( 5006 ) << "KMMsgIndex::removeMessage( " << serNum << " )" << endl;
513
	if ( mState == s_error || mState == s_disabled ) return;
514
	if ( mState == s_error || mState == s_disabled ) return;
514
	
515
515
#ifdef HAVE_INDEXLIB
516
#ifdef HAVE_INDEXLIB
516
	mIndex->remove_doc( QString::number( serNum ).latin1() );
517
	mIndex->remove_doc( QString::number( serNum ).latin1() );
517
	++mMaintenanceCount;
518
	++mMaintenanceCount;
(-)kmail/index.h (-7 / +7 lines)
Lines 8-23 Link Here
8
 * KMail is free software; you can redistribute it and/or modify it
8
 * KMail is free software; you can redistribute it and/or modify it
9
 * under the terms of the GNU General Public License, version 2, as
9
 * under the terms of the GNU General Public License, version 2, as
10
 * published by the Free Software Foundation.
10
 * published by the Free Software Foundation.
11
 * 
11
 *
12
 * KMail is distributed in the hope that it will be useful, but
12
 * KMail is distributed in the hope that it will be useful, but
13
 * WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 * General Public License for more details.
15
 * General Public License for more details.
16
 * 
16
 *
17
 * You should have received a copy of the GNU General Public License
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program; if not, write to the Free Software
18
 * along with this program; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
20
 * 
20
 *
21
 * In addition, as a special exception, the copyright holders give
21
 * In addition, as a special exception, the copyright holders give
22
 * permission to link the code of this program with any edition of
22
 * permission to link the code of this program with any edition of
23
 * the Qt library by Trolltech AS, Norway (or with modified versions
23
 * the Qt library by Trolltech AS, Norway (or with modified versions
Lines 56-66 Link Here
56
		~KMMsgIndex();
56
		~KMMsgIndex();
57
57
58
	public:
58
	public:
59
		
59
60
		/**
60
		/**
61
		 * Starts a query.
61
		 * Starts a query.
62
		 * Results will be returned assyncronously by signals.
62
		 * Results will be returned assyncronously by signals.
63
		 * 
63
		 *
64
		 * @return false if the query cannot be handled
64
		 * @return false if the query cannot be handled
65
		 */
65
		 */
66
		bool startQuery( KMSearch* );
66
		bool startQuery( KMSearch* );
Lines 133-140 Link Here
133
133
134
		void continueCreation();
134
		void continueCreation();
135
135
136
		void slotAddMessage( KMFolder*, Q_UINT32 message );
136
		void slotAddMessage( Q_UINT32 message );
137
		void slotRemoveMessage( KMFolder*, Q_UINT32 message );
137
		void slotRemoveMessage( Q_UINT32 message );
138
	private:
138
	private:
139
		static QString defaultPath();
139
		static QString defaultPath();
140
140
(-)kmail/kmaccount.cpp (-6 / +6 lines)
Lines 151-156 Link Here
151
  {
151
  {
152
    setFolder(kmkernel->folderMgr()->findIdString(folderName), true);
152
    setFolder(kmkernel->folderMgr()->findIdString(folderName), true);
153
  }
153
  }
154
155
  if (mInterval == 0)
156
    deinstallTimer();
157
  else
158
    installTimer();
154
}
159
}
155
160
156
161
Lines 278-292 Link Here
278
void KMAccount::setCheckInterval(int aInterval)
283
void KMAccount::setCheckInterval(int aInterval)
279
{
284
{
280
  if (aInterval <= 0)
285
  if (aInterval <= 0)
281
  {
282
    mInterval = 0;
286
    mInterval = 0;
283
    deinstallTimer();
284
  }
285
  else
287
  else
286
  {
287
    mInterval = aInterval;
288
    mInterval = aInterval;
288
    installTimer();
289
  // Don't call installTimer from here! See #117935.
289
  }
290
}
290
}
291
291
292
//----------------------------------------------------------------------------
292
//----------------------------------------------------------------------------
(-)kmail/kmacctimap.cpp (-18 / +21 lines)
Lines 66-78 Link Here
66
  connect(kmkernel->imapFolderMgr(), SIGNAL(changed()),
66
  connect(kmkernel->imapFolderMgr(), SIGNAL(changed()),
67
      this, SLOT(slotUpdateFolderList()));
67
      this, SLOT(slotUpdateFolderList()));
68
  connect(&mErrorTimer, SIGNAL(timeout()), SLOT(slotResetConnectionError()));
68
  connect(&mErrorTimer, SIGNAL(timeout()), SLOT(slotResetConnectionError()));
69
  
69
70
  QString serNumUri = locateLocal( "data", "kmail/unfiltered." + 
70
  QString serNumUri = locateLocal( "data", "kmail/unfiltered." +
71
				   QString("%1").arg(KAccount::id()) );
71
				   QString("%1").arg(KAccount::id()) );
72
  KConfig config( serNumUri );
72
  KConfig config( serNumUri );
73
  QStringList serNums = config.readListEntry( "unfiltered" );
73
  QStringList serNums = config.readListEntry( "unfiltered" );
74
  mFilterSerNumsToSave.setAutoDelete( false );
74
  mFilterSerNumsToSave.setAutoDelete( false );
75
  
75
76
  for ( QStringList::ConstIterator it = serNums.begin();
76
  for ( QStringList::ConstIterator it = serNums.begin();
77
	it != serNums.end(); ++it ) {
77
	it != serNums.end(); ++it ) {
78
      mFilterSerNums.append( (*it).toUInt() );
78
      mFilterSerNums.append( (*it).toUInt() );
Lines 85-92 Link Here
85
KMAcctImap::~KMAcctImap()
85
KMAcctImap::~KMAcctImap()
86
{
86
{
87
  killAllJobs( true );
87
  killAllJobs( true );
88
  
88
89
  QString serNumUri = locateLocal( "data", "kmail/unfiltered." + 
89
  QString serNumUri = locateLocal( "data", "kmail/unfiltered." +
90
				   QString("%1").arg(KAccount::id()) );
90
				   QString("%1").arg(KAccount::id()) );
91
  KConfig config( serNumUri );
91
  KConfig config( serNumUri );
92
  QStringList serNums;
92
  QStringList serNums;
Lines 265-273 Link Here
265
  if (!mFolder || !mFolder->folder() || !mFolder->folder()->child() ||
265
  if (!mFolder || !mFolder->folder() || !mFolder->folder()->child() ||
266
      makeConnection() == ImapAccountBase::Error)
266
      makeConnection() == ImapAccountBase::Error)
267
  {
267
  {
268
    // checks for mCountRemainChecks
269
    checkDone( false, CheckError );
268
    mCountRemainChecks = 0;
270
    mCountRemainChecks = 0;
269
    mCheckingSingleFolder = false;
271
    mCheckingSingleFolder = false;
270
    checkDone( false, CheckError );
271
    return;
272
    return;
272
  }
273
  }
273
  // if necessary then initialize the list of folders which should be checked
274
  // if necessary then initialize the list of folders which should be checked
Lines 330-338 Link Here
330
              this, SLOT(postProcessNewMail(KMFolderImap*, bool)));
331
              this, SLOT(postProcessNewMail(KMFolderImap*, bool)));
331
          imapFolder->getFolder();
332
          imapFolder->getFolder();
332
        } else if ( kmkernel->filterMgr()->atLeastOneIncomingFilterAppliesTo( id() ) &&
333
        } else if ( kmkernel->filterMgr()->atLeastOneIncomingFilterAppliesTo( id() ) &&
333
                    imapFolder->folder()->isSystemFolder() && 
334
                    imapFolder->folder()->isSystemFolder() &&
334
                    imapFolder->imapPath() == "/INBOX/" ) {
335
                    imapFolder->imapPath() == "/INBOX/" ) {
335
          imapFolder->open(); // will be closed in the folderSelected slot
336
          imapFolder->open("acctimap"); // will be closed in the folderSelected slot
336
          // first get new headers before we select the folder
337
          // first get new headers before we select the folder
337
          imapFolder->setSelected( true );
338
          imapFolder->setSelected( true );
338
          connect( imapFolder, SIGNAL( folderComplete( KMFolderImap*, bool ) ),
339
          connect( imapFolder, SIGNAL( folderComplete( KMFolderImap*, bool ) ),
Lines 342-348 Link Here
342
        else {
343
        else {
343
          connect(imapFolder, SIGNAL(numUnreadMsgsChanged(KMFolder*)),
344
          connect(imapFolder, SIGNAL(numUnreadMsgsChanged(KMFolder*)),
344
              this, SLOT(postProcessNewMail(KMFolder*)));
345
              this, SLOT(postProcessNewMail(KMFolder*)));
345
          bool ok = imapFolder->processNewMail(interactive);
346
          bool ok = imapFolder->processNewMail(interactive); // this removes the local kmfolderimap if its imapPath is somehow empty, and removing it calls createFolderList, invalidating mMailCheckFolders, and causing a crash
346
          if (!ok)
347
          if (!ok)
347
          {
348
          {
348
            // there was an error so cancel
349
            // there was an error so cancel
Lines 352-357 Link Here
352
              mMailCheckProgressItem->incCompletedItems();
353
              mMailCheckProgressItem->incCompletedItems();
353
              mMailCheckProgressItem->updateProgress();
354
              mMailCheckProgressItem->updateProgress();
354
            }
355
            }
356
            // since the list of folders might have been updated at this point, mMailCheckFolders may be invalid, so break
357
            break;
355
          }
358
          }
356
        }
359
        }
357
      }
360
      }
Lines 377-383 Link Here
377
  postProcessNewMail(static_cast<KMFolder*>(folder->folder()));
380
  postProcessNewMail(static_cast<KMFolder*>(folder->folder()));
378
}
381
}
379
382
380
void KMAcctImap::postProcessNewMail( KMFolder * folder ) 
383
void KMAcctImap::postProcessNewMail( KMFolder * folder )
381
{
384
{
382
  disconnect( folder->storage(), SIGNAL(numUnreadMsgsChanged(KMFolder*)),
385
  disconnect( folder->storage(), SIGNAL(numUnreadMsgsChanged(KMFolder*)),
383
              this, SLOT(postProcessNewMail(KMFolder*)) );
386
              this, SLOT(postProcessNewMail(KMFolder*)) );
Lines 403-409 Link Here
403
  QValueListIterator<Q_UINT32> filterIt = mFilterSerNums.begin();
406
  QValueListIterator<Q_UINT32> filterIt = mFilterSerNums.begin();
404
  QValueList<Q_UINT32> inTransit;
407
  QValueList<Q_UINT32> inTransit;
405
408
406
  if (ActionScheduler::isEnabled() || 
409
  if (ActionScheduler::isEnabled() ||
407
      kmkernel->filterMgr()->atLeastOneOnlineImapFolderTarget()) {
410
      kmkernel->filterMgr()->atLeastOneOnlineImapFolderTarget()) {
408
    KMFilterMgr::FilterSet set = KMFilterMgr::Inbound;
411
    KMFilterMgr::FilterSet set = KMFilterMgr::Inbound;
409
    QValueList<KMFilter*> filters = kmkernel->filterMgr()->filters();
412
    QValueList<KMFilter*> filters = kmkernel->filterMgr()->filters();
Lines 428-434 Link Here
428
      ++filterIt;
431
      ++filterIt;
429
      continue;
432
      continue;
430
    }
433
    }
431
    
434
432
    KMFolderImap *imapFolder = dynamic_cast<KMFolderImap*>(folder->storage());
435
    KMFolderImap *imapFolder = dynamic_cast<KMFolderImap*>(folder->storage());
433
    if (!imapFolder ||
436
    if (!imapFolder ||
434
	!imapFolder->folder()->isSystemFolder() ||
437
	!imapFolder->folder()->isSystemFolder() ||
Lines 447-453 Link Here
447
        continue;
450
        continue;
448
      }
451
      }
449
452
450
      if (ActionScheduler::isEnabled() || 
453
      if (ActionScheduler::isEnabled() ||
451
	  kmkernel->filterMgr()->atLeastOneOnlineImapFolderTarget()) {
454
	  kmkernel->filterMgr()->atLeastOneOnlineImapFolderTarget()) {
452
	mScheduler->execFilters( msg );
455
	mScheduler->execFilters( msg );
453
      } else {
456
      } else {
Lines 471-477 Link Here
471
    ++filterIt;
474
    ++filterIt;
472
  }
475
  }
473
  mFilterSerNums = inTransit;
476
  mFilterSerNums = inTransit;
474
  
477
475
  if (mCountRemainChecks == 0)
478
  if (mCountRemainChecks == 0)
476
  {
479
  {
477
    // all checks are done
480
    // all checks are done
Lines 542-548 Link Here
542
  return mFolder;
545
  return mFolder;
543
}
546
}
544
547
545
ImapAccountBase::ConnectionState KMAcctImap::makeConnection() 
548
ImapAccountBase::ConnectionState KMAcctImap::makeConnection()
546
{
549
{
547
  if ( mSlaveConnectionError )
550
  if ( mSlaveConnectionError )
548
  {
551
  {
Lines 557-570 Link Here
557
  mSlaveConnectionError = false;
560
  mSlaveConnectionError = false;
558
  kdDebug(5006) << k_funcinfo << endl;
561
  kdDebug(5006) << k_funcinfo << endl;
559
}
562
}
560
    
563
561
void KMAcctImap::slotFolderSelected( KMFolderImap* folder, bool )
564
void KMAcctImap::slotFolderSelected( KMFolderImap* folder, bool )
562
{
565
{
563
  folder->setSelected( false );
566
  folder->setSelected( false );
564
  disconnect( folder, SIGNAL( folderComplete( KMFolderImap*, bool ) ),
567
  disconnect( folder, SIGNAL( folderComplete( KMFolderImap*, bool ) ),
565
	      this, SLOT( slotFolderSelected( KMFolderImap*, bool) ) );
568
	      this, SLOT( slotFolderSelected( KMFolderImap*, bool) ) );
566
  postProcessNewMail( static_cast<KMFolder*>(folder->folder()) );
569
  postProcessNewMail( static_cast<KMFolder*>(folder->folder()) );
567
  folder->close();
570
  folder->close( "acctimap" );
568
}
571
}
569
572
570
void KMAcctImap::execFilters(Q_UINT32 serNum)
573
void KMAcctImap::execFilters(Q_UINT32 serNum)
Lines 588-594 Link Here
588
  if ( serNum )
591
  if ( serNum )
589
    mFilterSerNumsToSave.remove( QString( "%1" ).arg( serNum ) );
592
    mFilterSerNumsToSave.remove( QString( "%1" ).arg( serNum ) );
590
593
591
  int filterResult = kmkernel->filterMgr()->process(msg, 
594
  int filterResult = kmkernel->filterMgr()->process(msg,
592
						    KMFilterMgr::Inbound,
595
						    KMFilterMgr::Inbound,
593
						    true,
596
						    true,
594
						    id() );
597
						    id() );
(-)kmail/kmacctlocal.cpp (-5 / +5 lines)
Lines 146-152 Link Here
146
    return false;
146
    return false;
147
  }
147
  }
148
  
148
  
149
  const int rc = mMailFolder->open();
149
  const int rc = mMailFolder->open("acctlocalMail");
150
  if ( rc != 0 ) {
150
  if ( rc != 0 ) {
151
    QString aStr;
151
    QString aStr;
152
    aStr = i18n("Cannot open file:");
152
    aStr = i18n("Cannot open file:");
Lines 161-167 Link Here
161
161
162
  if (!mboxStorage->isLocked()) {
162
  if (!mboxStorage->isLocked()) {
163
    kdDebug(5006) << "mailFolder could not be locked" << endl;
163
    kdDebug(5006) << "mailFolder could not be locked" << endl;
164
    mMailFolder->close();
164
    mMailFolder->close("acctlocalMail");
165
    checkDone( mHasNewMail, CheckError );
165
    checkDone( mHasNewMail, CheckError );
166
    QString errMsg = i18n( "Transmission failed: Could not lock %1." )
166
    QString errMsg = i18n( "Transmission failed: Could not lock %1." )
167
      .arg( mMailFolder->location() );
167
      .arg( mMailFolder->location() );
Lines 169-175 Link Here
169
    return false;
169
    return false;
170
  }
170
  }
171
171
172
  mFolder->open();
172
  mFolder->open("acctlocalFold");
173
173
174
  mNumMsgs = mMailFolder->count();
174
  mNumMsgs = mMailFolder->count();
175
175
Lines 259-268 Link Here
259
  }
259
  }
260
  // else warning is written already
260
  // else warning is written already
261
261
262
  mMailFolder->close();
262
  mMailFolder->close("acctlocalMail");
263
  delete mMailFolder; mMailFolder = 0;
263
  delete mMailFolder; mMailFolder = 0;
264
264
265
  mFolder->close();
265
  mFolder->close("acctlocalFold");
266
266
267
  checkDone( mHasNewMail, CheckOK );
267
  checkDone( mHasNewMail, CheckOK );
268
}
268
}
(-)kmail/kmacctmaildir.cpp (-4 / +4 lines)
Lines 127-133 Link Here
127
    return;
127
    return;
128
  }
128
  }
129
129
130
  rc = mailFolder.open();
130
  rc = mailFolder.open("acctmaildirMail");
131
  if (rc)
131
  if (rc)
132
  {
132
  {
133
    QString aStr = i18n("<qt>Cannot open folder <b>%1</b>.</qt>").arg( mailFolder.location() );
133
    QString aStr = i18n("<qt>Cannot open folder <b>%1</b>.</qt>").arg( mailFolder.location() );
Lines 138-144 Link Here
138
    return;
138
    return;
139
  }
139
  }
140
140
141
  mFolder->open();
141
  mFolder->open("acctmaildirFold");
142
142
143
143
144
  num = mailFolder.count();
144
  num = mailFolder.count();
Lines 203-210 Link Here
203
  }
203
  }
204
  // else warning is written already
204
  // else warning is written already
205
205
206
  mailFolder.close();
206
  mailFolder.close("acctmaildirMail");
207
  mFolder->close();
207
  mFolder->close("acctmaildirFold");
208
208
209
  checkDone( hasNewMail, CheckOK );
209
  checkDone( hasNewMail, CheckOK );
210
210
(-)kmail/kmail.antispamrc (-1 / +1 lines)
Lines 216-222 Link Here
216
Version=1
216
Version=1
217
Priority=65
217
Priority=65
218
VisibleName=CRM114
218
VisibleName=CRM114
219
Executeable=crm -v | grep "CRM114"
219
Executable=crm -v | grep "CRM114"
220
URL=http://crm114.sourceforge.net
220
URL=http://crm114.sourceforge.net
221
PipeFilterName=CRM114 Check
221
PipeFilterName=CRM114 Check
222
PipeCmdDetect=crm -u $HOME/.crm114 mailreaver.crm
222
PipeCmdDetect=crm -u $HOME/.crm114 mailreaver.crm
(-)kmail/avscripts/kmail_clamav.sh (-1 / +1 lines)
Lines 39-45 Link Here
39
    chmod a+r $TEMPFILE
39
    chmod a+r $TEMPFILE
40
    CLAMCOMANDO="clamdscan --stdout --no-summary "
40
    CLAMCOMANDO="clamdscan --stdout --no-summary "
41
else
41
else
42
    CLAMCOMANDO="clamscan --stdout --no-summary --mbox"
42
    CLAMCOMANDO="clamscan --stdout --no-summary"
43
fi
43
fi
44
44
45
# analyze the message
45
# analyze the message
(-)kmail/kmailicalifaceimpl.h (-3 / +3 lines)
Lines 51-57 Link Here
51
class KMFolderDir;
51
class KMFolderDir;
52
class KMFolderTreeItem;
52
class KMFolderTreeItem;
53
53
54
namespace {
54
namespace KMail {
55
55
56
  // Local helper class
56
  // Local helper class
57
class ExtraFolder {
57
class ExtraFolder {
Lines 276-284 Link Here
276
276
277
  // The extra IMAP resource folders
277
  // The extra IMAP resource folders
278
  // Key: folder location. Data: folder.
278
  // Key: folder location. Data: folder.
279
  QDict<ExtraFolder> mExtraFolders;
279
  QDict<KMail::ExtraFolder> mExtraFolders;
280
  // used for collecting incidences during async loading
280
  // used for collecting incidences during async loading
281
  QDict<Accumulator> mAccumulators;
281
  QDict<KMail::Accumulator> mAccumulators;
282
  // More info for each folder we care about (mContacts etc. as well as the extra folders)
282
  // More info for each folder we care about (mContacts etc. as well as the extra folders)
283
  // The reason for storing it here is that it can be shared between
283
  // The reason for storing it here is that it can be shared between
284
  // kmfoldercachedimap and kmfolderimap, and that it's groupware data anyway.
284
  // kmfoldercachedimap and kmfolderimap, and that it's groupware data anyway.
(-)kmail/kmail.kcfg (+10 lines)
Lines 87-92 Link Here
87
    </group>
87
    </group>
88
88
89
    <group name="General">
89
    <group name="General">
90
      <entry name="disregardUmask" type="Bool">
91
        <label>Disregard the users umask setting and use "read-write for the user only" instead</label>
92
        <default>false</default>
93
      </entry>
90
      <entry name="SystemTrayEnabled" type="Bool">
94
      <entry name="SystemTrayEnabled" type="Bool">
91
        <label>Enable system tray icon</label>
95
        <label>Enable system tray icon</label>
92
        <default>false</default>
96
        <default>false</default>
Lines 446-451 Link Here
446
     <entry name="ChiasmusDecryptionOptions" type="String">
450
     <entry name="ChiasmusDecryptionOptions" type="String">
447
     </entry>
451
     </entry>
448
452
453
     <entry name="ShowUserAgent" type="Bool">
454
       <default>false</default>
455
       <label>Show user agent in fancy headers</label>
456
       <whatsthis>Enable this option to get the User-Agent and X-Mailer header lines displayed when using fancy headers.</whatsthis>
457
     </entry>
458
449
    </group>
459
    </group>
450
460
451
    <group name="TextIndex">
461
    <group name="TextIndex">
(-)kmail/kmcommands.cpp (-36 / +63 lines)
Lines 182-188 Link Here
182
  for ( fit = mFolders.begin(); fit != mFolders.end(); ++fit ) {
182
  for ( fit = mFolders.begin(); fit != mFolders.end(); ++fit ) {
183
    if (!(*fit))
183
    if (!(*fit))
184
      continue;
184
      continue;
185
    (*fit)->close();
185
    (*fit)->close("kmcommand");
186
  }
186
  }
187
}
187
}
188
188
Lines 440-446 Link Here
440
440
441
void KMCommand::keepFolderOpen( KMFolder *folder )
441
void KMCommand::keepFolderOpen( KMFolder *folder )
442
{
442
{
443
  folder->open();
443
  folder->open("kmcommand");
444
  mFolders.append( folder );
444
  mFolders.append( folder );
445
}
445
}
446
446
Lines 481-486 Link Here
481
{
481
{
482
  //TODO : consider factoring createReply into this method.
482
  //TODO : consider factoring createReply into this method.
483
  KMMessage *msg = retrievedMessage();
483
  KMMessage *msg = retrievedMessage();
484
  if ( !msg || !msg->codec() ) {
485
    return Failed;
486
  }
484
  KMMessage *rmsg = msg->createReply( KMail::ReplyNone, mSelection );
487
  KMMessage *rmsg = msg->createReply( KMail::ReplyNone, mSelection );
485
  rmsg->setTo( KMMessage::decodeMailtoUrl( mUrl.path() ) );
488
  rmsg->setTo( KMMessage::decodeMailtoUrl( mUrl.path() ) );
486
489
Lines 503-508 Link Here
503
{
506
{
504
  //TODO : consider factoring createForward into this method.
507
  //TODO : consider factoring createForward into this method.
505
  KMMessage *msg = retrievedMessage();
508
  KMMessage *msg = retrievedMessage();
509
  if ( !msg || !msg->codec() ) {
510
    return Failed;
511
  }
506
  KMMessage *fmsg = msg->createForward();
512
  KMMessage *fmsg = msg->createForward();
507
  fmsg->setTo( KMMessage::decodeMailtoUrl( mUrl.path() ) );
513
  fmsg->setTo( KMMessage::decodeMailtoUrl( mUrl.path() ) );
508
514
Lines 690-698 Link Here
690
    return Failed;
696
    return Failed;
691
697
692
  // Take a copy of the original message, which remains unchanged.
698
  // Take a copy of the original message, which remains unchanged.
693
  KMMessage *newMsg = new KMMessage;
699
  KMMessage *newMsg = new KMMessage( new DwMessage( *msg->asDwMessage() ) );
694
  newMsg->setComplete( msg->isComplete() );
700
  newMsg->setComplete( msg->isComplete() );
695
  newMsg->fromString( msg->asString() );
696
701
697
  KMail::Composer *win = KMail::makeComposer();
702
  KMail::Composer *win = KMail::makeComposer();
698
  newMsg->setTransferInProgress( false ); // From here on on, the composer owns the message.
703
  newMsg->setTransferInProgress( false ); // From here on on, the composer owns the message.
Lines 713-718 Link Here
713
KMCommand::Result KMShowMsgSrcCommand::execute()
718
KMCommand::Result KMShowMsgSrcCommand::execute()
714
{
719
{
715
  KMMessage *msg = retrievedMessage();
720
  KMMessage *msg = retrievedMessage();
721
  if ( !msg || !msg->codec() ) {
722
    return Failed;
723
  }
716
  if ( msg->isComplete() && !mMsgWasComplete )
724
  if ( msg->isComplete() && !mMsgWasComplete )
717
    msg->notify(); // notify observers as msg was transfered
725
    msg->notify(); // notify observers as msg was transfered
718
  QString str = msg->codec()->toUnicode( msg->asString() );
726
  QString str = msg->codec()->toUnicode( msg->asString() );
Lines 742-748 Link Here
742
static KURL subjectToUrl( const QString & subject ) {
750
static KURL subjectToUrl( const QString & subject ) {
743
    return KFileDialog::getSaveURL( subject.stripWhiteSpace()
751
    return KFileDialog::getSaveURL( subject.stripWhiteSpace()
744
                                           .replace( QDir::separator(), '_' ),
752
                                           .replace( QDir::separator(), '_' ),
745
                                    QString::null );
753
                                    "*.mbox" );
746
}
754
}
747
755
748
KMSaveMsgCommand::KMSaveMsgCommand( QWidget *parent, KMMessage * msg )
756
KMSaveMsgCommand::KMSaveMsgCommand( QWidget *parent, KMMessage * msg )
Lines 787-793 Link Here
787
    mMsgList.append( (*it)->getMsgSerNum() );
795
    mMsgList.append( (*it)->getMsgSerNum() );
788
    mTotalSize += (*it)->msgSize();
796
    mTotalSize += (*it)->msgSize();
789
    if ((*it)->parent() != 0)
797
    if ((*it)->parent() != 0)
790
      (*it)->parent()->open();
798
      (*it)->parent()->open("kmcommand");
791
    ++it;
799
    ++it;
792
  }
800
  }
793
  mMsgListIndex = 0;
801
  mMsgListIndex = 0;
Lines 876-888 Link Here
876
void KMSaveMsgCommand::slotMessageRetrievedForSaving(KMMessage *msg)
884
void KMSaveMsgCommand::slotMessageRetrievedForSaving(KMMessage *msg)
877
{
885
{
878
  if ( msg ) {
886
  if ( msg ) {
879
    QCString str( msg->mboxMessageSeparator() );
887
    mData = KMFolderMbox::escapeFrom( msg->asDwString() );
880
    str += KMFolderMbox::escapeFrom( msg->asString() );
888
    KMail::Util::insert( mData, 0, msg->mboxMessageSeparator() );
881
    str += '\n';
889
    KMail::Util::append( mData, "\n" );
882
    msg->setTransferInProgress(false);
890
    msg->setTransferInProgress(false);
883
891
884
    mData = str;
885
    mData.resize(mData.size() - 1);
886
    mOffset = 0;
892
    mOffset = 0;
887
    QByteArray data;
893
    QByteArray data;
888
    int size;
894
    int size;
Lines 904-910 Link Here
904
    KMMsgDict::instance()->getLocation( msg, &p, &idx );
910
    KMMsgDict::instance()->getLocation( msg, &p, &idx );
905
    assert( p == msg->parent() ); assert( idx >= 0 );
911
    assert( p == msg->parent() ); assert( idx >= 0 );
906
    p->unGetMsg( idx );
912
    p->unGetMsg( idx );
907
    p->close();
913
    p->close("kmcommand");
908
  }
914
  }
909
}
915
}
910
916
Lines 958-964 Link Here
958
KMCommand::Result KMOpenMsgCommand::execute()
964
KMCommand::Result KMOpenMsgCommand::execute()
959
{
965
{
960
  if ( mUrl.isEmpty() ) {
966
  if ( mUrl.isEmpty() ) {
961
    mUrl = KFileDialog::getOpenURL( ":OpenMessage", "message/rfc822",
967
    mUrl = KFileDialog::getOpenURL( ":OpenMessage", "message/rfc822 application/mbox",
962
                                    parentWidget(), i18n("Open Message") );
968
                                    parentWidget(), i18n("Open Message") );
963
  }
969
  }
964
  if ( mUrl.isEmpty() ) {
970
  if ( mUrl.isEmpty() ) {
Lines 1065-1070 Link Here
1065
{
1071
{
1066
  KCursorSaver busy(KBusyPtr::busy());
1072
  KCursorSaver busy(KBusyPtr::busy());
1067
  KMMessage *msg = retrievedMessage();
1073
  KMMessage *msg = retrievedMessage();
1074
  if ( !msg || !msg->codec() ) {
1075
    return Failed;
1076
  }
1068
  KMMessage *reply = msg->createReply( KMail::ReplySmart, mSelection );
1077
  KMMessage *reply = msg->createReply( KMail::ReplySmart, mSelection );
1069
  KMail::Composer * win = KMail::makeComposer( reply );
1078
  KMail::Composer * win = KMail::makeComposer( reply );
1070
  win->setCharset( msg->codec()->mimeName(), TRUE );
1079
  win->setCharset( msg->codec()->mimeName(), TRUE );
Lines 1085-1090 Link Here
1085
{
1094
{
1086
  KCursorSaver busy(KBusyPtr::busy());
1095
  KCursorSaver busy(KBusyPtr::busy());
1087
  KMMessage *msg = retrievedMessage();
1096
  KMMessage *msg = retrievedMessage();
1097
  if ( !msg || !msg->codec() ) {
1098
    return Failed;
1099
  }
1088
  KMMessage *reply = msg->createReply( KMail::ReplySmart, "", TRUE);
1100
  KMMessage *reply = msg->createReply( KMail::ReplySmart, "", TRUE);
1089
  KMail::Composer * win = KMail::makeComposer( reply );
1101
  KMail::Composer * win = KMail::makeComposer( reply );
1090
  win->setCharset(msg->codec()->mimeName(), TRUE);
1102
  win->setCharset(msg->codec()->mimeName(), TRUE);
Lines 1105-1110 Link Here
1105
{
1117
{
1106
  KCursorSaver busy(KBusyPtr::busy());
1118
  KCursorSaver busy(KBusyPtr::busy());
1107
  KMMessage *msg = retrievedMessage();
1119
  KMMessage *msg = retrievedMessage();
1120
  if ( !msg || !msg->codec() ) {
1121
    return Failed;
1122
  }
1108
  KMMessage *reply = msg->createReply( KMail::ReplyList, mSelection);
1123
  KMMessage *reply = msg->createReply( KMail::ReplyList, mSelection);
1109
  KMail::Composer * win = KMail::makeComposer( reply );
1124
  KMail::Composer * win = KMail::makeComposer( reply );
1110
  win->setCharset(msg->codec()->mimeName(), TRUE);
1125
  win->setCharset(msg->codec()->mimeName(), TRUE);
Lines 1125-1130 Link Here
1125
{
1140
{
1126
  KCursorSaver busy(KBusyPtr::busy());
1141
  KCursorSaver busy(KBusyPtr::busy());
1127
  KMMessage *msg = retrievedMessage();
1142
  KMMessage *msg = retrievedMessage();
1143
  if ( !msg || !msg->codec() ) {
1144
    return Failed;
1145
  }
1128
  KMMessage *reply = msg->createReply( KMail::ReplyAll, mSelection );
1146
  KMMessage *reply = msg->createReply( KMail::ReplyAll, mSelection );
1129
  KMail::Composer * win = KMail::makeComposer( reply );
1147
  KMail::Composer * win = KMail::makeComposer( reply );
1130
  win->setCharset( msg->codec()->mimeName(), TRUE );
1148
  win->setCharset( msg->codec()->mimeName(), TRUE );
Lines 1145-1150 Link Here
1145
{
1163
{
1146
  KCursorSaver busy(KBusyPtr::busy());
1164
  KCursorSaver busy(KBusyPtr::busy());
1147
  KMMessage *msg = retrievedMessage();
1165
  KMMessage *msg = retrievedMessage();
1166
  if ( !msg || !msg->codec() ) {
1167
    return Failed;
1168
  }
1148
  KMMessage *reply = msg->createReply( KMail::ReplyAuthor, mSelection );
1169
  KMMessage *reply = msg->createReply( KMail::ReplyAuthor, mSelection );
1149
  KMail::Composer * win = KMail::makeComposer( reply );
1170
  KMail::Composer * win = KMail::makeComposer( reply );
1150
  win->setCharset( msg->codec()->mimeName(), TRUE );
1171
  win->setCharset( msg->codec()->mimeName(), TRUE );
Lines 1176-1182 Link Here
1176
  if (msgList.count() >= 2) { // Multiple forward
1197
  if (msgList.count() >= 2) { // Multiple forward
1177
1198
1178
    uint id = 0;
1199
    uint id = 0;
1179
    // QCString msgText = "";
1180
    QPtrList<KMMessage> linklist;
1200
    QPtrList<KMMessage> linklist;
1181
    for ( KMMessage *msg = msgList.first(); msg; msg = msgList.next() ) {
1201
    for ( KMMessage *msg = msgList.first(); msg; msg = msgList.next() ) {
1182
      // set the identity
1202
      // set the identity
Lines 1197-1203 Link Here
1197
    for ( KMMessage *msg = linklist.first(); msg; msg = linklist.next() ) {
1217
    for ( KMMessage *msg = linklist.first(); msg; msg = linklist.next() ) {
1198
      TemplateParser parser( fwdMsg, TemplateParser::Forward,
1218
      TemplateParser parser( fwdMsg, TemplateParser::Forward,
1199
        msg->body(), false, false, false, false);
1219
        msg->body(), false, false, false, false);
1200
        parser.process( msg, 0, true );
1220
        parser.process( msg, false, true );
1201
1221
1202
      fwdMsg->link( msg, KMMsgStatusForwarded );
1222
      fwdMsg->link( msg, KMMsgStatusForwarded );
1203
    }
1223
    }
Lines 1280-1287 Link Here
1280
    msgPart->setContentDescription(msg->from()+": "+msg->subject());
1300
    msgPart->setContentDescription(msg->from()+": "+msg->subject());
1281
    msgPart->setContentDisposition( "inline" );
1301
    msgPart->setContentDisposition( "inline" );
1282
    // THIS HAS TO BE AFTER setCte()!!!!
1302
    // THIS HAS TO BE AFTER setCte()!!!!
1283
    QValueList<int> dummy;
1303
    msgPart->setMessageBody( KMail::Util::ByteArray( msg->asDwString() ) );
1284
    msgPart->setBodyAndGuessCte(msg->asString(), dummy, true);
1285
    msgPart->setCharset("");
1304
    msgPart->setCharset("");
1286
1305
1287
    fwdMsg->link(msg, KMMsgStatusForwarded);
1306
    fwdMsg->link(msg, KMMsgStatusForwarded);
Lines 1422-1427 Link Here
1422
{
1441
{
1423
  KCursorSaver busy(KBusyPtr::busy());
1442
  KCursorSaver busy(KBusyPtr::busy());
1424
  KMMessage *msg = retrievedMessage();
1443
  KMMessage *msg = retrievedMessage();
1444
  if ( !msg || !msg->codec() ) {
1445
    return Failed;
1446
  }
1425
  KMMessage *reply = msg->createReply( KMail::ReplySmart, mSelection,
1447
  KMMessage *reply = msg->createReply( KMail::ReplySmart, mSelection,
1426
                                       false, true, false, mTemplate );
1448
                                       false, true, false, mTemplate );
1427
  KMail::Composer * win = KMail::makeComposer( reply );
1449
  KMail::Composer * win = KMail::makeComposer( reply );
Lines 1444-1449 Link Here
1444
{
1466
{
1445
  KCursorSaver busy(KBusyPtr::busy());
1467
  KCursorSaver busy(KBusyPtr::busy());
1446
  KMMessage *msg = retrievedMessage();
1468
  KMMessage *msg = retrievedMessage();
1469
  if ( !msg || !msg->codec() ) {
1470
    return Failed;
1471
  }
1447
  KMMessage *reply = msg->createReply( KMail::ReplyAll, mSelection,
1472
  KMMessage *reply = msg->createReply( KMail::ReplyAll, mSelection,
1448
                                       false, true, false, mTemplate );
1473
                                       false, true, false, mTemplate );
1449
  KMail::Composer * win = KMail::makeComposer( reply );
1474
  KMail::Composer * win = KMail::makeComposer( reply );
Lines 1476-1482 Link Here
1476
  if (msgList.count() >= 2) { // Multiple forward
1501
  if (msgList.count() >= 2) { // Multiple forward
1477
1502
1478
    uint id = 0;
1503
    uint id = 0;
1479
    // QCString msgText = "";
1480
    QPtrList<KMMessage> linklist;
1504
    QPtrList<KMMessage> linklist;
1481
    for ( KMMessage *msg = msgList.first(); msg; msg = msgList.next() ) {
1505
    for ( KMMessage *msg = msgList.first(); msg; msg = msgList.next() ) {
1482
      // set the identity
1506
      // set the identity
Lines 1497-1503 Link Here
1497
    for ( KMMessage *msg = linklist.first(); msg; msg = linklist.next() ) {
1521
    for ( KMMessage *msg = linklist.first(); msg; msg = linklist.next() ) {
1498
      TemplateParser parser( fwdMsg, TemplateParser::Forward,
1522
      TemplateParser parser( fwdMsg, TemplateParser::Forward,
1499
        msg->body(), false, false, false, false);
1523
        msg->body(), false, false, false, false);
1500
        parser.process( msg, 0, true );
1524
        parser.process( msg, false, true );
1501
1525
1502
      fwdMsg->link( msg, KMMsgStatusForwarded );
1526
      fwdMsg->link( msg, KMMsgStatusForwarded );
1503
    }
1527
    }
Lines 1888-1894 Link Here
1888
  QPtrList<KMMessage> list;
1912
  QPtrList<KMMessage> list;
1889
  QPtrList<KMMessage> localList;
1913
  QPtrList<KMMessage> localList;
1890
1914
1891
  if (mDestFolder && mDestFolder->open() != 0)
1915
  if (mDestFolder && mDestFolder->open("kmcommand") != 0)
1892
  {
1916
  {
1893
    deleteLater();
1917
    deleteLater();
1894
    return Failed;
1918
    return Failed;
Lines 1918-1929 Link Here
1918
      // imap => imap with same account
1942
      // imap => imap with same account
1919
      list.append(msg);
1943
      list.append(msg);
1920
    } else {
1944
    } else {
1921
      newMsg = new KMMessage;
1945
      newMsg = new KMMessage( new DwMessage( *msg->asDwMessage() ) );
1922
      newMsg->setComplete(msg->isComplete());
1946
      newMsg->setComplete(msg->isComplete());
1923
      // make sure the attachment state is only calculated when it's complete
1947
      // make sure the attachment state is only calculated when it's complete
1924
      if (!newMsg->isComplete())
1948
      if (!newMsg->isComplete())
1925
        newMsg->setReadyToShow(false);
1949
        newMsg->setReadyToShow(false);
1926
      newMsg->fromString(msg->asString());
1927
      newMsg->setStatus(msg->status());
1950
      newMsg->setStatus(msg->status());
1928
1951
1929
      if (srcFolder && !newMsg->isComplete())
1952
      if (srcFolder && !newMsg->isComplete())
Lines 1990-1996 Link Here
1990
  // otherwise this is done in slotMsgAdded or slotFolderComplete
2013
  // otherwise this is done in slotMsgAdded or slotFolderComplete
1991
  if ( deleteNow )
2014
  if ( deleteNow )
1992
  {
2015
  {
1993
    mDestFolder->close();
2016
    mDestFolder->close("kmcommand");
1994
    deleteLater();
2017
    deleteLater();
1995
  }
2018
  }
1996
2019
Lines 2002-2015 Link Here
2002
  mWaitingForMsgs.remove( serNum );
2025
  mWaitingForMsgs.remove( serNum );
2003
  if ( mWaitingForMsgs.isEmpty() )
2026
  if ( mWaitingForMsgs.isEmpty() )
2004
  {
2027
  {
2005
    mDestFolder->close();
2028
    mDestFolder->close("kmcommand");
2006
    deleteLater();
2029
    deleteLater();
2007
  }
2030
  }
2008
}
2031
}
2009
2032
2010
void KMCopyCommand::slotFolderComplete()
2033
void KMCopyCommand::slotFolderComplete()
2011
{
2034
{
2012
  mDestFolder->close();
2035
  mDestFolder->close("kmcommand");
2013
  deleteLater();
2036
  deleteLater();
2014
}
2037
}
2015
2038
Lines 2046-2052 Link Here
2046
  typedef QMap< KMFolder*, QPtrList<KMMessage>* > FolderToMessageListMap;
2069
  typedef QMap< KMFolder*, QPtrList<KMMessage>* > FolderToMessageListMap;
2047
  FolderToMessageListMap folderDeleteList;
2070
  FolderToMessageListMap folderDeleteList;
2048
2071
2049
  if (mDestFolder && mDestFolder->open() != 0) {
2072
  if (mDestFolder && mDestFolder->open("kmcommand") != 0) {
2050
    completeMove( Failed );
2073
    completeMove( Failed );
2051
    return Failed;
2074
    return Failed;
2052
  }
2075
  }
Lines 2216-2226 Link Here
2216
void KMMoveCommand::completeMove( Result result )
2239
void KMMoveCommand::completeMove( Result result )
2217
{
2240
{
2218
  if ( mDestFolder )
2241
  if ( mDestFolder )
2219
    mDestFolder->close();
2242
    mDestFolder->close("kmcommand");
2220
  while ( !mOpenedFolders.empty() ) {
2243
  while ( !mOpenedFolders.empty() ) {
2221
    KMFolder *folder = mOpenedFolders.back();
2244
    KMFolder *folder = mOpenedFolders.back();
2222
    mOpenedFolders.pop_back();
2245
    mOpenedFolders.pop_back();
2223
    folder->close();
2246
    folder->close("kmcommand");
2224
  }
2247
  }
2225
  if ( mProgressItem ) {
2248
  if ( mProgressItem ) {
2226
    mProgressItem->setComplete();
2249
    mProgressItem->setComplete();
Lines 2241-2254 Link Here
2241
  const QPtrList<KMMsgBase> &msgList )
2264
  const QPtrList<KMMsgBase> &msgList )
2242
:KMMoveCommand( findTrashFolder( srcFolder ), msgList)
2265
:KMMoveCommand( findTrashFolder( srcFolder ), msgList)
2243
{
2266
{
2244
  srcFolder->open();
2267
  srcFolder->open("kmcommand");
2245
  mOpenedFolders.push_back( srcFolder );
2268
  mOpenedFolders.push_back( srcFolder );
2246
}
2269
}
2247
2270
2248
KMDeleteMsgCommand::KMDeleteMsgCommand( KMFolder* srcFolder, KMMessage * msg )
2271
KMDeleteMsgCommand::KMDeleteMsgCommand( KMFolder* srcFolder, KMMessage * msg )
2249
:KMMoveCommand( findTrashFolder( srcFolder ), msg)
2272
:KMMoveCommand( findTrashFolder( srcFolder ), msg)
2250
{
2273
{
2251
  srcFolder->open();
2274
  srcFolder->open("kmcommand");
2252
  mOpenedFolders.push_back( srcFolder );
2275
  mOpenedFolders.push_back( srcFolder );
2253
}
2276
}
2254
2277
Lines 2260-2266 Link Here
2260
  KMMsgDict::instance()->getLocation( sernum, &srcFolder, &idx );
2283
  KMMsgDict::instance()->getLocation( sernum, &srcFolder, &idx );
2261
  if ( srcFolder ) {
2284
  if ( srcFolder ) {
2262
    KMMsgBase *msg = srcFolder->getMsgBase( idx );
2285
    KMMsgBase *msg = srcFolder->getMsgBase( idx );
2263
    srcFolder->open();
2286
    srcFolder->open("kmcommand");
2264
    mOpenedFolders.push_back( srcFolder );
2287
    mOpenedFolders.push_back( srcFolder );
2265
    addMsg( msg );
2288
    addMsg( msg );
2266
  }
2289
  }
Lines 2563-2571 Link Here
2563
  {
2586
  {
2564
    // This does not decode the Message Content-Transfer-Encoding
2587
    // This does not decode the Message Content-Transfer-Encoding
2565
    // but saves the _original_ content of the message part
2588
    // but saves the _original_ content of the message part
2566
    QCString cstr( node->msgPart().body() );
2589
    data = KMail::Util::ByteArray( node->msgPart().dwBody() );
2567
    data = cstr;
2568
    data.resize(data.size() - 1);
2569
  }
2590
  }
2570
  else
2591
  else
2571
  {
2592
  {
Lines 2635-2641 Link Here
2635
          i18n( "KMail Error" ) );
2656
          i18n( "KMail Error" ) );
2636
      return Failed;
2657
      return Failed;
2637
    }
2658
    }
2638
    fchmod( file.handle(), S_IRUSR | S_IWUSR );
2659
2660
    // #79685 by default use the umask the user defined, but let it be configurable
2661
    if ( GlobalSettings::self()->disregardUmask() )
2662
      fchmod( file.handle(), S_IRUSR | S_IWUSR );
2663
2639
    ds.setDevice( &file );
2664
    ds.setDevice( &file );
2640
  } else
2665
  } else
2641
  {
2666
  {
Lines 2743-2749 Link Here
2743
KMCommand::Result KMResendMessageCommand::execute()
2768
KMCommand::Result KMResendMessageCommand::execute()
2744
{
2769
{
2745
  KMMessage *msg = retrievedMessage();
2770
  KMMessage *msg = retrievedMessage();
2746
2771
  if ( !msg || !msg->codec() ) {
2772
    return Failed;
2773
  }
2747
  KMMessage *newMsg = new KMMessage(*msg);
2774
  KMMessage *newMsg = new KMMessage(*msg);
2748
  newMsg->setCharset(msg->codec()->mimeName());
2775
  newMsg->setCharset(msg->codec()->mimeName());
2749
  // the message needs a new Message-Id
2776
  // the message needs a new Message-Id
(-)kmail/kmcomposewin.h (+9 lines)
Lines 838-843 Link Here
838
838
839
  QPopupMenu *mActNowMenu;
839
  QPopupMenu *mActNowMenu;
840
  QPopupMenu *mActLaterMenu;
840
  QPopupMenu *mActLaterMenu;
841
842
  /** If the message in this composer has a cursor position set (for
843
   *   instance because it comes from a template containing %CURSOR)
844
   *   then we need to preserve that cursor position even when auto-
845
   *   appending (or prepending) the signature during composer setup.
846
   *   Set to true *once* (and only in setMsg() at that) to avoid
847
   *   accidentally moving the cursor.
848
   */
849
  bool mPreserveUserCursorPosition;
841
};
850
};
842
851
843
#endif
852
#endif
(-)kmail/kmfiltermgr.cpp (-6 / +6 lines)
Lines 239-245 Link Here
239
    }
239
    }
240
    bool opened = folder->isOpened();
240
    bool opened = folder->isOpened();
241
    if ( !opened )
241
    if ( !opened )
242
      folder->open();
242
      folder->open("filtermgr");
243
    KMMsgBase *msgBase = folder->getMsgBase( idx );
243
    KMMsgBase *msgBase = folder->getMsgBase( idx );
244
    bool unGet = !msgBase->isMessage();
244
    bool unGet = !msgBase->isMessage();
245
    KMMessage *msg = folder->getMsg( idx );
245
    KMMessage *msg = folder->getMsg( idx );
Lines 248-261 Link Here
248
      if ( unGet )
248
      if ( unGet )
249
        folder->unGetMsg( idx );
249
        folder->unGetMsg( idx );
250
      if ( !opened )
250
      if ( !opened )
251
        folder->close();
251
        folder->close("filtermgr");
252
      return 1;
252
      return 1;
253
    }
253
    }
254
    if ( filter->execActions( msg, stopIt ) == KMFilter::CriticalError ) {
254
    if ( filter->execActions( msg, stopIt ) == KMFilter::CriticalError ) {
255
      if ( unGet )
255
      if ( unGet )
256
        folder->unGetMsg( idx );
256
        folder->unGetMsg( idx );
257
      if ( !opened )
257
      if ( !opened )
258
        folder->close();
258
        folder->close("filtermgr");
259
      return 2;
259
      return 2;
260
    }
260
    }
261
261
Lines 271-277 Link Here
271
    if ( unGet )
271
    if ( unGet )
272
      folder->unGetMsg( idx );
272
      folder->unGetMsg( idx );
273
    if ( !opened )
273
    if ( !opened )
274
      folder->close();
274
      folder->close("filtermgr");
275
  } else {
275
  } else {
276
    result = 1;
276
    result = 1;
277
  }
277
  }
Lines 423-429 Link Here
423
    return;
423
    return;
424
  QValueVector< KMFolder *>::const_iterator it;
424
  QValueVector< KMFolder *>::const_iterator it;
425
  for ( it = mOpenFolders.constBegin(); it != mOpenFolders.constEnd(); ++it )
425
  for ( it = mOpenFolders.constBegin(); it != mOpenFolders.constEnd(); ++it )
426
    (*it)->close();
426
    (*it)->close("filtermgr");
427
  mOpenFolders.clear();
427
  mOpenFolders.clear();
428
}
428
}
429
429
Lines 433-439 Link Here
433
{
433
{
434
  assert( aFolder );
434
  assert( aFolder );
435
435
436
  int rc = aFolder->open();
436
  int rc = aFolder->open("filermgr");
437
  if (rc) return rc;
437
  if (rc) return rc;
438
438
439
  mOpenFolders.append( aFolder );
439
  mOpenFolders.append( aFolder );
(-)kmail/kmfolder.h (-4 / +5 lines)
Lines 286-292 Link Here
286
    call close() first.
286
    call close() first.
287
    Returns zero on success and an error code equal to the c-library
287
    Returns zero on success and an error code equal to the c-library
288
    fopen call otherwise (errno). */
288
    fopen call otherwise (errno). */
289
  int open();
289
  int open(const char *owner);
290
290
291
  /** Check folder for permissions
291
  /** Check folder for permissions
292
    Returns zero if readable and writable. */
292
    Returns zero if readable and writable. */
Lines 294-300 Link Here
294
294
295
  /** Close folder. If force is true the files are closed even if
295
  /** Close folder. If force is true the files are closed even if
296
    others still use it (e.g. other mail reader windows). */
296
    others still use it (e.g. other mail reader windows). */
297
  void close(bool force=false);
297
  void close(const char *owner, bool force=false);
298
298
299
  /** fsync buffers to disk */
299
  /** fsync buffers to disk */
300
  void sync();
300
  void sync();
Lines 647-656 Link Here
647
*/
647
*/
648
class KMFolderCloser {
648
class KMFolderCloser {
649
  KMFolder * f;
649
  KMFolder * f;
650
  QString mOwner;
650
public:
651
public:
651
  KMFolderCloser( KMFolder * folder ) : f( folder ) {}
652
  KMFolderCloser( const char *owner, KMFolder * folder ) : f( folder ), mOwner( owner ) {}
652
  ~KMFolderCloser() {
653
  ~KMFolderCloser() {
653
    if ( f ) f->close();
654
    if ( f ) f->close(mOwner.latin1());
654
  }
655
  }
655
  KMFolder * folder() const { return f; }
656
  KMFolder * folder() const { return f; }
656
};
657
};
(-)kmail/kmfoldercachedimap.cpp (-11 / +12 lines)
Lines 150-157 Link Here
150
    uidWriteTimer( -1 ), mLastUid( 0 ), mTentativeHighestUid( 0 ),
150
    uidWriteTimer( -1 ), mLastUid( 0 ), mTentativeHighestUid( 0 ),
151
    mFoundAnIMAPDigest( false ),
151
    mFoundAnIMAPDigest( false ),
152
    mUserRights( 0 ), mSilentUpload( false ),
152
    mUserRights( 0 ), mSilentUpload( false ),
153
    /*mHoldSyncs( false ),*/
153
    mFolderRemoved( false ),
154
    mFolderRemoved( false ),
154
    /*mHoldSyncs( false ),*/ mRecurse( true ),
155
    mRecurse( true ),
155
    mStatusChangedLocally( false ), mAnnotationFolderTypeChanged( false ),
156
    mStatusChangedLocally( false ), mAnnotationFolderTypeChanged( false ),
156
    mIncidencesForChanged( false ), mPersonalNamespacesCheckDone( true ),
157
    mIncidencesForChanged( false ), mPersonalNamespacesCheckDone( true ),
157
    mQuotaInfo()
158
    mQuotaInfo()
Lines 380-386 Link Here
380
{
381
{
381
  //kdDebug(5006) << "Reloading Uid Map " << endl;
382
  //kdDebug(5006) << "Reloading Uid Map " << endl;
382
  uidMap.clear();
383
  uidMap.clear();
383
  open();
384
  open("reloadUdi");
384
  for( int i = 0; i < count(); ++i ) {
385
  for( int i = 0; i < count(); ++i ) {
385
    KMMsgBase *msg = getMsgBase( i );
386
    KMMsgBase *msg = getMsgBase( i );
386
    if( !msg ) continue;
387
    if( !msg ) continue;
Lines 388-394 Link Here
388
    //kdDebug(5006) << "Inserting: " << i << " with uid: " << uid << endl;
389
    //kdDebug(5006) << "Inserting: " << i << " with uid: " << uid << endl;
389
    uidMap.insert( uid, i );
390
    uidMap.insert( uid, i );
390
  }
391
  }
391
  close();
392
  close("reloadUdi");
392
  uidMapDirty = false;
393
  uidMapDirty = false;
393
}
394
}
394
395
Lines 709-715 Link Here
709
    foldersForDeletionOnServer.clear();
710
    foldersForDeletionOnServer.clear();
710
    newState( mProgress, i18n("Synchronizing"));
711
    newState( mProgress, i18n("Synchronizing"));
711
712
712
    open();
713
    open("cachedimap");
713
    if ( !noContent() )
714
    if ( !noContent() )
714
        mAccount->addLastUnreadMsgCount( this, countUnread() );
715
        mAccount->addLastUnreadMsgCount( this, countUnread() );
715
716
Lines 720-726 Link Here
720
      // kdDebug(5006) << "makeConnection said Error, aborting." << endl;
721
      // kdDebug(5006) << "makeConnection said Error, aborting." << endl;
721
      // We stop here. We're already in SYNC_STATE_INITIAL for the next time.
722
      // We stop here. We're already in SYNC_STATE_INITIAL for the next time.
722
      newState( mProgress, i18n( "Error connecting to server %1" ).arg( mAccount->host() ) );
723
      newState( mProgress, i18n( "Error connecting to server %1" ).arg( mAccount->host() ) );
723
      close();
724
      close("cachedimap");
724
      emit folderComplete(this, false);
725
      emit folderComplete(this, false);
725
      break;
726
      break;
726
    } else if ( cs == ImapAccountBase::Connecting ) {
727
    } else if ( cs == ImapAccountBase::Connecting ) {
Lines 1135-1141 Link Here
1135
      if( mSubfoldersForSync.isEmpty() ) {
1136
      if( mSubfoldersForSync.isEmpty() ) {
1136
        mSyncState = SYNC_STATE_INITIAL;
1137
        mSyncState = SYNC_STATE_INITIAL;
1137
        mAccount->addUnreadMsgCount( this, countUnread() ); // before closing
1138
        mAccount->addUnreadMsgCount( this, countUnread() ); // before closing
1138
        close();
1139
        close("cachedimap");
1139
        emit folderComplete( this, true );
1140
        emit folderComplete( this, true );
1140
      } else {
1141
      } else {
1141
        mCurrentSubfolder = mSubfoldersForSync.front();
1142
        mCurrentSubfolder = mSubfoldersForSync.front();
Lines 1735-1741 Link Here
1735
        f->setImapPath( mAccount->addPathToNamespace( name ) );
1736
        f->setImapPath( mAccount->addPathToNamespace( name ) );
1736
        f->setNoContent( true );
1737
        f->setNoContent( true );
1737
        f->setAccount( mAccount );
1738
        f->setAccount( mAccount );
1738
        f->close();
1739
        f->close("cachedimap");
1739
        kmkernel->dimapFolderMgr()->contentsChanged();
1740
        kmkernel->dimapFolderMgr()->contentsChanged();
1740
      }
1741
      }
1741
    }
1742
    }
Lines 1869-1875 Link Here
1869
    }
1870
    }
1870
    if (!node) {
1871
    if (!node) {
1871
      if ( f )
1872
      if ( f )
1872
        f->close();
1873
        f->close("cachedimap");
1873
      kmkernel->dimapFolderMgr()->contentsChanged();
1874
      kmkernel->dimapFolderMgr()->contentsChanged();
1874
    }
1875
    }
1875
    // so we have an INBOX
1876
    // so we have an INBOX
Lines 1920-1926 Link Here
1920
          f = static_cast<KMFolderCachedImap*>(newFolder->storage());
1921
          f = static_cast<KMFolderCachedImap*>(newFolder->storage());
1921
        }
1922
        }
1922
        if (f) {
1923
        if (f) {
1923
          f->close();
1924
          f->close("cachedimap");
1924
          f->setAccount(mAccount);
1925
          f->setAccount(mAccount);
1925
          kmkernel->dimapFolderMgr()->contentsChanged();
1926
          kmkernel->dimapFolderMgr()->contentsChanged();
1926
          f->mAnnotationFolderType = "FROMSERVER";
1927
          f->mAnnotationFolderType = "FROMSERVER";
Lines 2001-2007 Link Here
2001
2002
2002
    mSubfoldersForSync.clear();
2003
    mSubfoldersForSync.clear();
2003
    mSyncState = SYNC_STATE_INITIAL;
2004
    mSyncState = SYNC_STATE_INITIAL;
2004
    close();
2005
    close("cachedimap");
2005
    emit folderComplete( this, false );
2006
    emit folderComplete( this, false );
2006
  }
2007
  }
2007
}
2008
}
Lines 2134-2140 Link Here
2134
  if ( mSyncState == SYNC_STATE_INITIAL ) return;
2135
  if ( mSyncState == SYNC_STATE_INITIAL ) return;
2135
  mSubfoldersForSync.clear();
2136
  mSubfoldersForSync.clear();
2136
  mSyncState = SYNC_STATE_INITIAL;
2137
  mSyncState = SYNC_STATE_INITIAL;
2137
  close();
2138
  close("cachedimap");
2138
  // Don't use newState here, it would revert to mProgress (which is < current value when listing messages)
2139
  // Don't use newState here, it would revert to mProgress (which is < current value when listing messages)
2139
  KPIM::ProgressItem *progressItem = mAccount->mailCheckProgressItem();
2140
  KPIM::ProgressItem *progressItem = mAccount->mailCheckProgressItem();
2140
  QString str = i18n("Aborted");
2141
  QString str = i18n("Aborted");
(-)kmail/kmfolder.cpp (-10 / +12 lines)
Lines 426-437 Link Here
426
426
427
int KMFolder::find( const KMMsgBase* msg ) const
427
int KMFolder::find( const KMMsgBase* msg ) const
428
{
428
{
429
  return mStorage->find( msg );
429
  return mStorage ? mStorage->find( msg ) : 0;
430
}
430
}
431
431
432
int KMFolder::find( const KMMessage* msg ) const
432
int KMFolder::find( const KMMessage* msg ) const
433
{
433
{
434
  return mStorage->find( msg );
434
  return mStorage ? mStorage->find( msg ) : 0;
435
}
435
}
436
436
437
int KMFolder::count( bool cache ) const
437
int KMFolder::count( bool cache ) const
Lines 468-476 Link Here
468
  mStorage->msgStatusChanged( oldStatus, newStatus, idx );
468
  mStorage->msgStatusChanged( oldStatus, newStatus, idx );
469
}
469
}
470
470
471
int KMFolder::open()
471
int KMFolder::open(const char *owner)
472
{
472
{
473
  return mStorage->open();
473
  return mStorage->open(owner);
474
}
474
}
475
475
476
int KMFolder::canAccess()
476
int KMFolder::canAccess()
Lines 478-486 Link Here
478
  return mStorage->canAccess();
478
  return mStorage->canAccess();
479
}
479
}
480
480
481
void KMFolder::close( bool force )
481
void KMFolder::close( const char *owner, bool force )
482
{
482
{
483
  mStorage->close( force );
483
  mStorage->close( owner, force );
484
}
484
}
485
485
486
void KMFolder::sync()
486
void KMFolder::sync()
Lines 631-641 Link Here
631
        mWhoField = "From";
631
        mWhoField = "From";
632
      if ( this == kmkernel->outboxFolder() ||
632
      if ( this == kmkernel->outboxFolder() ||
633
           this == kmkernel->sentFolder() ||
633
           this == kmkernel->sentFolder() ||
634
           this == kmkernel->draftsFolder() )
634
           this == kmkernel->draftsFolder() ||
635
           this == kmkernel->templatesFolder() )
635
        mWhoField = "To";
636
        mWhoField = "To";
636
    } else if ( identity.drafts() == idString()
637
    } else if ( identity.drafts() == idString() ||
637
                || identity.fcc() == idString() )
638
                identity.templates() == idString() ||
638
      // drafts or sent of the identity
639
                identity.fcc() == idString() )
640
      // drafts, templates or sent of the identity
639
      mWhoField = "To";
641
      mWhoField = "To";
640
    else
642
    else
641
      mWhoField = "From";
643
      mWhoField = "From";
(-)kmail/kmfolderdia.h (-5 / +3 lines)
Lines 55-61 Link Here
55
class KPushButton;
55
class KPushButton;
56
56
57
namespace KMail {
57
namespace KMail {
58
  class FolderRequester; 
58
  class FolderRequester;
59
/**
59
/**
60
 * This is the base class for tabs in the folder dialog.
60
 * This is the base class for tabs in the folder dialog.
61
 * It uses the API from ConfigModuleTab (basically: it's a widget that can load and save)
61
 * It uses the API from ConfigModuleTab (basically: it's a widget that can load and save)
Lines 161-176 Link Here
161
  Q_OBJECT
161
  Q_OBJECT
162
162
163
public:
163
public:
164
  FolderDiaTemplatesTab( KMFolderDialog* dlg,
164
  FolderDiaTemplatesTab( KMFolderDialog *dlg, QWidget *parent );
165
                       const QString& aName,
166
                       QWidget* parent, const char* name = 0 );
167
165
168
  virtual void load();
166
  virtual void load();
169
  virtual bool save();
167
  virtual bool save();
170
168
171
public slots:
169
public slots:
172
  void slotEmitChanged(); // do nothing for now
170
  void slotEmitChanged(); // do nothing for now
173
  
171
174
  void slotCopyGlobal();
172
  void slotCopyGlobal();
175
173
176
private:
174
private:
(-)kmail/kmfolderdia.cpp (-18 / +17 lines)
Lines 122-128 Link Here
122
  tab = new FolderDiaGeneralTab( this, aName, box );
122
  tab = new FolderDiaGeneralTab( this, aName, box );
123
  addTab( tab );
123
  addTab( tab );
124
  box = addVBoxPage( i18n("Templates") );
124
  box = addVBoxPage( i18n("Templates") );
125
  tab = new FolderDiaTemplatesTab( this, aName, box );
125
  tab = new FolderDiaTemplatesTab( this, box );
126
  addTab( tab );
126
  addTab( tab );
127
127
128
  KMFolder* refFolder = mFolder ? mFolder : mParentFolder;
128
  KMFolder* refFolder = mFolder ? mFolder : mParentFolder;
Lines 666-674 Link Here
666
666
667
//----------------------------------------------------------------------------
667
//----------------------------------------------------------------------------
668
KMail::FolderDiaTemplatesTab::FolderDiaTemplatesTab( KMFolderDialog* dlg,
668
KMail::FolderDiaTemplatesTab::FolderDiaTemplatesTab( KMFolderDialog* dlg,
669
                                                 const QString& aName,
669
                                                 QWidget* parent )
670
                                                 QWidget* parent, const char* name )
670
  : FolderDiaTab( parent, 0 ), mDlg( dlg )
671
  : FolderDiaTab( parent, name ), mDlg( dlg )
672
{
671
{
673
672
674
  mIsLocalSystemFolder = mDlg->folder()->isSystemFolder() &&
673
  mIsLocalSystemFolder = mDlg->folder()->isSystemFolder() &&
Lines 676-699 Link Here
676
       mDlg->folder()->folderType() != KMFolderTypeCachedImap;
675
       mDlg->folder()->folderType() != KMFolderTypeCachedImap;
677
676
678
  QVBoxLayout *topLayout = new QVBoxLayout( this, 0, KDialog::spacingHint() );
677
  QVBoxLayout *topLayout = new QVBoxLayout( this, 0, KDialog::spacingHint() );
679
  
678
680
  mCustom = new QCheckBox( i18n("&Use custom message templates"), this );
679
  mCustom = new QCheckBox( i18n("&Use custom message templates"), this );
681
  topLayout->addWidget( mCustom );
680
  topLayout->addWidget( mCustom );
682
  
681
683
  mWidget = new TemplatesConfiguration( this , "folder-templates" );
682
  mWidget = new TemplatesConfiguration( this , "folder-templates" );
684
  mWidget->setEnabled( false );
683
  mWidget->setEnabled( false );
685
  topLayout->addWidget( mWidget );
684
  topLayout->addWidget( mWidget );
686
  
685
687
  QHBoxLayout *btns = new QHBoxLayout( topLayout, KDialog::spacingHint() );
686
  QHBoxLayout *btns = new QHBoxLayout( topLayout, KDialog::spacingHint() );
688
  mCopyGlobal = new KPushButton( i18n("&Copy global templates"), this );
687
  mCopyGlobal = new KPushButton( i18n("&Copy global templates"), this );
689
  mCopyGlobal->setEnabled( false );
688
  mCopyGlobal->setEnabled( false );
690
  btns->addWidget( mCopyGlobal );
689
  btns->addWidget( mCopyGlobal );
691
  
690
692
  connect( mCustom, SIGNAL(toggled(bool)),
691
  connect( mCustom, SIGNAL(toggled(bool)),
693
        mWidget, SLOT(setEnabled(bool)) );
692
        mWidget, SLOT(setEnabled(bool)) );
694
  connect( mCustom, SIGNAL(toggled(bool)),
693
  connect( mCustom, SIGNAL(toggled(bool)),
695
        mCopyGlobal, SLOT(setEnabled(bool)) );
694
        mCopyGlobal, SLOT(setEnabled(bool)) );
696
  
695
697
  connect( mCopyGlobal, SIGNAL(clicked()),
696
  connect( mCopyGlobal, SIGNAL(clicked()),
698
        this, SLOT(slotCopyGlobal()) );
697
        this, SLOT(slotCopyGlobal()) );
699
698
Lines 705-727 Link Here
705
704
706
void FolderDiaTemplatesTab::load()
705
void FolderDiaTemplatesTab::load()
707
{
706
{
708
  
707
709
}
708
}
710
709
711
void FolderDiaTemplatesTab::initializeWithValuesFromFolder( KMFolder* folder ) {
710
void FolderDiaTemplatesTab::initializeWithValuesFromFolder( KMFolder* folder ) {
712
  if ( !folder )
711
  if ( !folder )
713
    return;
712
    return;
714
  
713
715
  mFolder = folder;
714
  mFolder = folder;
716
715
717
  QString fid = folder->idString();
716
  QString fid = folder->idString();
718
  
717
719
  Templates t( fid );
718
  Templates t( fid );
720
719
721
  mCustom->setChecked(t.useCustomTemplates());
720
  mCustom->setChecked(t.useCustomTemplates());
722
  
721
723
  mIdentity = folder->identity();
722
  mIdentity = folder->identity();
724
  
723
725
  mWidget->loadFromFolder( fid, mIdentity );
724
  mWidget->loadFromFolder( fid, mIdentity );
726
}
725
}
727
726
Lines 729-744 Link Here
729
bool FolderDiaTemplatesTab::save()
728
bool FolderDiaTemplatesTab::save()
730
{
729
{
731
  KMFolder* folder = mDlg->folder();
730
  KMFolder* folder = mDlg->folder();
732
  
731
733
  QString fid = folder->idString();
732
  QString fid = folder->idString();
734
  Templates t(fid);
733
  Templates t(fid);
735
  
734
736
  kdDebug() << "use custom templates for folder " << fid << ": " << mCustom->isChecked() << endl;
735
  kdDebug() << "use custom templates for folder " << fid << ": " << mCustom->isChecked() << endl;
737
  t.setUseCustomTemplates(mCustom->isChecked());
736
  t.setUseCustomTemplates(mCustom->isChecked());
738
  t.writeConfig();
737
  t.writeConfig();
739
  
738
740
  mWidget->saveToFolder(fid);
739
  mWidget->saveToFolder(fid);
741
  
740
742
  return true;
741
  return true;
743
}
742
}
744
743
(-)kmail/kmfolderimap.h (-6 / +6 lines)
Lines 131-136 Link Here
131
  /** Remove the IMAP folder on the server and if successful also locally */
131
  /** Remove the IMAP folder on the server and if successful also locally */
132
  virtual void remove();
132
  virtual void remove();
133
133
134
  /** Close folder. If force is TRUE the files are closed even if
135
    others still use it (e.g. other mail reader windows). This also
136
    cancels all pending jobs. */
137
  virtual void close(const char *owner, bool force=FALSE);
138
134
  /** Automatically expunge deleted messages when leaving the folder */
139
  /** Automatically expunge deleted messages when leaving the folder */
135
  bool autoExpunge();
140
  bool autoExpunge();
136
141
Lines 277-287 Link Here
277
  /** imap folders cannot expire */
282
  /** imap folders cannot expire */
278
  virtual bool isAutoExpire() const { return false; }
283
  virtual bool isAutoExpire() const { return false; }
279
284
280
  /** Close folder. If force is TRUE the files are closed even if
281
    others still use it (e.g. other mail reader windows). This also
282
    cancels all pending jobs. */
283
  virtual void close(bool force=FALSE);
284
285
  void setCheckingValidity( bool val ) { mCheckingValidity = val; }
285
  void setCheckingValidity( bool val ) { mCheckingValidity = val; }
286
286
287
  /** Return the trash folder. */
287
  /** Return the trash folder. */
Lines 423-429 Link Here
423
  /** See if all folders are still present on server, otherwise delete them */
423
  /** See if all folders are still present on server, otherwise delete them */
424
  void checkFolders( const QStringList& folderNames, const QString& ns );
424
  void checkFolders( const QStringList& folderNames, const QString& ns );
425
425
426
  void finishMailCheck( imapState state );
426
  void finishMailCheck( const char *func, imapState state );
427
427
428
protected slots:
428
protected slots:
429
429
(-)kmail/kmfolderimap.cpp (-27 / +54 lines)
Lines 106-121 Link Here
106
106
107
107
108
//-----------------------------------------------------------------------------
108
//-----------------------------------------------------------------------------
109
void KMFolderImap::close(bool aForced)
109
void KMFolderImap::close(const char *owner, bool aForced)
110
{
110
{
111
  if (mOpenCount <= 0 ) return;
112
  if (mOpenCount > 0) mOpenCount--;
111
  if (mOpenCount > 0) mOpenCount--;
113
  if (mOpenCount > 0 && !aForced) return;
112
  if (mOpenCount == 0 && isSelected() && !aForced) {
114
  if (isSelected() && !aForced) {
115
      kdWarning(5006) << "Trying to close the selected folder " << label() <<
113
      kdWarning(5006) << "Trying to close the selected folder " << label() <<
116
          " - ignoring!" << endl;
114
        " - ignoring! " << kdBacktrace() << endl;
115
      mOpenCount++;
117
      return;
116
      return;
118
  }
117
  }
118
  if (mOpenCount > 0 && !aForced) {
119
    // The inherited close will decrement again, so we have to adjust.
120
    mOpenCount++;
121
    KMFolderMbox::close(owner, aForced);
122
    return;
123
  }
124
119
  // FIXME is this still needed?
125
  // FIXME is this still needed?
120
  if (mAccount)
126
  if (mAccount)
121
    mAccount->ignoreJobsForFolder( folder() );
127
    mAccount->ignoreJobsForFolder( folder() );
Lines 127-135 Link Here
127
          msg->setTransferInProgress( false );
133
          msg->setTransferInProgress( false );
128
    }
134
    }
129
  }
135
  }
136
137
  mCheckingValidity = false;
138
130
  // The inherited close will decrement again, so we have to adjust.
139
  // The inherited close will decrement again, so we have to adjust.
131
  mOpenCount++;
140
  mOpenCount++;
132
  KMFolderMbox::close(aForced);
141
  KMFolderMbox::close(owner, aForced);
133
}
142
}
134
143
135
KMFolder* KMFolderImap::trashFolder() const
144
KMFolder* KMFolderImap::trashFolder() const
Lines 694-700 Link Here
694
        KMFolderImap* f = static_cast<KMFolderImap*> ( fld->storage() );
700
        KMFolderImap* f = static_cast<KMFolderImap*> ( fld->storage() );
695
        f->initializeFrom( this, mAccount->addPathToNamespace( name ),
701
        f->initializeFrom( this, mAccount->addPathToNamespace( name ),
696
            "inode/directory" );
702
            "inode/directory" );
697
        f->close();
698
        if ( !mAccount->listOnlyOpenFolders() )
703
        if ( !mAccount->listOnlyOpenFolders() )
699
        {
704
        {
700
          f->slotListResult( subfolderNames, subfolderPaths,
705
          f->slotListResult( subfolderNames, subfolderPaths,
Lines 810-816 Link Here
810
      KMFolder *fld = folder()->child()->createFolder(subfolderNames[i]);
815
      KMFolder *fld = folder()->child()->createFolder(subfolderNames[i]);
811
      if ( fld ) {
816
      if ( fld ) {
812
        f = static_cast<KMFolderImap*> ( fld->storage() );
817
        f = static_cast<KMFolderImap*> ( fld->storage() );
813
        f->close();
814
        settingsChanged = true;
818
        settingsChanged = true;
815
      } else {
819
      } else {
816
        kdWarning(5006) << "can't create folder " << subfolderNames[i] << endl;
820
        kdWarning(5006) << "can't create folder " << subfolderNames[i] << endl;
Lines 875-881 Link Here
875
    if ( f )
879
    if ( f )
876
    {
880
    {
877
      f->folder()->setLabel( i18n("inbox") );
881
      f->folder()->setLabel( i18n("inbox") );
878
      f->close();
879
    }
882
    }
880
    kmkernel->imapFolderMgr()->contentsChanged();
883
    kmkernel->imapFolderMgr()->contentsChanged();
881
  }
884
  }
Lines 919-924 Link Here
919
    const QString& myNamespace )
922
    const QString& myNamespace )
920
{
923
{
921
  QPtrList<KMFolder> toRemove;
924
  QPtrList<KMFolder> toRemove;
925
  if (!folder()->child())
926
    return;
927
922
  KMFolderNode *node = folder()->child()->first();
928
  KMFolderNode *node = folder()->child()->first();
923
  while ( node )
929
  while ( node )
924
  {
930
  {
Lines 995-1001 Link Here
995
{
1001
{
996
  if (!mAccount) {
1002
  if (!mAccount) {
997
    emit folderComplete(this, false);
1003
    emit folderComplete(this, false);
998
    close();
999
    return;
1004
    return;
1000
  }
1005
  }
1001
  KURL url = mAccount->getUrl();
1006
  KURL url = mAccount->getUrl();
Lines 1011-1017 Link Here
1011
    kdDebug(5006) << "KMFolderImap::checkValidity - got no connection" << endl;
1016
    kdDebug(5006) << "KMFolderImap::checkValidity - got no connection" << endl;
1012
    emit folderComplete(this, FALSE);
1017
    emit folderComplete(this, FALSE);
1013
    mContentState = imapNoInformation;
1018
    mContentState = imapNoInformation;
1014
    close();
1015
    return;
1019
    return;
1016
  } else if ( connectionState == ImapAccountBase::Connecting ) {
1020
  } else if ( connectionState == ImapAccountBase::Connecting ) {
1017
    // We'll wait for the connectionResult signal from the account. If it
1021
    // We'll wait for the connectionResult signal from the account. If it
Lines 1024-1030 Link Here
1024
  // Only check once at a time.
1028
  // Only check once at a time.
1025
  if (mCheckingValidity) {
1029
  if (mCheckingValidity) {
1026
    kdDebug(5006) << "KMFolderImap::checkValidity - already checking" << endl;
1030
    kdDebug(5006) << "KMFolderImap::checkValidity - already checking" << endl;
1027
    close();
1028
    return;
1031
    return;
1029
  }
1032
  }
1030
  // otherwise we already are inside a mailcheck
1033
  // otherwise we already are inside a mailcheck
Lines 1044-1049 Link Here
1044
  if ( account()->mailCheckProgressItem() ) {
1047
  if ( account()->mailCheckProgressItem() ) {
1045
    account()->mailCheckProgressItem()->setStatus( folder()->prettyURL() );
1048
    account()->mailCheckProgressItem()->setStatus( folder()->prettyURL() );
1046
  }
1049
  }
1050
  open( "checkvalidity" );
1047
  ImapAccountBase::jobData jd( url.url() );
1051
  ImapAccountBase::jobData jd( url.url() );
1048
  KIO::SimpleJob *job = KIO::get(url, FALSE, FALSE);
1052
  KIO::SimpleJob *job = KIO::get(url, FALSE, FALSE);
1049
  KIO::Scheduler::assignJobToSlave(mAccount->slave(), job);
1053
  KIO::Scheduler::assignJobToSlave(mAccount->slave(), job);
Lines 1062-1074 Link Here
1062
{
1066
{
1063
  if ( mLastUid > 0 )
1067
  if ( mLastUid > 0 )
1064
      return mLastUid;
1068
      return mLastUid;
1065
  open();
1069
  open("lastuid");
1066
  if (count() > 0)
1070
  if (count() > 0)
1067
  {
1071
  {
1068
    KMMsgBase * base = getMsgBase(count()-1);
1072
    KMMsgBase * base = getMsgBase(count()-1);
1069
    mLastUid = base->UID();
1073
    mLastUid = base->UID();
1070
  }
1074
  }
1071
  close();
1075
  close("lastuid");
1072
  return mLastUid;
1076
  return mLastUid;
1073
}
1077
}
1074
1078
Lines 1076-1087 Link Here
1076
//-----------------------------------------------------------------------------
1080
//-----------------------------------------------------------------------------
1077
void KMFolderImap::slotCheckValidityResult(KIO::Job * job)
1081
void KMFolderImap::slotCheckValidityResult(KIO::Job * job)
1078
{
1082
{
1083
  // if we closed the folder in between, we don't want this results
1084
  if (!mCheckingValidity)
1085
    return;
1086
1079
  kdDebug(5006) << "KMFolderImap::slotCheckValidityResult of: " << fileName() << endl;
1087
  kdDebug(5006) << "KMFolderImap::slotCheckValidityResult of: " << fileName() << endl;
1080
  mCheckingValidity = false;
1088
  mCheckingValidity = false;
1081
  ImapAccountBase::JobIterator it = mAccount->findJob(job);
1089
  ImapAccountBase::JobIterator it = mAccount->findJob(job);
1082
  if ( it == mAccount->jobsEnd() ) return;
1090
  if ( it == mAccount->jobsEnd() )
1083
  if (job->error()) {
1091
  {
1084
    if ( job->error() != KIO::ERR_ACCESS_DENIED ) {
1092
    // the job has been killed internally, so we're not interested in its results
1093
    job = 0;
1094
  }
1095
  if (!job || job->error()) {
1096
    if ( job && job->error() != KIO::ERR_ACCESS_DENIED ) {
1085
      // we suppress access denied messages because they are normally a result of
1097
      // we suppress access denied messages because they are normally a result of
1086
      // explicitely set ACLs. Do not save this information (e.g. setNoContent) so that
1098
      // explicitely set ACLs. Do not save this information (e.g. setNoContent) so that
1087
      // we notice when this changes
1099
      // we notice when this changes
Lines 1089-1095 Link Here
1089
    }
1097
    }
1090
    mContentState = imapNoInformation;
1098
    mContentState = imapNoInformation;
1091
    emit folderComplete(this, FALSE);
1099
    emit folderComplete(this, FALSE);
1092
    close();
1100
    close("checkvalidity");
1093
  } else {
1101
  } else {
1094
    QCString cstr((*it).data.data(), (*it).data.size() + 1);
1102
    QCString cstr((*it).data.data(), (*it).data.size() + 1);
1095
    int a = cstr.find("X-uidValidity: ");
1103
    int a = cstr.find("X-uidValidity: ");
Lines 1143-1148 Link Here
1143
      mMailCheckProgressItem->setCompletedItems( 0 );
1151
      mMailCheckProgressItem->setCompletedItems( 0 );
1144
    }
1152
    }
1145
    reallyGetFolder(startUid);
1153
    reallyGetFolder(startUid);
1154
    close("checkvalidity");
1146
  }
1155
  }
1147
}
1156
}
1148
1157
Lines 1170-1182 Link Here
1170
    emit folderComplete(this, true);
1179
    emit folderComplete(this, true);
1171
    return;
1180
    return;
1172
  }
1181
  }
1173
  open();
1182
  open("getfolder");
1174
  mContentState = imapListingInProgress;
1183
  mContentState = imapListingInProgress;
1175
  if (force) {
1184
  if (force) {
1176
    // force an update
1185
    // force an update
1177
    mCheckFlags = TRUE;
1186
    mCheckFlags = TRUE;
1178
  }
1187
  }
1179
  checkValidity();
1188
  checkValidity();
1189
  close( "getfolder" );
1180
}
1190
}
1181
1191
1182
1192
Lines 1188-1194 Link Here
1188
  {
1198
  {
1189
    mContentState = imapNoInformation;
1199
    mContentState = imapNoInformation;
1190
    emit folderComplete(this, FALSE);
1200
    emit folderComplete(this, FALSE);
1191
    close();
1192
    return;
1201
    return;
1193
  }
1202
  }
1194
  quiet(true);
1203
  quiet(true);
Lines 1198-1203 Link Here
1198
      mMailCheckProgressItem->setStatus( i18n("Retrieving message status") );
1207
      mMailCheckProgressItem->setStatus( i18n("Retrieving message status") );
1199
    url.setPath(imapPath() + ";SECTION=UID FLAGS");
1208
    url.setPath(imapPath() + ";SECTION=UID FLAGS");
1200
    KIO::SimpleJob *job = KIO::listDir(url, FALSE);
1209
    KIO::SimpleJob *job = KIO::listDir(url, FALSE);
1210
    open( "listfolder" );
1201
    KIO::Scheduler::assignJobToSlave(mAccount->slave(), job);
1211
    KIO::Scheduler::assignJobToSlave(mAccount->slave(), job);
1202
    ImapAccountBase::jobData jd( url.url(), folder() );
1212
    ImapAccountBase::jobData jd( url.url(), folder() );
1203
    jd.cancellable = true;
1213
    jd.cancellable = true;
Lines 1217-1222 Link Here
1217
    KIO::Scheduler::assignJobToSlave(mAccount->slave(), newJob);
1227
    KIO::Scheduler::assignJobToSlave(mAccount->slave(), newJob);
1218
    ImapAccountBase::jobData jd( url.url(), folder() );
1228
    ImapAccountBase::jobData jd( url.url(), folder() );
1219
    jd.cancellable = true;
1229
    jd.cancellable = true;
1230
    open( "getMessage" );
1220
    mAccount->insertJob(newJob, jd);
1231
    mAccount->insertJob(newJob, jd);
1221
    connect(newJob, SIGNAL(result(KIO::Job *)),
1232
    connect(newJob, SIGNAL(result(KIO::Job *)),
1222
            this, SLOT(slotGetLastMessagesResult(KIO::Job *)));
1233
            this, SLOT(slotGetLastMessagesResult(KIO::Job *)));
Lines 1237-1243 Link Here
1237
    mAccount->handleJobError( job,
1248
    mAccount->handleJobError( job,
1238
         i18n("Error while listing the contents of the folder %1.").arg( label() ) );
1249
         i18n("Error while listing the contents of the folder %1.").arg( label() ) );
1239
    mAccount->removeJob(it);
1250
    mAccount->removeJob(it);
1240
    finishMailCheck( imapNoInformation );
1251
    finishMailCheck( "listfolder", imapNoInformation );
1241
    return;
1252
    return;
1242
  }
1253
  }
1243
  mCheckFlags = FALSE;
1254
  mCheckFlags = FALSE;
Lines 1290-1296 Link Here
1290
  jd.total = (*it).items.count();
1301
  jd.total = (*it).items.count();
1291
  if (jd.total == 0)
1302
  if (jd.total == 0)
1292
  {
1303
  {
1293
    finishMailCheck( imapFinished );
1304
    finishMailCheck( "listfolder", imapFinished );
1294
    mAccount->removeJob(it);
1305
    mAccount->removeJob(it);
1295
    return;
1306
    return;
1296
  }
1307
  }
Lines 1309-1314 Link Here
1309
  else sets = makeSets( (*it).items );
1320
  else sets = makeSets( (*it).items );
1310
  mAccount->removeJob(it); // don't use *it below
1321
  mAccount->removeJob(it); // don't use *it below
1311
1322
1323
  if ( !sets.isEmpty() )
1324
    open( "getMessage" );
1325
1326
  close( "listfolder" );
1327
1312
  // Now kick off the getting of envelopes for the new mails in the folder
1328
  // Now kick off the getting of envelopes for the new mails in the folder
1313
  for (QStringList::Iterator i = sets.begin(); i != sets.end(); ++i)
1329
  for (QStringList::Iterator i = sets.begin(); i != sets.end(); ++i)
1314
  {
1330
  {
Lines 1475-1481 Link Here
1475
      if ( ok && exists < count() ) {
1491
      if ( ok && exists < count() ) {
1476
        kdDebug(5006) << "KMFolderImap::slotGetMessagesData - server has less messages (" <<
1492
        kdDebug(5006) << "KMFolderImap::slotGetMessagesData - server has less messages (" <<
1477
          exists << ") then folder (" << count() << "), so reload" << endl;
1493
          exists << ") then folder (" << count() << "), so reload" << endl;
1478
        open();
1494
        open("getMessage");
1479
        reallyGetFolder( QString::null );
1495
        reallyGetFolder( QString::null );
1480
        (*it).cdata.remove(0, pos);
1496
        (*it).cdata.remove(0, pos);
1481
        return;
1497
        return;
Lines 1488-1493 Link Here
1488
    }
1504
    }
1489
    (*it).cdata.remove(0, pos);
1505
    (*it).cdata.remove(0, pos);
1490
  }
1506
  }
1507
  open("digestsplit");
1491
  pos = (*it).cdata.find("\r\n--IMAPDIGEST", 1);
1508
  pos = (*it).cdata.find("\r\n--IMAPDIGEST", 1);
1492
  int flags;
1509
  int flags;
1493
  while (pos >= 0)
1510
  while (pos >= 0)
Lines 1569-1574 Link Here
1569
    (*it).done++;
1586
    (*it).done++;
1570
    pos = (*it).cdata.find("\r\n--IMAPDIGEST", 1);
1587
    pos = (*it).cdata.find("\r\n--IMAPDIGEST", 1);
1571
  } // while
1588
  } // while
1589
  close("digestsplit");
1572
}
1590
}
1573
1591
1574
//-------------------------------------------------------------
1592
//-------------------------------------------------------------
Lines 1623-1633 Link Here
1623
  if ( it == mAccount->jobsEnd() ) return;
1641
  if ( it == mAccount->jobsEnd() ) return;
1624
  if (job->error()) {
1642
  if (job->error()) {
1625
    mAccount->handleJobError( job, i18n("Error while retrieving messages.") );
1643
    mAccount->handleJobError( job, i18n("Error while retrieving messages.") );
1626
    finishMailCheck( imapNoInformation );
1644
    finishMailCheck( "getMessage", imapNoInformation );
1627
    return;
1645
    return;
1628
  }
1646
  }
1629
  if (lastSet) {
1647
  if (lastSet) {
1630
    finishMailCheck( imapFinished );
1648
    finishMailCheck( "getMessage", imapFinished );
1631
    mAccount->removeJob(it);
1649
    mAccount->removeJob(it);
1632
  }
1650
  }
1633
}
1651
}
Lines 1811-1816 Link Here
1811
1829
1812
void KMFolderImap::setStatus(QValueList<int>& ids, KMMsgStatus status, bool toggle)
1830
void KMFolderImap::setStatus(QValueList<int>& ids, KMMsgStatus status, bool toggle)
1813
{
1831
{
1832
  open( "setstatus" );
1814
  FolderStorage::setStatus(ids, status, toggle);
1833
  FolderStorage::setStatus(ids, status, toggle);
1815
  if (mReadOnly) return;
1834
  if (mReadOnly) return;
1816
1835
Lines 1854-1859 Link Here
1854
    quiet( false );
1873
    quiet( false );
1855
    reallyGetFolder( QString::null );
1874
    reallyGetFolder( QString::null );
1856
  }
1875
  }
1876
  close( "setstatus" );
1857
}
1877
}
1858
1878
1859
//-----------------------------------------------------------------------------
1879
//-----------------------------------------------------------------------------
Lines 2306-2317 Link Here
2306
  }
2326
  }
2307
}
2327
}
2308
2328
2309
void KMFolderImap::finishMailCheck( imapState state )
2329
void KMFolderImap::finishMailCheck( const char *dbg, imapState state )
2310
{
2330
{
2311
  quiet( false );
2331
  quiet( false );
2312
  mContentState = state;
2332
  mContentState = state;
2313
  emit folderComplete( this, mContentState == imapFinished );
2333
  emit folderComplete( this, mContentState == imapFinished );
2314
  close();
2334
  close(dbg);
2315
}
2335
}
2316
2336
2317
#include "kmfolderimap.moc"
2337
#include "kmfolderimap.moc"
(-)kmail/kmfolderindex.cpp (-2 / +2 lines)
Lines 463-473 Link Here
463
463
464
void KMFolderIndex::fillMessageDict()
464
void KMFolderIndex::fillMessageDict()
465
{
465
{
466
  open();
466
  open("fillDict");
467
  for (unsigned int idx = 0; idx < mMsgList.high(); idx++)
467
  for (unsigned int idx = 0; idx < mMsgList.high(); idx++)
468
    if ( mMsgList.at( idx ) )
468
    if ( mMsgList.at( idx ) )
469
      KMMsgDict::mutableInstance()->insert(0, mMsgList.at( idx ), idx);
469
      KMMsgDict::mutableInstance()->insert(0, mMsgList.at( idx ), idx);
470
  close();
470
  close("fillDict");
471
}
471
}
472
472
473
473
(-)kmail/kmfoldermaildir.cpp (-9 / +8 lines)
Lines 28-34 Link Here
28
#include <kstaticdeleter.h>
28
#include <kstaticdeleter.h>
29
#include <kmessagebox.h>
29
#include <kmessagebox.h>
30
30
31
#include <ctype.h>
32
#include <dirent.h>
31
#include <dirent.h>
33
#include <errno.h>
32
#include <errno.h>
34
#include <stdlib.h>
33
#include <stdlib.h>
Lines 59-65 Link Here
59
//-----------------------------------------------------------------------------
58
//-----------------------------------------------------------------------------
60
KMFolderMaildir::~KMFolderMaildir()
59
KMFolderMaildir::~KMFolderMaildir()
61
{
60
{
62
  if (mOpenCount>0) close(true);
61
  if (mOpenCount>0) close("~foldermaildir", true);
63
  if (kmkernel->undoStack()) kmkernel->undoStack()->folderDestroyed( folder() );
62
  if (kmkernel->undoStack()) kmkernel->undoStack()->folderDestroyed( folder() );
64
}
63
}
65
64
Lines 97-103 Link Here
97
}
96
}
98
97
99
//-----------------------------------------------------------------------------
98
//-----------------------------------------------------------------------------
100
int KMFolderMaildir::open()
99
int KMFolderMaildir::open(const char *)
101
{
100
{
102
  int rc = 0;
101
  int rc = 0;
103
102
Lines 220-226 Link Here
220
219
221
220
222
//-----------------------------------------------------------------------------
221
//-----------------------------------------------------------------------------
223
void KMFolderMaildir::close(bool aForced)
222
void KMFolderMaildir::close(const char *, bool aForced)
224
{
223
{
225
  if (mOpenCount <= 0) return;
224
  if (mOpenCount <= 0) return;
226
  if (mOpenCount > 0) mOpenCount--;
225
  if (mOpenCount > 0) mOpenCount--;
Lines 406-412 Link Here
406
  if ( !uidHeader.isEmpty() && stripUid )
405
  if ( !uidHeader.isEmpty() && stripUid )
407
    aMsg->removeHeaderField( "X-UID" );
406
    aMsg->removeHeaderField( "X-UID" );
408
407
409
  msgText = aMsg->asString();
408
  msgText = aMsg->asString(); // TODO use asDwString instead
410
  len = msgText.length();
409
  len = msgText.length();
411
410
412
  // Re-add the uid so that the take can make use of it, in case the
411
  // Re-add the uid so that the take can make use of it, in case the
Lines 435-441 Link Here
435
  if (!isOpened())
434
  if (!isOpened())
436
  {
435
  {
437
    opened = true;
436
    opened = true;
438
    rc = open();
437
    rc = open("maildir");
439
    kdDebug(5006) << "KMFolderMaildir::addMsg-open: " << rc << " of folder: " << label() << endl;
438
    kdDebug(5006) << "KMFolderMaildir::addMsg-open: " << rc << " of folder: " << label() << endl;
440
    if (rc) return rc;
439
    if (rc) return rc;
441
  }
440
  }
Lines 446-452 Link Here
446
  if (moveInternal(tmp_file, new_loc, filename, aMsg->status()).isNull())
445
  if (moveInternal(tmp_file, new_loc, filename, aMsg->status()).isNull())
447
  {
446
  {
448
    file.remove();
447
    file.remove();
449
    if (opened) close();
448
    if (opened) close("maildir");
450
    return -1;
449
    return -1;
451
  }
450
  }
452
451
Lines 544-550 Link Here
544
  emitMsgAddedSignals(idx);
543
  emitMsgAddedSignals(idx);
545
  needsCompact = true;
544
  needsCompact = true;
546
545
547
  if (opened) close();
546
  if (opened) close("maildir" );
548
/*
547
/*
549
QFile fileD1( "testdat_xx-kmfoldermaildir-1" );
548
QFile fileD1( "testdat_xx-kmfoldermaildir-1" );
550
if( fileD1.open( IO_WriteOnly ) ) {
549
if( fileD1.open( IO_WriteOnly ) ) {
Lines 734-740 Link Here
734
        int cidx = contentTypeStr.find( "charset=" );
733
        int cidx = contentTypeStr.find( "charset=" );
735
        if ( cidx != -1 ) {
734
        if ( cidx != -1 ) {
736
          charset = contentTypeStr.mid( cidx + 8 );
735
          charset = contentTypeStr.mid( cidx + 8 );
737
          if ( charset[0] == '"' ) {
736
          if ( !charset.isEmpty() && ( charset[0] == '"' ) ) {
738
            charset = charset.mid( 1 );
737
            charset = charset.mid( 1 );
739
          }
738
          }
740
          cidx = 0;
739
          cidx = 0;
(-)kmail/kmfoldermaildir.h (-2 / +2 lines)
Lines 60-66 Link Here
60
    call close() first.
60
    call close() first.
61
    Returns zero on success and an error code equal to the c-library
61
    Returns zero on success and an error code equal to the c-library
62
    fopen call otherwise (errno). */
62
    fopen call otherwise (errno). */
63
  virtual int open();
63
  virtual int open(const char *owner);
64
64
65
  virtual int canAccess();
65
  virtual int canAccess();
66
66
Lines 69-75 Link Here
69
69
70
  /** Close folder. If force is TRUE the files are closed even if
70
  /** Close folder. If force is TRUE the files are closed even if
71
    others still use it (e.g. other mail reader windows). */
71
    others still use it (e.g. other mail reader windows). */
72
  virtual void close(bool force=FALSE);
72
  virtual void close(const char *owner, bool force=FALSE);
73
73
74
  /** Create the necessary folders for a maildir folder. Usually you will
74
  /** Create the necessary folders for a maildir folder. Usually you will
75
      want to use create() instead.
75
      want to use create() instead.
(-)kmail/kmfoldermbox.cpp (-18 / +25 lines)
Lines 84-102 Link Here
84
//-----------------------------------------------------------------------------
84
//-----------------------------------------------------------------------------
85
KMFolderMbox::~KMFolderMbox()
85
KMFolderMbox::~KMFolderMbox()
86
{
86
{
87
  if (mOpenCount>0) close(true);
87
  if (mOpenCount>0) close("~kmfoldermbox", true);
88
  if (kmkernel->undoStack()) kmkernel->undoStack()->folderDestroyed( folder() );
88
  if (kmkernel->undoStack()) kmkernel->undoStack()->folderDestroyed( folder() );
89
}
89
}
90
90
91
//-----------------------------------------------------------------------------
91
//-----------------------------------------------------------------------------
92
int KMFolderMbox::open()
92
int KMFolderMbox::open(const char *owner)
93
{
93
{
94
  int rc = 0;
94
  int rc = 0;
95
95
96
  mOpenCount++;
96
  mOpenCount++;
97
  kmkernel->jobScheduler()->notifyOpeningFolder( folder() );
97
  kmkernel->jobScheduler()->notifyOpeningFolder( folder() );
98
98
99
  if (mOpenCount > 1) return 0;  // already open
99
  if (mOpenCount > 1) {
100
     assert(mStream);
101
     return 0;  // already open
102
  }
100
103
101
  assert(!folder()->name().isEmpty());
104
  assert(!folder()->name().isEmpty());
102
105
Lines 253-263 Link Here
253
256
254
257
255
//-----------------------------------------------------------------------------
258
//-----------------------------------------------------------------------------
256
void KMFolderMbox::close(bool aForced)
259
void KMFolderMbox::close(const char *owner, bool aForced)
257
{
260
{
258
  if (mOpenCount <= 0 || !mStream) return;
261
  if (!aForced)
262
     assert(mOpenCount >= 0);
263
264
  if (mOpenCount <= 0 || !mStream) { mOpenCount = 0; return; }
259
  if (mOpenCount > 0) mOpenCount--;
265
  if (mOpenCount > 0) mOpenCount--;
260
  if (mOpenCount > 0 && !aForced) return;
266
  if (mOpenCount > 0 && !aForced) { assert(mStream); return; }
267
  
261
#if 0 // removed hack that prevented closing system folders (see kmail-devel discussion about mail expiring)
268
#if 0 // removed hack that prevented closing system folders (see kmail-devel discussion about mail expiring)
262
  if ( (folder() != kmkernel->inboxFolder())
269
  if ( (folder() != kmkernel->inboxFolder())
263
        && folder()->isSystemFolder() && !aForced )
270
        && folder()->isSystemFolder() && !aForced )
Lines 870-881 Link Here
870
}
877
}
871
878
872
//static
879
//static
873
QCString KMFolderMbox::escapeFrom( const QCString & str ) {
880
QByteArray KMFolderMbox::escapeFrom( const DwString & str ) {
874
  const unsigned int strLen = str.length();
881
  const unsigned int strLen = str.length();
875
  if ( strLen <= STRDIM("From ") )
882
  if ( strLen <= STRDIM("From ") )
876
    return str;
883
    return KMail::Util::ByteArray( str );
877
  // worst case: \nFrom_\nFrom_\nFrom_... => grows to 7/6
884
  // worst case: \nFrom_\nFrom_\nFrom_... => grows to 7/6
878
  QCString result( int( strLen + 5 ) / 6 * 7 + 1 );
885
  QByteArray result( int( strLen + 5 ) / 6 * 7 + 1 );
879
886
880
  const char * s = str.data();
887
  const char * s = str.data();
881
  const char * const e = s + strLen - STRDIM("From ");
888
  const char * const e = s + strLen - STRDIM("From ");
Lines 961-967 Link Here
961
{
968
{
962
  if (!canAddMsgNow(aMsg, aIndex_ret)) return 0;
969
  if (!canAddMsgNow(aMsg, aIndex_ret)) return 0;
963
  bool opened = false;
970
  bool opened = false;
964
  QCString msgText;
971
  QByteArray msgText;
965
  char endStr[3];
972
  char endStr[3];
966
  int idx = -1, rc;
973
  int idx = -1, rc;
967
  KMFolder* msgParent;
974
  KMFolder* msgParent;
Lines 971-977 Link Here
971
  if (!mStream)
978
  if (!mStream)
972
  {
979
  {
973
    opened = true;
980
    opened = true;
974
    rc = open();
981
    rc = open("mboxaddMsg");
975
    kdDebug(5006) << "KMFolderMBox::addMsg-open: " << rc << " of folder: " << label() << endl;
982
    kdDebug(5006) << "KMFolderMBox::addMsg-open: " << rc << " of folder: " << label() << endl;
976
    if (rc) return rc;
983
    if (rc) return rc;
977
  }
984
  }
Lines 1018-1032 Link Here
1018
    if (aMsg->headerField("Content-Type").isEmpty())  // This might be added by
1025
    if (aMsg->headerField("Content-Type").isEmpty())  // This might be added by
1019
      aMsg->removeHeaderField("Content-Type");        // the line above
1026
      aMsg->removeHeaderField("Content-Type");        // the line above
1020
  }
1027
  }
1021
  msgText = escapeFrom( aMsg->asString() );
1028
  msgText = escapeFrom( aMsg->asDwString() );
1022
  size_t len = msgText.length();
1029
  size_t len = msgText.size();
1023
1030
1024
  assert(mStream != 0);
1031
  assert(mStream != 0);
1025
  clearerr(mStream);
1032
  clearerr(mStream);
1026
  if (len <= 0)
1033
  if (len <= 0)
1027
  {
1034
  {
1028
    kdDebug(5006) << "Message added to folder `" << name() << "' contains no data. Ignoring it." << endl;
1035
    kdDebug(5006) << "Message added to folder `" << name() << "' contains no data. Ignoring it." << endl;
1029
    if (opened) close();
1036
    if (opened) close("mboxaddMsg");
1030
    return 0;
1037
    return 0;
1031
  }
1038
  }
1032
1039
Lines 1052-1065 Link Here
1052
  int error = ferror(mStream);
1059
  int error = ferror(mStream);
1053
  if (error)
1060
  if (error)
1054
  {
1061
  {
1055
    if (opened) close();
1062
    if (opened) close("mboxaddMsg");
1056
    return error;
1063
    return error;
1057
  }
1064
  }
1058
1065
1059
  QCString messageSeparator( aMsg->mboxMessageSeparator() );
1066
  QCString messageSeparator( aMsg->mboxMessageSeparator() );
1060
  fwrite( messageSeparator.data(), messageSeparator.length(), 1, mStream );
1067
  fwrite( messageSeparator.data(), messageSeparator.length(), 1, mStream );
1061
  off_t offs = ftell(mStream);
1068
  off_t offs = ftell(mStream);
1062
  fwrite(msgText, len, 1, mStream);
1069
  fwrite(msgText.data(), len, 1, mStream);
1063
  if (msgText[(int)len-1]!='\n') fwrite("\n\n", 1, 2, mStream);
1070
  if (msgText[(int)len-1]!='\n') fwrite("\n\n", 1, 2, mStream);
1064
  fflush(mStream);
1071
  fflush(mStream);
1065
  size_t size = ftell(mStream) - offs;
1072
  size_t size = ftell(mStream) - offs;
Lines 1173-1179 Link Here
1173
  // some "paper work"
1180
  // some "paper work"
1174
  if (aIndex_ret) *aIndex_ret = idx;
1181
  if (aIndex_ret) *aIndex_ret = idx;
1175
  emitMsgAddedSignals(idx);
1182
  emitMsgAddedSignals(idx);
1176
  if (opened) close();
1183
  if (opened) close("mboxaddMsg");
1177
1184
1178
  // All streams have been flushed without errors if we arrive here
1185
  // All streams have been flushed without errors if we arrive here
1179
  // Return success!
1186
  // Return success!
Lines 1270-1276 Link Here
1270
1277
1271
  if (openCount > 0)
1278
  if (openCount > 0)
1272
  {
1279
  {
1273
    open();
1280
    open("mboxcompact");
1274
    mOpenCount = openCount;
1281
    mOpenCount = openCount;
1275
  }
1282
  }
1276
  // If this is the current folder, the changed signal will ultimately call
1283
  // If this is the current folder, the changed signal will ultimately call
(-)kmail/kmfoldersearch.cpp (-21 / +41 lines)
Lines 146-151 Link Here
146
146
147
void KMSearch::start()
147
void KMSearch::start()
148
{
148
{
149
    //close all referenced folders
150
    QValueListIterator<QGuardedPtr<KMFolder> > fit;
151
    for (fit = mFolders.begin(); fit != mFolders.end(); ++fit) {
152
        if (!(*fit))
153
            continue;
154
        (*fit)->close("kmsearch");
155
    }
156
    mFolders.clear();
157
149
    if ( running() )
158
    if ( running() )
150
        return;
159
        return;
151
160
Lines 220-226 Link Here
220
            }
229
            }
221
            folder->storage()->search( 0 );
230
            folder->storage()->search( 0 );
222
            mSearchCount += folder->count();
231
            mSearchCount += folder->count();
223
            folder->close();
232
            folder->close("kmsearch");
224
        }
233
        }
225
    }
234
    }
226
    mRemainingFolders = -1;
235
    mRemainingFolders = -1;
Lines 248-254 Link Here
248
        if ( folder )
257
        if ( folder )
249
        {
258
        {
250
            mLastFolder = folder->label();
259
            mLastFolder = folder->label();
251
            folder->open();
260
            folder->open("kmsearch");
252
            mOpenedFolders.append( folder );
261
            mOpenedFolders.append( folder );
253
            connect( folder->storage(),
262
            connect( folder->storage(),
254
                SIGNAL( searchResult( KMFolder*, QValueList<Q_UINT32>, const KMSearchPattern*, bool ) ),
263
                SIGNAL( searchResult( KMFolder*, QValueList<Q_UINT32>, const KMSearchPattern*, bool ) ),
Lines 286-292 Link Here
286
                                        const KMSearchPattern*, bool ) ) );
295
                                        const KMSearchPattern*, bool ) ) );
287
      --mRemainingFolders;
296
      --mRemainingFolders;
288
      mSearchCount += folder->count();
297
      mSearchCount += folder->count();
289
      folder->close();
298
      folder->close("kmsearch");
290
      mOpenedFolders.remove( folder );
299
      mOpenedFolders.remove( folder );
291
      if ( mRemainingFolders <= 0 )
300
      if ( mRemainingFolders <= 0 )
292
      {
301
      {
Lines 369-375 Link Here
369
    delete mSearch;
378
    delete mSearch;
370
    mSearch = 0;
379
    mSearch = 0;
371
    if (mOpenCount > 0)
380
    if (mOpenCount > 0)
372
        close(TRUE);
381
        close("~foldersearch", TRUE);
373
}
382
}
374
383
375
void KMFolderSearch::setSearch(KMSearch *search)
384
void KMFolderSearch::setSearch(KMSearch *search)
Lines 403-409 Link Here
403
    /* TODO There is KMFolder::cleared signal now. Adjust. */
412
    /* TODO There is KMFolder::cleared signal now. Adjust. */
404
    if (mSearch)
413
    if (mSearch)
405
        mSearch->start();
414
        mSearch->start();
406
    open(); // will be closed in searchFinished
415
    open("foldersearch"); // will be closed in searchFinished
407
}
416
}
408
417
409
void KMFolderSearch::executeSearch()
418
void KMFolderSearch::executeSearch()
Lines 423-429 Link Here
423
{
432
{
424
    if (!success)
433
    if (!success)
425
        mSerNums.clear();
434
        mSerNums.clear();
426
    close();
435
    close("foldersearch");
427
}
436
}
428
437
429
void KMFolderSearch::addSerNum(Q_UINT32 serNum)
438
void KMFolderSearch::addSerNum(Q_UINT32 serNum)
Lines 435-441 Link Here
435
    KMMsgDict::instance()->getLocation(serNum, &aFolder, &idx);
444
    KMMsgDict::instance()->getLocation(serNum, &aFolder, &idx);
436
    assert(aFolder && (idx != -1));
445
    assert(aFolder && (idx != -1));
437
    if(mFolders.findIndex(aFolder) == -1) {
446
    if(mFolders.findIndex(aFolder) == -1) {
438
        aFolder->open();
447
        aFolder->open("foldersearch");
439
        // Exceptional case, for when folder has invalid ids
448
        // Exceptional case, for when folder has invalid ids
440
        if (mInvalid)
449
        if (mInvalid)
441
            return;
450
            return;
Lines 499-505 Link Here
499
    return mSearch->read(location());
508
    return mSearch->read(location());
500
}
509
}
501
510
502
int KMFolderSearch::open()
511
int KMFolderSearch::open(const char *)
503
{
512
{
504
    mOpenCount++;
513
    mOpenCount++;
505
    kmkernel->jobScheduler()->notifyOpeningFolder( folder() );
514
    kmkernel->jobScheduler()->notifyOpeningFolder( folder() );
Lines 537-543 Link Here
537
    }
546
    }
538
}
547
}
539
548
540
void KMFolderSearch::close(bool force)
549
void KMFolderSearch::close(const char *, bool force)
541
{
550
{
542
    if (mOpenCount <= 0) return;
551
    if (mOpenCount <= 0) return;
543
    if (mOpenCount > 0) mOpenCount--;
552
    if (mOpenCount > 0) mOpenCount--;
Lines 557-563 Link Here
557
    for (fit = mFolders.begin(); fit != mFolders.end(); ++fit) {
566
    for (fit = mFolders.begin(); fit != mFolders.end(); ++fit) {
558
        if (!(*fit))
567
        if (!(*fit))
559
            continue;
568
            continue;
560
        (*fit)->close();
569
        (*fit)->close("foldersearch");
561
    }
570
    }
562
    mFolders.clear();
571
    mFolders.clear();
563
572
Lines 852-858 Link Here
852
        }
861
        }
853
        mSerNums.push_back(serNum);
862
        mSerNums.push_back(serNum);
854
        if(mFolders.findIndex(folder) == -1) {
863
        if(mFolders.findIndex(folder) == -1) {
855
            folder->open();
864
            folder->open("foldersearch");
856
            if (mInvalid) //exceptional case for when folder has invalid ids
865
            if (mInvalid) //exceptional case for when folder has invalid ids
857
                return false;
866
                return false;
858
            mFolders.append(folder);
867
            mFolders.append(folder);
Lines 910-916 Link Here
910
919
911
void KMFolderSearch::clearIndex(bool, bool)
920
void KMFolderSearch::clearIndex(bool, bool)
912
{
921
{
913
    mSerNums.clear();
922
  //close all referenced folders
923
  QValueListIterator<QGuardedPtr<KMFolder> > fit;
924
  for (fit = mFolders.begin(); fit != mFolders.end(); ++fit) {
925
    if (!(*fit))
926
      continue;
927
    (*fit)->close("foldersearch");
928
  }
929
  mFolders.clear();
930
931
  mSerNums.clear();
914
}
932
}
915
933
916
void KMFolderSearch::truncateIndex()
934
void KMFolderSearch::truncateIndex()
Lines 925-931 Link Here
925
    if (!search()->inScope(aFolder))
943
    if (!search()->inScope(aFolder))
926
        return;
944
        return;
927
    if (!mTempOpened) {
945
    if (!mTempOpened) {
928
        open();
946
        open( "foldersearch" );
929
        mTempOpened = true;
947
        mTempOpened = true;
930
    }
948
    }
931
949
Lines 937-943 Link Here
937
    KMMsgDict::instance()->getLocation(serNum, &folder, &idx);
955
    KMMsgDict::instance()->getLocation(serNum, &folder, &idx);
938
    assert(folder && (idx != -1));
956
    assert(folder && (idx != -1));
939
    assert(folder == aFolder);
957
    assert(folder == aFolder);
940
    folder->open();
958
    folder->open("examineAddedMessage");
941
959
942
    // if we are already checking this folder, refcount
960
    // if we are already checking this folder, refcount
943
    if ( mFoldersCurrentlyBeingSearched.contains( folder ) ) {
961
    if ( mFoldersCurrentlyBeingSearched.contains( folder ) ) {
Lines 952-957 Link Here
952
      mFoldersCurrentlyBeingSearched.insert( folder, 1 );
970
      mFoldersCurrentlyBeingSearched.insert( folder, 1 );
953
    }
971
    }
954
    folder->storage()->search( search()->searchPattern(), serNum );
972
    folder->storage()->search( search()->searchPattern(), serNum );
973
    folder->close("examineAddedMessage");
955
}
974
}
956
975
957
void KMFolderSearch::slotSearchExamineMsgDone( KMFolder* folder,
976
void KMFolderSearch::slotSearchExamineMsgDone( KMFolder* folder,
Lines 962-967 Link Here
962
    if ( search()->searchPattern() != pattern ) return;
981
    if ( search()->searchPattern() != pattern ) return;
963
    kdDebug(5006) << folder->label() << ": serNum " << serNum
982
    kdDebug(5006) << folder->label() << ": serNum " << serNum
964
     << " matches?" << matches << endl;
983
     << " matches?" << matches << endl;
984
    folder->open("SearchExamineMsgDone");
965
985
966
    if ( mFoldersCurrentlyBeingSearched.contains( folder ) ) {
986
    if ( mFoldersCurrentlyBeingSearched.contains( folder ) ) {
967
      unsigned int count = mFoldersCurrentlyBeingSearched[folder];
987
      unsigned int count = mFoldersCurrentlyBeingSearched[folder];
Lines 979-985 Link Here
979
    } else {
999
    } else {
980
      Q_ASSERT( 0 ); // Can't happen (TM)
1000
      Q_ASSERT( 0 ); // Can't happen (TM)
981
    }
1001
    }
982
    folder->close();
1002
    folder->close("SearchExamineMsgDone");
983
1003
984
    if ( !matches ) {
1004
    if ( !matches ) {
985
        QValueVector<Q_UINT32>::const_iterator it;
1005
        QValueVector<Q_UINT32>::const_iterator it;
Lines 1009-1015 Link Here
1009
    if (!search()->inScope(folder))
1029
    if (!search()->inScope(folder))
1010
        return;
1030
        return;
1011
    if (!mTempOpened) {
1031
    if (!mTempOpened) {
1012
        open();
1032
        open("foldersearch");
1013
        mTempOpened = true;
1033
        mTempOpened = true;
1014
    }
1034
    }
1015
1035
Lines 1027-1033 Link Here
1027
    if (!search()->inScope(aFolder))
1047
    if (!search()->inScope(aFolder))
1028
        return;
1048
        return;
1029
    if (!mTempOpened) {
1049
    if (!mTempOpened) {
1030
        open();
1050
        open("foldersearch");
1031
        mTempOpened = true;
1051
        mTempOpened = true;
1032
    }
1052
    }
1033
    QValueVector<Q_UINT32>::const_iterator it;
1053
    QValueVector<Q_UINT32>::const_iterator it;
Lines 1046-1052 Link Here
1046
    if (!search()->inScope(folder))
1066
    if (!search()->inScope(folder))
1047
        return;
1067
        return;
1048
    if (mTempOpened) {
1068
    if (mTempOpened) {
1049
        close();
1069
        close("foldersearch");
1050
        mTempOpened = false;
1070
        mTempOpened = false;
1051
    }
1071
    }
1052
1072
Lines 1063-1069 Link Here
1063
        return;
1083
        return;
1064
1084
1065
    if (!mTempOpened) {
1085
    if (!mTempOpened) {
1066
        open();
1086
        open("foldersearch");
1067
        mTempOpened = true;
1087
        mTempOpened = true;
1068
    }
1088
    }
1069
    mExecuteSearchTimer->start(0, true);
1089
    mExecuteSearchTimer->start(0, true);
Lines 1086-1092 Link Here
1086
    if (!search()->inScope(aFolder))
1106
    if (!search()->inScope(aFolder))
1087
        return;
1107
        return;
1088
    if (!mTempOpened) {
1108
    if (!mTempOpened) {
1089
        open();
1109
        open("foldersearch");
1090
        mTempOpened = true;
1110
        mTempOpened = true;
1091
    }
1111
    }
1092
1112
Lines 1100-1106 Link Here
1100
        ++pos;
1120
        ++pos;
1101
    }
1121
    }
1102
    // let's try if the message matches our search
1122
    // let's try if the message matches our search
1103
    aFolder->open();
1123
    aFolder->open("foldersearch");
1104
1124
1105
    // if we are already checking this folder, refcount
1125
    // if we are already checking this folder, refcount
1106
    if ( mFoldersCurrentlyBeingSearched.contains( aFolder ) ) {
1126
    if ( mFoldersCurrentlyBeingSearched.contains( aFolder ) ) {
(-)kmail/kmfoldersearch.h (-2 / +2 lines)
Lines 171-180 Link Here
171
  //See base class for documentation
171
  //See base class for documentation
172
  virtual QCString& getMsgString(int idx, QCString& mDest);
172
  virtual QCString& getMsgString(int idx, QCString& mDest);
173
  virtual int addMsg(KMMessage* msg, int* index_return = 0);
173
  virtual int addMsg(KMMessage* msg, int* index_return = 0);
174
  virtual int open();
174
  virtual int open(const char *owner);
175
  virtual int canAccess();
175
  virtual int canAccess();
176
  virtual void sync();
176
  virtual void sync();
177
  virtual void close(bool force=FALSE);
177
  virtual void close(const char *owner, bool force=FALSE);
178
  virtual int create();
178
  virtual int create();
179
  virtual int compact( bool );
179
  virtual int compact( bool );
180
  virtual bool isReadOnly() const;
180
  virtual bool isReadOnly() const;
(-)kmail/kmfoldertree.cpp (-4 / +4 lines)
Lines 489-497 Link Here
489
    if (!folderNode->isDir()) {
489
    if (!folderNode->isDir()) {
490
      folder = static_cast<KMFolder*>(folderNode);
490
      folder = static_cast<KMFolder*>(folderNode);
491
491
492
      folder->open();
492
      folder->open("updateunread");
493
      folder->countUnread();
493
      folder->countUnread();
494
      folder->close();
494
      folder->close("updateunread");
495
    }
495
    }
496
  }
496
  }
497
497
Lines 648-657 Link Here
648
648
649
  // open the folder and update the count
649
  // open the folder and update the count
650
  bool open = fti->folder()->isOpened();
650
  bool open = fti->folder()->isOpened();
651
  if (!open) fti->folder()->open();
651
  if (!open) fti->folder()->open("updatecount");
652
  slotUpdateCounts(fti->folder());
652
  slotUpdateCounts(fti->folder());
653
  // restore previous state
653
  // restore previous state
654
  if (!open) fti->folder()->close();
654
  if (!open) fti->folder()->close("updatecount");
655
655
656
  QTimer::singleShot( 0, this, SLOT(slotUpdateOneCount()) );
656
  QTimer::singleShot( 0, this, SLOT(slotUpdateOneCount()) );
657
}
657
}
(-)kmail/kmkernel.cpp (-18 / +27 lines)
Lines 866-872 Link Here
866
866
867
        int i;
867
        int i;
868
868
869
        mAddMsgCurrentFolder->open();
869
        mAddMsgCurrentFolder->open("dcopadd");
870
        for( i=0; i<mAddMsgCurrentFolder->count(); i++) {
870
        for( i=0; i<mAddMsgCurrentFolder->count(); i++) {
871
          KMMsgBase *mb = mAddMsgCurrentFolder->getMsgBase(i);
871
          KMMsgBase *mb = mAddMsgCurrentFolder->getMsgBase(i);
872
	  QString id = mb->msgIdMD5();
872
	  QString id = mb->msgIdMD5();
Lines 885-891 Link Here
885
            mAddMessageMsgIds.append(id);
885
            mAddMessageMsgIds.append(id);
886
          }
886
          }
887
        }
887
        }
888
        mAddMsgCurrentFolder->close();
888
        mAddMsgCurrentFolder->close("dcopadd");
889
      }
889
      }
890
890
891
      QString msgId = msg->msgIdMD5();
891
      QString msgId = msg->msgIdMD5();
Lines 1101-1107 Link Here
1101
    KMMsgDict::instance()->getLocation(serialNumber, &folder, &idx);
1101
    KMMsgDict::instance()->getLocation(serialNumber, &folder, &idx);
1102
    if (!folder || (idx == -1))
1102
    if (!folder || (idx == -1))
1103
      return false;
1103
      return false;
1104
    folder->open();
1104
    folder->open("showmail");
1105
    KMMsgBase *msgBase = folder->getMsgBase(idx);
1105
    KMMsgBase *msgBase = folder->getMsgBase(idx);
1106
    if (!msgBase)
1106
    if (!msgBase)
1107
      return false;
1107
      return false;
Lines 1118-1124 Link Here
1118
1118
1119
    if (unGet)
1119
    if (unGet)
1120
      folder->unGetMsg(idx);
1120
      folder->unGetMsg(idx);
1121
    folder->close();
1121
    folder->close("showmail");
1122
    return true;
1122
    return true;
1123
  }
1123
  }
1124
1124
Lines 1132-1138 Link Here
1132
  KMMsgDict::instance()->getLocation(serialNumber, &folder, &idx);
1132
  KMMsgDict::instance()->getLocation(serialNumber, &folder, &idx);
1133
  if (!folder || (idx == -1))
1133
  if (!folder || (idx == -1))
1134
    return QString::null;
1134
    return QString::null;
1135
  folder->open();
1135
  folder->open("getFrom");
1136
  KMMsgBase *msgBase = folder->getMsgBase(idx);
1136
  KMMsgBase *msgBase = folder->getMsgBase(idx);
1137
  if (!msgBase)
1137
  if (!msgBase)
1138
    return QString::null;
1138
    return QString::null;
Lines 1141-1147 Link Here
1141
  QString result = msg->from();
1141
  QString result = msg->from();
1142
  if (unGet)
1142
  if (unGet)
1143
    folder->unGetMsg(idx);
1143
    folder->unGetMsg(idx);
1144
  folder->close();
1144
  folder->close("getFrom");
1145
  return result;
1145
  return result;
1146
}
1146
}
1147
1147
Lines 1163-1169 Link Here
1163
    // different folder
1163
    // different folder
1164
    if (folder && (idx != -1)) {
1164
    if (folder && (idx != -1)) {
1165
      // everything is ok
1165
      // everything is ok
1166
      folder->open();
1166
      folder->open("debugser");
1167
      msg = folder->getMsgBase( idx );
1167
      msg = folder->getMsgBase( idx );
1168
      if (msg) {
1168
      if (msg) {
1169
	res.append( QString( " subject %s,\n sender %s,\n date %s.\n" )
1169
	res.append( QString( " subject %s,\n sender %s,\n date %s.\n" )
Lines 1173-1179 Link Here
1173
      } else {
1173
      } else {
1174
	res.append( QString( "Invalid serial number." ) );
1174
	res.append( QString( "Invalid serial number." ) );
1175
      }
1175
      }
1176
      folder->close();
1176
      folder->close("debugser");
1177
    } else {
1177
    } else {
1178
      res.append( QString( "Invalid serial number." ) );
1178
      res.append( QString( "Invalid serial number." ) );
1179
    }
1179
    }
Lines 1335-1341 Link Here
1335
    return;
1335
    return;
1336
1336
1337
  KMFolder folder( 0, pathName + "autosave", KMFolderTypeMaildir, false /* no index */ );
1337
  KMFolder folder( 0, pathName + "autosave", KMFolderTypeMaildir, false /* no index */ );
1338
  const int rc = folder.open();
1338
  const int rc = folder.open("recover");
1339
  if ( rc ) {
1339
  if ( rc ) {
1340
    perror( "cannot open autosave folder" );
1340
    perror( "cannot open autosave folder" );
1341
    return;
1341
    return;
Lines 1351-1357 Link Here
1351
      win->show();
1351
      win->show();
1352
    }
1352
    }
1353
  }
1353
  }
1354
  folder.close();
1354
  folder.close("recover");
1355
}
1355
}
1356
1356
1357
//-----------------------------------------------------------------------------
1357
//-----------------------------------------------------------------------------
Lines 1395-1401 Link Here
1395
   * the index on each start to be on the save side. */
1395
   * the index on each start to be on the save side. */
1396
  //if ( the_outboxFolder->folderType() == KMFolderTypeMaildir )
1396
  //if ( the_outboxFolder->folderType() == KMFolderTypeMaildir )
1397
  //  unlink( QFile::encodeName( the_outboxFolder->indexLocation() ) );
1397
  //  unlink( QFile::encodeName( the_outboxFolder->indexLocation() ) );
1398
  the_outboxFolder->open();
1398
  the_outboxFolder->open("kmkernel");
1399
1399
1400
  the_sentFolder = the_folderMgr->findOrCreate(cfg->readEntry("sentFolder", I18N_NOOP("sent-mail")));
1400
  the_sentFolder = the_folderMgr->findOrCreate(cfg->readEntry("sentFolder", I18N_NOOP("sent-mail")));
1401
  if (the_sentFolder->canAccess() != 0) {
1401
  if (the_sentFolder->canAccess() != 0) {
Lines 1422-1428 Link Here
1422
  the_draftsFolder->setSystemFolder( TRUE );
1422
  the_draftsFolder->setSystemFolder( TRUE );
1423
  if ( the_draftsFolder->userWhoField().isEmpty() )
1423
  if ( the_draftsFolder->userWhoField().isEmpty() )
1424
    the_draftsFolder->setUserWhoField( QString::null );
1424
    the_draftsFolder->setUserWhoField( QString::null );
1425
  the_draftsFolder->open();
1425
  the_draftsFolder->open("kmkernel");
1426
1426
1427
  the_templatesFolder =
1427
  the_templatesFolder =
1428
    the_folderMgr->findOrCreate( cfg->readEntry( "templatesFolder",
1428
    the_folderMgr->findOrCreate( cfg->readEntry( "templatesFolder",
Lines 1433-1439 Link Here
1433
  the_templatesFolder->setSystemFolder( TRUE );
1433
  the_templatesFolder->setSystemFolder( TRUE );
1434
  if ( the_templatesFolder->userWhoField().isEmpty() )
1434
  if ( the_templatesFolder->userWhoField().isEmpty() )
1435
    the_templatesFolder->setUserWhoField( QString::null );
1435
    the_templatesFolder->setUserWhoField( QString::null );
1436
  the_templatesFolder->open();
1436
  the_templatesFolder->open("kmkernel");
1437
}
1437
}
1438
1438
1439
1439
Lines 1581-1587 Link Here
1581
    imapAcct = static_cast<KMAcctImap*>(acct);
1581
    imapAcct = static_cast<KMAcctImap*>(acct);
1582
    fld->setAccount(imapAcct);
1582
    fld->setAccount(imapAcct);
1583
    imapAcct->setImapFolder(fld);
1583
    imapAcct->setImapFolder(fld);
1584
    fld->close();
1584
    fld->close( "kernel", true );
1585
  }
1585
  }
1586
  the_imapFolderMgr->quiet(false);
1586
  the_imapFolderMgr->quiet(false);
1587
1587
Lines 1612-1618 Link Here
1612
    cachedImapAcct = static_cast<KMAcctCachedImap*>(acct);
1612
    cachedImapAcct = static_cast<KMAcctCachedImap*>(acct);
1613
    cfld->setAccount(cachedImapAcct);
1613
    cfld->setAccount(cachedImapAcct);
1614
    cachedImapAcct->setImapFolder(cfld);
1614
    cachedImapAcct->setImapFolder(cfld);
1615
    cfld->close();
1615
    cfld->close("kmkernel");
1616
  }
1616
  }
1617
  the_dimapFolderMgr->quiet( false );
1617
  the_dimapFolderMgr->quiet( false );
1618
}
1618
}
Lines 1676-1682 Link Here
1676
1676
1677
  if (the_trashFolder) {
1677
  if (the_trashFolder) {
1678
1678
1679
    the_trashFolder->close(TRUE);
1679
    the_trashFolder->close("kmkernel", TRUE);
1680
1680
1681
    if (config->readBoolEntry("empty-trash-on-exit", true))
1681
    if (config->readBoolEntry("empty-trash-on-exit", true))
1682
    {
1682
    {
Lines 1695-1701 Link Here
1695
  {
1695
  {
1696
    folder = *folders.at(i);
1696
    folder = *folders.at(i);
1697
    if (!folder || folder->isDir()) continue;
1697
    if (!folder || folder->isDir()) continue;
1698
    folder->close(TRUE);
1698
    folder->close("kmkernel", TRUE);
1699
  }
1699
  }
1700
  strList.clear();
1700
  strList.clear();
1701
  folders.clear();
1701
  folders.clear();
Lines 1704-1710 Link Here
1704
  {
1704
  {
1705
    folder = *folders.at(i);
1705
    folder = *folders.at(i);
1706
    if (!folder || folder->isDir()) continue;
1706
    if (!folder || folder->isDir()) continue;
1707
    folder->close(TRUE);
1707
    folder->close("kmkernel", TRUE);
1708
  }
1708
  }
1709
1709
1710
  delete the_msgIndex;
1710
  delete the_msgIndex;
Lines 1952-1957 Link Here
1952
             this, SLOT( slotConfigChanged() ) );
1952
             this, SLOT( slotConfigChanged() ) );
1953
  }
1953
  }
1954
1954
1955
  if( KMKernel::getKMMainWidget() == 0 )
1956
  {
1957
    // ensure that there is a main widget available
1958
    // as parts of the configure dialog (identity) rely on this
1959
    // and this slot can be called when there is only a KMComposeWin showing
1960
    KMMainWin * win = new KMMainWin;
1961
    win->show();
1962
  }
1963
1955
  if( mConfigureDialog->isHidden() )
1964
  if( mConfigureDialog->isHidden() )
1956
    mConfigureDialog->show();
1965
    mConfigureDialog->show();
1957
  else
1966
  else
(-)kmail/kmmainwidget.cpp (-23 / +44 lines)
Lines 164-169 Link Here
164
  mJob = 0;
164
  mJob = 0;
165
  mConfig = config;
165
  mConfig = config;
166
  mGUIClient = aGUIClient;
166
  mGUIClient = aGUIClient;
167
  mOpenedImapFolder = false;
167
168
168
  mCustomReplyActionMenu = 0;
169
  mCustomReplyActionMenu = 0;
169
  mCustomReplyAllActionMenu = 0;
170
  mCustomReplyAllActionMenu = 0;
Lines 265-275 Link Here
265
void KMMainWidget::readPreConfig(void)
266
void KMMainWidget::readPreConfig(void)
266
{
267
{
267
  const KConfigGroup geometry( KMKernel::config(), "Geometry" );
268
  const KConfigGroup geometry( KMKernel::config(), "Geometry" );
268
  const KConfigGroup general( KMKernel::config(), "General" );
269
  const KConfigGroup reader( KMKernel::config(), "Reader" );
269
270
270
  mLongFolderList = geometry.readEntry( "FolderList", "long" ) != "short";
271
  mLongFolderList = geometry.readEntry( "FolderList", "long" ) != "short";
271
  mReaderWindowActive = geometry.readEntry( "readerWindowMode", "below" ) != "hide";
272
  mReaderWindowActive = geometry.readEntry( "readerWindowMode", "below" ) != "hide";
272
  mReaderWindowBelow = geometry.readEntry( "readerWindowMode", "below" ) == "below";
273
  mReaderWindowBelow = geometry.readEntry( "readerWindowMode", "below" ) == "below";
274
  mThreadPref = geometry.readBoolEntry( "nestedMessages", false );
275
276
  mHtmlPref = reader.readBoolEntry( "htmlMail", false );
277
  mHtmlLoadExtPref = reader.readBoolEntry( "htmlLoadExternal", false );
273
}
278
}
274
279
275
280
Lines 336-349 Link Here
336
341
337
  }
342
  }
338
343
339
  // read "Reader" config options
340
  KConfigGroup readerConfig( config, "Reader" );
341
  mHtmlPref = readerConfig.readBoolEntry( "htmlMail", false );
342
  mHtmlLoadExtPref = readerConfig.readBoolEntry( "htmlLoadExternal", false );
343
344
  { // area for config group "Geometry"
344
  { // area for config group "Geometry"
345
    KConfigGroupSaver saver(config, "Geometry");
345
    KConfigGroupSaver saver(config, "Geometry");
346
    mThreadPref = config->readBoolEntry( "nestedMessages", false );
347
    // size of the mainwin
346
    // size of the mainwin
348
    QSize defaultSize(750,560);
347
    QSize defaultSize(750,560);
349
    siz = config->readSizeEntry("MainWin", &defaultSize);
348
    siz = config->readSizeEntry("MainWin", &defaultSize);
Lines 464-470 Link Here
464
  QString s;
463
  QString s;
465
  KConfig *config = KMKernel::config();
464
  KConfig *config = KMKernel::config();
466
  KConfigGroup geometry( config, "Geometry" );
465
  KConfigGroup geometry( config, "Geometry" );
467
  KConfigGroup general( config, "General" );
468
466
469
  if (mMsgView)
467
  if (mMsgView)
470
    mMsgView->writeConfig();
468
    mMsgView->writeConfig();
Lines 856-862 Link Here
856
854
857
    KMFolder *folder = kmkernel->findFolderById( *it );
855
    KMFolder *folder = kmkernel->findFolderById( *it );
858
856
859
    if ( !folder->ignoreNewMail() ) {
857
    if ( folder && !folder->ignoreNewMail() ) {
860
      showNotification = true;
858
      showNotification = true;
861
      if ( GlobalSettings::self()->verboseNewMailNotification() ) {
859
      if ( GlobalSettings::self()->verboseNewMailNotification() ) {
862
        summary += "<br>" + i18n( "1 new message in %1",
860
        summary += "<br>" + i18n( "1 new message in %1",
Lines 1872-1885 Link Here
1872
  slotChangeCaption( mFolderTree->currentItem() );
1870
  slotChangeCaption( mFolderTree->currentItem() );
1873
}
1871
}
1874
1872
1873
void KMMainWidget::openFolder()
1874
{
1875
  if ( !mFolder || mFolder->folderType() != KMFolderTypeImap )
1876
    return;
1877
  KMFolderImap *imap = static_cast<KMFolderImap*>(mFolder->storage());
1878
  assert( !mOpenedImapFolder );
1879
  imap->open("mainwidget"); // will be closed in the folderSelected slot
1880
  mOpenedImapFolder = true;
1881
  // first get new headers before we select the folder
1882
  imap->setSelected( true );
1883
}
1884
1885
void KMMainWidget::closeFolder()
1886
{
1887
  if ( !mFolder || mFolder->folderType() != KMFolderTypeImap )
1888
    return;
1889
  assert( mOpenedImapFolder );
1890
  KMFolderImap *imap = static_cast<KMFolderImap*>(mFolder->storage());
1891
  imap->setSelected( false );
1892
  mFolder->close( "mainwidget" );
1893
  mOpenedImapFolder = false;
1894
}
1895
1875
//-----------------------------------------------------------------------------
1896
//-----------------------------------------------------------------------------
1876
void KMMainWidget::folderSelected()
1897
void KMMainWidget::folderSelected()
1877
{
1898
{
1878
  folderSelected( mFolder );
1899
  folderSelected( mFolder );
1879
  updateFolderMenu();
1900
  updateFolderMenu();
1880
  // opened() before the getAndCheckFolder() in folderSelected
1881
  if ( mFolder && mFolder->folderType() == KMFolderTypeImap )
1882
    mFolder->close();
1883
}
1901
}
1884
1902
1885
//-----------------------------------------------------------------------------
1903
//-----------------------------------------------------------------------------
Lines 1907-1913 Link Here
1907
  bool newFolder = ( mFolder != aFolder );
1925
  bool newFolder = ( mFolder != aFolder );
1908
  bool isNewImapFolder = aFolder && aFolder->folderType() == KMFolderTypeImap && newFolder;
1926
  bool isNewImapFolder = aFolder && aFolder->folderType() == KMFolderTypeImap && newFolder;
1909
  if( !mFolder
1927
  if( !mFolder
1910
      || ( !isNewImapFolder && mShowBusySplashTimer && !mShowBusySplashTimer->isActive() )
1928
      || ( !isNewImapFolder && mShowBusySplashTimer )
1911
      || ( newFolder && mShowingOfflineScreen && !( isNewImapFolder && kmkernel->isOffline() ) ) ) {
1929
      || ( newFolder && mShowingOfflineScreen && !( isNewImapFolder && kmkernel->isOffline() ) ) ) {
1912
    if ( mMsgView ) {
1930
    if ( mMsgView ) {
1913
      mMsgView->enableMsgDisplay();
1931
      mMsgView->enableMsgDisplay();
Lines 1935-1942 Link Here
1935
           this, SLOT( updateMarkAsReadAction() ) );
1953
           this, SLOT( updateMarkAsReadAction() ) );
1936
  }
1954
  }
1937
1955
1956
  if ( newFolder )
1957
      closeFolder();
1958
1938
  mFolder = aFolder;
1959
  mFolder = aFolder;
1939
1960
1961
  if ( newFolder )
1962
    openFolder();
1963
1940
  if ( aFolder && aFolder->folderType() == KMFolderTypeImap )
1964
  if ( aFolder && aFolder->folderType() == KMFolderTypeImap )
1941
  {
1965
  {
1942
    if ( kmkernel->isOffline() ) {
1966
    if ( kmkernel->isOffline() ) {
Lines 1946-1954 Link Here
1946
    KMFolderImap *imap = static_cast<KMFolderImap*>(aFolder->storage());
1970
    KMFolderImap *imap = static_cast<KMFolderImap*>(aFolder->storage());
1947
    if ( newFolder && !mFolder->noContent() )
1971
    if ( newFolder && !mFolder->noContent() )
1948
    {
1972
    {
1949
      imap->open(); // will be closed in the folderSelected slot
1950
      // first get new headers before we select the folder
1951
      imap->setSelected( true );
1952
      connect( imap, SIGNAL( folderComplete( KMFolderImap*, bool ) ),
1973
      connect( imap, SIGNAL( folderComplete( KMFolderImap*, bool ) ),
1953
          this, SLOT( folderSelected() ) );
1974
          this, SLOT( folderSelected() ) );
1954
      imap->getAndCheckFolder();
1975
      imap->getAndCheckFolder();
Lines 2724-2733 Link Here
2724
                                      actionCollection(), "refresh_folder" );
2745
                                      actionCollection(), "refresh_folder" );
2725
  mTroubleshootFolderAction = 0; // set in initializeIMAPActions
2746
  mTroubleshootFolderAction = 0; // set in initializeIMAPActions
2726
2747
2727
  mEmptyFolderAction = new KAction( "foo", "edittrash", 0, this,
2748
  mEmptyFolderAction = new KAction( "foo" /*set in updateFolderMenu*/, "edittrash", 0, this,
2728
		      SLOT(slotEmptyFolder()), actionCollection(), "empty" );
2749
		      SLOT(slotEmptyFolder()), actionCollection(), "empty" );
2729
2750
2730
  mRemoveFolderAction = new KAction( "foo", "editdelete", 0, this,
2751
  mRemoveFolderAction = new KAction( "foo" /*set in updateFolderMenu*/, "editdelete", 0, this,
2731
		      SLOT(slotRemoveFolder()), actionCollection(), "delete_folder" );
2752
		      SLOT(slotRemoveFolder()), actionCollection(), "delete_folder" );
2732
2753
2733
  mPreferHtmlAction = new KToggleAction( i18n("Prefer &HTML to Plain Text"), 0, this,
2754
  mPreferHtmlAction = new KToggleAction( i18n("Prefer &HTML to Plain Text"), 0, this,
Lines 3127-3132 Link Here
3127
  initializeIMAPActions( false ); // don't set state, config not read yet
3148
  initializeIMAPActions( false ); // don't set state, config not read yet
3128
  updateMessageActions();
3149
  updateMessageActions();
3129
  updateCustomTemplateMenus();
3150
  updateCustomTemplateMenus();
3151
  updateFolderMenu();
3130
}
3152
}
3131
3153
3132
//-----------------------------------------------------------------------------
3154
//-----------------------------------------------------------------------------
Lines 3397-3406 Link Here
3397
  mEmptyFolderAction->setText( (mFolder && kmkernel->folderIsTrash(mFolder))
3419
  mEmptyFolderAction->setText( (mFolder && kmkernel->folderIsTrash(mFolder))
3398
    ? i18n("E&mpty Trash") : i18n("&Move All Messages to Trash") );
3420
    ? i18n("E&mpty Trash") : i18n("&Move All Messages to Trash") );
3399
  mRemoveFolderAction->setEnabled( mFolder && !mFolder->isSystemFolder() && !mFolder->isReadOnly() );
3421
  mRemoveFolderAction->setEnabled( mFolder && !mFolder->isSystemFolder() && !mFolder->isReadOnly() );
3400
  if(mFolder) {
3422
  mRemoveFolderAction->setText( mFolder && mFolder->folderType() == KMFolderTypeSearch
3401
    mRemoveFolderAction->setText( mFolder->folderType() == KMFolderTypeSearch
3402
        ? i18n("&Delete Search") : i18n("&Delete Folder") );
3423
        ? i18n("&Delete Search") : i18n("&Delete Folder") );
3403
  }
3404
  mExpireFolderAction->setEnabled( mFolder && mFolder->isAutoExpire() );
3424
  mExpireFolderAction->setEnabled( mFolder && mFolder->isAutoExpire() );
3405
  updateMarkAsReadAction();
3425
  updateMarkAsReadAction();
3406
  // the visual ones only make sense if we are showing a message list
3426
  // the visual ones only make sense if we are showing a message list
Lines 3465-3470 Link Here
3465
3485
3466
  mMsgView->displayAboutPage();
3486
  mMsgView->displayAboutPage();
3467
3487
3488
  closeFolder();
3468
  mFolder = 0;
3489
  mFolder = 0;
3469
}
3490
}
3470
3491
Lines 3533-3539 Link Here
3533
  QMap< QString, QValueList<int> > idMD5s;
3554
  QMap< QString, QValueList<int> > idMD5s;
3534
  QValueList<int> redundantIds;
3555
  QValueList<int> redundantIds;
3535
  QValueList<int>::Iterator kt;
3556
  QValueList<int>::Iterator kt;
3536
  mFolder->open();
3557
  mFolder->open("removedups");
3537
  for (int i = mFolder->count() - 1; i >= 0; --i) {
3558
  for (int i = mFolder->count() - 1; i >= 0; --i) {
3538
    QString id = (*mFolder)[i]->msgIdMD5();
3559
    QString id = (*mFolder)[i]->msgIdMD5();
3539
    if ( !id.isEmpty() ) {
3560
    if ( !id.isEmpty() ) {
Lines 3572-3578 Link Here
3572
  }
3593
  }
3573
  while (kt != redundantIds.begin());
3594
  while (kt != redundantIds.begin());
3574
3595
3575
  mFolder->close();
3596
  mFolder->close("removedups");
3576
  mHeaders->setFolder(oFolder);
3597
  mHeaders->setFolder(oFolder);
3577
  QString msg;
3598
  QString msg;
3578
  if ( numDuplicates )
3599
  if ( numDuplicates )
(-)kmail/kmmainwidget.h (+5 lines)
Lines 241-246 Link Here
241
  void updateFileMenu();
241
  void updateFileMenu();
242
  void newFromTemplate( KMMessage *msg );
242
  void newFromTemplate( KMMessage *msg );
243
243
244
  // helper functions for keeping reference to mFolder
245
  void openFolder();
246
  void closeFolder();
247
244
  KActionCollection * actionCollection() const { return mActionCollection; }
248
  KActionCollection * actionCollection() const { return mActionCollection; }
245
249
246
  /** @return the correct config dialog depending on whether the parent of the mainWidget
250
  /** @return the correct config dialog depending on whether the parent of the mainWidget
Lines 531-536 Link Here
531
  KXMLGUIClient *mGUIClient;
535
  KXMLGUIClient *mGUIClient;
532
536
533
  static QValueList<KMMainWidget*>* s_mainWidgetList;
537
  static QValueList<KMMainWidget*>* s_mainWidgetList;
538
  bool mOpenedImapFolder;
534
};
539
};
535
540
536
#endif
541
#endif
(-)kmail/kmmessage.cpp (-57 / +75 lines)
Lines 64-69 Link Here
64
#include <klocale.h>
64
#include <klocale.h>
65
#include <stdlib.h>
65
#include <stdlib.h>
66
#include <unistd.h>
66
#include <unistd.h>
67
#include "util.h"
67
68
68
#if ALLOW_GUI
69
#if ALLOW_GUI
69
#include <kmessagebox.h>
70
#include <kmessagebox.h>
Lines 87-107 Link Here
87
88
88
//-----------------------------------------------------------------------------
89
//-----------------------------------------------------------------------------
89
KMMessage::KMMessage(DwMessage* aMsg)
90
KMMessage::KMMessage(DwMessage* aMsg)
90
  : KMMsgBase(),
91
  : KMMsgBase()
91
    mMsg(aMsg),
92
    mNeedsAssembly(true),
93
    mDecodeHTML(false),
94
    mOverrideCodec(0),
95
    mFolderOffset( 0 ),
96
    mMsgSize(0),
97
    mMsgLength( 0 ),
98
    mDate( 0 ),
99
    mEncryptionState( KMMsgEncryptionStateUnknown ),
100
    mSignatureState( KMMsgSignatureStateUnknown ),
101
    mMDNSentState( KMMsgMDNStateUnknown ),
102
    mUnencryptedMsg(0),
103
    mLastUpdated( 0 )
104
{
92
{
93
  init( aMsg );
94
  // aMsg might need assembly
95
  mNeedsAssembly = true;
105
}
96
}
106
97
107
//-----------------------------------------------------------------------------
98
//-----------------------------------------------------------------------------
Lines 138-147 Link Here
138
  assign( other );
129
  assign( other );
139
}
130
}
140
131
141
void KMMessage::init()
132
void KMMessage::init( DwMessage* aMsg )
142
{
133
{
143
  mNeedsAssembly = false;
134
  mNeedsAssembly = false;
135
  if ( aMsg ) {
136
    mMsg = aMsg;
137
  } else {
144
  mMsg = new DwMessage;
138
  mMsg = new DwMessage;
139
  }
145
  mOverrideCodec = 0;
140
  mOverrideCodec = 0;
146
  mDecodeHTML = false;
141
  mDecodeHTML = false;
147
  mComplete = true;
142
  mComplete = true;
Lines 157-162 Link Here
157
  mUnencryptedMsg = 0;
152
  mUnencryptedMsg = 0;
158
  mLastUpdated = 0;
153
  mLastUpdated = 0;
159
  mCursorPos = 0;
154
  mCursorPos = 0;
155
  mIsParsed = false;
160
}
156
}
161
157
162
void KMMessage::assign( const KMMessage& other )
158
void KMMessage::assign( const KMMessage& other )
Lines 179-184 Link Here
179
  mEncryptionState = other.mEncryptionState;
175
  mEncryptionState = other.mEncryptionState;
180
  mSignatureState = other.mSignatureState;
176
  mSignatureState = other.mSignatureState;
181
  mMDNSentState = other.mMDNSentState;
177
  mMDNSentState = other.mMDNSentState;
178
  mIsParsed = other.mIsParsed;
182
  mDate    = other.mDate;
179
  mDate    = other.mDate;
183
  if( other.hasUnencryptedMsg() )
180
  if( other.hasUnencryptedMsg() )
184
    mUnencryptedMsg = new KMMessage( *other.unencryptedMsg() );
181
    mUnencryptedMsg = new KMMessage( *other.unencryptedMsg() );
Lines 212-218 Link Here
212
{
209
{
213
  DwHeaders& header = mMsg->Headers();
210
  DwHeaders& header = mMsg->Headers();
214
  if (header.HasMessageId())
211
  if (header.HasMessageId())
215
    return header.MessageId().AsString().c_str();
212
    return KMail::Util::CString( header.MessageId().AsString() );
216
  else
213
  else
217
    return "";
214
    return "";
218
}
215
}
Lines 294-300 Link Here
294
}
291
}
295
292
296
//-----------------------------------------------------------------------------
293
//-----------------------------------------------------------------------------
297
const DwMessage *KMMessage::asDwMessage()
294
const DwMessage* KMMessage::asDwMessage()
298
{
295
{
299
  if (mNeedsAssembly)
296
  if (mNeedsAssembly)
300
  {
297
  {
Lines 306-328 Link Here
306
303
307
//-----------------------------------------------------------------------------
304
//-----------------------------------------------------------------------------
308
QCString KMMessage::asString() const {
305
QCString KMMessage::asString() const {
309
  return asDwString().c_str();
306
  return KMail::Util::CString( asDwString() );
310
}
307
}
311
308
312
309
313
QCString KMMessage::asSendableString() const
310
QByteArray KMMessage::asSendableString() const
314
{
311
{
315
  KMMessage msg;
312
  KMMessage msg( new DwMessage( *this->mMsg ) );
316
  msg.fromString(asString());
317
  msg.removePrivateHeaderFields();
313
  msg.removePrivateHeaderFields();
318
  msg.removeHeaderField("Bcc");
314
  msg.removeHeaderField("Bcc");
319
  return msg.asString();
315
  return KMail::Util::ByteArray( msg.asDwString() ); // and another copy again!
320
}
316
}
321
317
322
QCString KMMessage::headerAsSendableString() const
318
QCString KMMessage::headerAsSendableString() const
323
{
319
{
324
  KMMessage msg;
320
  KMMessage msg( new DwMessage( *this->mMsg ) );
325
  msg.fromString(asString());
326
  msg.removePrivateHeaderFields();
321
  msg.removePrivateHeaderFields();
327
  msg.removeHeaderField("Bcc");
322
  msg.removeHeaderField("Bcc");
328
  return msg.headerAsString().latin1();
323
  return msg.headerAsString().latin1();
Lines 392-398 Link Here
392
}
387
}
393
388
394
void KMMessage::fromString( const QCString & str, bool aSetStatus ) {
389
void KMMessage::fromString( const QCString & str, bool aSetStatus ) {
395
  return fromDwString( DwString( str.data() ), aSetStatus );
390
  return fromDwString( KMail::Util::dwString( str ), aSetStatus );
396
}
391
}
397
392
398
void KMMessage::fromDwString(const DwString& str, bool aSetStatus)
393
void KMMessage::fromDwString(const DwString& str, bool aSetStatus)
Lines 1105-1115 Link Here
1105
1100
1106
KMMessage* KMMessage::createRedirect( const QString &toStr )
1101
KMMessage* KMMessage::createRedirect( const QString &toStr )
1107
{
1102
{
1108
  KMMessage* msg = new KMMessage;
1109
  KMMessagePart msgPart;
1110
1111
  // copy the message 1:1
1103
  // copy the message 1:1
1112
  msg->fromDwString(this->asDwString());
1104
  KMMessage* msg = new KMMessage( new DwMessage( *this->mMsg ) );
1105
  KMMessagePart msgPart;
1113
1106
1114
  uint id = 0;
1107
  uint id = 0;
1115
  QString strId = msg->headerField( "X-KMail-Identity" ).stripWhiteSpace();
1108
  QString strId = msg->headerField( "X-KMail-Identity" ).stripWhiteSpace();
Lines 1195-1200 Link Here
1195
  // preserved
1188
  // preserved
1196
  if ( type() == DwMime::kTypeMultipart ||
1189
  if ( type() == DwMime::kTypeMultipart ||
1197
     ( type() == DwMime::kTypeText && subtype() == DwMime::kSubtypePlain ) ) {
1190
     ( type() == DwMime::kTypeText && subtype() == DwMime::kSubtypePlain ) ) {
1191
    // ## slow, we could probably use: delete msg->mMsg; msg->mMsg = new DwMessage( this->mMsg );
1198
    msg->fromDwString( this->asDwString() );
1192
    msg->fromDwString( this->asDwString() );
1199
    // remember the type and subtype, initFromMessage sets the contents type to
1193
    // remember the type and subtype, initFromMessage sets the contents type to
1200
    // text/plain, via initHeader, for unclear reasons
1194
    // text/plain, via initHeader, for unclear reasons
Lines 1250-1256 Link Here
1250
    KMMessagePart secondPart;
1244
    KMMessagePart secondPart;
1251
    secondPart.setType( type() );
1245
    secondPart.setType( type() );
1252
    secondPart.setSubtype( subtype() );
1246
    secondPart.setSubtype( subtype() );
1253
    secondPart.setBody( mMsg->Body().AsString().c_str() );
1247
    secondPart.setBody( mMsg->Body().AsString() );
1254
    // use the headers of the original mail
1248
    // use the headers of the original mail
1255
    applyHeadersToMessagePart( mMsg->Headers(), &secondPart );
1249
    applyHeadersToMessagePart( mMsg->Headers(), &secondPart );
1256
    msg->addBodyPart(&secondPart);
1250
    msg->addBodyPart(&secondPart);
Lines 1761-1769 Link Here
1761
  unixTime = header.Date().AsUnixTime();
1755
  unixTime = header.Date().AsUnixTime();
1762
1756
1763
  QCString result = ctime(&unixTime);
1757
  QCString result = ctime(&unixTime);
1764
1758
  int len = result.length();
1765
  if (result[result.length()-1]=='\n')
1759
  if (result[len-1]=='\n')
1766
    result.truncate(result.length()-1);
1760
    result.truncate(len-1);
1767
1761
1768
  return result;
1762
  return result;
1769
}
1763
}
Lines 2469-2478 Link Here
2469
//-----------------------------------------------------------------------------
2463
//-----------------------------------------------------------------------------
2470
QCString KMMessage::body() const
2464
QCString KMMessage::body() const
2471
{
2465
{
2472
  DwString body = mMsg->Body().AsString();
2466
  const DwString& body = mMsg->Body().AsString();
2473
  QCString str = body.c_str();
2467
  QCString str = KMail::Util::CString( body );
2474
  kdWarning( str.length() != body.length(), 5006 )
2468
  // Calls length() -> slow
2475
    << "KMMessage::body(): body is binary but used as text!" << endl;
2469
  //kdWarning( str.length() != body.length(), 5006 )
2470
  //  << "KMMessage::body(): body is binary but used as text!" << endl;
2476
  return str;
2471
  return str;
2477
}
2472
}
2478
2473
Lines 2481-2487 Link Here
2481
QByteArray KMMessage::bodyDecodedBinary() const
2476
QByteArray KMMessage::bodyDecodedBinary() const
2482
{
2477
{
2483
  DwString dwstr;
2478
  DwString dwstr;
2484
  DwString dwsrc = mMsg->Body().AsString();
2479
  const DwString& dwsrc = mMsg->Body().AsString();
2485
2480
2486
  switch (cte())
2481
  switch (cte())
2487
  {
2482
  {
Lines 2522-2534 Link Here
2522
    break;
2517
    break;
2523
  }
2518
  }
2524
2519
2525
  unsigned int len = dwstr.size();
2520
  return KMail::Util::CString( dwstr );
2526
  QCString result(len+1);
2521
2527
  memcpy(result.data(),dwstr.data(),len);
2522
  // Calling QCString::length() is slow
2528
  result[len] = 0;
2523
  //QCString result = KMail::Util::CString( dwstr );
2529
  kdWarning(result.length() != len, 5006)
2524
  //kdWarning(result.length() != len, 5006)
2530
    << "KMMessage::bodyDecoded(): body is binary but used as text!" << endl;
2525
  //  << "KMMessage::bodyDecoded(): body is binary but used as text!" << endl;
2531
  return result;
2526
  //return result;
2532
}
2527
}
2533
2528
2534
2529
Lines 2609-2615 Link Here
2609
                                    bool allow8Bit,
2604
                                    bool allow8Bit,
2610
                                    bool willBeSigned )
2605
                                    bool willBeSigned )
2611
{
2606
{
2612
  CharFreq cf( aBuf.data(), aBuf.length() ); // it's safe to pass null strings
2607
  CharFreq cf( aBuf.data(), aBuf.size()-1 ); // it's safe to pass null strings
2613
2608
2614
  allowedCte = determineAllowedCtes( cf, allow8Bit, willBeSigned );
2609
  allowedCte = determineAllowedCtes( cf, allow8Bit, willBeSigned );
2615
2610
Lines 2676-2682 Link Here
2676
//-----------------------------------------------------------------------------
2671
//-----------------------------------------------------------------------------
2677
void KMMessage::setBody(const QCString& aStr)
2672
void KMMessage::setBody(const QCString& aStr)
2678
{
2673
{
2679
  mMsg->Body().FromString(aStr.data());
2674
  mMsg->Body().FromString(KMail::Util::dwString(aStr));
2675
  mNeedsAssembly = TRUE;
2676
}
2677
void KMMessage::setBody(const DwString& aStr)
2678
{
2679
  mMsg->Body().FromString(aStr);
2680
  mNeedsAssembly = TRUE;
2681
}
2682
void KMMessage::setBody(const char* aStr)
2683
{
2684
  mMsg->Body().FromString(aStr);
2680
  mNeedsAssembly = TRUE;
2685
  mNeedsAssembly = TRUE;
2681
}
2686
}
2682
2687
Lines 2874-2887 Link Here
2874
2879
2875
void applyHeadersToMessagePart( DwHeaders& headers, KMMessagePart* aPart )
2880
void applyHeadersToMessagePart( DwHeaders& headers, KMMessagePart* aPart )
2876
{
2881
{
2877
  // TODO: Instead of manually implementing RFC2231 header encoding (i.e. 
2882
  // TODO: Instead of manually implementing RFC2231 header encoding (i.e.
2878
  //       possibly multiple values given as paramname*0=..; parmaname*1=..;... 
2883
  //       possibly multiple values given as paramname*0=..; parmaname*1=..;...
2879
  //       or par as paramname*0*=..; parmaname*1*=..;..., which should be
2884
  //       or par as paramname*0*=..; parmaname*1*=..;..., which should be
2880
  //       concatenated), use a generic method to decode the header, using RFC
2885
  //       concatenated), use a generic method to decode the header, using RFC
2881
  //       2047 or 2231, or whatever future RFC might be appropriate!
2886
  //       2047 or 2231, or whatever future RFC might be appropriate!
2882
  //       Right now, some fields are decoded, while others are not. E.g.
2887
  //       Right now, some fields are decoded, while others are not. E.g.
2883
  //       Content-Disposition is not decoded here, rather only on demand in
2888
  //       Content-Disposition is not decoded here, rather only on demand in
2884
  //       KMMsgPart::fileName; Name however is decoded here and stored as a 
2889
  //       KMMsgPart::fileName; Name however is decoded here and stored as a
2885
  //       decoded String in KMMsgPart...
2890
  //       decoded String in KMMsgPart...
2886
  // Content-type
2891
  // Content-type
2887
  QCString additionalCTypeParams;
2892
  QCString additionalCTypeParams;
Lines 2964-2972 Link Here
2964
2969
2965
    // Body
2970
    // Body
2966
    if (withBody)
2971
    if (withBody)
2967
      aPart->setBody( aDwBodyPart->Body().AsString().c_str() );
2972
      aPart->setBody( aDwBodyPart->Body().AsString() );
2968
    else
2973
    else
2969
      aPart->setBody( "" );
2974
      aPart->setBody( QCString("") );
2970
2975
2971
    // Content-id
2976
    // Content-id
2972
    if ( headers.HasContentId() ) {
2977
    if ( headers.HasContentId() ) {
Lines 2987-2993 Link Here
2987
    //aPart->setName(" ");
2992
    //aPart->setName(" ");
2988
    aPart->setContentDescription("");
2993
    aPart->setContentDescription("");
2989
    aPart->setContentDisposition("");
2994
    aPart->setContentDisposition("");
2990
    aPart->setBody("");
2995
    aPart->setBody(QCString(""));
2991
    aPart->setContentId("");
2996
    aPart->setContentId("");
2992
  }
2997
  }
2993
}
2998
}
Lines 3135-3142 Link Here
3135
  if (!contDisp.isEmpty())
3140
  if (!contDisp.isEmpty())
3136
    headers.ContentDisposition().FromString(contDisp);
3141
    headers.ContentDisposition().FromString(contDisp);
3137
3142
3138
  if (!aPart->body().isNull())
3143
  const DwString bodyStr = aPart->dwBody();
3139
    part->Body().FromString(aPart->body());
3144
  if (!bodyStr.empty())
3145
    part->Body().FromString(bodyStr);
3140
  else
3146
  else
3141
    part->Body().FromString("");
3147
    part->Body().FromString("");
3142
3148
Lines 3194-3200 Link Here
3194
//-----------------------------------------------------------------------------
3200
//-----------------------------------------------------------------------------
3195
QCString KMMessage::html2source( const QCString & src )
3201
QCString KMMessage::html2source( const QCString & src )
3196
{
3202
{
3197
  QCString result( 1 + 6*src.length() );  // maximal possible length
3203
  QCString result( 1 + 6*(src.size()-1) );  // maximal possible length
3198
3204
3199
  QCString::ConstIterator s = src.begin();
3205
  QCString::ConstIterator s = src.begin();
3200
  QCString::Iterator d = result.begin();
3206
  QCString::Iterator d = result.begin();
Lines 4134-4144 Link Here
4134
    return;
4140
    return;
4135
  }
4141
  }
4136
4142
4143
  bool filenameEmpty = true;
4144
  if ( part->hasHeaders() ) {
4145
    if ( part->Headers().HasContentDisposition() ) {
4146
      DwDispositionType cd = part->Headers().ContentDisposition();
4147
      filenameEmpty = cd.Filename().empty();
4148
      if ( filenameEmpty ) {
4149
        // let's try if it is rfc 2231 encoded which mimelib can't handle
4150
        filenameEmpty = KMMsgBase::decodeRFC2231String( KMMsgBase::extractRFC2231HeaderField( cd.AsString().c_str(), "filename" ) ).isEmpty();
4151
      }
4152
    }
4153
  }
4154
4137
  if ( part->hasHeaders() &&
4155
  if ( part->hasHeaders() &&
4138
       ( ( part->Headers().HasContentDisposition() &&
4156
       ( ( part->Headers().HasContentDisposition() &&
4139
           !part->Headers().ContentDisposition().Filename().empty() ) ||
4157
           !part->Headers().ContentDisposition().Filename().empty() ) ||
4140
         ( part->Headers().HasContentType() &&
4158
         ( part->Headers().HasContentType() &&
4141
           !part->Headers().ContentType().Name().empty() ) ) )
4159
           !filenameEmpty ) ) )
4142
  {
4160
  {
4143
    // now blacklist certain ContentTypes
4161
    // now blacklist certain ContentTypes
4144
    if ( !part->Headers().HasContentType() ||
4162
    if ( !part->Headers().HasContentType() ||
(-)kmail/kmmessage.h (-3 / +12 lines)
Lines 208-214 Link Here
208
  /** Parse the string and create this message from it. */
208
  /** Parse the string and create this message from it. */
209
  void fromDwString(const DwString& str, bool setStatus=FALSE);
209
  void fromDwString(const DwString& str, bool setStatus=FALSE);
210
  void fromString(const QCString& str, bool setStatus=FALSE);
210
  void fromString(const QCString& str, bool setStatus=FALSE);
211
  void fromByteArray( const QByteArray & ba, bool setStatus=false );
211
  void fromByteArray(const QByteArray & ba, bool setStatus=false);
212
212
213
  /** Return the entire message contents in the DwString. This function
213
  /** Return the entire message contents in the DwString. This function
214
      is *fast* even for large message since it does *not* involve a
214
      is *fast* even for large message since it does *not* involve a
Lines 230-236 Link Here
230
   * Return the message contents with the headers that should not be
230
   * Return the message contents with the headers that should not be
231
   * sent stripped off.
231
   * sent stripped off.
232
   */
232
   */
233
  QCString asSendableString() const;
233
  QByteArray asSendableString() const;
234
234
235
  /**
235
  /**
236
   * Return the message header with the headers that should not be
236
   * Return the message header with the headers that should not be
Lines 526-531 Link Here
526
526
527
  /** Set the message body. Does not encode the body. */
527
  /** Set the message body. Does not encode the body. */
528
  void setBody(const QCString& aStr);
528
  void setBody(const QCString& aStr);
529
  void setBody(const DwString& aStr);
530
  void setBody(const char* aStr); // avoid ambiguous calls
529
531
530
  /** Hack to enable structured body parts to be set as flat text... */
532
  /** Hack to enable structured body parts to be set as flat text... */
531
  void setMultiPartBody( const QCString & aStr );
533
  void setMultiPartBody( const QCString & aStr );
Lines 853-862 Link Here
853
  /** Set cursor position as offset from message start */
855
  /** Set cursor position as offset from message start */
854
  void setCursorPos(int pos) { mCursorPos = pos; };
856
  void setCursorPos(int pos) { mCursorPos = pos; };
855
857
858
  /* This is set in kmreaderwin if a message is being parsed to avoid
859
     other parts of kmail (e.g. kmheaders) destroying the message. 
860
     Parsing can take longer and can be async (in case of gpg mails) */
861
  bool isBeingParsed() const { return mIsParsed; }
862
  void setIsBeingParsed( bool t ) { mIsParsed = t; }
863
856
private:
864
private:
857
865
858
  /** Initialization shared by the ctors. */
866
  /** Initialization shared by the ctors. */
859
  void init();
867
  void init( DwMessage* aMsg = 0 );
860
  /** Assign the values of @param other to this message. Used in the copy c'tor. */
868
  /** Assign the values of @param other to this message. Used in the copy c'tor. */
861
  void assign( const KMMessage& other );
869
  void assign( const KMMessage& other );
862
870
Lines 867-872 Link Here
867
  bool mDecodeHTML :1;
875
  bool mDecodeHTML :1;
868
  bool mReadyToShow :1;
876
  bool mReadyToShow :1;
869
  bool mComplete :1;
877
  bool mComplete :1;
878
  bool mIsParsed : 1;
870
  static const KMail::HeaderStrategy * sHeaderStrategy;
879
  static const KMail::HeaderStrategy * sHeaderStrategy;
871
  static QString sForwardStr;
880
  static QString sForwardStr;
872
  const QTextCodec * mOverrideCodec;
881
  const QTextCodec * mOverrideCodec;
(-)kmail/kmmsgbase.cpp (-20 / +20 lines)
Lines 118-124 Link Here
118
//-----------------------------------------------------------------------------
118
//-----------------------------------------------------------------------------
119
bool KMMsgBase::isMessage(void) const
119
bool KMMsgBase::isMessage(void) const
120
{
120
{
121
  return FALSE;
121
  return false;
122
}
122
}
123
//-----------------------------------------------------------------------------
123
//-----------------------------------------------------------------------------
124
void KMMsgBase::toggleStatus(const KMMsgStatus aStatus, int idx)
124
void KMMsgBase::toggleStatus(const KMMsgStatus aStatus, int idx)
Lines 152-158 Link Here
152
//-----------------------------------------------------------------------------
152
//-----------------------------------------------------------------------------
153
void KMMsgBase::setStatus(const KMMsgStatus aStatus, int idx)
153
void KMMsgBase::setStatus(const KMMsgStatus aStatus, int idx)
154
{
154
{
155
  mDirty = TRUE;
155
  mDirty = true;
156
  KMMsgStatus oldStatus = status();
156
  KMMsgStatus oldStatus = status();
157
  switch (aStatus) {
157
  switch (aStatus) {
158
    case KMMsgStatusRead:
158
    case KMMsgStatusRead:
Lines 300-306 Link Here
300
void KMMsgBase::setEncryptionState( const KMMsgEncryptionState /*status*/, int idx )
300
void KMMsgBase::setEncryptionState( const KMMsgEncryptionState /*status*/, int idx )
301
{
301
{
302
    //kdDebug(5006) << "***setEncryptionState1( " << status << " )" << endl;
302
    //kdDebug(5006) << "***setEncryptionState1( " << status << " )" << endl;
303
    mDirty = TRUE;
303
    mDirty = true;
304
    if (storage())
304
    if (storage())
305
        storage()->headerOfMsgChanged(this, idx);
305
        storage()->headerOfMsgChanged(this, idx);
306
}
306
}
Lines 325-331 Link Here
325
void KMMsgBase::setSignatureState( const KMMsgSignatureState /*status*/, int idx )
325
void KMMsgBase::setSignatureState( const KMMsgSignatureState /*status*/, int idx )
326
{
326
{
327
    //kdDebug(5006) << "***setSignatureState1( " << status << " )" << endl;
327
    //kdDebug(5006) << "***setSignatureState1( " << status << " )" << endl;
328
    mDirty = TRUE;
328
    mDirty = true;
329
    if (storage())
329
    if (storage())
330
         storage()->headerOfMsgChanged(this, idx);
330
         storage()->headerOfMsgChanged(this, idx);
331
}
331
}
Lines 542-548 Link Here
542
  QString str = aStr;
542
  QString str = aStr;
543
543
544
  while (str[0] == ' ') str.remove(0,1);
544
  while (str[0] == ' ') str.remove(0,1);
545
  if (hasKeyword) *hasKeyword=FALSE;
545
  if (hasKeyword) *hasKeyword=false;
546
546
547
  unsigned int strLength(str.length());
547
  unsigned int strLength(str.length());
548
  for (i=0; i < strLength && i < maxChars; i++)
548
  for (i=0; i < strLength && i < maxChars; i++)
Lines 555-561 Link Here
555
    do {
555
    do {
556
      i++;
556
      i++;
557
    } while (str[i] == ' ');
557
    } while (str[i] == ' ');
558
    if (hasKeyword) *hasKeyword=TRUE;
558
    if (hasKeyword) *hasKeyword=true;
559
    return str.mid(i);
559
    return str.mid(i);
560
  }
560
  }
561
  return str;
561
  return str;
Lines 604-610 Link Here
604
    {
604
    {
605
      encodings.append(KGlobal::charsets()->languageForEncoding(*it)
605
      encodings.append(KGlobal::charsets()->languageForEncoding(*it)
606
        + " ( " + mimeName + " )");
606
        + " ( " + mimeName + " )");
607
      mimeNames.insert(mimeName, TRUE);
607
      mimeNames.insert(mimeName, true);
608
    }
608
    }
609
  }
609
  }
610
  encodings.sort();
610
  encodings.sort();
Lines 686-692 Link Here
686
    if (pos[0]!='=' || pos[1]!='?') {
686
    if (pos[0]!='=' || pos[1]!='?') {
687
      result += LWSP_buffer + pos[0];
687
      result += LWSP_buffer + pos[0];
688
      LWSP_buffer = 0;
688
      LWSP_buffer = 0;
689
      lastWasEncodedWord = FALSE;
689
      lastWasEncodedWord = false;
690
      continue;
690
      continue;
691
    }
691
    }
692
    // found possible encoded-word
692
    // found possible encoded-word
Lines 789-795 Link Here
789
789
790
  unsigned int start, stop, p, pos = 0, encLength;
790
  unsigned int start, stop, p, pos = 0, encLength;
791
  QCString result;
791
  QCString result;
792
  bool breakLine = FALSE;
792
  bool breakLine = false;
793
  const unsigned int maxLen = 75 - 7 - cset.length();
793
  const unsigned int maxLen = 75 - 7 - cset.length();
794
794
795
  while (pos < strLength)
795
  while (pos < strLength)
Lines 960-967 Link Here
960
      pattern += QString::number(n) + "[*]?";
960
      pattern += QString::number(n) + "[*]?";
961
    }
961
    }
962
    pattern += "=";
962
    pattern += "=";
963
    
963
964
    QRegExp fnamePart( pattern, FALSE );
964
    QRegExp fnamePart( pattern, false );
965
    int startPart = fnamePart.search( aStr );
965
    int startPart = fnamePart.search( aStr );
966
    int endPart;
966
    int endPart;
967
    found = ( startPart >= 0 );
967
    found = ( startPart >= 0 );
Lines 1112-1130 Link Here
1112
  QString ret;
1112
  QString ret;
1113
1113
1114
  g_chunk_offset = 0;
1114
  g_chunk_offset = 0;
1115
  bool using_mmap = FALSE;
1115
  bool using_mmap = false;
1116
  bool swapByteOrder = storage()->indexSwapByteOrder();
1116
  bool swapByteOrder = storage()->indexSwapByteOrder();
1117
  if (storage()->indexStreamBasePtr()) {
1117
  if (storage()->indexStreamBasePtr()) {
1118
    if (g_chunk)
1118
    if (g_chunk)
1119
	free(g_chunk);
1119
      free(g_chunk);
1120
    using_mmap = TRUE;
1120
    using_mmap = true;
1121
    g_chunk = storage()->indexStreamBasePtr() + mIndexOffset;
1121
    g_chunk = storage()->indexStreamBasePtr() + mIndexOffset;
1122
    g_chunk_length = mIndexLength;
1122
    g_chunk_length = mIndexLength;
1123
  } else {
1123
  } else {
1124
    if(!storage()->mIndexStream)
1124
    if(!storage()->mIndexStream)
1125
      return ret;
1125
      return ret;
1126
    if (g_chunk_length < mIndexLength)
1126
    if (g_chunk_length < mIndexLength)
1127
	g_chunk = (uchar *)realloc(g_chunk, g_chunk_length = mIndexLength);
1127
      g_chunk = (uchar *)realloc(g_chunk, g_chunk_length = mIndexLength);
1128
    off_t first_off=ftell(storage()->mIndexStream);
1128
    off_t first_off=ftell(storage()->mIndexStream);
1129
    fseek(storage()->mIndexStream, mIndexOffset, SEEK_SET);
1129
    fseek(storage()->mIndexStream, mIndexOffset, SEEK_SET);
1130
    fread( g_chunk, mIndexLength, 1, storage()->mIndexStream);
1130
    fread( g_chunk, mIndexLength, 1, storage()->mIndexStream);
Lines 1181-1193 Link Here
1181
  off_t ret = 0;
1181
  off_t ret = 0;
1182
1182
1183
  g_chunk_offset = 0;
1183
  g_chunk_offset = 0;
1184
  bool using_mmap = FALSE;
1184
  bool using_mmap = false;
1185
  int sizeOfLong = storage()->indexSizeOfLong();
1185
  int sizeOfLong = storage()->indexSizeOfLong();
1186
  bool swapByteOrder = storage()->indexSwapByteOrder();
1186
  bool swapByteOrder = storage()->indexSwapByteOrder();
1187
  if (storage()->indexStreamBasePtr()) {
1187
  if (storage()->indexStreamBasePtr()) {
1188
    if (g_chunk)
1188
    if (g_chunk)
1189
      free(g_chunk);
1189
      free(g_chunk);
1190
    using_mmap = TRUE;
1190
    using_mmap = true;
1191
    g_chunk = storage()->indexStreamBasePtr() + mIndexOffset;
1191
    g_chunk = storage()->indexStreamBasePtr() + mIndexOffset;
1192
    g_chunk_length = mIndexLength;
1192
    g_chunk_length = mIndexLength;
1193
  } else {
1193
  } else {
Lines 1371-1377 Link Here
1371
bool KMMsgBase::syncIndexString() const
1371
bool KMMsgBase::syncIndexString() const
1372
{
1372
{
1373
  if(!dirty())
1373
  if(!dirty())
1374
    return TRUE;
1374
    return true;
1375
  int len;
1375
  int len;
1376
  const uchar *buffer = asIndexString(len);
1376
  const uchar *buffer = asIndexString(len);
1377
  if (len == mIndexLength) {
1377
  if (len == mIndexLength) {
Lines 1379-1387 Link Here
1379
    fseek(storage()->mIndexStream, mIndexOffset, SEEK_SET);
1379
    fseek(storage()->mIndexStream, mIndexOffset, SEEK_SET);
1380
    assert( mIndexOffset > 0 );
1380
    assert( mIndexOffset > 0 );
1381
    fwrite( buffer, len, 1, storage()->mIndexStream);
1381
    fwrite( buffer, len, 1, storage()->mIndexStream);
1382
    return TRUE;
1382
    return true;
1383
  }
1383
  }
1384
  return FALSE;
1384
  return false;
1385
}
1385
}
1386
1386
1387
static QStringList sReplySubjPrefixes, sForwardSubjPrefixes;
1387
static QStringList sReplySubjPrefixes, sForwardSubjPrefixes;
(-)kmail/kmmsgdict.cpp (-2 / +15 lines)
Lines 16-21 Link Here
16
#include <stdio.h>
16
#include <stdio.h>
17
#include <unistd.h>
17
#include <unistd.h>
18
18
19
#include <string.h>
19
#include <errno.h>
20
#include <errno.h>
20
21
21
#include <config.h>
22
#include <config.h>
Lines 73-80 Link Here
73
  KMMsgDictREntry(int size = 0)
74
  KMMsgDictREntry(int size = 0)
74
  {
75
  {
75
    array.resize(size);
76
    array.resize(size);
76
    for (int i = 0; i < size; i++)
77
    memset(array.data(), 0, array.size() * sizeof(KMMsgDictEntry *));  // faster than a loop
77
      array.at(i) = 0;
78
    fp = 0;
78
    fp = 0;
79
    swapByteOrder = false;
79
    swapByteOrder = false;
80
    baseOffset = 0;
80
    baseOffset = 0;
Lines 412-417 Link Here
412
  if (swapByteOrder)
412
  if (swapByteOrder)
413
     count = kmail_swap_32(count);
413
     count = kmail_swap_32(count);
414
414
415
  // quick consistency check to avoid allocating huge amount of memory
416
  // due to reading corrupt file (#71549)
417
  long pos = ftell(fp);       // store current position
418
  fseek(fp, 0, SEEK_END);
419
  long fileSize = ftell(fp);  // how large is the file ?
420
  fseek(fp, pos, SEEK_SET);   // back to previous position
421
422
  // the file must at least contain what we try to read below
423
  if ( (fileSize - pos) < (long)(count * sizeof(Q_UINT32)) ) {
424
    fclose(fp);
425
    return -1;
426
  }
427
415
  KMMsgDictREntry *rentry = new KMMsgDictREntry(count);
428
  KMMsgDictREntry *rentry = new KMMsgDictREntry(count);
416
429
417
  for (unsigned int index = 0; index < count; index++) {
430
  for (unsigned int index = 0; index < count; index++) {
(-)kmail/kmmsgpart.cpp (-18 / +68 lines)
Lines 10-15 Link Here
10
#include "kmkernel.h"
10
#include "kmkernel.h"
11
#include "kmmessage.h"
11
#include "kmmessage.h"
12
#include "globalsettings.h"
12
#include "globalsettings.h"
13
#include "util.h"
13
14
14
#include <kasciistringtools.h>
15
#include <kasciistringtools.h>
15
#include <kmime_charfreq.h>
16
#include <kmime_charfreq.h>
Lines 102-108 Link Here
102
//-----------------------------------------------------------------------------
103
//-----------------------------------------------------------------------------
103
void KMMessagePart::setBody(const QCString &aStr)
104
void KMMessagePart::setBody(const QCString &aStr)
104
{
105
{
105
  mBody.duplicate( aStr.data(), aStr.length() );
106
  KMail::Util::setFromQCString( mBody, aStr );
107
108
  int enc = cte();
109
  if (enc == DwMime::kCte7bit || enc == DwMime::kCte8bit || enc == DwMime::kCteBinary)
110
    mBodyDecodedSize = mBody.size();
111
  else
112
    mBodyDecodedSize = -1; // Can't know the decoded size
113
}
114
115
void KMMessagePart::setBody(const DwString &aStr)
116
{
117
  mBody.duplicate( aStr.c_str(), aStr.length() );
118
119
  int enc = cte();
120
  if (enc == DwMime::kCte7bit || enc == DwMime::kCte8bit || enc == DwMime::kCteBinary)
121
    mBodyDecodedSize = mBody.size();
122
  else
123
    mBodyDecodedSize = -1; // Can't know the decoded size
124
}
125
126
void KMMessagePart::setBody(const QByteArray &aStr)
127
{
128
  mBody = aStr;
106
129
107
  int enc = cte();
130
  int enc = cte();
108
  if (enc == DwMime::kCte7bit || enc == DwMime::kCte8bit || enc == DwMime::kCteBinary)
131
  if (enc == DwMime::kCte7bit || enc == DwMime::kCte8bit || enc == DwMime::kCteBinary)
Lines 161-168 Link Here
161
//-----------------------------------------------------------------------------
184
//-----------------------------------------------------------------------------
162
void KMMessagePart::setBodyEncoded(const QCString& aStr)
185
void KMMessagePart::setBodyEncoded(const QCString& aStr)
163
{
186
{
164
  mBodyDecodedSize = aStr.length();
187
  mBodyDecodedSize = aStr.size() - 1; // same as aStr.length() but faster - assuming no embedded nuls
165
166
  switch (cte())
188
  switch (cte())
167
  {
189
  {
168
  case DwMime::kCteQuotedPrintable:
190
  case DwMime::kCteQuotedPrintable:
Lines 191-196 Link Here
191
  case DwMime::kCte7bit:
213
  case DwMime::kCte7bit:
192
  case DwMime::kCte8bit:
214
  case DwMime::kCte8bit:
193
  case DwMime::kCteBinary:
215
  case DwMime::kCteBinary:
216
    // This is slow and memory hungry - consider using setBodyEncodedBinary instead!
194
    mBody.duplicate( aStr.data(), mBodyDecodedSize );
217
    mBody.duplicate( aStr.data(), mBodyDecodedSize );
195
    break;
218
    break;
196
  }
219
  }
Lines 224-230 Link Here
224
				       bool allow8Bit,
247
				       bool allow8Bit,
225
                                       bool willBeSigned )
248
                                       bool willBeSigned )
226
{
249
{
227
  mBodyDecodedSize = aBuf.length();
250
  mBodyDecodedSize = aBuf.size() - 1; // same as aStr.length() but faster - assuming no embedded nuls
228
251
229
  CharFreq cf( aBuf.data(), mBodyDecodedSize ); // save to pass null strings
252
  CharFreq cf( aBuf.data(), mBodyDecodedSize ); // save to pass null strings
230
253
Lines 270-280 Link Here
270
  case DwMime::kCte7bit:
293
  case DwMime::kCte7bit:
271
  case DwMime::kCte8bit:
294
  case DwMime::kCte8bit:
272
  case DwMime::kCteBinary:
295
  case DwMime::kCteBinary:
273
    mBody.duplicate( aStr );
296
    //mBody.duplicate( aStr );
297
    mBody = aStr;
298
    // Caller has to detach before it modifies aStr!
274
    break;
299
    break;
275
  }
300
  }
276
}
301
}
277
302
303
//-----------------------------------------------------------------------------
304
void KMMessagePart::setMessageBody( const QByteArray& aBuf )
305
{
306
  CharFreq cf( aBuf ); // it's safe to pass null arrays
307
  mBodyDecodedSize = aBuf.size();
308
309
  int cte;
310
  switch ( cf.type() ) {
311
  case CharFreq::SevenBitText:
312
  case CharFreq::SevenBitData:
313
     cte = DwMime::kCte7bit;
314
     break;
315
  case CharFreq::EightBitText:
316
  case CharFreq::EightBitData:
317
     cte = DwMime::kCte8bit;
318
     break;
319
  default:
320
     kdWarning(5006) << "Calling " << k_funcinfo
321
         << " with something containing neither 7 nor 8 bit text!"
322
         << " Fix this caller: " << kdBacktrace() << endl;
323
  }
324
  setCte( cte );
325
  setBodyEncodedBinary( aBuf );
326
}
278
327
279
//-----------------------------------------------------------------------------
328
//-----------------------------------------------------------------------------
280
QByteArray KMMessagePart::bodyDecodedBinary() const
329
QByteArray KMMessagePart::bodyDecodedBinary() const
Lines 348-360 Link Here
348
397
349
  if ( decodeBinary ) {
398
  if ( decodeBinary ) {
350
    len = mBody.size();
399
    len = mBody.size();
351
    result.resize( len+1 /* trailing NUL */ );
400
    KMail::Util::setFromByteArray( result, mBody );
352
    memcpy(result.data(), mBody.data(), len);
353
    result[len] = 0;
354
  }
401
  }
355
402
356
  kdWarning( result.length() != (unsigned int)len, 5006 )
403
  // Calls length -> slow
357
    << "KMMessagePart::bodyDecoded(): body is binary but used as text!" << endl;
404
  //kdWarning( result.length() != (unsigned int)len, 5006 )
405
  //  << "KMMessagePart::bodyDecoded(): body is binary but used as text!" << endl;
358
406
359
  result = result.replace( "\r\n", "\n" ); // CRLF -> LF conversion
407
  result = result.replace( "\r\n", "\n" ); // CRLF -> LF conversion
360
408
Lines 505-521 Link Here
505
QString KMMessagePart::fileName(void) const
553
QString KMMessagePart::fileName(void) const
506
{
554
{
507
  QCString str;
555
  QCString str;
508
  
556
509
  // Allow for multiple filname*0, filename*1, ... params (defined by RFC 2231) 
557
  // Allow for multiple filname*0, filename*1, ... params (defined by RFC 2231)
510
  // in the Content-Disposision
558
  // in the Content-Disposision
511
  if ( mContentDisposition.contains( "filename*", FALSE ) ) {
559
  if ( mContentDisposition.contains( "filename*", FALSE ) ) {
512
  
560
513
    // It's RFC 2231 encoded, so extract the file name with the 2231 method
561
    // It's RFC 2231 encoded, so extract the file name with the 2231 method
514
    str = KMMsgBase::extractRFC2231HeaderField( mContentDisposition, "filename" );
562
    str = KMMsgBase::extractRFC2231HeaderField( mContentDisposition, "filename" );
515
    return KMMsgBase::decodeRFC2231String(str);
563
    return KMMsgBase::decodeRFC2231String(str);
516
  
564
517
  } else {
565
  } else {
518
    
566
519
    // Standard RFC 2047-encoded
567
    // Standard RFC 2047-encoded
520
    // search the start of the filename
568
    // search the start of the filename
521
    int startOfFilename = mContentDisposition.find("filename=", 0, FALSE);
569
    int startOfFilename = mContentDisposition.find("filename=", 0, FALSE);
Lines 540-553 Link Here
540
                           .stripWhiteSpace();
588
                           .stripWhiteSpace();
541
    return KMMsgBase::decodeRFC2047String(str, charset());
589
    return KMMsgBase::decodeRFC2047String(str, charset());
542
  }
590
  }
543
  
591
544
  return QString::null;
592
  return QString::null;
545
}
593
}
546
594
547
548
549
QCString KMMessagePart::body() const
595
QCString KMMessagePart::body() const
550
{
596
{
551
  return QCString( mBody.data(), mBody.size() + 1 ); // space for trailing NUL
597
  return QCString( mBody.data(), mBody.size() + 1 ); // space for trailing NUL
552
}
598
}
553
599
600
DwString KMMessagePart::dwBody() const
601
{
602
  return KMail::Util::dwString( mBody );
603
}
(-)kmail/kmmsgpart.h (-9 / +27 lines)
Lines 27-32 Link Here
27
template <typename T>
27
template <typename T>
28
class QValueList;
28
class QValueList;
29
class QTextCodec;
29
class QTextCodec;
30
class DwString;
30
31
31
class KMMessagePart
32
class KMMessagePart
32
{
33
{
Lines 45-50 Link Here
45
  /** Get or set the message body */
46
  /** Get or set the message body */
46
  QCString body(void) const;
47
  QCString body(void) const;
47
  void setBody(const QCString &aStr);
48
  void setBody(const QCString &aStr);
49
  DwString dwBody() const;
50
  void setBody(const DwString &aStr);
51
  // warning, doesn't detach from 'arr'
52
  void setBody(const QByteArray &arr);
48
53
49
  /** Sets this body part's content to @p str. @p str is subject to
54
  /** Sets this body part's content to @p str. @p str is subject to
50
      automatic charset and CTE detection.
55
      automatic charset and CTE detection.
Lines 58-68 Link Here
58
  /** Returns body as decoded string. Assumes that content-transfer-encoding
63
  /** Returns body as decoded string. Assumes that content-transfer-encoding
59
    contains the correct encoding. This routine is meant for binary data.
64
    contains the correct encoding. This routine is meant for binary data.
60
    No trailing 0 is appended. */
65
    No trailing 0 is appended. */
61
  virtual QByteArray bodyDecodedBinary(void) const;
66
  QByteArray bodyDecodedBinary(void) const;
62
67
63
  /** Returns body as decoded string. Assumes that content-transfer-encoding
68
  /** Returns body as decoded string. Assumes that content-transfer-encoding
64
      contains the correct encoding. This routine is meant for text strings! */
69
      contains the correct encoding. This routine is meant for text strings! */
65
  virtual QCString bodyDecoded(void) const;
70
  QCString bodyDecoded(void) const;
66
71
67
  /** Sets body, encoded in the best fitting
72
  /** Sets body, encoded in the best fitting
68
      content-transfer-encoding, which is determined by character
73
      content-transfer-encoding, which is determined by character
Lines 73-98 Link Here
73
      @param allow8Bit  whether "8bit" is allowed as cte.
78
      @param allow8Bit  whether "8bit" is allowed as cte.
74
      @param willBeSigned whether "7bit"/"8bit" is allowed as cte according to RFC 3156
79
      @param willBeSigned whether "7bit"/"8bit" is allowed as cte according to RFC 3156
75
  */
80
  */
76
  virtual void setBodyAndGuessCte(const QByteArray& aBuf,
81
  void setBodyAndGuessCte(const QByteArray& aBuf,
77
				  QValueList<int>& allowedCte,
82
				  QValueList<int>& allowedCte,
78
				  bool allow8Bit = false,
83
				  bool allow8Bit = false,
79
                                  bool willBeSigned = false);
84
                                  bool willBeSigned = false);
80
  /** Same for text */
85
  /** Same for text */
81
  virtual void setBodyAndGuessCte(const QCString& aBuf,
86
  void setBodyAndGuessCte(const QCString& aBuf,
82
				  QValueList<int>& allowedCte,
87
				  QValueList<int>& allowedCte,
83
				  bool allow8Bit = false,
88
				  bool allow8Bit = false,
84
                                  bool willBeSigned = false);
89
                                  bool willBeSigned = false);
85
90
86
  /** Sets body, encoded according to the content-transfer-encoding.
91
  /** Sets body, encoded according to the content-transfer-encoding.
87
      BEWARE: The entire aStr is used including trailing 0 of text strings! */
92
      BEWARE: The entire aStr is used including trailing 0 of text strings!
88
  virtual void setBodyEncodedBinary(const QByteArray& aStr);
93
      This version is faster than setBodyEncoded, no duplication necessary.
94
    */
95
  void setBodyEncodedBinary(const QByteArray& aStr);
89
96
90
  /** Sets body, encoded according to the content-transfer-encoding.
97
  /** Sets body, encoded according to the content-transfer-encoding.
91
      This one is for text strings, the trailing 0 is not used. */
98
      This one is for text strings, the trailing 0 is not used.
92
  virtual void setBodyEncoded(const QCString& aStr);
99
100
      For speed reasons, prefer setBodyEncodedBinary.
101
      When possible (the QCString isn't used afterwards), change setBodyEncoded(myQCString) into:
102
       setBodyEncodedBinary(byteArrayFromQCStringNoDetach(myQCString));
103
  */
104
 void setBodyEncoded(const QCString& aStr);
105
106
  /** Set a full message string as the body of the message part,
107
      disallowing anything but 7bit or 8bit encoding.
108
      (RFC 1521 section 7.3)
109
  */
110
 void setMessageBody( const QByteArray & aBuf );
93
111
94
  /** Returns decoded length of body. */
112
  /** Returns decoded length of body. */
95
  virtual int decodedSize(void) const;
113
  int decodedSize(void) const;
96
114
97
  /** Get or set the 'Content-Type' header field
115
  /** Get or set the 'Content-Type' header field
98
   The member functions that involve enumerated types (ints)
116
   The member functions that involve enumerated types (ints)
(-)kmail/kmreadermainwin.cpp (-2 / +2 lines)
Lines 132-144 Link Here
132
  KMMsgDict::instance()->getLocation( mMsg->getMsgSerNum(), &parent, &index );
132
  KMMsgDict::instance()->getLocation( mMsg->getMsgSerNum(), &parent, &index );
133
  if ( parent && !parent->isTrash() ) {
133
  if ( parent && !parent->isTrash() ) {
134
    // open the folder (ref counted)
134
    // open the folder (ref counted)
135
    parent->open();
135
    parent->open("trashmsg");
136
    KMMessage *msg = parent->getMsg( index );
136
    KMMessage *msg = parent->getMsg( index );
137
    if (msg) {
137
    if (msg) {
138
      KMDeleteMsgCommand *command = new KMDeleteMsgCommand( parent, msg );
138
      KMDeleteMsgCommand *command = new KMDeleteMsgCommand( parent, msg );
139
      command->start();
139
      command->start();
140
    }
140
    }
141
    parent->close();
141
    parent->close("trashmsg");
142
  }
142
  }
143
  close();
143
  close();
144
}
144
}
(-)kmail/kmreaderwin.cpp (-10 / +19 lines)
Lines 636-648 Link Here
636
  mSelectEncodingAction->setItems( encodings );
636
  mSelectEncodingAction->setItems( encodings );
637
  mSelectEncodingAction->setCurrentItem( 0 );
637
  mSelectEncodingAction->setCurrentItem( 0 );
638
638
639
  mMailToComposeAction = new KAction( i18n("New Message To..."), 0, this,
639
  mMailToComposeAction = new KAction( i18n("New Message To..."), "mail_new",
640
                                      SLOT(slotMailtoCompose()), ac,
640
                                      0, this, SLOT(slotMailtoCompose()), ac,
641
                                      "mailto_compose" );
641
                                      "mailto_compose" );
642
  mMailToReplyAction = new KAction( i18n("Reply To..."), 0, this,
642
  mMailToReplyAction = new KAction( i18n("Reply To..."), "mail_reply",
643
				    SLOT(slotMailtoReply()), ac,
643
                                    0, this, SLOT(slotMailtoReply()), ac,
644
				    "mailto_reply" );
644
				    "mailto_reply" );
645
  mMailToForwardAction = new KAction( i18n("Forward To..."),
645
  mMailToForwardAction = new KAction( i18n("Forward To..."), "mail_forward",
646
                                      0, this, SLOT(slotMailtoForward()), ac,
646
                                      0, this, SLOT(slotMailtoForward()), ac,
647
                                      "mailto_forward" );
647
                                      "mailto_forward" );
648
  mAddAddrBookAction = new KAction( i18n("Add to Address Book"),
648
  mAddAddrBookAction = new KAction( i18n("Add to Address Book"),
Lines 1354-1360 Link Here
1354
	     "<p style='margin-bottom: 0px'>&nbsp; &nbsp; The KMail Team</p>")
1354
	     "<p style='margin-bottom: 0px'>&nbsp; &nbsp; The KMail Team</p>")
1355
    .arg(KMAIL_VERSION) // KMail version
1355
    .arg(KMAIL_VERSION) // KMail version
1356
    .arg("help:/kmail/index.html") // KMail help:// URL
1356
    .arg("help:/kmail/index.html") // KMail help:// URL
1357
    .arg("http://kmail.kde.org/") // KMail homepage URL
1357
    .arg("http://kontact.kde.org/kmail/") // KMail homepage URL
1358
    .arg("1.8").arg("3.4"); // prior KMail and KDE version
1358
    .arg("1.8").arg("3.4"); // prior KMail and KDE version
1359
1359
1360
  QString featureItems;
1360
  QString featureItems;
Lines 1504-1510 Link Here
1504
1504
1505
  assert(aMsg!=0);
1505
  assert(aMsg!=0);
1506
1506
1507
  delete mRootNode;
1507
  aMsg->setIsBeingParsed( true );
1508
1509
  if ( mRootNode && !mRootNode->processed() )
1510
  {
1511
    kdWarning() << "The root node is not yet processed! Danger!\n";
1512
    return;
1513
  } else
1514
    delete mRootNode;
1508
  mRootNode = partNode::fromMessage( aMsg );
1515
  mRootNode = partNode::fromMessage( aMsg );
1509
  const QCString mainCntTypeStr = mRootNode->typeString() + '/' + mRootNode->subTypeString();
1516
  const QCString mainCntTypeStr = mRootNode->typeString() + '/' + mRootNode->subTypeString();
1510
1517
Lines 1614-1626 Link Here
1614
      unencryptedMessage->setParent( 0 );
1621
      unencryptedMessage->setParent( 0 );
1615
      // because this did not work:
1622
      // because this did not work:
1616
      /*
1623
      /*
1617
      DwMessage dwMsg( DwString( aMsg->asString() ) );
1624
      DwMessage dwMsg( aMsg->asDwString() );
1618
      dwMsg.Body() = DwBody( DwString( resultString.data() ) );
1625
      dwMsg.Body() = DwBody( DwString( resultString.data() ) );
1619
      dwMsg.Body().Parse();
1626
      dwMsg.Body().Parse();
1620
      KMMessage* unencryptedMessage = new KMMessage( &dwMsg );
1627
      KMMessage* unencryptedMessage = new KMMessage( &dwMsg );
1621
      */
1628
      */
1622
kdDebug(5006) << "KMReaderWin  -  resulting message:" << unencryptedMessage->asString() << endl;
1629
      //kdDebug(5006) << "KMReaderWin  -  resulting message:" << unencryptedMessage->asString() << endl;
1623
kdDebug(5006) << "KMReaderWin  -  attach unencrypted message to aMsg" << endl;
1630
      kdDebug(5006) << "KMReaderWin  -  attach unencrypted message to aMsg" << endl;
1624
      aMsg->setUnencryptedMsg( unencryptedMessage );
1631
      aMsg->setUnencryptedMsg( unencryptedMessage );
1625
      emitReplaceMsgByUnencryptedVersion = true;
1632
      emitReplaceMsgByUnencryptedVersion = true;
1626
    }
1633
    }
Lines 1642-1647 Link Here
1642
    showHideMimeTree( rootNodeCntType == DwMime::kTypeText &&
1649
    showHideMimeTree( rootNodeCntType == DwMime::kTypeText &&
1643
		      rootNodeCntSubtype == DwMime::kSubtypePlain );
1650
		      rootNodeCntSubtype == DwMime::kSubtypePlain );
1644
  }
1651
  }
1652
1653
  aMsg->setIsBeingParsed( false );
1645
}
1654
}
1646
1655
1647
1656
(-)kmail/kmsearchpattern.cpp (-2 / +2 lines)
Lines 762-768 Link Here
762
762
763
  bool opened = folder->isOpened();
763
  bool opened = folder->isOpened();
764
  if ( !opened )
764
  if ( !opened )
765
    folder->open();
765
    folder->open("searchptr");
766
  KMMsgBase *msgBase = folder->getMsgBase(idx);
766
  KMMsgBase *msgBase = folder->getMsgBase(idx);
767
  if (requiresBody() && !ignoreBody) {
767
  if (requiresBody() && !ignoreBody) {
768
    bool unGet = !msgBase->isMessage();
768
    bool unGet = !msgBase->isMessage();
Lines 774-780 Link Here
774
    res = matches( folder->getDwString(idx), ignoreBody );
774
    res = matches( folder->getDwString(idx), ignoreBody );
775
  }
775
  }
776
  if ( !opened )
776
  if ( !opened )
777
    folder->close();
777
    folder->close("searchptr");
778
  return res;
778
  return res;
779
}
779
}
780
780
(-)kmail/kmsender.cpp (-17 / +17 lines)
Lines 161-168 Link Here
161
161
162
  if (sendNow==-1) sendNow = mSendImmediate;
162
  if (sendNow==-1) sendNow = mSendImmediate;
163
163
164
  kmkernel->outboxFolder()->open();
164
  kmkernel->outboxFolder()->open("outbox");
165
  const KMFolderCloser openOutbox( kmkernel->outboxFolder() );
165
  const KMFolderCloser openOutbox( "outbox", kmkernel->outboxFolder() );
166
166
167
  aMsg->setStatus(KMMsgStatusQueued);
167
  aMsg->setStatus(KMMsgStatusQueued);
168
168
Lines 219-229 Link Here
219
219
220
  // open necessary folders
220
  // open necessary folders
221
  mOutboxFolder = kmkernel->outboxFolder();
221
  mOutboxFolder = kmkernel->outboxFolder();
222
  mOutboxFolder->open();
222
  mOutboxFolder->open("dosendoutbox");
223
  mTotalMessages = mOutboxFolder->count();
223
  mTotalMessages = mOutboxFolder->count();
224
  if (mTotalMessages == 0) {
224
  if (mTotalMessages == 0) {
225
    // Nothing in the outbox. We are done.
225
    // Nothing in the outbox. We are done.
226
    mOutboxFolder->close();
226
    mOutboxFolder->close("dosendoutbox");
227
    mOutboxFolder = 0;
227
    mOutboxFolder = 0;
228
    return TRUE;
228
    return TRUE;
229
  }
229
  }
Lines 236-242 Link Here
236
  mCurrentMsg = 0;
236
  mCurrentMsg = 0;
237
237
238
  mSentFolder = kmkernel->sentFolder();
238
  mSentFolder = kmkernel->sentFolder();
239
  mSentFolder->open();
239
  mSentFolder->open("dosendsent");
240
  kmkernel->filterMgr()->ref();
240
  kmkernel->filterMgr()->ref();
241
241
242
  // start sending the messages
242
  // start sending the messages
Lines 352-358 Link Here
352
      sentFolder = kmkernel->sentFolder();
352
      sentFolder = kmkernel->sentFolder();
353
353
354
    if ( sentFolder ) {
354
    if ( sentFolder ) {
355
      if ( const int err = sentFolder->open() ) {
355
      if ( const int err = sentFolder->open("sentFolder") ) {
356
        Q_UNUSED( err );
356
        Q_UNUSED( err );
357
        cleanup();
357
        cleanup();
358
        return;
358
        return;
Lines 375-381 Link Here
375
                   "Moving failing message to \"sent-mail\" folder."));
375
                   "Moving failing message to \"sent-mail\" folder."));
376
      if ( sentFolder ) {
376
      if ( sentFolder ) {
377
        sentFolder->moveMsg(mCurrentMsg);
377
        sentFolder->moveMsg(mCurrentMsg);
378
        sentFolder->close();
378
        sentFolder->close("sentFolder");
379
      }
379
      }
380
      cleanup();
380
      cleanup();
381
      return;
381
      return;
Lines 446-452 Link Here
446
    	mCurrentMsg = 0;
446
    	mCurrentMsg = 0;
447
    // no more message: cleanup and done
447
    // no more message: cleanup and done
448
    if ( sentFolder != 0 )
448
    if ( sentFolder != 0 )
449
        sentFolder->close();
449
        sentFolder->close("sentFolder");
450
    if ( someSent ) {
450
    if ( someSent ) {
451
      if ( mSentMessages == mTotalMessages ) {
451
      if ( mSentMessages == mTotalMessages ) {
452
        setStatusMsg(i18n("%n queued message successfully sent.",
452
        setStatusMsg(i18n("%n queued message successfully sent.",
Lines 605-611 Link Here
605
  if ( messageIsDispositionNotificationReport( mCurrentMsg ) && GlobalSettings::self()->sendMDNsWithEmptySender() )
605
  if ( messageIsDispositionNotificationReport( mCurrentMsg ) && GlobalSettings::self()->sendMDNsWithEmptySender() )
606
    sender = "<>";
606
    sender = "<>";
607
607
608
  const QCString message = mCurrentMsg->asSendableString();
608
  const QByteArray message = mCurrentMsg->asSendableString();
609
  if ( sender.isEmpty() || !mSendProc->send( sender, to, cc, bcc, message ) ) {
609
  if ( sender.isEmpty() || !mSendProc->send( sender, to, cc, bcc, message ) ) {
610
    if ( mCurrentMsg )
610
    if ( mCurrentMsg )
611
      mCurrentMsg->setTransferInProgress( false );
611
      mCurrentMsg->setTransferInProgress( false );
Lines 636-648 Link Here
636
    mCurrentMsg = 0;
636
    mCurrentMsg = 0;
637
  }
637
  }
638
  if ( mSentFolder ) {
638
  if ( mSentFolder ) {
639
    mSentFolder->close();
639
    mSentFolder->close("dosendsent");
640
    mSentFolder = 0;
640
    mSentFolder = 0;
641
  }
641
  }
642
  if ( mOutboxFolder ) {
642
  if ( mOutboxFolder ) {
643
    disconnect( mOutboxFolder, SIGNAL(msgAdded(int)),
643
    disconnect( mOutboxFolder, SIGNAL(msgAdded(int)),
644
                this, SLOT(outboxMsgAdded(int)) );
644
                this, SLOT(outboxMsgAdded(int)) );
645
    mOutboxFolder->close();
645
    mOutboxFolder->close("dosendoutbox");
646
    if ( mOutboxFolder->count( true ) == 0 ) {
646
    if ( mOutboxFolder->count( true ) == 0 ) {
647
      mOutboxFolder->expunge();
647
      mOutboxFolder->expunge();
648
    }
648
    }
Lines 854-860 Link Here
854
    int index = -1;
854
    int index = -1;
855
    KMMsgDict::instance()->getLocation(msn, &folder, &index);
855
    KMMsgDict::instance()->getLocation(msn, &folder, &index);
856
    if (folder && index != -1) {
856
    if (folder && index != -1) {
857
      folder->open();
857
      folder->open("setstatus");
858
      if ( status == KMMsgStatusDeleted ) {
858
      if ( status == KMMsgStatusDeleted ) {
859
        // Move the message to the trash folder
859
        // Move the message to the trash folder
860
        KMDeleteMsgCommand *cmd =
860
        KMDeleteMsgCommand *cmd =
Lines 863-869 Link Here
863
      } else {
863
      } else {
864
        folder->setStatus(index, status);
864
        folder->setStatus(index, status);
865
      }
865
      }
866
      folder->close();
866
      folder->close("setstatus");
867
    } else {
867
    } else {
868
      kdWarning(5006) << k_funcinfo << "Cannot update linked message, it could not be found!" << endl;
868
      kdWarning(5006) << k_funcinfo << "Cannot update linked message, it could not be found!" << endl;
869
    }
869
    }
Lines 963-969 Link Here
963
  idle();
963
  idle();
964
}
964
}
965
965
966
bool KMSendSendmail::doSend( const QString & sender, const QStringList & to, const QStringList & cc, const QStringList & bcc, const QCString & message ) {
966
bool KMSendSendmail::doSend( const QString & sender, const QStringList & to, const QStringList & cc, const QStringList & bcc, const QByteArray & message ) {
967
  mMailerProc->clearArguments();
967
  mMailerProc->clearArguments();
968
  *mMailerProc << mSender->transportInfo()->host
968
  *mMailerProc << mSender->transportInfo()->host
969
               << "-i" << "-f" << sender
969
               << "-i" << "-f" << sender
Lines 977-983 Link Here
977
    return false;
977
    return false;
978
  }
978
  }
979
  mMsgPos  = mMsgStr.data();
979
  mMsgPos  = mMsgStr.data();
980
  mMsgRest = mMsgStr.length();
980
  mMsgRest = mMsgStr.size();
981
  wroteStdin( mMailerProc );
981
  wroteStdin( mMailerProc );
982
982
983
  return true;
983
  return true;
Lines 1048-1054 Link Here
1048
  if (mJob) mJob->kill();
1048
  if (mJob) mJob->kill();
1049
}
1049
}
1050
1050
1051
bool KMSendSMTP::doSend( const QString & sender, const QStringList & to, const QStringList & cc, const QStringList & bcc, const QCString & message ) {
1051
bool KMSendSMTP::doSend( const QString & sender, const QStringList & to, const QStringList & cc, const QStringList & bcc, const QByteArray & message ) {
1052
  QString query = "headers=0&from=";
1052
  QString query = "headers=0&from=";
1053
  query += KURL::encode_string( sender );
1053
  query += KURL::encode_string( sender );
1054
1054
Lines 1119-1125 Link Here
1119
1119
1120
  // dotstuffing is now done by the slave (see setting of metadata)
1120
  // dotstuffing is now done by the slave (see setting of metadata)
1121
  mMessage = message;
1121
  mMessage = message;
1122
  mMessageLength = mMessage.length();
1122
  mMessageLength = mMessage.size();
1123
  mMessageOffset = 0;
1123
  mMessageOffset = 0;
1124
1124
1125
  if ( mMessageLength )
1125
  if ( mMessageLength )
(-)kmail/kmstartup.cpp (-5 / +29 lines)
Lines 36-45 Link Here
36
36
37
#include <errno.h>
37
#include <errno.h>
38
#include <sys/types.h>
38
#include <sys/types.h>
39
#include <sys/param.h>
39
#include <signal.h>
40
#include <signal.h>
40
#include <stdio.h>
41
#include <stdio.h>
41
#include <stdlib.h>
42
#include <stdlib.h>
42
#include <unistd.h>
43
#include <unistd.h>
44
#include <qfile.h>
43
45
44
#undef Status // stupid X headers
46
#undef Status // stupid X headers
45
47
Lines 154-165 Link Here
154
  bool first_instance = false;
156
  bool first_instance = false;
155
  if ( oldPid == -1 )
157
  if ( oldPid == -1 )
156
      first_instance = true;
158
      first_instance = true;
157
  // check if the lock file is stale by trying to see if
158
  // the other pid is currently running.
159
  // Not 100% correct but better safe than sorry
160
  else if (hostName == oldHostName && oldPid != getpid()) {
159
  else if (hostName == oldHostName && oldPid != getpid()) {
161
      if ( kill(oldPid, 0) == -1 )
160
      // check if the lock file is stale
162
          first_instance = ( errno == ESRCH );
161
#ifdef Q_OS_LINUX
162
      if ( ::access("/proc", X_OK ) == 0 ) {
163
          // On linux with /proc we can even check that it's really kmail and not something else
164
          char path_buffer[MAXPATHLEN + 1];
165
          path_buffer[MAXPATHLEN] = 0;
166
          const QString procPath = QString("/proc/%1/exe").arg(oldPid);
167
          const int length = readlink (procPath.latin1(), path_buffer, MAXPATHLEN);
168
          if ( length == -1 ) // not such pid
169
              first_instance = true;
170
          else {
171
              path_buffer[length] = '\0';
172
              const QString path = QFile::decodeName(path_buffer);
173
              kdDebug() << k_funcinfo << path << endl;
174
              const int pos = path.findRev('/');
175
              const QString fileName = path.mid(pos+1);
176
              kdDebug() << "Found process " << oldPid << " running. It's: " << fileName << endl;
177
              first_instance = fileName != "kmail" && fileName != "kontact";
178
          }
179
      } else
180
#endif
181
      {
182
          // Otherwise we just check if the other pid is currently running.
183
          // Not 100% correct but better safe than sorry.
184
          if ( kill(oldPid, 0) == -1 )
185
              first_instance = ( errno == ESRCH );
186
      }
163
  }
187
  }
164
188
165
  if ( !first_instance ) {
189
  if ( !first_instance ) {
(-)kmail/kmtransport.cpp (-2 / +2 lines)
Lines 126-140 Link Here
126
  if ( storePasswd() ) {
126
  if ( storePasswd() ) {
127
    // write password into the wallet if possible and necessary
127
    // write password into the wallet if possible and necessary
128
    bool passwdStored = false;
128
    bool passwdStored = false;
129
    Wallet *wallet = kmkernel->wallet();
129
    if ( mPasswdDirty ) {
130
    if ( mPasswdDirty ) {
130
      Wallet *wallet = kmkernel->wallet();
131
      if ( wallet && wallet->writePassword( "transport-" + QString::number(mId), passwd() ) == 0 ) {
131
      if ( wallet && wallet->writePassword( "transport-" + QString::number(mId), passwd() ) == 0 ) {
132
        passwdStored = true;
132
        passwdStored = true;
133
        mPasswdDirty = false;
133
        mPasswdDirty = false;
134
        mStorePasswdInConfig = false;
134
        mStorePasswdInConfig = false;
135
      }
135
      }
136
    } else {
136
    } else {
137
      passwdStored = !mStorePasswdInConfig; // already in the wallet
137
      passwdStored = wallet ? !mStorePasswdInConfig /*already in the wallet*/ : config->hasKey("pass");
138
    }
138
    }
139
    // wallet not available, ask the user if we should use the config file instead
139
    // wallet not available, ask the user if we should use the config file instead
140
    if ( !passwdStored && ( mStorePasswdInConfig ||  KMessageBox::warningYesNo( 0,
140
    if ( !passwdStored && ( mStorePasswdInConfig ||  KMessageBox::warningYesNo( 0,
(-)kmail/messagecomposer.cpp (-122 / +123 lines)
Lines 287-299 Link Here
287
287
288
MessageComposer::MessageComposer( KMComposeWin* win, const char* name )
288
MessageComposer::MessageComposer( KMComposeWin* win, const char* name )
289
  : QObject( win, name ), mComposeWin( win ), mCurrentJob( 0 ),
289
  : QObject( win, name ), mComposeWin( win ), mCurrentJob( 0 ),
290
    mKeyResolver( 0 ), mIdentityUid( 0 )
290
    mKeyResolver( 0 ), mIdentityUid( 0 ), mPerformingSignOperation( false )
291
{
291
{
292
}
292
}
293
293
294
MessageComposer::~MessageComposer()
294
MessageComposer::~MessageComposer()
295
{
295
{
296
  delete mKeyResolver; mKeyResolver = 0;
296
  delete mKeyResolver; mKeyResolver = 0;
297
  delete mNewBodyPart; mNewBodyPart = 0;
297
}
298
}
298
299
299
void MessageComposer::applyChanges( bool disableCrypto )
300
void MessageComposer::applyChanges( bool disableCrypto )
Lines 338-344 Link Here
338
339
339
  if( mJobs.isEmpty() ) {
340
  if( mJobs.isEmpty() ) {
340
    // No more jobs. Signal that we're done
341
    // No more jobs. Signal that we're done
341
    emit done( mRc );
342
    emitDone( mRc );
342
    return;
343
    return;
343
  }
344
  }
344
345
Lines 348-354 Link Here
348
      delete mJobs.front();
349
      delete mJobs.front();
349
      mJobs.pop_front();
350
      mJobs.pop_front();
350
    }
351
    }
351
    emit done( false );
352
    emitDone( false );
352
    return;
353
    return;
353
  }
354
  }
354
355
Lines 356-361 Link Here
356
  QTimer::singleShot( 0, this, SLOT( slotDoNextJob() ) );
357
  QTimer::singleShot( 0, this, SLOT( slotDoNextJob() ) );
357
}
358
}
358
359
360
void MessageComposer::emitDone( bool b )
361
{
362
  // Save memory - before sending the mail
363
  mEncodedBody = QByteArray();
364
  delete mNewBodyPart; mNewBodyPart = 0;
365
  mOldBodyPart.clear();
366
  emit done( b );
367
}
368
359
void MessageComposer::slotDoNextJob()
369
void MessageComposer::slotDoNextJob()
360
{
370
{
361
  assert( !mCurrentJob );
371
  assert( !mCurrentJob );
Lines 495-500 Link Here
495
  mIsRichText = mComposeWin->mEditor->textFormat() == Qt::RichText;
505
  mIsRichText = mComposeWin->mEditor->textFormat() == Qt::RichText;
496
  mIdentityUid = mComposeWin->identityUid();
506
  mIdentityUid = mComposeWin->identityUid();
497
  mText = breakLinesAndApplyCodec();
507
  mText = breakLinesAndApplyCodec();
508
  assert( mText.isEmpty() || mText[mText.size()-1] == '\n' );
498
  // Hopefully we can get rid of this eventually, it's needed to be able
509
  // Hopefully we can get rid of this eventually, it's needed to be able
499
  // to break the plain/text version of a multipart/alternative (html) mail
510
  // to break the plain/text version of a multipart/alternative (html) mail
500
  // according to the line breaks of the richtext version.
511
  // according to the line breaks of the richtext version.
Lines 1055-1061 Link Here
1055
static inline const char * nestedContentType( Kleo::CryptoMessageFormat f, bool signing ) {
1066
static inline const char * nestedContentType( Kleo::CryptoMessageFormat f, bool signing ) {
1056
  switch ( f ) {
1067
  switch ( f ) {
1057
  case Kleo::OpenPGPMIMEFormat:
1068
  case Kleo::OpenPGPMIMEFormat:
1058
    return signing ? "application/pgp-signature" : "application/octet-stream" ;
1069
    return signing ? "application/pgp-signature; name=signature.asc \nContent-Description: This is a digitally signed message part." : "application/octet-stream" ;
1059
  case Kleo::SMIMEFormat:
1070
  case Kleo::SMIMEFormat:
1060
    if ( signing )
1071
    if ( signing )
1061
      return "application/pkcs7-signature; name=\"smime.p7s\"";
1072
      return "application/pkcs7-signature; name=\"smime.p7s\"";
Lines 1115-1132 Link Here
1115
class EncryptMessageJob : public MessageComposerJob {
1126
class EncryptMessageJob : public MessageComposerJob {
1116
public:
1127
public:
1117
  EncryptMessageJob( KMMessage* msg, const Kleo::KeyResolver::SplitInfo & si,
1128
  EncryptMessageJob( KMMessage* msg, const Kleo::KeyResolver::SplitInfo & si,
1118
                     bool doSign, bool doEncrypt, const QCString& encodedBody,
1129
                     bool doSign, bool doEncrypt, const QByteArray& encodedBody,
1119
                     int boundaryLevel, const KMMessagePart& oldBodyPart,
1130
                     int boundaryLevel, /*const KMMessagePart& oldBodyPart,*/
1120
                     KMMessagePart* newBodyPart, Kleo::CryptoMessageFormat format,
1131
                     KMMessagePart* newBodyPart, Kleo::CryptoMessageFormat format,
1121
		     MessageComposer* composer )
1132
		     MessageComposer* composer )
1122
    : MessageComposerJob( composer ), mMsg( msg ), mSplitInfo( si ),
1133
    : MessageComposerJob( composer ), mMsg( msg ), mSplitInfo( si ),
1123
      mDoSign( doSign ), mDoEncrypt( doEncrypt ), mEncodedBody( encodedBody ),
1134
      mDoSign( doSign ), mDoEncrypt( doEncrypt ), mEncodedBody( encodedBody ),
1124
      mBoundaryLevel( boundaryLevel ), mOldBodyPart( oldBodyPart ),
1135
      mBoundaryLevel( boundaryLevel ), /*mOldBodyPart( oldBodyPart ),*/
1125
      mNewBodyPart( newBodyPart ), mFormat( format ) {}
1136
      mNewBodyPart( newBodyPart ), mFormat( format ) {}
1126
1137
1127
  void execute() {
1138
  void execute() {
1128
    KMMessagePart tmpNewBodyPart;
1139
    KMMessagePart tmpNewBodyPart;
1129
    tmpNewBodyPart.duplicate( *mNewBodyPart );
1140
    tmpNewBodyPart.duplicate( *mNewBodyPart ); // slow - we duplicate everything again
1130
1141
1131
    // TODO: Async call
1142
    // TODO: Async call
1132
1143
Lines 1143-1151 Link Here
1143
  KMMessage* mMsg;
1154
  KMMessage* mMsg;
1144
  Kleo::KeyResolver::SplitInfo mSplitInfo;
1155
  Kleo::KeyResolver::SplitInfo mSplitInfo;
1145
  bool mDoSign, mDoEncrypt;
1156
  bool mDoSign, mDoEncrypt;
1146
  QCString mEncodedBody;
1157
  QByteArray mEncodedBody;
1147
  int mBoundaryLevel;
1158
  int mBoundaryLevel;
1148
  KMMessagePart mOldBodyPart;
1159
  //KMMessagePart mOldBodyPart;
1149
  KMMessagePart* mNewBodyPart;
1160
  KMMessagePart* mNewBodyPart;
1150
  Kleo::CryptoMessageFormat mFormat;
1161
  Kleo::CryptoMessageFormat mFormat;
1151
};
1162
};
Lines 1162-1199 Link Here
1162
  }
1173
  }
1163
};
1174
};
1164
1175
1165
QCString MessageComposer::bodyText()
1166
{
1167
  QCString body = mText;
1168
1169
  if (body.isNull()) return body;
1170
1171
  if (body.isEmpty()) body = "\n"; // don't crash
1172
1173
  // From RFC 3156:
1174
  //  Note: The accepted OpenPGP convention is for signed data to end
1175
  //  with a <CR><LF> sequence.  Note that the <CR><LF> sequence
1176
  //  immediately preceding a MIME boundary delimiter line is considered
1177
  //  to be part of the delimiter in [3], 5.1.  Thus, it is not part of
1178
  //  the signed data preceding the delimiter line.  An implementation
1179
  //  which elects to adhere to the OpenPGP convention has to make sure
1180
  //  it inserts a <CR><LF> pair on the last line of the data to be
1181
  //  signed and transmitted (signed message and transmitted message
1182
  //  MUST be identical).
1183
  // So make sure that the body ends with a <LF>.
1184
  if( body[body.length()-1] != '\n' ) {
1185
    kdDebug(5006) << "Added an <LF> on the last line" << endl;
1186
    body += "\n";
1187
  }
1188
  return body;
1189
}
1190
1191
void MessageComposer::composeInlineOpenPGPMessage( KMMessage& theMessage,
1176
void MessageComposer::composeInlineOpenPGPMessage( KMMessage& theMessage,
1192
                                                   bool doSign, bool doEncrypt )
1177
                                                   bool doSign, bool doEncrypt )
1193
{
1178
{
1194
  // preprocess the body text
1179
  // preprocess the body text
1195
  QCString body = bodyText();
1180
  const QByteArray bodyData = mText;
1196
  if (body.isNull()) {
1181
  if (bodyData.isNull()) {
1197
    mRc = false;
1182
    mRc = false;
1198
    return;
1183
    return;
1199
  }
1184
  }
Lines 1222-1231 Link Here
1222
      QByteArray encryptedBody;
1207
      QByteArray encryptedBody;
1223
      if ( doSign ) {  // Sign and encrypt
1208
      if ( doSign ) {  // Sign and encrypt
1224
        const std::vector<GpgME::Key> signingKeys = mKeyResolver->signingKeys( Kleo::InlineOpenPGPFormat );
1209
        const std::vector<GpgME::Key> signingKeys = mKeyResolver->signingKeys( Kleo::InlineOpenPGPFormat );
1225
        result = pgpSignedAndEncryptedMsg( encryptedBody, body, signingKeys,
1210
        result = pgpSignedAndEncryptedMsg( encryptedBody, bodyData, signingKeys,
1226
                                           splitInfo.keys, Kleo::InlineOpenPGPFormat );
1211
                                           splitInfo.keys, Kleo::InlineOpenPGPFormat );
1227
      } else { // Encrypt but don't sign
1212
      } else { // Encrypt but don't sign
1228
        result = pgpEncryptedMsg( encryptedBody, body,
1213
        result = pgpEncryptedMsg( encryptedBody, bodyData,
1229
                                  splitInfo.keys, Kleo::InlineOpenPGPFormat );
1214
                                  splitInfo.keys, Kleo::InlineOpenPGPFormat );
1230
      }
1215
      }
1231
      if ( result != Kpgp::Ok ) {
1216
      if ( result != Kpgp::Ok ) {
Lines 1236-1250 Link Here
1236
      mOldBodyPart.setBodyEncodedBinary( encryptedBody );
1221
      mOldBodyPart.setBodyEncodedBinary( encryptedBody );
1237
    } else {
1222
    } else {
1238
      if ( doSign ) { // Sign but don't encrypt
1223
      if ( doSign ) { // Sign but don't encrypt
1239
        pgpSignedMsg( body, Kleo::InlineOpenPGPFormat );
1224
        pgpSignedMsg( bodyData, Kleo::InlineOpenPGPFormat );
1240
        if ( mSignature.isNull() ) {
1225
        if ( mSignature.isNull() ) {
1241
          mRc = false;
1226
          mRc = false;
1242
          return;
1227
          return;
1243
        }
1228
        }
1244
        mOldBodyPart.setBodyEncodedBinary( mSignature );
1229
        mOldBodyPart.setBodyEncodedBinary( mSignature );
1245
      } else { // don't sign nor encrypt -> nothing to do
1230
      } else { // don't sign nor encrypt -> nothing to do
1246
        assert( !body.isNull() );
1231
        assert( !bodyData.isNull() );
1247
        mOldBodyPart.setBodyEncoded( body );
1232
        mOldBodyPart.setBodyEncodedBinary( bodyData );
1248
      }
1233
      }
1249
    }
1234
    }
1250
    mOldBodyPart.setContentDisposition( "inline" );
1235
    mOldBodyPart.setContentDisposition( "inline" );
Lines 1254-1260 Link Here
1254
    mMessageList.push_back( msg );
1239
    mMessageList.push_back( msg );
1255
    if ( it == splitInfos.begin() ) {
1240
    if ( it == splitInfos.begin() ) {
1256
      if ( doEncrypt && !saveMessagesEncrypted() ) {
1241
      if ( doEncrypt && !saveMessagesEncrypted() ) {
1257
        mOldBodyPart.setBodyEncoded( body );
1242
        mOldBodyPart.setBodyEncodedBinary( bodyData );
1258
        KMMessage* msgUnenc = new KMMessage( theMessage );
1243
        KMMessage* msgUnenc = new KMMessage( theMessage );
1259
        addBodyAndAttachments( msgUnenc, splitInfo, false, false, mOldBodyPart, Kleo::InlineOpenPGPFormat );
1244
        addBodyAndAttachments( msgUnenc, splitInfo, false, false, mOldBodyPart, Kleo::InlineOpenPGPFormat );
1260
        msg->setUnencryptedMsg( msgUnenc );
1245
        msg->setUnencryptedMsg( msgUnenc );
Lines 1274-1281 Link Here
1274
  assert( chiasmus ); // kmcomposewin code should have made sure
1259
  assert( chiasmus ); // kmcomposewin code should have made sure
1275
1260
1276
  // preprocess the body text
1261
  // preprocess the body text
1277
  QCString body = bodyText();
1262
  const QByteArray bodyData = mText;
1278
  if (body.isNull()) {
1263
  if (bodyData.isNull()) {
1279
    mRc = false;
1264
    mRc = false;
1280
    return;
1265
    return;
1281
  }
1266
  }
Lines 1290-1298 Link Here
1290
  theMessage.removeHeaderField("Content-Type");
1275
  theMessage.removeHeaderField("Content-Type");
1291
  theMessage.removeHeaderField("Content-Transfer-Encoding");
1276
  theMessage.removeHeaderField("Content-Transfer-Encoding");
1292
1277
1293
  QByteArray plainText;
1294
  plainText.duplicate( body.data(), body.length() ); // hrmpf...
1295
1296
  // This reads strange, but we know that AdjustCryptFlagsJob created a single splitinfo,
1278
  // This reads strange, but we know that AdjustCryptFlagsJob created a single splitinfo,
1297
  // under the given "format" (usually openpgp/mime; doesn't matter)
1279
  // under the given "format" (usually openpgp/mime; doesn't matter)
1298
  const std::vector<Kleo::KeyResolver::SplitInfo> splitInfos
1280
  const std::vector<Kleo::KeyResolver::SplitInfo> splitInfos
Lines 1304-1310 Link Here
1304
    KMMessage* msg = new KMMessage( theMessage );
1286
    KMMessage* msg = new KMMessage( theMessage );
1305
    QByteArray encryptedBody;
1287
    QByteArray encryptedBody;
1306
1288
1307
    if ( !encryptWithChiasmus( chiasmus, plainText, encryptedBody ) ) {
1289
    if ( !encryptWithChiasmus( chiasmus, bodyData, encryptedBody ) ) {
1308
      mRc = false;
1290
      mRc = false;
1309
      return;
1291
      return;
1310
    }
1292
    }
Lines 1330-1336 Link Here
1330
    mMessageList.push_back( msg );
1312
    mMessageList.push_back( msg );
1331
1313
1332
    if ( it == splitInfos.begin() && !saveMessagesEncrypted() ) {
1314
    if ( it == splitInfos.begin() && !saveMessagesEncrypted() ) {
1333
      mOldBodyPart.setBodyEncoded( body );
1315
      mOldBodyPart.setBodyEncodedBinary( bodyData );
1334
      KMMessage* msgUnenc = new KMMessage( theMessage );
1316
      KMMessage* msgUnenc = new KMMessage( theMessage );
1335
      addBodyAndAttachments( msgUnenc, splitInfo, false, false, mOldBodyPart, Kleo::InlineOpenPGPFormat );
1317
      addBodyAndAttachments( msgUnenc, splitInfo, false, false, mOldBodyPart, Kleo::InlineOpenPGPFormat );
1336
      msg->setUnencryptedMsg( msgUnenc );
1318
      msg->setUnencryptedMsg( msgUnenc );
Lines 1361-1368 Link Here
1361
  theMessage.setBody( "This message is in MIME format." );
1343
  theMessage.setBody( "This message is in MIME format." );
1362
1344
1363
  // preprocess the body text
1345
  // preprocess the body text
1364
  QCString body = bodyText();
1346
  QByteArray bodyData = mText;
1365
  if (body.isNull()) {
1347
  if (bodyData.isNull()) {
1366
    mRc = false;
1348
    mRc = false;
1367
    return;
1349
    return;
1368
  }
1350
  }
Lines 1430-1443 Link Here
1430
    QCString newbody;
1412
    QCString newbody;
1431
    DwMediaType tmpCT;
1413
    DwMediaType tmpCT;
1432
    tmpCT.CreateBoundary( ++mPreviousBoundaryLevel );
1414
    tmpCT.CreateBoundary( ++mPreviousBoundaryLevel );
1433
    boundaryCStr = tmpCT.Boundary().c_str();
1415
    boundaryCStr = KMail::Util::CString( tmpCT.Boundary() );
1434
    QValueList<int> allowedCTEs;
1416
    QValueList<int> allowedCTEs;
1435
1417
1436
    KMMessagePart textBodyPart;
1418
    KMMessagePart textBodyPart;
1437
    textBodyPart.setTypeStr("text");
1419
    textBodyPart.setTypeStr("text");
1438
    textBodyPart.setSubtypeStr("plain");
1420
    textBodyPart.setSubtypeStr("plain");
1439
1421
1440
    QCString textbody = plainTextFromMarkup( mText );
1422
    QCString textbody = plainTextFromMarkup( mText /* converted to QString */ );
1441
1423
1442
    // the signed body must not be 8bit encoded
1424
    // the signed body must not be 8bit encoded
1443
    textBodyPart.setBodyAndGuessCte( textbody, allowedCTEs,
1425
    textBodyPart.setBodyAndGuessCte( textbody, allowedCTEs,
Lines 1457-1469 Link Here
1457
    KMMessagePart htmlBodyPart;
1439
    KMMessagePart htmlBodyPart;
1458
    htmlBodyPart.setTypeStr("text");
1440
    htmlBodyPart.setTypeStr("text");
1459
    htmlBodyPart.setSubtypeStr("html");
1441
    htmlBodyPart.setSubtypeStr("html");
1460
    QCString htmlbody = mText;
1442
    QByteArray htmlbody = mText;
1461
    // the signed body must not be 8bit encoded
1443
    // the signed body must not be 8bit encoded
1462
    htmlBodyPart.setBodyAndGuessCte( htmlbody, allowedCTEs,
1444
    htmlBodyPart.setBodyAndGuessCte( htmlbody, allowedCTEs,
1463
                                     !kmkernel->msgSender()->sendQuotedPrintable() && !doSign,
1445
                                     !kmkernel->msgSender()->sendQuotedPrintable() && !doSign,
1464
				     doSign );
1446
				     doSign );
1465
    htmlBodyPart.setCharset( mCharset );
1447
    htmlBodyPart.setCharset( mCharset );
1466
    htmlBodyPart.setBodyEncoded( htmlbody );
1448
    htmlBodyPart.setBodyEncodedBinary( htmlbody );
1467
    DwBodyPart* htmlDwPart = theMessage.createDWBodyPart( &htmlBodyPart );
1449
    DwBodyPart* htmlDwPart = theMessage.createDWBodyPart( &htmlBodyPart );
1468
    htmlDwPart->Assemble();
1450
    htmlDwPart->Assemble();
1469
    newbody += "\n--";
1451
    newbody += "\n--";
Lines 1476-1483 Link Here
1476
    newbody += "--";
1458
    newbody += "--";
1477
    newbody +=     boundaryCStr;
1459
    newbody +=     boundaryCStr;
1478
    newbody +=                 "--\n";
1460
    newbody +=                 "--\n";
1479
    body = newbody;
1461
    bodyData = KMail::Util::byteArrayFromQCStringNoDetach( newbody );
1480
    mOldBodyPart.setBodyEncoded( newbody );
1462
    mOldBodyPart.setBodyEncodedBinary( bodyData );
1481
1463
1482
    mSaveBoundary = tmpCT.Boundary();
1464
    mSaveBoundary = tmpCT.Boundary();
1483
  }
1465
  }
Lines 1493-1499 Link Here
1493
    // eventually get rid of this:
1475
    // eventually get rid of this:
1494
    if( it->sign || it->encrypt ) {
1476
    if( it->sign || it->encrypt ) {
1495
      QCString cte = it->part->cteStr().lower();
1477
      QCString cte = it->part->cteStr().lower();
1496
      if( ( "8bit" == cte )
1478
      if( ( "8bit" == cte && it->part->type() != DwMime::kTypeMessage )
1497
          || ( ( it->part->type() == DwMime::kTypeText )
1479
          || ( ( it->part->type() == DwMime::kTypeText )
1498
               && ( "7bit" == cte ) ) ) {
1480
               && ( "7bit" == cte ) ) ) {
1499
        const QByteArray body = it->part->bodyDecodedBinary();
1481
        const QByteArray body = it->part->bodyDecodedBinary();
Lines 1518-1545 Link Here
1518
    innerBodyPart.setContentDisposition( "inline" );
1500
    innerBodyPart.setContentDisposition( "inline" );
1519
    QValueList<int> allowedCTEs;
1501
    QValueList<int> allowedCTEs;
1520
    // the signed body must not be 8bit encoded
1502
    // the signed body must not be 8bit encoded
1521
    innerBodyPart.setBodyAndGuessCte( body, allowedCTEs,
1503
    innerBodyPart.setBodyAndGuessCte( bodyData, allowedCTEs,
1522
                                      !kmkernel->msgSender()->sendQuotedPrintable() && !doSign,
1504
                                      !kmkernel->msgSender()->sendQuotedPrintable() && !doSign,
1523
                                      doSign );
1505
                                      doSign );
1524
    if ( !mIsRichText )
1506
    if ( !mIsRichText )
1525
      innerBodyPart.setCharset( mCharset );
1507
      innerBodyPart.setCharset( mCharset );
1526
    innerBodyPart.setBodyEncoded( body ); // do we need this, since setBodyAndGuessCte does this already?
1508
    innerBodyPart.setBodyEncodedBinary( bodyData ); // do we need this, since setBodyAndGuessCte does this already?
1527
    DwBodyPart* innerDwPart = theMessage.createDWBodyPart( &innerBodyPart );
1509
    DwBodyPart* innerDwPart = theMessage.createDWBodyPart( &innerBodyPart );
1528
    innerDwPart->Assemble();
1510
    innerDwPart->Assemble();
1511
    QByteArray tmpbody = KMail::Util::ByteArray( innerDwPart->AsString() );
1529
    if ( mIsRichText ) { // and add our mp/a boundary
1512
    if ( mIsRichText ) { // and add our mp/a boundary
1530
        QCString tmpbody = innerDwPart->AsString().c_str();
1531
        int boundPos = tmpbody.find( '\n' );
1513
        int boundPos = tmpbody.find( '\n' );
1532
        if( -1 < boundPos ) {
1514
        if( -1 < boundPos ) {
1533
          QCString bStr( ";\n  boundary=\"" );
1515
          QCString bStr( ";\n  boundary=\"" );
1534
          bStr += mSaveBoundary.c_str();
1516
          bStr += mSaveBoundary.c_str();
1535
          bStr += "\"";
1517
          bStr += "\"";
1536
          body = innerDwPart->AsString().c_str();
1518
          bodyData = tmpbody;
1537
          body.insert( boundPos, bStr );
1519
          KMail::Util::insert( bodyData, boundPos, bStr );
1538
          body = "--" + mMultipartMixedBoundary + "\n" + body;
1520
          KMail::Util::insert( bodyData, 0, "--" + mMultipartMixedBoundary + "\n" ); // prepend
1539
        }
1521
        }
1540
    }
1522
    }
1541
    else
1523
    else {
1542
      body = "--" + mMultipartMixedBoundary + "\n" + innerDwPart->AsString().c_str();
1524
      bodyData = tmpbody;
1525
      KMail::Util::insert( bodyData, 0, "--" + mMultipartMixedBoundary + "\n" ); // prepend
1526
    }
1543
    delete innerDwPart;
1527
    delete innerDwPart;
1544
    innerDwPart = 0;
1528
    innerDwPart = 0;
1545
    // add all matching Attachments
1529
    // add all matching Attachments
Lines 1548-1569 Link Here
1548
      if ( it->encrypt == doEncryptBody && it->sign == doSignBody ) {
1532
      if ( it->encrypt == doEncryptBody && it->sign == doSignBody ) {
1549
        innerDwPart = theMessage.createDWBodyPart( it->part );
1533
        innerDwPart = theMessage.createDWBodyPart( it->part );
1550
        innerDwPart->Assemble();
1534
        innerDwPart->Assemble();
1551
        body += "\n--" + mMultipartMixedBoundary + "\n" + innerDwPart->AsString().c_str();
1535
        KMail::Util::append( bodyData, QCString( "\n--" + mMultipartMixedBoundary + "\n" ) );
1536
        KMail::Util::append( bodyData, innerDwPart->AsString().c_str() );
1552
        delete innerDwPart;
1537
        delete innerDwPart;
1553
        innerDwPart = 0;
1538
        innerDwPart = 0;
1554
      }
1539
      }
1555
    }
1540
    }
1556
    body += "\n--" + mMultipartMixedBoundary + "--\n";
1541
    KMail::Util::append( bodyData, QCString( "\n--" + mMultipartMixedBoundary + "--\n" ) );
1557
  } else { // !earlyAddAttachments
1542
  } else { // !earlyAddAttachments
1558
    QValueList<int> allowedCTEs;
1543
    QValueList<int> allowedCTEs;
1559
    // the signed body must not be 8bit encoded
1544
    // the signed body must not be 8bit encoded
1560
    mOldBodyPart.setBodyAndGuessCte(body, allowedCTEs, !kmkernel->msgSender()->sendQuotedPrintable() && !doSign,
1545
    mOldBodyPart.setBodyAndGuessCte(bodyData, allowedCTEs, !kmkernel->msgSender()->sendQuotedPrintable() && !doSign,
1561
                                   doSign);
1546
                                   doSign);
1562
    if ( !mIsRichText )
1547
    if ( !mIsRichText )
1563
      mOldBodyPart.setCharset(mCharset);
1548
      mOldBodyPart.setCharset(mCharset);
1564
  }
1549
  }
1565
  // create S/MIME body part for signing and/or encrypting
1550
  // create S/MIME body part for signing and/or encrypting
1566
  mOldBodyPart.setBodyEncoded( body );
1551
  mOldBodyPart.setBodyEncodedBinary( bodyData );
1567
1552
1568
  if( doSignBody || doEncryptBody ) {
1553
  if( doSignBody || doEncryptBody ) {
1569
    // get string representation of body part (including the attachments)
1554
    // get string representation of body part (including the attachments)
Lines 1577-1589 Link Here
1577
      DwMediaType& ct = headers.ContentType();
1562
      DwMediaType& ct = headers.ContentType();
1578
      ct.SetBoundary(mSaveBoundary);
1563
      ct.SetBoundary(mSaveBoundary);
1579
      dwPart->Assemble();
1564
      dwPart->Assemble();
1580
      mEncodedBody = dwPart->AsString().c_str();
1581
    }
1565
    }
1582
    else {
1566
    else {
1583
      dwPart = theMessage.createDWBodyPart( &mOldBodyPart );
1567
      dwPart = theMessage.createDWBodyPart( &mOldBodyPart );
1584
      dwPart->Assemble();
1568
      dwPart->Assemble();
1585
      mEncodedBody = dwPart->AsString().c_str();
1586
    }
1569
    }
1570
    mEncodedBody = KMail::Util::ByteArray( dwPart->AsString() );
1587
    delete dwPart;
1571
    delete dwPart;
1588
    dwPart = 0;
1572
    dwPart = 0;
1589
1573
Lines 1595-1601 Link Here
1595
        QCString bStr( ";\n  boundary=\"" );
1579
        QCString bStr( ";\n  boundary=\"" );
1596
        bStr += mMultipartMixedBoundary;
1580
        bStr += mMultipartMixedBoundary;
1597
        bStr += "\"";
1581
        bStr += "\"";
1598
        mEncodedBody.insert( boundPos, bStr );
1582
        KMail::Util::insert( mEncodedBody, boundPos, bStr.data() );
1599
      }
1583
      }
1600
    }
1584
    }
1601
1585
Lines 1606-1613 Link Here
1606
  }
1590
  }
1607
1591
1608
  if ( doSignBody ) {
1592
  if ( doSignBody ) {
1593
    mPerformingSignOperation = true;  // this lets the KMComposeWin know if it is safe to close the window.
1609
    pgpSignedMsg( mEncodedBody, format );
1594
    pgpSignedMsg( mEncodedBody, format );
1610
1595
    mPerformingSignOperation = false;
1596
    
1611
    if ( mSignature.isEmpty() ) {
1597
    if ( mSignature.isEmpty() ) {
1612
      kdDebug() << "signature was empty" << endl;
1598
      kdDebug() << "signature was empty" << endl;
1613
      mRc = false;
1599
      mRc = false;
Lines 1655-1661 Link Here
1655
					     Kleo::KeyResolver::SplitInfo( splitInfos.front().recipients ), doSign,
1641
					     Kleo::KeyResolver::SplitInfo( splitInfos.front().recipients ), doSign,
1656
					     false, mEncodedBody,
1642
					     false, mEncodedBody,
1657
					     mPreviousBoundaryLevel,
1643
					     mPreviousBoundaryLevel,
1658
					     mOldBodyPart, mNewBodyPart,
1644
					     /*mOldBodyPart,*/ mNewBodyPart,
1659
					     format, this ) );
1645
					     format, this ) );
1660
  }
1646
  }
1661
1647
Lines 1663-1669 Link Here
1663
    mJobs.push_front( new EncryptMessageJob( new KMMessage( theMessage ), *it, doSign,
1649
    mJobs.push_front( new EncryptMessageJob( new KMMessage( theMessage ), *it, doSign,
1664
					     doEncrypt, mEncodedBody,
1650
					     doEncrypt, mEncodedBody,
1665
					     mPreviousBoundaryLevel,
1651
					     mPreviousBoundaryLevel,
1666
					     mOldBodyPart, mNewBodyPart,
1652
					     /*mOldBodyPart,*/ mNewBodyPart,
1667
					     format, this ) );
1653
					     format, this ) );
1668
}
1654
}
1669
1655
Lines 1684-1699 Link Here
1684
  const bool doSignBody = doSign && mSignBody;
1670
  const bool doSignBody = doSign && mSignBody;
1685
1671
1686
  if ( doEncryptBody ) {
1672
  if ( doEncryptBody ) {
1687
    QCString innerContent;
1673
    QByteArray innerContent;
1688
    if ( doSignBody ) {
1674
    if ( doSignBody ) {
1689
      // extract signed body from newBodyPart
1675
      // extract signed body from newBodyPart
1690
      DwBodyPart* dwPart = msg->createDWBodyPart( &newBodyPart );
1676
      DwBodyPart* dwPart = msg->createDWBodyPart( &newBodyPart );
1691
      dwPart->Assemble();
1677
      dwPart->Assemble();
1692
      innerContent = dwPart->AsString().c_str();
1678
      innerContent = KMail::Util::ByteArray( dwPart->AsString() );
1693
      delete dwPart;
1679
      delete dwPart;
1694
      dwPart = 0;
1680
      dwPart = 0;
1695
    } else
1681
    } else {
1696
      innerContent = mEncodedBody;
1682
      innerContent = mEncodedBody;
1683
    }
1697
1684
1698
    // now do the encrypting:
1685
    // now do the encrypting:
1699
    // replace simple LFs by CRLFs for all MIME supporting CryptPlugs
1686
    // replace simple LFs by CRLFs for all MIME supporting CryptPlugs
Lines 1784-1790 Link Here
1784
1771
1785
      DwBodyPart* innerDwPart = msg->createDWBodyPart( it->part );
1772
      DwBodyPart* innerDwPart = msg->createDWBodyPart( it->part );
1786
      innerDwPart->Assemble();
1773
      innerDwPart->Assemble();
1787
      QCString encodedAttachment = innerDwPart->AsString().c_str();
1774
      QByteArray encodedAttachment = KMail::Util::ByteArray( innerDwPart->AsString() );
1788
      delete innerDwPart;
1775
      delete innerDwPart;
1789
      innerDwPart = 0;
1776
      innerDwPart = 0;
1790
1777
Lines 1795-1804 Link Here
1795
1782
1796
      // sign this attachment
1783
      // sign this attachment
1797
      if( signThisNow ) {
1784
      if( signThisNow ) {
1798
1799
        pgpSignedMsg( encodedAttachment, format );
1785
        pgpSignedMsg( encodedAttachment, format );
1800
        QByteArray signature = mSignature;
1786
        mRc = !mSignature.isEmpty();
1801
        mRc = !signature.isEmpty();
1802
        if( mRc ) {
1787
        if( mRc ) {
1803
          mRc = processStructuringInfo( "http://www.gnupg.org/aegypten/",
1788
          mRc = processStructuringInfo( "http://www.gnupg.org/aegypten/",
1804
                                        it->part->contentDescription(),
1789
                                        it->part->contentDescription(),
Lines 1808-1821 Link Here
1808
                                        it->part->contentTransferEncodingStr(),
1793
                                        it->part->contentTransferEncodingStr(),
1809
                                        encodedAttachment,
1794
                                        encodedAttachment,
1810
                                        "signature",
1795
                                        "signature",
1811
                                        signature,
1796
                                        mSignature,
1812
                                        newAttachPart, true, format );
1797
                                        newAttachPart, true, format );
1813
          if( mRc ) {
1798
          if( mRc ) {
1814
            if( encryptThisNow ) {
1799
            if( encryptThisNow ) {
1815
              rEncryptMessagePart = newAttachPart;
1800
              rEncryptMessagePart = newAttachPart;
1816
              DwBodyPart* dwPart = msg->createDWBodyPart( &newAttachPart );
1801
              DwBodyPart* dwPart = msg->createDWBodyPart( &newAttachPart );
1817
              dwPart->Assemble();
1802
              dwPart->Assemble();
1818
              encodedAttachment = dwPart->AsString().c_str();
1803
              encodedAttachment = KMail::Util::ByteArray( dwPart->AsString() );
1819
              delete dwPart;
1804
              delete dwPart;
1820
              dwPart = 0;
1805
              dwPart = 0;
1821
            }
1806
            }
Lines 1880-1886 Link Here
1880
      kdDebug(5006) << "MessageComposer::addBodyAndAttachments() : top level headers and body adjusted" << endl;
1865
      kdDebug(5006) << "MessageComposer::addBodyAndAttachments() : top level headers and body adjusted" << endl;
1881
1866
1882
    // set body content
1867
    // set body content
1883
    msg->setBody(ourFineBodyPart.body() );
1868
    msg->setBody( ourFineBodyPart.dwBody() );
1884
1869
1885
  }
1870
  }
1886
1871
Lines 1902-1913 Link Here
1902
                                              const QCString contentSubtypeClear,
1887
                                              const QCString contentSubtypeClear,
1903
                                              const QCString contentDispClear,
1888
                                              const QCString contentDispClear,
1904
                                              const QCString contentTEncClear,
1889
                                              const QCString contentTEncClear,
1905
                                              const QCString& clearCStr,
1890
                                              const QByteArray& clearCStr,
1906
                                              const QString /*contentDescCiph*/,
1891
                                              const QString /*contentDescCiph*/,
1907
                                              const QByteArray& ciphertext,
1892
                                              const QByteArray& ciphertext,
1908
                                              KMMessagePart& resultingPart,
1893
                                              KMMessagePart& resultingPart,
1909
					      bool signing, Kleo::CryptoMessageFormat format )
1894
					      bool signing, Kleo::CryptoMessageFormat format )
1910
{
1895
{
1896
  assert( clearCStr.isEmpty() || clearCStr[clearCStr.size()-1] != '\0' ); // I was called with a QCString !?
1911
  bool bOk = true;
1897
  bool bOk = true;
1912
1898
1913
  if ( makeMimeObject( format, signing ) ) {
1899
  if ( makeMimeObject( format, signing ) ) {
Lines 1955-1966 Link Here
1955
    KMMessage::bodyPart( &mainDwPa, &resultingPart );
1941
    KMMessage::bodyPart( &mainDwPa, &resultingPart );
1956
    if( !makeMultiMime( format, signing ) ) {
1942
    if( !makeMultiMime( format, signing ) ) {
1957
      if ( signing && includeCleartextWhenSigning( format ) ) {
1943
      if ( signing && includeCleartextWhenSigning( format ) ) {
1958
        QCString bodyText( clearCStr );
1944
        QByteArray bodyText( clearCStr );
1959
        bodyText += '\n';
1945
        KMail::Util::append( bodyText, "\n" );
1960
        bodyText += QCString( ciphertext.data(), ciphertext.size() + 1 );
1946
        KMail::Util::append( bodyText, ciphertext );
1961
        resultingPart.setBodyEncoded( bodyText );
1947
        resultingPart.setBodyEncodedBinary( bodyText );
1962
      } else
1948
      } else {
1963
        resultingPart.setBodyEncodedBinary( ciphertext );
1949
        resultingPart.setBodyEncodedBinary( ciphertext );
1950
      }
1964
    } else {
1951
    } else {
1965
      // Build the encapsulated MIME parts.
1952
      // Build the encapsulated MIME parts.
1966
      // Build a MIME part holding the version information
1953
      // Build a MIME part holding the version information
Lines 1993-2010 Link Here
1993
	codeCStr += '\n' + QCString( ciphertext.data(), ciphertext.size() + 1 );
1980
	codeCStr += '\n' + QCString( ciphertext.data(), ciphertext.size() + 1 );
1994
1981
1995
1982
1996
      QCString mainStr = "--" + boundaryCStr;
1983
      QByteArray mainStr;
1984
      KMail::Util::append( mainStr, "--" );
1985
      KMail::Util::append( mainStr, boundaryCStr );
1997
      if ( signing && includeCleartextWhenSigning( format ) &&
1986
      if ( signing && includeCleartextWhenSigning( format ) &&
1998
	   !clearCStr.isEmpty() )
1987
	   !clearCStr.isEmpty() ) {
1999
        mainStr += "\n" + clearCStr + "\n--" + boundaryCStr;
1988
        KMail::Util::append( mainStr, "\n" );
1989
        // clearCStr is the one that can be very big for large attachments, don't merge with the other lines
1990
        KMail::Util::append( mainStr, clearCStr );
1991
        KMail::Util::append( mainStr, "\n--" + boundaryCStr );
1992
      }
2000
      if ( !versCStr.isEmpty() )
1993
      if ( !versCStr.isEmpty() )
2001
        mainStr += "\n" + versCStr + "\n--" + boundaryCStr;
1994
        KMail::Util::append( mainStr, "\n" + versCStr + "\n--" + boundaryCStr );
2002
      if( !codeCStr.isEmpty() )
1995
      if( !codeCStr.isEmpty() )
2003
        mainStr += "\n" + codeCStr + "\n--" + boundaryCStr;
1996
        KMail::Util::append( mainStr, "\n" + codeCStr + "\n--" + boundaryCStr );
2004
      mainStr += "--\n";
1997
      KMail::Util::append( mainStr, "--\n" );
2005
1998
2006
      //kdDebug(5006) << "processStructuringInfo: mainStr=" << mainStr << endl;
1999
      //kdDebug(5006) << "processStructuringInfo: mainStr=" << mainStr << endl;
2007
      resultingPart.setBodyEncoded( mainStr );
2000
      resultingPart.setBodyEncodedBinary( mainStr );
2008
    }
2001
    }
2009
2002
2010
  } else { //  not making a mime object, build a plain message body.
2003
  } else { //  not making a mime object, build a plain message body.
Lines 2014-2027 Link Here
2014
    resultingPart.setSubtypeStr( contentSubtypeClear );
2007
    resultingPart.setSubtypeStr( contentSubtypeClear );
2015
    resultingPart.setContentDisposition( contentDispClear );
2008
    resultingPart.setContentDisposition( contentDispClear );
2016
    resultingPart.setContentTransferEncodingStr( contentTEncClear );
2009
    resultingPart.setContentTransferEncodingStr( contentTEncClear );
2017
    QCString resultingBody;
2010
    QByteArray resultingBody;
2018
2011
2019
    if ( signing && includeCleartextWhenSigning( format ) ) {
2012
    if ( signing && includeCleartextWhenSigning( format ) ) {
2020
      if( !clearCStr.isEmpty() )
2013
      if( !clearCStr.isEmpty() )
2021
        resultingBody += clearCStr;
2014
        KMail::Util::append( resultingBody, clearCStr );
2022
    }
2015
    }
2023
    if ( !ciphertext.isEmpty() )
2016
    if ( !ciphertext.isEmpty() )
2024
      resultingBody += QCString( ciphertext.data(), ciphertext.size() + 1 ); // null-terminate
2017
      KMail::Util::append( resultingBody, ciphertext );
2025
    else {
2018
    else {
2026
      // Plugin error!
2019
      // Plugin error!
2027
      KMessageBox::sorry( mComposeWin,
2020
      KMessageBox::sorry( mComposeWin,
Lines 2031-2037 Link Here
2031
                          .arg( bugURL ) );
2024
                          .arg( bugURL ) );
2032
      bOk = false;
2025
      bOk = false;
2033
    }
2026
    }
2034
    resultingPart.setBodyEncoded( resultingBody );
2027
    resultingPart.setBodyEncodedBinary( resultingBody );
2035
  }
2028
  }
2036
2029
2037
  return bOk;
2030
  return bOk;
Lines 2065-2071 Link Here
2065
}
2058
}
2066
2059
2067
//-----------------------------------------------------------------------------
2060
//-----------------------------------------------------------------------------
2068
QCString MessageComposer::breakLinesAndApplyCodec()
2061
QByteArray MessageComposer::breakLinesAndApplyCodec()
2069
{
2062
{
2070
  QString text;
2063
  QString text;
2071
  QCString cText;
2064
  QCString cText;
Lines 2103-2119 Link Here
2103
                                               i18n("Lose Characters"), i18n("Change Encoding") ) == KMessageBox::Yes );
2096
                                               i18n("Lose Characters"), i18n("Change Encoding") ) == KMessageBox::Yes );
2104
    if( !anyway ) {
2097
    if( !anyway ) {
2105
      mComposeWin->mEditor->setText(oldText);
2098
      mComposeWin->mEditor->setText(oldText);
2106
      return QCString();
2099
      return QByteArray();
2107
    }
2100
    }
2108
  }
2101
  }
2109
2102
2110
  return cText;
2103
  // From RFC 3156:
2104
  //  Note: The accepted OpenPGP convention is for signed data to end
2105
  //  with a <CR><LF> sequence.  Note that the <CR><LF> sequence
2106
  //  immediately preceding a MIME boundary delimiter line is considered
2107
  //  to be part of the delimiter in [3], 5.1.  Thus, it is not part of
2108
  //  the signed data preceding the delimiter line.  An implementation
2109
  //  which elects to adhere to the OpenPGP convention has to make sure
2110
  //  it inserts a <CR><LF> pair on the last line of the data to be
2111
  //  signed and transmitted (signed message and transmitted message
2112
  //  MUST be identical).
2113
  // So make sure that the body ends with a <LF>.
2114
  if( cText.isEmpty() || cText[cText.length()-1] != '\n' ) {
2115
    kdDebug(5006) << "Added an <LF> on the last line" << endl;
2116
    cText += "\n";
2117
  }
2118
  return KMail::Util::byteArrayFromQCStringNoDetach( cText );
2111
}
2119
}
2112
2120
2113
2121
2114
//-----------------------------------------------------------------------------
2122
//-----------------------------------------------------------------------------
2115
void MessageComposer::pgpSignedMsg( const QCString & cText, Kleo::CryptoMessageFormat format ) {
2123
void MessageComposer::pgpSignedMsg( const QByteArray& cText, Kleo::CryptoMessageFormat format ) {
2116
2124
2125
  assert( cText.isEmpty() || cText[cText.size()-1] != '\0' ); // I was called with a QCString !?
2117
  mSignature = QByteArray();
2126
  mSignature = QByteArray();
2118
2127
2119
  const std::vector<GpgME::Key> signingKeys = mKeyResolver->signingKeys( format );
2128
  const std::vector<GpgME::Key> signingKeys = mKeyResolver->signingKeys( format );
Lines 2139-2149 Link Here
2139
    return;
2148
    return;
2140
  }
2149
  }
2141
2150
2142
  QByteArray plainText;
2143
  plainText.duplicate( cText.data(), cText.length() ); // hrmpf...
2144
  QByteArray signature;
2151
  QByteArray signature;
2145
  const GpgME::SigningResult res =
2152
  const GpgME::SigningResult res =
2146
    job->exec( signingKeys, plainText, signingMode( format ), signature );
2153
    job->exec( signingKeys, cText, signingMode( format ), signature );
2147
  if ( res.error().isCanceled() ) {
2154
  if ( res.error().isCanceled() ) {
2148
    kdDebug() << "signing was canceled by user" << endl;
2155
    kdDebug() << "signing was canceled by user" << endl;
2149
    return;
2156
    return;
Lines 2165-2171 Link Here
2165
2172
2166
//-----------------------------------------------------------------------------
2173
//-----------------------------------------------------------------------------
2167
Kpgp::Result MessageComposer::pgpEncryptedMsg( QByteArray & encryptedBody,
2174
Kpgp::Result MessageComposer::pgpEncryptedMsg( QByteArray & encryptedBody,
2168
                                               const QCString & cText,
2175
                                               const QByteArray& cText,
2169
                                               const std::vector<GpgME::Key> & encryptionKeys,
2176
                                               const std::vector<GpgME::Key> & encryptionKeys,
2170
					       Kleo::CryptoMessageFormat format )
2177
					       Kleo::CryptoMessageFormat format )
2171
{
2178
{
Lines 2187-2197 Link Here
2187
    return Kpgp::Failure;
2194
    return Kpgp::Failure;
2188
  }
2195
  }
2189
2196
2190
  QByteArray plainText;
2191
  plainText.duplicate( cText.data(), cText.length() ); // hrmpf...
2192
2193
  const GpgME::EncryptionResult res =
2197
  const GpgME::EncryptionResult res =
2194
    job->exec( encryptionKeys, plainText, false, encryptedBody );
2198
    job->exec( encryptionKeys, cText, false, encryptedBody );
2195
  if ( res.error().isCanceled() ) {
2199
  if ( res.error().isCanceled() ) {
2196
    kdDebug() << "encryption was canceled by user" << endl;
2200
    kdDebug() << "encryption was canceled by user" << endl;
2197
    return Kpgp::Canceled;
2201
    return Kpgp::Canceled;
Lines 2205-2211 Link Here
2205
}
2209
}
2206
2210
2207
Kpgp::Result MessageComposer::pgpSignedAndEncryptedMsg( QByteArray & encryptedBody,
2211
Kpgp::Result MessageComposer::pgpSignedAndEncryptedMsg( QByteArray & encryptedBody,
2208
							const QCString & cText,
2212
							const QByteArray& cText,
2209
							const std::vector<GpgME::Key> & signingKeys,
2213
							const std::vector<GpgME::Key> & signingKeys,
2210
							const std::vector<GpgME::Key> & encryptionKeys,
2214
							const std::vector<GpgME::Key> & encryptionKeys,
2211
							Kleo::CryptoMessageFormat format )
2215
							Kleo::CryptoMessageFormat format )
Lines 2228-2238 Link Here
2228
    return Kpgp::Failure;
2232
    return Kpgp::Failure;
2229
  }
2233
  }
2230
2234
2231
  QByteArray plainText;
2232
  plainText.duplicate( cText.data(), cText.length() ); // hrmpf...
2233
2234
  const std::pair<GpgME::SigningResult,GpgME::EncryptionResult> res =
2235
  const std::pair<GpgME::SigningResult,GpgME::EncryptionResult> res =
2235
    job->exec( signingKeys, encryptionKeys, plainText, false, encryptedBody );
2236
    job->exec( signingKeys, encryptionKeys, cText, false, encryptedBody );
2236
  if ( res.first.error().isCanceled() || res.second.error().isCanceled() ) {
2237
  if ( res.first.error().isCanceled() || res.second.error().isCanceled() ) {
2237
    kdDebug() << "encrypt/sign was canceled by user" << endl;
2238
    kdDebug() << "encrypt/sign was canceled by user" << endl;
2238
    return Kpgp::Canceled;
2239
    return Kpgp::Canceled;
(-)kmail/messagecomposer.h (-9 / +10 lines)
Lines 92-97 Link Here
92
    return mMessageList;
92
    return mMessageList;
93
  }
93
  }
94
94
95
  bool isPerformingSignOperation() const { return mPerformingSignOperation; }
95
signals:
96
signals:
96
  void done( bool );
97
  void done( bool );
97
98
Lines 135-143 Link Here
135
   * Get message ready for sending or saving.
136
   * Get message ready for sending or saving.
136
   * This must be done _before_ signing and/or encrypting it.
137
   * This must be done _before_ signing and/or encrypting it.
137
   */
138
   */
138
  QCString breakLinesAndApplyCodec();
139
  QByteArray breakLinesAndApplyCodec();
139
  /// Same as above but ensure \n termination
140
  QCString bodyText();
141
140
142
  /**
141
  /**
143
   * Create a plain text version of a marked up mail for use as the plain
142
   * Create a plain text version of a marked up mail for use as the plain
Lines 149-161 Link Here
149
   * Get signature for a message (into mMessage).
148
   * Get signature for a message (into mMessage).
150
   * To build nice S/MIME objects signing and encoding must be separated.
149
   * To build nice S/MIME objects signing and encoding must be separated.
151
   */
150
   */
152
  void pgpSignedMsg( const QCString & cText, Kleo::CryptoMessageFormat f );
151
  void pgpSignedMsg( const QByteArray& cText, Kleo::CryptoMessageFormat f );
153
  /**
152
  /**
154
   * Get encrypted message.
153
   * Get encrypted message.
155
   * To build nice S/MIME objects signing and encrypting must be separate.
154
   * To build nice S/MIME objects signing and encrypting must be separate.
156
   */
155
   */
157
  Kpgp::Result pgpEncryptedMsg( QByteArray& rEncryptedBody,
156
  Kpgp::Result pgpEncryptedMsg( QByteArray& rEncryptedBody,
158
                                const QCString & cText,
157
                                const QByteArray& cText,
159
                                const std::vector<GpgME::Key> & encryptionKeys,
158
                                const std::vector<GpgME::Key> & encryptionKeys,
160
				Kleo::CryptoMessageFormat f );
159
				Kleo::CryptoMessageFormat f );
161
160
Lines 164-170 Link Here
164
   * To build nice S/MIME objects signing and encrypting must be separate.
163
   * To build nice S/MIME objects signing and encrypting must be separate.
165
   */
164
   */
166
  Kpgp::Result pgpSignedAndEncryptedMsg( QByteArray& rEncryptedBody,
165
  Kpgp::Result pgpSignedAndEncryptedMsg( QByteArray& rEncryptedBody,
167
					 const QCString & cText,
166
					 const QByteArray& cText,
168
					 const std::vector<GpgME::Key> & signingKeys,
167
					 const std::vector<GpgME::Key> & signingKeys,
169
					 const std::vector<GpgME::Key> & encryptionKeys,
168
					 const std::vector<GpgME::Key> & encryptionKeys,
170
					 Kleo::CryptoMessageFormat f );
169
					 Kleo::CryptoMessageFormat f );
Lines 192-198 Link Here
192
                               const QCString contentSubtypeClear,
191
                               const QCString contentSubtypeClear,
193
                               const QCString contentDispClear,
192
                               const QCString contentDispClear,
194
                               const QCString contentTEncClear,
193
                               const QCString contentTEncClear,
195
                               const QCString& bodytext,
194
                               const QByteArray& bodytext,
196
                               const QString contentDescriptionCiph,
195
                               const QString contentDescriptionCiph,
197
                               const QByteArray& ciphertext,
196
                               const QByteArray& ciphertext,
198
                               KMMessagePart& resultingPart,
197
                               KMMessagePart& resultingPart,
Lines 213-218 Link Here
213
212
214
private:
213
private:
215
  void doNextJob();
214
  void doNextJob();
215
  void emitDone( bool ok );
216
216
217
  int encryptionPossible( const QStringList & recipients, bool openPGP );
217
  int encryptionPossible( const QStringList & recipients, bool openPGP );
218
  bool determineWhetherToSign( bool doSignCompletely );
218
  bool determineWhetherToSign( bool doSignCompletely );
Lines 256-269 Link Here
256
  bool mRc; // Set this to false, if something fails during the processes
256
  bool mRc; // Set this to false, if something fails during the processes
257
  bool mHoldJobs; // Don't run the next job yet
257
  bool mHoldJobs; // Don't run the next job yet
258
258
259
  QCString mText; // textual representation of the message text, encoded
259
  QByteArray mText; // textual representation of the message text, encoded
260
  unsigned int mLineBreakColumn; // used for line breaking
260
  unsigned int mLineBreakColumn; // used for line breaking
261
261
262
  // These are the variables of the big composeMessage(X,Y,Z) message
262
  // These are the variables of the big composeMessage(X,Y,Z) message
263
  KMMessagePart* mNewBodyPart;
263
  KMMessagePart* mNewBodyPart;
264
  QByteArray mSignature;
264
  QByteArray mSignature;
265
265
266
  QCString mEncodedBody; // Only needed if signing and/or encrypting
266
  QByteArray mEncodedBody; // Only needed if signing and/or encrypting
267
  bool mEarlyAddAttachments, mAllAttachmentsAreInBody;
267
  bool mEarlyAddAttachments, mAllAttachmentsAreInBody;
268
  KMMessagePart mOldBodyPart;
268
  KMMessagePart mOldBodyPart;
269
  int mPreviousBoundaryLevel;
269
  int mPreviousBoundaryLevel;
Lines 274-279 Link Here
274
274
275
  QValueList<MessageComposerJob*> mJobs;
275
  QValueList<MessageComposerJob*> mJobs;
276
  bool mEncryptWithChiasmus;
276
  bool mEncryptWithChiasmus;
277
  bool mPerformingSignOperation;
277
};
278
};
278
279
279
#endif /* MESSAGECOMPOSER_H */
280
#endif /* MESSAGECOMPOSER_H */
(-)kmail/objecttreeparser.cpp (-6 / +4 lines)
Lines 401-407 Link Here
401
401
402
    if ( doCheck && cryptPlug ) {
402
    if ( doCheck && cryptPlug ) {
403
      if ( data ) {
403
      if ( data ) {
404
        cleartext = data->dwPart()->AsString().c_str();
404
        cleartext = KMail::Util::CString( data->dwPart()->AsString() );
405
405
406
        dumpToFile( "dat_01_reader_signedtext_before_canonicalization",
406
        dumpToFile( "dat_01_reader_signedtext_before_canonicalization",
407
                    cleartext.data(), cleartext.length() );
407
                    cleartext.data(), cleartext.length() );
Lines 970-978 Link Here
970
  }
970
  }
971
971
972
  bool ObjectTreeParser::processTextPlainSubtype( partNode * curNode, ProcessResult & result ) {
972
  bool ObjectTreeParser::processTextPlainSubtype( partNode * curNode, ProcessResult & result ) {
973
    const QCString cstr = curNode->msgPart().bodyDecoded();
974
    if ( !mReader ) {
973
    if ( !mReader ) {
975
      mRawReplyString = cstr;
974
      mRawReplyString = curNode->msgPart().bodyDecoded();
976
      if ( curNode->isFirstTextPart() ) {
975
      if ( curNode->isFirstTextPart() ) {
977
        mTextualContent += curNode->msgPart().bodyToUnicode();
976
        mTextualContent += curNode->msgPart().bodyToUnicode();
978
        mTextualContentCharset = curNode->msgPart().charset();
977
        mTextualContentCharset = curNode->msgPart().charset();
Lines 980-992 Link Here
980
      return true;
979
      return true;
981
    }
980
    }
982
981
983
    //resultingRawData += cstr;
984
    if ( !curNode->isFirstTextPart() &&
982
    if ( !curNode->isFirstTextPart() &&
985
         attachmentStrategy()->defaultDisplay( curNode ) != AttachmentStrategy::Inline &&
983
         attachmentStrategy()->defaultDisplay( curNode ) != AttachmentStrategy::Inline &&
986
         !showOnlyOneMimePart() )
984
         !showOnlyOneMimePart() )
987
      return false;
985
      return false;
988
986
989
    mRawReplyString = cstr;
987
    mRawReplyString = curNode->msgPart().bodyDecoded();
990
    if ( curNode->isFirstTextPart() ) {
988
    if ( curNode->isFirstTextPart() ) {
991
      mTextualContent += curNode->msgPart().bodyToUnicode();
989
      mTextualContent += curNode->msgPart().bodyToUnicode();
992
      mTextualContentCharset = curNode->msgPart().charset();
990
      mTextualContentCharset = curNode->msgPart().charset();
Lines 1029-1035 Link Here
1029
    // enable verification of the embedded messages' signatures
1027
    // enable verification of the embedded messages' signatures
1030
    if ( !isMailmanMessage( curNode ) ||
1028
    if ( !isMailmanMessage( curNode ) ||
1031
         !processMailmanMessage( curNode ) )
1029
         !processMailmanMessage( curNode ) )
1032
      writeBodyString( cstr, curNode->trueFromAddress(),
1030
      writeBodyString( mRawReplyString, curNode->trueFromAddress(),
1033
                       codecFor( curNode ), result, !bDrawFrame );
1031
                       codecFor( curNode ), result, !bDrawFrame );
1034
    if ( bDrawFrame )
1032
    if ( bDrawFrame )
1035
      htmlWriter()->queue( "</td></tr></table>" );
1033
      htmlWriter()->queue( "</td></tr></table>" );
(-)kmail/partNode.cpp (-1 / +2 lines)
Lines 37-42 Link Here
37
#include <mimelib/utility.h>
37
#include <mimelib/utility.h>
38
#include <qregexp.h>
38
#include <qregexp.h>
39
#include <kasciistricmp.h>
39
#include <kasciistricmp.h>
40
#include "util.h"
40
41
41
/*
42
/*
42
  ===========================================================================
43
  ===========================================================================
Lines 179-185 Link Here
179
    return mEncodedBody;
180
    return mEncodedBody;
180
181
181
  if ( mDwPart )
182
  if ( mDwPart )
182
    mEncodedBody = mDwPart->Body().AsString().c_str();
183
    mEncodedBody = KMail::Util::CString( mDwPart->Body().AsString() );
183
  else
184
  else
184
    mEncodedBody = 0;
185
    mEncodedBody = 0;
185
  mEncodedOk = true;
186
  mEncodedOk = true;
(-)kmail/recipientseditor.cpp (-2 / +3 lines)
Lines 318-325 Link Here
318
// ------------ RecipientsView ---------------------
318
// ------------ RecipientsView ---------------------
319
319
320
RecipientsView::RecipientsView( QWidget *parent )
320
RecipientsView::RecipientsView( QWidget *parent )
321
  : QScrollView( parent ), mCurDelLine( 0 ), mModified( false ),
321
  : QScrollView( parent ), mCurDelLine( 0 ),
322
    mFirstColumnWidth( 0 ), mLineHeight( 0 )
322
    mLineHeight( 0 ), mFirstColumnWidth( 0 ),
323
    mModified( false )
323
{
324
{
324
  mCompletionMode = KGlobalSettings::completionMode();
325
  mCompletionMode = KGlobalSettings::completionMode();
325
  setHScrollBarMode( AlwaysOff );
326
  setHScrollBarMode( AlwaysOff );
(-)kmail/renamejob.cpp (-2 / +2 lines)
Lines 228-234 Link Here
228
  // move all messages to the new folder
228
  // move all messages to the new folder
229
  QPtrList<KMMsgBase> msgList;
229
  QPtrList<KMMsgBase> msgList;
230
  if ( !mStorage->isOpened() )
230
  if ( !mStorage->isOpened() )
231
    mStorageTempOpened = mStorage->open() ? mStorage : 0;
231
    mStorageTempOpened = mStorage->open("renamejob") ? mStorage : 0;
232
  for ( int i = 0; i < mStorage->count(); i++ )
232
  for ( int i = 0; i < mStorage->count(); i++ )
233
  {
233
  {
234
    KMMsgBase* msgBase = mStorage->getMsgBase( i );
234
    KMMsgBase* msgBase = mStorage->getMsgBase( i );
Lines 251-257 Link Here
251
{
251
{
252
  kdDebug(5006) << k_funcinfo << (command?command->result():0) << endl;
252
  kdDebug(5006) << k_funcinfo << (command?command->result():0) << endl;
253
  if ( mStorageTempOpened ) {
253
  if ( mStorageTempOpened ) {
254
    mStorageTempOpened->close();
254
    mStorageTempOpened->close("renamejob");
255
    mStorageTempOpened = 0;
255
    mStorageTempOpened = 0;
256
  }
256
  }
257
  if ( command ) {
257
  if ( command ) {
(-)kmail/searchjob.cpp (-1 / +6 lines)
Lines 222-228 Link Here
222
    for ( QStringList::Iterator it = mImapSearchHits.begin(); 
222
    for ( QStringList::Iterator it = mImapSearchHits.begin(); 
223
        it != mImapSearchHits.end(); ++it ) 
223
        it != mImapSearchHits.end(); ++it ) 
224
    {
224
    {
225
      serNums.append( mFolder->serNumForUID( (*it).toULong() ) );
225
      ulong serNum = mFolder->serNumForUID( (*it).toULong() );
226
      // we need to check that the local folder does contain a message for this UID. 
227
      // scenario: server responds with a list of UIDs.  While the search was running, filtering or bad juju moved a message locally
228
      // serNumForUID will happily return 0 for the missing message, and KMFolderSearch::addSerNum() will fail its assertion.
229
      if ( serNum != 0 ) 
230
        serNums.append( serNum );
226
    }
231
    }
227
    emit searchDone( serNums, mSearchPattern, true );
232
    emit searchDone( serNums, mSearchPattern, true );
228
  } else {
233
  } else {
(-)kmail/searchwindow.cpp (-3 / +3 lines)
Lines 313-319 Link Here
313
  for ( fit = mFolders.begin(); fit != mFolders.end(); ++fit ) {
313
  for ( fit = mFolders.begin(); fit != mFolders.end(); ++fit ) {
314
    if (!(*fit))
314
    if (!(*fit))
315
      continue;
315
      continue;
316
    (*fit)->close();
316
    (*fit)->close("searchwindow");
317
  }
317
  }
318
318
319
  KConfig* config = KMKernel::config();
319
  KConfig* config = KMKernel::config();
Lines 470-476 Link Here
470
    enableGUI();
470
    enableGUI();
471
471
472
    if (mFolder && !mFolders.contains(mFolder.operator->()->folder())) {
472
    if (mFolder && !mFolders.contains(mFolder.operator->()->folder())) {
473
        mFolder->open();
473
        mFolder->open("searchwindow");
474
        mFolders.append(mFolder.operator->()->folder());
474
        mFolders.append(mFolder.operator->()->folder());
475
    }
475
    }
476
    mTimer->start(200);
476
    mTimer->start(200);
Lines 502-508 Link Here
502
    KMFolder *pFolder = msg->parent();
502
    KMFolder *pFolder = msg->parent();
503
    if (!mFolders.contains(pFolder)) {
503
    if (!mFolders.contains(pFolder)) {
504
        mFolders.append(pFolder);
504
        mFolders.append(pFolder);
505
        pFolder->open();
505
        pFolder->open("searchwindow");
506
    }
506
    }
507
    if(pFolder->whoField() == "To")
507
    if(pFolder->whoField() == "To")
508
        from = msg->to();
508
        from = msg->to();
(-)kmail/undostack.cpp (-2 / +2 lines)
Lines 88-94 Link Here
88
    UndoInfo *info = mStack.take(0);
88
    UndoInfo *info = mStack.take(0);
89
    emit undoStackChanged();
89
    emit undoStackChanged();
90
    QValueList<ulong>::iterator itr;
90
    QValueList<ulong>::iterator itr;
91
    info->destFolder->open();
91
    info->destFolder->open("undodest");
92
    for( itr = info->serNums.begin(); itr != info->serNums.end(); ++itr ) {
92
    for( itr = info->serNums.begin(); itr != info->serNums.end(); ++itr ) {
93
      serNum = *itr;
93
      serNum = *itr;
94
      KMMsgDict::instance()->getLocation(serNum, &curFolder, &idx);
94
      KMMsgDict::instance()->getLocation(serNum, &curFolder, &idx);
Lines 102-108 Link Here
102
      if ( info->srcFolder->count() > 1 )
102
      if ( info->srcFolder->count() > 1 )
103
        info->srcFolder->unGetMsg( info->srcFolder->count() - 1 );
103
        info->srcFolder->unGetMsg( info->srcFolder->count() - 1 );
104
    }
104
    }
105
    info->destFolder->close();
105
    info->destFolder->close("undodest");
106
    delete info;
106
    delete info;
107
  }
107
  }
108
  else
108
  else
(-)kmail/util.cpp (-1 / +106 lines)
Lines 39-44 Link Here
39
39
40
#include <stdlib.h>
40
#include <stdlib.h>
41
#include <qcstring.h>
41
#include <qcstring.h>
42
#include <mimelib/string.h>
42
43
43
size_t KMail::Util::crlf2lf( char* str, const size_t strLen )
44
size_t KMail::Util::crlf2lf( char* str, const size_t strLen )
44
{
45
{
Lines 72-78 Link Here
72
73
73
QCString KMail::Util::lf2crlf( const QCString & src )
74
QCString KMail::Util::lf2crlf( const QCString & src )
74
{
75
{
75
    QCString result( 1 + 2*src.length() );  // maximal possible length
76
    QCString result( 1 + 2*src.size() );  // maximal possible length
76
77
77
    QCString::ConstIterator s = src.begin();
78
    QCString::ConstIterator s = src.begin();
78
    QCString::Iterator d = result.begin();
79
    QCString::Iterator d = result.begin();
Lines 87-89 Link Here
87
    result.truncate( d - result.begin() ); // adds trailing NUL
88
    result.truncate( d - result.begin() ); // adds trailing NUL
88
    return result;
89
    return result;
89
}
90
}
91
92
QByteArray KMail::Util::lf2crlf( const QByteArray & src )
93
{
94
    const char* s = src.data();
95
    if ( !s )
96
      return QByteArray();
97
98
    QByteArray result( 2 * src.size() );  // maximal possible length
99
    QByteArray::Iterator d = result.begin();
100
    // we use cPrev to make sure we insert '\r' only there where it is missing
101
    char cPrev = '?';
102
    const char* end = src.end();
103
    while ( s != end ) {
104
        if ( ('\n' == *s) && ('\r' != cPrev) )
105
            *d++ = '\r';
106
        cPrev = *s;
107
        *d++ = *s++;
108
    }
109
    result.truncate( d - result.begin() ); // does not add trailing NUL, as expected
110
    return result;
111
}
112
113
QCString KMail::Util::CString( const DwString& str )
114
{
115
  const int strLen = str.size();
116
  QCString cstr( strLen + 1 );
117
  memcpy( cstr.data(), str.data(), strLen );
118
  cstr[ strLen ] = 0;
119
  return cstr;
120
}
121
122
QByteArray KMail::Util::ByteArray( const DwString& str )
123
{
124
  const int strLen = str.size();
125
  QByteArray arr( strLen );
126
  memcpy( arr.data(), str.data(), strLen );
127
  return arr;
128
}
129
130
DwString KMail::Util::dwString( const QCString& str )
131
{
132
  if ( !str.data() ) // DwString doesn't like char*=0
133
    return DwString();
134
  return DwString( str.data(), str.size() - 1 );
135
}
136
137
DwString KMail::Util::dwString( const QByteArray& str )
138
{
139
  if ( !str.data() ) // DwString doesn't like char*=0
140
    return DwString();
141
  return DwString( str.data(), str.size() );
142
}
143
144
void KMail::Util::append( QByteArray& that, const QByteArray& str )
145
{
146
  that.detach();
147
  uint len1 = that.size();
148
  uint len2 = str.size();
149
  if ( that.resize( len1 + len2, QByteArray::SpeedOptim ) )
150
    memcpy( that.data() + len1, str.data(), len2 );
151
}
152
153
void KMail::Util::append( QByteArray& that, const char* str )
154
{
155
  if ( !str )
156
    return; // nothing to append
157
  that.detach();
158
  uint len1 = that.size();
159
  uint len2 = qstrlen(str);
160
  if ( that.resize( len1 + len2, QByteArray::SpeedOptim ) )
161
    memcpy( that.data() + len1, str, len2 );
162
}
163
164
void KMail::Util::append( QByteArray& that, const QCString& str )
165
{
166
  that.detach();
167
  uint len1 = that.size();
168
  uint len2 = str.size() - 1;
169
  if ( that.resize( len1 + len2, QByteArray::SpeedOptim ) )
170
    memcpy( that.data() + len1, str.data(), len2 );
171
}
172
173
// Code taken from QCString::insert, but trailing nul removed
174
void KMail::Util::insert( QByteArray& that, uint index, const char* s )
175
{
176
  int len = qstrlen(s);
177
  if ( len == 0 )
178
    return;
179
  uint olen = that.size();
180
  int nlen = olen + len;
181
  if ( index >= olen ) {                      // insert after end of string
182
    that.detach();
183
    if ( that.resize(nlen+index-olen, QByteArray::SpeedOptim ) ) {
184
      memset( that.data()+olen, ' ', index-olen );
185
      memcpy( that.data()+index, s, len );
186
    }
187
  } else {
188
    that.detach();
189
    if ( that.resize(nlen, QByteArray::SpeedOptim ) ) {    // normal insert
190
      memmove( that.data()+index+len, that.data()+index, olen-index );
191
      memcpy( that.data()+index, s, len );
192
    }
193
  }
194
}
(-)kmail/util.h (-1 / +95 lines)
Lines 41-46 Link Here
41
#include <stdlib.h>
41
#include <stdlib.h>
42
#include <qobject.h>
42
#include <qobject.h>
43
#include <qcstring.h>
43
#include <qcstring.h>
44
class DwString;
44
45
45
namespace KMail
46
namespace KMail
46
{
47
{
Lines 66-75 Link Here
66
     * @return The result string.
67
     * @return The result string.
67
     */
68
     */
68
    QCString lf2crlf( const QCString & src );
69
    QCString lf2crlf( const QCString & src );
70
    /**
71
     * Convert "\n" line endings to "\r\n".
72
     * @param src The source string to convert. NOT null-terminated.
73
     * @return The result string. NOT null-terminated.
74
     */
75
    QByteArray lf2crlf( const QByteArray & src );
76
77
    /**
78
     * Construct a QCString from a DwString
79
     */
80
    QCString CString( const DwString& str );
81
82
    /**
83
     * Construct a QByteArray from a DwString
84
     */
85
    QByteArray ByteArray( const DwString& str );
86
87
    /**
88
     * Construct a DwString from a QCString
89
     */
90
    DwString dwString( const QCString& str );
91
92
    /**
93
     * Construct a DwString from a QByteArray
94
     */
95
    DwString dwString( const QByteArray& str );
96
97
    /**
98
     * Fills a QByteArray from a QCString - removing the trailing null.
99
     */
100
    void setFromQCString( QByteArray& arr, const QCString& cstr );
101
102
    inline void setFromQCString( QByteArray& arr, const QCString& cstr )
103
    {
104
      if ( cstr.size() )
105
        arr.duplicate( cstr.data(), cstr.size()-1 );
106
      else
107
        arr.resize(0);
108
    }
109
110
    /**
111
     * Creates a QByteArray from a QCString without detaching (duplicating the data).
112
     * Fast, but be careful, the QCString gets modified by this; this is only good for
113
     * the case where the QCString is going to be thrown away afterwards anyway.
114
     */
115
    QByteArray byteArrayFromQCStringNoDetach( QCString& cstr );
116
    inline QByteArray byteArrayFromQCStringNoDetach( QCString& cstr )
117
    {
118
      QByteArray arr = cstr;
119
      if ( arr.size() )
120
        arr.resize( arr.size() - 1 );
121
      return arr;
122
    }
123
124
    /**
125
     * Restore the QCString after byteArrayFromQCStringNoDetach modified it
126
     */
127
    void restoreQCString( QCString& str );
128
    inline void restoreQCString( QCString& str )
129
    {
130
      if ( str.data() )
131
        str.resize( str.size() + 1 );
132
    }
133
134
    /**
135
     * Fills a QCString from a QByteArray - adding the trailing null.
136
     */
137
    void setFromByteArray( QCString& cstr, const QByteArray& arr );
138
139
    inline void setFromByteArray( QCString& result, const QByteArray& arr )
140
    {
141
      const int len = arr.size();
142
      result.resize( len + 1 /* trailing NUL */ );
143
      memcpy(result.data(), arr.data(), len);
144
      result[len] = 0;
145
    }
146
147
    /**
148
     * Append a bytearray to a bytearray. No trailing nuls anywhere.
149
     */
150
    void append( QByteArray& that, const QByteArray& str );
151
152
    /**
153
     * Append a char* to a bytearray. Trailing nul not copied.
154
     */
155
    void append( QByteArray& that, const char* str );
156
157
    /**
158
     * Append a QCString to a bytearray. Trailing nul not copied.
159
     */
160
    void append( QByteArray& that, const QCString& str );
161
162
    void insert( QByteArray& that, uint index, const char* s );
69
163
70
    /**
164
    /**
71
     * A LaterDeleter is intended to be used with the RAII ( Resource
165
     * A LaterDeleter is intended to be used with the RAII ( Resource
72
     * Acquisiation is Initialization ) paradigm. When an instance of it
166
     * Acquisition is Initialization ) paradigm. When an instance of it
73
     * goes out of scope it deletes the associated object  It can be 
167
     * goes out of scope it deletes the associated object  It can be 
74
     * disabled, in case the deletion needs to be avoided for some 
168
     * disabled, in case the deletion needs to be avoided for some 
75
     * reason, since going out-of-scope cannot be avoided.
169
     * reason, since going out-of-scope cannot be avoided.
(-)kmail/kmheaders.cpp (-3 / +21 lines)
Lines 15-20 Link Here
15
#include "kmmsgdict.h"
15
#include "kmmsgdict.h"
16
#include "kmdebug.h"
16
#include "kmdebug.h"
17
#include "kmfoldertree.h"
17
#include "kmfoldertree.h"
18
#include "kmfolderimap.h"
18
#include "folderjob.h"
19
#include "folderjob.h"
19
using KMail::FolderJob;
20
using KMail::FolderJob;
20
#include "actionscheduler.h"
21
#include "actionscheduler.h"
Lines 215-221 Link Here
215
  {
216
  {
216
    writeFolderConfig();
217
    writeFolderConfig();
217
    writeSortOrder();
218
    writeSortOrder();
218
    mFolder->close();
219
    if (mFolder->folderType() == KMFolderTypeImap)
220
    {
221
      KMFolderImap *imap = static_cast<KMFolderImap*>(mFolder->storage());
222
      imap->setSelected( false );
223
    }
224
    mFolder->close("kmheaders");
219
  }
225
  }
220
  writeConfig();
226
  writeConfig();
221
  delete mRoot;
227
  delete mRoot;
Lines 666-672 Link Here
666
                  BroadcastStatus::instance(), SLOT( setStatusMsg( const QString& ) ) );
672
                  BroadcastStatus::instance(), SLOT( setStatusMsg( const QString& ) ) );
667
      disconnect(mFolder, SIGNAL(viewConfigChanged()), this, SLOT(reset()));
673
      disconnect(mFolder, SIGNAL(viewConfigChanged()), this, SLOT(reset()));
668
      writeSortOrder();
674
      writeSortOrder();
669
      mFolder->close();
675
      mFolder->close("kmheaders");
670
      // System folders remain open but we also should write the index from
676
      // System folders remain open but we also should write the index from
671
      // time to time
677
      // time to time
672
      if (mFolder->dirty()) mFolder->writeIndex();
678
      if (mFolder->dirty()) mFolder->writeIndex();
Lines 715-721 Link Here
715
721
716
      CREATE_TIMER(kmfolder_open);
722
      CREATE_TIMER(kmfolder_open);
717
      START_TIMER(kmfolder_open);
723
      START_TIMER(kmfolder_open);
718
      mFolder->open();
724
      mFolder->open("kmheaders");
719
      END_TIMER(kmfolder_open);
725
      END_TIMER(kmfolder_open);
720
      SHOW_TIMER(kmfolder_open);
726
      SHOW_TIMER(kmfolder_open);
721
727
Lines 1725-1730 Link Here
1725
1731
1726
void KMHeaders::selectNextMessage()
1732
void KMHeaders::selectNextMessage()
1727
{
1733
{
1734
  KMMessage *cm = currentMsg();
1735
  if ( cm && cm->isBeingParsed() )
1736
    return;
1728
  QListViewItem *lvi = currentItem();
1737
  QListViewItem *lvi = currentItem();
1729
  if( lvi ) {
1738
  if( lvi ) {
1730
    QListViewItem *below = lvi->itemBelow();
1739
    QListViewItem *below = lvi->itemBelow();
Lines 1759-1764 Link Here
1759
1768
1760
void KMHeaders::selectPrevMessage()
1769
void KMHeaders::selectPrevMessage()
1761
{
1770
{
1771
  KMMessage *cm = currentMsg();
1772
  if ( cm && cm->isBeingParsed() )
1773
    return;
1762
  QListViewItem *lvi = currentItem();
1774
  QListViewItem *lvi = currentItem();
1763
  if( lvi ) {
1775
  if( lvi ) {
1764
    QListViewItem *above = lvi->itemAbove();
1776
    QListViewItem *above = lvi->itemAbove();
Lines 1782-1787 Link Here
1782
1794
1783
void KMHeaders::incCurrentMessage()
1795
void KMHeaders::incCurrentMessage()
1784
{
1796
{
1797
  KMMessage *cm = currentMsg();
1798
  if ( cm && cm->isBeingParsed() )
1799
    return;
1785
  QListViewItem *lvi = currentItem();
1800
  QListViewItem *lvi = currentItem();
1786
  if ( lvi && lvi->itemBelow() ) {
1801
  if ( lvi && lvi->itemBelow() ) {
1787
1802
Lines 1797-1802 Link Here
1797
1812
1798
void KMHeaders::decCurrentMessage()
1813
void KMHeaders::decCurrentMessage()
1799
{
1814
{
1815
  KMMessage *cm = currentMsg();
1816
  if ( cm && cm->isBeingParsed() )
1817
    return;
1800
  QListViewItem *lvi = currentItem();
1818
  QListViewItem *lvi = currentItem();
1801
  if ( lvi && lvi->itemAbove() ) {
1819
  if ( lvi && lvi->itemAbove() ) {
1802
    disconnect(this,SIGNAL(currentChanged(QListViewItem*)),
1820
    disconnect(this,SIGNAL(currentChanged(QListViewItem*)),
(-)kmail/kmfilteraction.cpp (-4 / +6 lines)
Lines 22-27 Link Here
22
#include <libkdepim/kfileio.h>
22
#include <libkdepim/kfileio.h>
23
#include <libkdepim/collectingprocess.h>
23
#include <libkdepim/collectingprocess.h>
24
using KPIM::CollectingProcess;
24
using KPIM::CollectingProcess;
25
#include <mimelib/message.h>
25
#include "kmfawidgets.h"
26
#include "kmfawidgets.h"
26
#include "folderrequester.h"
27
#include "folderrequester.h"
27
using KMail::FolderRequester;
28
using KMail::FolderRequester;
Lines 1377-1394 Link Here
1377
  // TODO opening and closing the folder is a trade off.
1378
  // TODO opening and closing the folder is a trade off.
1378
  // Perhaps Copy is a seldomly used action for now,
1379
  // Perhaps Copy is a seldomly used action for now,
1379
  // but I gonna look at improvements ASAP.
1380
  // but I gonna look at improvements ASAP.
1380
  if ( !mFolder && mFolder->open() != 0 )
1381
  if ( !mFolder )
1382
    return ErrorButGoOn;
1383
  if ( mFolder->open("filtercopy") != 0 )
1381
    return ErrorButGoOn;
1384
    return ErrorButGoOn;
1382
1385
1383
  // copy the message 1:1
1386
  // copy the message 1:1
1384
  KMMessage* msgCopy = new KMMessage;
1387
  KMMessage* msgCopy = new KMMessage( new DwMessage( *msg->asDwMessage() ) );
1385
  msgCopy->fromDwString(msg->asDwString());
1386
1388
1387
  int index;
1389
  int index;
1388
  int rc = mFolder->addMsg(msgCopy, &index);
1390
  int rc = mFolder->addMsg(msgCopy, &index);
1389
  if (rc == 0 && index != -1)
1391
  if (rc == 0 && index != -1)
1390
    mFolder->unGetMsg( index );
1392
    mFolder->unGetMsg( index );
1391
  mFolder->close();
1393
  mFolder->close("filtercopy");
1392
1394
1393
  return GoOn;
1395
  return GoOn;
1394
}
1396
}
(-)kmail/kmcomposewin.cpp (-32 / +86 lines)
Lines 176-182 Link Here
176
    mEncryptWithChiasmus( false ),
176
    mEncryptWithChiasmus( false ),
177
    mComposer( 0 ),
177
    mComposer( 0 ),
178
    mLabelWidth( 0 ),
178
    mLabelWidth( 0 ),
179
    mAutoSaveTimer( 0 ), mLastAutoSaveErrno( 0 )
179
    mAutoSaveTimer( 0 ), mLastAutoSaveErrno( 0 ),
180
    mPreserveUserCursorPosition( false )
180
{
181
{
181
  mClassicalRecipients = GlobalSettings::self()->recipientsEditorType() ==
182
  mClassicalRecipients = GlobalSettings::self()->recipientsEditorType() ==
182
    GlobalSettings::EnumRecipientsEditorType::Classic;
183
    GlobalSettings::EnumRecipientsEditorType::Classic;
Lines 476-484 Link Here
476
  if (!data.isEmpty()) {
477
  if (!data.isEmpty()) {
477
    KMMessagePart *msgPart = new KMMessagePart;
478
    KMMessagePart *msgPart = new KMMessagePart;
478
    msgPart->setName(name);
479
    msgPart->setName(name);
479
    QValueList<int> dummy;
480
    if( type == "message" && subType == "rfc822" ) {
480
    msgPart->setBodyAndGuessCte(data, dummy,
481
       msgPart->setMessageBody( data );
481
                                kmkernel->msgSender()->sendQuotedPrintable());
482
    } else {
483
       QValueList<int> dummy;
484
       msgPart->setBodyAndGuessCte(data, dummy,
485
              kmkernel->msgSender()->sendQuotedPrintable());
486
    }
482
    msgPart->setTypeStr(type);
487
    msgPart->setTypeStr(type);
483
    msgPart->setSubtypeStr(subType);
488
    msgPart->setSubtypeStr(subType);
484
    msgPart->setParameter(paramAttr,paramValue);
489
    msgPart->setParameter(paramAttr,paramValue);
Lines 706-713 Link Here
706
  if ( status == 0 ) { // no error
711
  if ( status == 0 ) { // no error
707
    kdDebug(5006) << "autosaving message in " << filename << endl;
712
    kdDebug(5006) << "autosaving message in " << filename << endl;
708
    int fd = autoSaveFile.handle();
713
    int fd = autoSaveFile.handle();
709
    QCString msgStr = msg->asString();
714
    const DwString& msgStr = msg->asDwString();
710
    if ( ::write( fd, msgStr, msgStr.length() ) == -1 )
715
    if ( ::write( fd, msgStr.data(), msgStr.length() ) == -1 )
711
      status = errno;
716
      status = errno;
712
  }
717
  }
713
  if ( status == 0 ) {
718
  if ( status == 0 ) {
Lines 1701-1706 Link Here
1701
      return;
1706
      return;
1702
    }
1707
    }
1703
  mMsg = newMsg;
1708
  mMsg = newMsg;
1709
  KPIM::IdentityManager * im = kmkernel->identityManager();
1704
1710
1705
  mEdtFrom->setText(mMsg->from());
1711
  mEdtFrom->setText(mMsg->from());
1706
  mEdtReplyTo->setText(mMsg->replyTo());
1712
  mEdtReplyTo->setText(mMsg->replyTo());
Lines 1712-1717 Link Here
1712
    mRecipientsEditor->setRecipientString( mMsg->to(), Recipient::To );
1718
    mRecipientsEditor->setRecipientString( mMsg->to(), Recipient::To );
1713
    mRecipientsEditor->setRecipientString( mMsg->cc(), Recipient::Cc );
1719
    mRecipientsEditor->setRecipientString( mMsg->cc(), Recipient::Cc );
1714
    mRecipientsEditor->setRecipientString( mMsg->bcc(), Recipient::Bcc );
1720
    mRecipientsEditor->setRecipientString( mMsg->bcc(), Recipient::Bcc );
1721
    mRecipientsEditor->setFocusBottom();
1715
  }
1722
  }
1716
  mEdtSubject->setText(mMsg->subject());
1723
  mEdtSubject->setText(mMsg->subject());
1717
1724
Lines 1733-1742 Link Here
1733
    // make sure the header values are overwritten with the values of the
1740
    // make sure the header values are overwritten with the values of the
1734
    // sticky identity (the slot isn't called by the signal for new messages
1741
    // sticky identity (the slot isn't called by the signal for new messages
1735
    // since the identity has already been set before the signal was connected)
1742
    // since the identity has already been set before the signal was connected)
1736
    slotIdentityChanged( mId );
1743
    uint savedId = mId;
1744
    if ( !newMsg->headerField("X-KMail-Identity").isEmpty() )
1745
      mId = newMsg->headerField("X-KMail-Identity").stripWhiteSpace().toUInt();
1746
    else
1747
      mId = im->defaultIdentity().uoid();
1748
    slotIdentityChanged( savedId );
1737
  }
1749
  }
1738
1750
1739
  KPIM::IdentityManager * im = kmkernel->identityManager();
1740
1751
1741
  const KPIM::Identity & ident = im->identityForUoid( mIdentity->currentIdentity() );
1752
  const KPIM::Identity & ident = im->identityForUoid( mIdentity->currentIdentity() );
1742
1753
Lines 1839-1858 Link Here
1839
1850
1840
  mEditor->setText( otp.textualContent() );
1851
  mEditor->setText( otp.textualContent() );
1841
  mCharset = otp.textualContentCharset();
1852
  mCharset = otp.textualContentCharset();
1842
  if ( mCharset.isEmpty() )
1843
    mCharset = mMsg->charset();
1844
  if ( mCharset.isEmpty() )
1845
    mCharset = mDefCharset;
1846
  setCharset( mCharset );
1847
1848
  if ( partNode * n = root->findType( DwMime::kTypeText, DwMime::kSubtypeHtml ) )
1853
  if ( partNode * n = root->findType( DwMime::kTypeText, DwMime::kSubtypeHtml ) )
1849
    if ( partNode * p = n->parentNode() )
1854
    if ( partNode * p = n->parentNode() )
1850
      if ( p->hasType( DwMime::kTypeMultipart ) &&
1855
      if ( p->hasType( DwMime::kTypeMultipart ) &&
1851
           p->hasSubType( DwMime::kSubtypeAlternative ) )
1856
           p->hasSubType( DwMime::kSubtypeAlternative ) )
1852
        if ( mMsg->headerField( "X-KMail-Markup" ) == "true" ) {
1857
        if ( mMsg->headerField( "X-KMail-Markup" ) == "true" ) {
1853
          toggleMarkup( true );
1858
          toggleMarkup( true );
1854
          mEditor->setText(n->encodedBody() );
1859
1860
          // get cte decoded body part
1861
          mCharset = n->msgPart().charset();
1862
          QCString bodyDecoded = n->msgPart().bodyDecoded();
1863
1864
          // respect html part charset
1865
          const QTextCodec *codec = KMMsgBase::codecForName( mCharset );
1866
          if ( codec ) {
1867
            mEditor->setText( codec->toUnicode( bodyDecoded ) );
1868
          } else {
1869
            mEditor->setText( QString::fromLocal8Bit( bodyDecoded ) );
1870
          }
1855
        }
1871
        }
1872
1873
  if ( mCharset.isEmpty() )
1874
    mCharset = mMsg->charset();
1875
  if ( mCharset.isEmpty() )
1876
    mCharset = mDefCharset;
1877
  setCharset( mCharset );
1878
1856
  /* Handle the special case of non-mime mails */
1879
  /* Handle the special case of non-mime mails */
1857
  if ( mMsg->numBodyParts() == 0 && otp.textualContent().isEmpty() ) {
1880
  if ( mMsg->numBodyParts() == 0 && otp.textualContent().isEmpty() ) {
1858
    mCharset=mMsg->charset();
1881
    mCharset=mMsg->charset();
Lines 1870-1877 Link Here
1870
    } else
1893
    } else
1871
      mEditor->setText(QString::fromLocal8Bit(bodyDecoded));
1894
      mEditor->setText(QString::fromLocal8Bit(bodyDecoded));
1872
  }
1895
  }
1873
1874
1875
#ifdef BROKEN_FOR_OPAQUE_SIGNED_OR_ENCRYPTED_MAILS
1896
#ifdef BROKEN_FOR_OPAQUE_SIGNED_OR_ENCRYPTED_MAILS
1876
  const int num = mMsg->numBodyParts();
1897
  const int num = mMsg->numBodyParts();
1877
  kdDebug(5006) << "KMComposeWin::setMsg() mMsg->numBodyParts="
1898
  kdDebug(5006) << "KMComposeWin::setMsg() mMsg->numBodyParts="
Lines 1973-1978 Link Here
1973
    //
1994
    //
1974
    QTimer::singleShot( 200, this, SLOT(slotAppendSignature()) );
1995
    QTimer::singleShot( 200, this, SLOT(slotAppendSignature()) );
1975
  }
1996
  }
1997
1998
  if ( mMsg->getCursorPos() > 0 ) {
1999
    // The message has a cursor position explicitly set, so avoid
2000
    // changing it when appending the signature.
2001
    mPreserveUserCursorPosition = true;
2002
  }
1976
  setModified( isModified );
2003
  setModified( isModified );
1977
2004
1978
  // do this even for new messages
2005
  // do this even for new messages
Lines 2034-2039 Link Here
2034
    return false;
2061
    return false;
2035
  if ( kmkernel->shuttingDown() || kapp->sessionSaving() )
2062
  if ( kmkernel->shuttingDown() || kapp->sessionSaving() )
2036
    return true;
2063
    return true;
2064
  if ( mComposer && mComposer->isPerformingSignOperation() ) // since the non-gpg-agent gpg plugin gets a passphrase using QDialog::exec()
2065
    return false;                                            // the user can try to close the window, which destroys mComposer mid-call.
2037
2066
2038
  if ( isModified() ) {
2067
  if ( isModified() ) {
2039
    bool istemplate = ( mFolder!=0 && mFolder->isTemplates() );
2068
    bool istemplate = ( mFolder!=0 && mFolder->isTemplates() );
Lines 2637-2645 Link Here
2637
  msgPart = new KMMessagePart;
2666
  msgPart = new KMMessagePart;
2638
  msgPart->setName(name);
2667
  msgPart->setName(name);
2639
  QValueList<int> allowedCTEs;
2668
  QValueList<int> allowedCTEs;
2640
  msgPart->setBodyAndGuessCte((*it).data, allowedCTEs,
2669
  if ( mimeType == "message/rfc822" ) {
2641
                              !kmkernel->msgSender()->sendQuotedPrintable());
2670
    msgPart->setMessageBody( (*it).data );
2642
  kdDebug(5006) << "autodetected cte: " << msgPart->cteStr() << endl;
2671
    allowedCTEs << DwMime::kCte7bit;
2672
    allowedCTEs << DwMime::kCte8bit;
2673
  } else {
2674
    msgPart->setBodyAndGuessCte((*it).data, allowedCTEs,
2675
                               !kmkernel->msgSender()->sendQuotedPrintable());
2676
    kdDebug(5006) << "autodetected cte: " << msgPart->cteStr() << endl;
2677
  }
2643
  int slash = mimeType.find( '/' );
2678
  int slash = mimeType.find( '/' );
2644
  if( slash == -1 )
2679
  if( slash == -1 )
2645
    slash = mimeType.length();
2680
    slash = mimeType.length();
Lines 3766-3778 Link Here
3766
                               "not have to enter it for each message.") );
3801
                               "not have to enter it for each message.") );
3767
      return;
3802
      return;
3768
    }
3803
    }
3769
    if (to().isEmpty() && cc().isEmpty() && bcc().isEmpty())
3804
    if ( to().isEmpty() ) {
3770
    {
3805
      if (  cc().isEmpty() && bcc().isEmpty()) {
3771
      if ( mEdtTo ) mEdtTo->setFocus();
3806
        if ( mEdtTo ) mEdtTo->setFocus();
3772
      KMessageBox::information( this,
3807
        KMessageBox::information( this,
3773
                                i18n("You must specify at least one receiver,"
3808
                                  i18n("You must specify at least one receiver,"
3774
                                     "either in the To: field or as CC or as BCC.") );
3809
                                       "either in the To: field or as CC or as BCC.") );
3775
      return;
3810
        return;
3811
      } else {
3812
        if ( mEdtTo )mEdtTo->setFocus();
3813
        int rc = KMessageBox::questionYesNo( this,
3814
                                             i18n("To: field is empty. "
3815
                                                  "Send message anyway?"),
3816
                                             i18n("No To: specified") );
3817
        if ( rc == KMessageBox::No ) {
3818
          return;
3819
        }
3820
      }
3776
    }
3821
    }
3777
3822
3778
    // Validate the To:, CC: and BCC fields
3823
    // Validate the To:, CC: and BCC fields
Lines 3891-3902 Link Here
3891
  if ( imapTheFolder && imapTheFolder->noContent() )
3936
  if ( imapTheFolder && imapTheFolder->noContent() )
3892
    imapTheFolder = 0;
3937
    imapTheFolder = 0;
3893
3938
3894
  if ( theFolder == 0 ) {
3939
  if ( theFolder == 0 )
3895
    theFolder = ( mSaveIn==KMComposeWin::Drafts ?
3940
    theFolder = ( mSaveIn==KMComposeWin::Drafts ?
3896
                  kmkernel->draftsFolder() : kmkernel->templatesFolder() );
3941
                  kmkernel->draftsFolder() : kmkernel->templatesFolder() );
3897
  } else {
3942
3898
    theFolder->open();
3943
  theFolder->open("composer");
3899
  }
3944
3900
  kdDebug(5006) << k_funcinfo << "theFolder=" << theFolder->name() << endl;
3945
  kdDebug(5006) << k_funcinfo << "theFolder=" << theFolder->name() << endl;
3901
  if ( imapTheFolder )
3946
  if ( imapTheFolder )
3902
    kdDebug(5006) << k_funcinfo << "imapTheFolder=" << imapTheFolder->name() << endl;
3947
    kdDebug(5006) << k_funcinfo << "imapTheFolder=" << imapTheFolder->name() << endl;
Lines 3914-3919 Link Here
3914
    (static_cast<KMFolderImap*>( imapTheFolder->storage() ))->getFolder();
3959
    (static_cast<KMFolderImap*>( imapTheFolder->storage() ))->getFolder();
3915
  }
3960
  }
3916
3961
3962
  theFolder->close( "composer" );
3917
  return sentOk;
3963
  return sentOk;
3918
}
3964
}
3919
3965
Lines 4049-4055 Link Here
4049
    mEditor->append(mOldSigText);
4095
    mEditor->append(mOldSigText);
4050
    mEditor->setModified(mod);
4096
    mEditor->setModified(mod);
4051
    // mEditor->setContentsPos( 0, 0 );
4097
    // mEditor->setContentsPos( 0, 0 );
4052
    mEditor->setCursorPositionFromStart( (unsigned int) mMsg->getCursorPos() );
4098
    if (  mPreserveUserCursorPosition ) {
4099
      mEditor->setCursorPositionFromStart( (unsigned int) mMsg->getCursorPos() );
4100
      // Only keep the cursor from the mMsg *once* based on the
4101
      // preserve-cursor-position setting; this handles the case where
4102
      // the message comes from a template with a specific cursor
4103
      // position set and the signature is appended automatically.
4104
      mPreserveUserCursorPosition = false;
4105
    }
4053
    mEditor->sync();
4106
    mEditor->sync();
4054
  }
4107
  }
4055
}
4108
}
Lines 4283-4288 Link Here
4283
    if ( oldIdentity.bcc() != ident.bcc() ) {
4336
    if ( oldIdentity.bcc() != ident.bcc() ) {
4284
      mRecipientsEditor->removeRecipient( oldIdentity.bcc(), Recipient::Bcc );
4337
      mRecipientsEditor->removeRecipient( oldIdentity.bcc(), Recipient::Bcc );
4285
      mRecipientsEditor->addRecipient( ident.bcc(), Recipient::Bcc );
4338
      mRecipientsEditor->addRecipient( ident.bcc(), Recipient::Bcc );
4339
      mRecipientsEditor->setFocusBottom();
4286
    }
4340
    }
4287
  }
4341
  }
4288
4342
(-)kmail/kmfoldermbox.h (-3 / +3 lines)
Lines 77-87 Link Here
77
    call close() first.
77
    call close() first.
78
    Returns zero on success and an error code equal to the c-library
78
    Returns zero on success and an error code equal to the c-library
79
    fopen call otherwise (errno). */
79
    fopen call otherwise (errno). */
80
  virtual int open();
80
  virtual int open(const char *owner);
81
81
82
  /** Close folder. If force is TRUE the files are closed even if
82
  /** Close folder. If force is TRUE the files are closed even if
83
    others still use it (e.g. other mail reader windows). */
83
    others still use it (e.g. other mail reader windows). */
84
  virtual void close(bool force=FALSE);
84
  virtual void close(const char *owner, bool force=FALSE);
85
85
86
  virtual int canAccess();
86
  virtual int canAccess();
87
87
Lines 109-115 Link Here
109
109
110
  void setProcmailLockFileName( const QString& );
110
  void setProcmailLockFileName( const QString& );
111
111
112
  static QCString escapeFrom( const QCString & str );
112
  static QByteArray escapeFrom( const DwString & str );
113
113
114
  virtual IndexStatus indexStatus();
114
  virtual IndexStatus indexStatus();
115
115
(-)kmail/kmsender_p.h (-7 / +6 lines)
Lines 6-12 Link Here
6
#define __KMAIL_SENDER_P_H__
6
#define __KMAIL_SENDER_P_H__
7
#include "kmsender.h"
7
#include "kmsender.h"
8
8
9
#include <qcstring.h>
10
#include <qstring.h>
9
#include <qstring.h>
11
#include <qstringlist.h>
10
#include <qstringlist.h>
12
#include <qobject.h>
11
#include <qobject.h>
Lines 33-39 Link Here
33
  void start() { emit started( doStart() ); }
32
  void start() { emit started( doStart() ); }
34
33
35
  /** Send given message. May return before message is sent. */
34
  /** Send given message. May return before message is sent. */
36
  bool send( const QString & sender, const QStringList & to, const QStringList & cc, const QStringList & bcc, const QCString & message ) {
35
  bool send( const QString & sender, const QStringList & to, const QStringList & cc, const QStringList & bcc, const QByteArray & message ) {
37
    reset(); return doSend( sender, to, cc, bcc, message );
36
    reset(); return doSend( sender, to, cc, bcc, message );
38
  }
37
  }
39
38
Lines 72-78 Link Here
72
71
73
private:
72
private:
74
  virtual void doFinish() = 0;
73
  virtual void doFinish() = 0;
75
  virtual bool doSend( const QString & sender, const QStringList & to, const QStringList & cc, const QStringList & bcc, const QCString & message ) = 0;
74
  virtual bool doSend( const QString & sender, const QStringList & to, const QStringList & cc, const QStringList & bcc, const QByteArray & message ) = 0;
76
  virtual bool doStart() = 0;
75
  virtual bool doStart() = 0;
77
76
78
protected:
77
protected:
Lines 102-113 Link Here
102
  /** implemented from KMSendProc */
101
  /** implemented from KMSendProc */
103
  void doFinish();
102
  void doFinish();
104
  /** implemented from KMSendProc */
103
  /** implemented from KMSendProc */
105
  bool doSend( const QString & sender, const QStringList & to, const QStringList & cc, const QStringList & bcc, const QCString & message );
104
  bool doSend( const QString & sender, const QStringList & to, const QStringList & cc, const QStringList & bcc, const QByteArray & message );
106
  /** implemented from KMSendProc */
105
  /** implemented from KMSendProc */
107
  bool doStart();
106
  bool doStart();
108
107
109
private:
108
private:
110
  QCString mMsgStr;
109
  QByteArray mMsgStr;
111
  char* mMsgPos;
110
  char* mMsgPos;
112
  int mMsgRest;
111
  int mMsgRest;
113
  KProcess* mMailerProc;
112
  KProcess* mMailerProc;
Lines 132-145 Link Here
132
  /** implemented from KMSendProc */
131
  /** implemented from KMSendProc */
133
  void doFinish();
132
  void doFinish();
134
  /** implemented from KMSendProc */
133
  /** implemented from KMSendProc */
135
  bool doSend( const QString & sender, const QStringList & to, const QStringList & cc, const QStringList & bcc, const QCString & message );
134
  bool doSend( const QString & sender, const QStringList & to, const QStringList & cc, const QStringList & bcc, const QByteArray & message );
136
  /** implemented from KMSendProc */
135
  /** implemented from KMSendProc */
137
  bool doStart() { return true; }
136
  bool doStart() { return true; }
138
137
139
  void cleanup();
138
  void cleanup();
140
139
141
private:
140
private:
142
  QCString mMessage;
141
  QByteArray mMessage;
143
  uint mMessageLength;
142
  uint mMessageLength;
144
  uint mMessageOffset;
143
  uint mMessageOffset;
145
144
(-)kmail/kmailicalifaceimpl.cpp (-9 / +12 lines)
Lines 70-75 Link Here
70
#include <kurl.h>
70
#include <kurl.h>
71
#include <ktempfile.h>
71
#include <ktempfile.h>
72
72
73
using namespace KMail;
74
73
// Local helper methods
75
// Local helper methods
74
static void vPartMicroParser( const QString& str, QString& s );
76
static void vPartMicroParser( const QString& str, QString& s );
75
static void reloadFolderTree();
77
static void reloadFolderTree();
Lines 480-488 Link Here
480
    return 0;
482
    return 0;
481
  }
483
  }
482
484
483
  f->open();
485
  f->open("kolabcount");
484
  int n = f->count();
486
  int n = f->count();
485
  f->close();
487
  f->close("kolabcount");
486
  kdDebug(5006) << "KMailICalIfaceImpl::incidencesKolabCount( " << mimetype << ", "
488
  kdDebug(5006) << "KMailICalIfaceImpl::incidencesKolabCount( " << mimetype << ", "
487
                << resource << " ) returned " << n << endl;
489
                << resource << " ) returned " << n << endl;
488
  return n;
490
  return n;
Lines 507-513 Link Here
507
    return aMap;
509
    return aMap;
508
  }
510
  }
509
511
510
  f->open();
512
  f->open("incidences");
511
513
512
  int stopIndex = nbMessages == -1 ? f->count() :
514
  int stopIndex = nbMessages == -1 ? f->count() :
513
                  QMIN( f->count(), startIndex + nbMessages );
515
                  QMIN( f->count(), startIndex + nbMessages );
Lines 553-558 Link Here
553
#endif
555
#endif
554
    }
556
    }
555
  }
557
  }
558
  f->close( "incidences" );
556
  return aMap;
559
  return aMap;
557
}
560
}
558
561
Lines 634-640 Link Here
634
  kdDebug(5006) << k_funcinfo << endl;
637
  kdDebug(5006) << k_funcinfo << endl;
635
  QValueList<KMailICalIfaceImpl::SubResource> folderList = subresourcesKolab( contentsType );
638
  QValueList<KMailICalIfaceImpl::SubResource> folderList = subresourcesKolab( contentsType );
636
  for ( QValueList<KMailICalIfaceImpl::SubResource>::const_iterator it( folderList.begin() ),
639
  for ( QValueList<KMailICalIfaceImpl::SubResource>::const_iterator it( folderList.begin() ),
637
                                                                    end( folderList.end() ); 
640
                                                                    end( folderList.end() );
638
        it != end ; ++it ) {
641
        it != end ; ++it ) {
639
    KMFolder * const f = findResourceFolder( (*it).location );
642
    KMFolder * const f = findResourceFolder( (*it).location );
640
    if ( !f ) continue;
643
    if ( !f ) continue;
Lines 723-729 Link Here
723
    return rc;
726
    return rc;
724
  }
727
  }
725
728
726
  f->open();
729
  f->open("ifaceupdate");
727
730
728
  KMMessage* msg = 0;
731
  KMMessage* msg = 0;
729
  if ( sernum != 0 ) {
732
  if ( sernum != 0 ) {
Lines 751-757 Link Here
751
    const KMail::FolderContentsType t = f->storage()->contentsType();
754
    const KMail::FolderContentsType t = f->storage()->contentsType();
752
    const QCString type = msg->typeStr();
755
    const QCString type = msg->typeStr();
753
    const QCString subtype = msg->subtypeStr();
756
    const QCString subtype = msg->subtypeStr();
754
    const bool messageWasIcalVcardFormat = ( type.lower() == "text" && 
757
    const bool messageWasIcalVcardFormat = ( type.lower() == "text" &&
755
        ( subtype.lower() == "calendar" || subtype.lower() == "x-vcard" ) );
758
        ( subtype.lower() == "calendar" || subtype.lower() == "x-vcard" ) );
756
759
757
    if ( storageFormat( f ) == StorageIcalVcard ) {
760
    if ( storageFormat( f ) == StorageIcalVcard ) {
Lines 806-812 Link Here
806
                            attachmentMimetypes );
809
                            attachmentMimetypes );
807
  }
810
  }
808
811
809
  f->close();
812
  f->close("ifaceupdate");
810
  return rc;
813
  return rc;
811
}
814
}
812
815
Lines 1691-1697 Link Here
1691
  folder->storage()->setContentsType( contentsType );
1694
  folder->storage()->setContentsType( contentsType );
1692
  folder->setSystemFolder( true );
1695
  folder->setSystemFolder( true );
1693
  folder->storage()->writeConfig();
1696
  folder->storage()->writeConfig();
1694
  folder->open();
1697
  folder->open("ifacefolder");
1695
  connectFolder( folder );
1698
  connectFolder( folder );
1696
  return folder;
1699
  return folder;
1697
}
1700
}
Lines 1733-1739 Link Here
1733
  if( folder ) {
1736
  if( folder ) {
1734
    folder->setSystemFolder( false );
1737
    folder->setSystemFolder( false );
1735
    folder->disconnect( _this );
1738
    folder->disconnect( _this );
1736
    folder->close();
1739
    folder->close("ifacefolder");
1737
  }
1740
  }
1738
}
1741
}
1739
1742
(-)kmail/actionscheduler.cpp (-15 / +15 lines)
Lines 122-128 Link Here
122
{
122
{
123
  schedulerList->remove( this );
123
  schedulerList->remove( this );
124
  tempCloseFolders();
124
  tempCloseFolders();
125
  mSrcFolder->close();
125
  mSrcFolder->close("actionschedsrc");
126
126
127
  if (mDeleteSrcFolder)
127
  if (mDeleteSrcFolder)
128
    tempFolderMgr->remove(mSrcFolder);
128
    tempFolderMgr->remove(mSrcFolder);
Lines 151-161 Link Here
151
151
152
void ActionScheduler::setSourceFolder( KMFolder *srcFolder )
152
void ActionScheduler::setSourceFolder( KMFolder *srcFolder )
153
{
153
{
154
  srcFolder->open();
154
  srcFolder->open("actionschedsrc");
155
  if (mSrcFolder) {
155
  if (mSrcFolder) {
156
    disconnect( mSrcFolder, SIGNAL(msgAdded(KMFolder*, Q_UINT32)),
156
    disconnect( mSrcFolder, SIGNAL(msgAdded(KMFolder*, Q_UINT32)),
157
		this, SLOT(msgAdded(KMFolder*, Q_UINT32)) );
157
		this, SLOT(msgAdded(KMFolder*, Q_UINT32)) );
158
    mSrcFolder->close();
158
    mSrcFolder->close("actionschedsrc");
159
  }
159
  }
160
  mSrcFolder = srcFolder;
160
  mSrcFolder = srcFolder;
161
  int i = 0;
161
  int i = 0;
Lines 170-176 Link Here
170
{
170
{
171
  mFiltersAreQueued = true;
171
  mFiltersAreQueued = true;
172
  mQueuedFilters.clear();
172
  mQueuedFilters.clear();
173
  
173
174
  QValueList<KMFilter*>::Iterator it = filters.begin();
174
  QValueList<KMFilter*>::Iterator it = filters.begin();
175
  for (; it != filters.end(); ++it)
175
  for (; it != filters.end(); ++it)
176
    mQueuedFilters.append( **it );
176
    mQueuedFilters.append( **it );
Lines 188-194 Link Here
188
  if ( aFolder == mSrcFolder.operator->() )
188
  if ( aFolder == mSrcFolder.operator->() )
189
    return 0;
189
    return 0;
190
190
191
  int rc = aFolder->open();
191
  int rc = aFolder->open("actionsched");
192
  if (rc)
192
  if (rc)
193
    return rc;
193
    return rc;
194
194
Lines 203-209 Link Here
203
  for (it = mOpenFolders.begin(); it != mOpenFolders.end(); ++it) {
203
  for (it = mOpenFolders.begin(); it != mOpenFolders.end(); ++it) {
204
    KMFolder *folder = *it;
204
    KMFolder *folder = *it;
205
    if (folder)
205
    if (folder)
206
      folder->close();
206
      folder->close("actionsched");
207
  }
207
  }
208
  mOpenFolders.clear();
208
  mOpenFolders.clear();
209
}
209
}
Lines 231-237 Link Here
231
void ActionScheduler::execFilters(Q_UINT32 serNum)
231
void ActionScheduler::execFilters(Q_UINT32 serNum)
232
{
232
{
233
  if (mResult != ResultOk) {
233
  if (mResult != ResultOk) {
234
      if ((mResult != ResultCriticalError) && 
234
      if ((mResult != ResultCriticalError) &&
235
	  !mExecuting && !mExecutingLock && !mFetchExecuting) {
235
	  !mExecuting && !mExecutingLock && !mFetchExecuting) {
236
	  mResult = ResultOk; // Recoverable error
236
	  mResult = ResultOk; // Recoverable error
237
	  if (!mFetchSerNums.isEmpty()) {
237
	  if (!mFetchSerNums.isEmpty()) {
Lines 420-429 Link Here
420
      fetchMessageTimer->start( 0, true );
420
      fetchMessageTimer->start( 0, true );
421
      return;
421
      return;
422
  }
422
  }
423
	
423
424
  mFetchSerNums.remove( msg->getMsgSerNum() );
424
  mFetchSerNums.remove( msg->getMsgSerNum() );
425
425
426
  // Note: This may not be necessary. What about when it's time to 
426
  // Note: This may not be necessary. What about when it's time to
427
  //       delete the original message?
427
  //       delete the original message?
428
  //       Is the new serial number being set correctly then?
428
  //       Is the new serial number being set correctly then?
429
  if ((mSet & KMFilterMgr::Explicit) ||
429
  if ((mSet & KMFilterMgr::Explicit) ||
Lines 500-506 Link Here
500
500
501
  //If we got this far then there's a valid message to work with
501
  //If we got this far then there's a valid message to work with
502
  KMMsgBase *msgBase = messageBase( *mMessageIt );
502
  KMMsgBase *msgBase = messageBase( *mMessageIt );
503
  if (mResult != ResultOk) {
503
  if (!msgBase || mResult != ResultOk) {
504
    mExecuting = false;
504
    mExecuting = false;
505
    return;
505
    return;
506
  }
506
  }
Lines 580-586 Link Here
580
    if (mAlwaysMatch ||
580
    if (mAlwaysMatch ||
581
	(*mFilterIt).pattern()->matches( *mMessageIt )) {
581
	(*mFilterIt).pattern()->matches( *mMessageIt )) {
582
      if ( FilterLog::instance()->isLogging() ) {
582
      if ( FilterLog::instance()->isLogging() ) {
583
        FilterLog::instance()->add( i18n( "<b>Filter rules have matched.</b>" ), 
583
        FilterLog::instance()->add( i18n( "<b>Filter rules have matched.</b>" ),
584
                                    FilterLog::patternResult );
584
                                    FilterLog::patternResult );
585
      }
585
      }
586
      mFilterAction = (*mFilterIt).actions()->first();
586
      mFilterAction = (*mFilterIt).actions()->first();
Lines 694-700 Link Here
694
    msg = message( mOriginalSerNum );
694
    msg = message( mOriginalSerNum );
695
    emit filtered( mOriginalSerNum );
695
    emit filtered( mOriginalSerNum );
696
  }
696
  }
697
  
697
698
  mResult = mOldReturnCode; // ignore errors in deleting original message
698
  mResult = mOldReturnCode; // ignore errors in deleting original message
699
  KMCommand *cmd = 0;
699
  KMCommand *cmd = 0;
700
  if (msg && msg->parent()) {
700
  if (msg && msg->parent()) {
Lines 710-716 Link Here
710
    else
710
    else
711
	processMessageTimer->start( 0, true );
711
	processMessageTimer->start( 0, true );
712
  } else {
712
  } else {
713
    // Note: An alternative to consider is just calling 
713
    // Note: An alternative to consider is just calling
714
    //       finishTimer->start and returning
714
    //       finishTimer->start and returning
715
    if (cmd)
715
    if (cmd)
716
	connect( cmd, SIGNAL( completed( KMCommand * ) ),
716
	connect( cmd, SIGNAL( completed( KMCommand * ) ),
Lines 727-733 Link Here
727
{
727
{
728
  if ( command->result() != KMCommand::OK )
728
  if ( command->result() != KMCommand::OK )
729
    actionMessage( KMFilterAction::ErrorButGoOn );
729
    actionMessage( KMFilterAction::ErrorButGoOn );
730
  else 
730
  else
731
    actionMessage();
731
    actionMessage();
732
}
732
}
733
733
Lines 786-792 Link Here
786
	    res.append( QString( "ResultCriticalError.\n" ) );
786
	    res.append( QString( "ResultCriticalError.\n" ) );
787
	else
787
	else
788
	    res.append( QString( "Unknown.\n" ) );
788
	    res.append( QString( "Unknown.\n" ) );
789
	    
789
790
	++i;
790
	++i;
791
    }
791
    }
792
    return res;
792
    return res;
(-)kmail/compactionjob.cpp (-7 / +7 lines)
Lines 65-71 Link Here
65
  Q_ASSERT( mCancellable );
65
  Q_ASSERT( mCancellable );
66
  // We must close the folder if we opened it and got interrupted
66
  // We must close the folder if we opened it and got interrupted
67
  if ( mFolderOpen && mSrcFolder && mSrcFolder->storage() )
67
  if ( mFolderOpen && mSrcFolder && mSrcFolder->storage() )
68
    mSrcFolder->storage()->close();
68
    mSrcFolder->storage()->close("mboxcompactjob");
69
69
70
  if ( mTmpFile )
70
  if ( mTmpFile )
71
    fclose( mTmpFile );
71
    fclose( mTmpFile );
Lines 124-130 Link Here
124
    return errno;
124
    return errno;
125
  }
125
  }
126
  mOpeningFolder = true; // Ignore open-notifications while opening the folder
126
  mOpeningFolder = true; // Ignore open-notifications while opening the folder
127
  storage->open();
127
  storage->open("mboxcompactjob");
128
  mOpeningFolder = false;
128
  mOpeningFolder = false;
129
  mFolderOpen = true;
129
  mFolderOpen = true;
130
  mOffset = 0;
130
  mOffset = 0;
Lines 170-182 Link Here
170
    mbox->writeIndex();
170
    mbox->writeIndex();
171
    mbox->writeConfig();
171
    mbox->writeConfig();
172
    mbox->setAutoCreateIndex( false );
172
    mbox->setAutoCreateIndex( false );
173
    mbox->close(true);
173
    mbox->close("mboxcompact", true);
174
    mbox->setAutoCreateIndex( autoCreate );
174
    mbox->setAutoCreateIndex( autoCreate );
175
    mbox->setNeedsCompacting( false );            // We are clean now
175
    mbox->setNeedsCompacting( false );            // We are clean now
176
    str = i18n( "Folder \"%1\" successfully compacted" ).arg( mSrcFolder->label() );
176
    str = i18n( "Folder \"%1\" successfully compacted" ).arg( mSrcFolder->label() );
177
    kdDebug(5006) << str << endl;
177
    kdDebug(5006) << str << endl;
178
  } else {
178
  } else {
179
    mbox->close();
179
    mbox->close("mboxcompact");
180
    str = i18n( "Error occurred while compacting \"%1\". Compaction aborted." ).arg( mSrcFolder->label() );
180
    str = i18n( "Error occurred while compacting \"%1\". Compaction aborted." ).arg( mSrcFolder->label() );
181
    kdDebug(5006) << "Error occurred while compacting " << mbox->location() << endl;
181
    kdDebug(5006) << "Error occurred while compacting " << mbox->location() << endl;
182
    kdDebug(5006) << "Compaction aborted." << endl;
182
    kdDebug(5006) << "Compaction aborted." << endl;
Lines 208-214 Link Here
208
  Q_ASSERT( mCancellable );
208
  Q_ASSERT( mCancellable );
209
  // We must close the folder if we opened it and got interrupted
209
  // We must close the folder if we opened it and got interrupted
210
  if ( mFolderOpen && mSrcFolder && mSrcFolder->storage() )
210
  if ( mFolderOpen && mSrcFolder && mSrcFolder->storage() )
211
    mSrcFolder->storage()->close();
211
    mSrcFolder->storage()->close("maildircompact");
212
212
213
  FolderJob::kill();
213
  FolderJob::kill();
214
}
214
}
Lines 220-226 Link Here
220
  kdDebug(5006) << "Compacting " << mSrcFolder->idString() << endl;
220
  kdDebug(5006) << "Compacting " << mSrcFolder->idString() << endl;
221
221
222
  mOpeningFolder = true; // Ignore open-notifications while opening the folder
222
  mOpeningFolder = true; // Ignore open-notifications while opening the folder
223
  storage->open();
223
  storage->open("maildircompact");
224
  mOpeningFolder = false;
224
  mOpeningFolder = false;
225
  mFolderOpen = true;
225
  mFolderOpen = true;
226
  QString subdirNew(storage->location() + "/new/");
226
  QString subdirNew(storage->location() + "/new/");
Lines 262-268 Link Here
262
  }
262
  }
263
  mErrorCode = rc;
263
  mErrorCode = rc;
264
  storage->setNeedsCompacting( false );
264
  storage->setNeedsCompacting( false );
265
  storage->close();
265
  storage->close("maildircompact");
266
  if ( storage->isOpened() )
266
  if ( storage->isOpened() )
267
    storage->updateIndex();
267
    storage->updateIndex();
268
  if ( !mSilent )
268
  if ( !mSilent )

Return to bug 171346