Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 115548 Details for
Bug 171346
[PATCH] kde-base/kmail-3.5.6-r1: Fixes for various crash and hang bugs
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
kmail-3.5.6-fixes.diff
kmail-3.5.6-fixes.diff (text/plain), 195.55 KB, created by
Carsten Lohrke (RETIRED)
on 2007-04-06 10:06:36 UTC
(
hide
)
Description:
kmail-3.5.6-fixes.diff
Filename:
MIME Type:
Creator:
Carsten Lohrke (RETIRED)
Created:
2007-04-06 10:06:36 UTC
Size:
195.55 KB
patch
obsolete
>--- kmail/aboutdata.cpp 2005/10/06 19:56:31 467910 >+++ kmail/aboutdata.cpp 2007/01/30 11:50:08 628565 >@@ -212,7 +212,7 @@ > : KAboutData( "kmail", I18N_NOOP("KMail"),KMAIL_VERSION, > I18N_NOOP("KDE Email Client"), License_GPL, > I18N_NOOP("(c) 1997-2005, The KMail developers"), 0, >- "http://kmail.kde.org" ) >+ "http://kontact.kde.org/kmail/" ) > { > using KMail::authors; > using KMail::credits; >--- kmail/accountwizard.cpp 2006/12/16 01:12:17 614027 >+++ kmail/accountwizard.cpp 2007/03/21 13:29:05 644988 >@@ -491,7 +491,10 @@ > void AccountWizard::accountCreated() > { > if ( mAccount ) >+ { > mKernel->acctMgr()->add( mAccount ); >+ mKernel->cleanupImapFolders(); >+ } > > finished(); > } >--- kmail/configuredialog.cpp 2007/02/08 19:54:29 631698 >+++ kmail/configuredialog.cpp 2007/02/09 15:10:36 631934 >@@ -1147,6 +1147,28 @@ > this, SLOT(slotEditNotifications()) ); > } > >+AccountsPageReceivingTab::~AccountsPageReceivingTab() >+{ >+ // When hitting Cancel or closing the dialog with the window-manager-button, >+ // we have a number of things to clean up: >+ >+ // The newly created accounts >+ QValueList< QGuardedPtr<KMAccount> >::Iterator it; >+ for (it = mNewAccounts.begin(); it != mNewAccounts.end(); ++it ) { >+ delete (*it); >+ } >+ mNewAccounts.clear(); >+ >+ // The modified accounts >+ QValueList<ModifiedAccountsType*>::Iterator j; >+ for ( j = mModifiedAccounts.begin() ; j != mModifiedAccounts.end() ; ++j ) { >+ delete (*j)->newAccount; >+ delete (*j); >+ } >+ mModifiedAccounts.clear(); >+ >+ >+} > > void AccountsPage::ReceivingTab::slotAccountSelected() > { >@@ -1398,8 +1420,7 @@ > // Add accounts marked as new > QValueList< QGuardedPtr<KMAccount> >::Iterator it; > for (it = mNewAccounts.begin(); it != mNewAccounts.end(); ++it ) { >- kmkernel->acctMgr()->add( *it ); >- (*it)->installTimer(); >+ kmkernel->acctMgr()->add( *it ); // calls installTimer too > } > > // Update accounts that have been modified >--- kmail/configuredialog_p.h 2007/02/08 19:54:29 631698 >+++ kmail/configuredialog_p.h 2007/02/09 15:10:36 631934 >@@ -349,6 +349,7 @@ > Q_OBJECT > public: > AccountsPageReceivingTab( QWidget * parent=0, const char * name=0 ); >+ ~AccountsPageReceivingTab(); > QString helpAnchor() const; > void save(); > >@@ -384,7 +385,7 @@ > QGuardedPtr< KMAccount > oldAccount; > QGuardedPtr< KMAccount > newAccount; > }; >- // ### make this a qptrlist: >+ // ### make this value-based: > QValueList< ModifiedAccountsType* > mModifiedAccounts; > }; > >--- kmail/customtemplates.cpp 2006/12/16 04:47:10 614050 >+++ kmail/customtemplates.cpp 2007/03/17 02:16:46 643369 >@@ -300,9 +300,10 @@ > if ( mCurrentItem ) { > // mCurrentItem->setText( 0, indexToType( index ) ); > CustomTemplateItem *vitem = mItemList[ mCurrentItem->text( 1 ) ]; >- if ( vitem ) { >- vitem->mType = static_cast<Type>(index); >+ if ( !vitem ) { >+ return; > } >+ vitem->mType = static_cast<Type>(index); > switch ( vitem->mType ) { > case TReply: > mCurrentItem->setPixmap( 0, mReplyPix ); >--- kmail/expirejob.cpp 2006/10/17 13:36:14 596423 >+++ kmail/expirejob.cpp 2007/03/28 14:44:39 647499 >@@ -73,7 +73,7 @@ > Q_ASSERT( mCancellable ); > // We must close the folder if we opened it and got interrupted > if ( mFolderOpen && mSrcFolder && mSrcFolder->storage() ) >- mSrcFolder->storage()->close(); >+ mSrcFolder->storage()->close("expirejob"); > FolderJob::kill(); > } > >@@ -102,7 +102,7 @@ > > FolderStorage* storage = mSrcFolder->storage(); > mOpeningFolder = true; // Ignore open-notifications while opening the folder >- storage->open(); >+ storage->open("expirejob"); > mOpeningFolder = false; > mFolderOpen = true; > mCurrentIndex = storage->count()-1; >@@ -196,7 +196,7 @@ > group.writeEntry( "Current", -1 ); // i.e. make it invalid, the serial number will be used > > if ( !moving ) { >- mSrcFolder->storage()->close(); >+ mSrcFolder->storage()->close("expirejob"); > mFolderOpen = false; > delete this; > } >@@ -204,7 +204,7 @@ > > void ExpireJob::slotMessagesMoved( KMCommand *command ) > { >- mSrcFolder->storage()->close(); >+ mSrcFolder->storage()->close("expirejob"); > mFolderOpen = false; > QString msg; > switch ( command->result() ) { >--- kmail/folderstorage.cpp 2005/10/26 22:58:04 474655 >+++ kmail/folderstorage.cpp 2007/03/28 14:44:39 647499 >@@ -584,14 +584,14 @@ > KMFolder* msgParent = aMsg->parent(); > > if (msgParent) >- msgParent->open(); >+ msgParent->open("moveMsgSrc"); > >- open(); >+ open("moveMsgDest"); > int rc = addMsg(aMsg, aIndex_ret); >- close(); >+ close("moveMsgDest"); > > if (msgParent) >- msgParent->close(); >+ msgParent->close("moveMsgSrc"); > > return rc; > } >@@ -604,18 +604,18 @@ > KMFolder* msgParent = aMsg->parent(); > > if (msgParent) >- msgParent->open(); >+ msgParent->open("foldermovemsg"); > > QValueList<int> index; >- open(); >+ open("moveMsg"); > int rc = addMsg(msglist, index); >- close(); >+ close("moveMsg"); > // FIXME: we want to have a QValueList to pass it back, so change this method > if ( !index.isEmpty() ) > aIndex_ret = &index.first(); > > if (msgParent) >- msgParent->close(); >+ msgParent->close("foldermovemsg"); > > return rc; > } >@@ -638,7 +638,7 @@ > oldIdsLoc = KMMsgDict::instance()->getFolderIdsLocation( *this ); > QString oldConfigString = "Folder-" + folder()->idString(); > >- close(true); >+ close("rename", true); > > oldName = folder()->fileName(); > oldParent = folder()->parent(); >@@ -699,7 +699,7 @@ > > if (openCount > 0) > { >- open(); >+ open("rename"); > mOpenCount = openCount; > } > writeConfig(); >@@ -721,10 +721,12 @@ > assert(!folder()->name().isEmpty()); > > clearIndex( true, mExportsSernums ); // delete and remove from dict if necessary >- close(true); >+ close("remove", true); > >- if ( mExportsSernums ) >+ if ( mExportsSernums ) { > KMMsgDict::mutableInstance()->removeFolderIds( *this ); >+ mExportsSernums = false; // do not writeFolderIds after removal >+ } > unlink(QFile::encodeName(indexLocation()) + ".sorted"); > unlink(QFile::encodeName(indexLocation())); > >@@ -748,7 +750,7 @@ > assert(!folder()->name().isEmpty()); > > clearIndex( true, mExportsSernums ); // delete and remove from dict, if needed >- close( true ); >+ close( "expunge", true ); > > if ( mExportsSernums ) > KMMsgDict::mutableInstance()->removeFolderIds( *this ); >@@ -764,7 +766,7 @@ > > if (openCount > 0) > { >- open(); >+ open("expunge"); > mOpenCount = openCount; > } > >@@ -806,9 +808,9 @@ > if (mUnreadMsgs > -1) > return mUnreadMsgs; > >- open(); // will update unreadMsgs >+ open("countunread"); // will update unreadMsgs > int unread = mUnreadMsgs; >- close(); >+ close("countunread"); > return (unread > 0) ? unread : 0; > } > >@@ -905,8 +907,8 @@ > //----------------------------------------------------------------------------- > void FolderStorage::correctUnreadMsgsCount() > { >- open(); >- close(); >+ open("countunreadmsg"); >+ close("countunreadmsg"); > emit numUnreadMsgsChanged( folder() ); > } > >--- kmail/folderstorage.h 2005/07/26 18:54:59 438982 >+++ kmail/folderstorage.h 2007/03/28 14:44:39 647499 >@@ -251,7 +251,7 @@ > call close() first. > Returns zero on success and an error code equal to the c-library > fopen call otherwise (errno). */ >- virtual int open() = 0; >+ virtual int open(const char *owner) = 0; > > /** Check folder for permissions > Returns zero if readable and writable. */ >@@ -259,7 +259,7 @@ > > /** Close folder. If force is TRUE the files are closed even if > others still use it (e.g. other mail reader windows). */ >- virtual void close(bool force=FALSE) = 0; >+ virtual void close(const char * owner,bool force=FALSE) = 0; > > /** Try releasing @p folder if possible, something is attempting an exclusive access to it. > Currently used for KMFolderSearch and the background tasks like expiry. */ >--- kmail/headerstrategy.cpp 2005/07/26 18:54:59 438982 >+++ kmail/headerstrategy.cpp 2007/03/22 00:31:58 645242 >@@ -60,7 +60,8 @@ > > static const char * richHeaders[] = { > "subject", "date", "from", "cc", "bcc", "to", >- "organization", "organisation", "reply-to" >+ "organization", "organisation", "reply-to", >+ "user-agent", "x-mailer" > }; > static const int numRichHeaders = sizeof richHeaders / sizeof *richHeaders; > >--- kmail/headerstyle.cpp 2006/10/16 22:00:00 596213 >+++ kmail/headerstyle.cpp 2007/03/22 00:31:58 645242 >@@ -541,7 +541,7 @@ > if ( facestring.length() < 993 ) { > QByteArray facearray; > KCodecs::base64Decode(facestring, facearray); >- >+ > QImage faceimage; > if ( faceimage.loadFromData( facearray, "png" ) ) { > // Spec says image must be 48x48 pixels >@@ -659,30 +659,50 @@ > // to line > if ( strategy->showHeader( "to" ) ) > headerStr.append(QString("<tr><th>%1</th>\n" >- "<td>%2</td></tr>\n") >- .arg(i18n("To: ")) >- .arg(KMMessage::emailAddrAsAnchor(message->to(),FALSE))); >+ "<td>%2</td></tr>\n") >+ .arg(i18n("To: ")) >+ .arg(KMMessage::emailAddrAsAnchor(message->to(),FALSE))); > > // cc line, if any > if ( strategy->showHeader( "cc" ) && !message->cc().isEmpty()) > headerStr.append(QString("<tr><th>%1</th>\n" >- "<td>%2</td></tr>\n") >- .arg(i18n("CC: ")) >- .arg(KMMessage::emailAddrAsAnchor(message->cc(),FALSE))); >+ "<td>%2</td></tr>\n") >+ .arg(i18n("CC: ")) >+ .arg(KMMessage::emailAddrAsAnchor(message->cc(),FALSE))); > > // Bcc line, if any > if ( strategy->showHeader( "bcc" ) && !message->bcc().isEmpty()) > headerStr.append(QString("<tr><th>%1</th>\n" >- "<td>%2</td></tr>\n") >- .arg(i18n("BCC: ")) >- .arg(KMMessage::emailAddrAsAnchor(message->bcc(),FALSE))); >+ "<td>%2</td></tr>\n") >+ .arg(i18n("BCC: ")) >+ .arg(KMMessage::emailAddrAsAnchor(message->bcc(),FALSE))); > > if ( strategy->showHeader( "date" ) ) > headerStr.append(QString("<tr><th>%1</th>\n" >- "<td dir=\"%2\">%3</td></tr>\n") >- .arg(i18n("Date: ")) >- .arg( directionOf( message->dateStr() ) ) >- .arg(strToHtml(dateString))); >+ "<td dir=\"%2\">%3</td></tr>\n") >+ .arg(i18n("Date: ")) >+ .arg( directionOf( message->dateStr() ) ) >+ .arg(strToHtml(dateString))); >+ >+ if ( GlobalSettings::self()->showUserAgent() ) { >+ if ( strategy->showHeader( "user-agent" ) ) { >+ if ( !message->headerField("User-Agent").isEmpty() ) { >+ headerStr.append(QString("<tr><th>%1</th>\n" >+ "<td>%2</td></tr>\n") >+ .arg(i18n("User-Agent: ")) >+ .arg( strToHtml( message->headerField("User-Agent") ) ) ); >+ } >+ } >+ >+ if ( strategy->showHeader( "x-mailer" ) ) { >+ if ( !message->headerField("X-Mailer").isEmpty() ) { >+ headerStr.append(QString("<tr><th>%1</th>\n" >+ "<td>%2</td></tr>\n") >+ .arg(i18n("X-Mailer: ")) >+ .arg( strToHtml( message->headerField("X-Mailer") ) ) ); >+ } >+ } >+ } > > // FIXME: Show status in synthetic header style field. Decide whether this or current in brackets style is best and remove one. > /* if( strategy->showHeader( "status" ) ) >--- kmail/imapjob.cpp 2006/05/27 15:57:23 545471 >+++ kmail/imapjob.cpp 2007/03/28 14:44:39 647499 >@@ -84,12 +84,12 @@ > mDestFolder = folder? folder->folder() : 0; > // refcount++ > if (folder) { >- folder->open(); >+ folder->open("imapjobdest"); > } > KMFolder *msg_parent = msg->parent(); > if (msg_parent) { > if (!folder || folder!= msg_parent->storage()) { >- msg_parent->open(); >+ msg_parent->open("imapjobsrc"); > } > } > mSrcFolder = msg_parent; >@@ -241,7 +241,7 @@ > } > account->mJobList.remove( this ); > } >- mDestFolder->close(); >+ mDestFolder->close("imapjobdest"); > } > > if ( mSrcFolder ) { >@@ -266,7 +266,7 @@ > account->mJobList.remove( this ); // remove the folderjob > } > } >- mSrcFolder->close(); >+ mSrcFolder->close("imapjobsrc"); > } > } > >@@ -502,6 +502,12 @@ > void ImapJob::slotPutMessageDataReq( KIO::Job *job, QByteArray &data ) > { > KMAcctImap *account = static_cast<KMFolderImap*>(mDestFolder->storage())->account(); >+ if ( !account ) >+ { >+ emit finished(); >+ deleteLater(); >+ return; >+ } > ImapAccountBase::JobIterator it = account->findJob( job ); > if ( it == account->jobsEnd() ) return; > >@@ -522,6 +528,12 @@ > void ImapJob::slotPutMessageResult( KIO::Job *job ) > { > KMAcctImap *account = static_cast<KMFolderImap*>(mDestFolder->storage())->account(); >+ if ( !account ) >+ { >+ emit finished(); >+ deleteLater(); >+ return; >+ } > ImapAccountBase::JobIterator it = account->findJob( job ); > if ( it == account->jobsEnd() ) return; > bool deleteMe = false; >@@ -562,6 +574,12 @@ > { > KMFolderImap * imapFolder = static_cast<KMFolderImap*>(mDestFolder->storage()); > KMAcctImap *account = imapFolder->account(); >+ if ( !account ) >+ { >+ emit finished(); >+ deleteLater(); >+ return; >+ } > ImapAccountBase::JobIterator it = account->findJob( job ); > if ( it == account->jobsEnd() ) return; > >@@ -595,6 +613,12 @@ > { > KMFolderImap * imapFolder = static_cast<KMFolderImap*>(mDestFolder->storage()); > KMAcctImap *account = imapFolder->account(); >+ if ( !account ) >+ { >+ emit finished(); >+ deleteLater(); >+ return; >+ } > ImapAccountBase::JobIterator it = account->findJob( job ); > if ( it == account->jobsEnd() ) return; > >@@ -613,6 +637,12 @@ > void ImapJob::slotCopyMessageResult( KIO::Job *job ) > { > KMAcctImap *account = static_cast<KMFolderImap*>(mDestFolder->storage())->account(); >+ if ( !account ) >+ { >+ emit finished(); >+ deleteLater(); >+ return; >+ } > ImapAccountBase::JobIterator it = account->findJob( job ); > if ( it == account->jobsEnd() ) return; > >--- kmail/index.cpp 2005/10/15 17:02:32 470926 >+++ kmail/index.cpp 2007/03/29 09:21:13 647728 >@@ -4,12 +4,12 @@ > * KMail is free software; you can redistribute it and/or modify it > * under the terms of the GNU General Public License, version 2, as > * published by the Free Software Foundation. >- * >+ * > * KMail is distributed in the hope that it will be useful, but > * WITHOUT ANY WARRANTY; without even the implied warranty of > * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > * General Public License for more details. >- * >+ * > * You should have received a copy of the GNU General Public License > * along with this program; if not, write to the Free Software > * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA >@@ -58,6 +58,7 @@ > const char* const folderIndexDisabledKey = "fulltextIndexDisabled"; > } > >+#ifdef HAVE_INDEXLIB > static > QValueList<int> vectorToQValueList( const std::vector<Q_UINT32>& input ) { > QValueList<int> res; >@@ -65,7 +66,6 @@ > return res; > } > >- > static > std::vector<Q_UINT32> QValueListToVector( const QValueList<int>& input ) { > std::vector<Q_UINT32> res; >@@ -75,6 +75,7 @@ > } > return res; > } >+#endif > > KMMsgIndex::KMMsgIndex( QObject* parent ): > QObject( parent, "index" ), >@@ -89,11 +90,11 @@ > //mSyncTimer( new QTimer( this ) ), > mSlowDown( false ) { > kdDebug( 5006 ) << "KMMsgIndex::KMMsgIndex()" << endl; >- >- connect( kmkernel->folderMgr(), SIGNAL( msgRemoved( KMFolder*, Q_UINT32 ) ), SLOT( slotRemoveMessage( KMFolder*, Q_UINT32 ) ) ); >- connect( kmkernel->folderMgr(), SIGNAL( msgAdded( KMFolder*, Q_UINT32 ) ), SLOT( slotAddMessage( KMFolder*, Q_UINT32 ) ) ); >- connect( kmkernel->dimapFolderMgr(), SIGNAL( msgRemoved( KMFolder*, Q_UINT32 ) ), SLOT( slotRemoveMessage( KMFolder*, Q_UINT32 ) ) ); >- connect( kmkernel->dimapFolderMgr(), SIGNAL( msgAdded( KMFolder*, Q_UINT32 ) ), SLOT( slotAddMessage( KMFolder*, Q_UINT32 ) ) ); >+ >+ connect( kmkernel->folderMgr(), SIGNAL( msgRemoved( KMFolder*, Q_UINT32 ) ), SLOT( slotRemoveMessage( Q_UINT32 ) ) ); >+ connect( kmkernel->folderMgr(), SIGNAL( msgAdded( KMFolder*, Q_UINT32 ) ), SLOT( slotAddMessage( Q_UINT32 ) ) ); >+ connect( kmkernel->dimapFolderMgr(), SIGNAL( msgRemoved( KMFolder*, Q_UINT32 ) ), SLOT( slotRemoveMessage( Q_UINT32 ) ) ); >+ connect( kmkernel->dimapFolderMgr(), SIGNAL( msgAdded( KMFolder*, Q_UINT32 ) ), SLOT( slotAddMessage( Q_UINT32 ) ) ); > > connect( mTimer, SIGNAL( timeout() ), SLOT( act() ) ); > //connect( mSyncTimer, SIGNAL( timeout() ), SLOT( syncIndex() ) ); >@@ -226,7 +227,7 @@ > //else fall-through > case s_idle: > case s_processing: >- >+ > case s_error: > case s_disabled: > // nothing can be done >@@ -250,7 +251,7 @@ > mExisting.clear(); > mState = s_disabled; > for ( std::set<KMFolder*>::const_iterator first = mOpenedFolders.begin(), past = mOpenedFolders.end(); first != past; ++first ) { >- ( *first )->close(); >+ ( *first )->close("msgindex"); > } > mOpenedFolders.clear(); > for ( std::vector<Search*>::const_iterator first = mSearches.begin(), past = mSearches.end(); first != past; ++first ) { >@@ -284,7 +285,7 @@ > if ( !folder || idx == -1 ) return -1; > if ( !mOpenedFolders.count( folder ) ) { > mOpenedFolders.insert( folder ); >- folder->open(); >+ folder->open("msgindex"); > } > KMMessage* msg = folder->getMsg( idx ); > /* I still don't know whether we should allow decryption or not. >@@ -324,7 +325,7 @@ > mPendingFolders.pop_back(); > if ( !mOpenedFolders.count( f ) ) { > mOpenedFolders.insert( f ); >- f->open(); >+ f->open("msgindex"); > } > const KMMsgDict* dict = KMMsgDict::instance(); > KConfig* config = KMKernel::config(); >@@ -344,7 +345,7 @@ > for ( std::set<KMFolder*>::const_iterator first = mOpenedFolders.begin(), past = mOpenedFolders.end(); > first != past; > ++first ) { >- ( *first )->close(); >+ ( *first )->close("msgindex"); > } > mOpenedFolders.clear(); > mState = s_idle; >@@ -367,7 +368,7 @@ > > void KMMsgIndex::create() { > kdDebug( 5006 ) << "KMMsgIndex::create()" << endl; >- >+ > #ifdef HAVE_INDEXLIB > if ( !QFileInfo( mIndexPath ).exists() ) { > ::mkdir( mIndexPath, S_IRWXU ); >@@ -428,7 +429,7 @@ > //} > // > //void KMMsgIndex::finishSync() { >-// >+// > //} > > void KMMsgIndex::removeSearch( QObject* destroyed ) { >@@ -481,10 +482,10 @@ > return false; > } > >-void KMMsgIndex::slotAddMessage( KMFolder* folder, Q_UINT32 serNum ) { >+void KMMsgIndex::slotAddMessage( Q_UINT32 serNum ) { > kdDebug( 5006 ) << "KMMsgIndex::slotAddMessage( . , " << serNum << " )" << endl; > if ( mState == s_error || mState == s_disabled ) return; >- >+ > if ( mState == s_creating ) mAddedMsgs.push_back( serNum ); > else mPendingMsgs.push_back( serNum ); > >@@ -492,7 +493,7 @@ > scheduleAction(); > } > >-void KMMsgIndex::slotRemoveMessage( KMFolder* folder, Q_UINT32 serNum ) { >+void KMMsgIndex::slotRemoveMessage( Q_UINT32 serNum ) { > kdDebug( 5006 ) << "KMMsgIndex::slotRemoveMessage( . , " << serNum << " )" << endl; > if ( mState == s_error || mState == s_disabled ) return; > >@@ -511,7 +512,7 @@ > void KMMsgIndex::removeMessage( Q_UINT32 serNum ) { > kdDebug( 5006 ) << "KMMsgIndex::removeMessage( " << serNum << " )" << endl; > if ( mState == s_error || mState == s_disabled ) return; >- >+ > #ifdef HAVE_INDEXLIB > mIndex->remove_doc( QString::number( serNum ).latin1() ); > ++mMaintenanceCount; >--- kmail/index.h 2005/08/18 08:19:12 450437 >+++ kmail/index.h 2007/03/09 17:06:16 640993 >@@ -8,16 +8,16 @@ > * KMail is free software; you can redistribute it and/or modify it > * under the terms of the GNU General Public License, version 2, as > * published by the Free Software Foundation. >- * >+ * > * KMail is distributed in the hope that it will be useful, but > * WITHOUT ANY WARRANTY; without even the implied warranty of > * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > * General Public License for more details. >- * >+ * > * You should have received a copy of the GNU General Public License > * along with this program; if not, write to the Free Software > * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA >- * >+ * > * In addition, as a special exception, the copyright holders give > * permission to link the code of this program with any edition of > * the Qt library by Trolltech AS, Norway (or with modified versions >@@ -56,11 +56,11 @@ > ~KMMsgIndex(); > > public: >- >+ > /** > * Starts a query. > * Results will be returned assyncronously by signals. >- * >+ * > * @return false if the query cannot be handled > */ > bool startQuery( KMSearch* ); >@@ -133,8 +133,8 @@ > > void continueCreation(); > >- void slotAddMessage( KMFolder*, Q_UINT32 message ); >- void slotRemoveMessage( KMFolder*, Q_UINT32 message ); >+ void slotAddMessage( Q_UINT32 message ); >+ void slotRemoveMessage( Q_UINT32 message ); > private: > static QString defaultPath(); > >--- kmail/kmaccount.cpp 2006/08/08 22:20:43 571253 >+++ kmail/kmaccount.cpp 2007/02/09 15:10:36 631934 >@@ -151,6 +151,11 @@ > { > setFolder(kmkernel->folderMgr()->findIdString(folderName), true); > } >+ >+ if (mInterval == 0) >+ deinstallTimer(); >+ else >+ installTimer(); > } > > >@@ -278,15 +283,10 @@ > void KMAccount::setCheckInterval(int aInterval) > { > if (aInterval <= 0) >- { > mInterval = 0; >- deinstallTimer(); >- } > else >- { > mInterval = aInterval; >- installTimer(); >- } >+ // Don't call installTimer from here! See #117935. > } > > //---------------------------------------------------------------------------- >--- kmail/kmacctimap.cpp 2006/06/17 22:01:59 552469 >+++ kmail/kmacctimap.cpp 2007/03/28 14:44:39 647499 >@@ -66,13 +66,13 @@ > connect(kmkernel->imapFolderMgr(), SIGNAL(changed()), > this, SLOT(slotUpdateFolderList())); > connect(&mErrorTimer, SIGNAL(timeout()), SLOT(slotResetConnectionError())); >- >- QString serNumUri = locateLocal( "data", "kmail/unfiltered." + >+ >+ QString serNumUri = locateLocal( "data", "kmail/unfiltered." + > QString("%1").arg(KAccount::id()) ); > KConfig config( serNumUri ); > QStringList serNums = config.readListEntry( "unfiltered" ); > mFilterSerNumsToSave.setAutoDelete( false ); >- >+ > for ( QStringList::ConstIterator it = serNums.begin(); > it != serNums.end(); ++it ) { > mFilterSerNums.append( (*it).toUInt() ); >@@ -85,8 +85,8 @@ > KMAcctImap::~KMAcctImap() > { > killAllJobs( true ); >- >- QString serNumUri = locateLocal( "data", "kmail/unfiltered." + >+ >+ QString serNumUri = locateLocal( "data", "kmail/unfiltered." + > QString("%1").arg(KAccount::id()) ); > KConfig config( serNumUri ); > QStringList serNums; >@@ -265,9 +265,10 @@ > if (!mFolder || !mFolder->folder() || !mFolder->folder()->child() || > makeConnection() == ImapAccountBase::Error) > { >+ // checks for mCountRemainChecks >+ checkDone( false, CheckError ); > mCountRemainChecks = 0; > mCheckingSingleFolder = false; >- checkDone( false, CheckError ); > return; > } > // if necessary then initialize the list of folders which should be checked >@@ -330,9 +331,9 @@ > this, SLOT(postProcessNewMail(KMFolderImap*, bool))); > imapFolder->getFolder(); > } else if ( kmkernel->filterMgr()->atLeastOneIncomingFilterAppliesTo( id() ) && >- imapFolder->folder()->isSystemFolder() && >+ imapFolder->folder()->isSystemFolder() && > imapFolder->imapPath() == "/INBOX/" ) { >- imapFolder->open(); // will be closed in the folderSelected slot >+ imapFolder->open("acctimap"); // will be closed in the folderSelected slot > // first get new headers before we select the folder > imapFolder->setSelected( true ); > connect( imapFolder, SIGNAL( folderComplete( KMFolderImap*, bool ) ), >@@ -342,7 +343,7 @@ > else { > connect(imapFolder, SIGNAL(numUnreadMsgsChanged(KMFolder*)), > this, SLOT(postProcessNewMail(KMFolder*))); >- bool ok = imapFolder->processNewMail(interactive); >+ 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 > if (!ok) > { > // there was an error so cancel >@@ -352,6 +353,8 @@ > mMailCheckProgressItem->incCompletedItems(); > mMailCheckProgressItem->updateProgress(); > } >+ // since the list of folders might have been updated at this point, mMailCheckFolders may be invalid, so break >+ break; > } > } > } >@@ -377,7 +380,7 @@ > postProcessNewMail(static_cast<KMFolder*>(folder->folder())); > } > >-void KMAcctImap::postProcessNewMail( KMFolder * folder ) >+void KMAcctImap::postProcessNewMail( KMFolder * folder ) > { > disconnect( folder->storage(), SIGNAL(numUnreadMsgsChanged(KMFolder*)), > this, SLOT(postProcessNewMail(KMFolder*)) ); >@@ -403,7 +406,7 @@ > QValueListIterator<Q_UINT32> filterIt = mFilterSerNums.begin(); > QValueList<Q_UINT32> inTransit; > >- if (ActionScheduler::isEnabled() || >+ if (ActionScheduler::isEnabled() || > kmkernel->filterMgr()->atLeastOneOnlineImapFolderTarget()) { > KMFilterMgr::FilterSet set = KMFilterMgr::Inbound; > QValueList<KMFilter*> filters = kmkernel->filterMgr()->filters(); >@@ -428,7 +431,7 @@ > ++filterIt; > continue; > } >- >+ > KMFolderImap *imapFolder = dynamic_cast<KMFolderImap*>(folder->storage()); > if (!imapFolder || > !imapFolder->folder()->isSystemFolder() || >@@ -447,7 +450,7 @@ > continue; > } > >- if (ActionScheduler::isEnabled() || >+ if (ActionScheduler::isEnabled() || > kmkernel->filterMgr()->atLeastOneOnlineImapFolderTarget()) { > mScheduler->execFilters( msg ); > } else { >@@ -471,7 +474,7 @@ > ++filterIt; > } > mFilterSerNums = inTransit; >- >+ > if (mCountRemainChecks == 0) > { > // all checks are done >@@ -542,7 +545,7 @@ > return mFolder; > } > >-ImapAccountBase::ConnectionState KMAcctImap::makeConnection() >+ImapAccountBase::ConnectionState KMAcctImap::makeConnection() > { > if ( mSlaveConnectionError ) > { >@@ -557,14 +560,14 @@ > mSlaveConnectionError = false; > kdDebug(5006) << k_funcinfo << endl; > } >- >+ > void KMAcctImap::slotFolderSelected( KMFolderImap* folder, bool ) > { > folder->setSelected( false ); > disconnect( folder, SIGNAL( folderComplete( KMFolderImap*, bool ) ), > this, SLOT( slotFolderSelected( KMFolderImap*, bool) ) ); > postProcessNewMail( static_cast<KMFolder*>(folder->folder()) ); >- folder->close(); >+ folder->close( "acctimap" ); > } > > void KMAcctImap::execFilters(Q_UINT32 serNum) >@@ -588,7 +591,7 @@ > if ( serNum ) > mFilterSerNumsToSave.remove( QString( "%1" ).arg( serNum ) ); > >- int filterResult = kmkernel->filterMgr()->process(msg, >+ int filterResult = kmkernel->filterMgr()->process(msg, > KMFilterMgr::Inbound, > true, > id() ); >--- kmail/kmacctlocal.cpp 2006/09/20 21:30:16 586892 >+++ kmail/kmacctlocal.cpp 2007/03/28 14:44:39 647499 >@@ -146,7 +146,7 @@ > return false; > } > >- const int rc = mMailFolder->open(); >+ const int rc = mMailFolder->open("acctlocalMail"); > if ( rc != 0 ) { > QString aStr; > aStr = i18n("Cannot open file:"); >@@ -161,7 +161,7 @@ > > if (!mboxStorage->isLocked()) { > kdDebug(5006) << "mailFolder could not be locked" << endl; >- mMailFolder->close(); >+ mMailFolder->close("acctlocalMail"); > checkDone( mHasNewMail, CheckError ); > QString errMsg = i18n( "Transmission failed: Could not lock %1." ) > .arg( mMailFolder->location() ); >@@ -169,7 +169,7 @@ > return false; > } > >- mFolder->open(); >+ mFolder->open("acctlocalFold"); > > mNumMsgs = mMailFolder->count(); > >@@ -259,10 +259,10 @@ > } > // else warning is written already > >- mMailFolder->close(); >+ mMailFolder->close("acctlocalMail"); > delete mMailFolder; mMailFolder = 0; > >- mFolder->close(); >+ mFolder->close("acctlocalFold"); > > checkDone( mHasNewMail, CheckOK ); > } >--- kmail/kmacctmaildir.cpp 2006/05/21 22:03:38 543389 >+++ kmail/kmacctmaildir.cpp 2007/03/28 14:44:39 647499 >@@ -127,7 +127,7 @@ > return; > } > >- rc = mailFolder.open(); >+ rc = mailFolder.open("acctmaildirMail"); > if (rc) > { > QString aStr = i18n("<qt>Cannot open folder <b>%1</b>.</qt>").arg( mailFolder.location() ); >@@ -138,7 +138,7 @@ > return; > } > >- mFolder->open(); >+ mFolder->open("acctmaildirFold"); > > > num = mailFolder.count(); >@@ -203,8 +203,8 @@ > } > // else warning is written already > >- mailFolder.close(); >- mFolder->close(); >+ mailFolder.close("acctmaildirMail"); >+ mFolder->close("acctmaildirFold"); > > checkDone( hasNewMail, CheckOK ); > >--- kmail/kmail.antispamrc 2006/10/30 19:48:35 600501 >+++ kmail/kmail.antispamrc 2007/02/06 15:18:46 630850 >@@ -216,7 +216,7 @@ > Version=1 > Priority=65 > VisibleName=CRM114 >-Executeable=crm -v | grep "CRM114" >+Executable=crm -v | grep "CRM114" > URL=http://crm114.sourceforge.net > PipeFilterName=CRM114 Check > PipeCmdDetect=crm -u $HOME/.crm114 mailreaver.crm >--- kmail/avscripts/kmail_clamav.sh 2006/04/30 15:24:43 535841 >+++ kmail/avscripts/kmail_clamav.sh 2007/03/08 10:41:44 640538 >@@ -39,7 +39,7 @@ > chmod a+r $TEMPFILE > CLAMCOMANDO="clamdscan --stdout --no-summary " > else >- CLAMCOMANDO="clamscan --stdout --no-summary --mbox" >+ CLAMCOMANDO="clamscan --stdout --no-summary" > fi > > # analyze the message >--- kmail/kmailicalifaceimpl.h 2005/07/29 10:15:34 439934 >+++ kmail/kmailicalifaceimpl.h 2007/03/09 17:06:16 640993 >@@ -51,7 +51,7 @@ > class KMFolderDir; > class KMFolderTreeItem; > >-namespace { >+namespace KMail { > > // Local helper class > class ExtraFolder { >@@ -276,9 +276,9 @@ > > // The extra IMAP resource folders > // Key: folder location. Data: folder. >- QDict<ExtraFolder> mExtraFolders; >+ QDict<KMail::ExtraFolder> mExtraFolders; > // used for collecting incidences during async loading >- QDict<Accumulator> mAccumulators; >+ QDict<KMail::Accumulator> mAccumulators; > // More info for each folder we care about (mContacts etc. as well as the extra folders) > // The reason for storing it here is that it can be shared between > // kmfoldercachedimap and kmfolderimap, and that it's groupware data anyway. >--- kmail/kmail.kcfg 2007/02/08 19:54:29 631698 >+++ kmail/kmail.kcfg 2007/03/22 00:31:58 645242 >@@ -87,6 +87,10 @@ > </group> > > <group name="General"> >+ <entry name="disregardUmask" type="Bool"> >+ <label>Disregard the users umask setting and use "read-write for the user only" instead</label> >+ <default>false</default> >+ </entry> > <entry name="SystemTrayEnabled" type="Bool"> > <label>Enable system tray icon</label> > <default>false</default> >@@ -446,6 +450,12 @@ > <entry name="ChiasmusDecryptionOptions" type="String"> > </entry> > >+ <entry name="ShowUserAgent" type="Bool"> >+ <default>false</default> >+ <label>Show user agent in fancy headers</label> >+ <whatsthis>Enable this option to get the User-Agent and X-Mailer header lines displayed when using fancy headers.</whatsthis> >+ </entry> >+ > </group> > > <group name="TextIndex"> >--- kmail/kmcommands.cpp 2007/01/10 19:21:19 622120 >+++ kmail/kmcommands.cpp 2007/03/28 14:44:39 647499+++ >@@ -182,7 +182,7 @@ > for ( fit = mFolders.begin(); fit != mFolders.end(); ++fit ) { > if (!(*fit)) > continue; >- (*fit)->close(); >+ (*fit)->close("kmcommand"); > } > } > >@@ -440,7 +440,7 @@ > > void KMCommand::keepFolderOpen( KMFolder *folder ) > { >- folder->open(); >+ folder->open("kmcommand"); > mFolders.append( folder ); > } > >@@ -481,6 +481,9 @@ > { > //TODO : consider factoring createReply into this method. > KMMessage *msg = retrievedMessage(); >+ if ( !msg || !msg->codec() ) { >+ return Failed; >+ } > KMMessage *rmsg = msg->createReply( KMail::ReplyNone, mSelection ); > rmsg->setTo( KMMessage::decodeMailtoUrl( mUrl.path() ) ); > >@@ -503,6 +506,9 @@ > { > //TODO : consider factoring createForward into this method. > KMMessage *msg = retrievedMessage(); >+ if ( !msg || !msg->codec() ) { >+ return Failed; >+ } > KMMessage *fmsg = msg->createForward(); > fmsg->setTo( KMMessage::decodeMailtoUrl( mUrl.path() ) ); > >@@ -690,9 +696,8 @@ > return Failed; > > // Take a copy of the original message, which remains unchanged. >- KMMessage *newMsg = new KMMessage; >+ KMMessage *newMsg = new KMMessage( new DwMessage( *msg->asDwMessage() ) ); > newMsg->setComplete( msg->isComplete() ); >- newMsg->fromString( msg->asString() ); > > KMail::Composer *win = KMail::makeComposer(); > newMsg->setTransferInProgress( false ); // From here on on, the composer owns the message. >@@ -713,6 +718,9 @@ > KMCommand::Result KMShowMsgSrcCommand::execute() > { > KMMessage *msg = retrievedMessage(); >+ if ( !msg || !msg->codec() ) { >+ return Failed; >+ } > if ( msg->isComplete() && !mMsgWasComplete ) > msg->notify(); // notify observers as msg was transfered > QString str = msg->codec()->toUnicode( msg->asString() ); >@@ -742,7 +750,7 @@ > static KURL subjectToUrl( const QString & subject ) { > return KFileDialog::getSaveURL( subject.stripWhiteSpace() > .replace( QDir::separator(), '_' ), >- QString::null ); >+ "*.mbox" ); > } > > KMSaveMsgCommand::KMSaveMsgCommand( QWidget *parent, KMMessage * msg ) >@@ -787,7 +795,7 @@ > mMsgList.append( (*it)->getMsgSerNum() ); > mTotalSize += (*it)->msgSize(); > if ((*it)->parent() != 0) >- (*it)->parent()->open(); >+ (*it)->parent()->open("kmcommand"); > ++it; > } > mMsgListIndex = 0; >@@ -876,13 +884,11 @@ > void KMSaveMsgCommand::slotMessageRetrievedForSaving(KMMessage *msg) > { > if ( msg ) { >- QCString str( msg->mboxMessageSeparator() ); >- str += KMFolderMbox::escapeFrom( msg->asString() ); >- str += '\n'; >+ mData = KMFolderMbox::escapeFrom( msg->asDwString() ); >+ KMail::Util::insert( mData, 0, msg->mboxMessageSeparator() ); >+ KMail::Util::append( mData, "\n" ); > msg->setTransferInProgress(false); > >- mData = str; >- mData.resize(mData.size() - 1); > mOffset = 0; > QByteArray data; > int size; >@@ -904,7 +910,7 @@ > KMMsgDict::instance()->getLocation( msg, &p, &idx ); > assert( p == msg->parent() ); assert( idx >= 0 ); > p->unGetMsg( idx ); >- p->close(); >+ p->close("kmcommand"); > } > } > >@@ -958,7 +964,7 @@ > KMCommand::Result KMOpenMsgCommand::execute() > { > if ( mUrl.isEmpty() ) { >- mUrl = KFileDialog::getOpenURL( ":OpenMessage", "message/rfc822", >+ mUrl = KFileDialog::getOpenURL( ":OpenMessage", "message/rfc822 application/mbox", > parentWidget(), i18n("Open Message") ); > } > if ( mUrl.isEmpty() ) { >@@ -1065,6 +1071,9 @@ > { > KCursorSaver busy(KBusyPtr::busy()); > KMMessage *msg = retrievedMessage(); >+ if ( !msg || !msg->codec() ) { >+ return Failed; >+ } > KMMessage *reply = msg->createReply( KMail::ReplySmart, mSelection ); > KMail::Composer * win = KMail::makeComposer( reply ); > win->setCharset( msg->codec()->mimeName(), TRUE ); >@@ -1085,6 +1094,9 @@ > { > KCursorSaver busy(KBusyPtr::busy()); > KMMessage *msg = retrievedMessage(); >+ if ( !msg || !msg->codec() ) { >+ return Failed; >+ } > KMMessage *reply = msg->createReply( KMail::ReplySmart, "", TRUE); > KMail::Composer * win = KMail::makeComposer( reply ); > win->setCharset(msg->codec()->mimeName(), TRUE); >@@ -1105,6 +1117,9 @@ > { > KCursorSaver busy(KBusyPtr::busy()); > KMMessage *msg = retrievedMessage(); >+ if ( !msg || !msg->codec() ) { >+ return Failed; >+ } > KMMessage *reply = msg->createReply( KMail::ReplyList, mSelection); > KMail::Composer * win = KMail::makeComposer( reply ); > win->setCharset(msg->codec()->mimeName(), TRUE); >@@ -1125,6 +1140,9 @@ > { > KCursorSaver busy(KBusyPtr::busy()); > KMMessage *msg = retrievedMessage(); >+ if ( !msg || !msg->codec() ) { >+ return Failed; >+ } > KMMessage *reply = msg->createReply( KMail::ReplyAll, mSelection ); > KMail::Composer * win = KMail::makeComposer( reply ); > win->setCharset( msg->codec()->mimeName(), TRUE ); >@@ -1145,6 +1163,9 @@ > { > KCursorSaver busy(KBusyPtr::busy()); > KMMessage *msg = retrievedMessage(); >+ if ( !msg || !msg->codec() ) { >+ return Failed; >+ } > KMMessage *reply = msg->createReply( KMail::ReplyAuthor, mSelection ); > KMail::Composer * win = KMail::makeComposer( reply ); > win->setCharset( msg->codec()->mimeName(), TRUE ); >@@ -1176,7 +1197,6 @@ > if (msgList.count() >= 2) { // Multiple forward > > uint id = 0; >- // QCString msgText = ""; > QPtrList<KMMessage> linklist; > for ( KMMessage *msg = msgList.first(); msg; msg = msgList.next() ) { > // set the identity >@@ -1197,7 +1217,7 @@ > for ( KMMessage *msg = linklist.first(); msg; msg = linklist.next() ) { > TemplateParser parser( fwdMsg, TemplateParser::Forward, > msg->body(), false, false, false, false); >- parser.process( msg, 0, true ); >+ parser.process( msg, false, true ); > > fwdMsg->link( msg, KMMsgStatusForwarded ); > } >@@ -1280,8 +1300,7 @@ > msgPart->setContentDescription(msg->from()+": "+msg->subject()); > msgPart->setContentDisposition( "inline" ); > // THIS HAS TO BE AFTER setCte()!!!! >- QValueList<int> dummy; >- msgPart->setBodyAndGuessCte(msg->asString(), dummy, true); >+ msgPart->setMessageBody( KMail::Util::ByteArray( msg->asDwString() ) ); > msgPart->setCharset(""); > > fwdMsg->link(msg, KMMsgStatusForwarded); >@@ -1422,6 +1441,9 @@ > { > KCursorSaver busy(KBusyPtr::busy()); > KMMessage *msg = retrievedMessage(); >+ if ( !msg || !msg->codec() ) { >+ return Failed; >+ } > KMMessage *reply = msg->createReply( KMail::ReplySmart, mSelection, > false, true, false, mTemplate ); > KMail::Composer * win = KMail::makeComposer( reply ); >@@ -1444,6 +1466,9 @@ > { > KCursorSaver busy(KBusyPtr::busy()); > KMMessage *msg = retrievedMessage(); >+ if ( !msg || !msg->codec() ) { >+ return Failed; >+ } > KMMessage *reply = msg->createReply( KMail::ReplyAll, mSelection, > false, true, false, mTemplate ); > KMail::Composer * win = KMail::makeComposer( reply ); >@@ -1476,7 +1501,6 @@ > if (msgList.count() >= 2) { // Multiple forward > > uint id = 0; >- // QCString msgText = ""; > QPtrList<KMMessage> linklist; > for ( KMMessage *msg = msgList.first(); msg; msg = msgList.next() ) { > // set the identity >@@ -1497,7 +1521,7 @@ > for ( KMMessage *msg = linklist.first(); msg; msg = linklist.next() ) { > TemplateParser parser( fwdMsg, TemplateParser::Forward, > msg->body(), false, false, false, false); >- parser.process( msg, 0, true ); >+ parser.process( msg, false, true ); > > fwdMsg->link( msg, KMMsgStatusForwarded ); > } >@@ -1888,7 +1912,7 @@ > QPtrList<KMMessage> list; > QPtrList<KMMessage> localList; > >- if (mDestFolder && mDestFolder->open() != 0) >+ if (mDestFolder && mDestFolder->open("kmcommand") != 0) > { > deleteLater(); > return Failed; >@@ -1918,12 +1942,11 @@ > // imap => imap with same account > list.append(msg); > } else { >- newMsg = new KMMessage; >+ newMsg = new KMMessage( new DwMessage( *msg->asDwMessage() ) ); > newMsg->setComplete(msg->isComplete()); > // make sure the attachment state is only calculated when it's complete > if (!newMsg->isComplete()) > newMsg->setReadyToShow(false); >- newMsg->fromString(msg->asString()); > newMsg->setStatus(msg->status()); > > if (srcFolder && !newMsg->isComplete()) >@@ -1990,7 +2013,7 @@ > // otherwise this is done in slotMsgAdded or slotFolderComplete > if ( deleteNow ) > { >- mDestFolder->close(); >+ mDestFolder->close("kmcommand"); > deleteLater(); > } > >@@ -2002,14 +2025,14 @@ > mWaitingForMsgs.remove( serNum ); > if ( mWaitingForMsgs.isEmpty() ) > { >- mDestFolder->close(); >+ mDestFolder->close("kmcommand"); > deleteLater(); > } > } > > void KMCopyCommand::slotFolderComplete() > { >- mDestFolder->close(); >+ mDestFolder->close("kmcommand"); > deleteLater(); > } > >@@ -2046,7 +2069,7 @@ > typedef QMap< KMFolder*, QPtrList<KMMessage>* > FolderToMessageListMap; > FolderToMessageListMap folderDeleteList; > >- if (mDestFolder && mDestFolder->open() != 0) { >+ if (mDestFolder && mDestFolder->open("kmcommand") != 0) { > completeMove( Failed ); > return Failed; > } >@@ -2216,11 +2239,11 @@ > void KMMoveCommand::completeMove( Result result ) > { > if ( mDestFolder ) >- mDestFolder->close(); >+ mDestFolder->close("kmcommand"); > while ( !mOpenedFolders.empty() ) { > KMFolder *folder = mOpenedFolders.back(); > mOpenedFolders.pop_back(); >- folder->close(); >+ folder->close("kmcommand"); > } > if ( mProgressItem ) { > mProgressItem->setComplete(); >@@ -2241,14 +2264,14 @@ > const QPtrList<KMMsgBase> &msgList ) > :KMMoveCommand( findTrashFolder( srcFolder ), msgList) > { >- srcFolder->open(); >+ srcFolder->open("kmcommand"); > mOpenedFolders.push_back( srcFolder ); > } > > KMDeleteMsgCommand::KMDeleteMsgCommand( KMFolder* srcFolder, KMMessage * msg ) > :KMMoveCommand( findTrashFolder( srcFolder ), msg) > { >- srcFolder->open(); >+ srcFolder->open("kmcommand"); > mOpenedFolders.push_back( srcFolder ); > } > >@@ -2260,7 +2283,7 @@ > KMMsgDict::instance()->getLocation( sernum, &srcFolder, &idx ); > if ( srcFolder ) { > KMMsgBase *msg = srcFolder->getMsgBase( idx ); >- srcFolder->open(); >+ srcFolder->open("kmcommand"); > mOpenedFolders.push_back( srcFolder ); > addMsg( msg ); > } >@@ -2563,9 +2586,7 @@ > { > // This does not decode the Message Content-Transfer-Encoding > // but saves the _original_ content of the message part >- QCString cstr( node->msgPart().body() ); >- data = cstr; >- data.resize(data.size() - 1); >+ data = KMail::Util::ByteArray( node->msgPart().dwBody() ); > } > else > { >@@ -2635,7 +2656,11 @@ > i18n( "KMail Error" ) ); > return Failed; > } >- fchmod( file.handle(), S_IRUSR | S_IWUSR ); >+ >+ // #79685 by default use the umask the user defined, but let it be configurable >+ if ( GlobalSettings::self()->disregardUmask() ) >+ fchmod( file.handle(), S_IRUSR | S_IWUSR ); >+ > ds.setDevice( &file ); > } else > { >@@ -2743,7 +2768,9 @@ > KMCommand::Result KMResendMessageCommand::execute() > { > KMMessage *msg = retrievedMessage(); >- >+ if ( !msg || !msg->codec() ) { >+ return Failed; >+ } > KMMessage *newMsg = new KMMessage(*msg); > newMsg->setCharset(msg->codec()->mimeName()); > // the message needs a new Message-Id >--- kmail/kmcomposewin.h 2006/12/16 03:44:17 614049 >+++ kmail/kmcomposewin.h 2007/03/05 22:25:33 639750 >@@ -838,6 +838,15 @@ > > QPopupMenu *mActNowMenu; > QPopupMenu *mActLaterMenu; >+ >+ /** If the message in this composer has a cursor position set (for >+ * instance because it comes from a template containing %CURSOR) >+ * then we need to preserve that cursor position even when auto- >+ * appending (or prepending) the signature during composer setup. >+ * Set to true *once* (and only in setMsg() at that) to avoid >+ * accidentally moving the cursor. >+ */ >+ bool mPreserveUserCursorPosition; > }; > > #endif >--- kmail/kmfiltermgr.cpp 2006/11/28 20:44:21 608897 >+++ kmail/kmfiltermgr.cpp 2007/03/28 14:44:39 647499 >@@ -239,7 +239,7 @@ > } > bool opened = folder->isOpened(); > if ( !opened ) >- folder->open(); >+ folder->open("filtermgr"); > KMMsgBase *msgBase = folder->getMsgBase( idx ); > bool unGet = !msgBase->isMessage(); > KMMessage *msg = folder->getMsg( idx ); >@@ -248,14 +248,14 @@ > if ( unGet ) > folder->unGetMsg( idx ); > if ( !opened ) >- folder->close(); >+ folder->close("filtermgr"); > return 1; > } > if ( filter->execActions( msg, stopIt ) == KMFilter::CriticalError ) { > if ( unGet ) > folder->unGetMsg( idx ); > if ( !opened ) >- folder->close(); >+ folder->close("filtermgr"); > return 2; > } > >@@ -271,7 +271,7 @@ > if ( unGet ) > folder->unGetMsg( idx ); > if ( !opened ) >- folder->close(); >+ folder->close("filtermgr"); > } else { > result = 1; > } >@@ -423,7 +423,7 @@ > return; > QValueVector< KMFolder *>::const_iterator it; > for ( it = mOpenFolders.constBegin(); it != mOpenFolders.constEnd(); ++it ) >- (*it)->close(); >+ (*it)->close("filtermgr"); > mOpenFolders.clear(); > } > >@@ -433,7 +433,7 @@ > { > assert( aFolder ); > >- int rc = aFolder->open(); >+ int rc = aFolder->open("filermgr"); > if (rc) return rc; > > mOpenFolders.append( aFolder ); >--- kmail/kmfolder.h 2006/12/16 03:44:17 614049 >+++ kmail/kmfolder.h 2007/03/28 14:44:39 647499 >@@ -286,7 +286,7 @@ > call close() first. > Returns zero on success and an error code equal to the c-library > fopen call otherwise (errno). */ >- int open(); >+ int open(const char *owner); > > /** Check folder for permissions > Returns zero if readable and writable. */ >@@ -294,7 +294,7 @@ > > /** Close folder. If force is true the files are closed even if > others still use it (e.g. other mail reader windows). */ >- void close(bool force=false); >+ void close(const char *owner, bool force=false); > > /** fsync buffers to disk */ > void sync(); >@@ -647,10 +647,11 @@ > */ > class KMFolderCloser { > KMFolder * f; >+ QString mOwner; > public: >- KMFolderCloser( KMFolder * folder ) : f( folder ) {} >+ KMFolderCloser( const char *owner, KMFolder * folder ) : f( folder ), mOwner( owner ) {} > ~KMFolderCloser() { >- if ( f ) f->close(); >+ if ( f ) f->close(mOwner.latin1()); > } > KMFolder * folder() const { return f; } > }; >--- kmail/kmfoldercachedimap.cpp 2007/02/08 19:54:29 631698 >+++ kmail/kmfoldercachedimap.cpp 2007/03/28 14:44:39 647499 >@@ -150,8 +150,9 @@ > uidWriteTimer( -1 ), mLastUid( 0 ), mTentativeHighestUid( 0 ), > mFoundAnIMAPDigest( false ), > mUserRights( 0 ), mSilentUpload( false ), >+ /*mHoldSyncs( false ),*/ > mFolderRemoved( false ), >- /*mHoldSyncs( false ),*/ mRecurse( true ), >+ mRecurse( true ), > mStatusChangedLocally( false ), mAnnotationFolderTypeChanged( false ), > mIncidencesForChanged( false ), mPersonalNamespacesCheckDone( true ), > mQuotaInfo() >@@ -380,7 +381,7 @@ > { > //kdDebug(5006) << "Reloading Uid Map " << endl; > uidMap.clear(); >- open(); >+ open("reloadUdi"); > for( int i = 0; i < count(); ++i ) { > KMMsgBase *msg = getMsgBase( i ); > if( !msg ) continue; >@@ -388,7 +389,7 @@ > //kdDebug(5006) << "Inserting: " << i << " with uid: " << uid << endl; > uidMap.insert( uid, i ); > } >- close(); >+ close("reloadUdi"); > uidMapDirty = false; > } > >@@ -709,7 +710,7 @@ > foldersForDeletionOnServer.clear(); > newState( mProgress, i18n("Synchronizing")); > >- open(); >+ open("cachedimap"); > if ( !noContent() ) > mAccount->addLastUnreadMsgCount( this, countUnread() ); > >@@ -720,7 +721,7 @@ > // kdDebug(5006) << "makeConnection said Error, aborting." << endl; > // We stop here. We're already in SYNC_STATE_INITIAL for the next time. > newState( mProgress, i18n( "Error connecting to server %1" ).arg( mAccount->host() ) ); >- close(); >+ close("cachedimap"); > emit folderComplete(this, false); > break; > } else if ( cs == ImapAccountBase::Connecting ) { >@@ -1135,7 +1136,7 @@ > if( mSubfoldersForSync.isEmpty() ) { > mSyncState = SYNC_STATE_INITIAL; > mAccount->addUnreadMsgCount( this, countUnread() ); // before closing >- close(); >+ close("cachedimap"); > emit folderComplete( this, true ); > } else { > mCurrentSubfolder = mSubfoldersForSync.front(); >@@ -1735,7 +1736,7 @@ > f->setImapPath( mAccount->addPathToNamespace( name ) ); > f->setNoContent( true ); > f->setAccount( mAccount ); >- f->close(); >+ f->close("cachedimap"); > kmkernel->dimapFolderMgr()->contentsChanged(); > } > } >@@ -1869,7 +1870,7 @@ > } > if (!node) { > if ( f ) >- f->close(); >+ f->close("cachedimap"); > kmkernel->dimapFolderMgr()->contentsChanged(); > } > // so we have an INBOX >@@ -1920,7 +1921,7 @@ > f = static_cast<KMFolderCachedImap*>(newFolder->storage()); > } > if (f) { >- f->close(); >+ f->close("cachedimap"); > f->setAccount(mAccount); > kmkernel->dimapFolderMgr()->contentsChanged(); > f->mAnnotationFolderType = "FROMSERVER"; >@@ -2001,7 +2002,7 @@ > > mSubfoldersForSync.clear(); > mSyncState = SYNC_STATE_INITIAL; >- close(); >+ close("cachedimap"); > emit folderComplete( this, false ); > } > } >@@ -2134,7 +2135,7 @@ > if ( mSyncState == SYNC_STATE_INITIAL ) return; > mSubfoldersForSync.clear(); > mSyncState = SYNC_STATE_INITIAL; >- close(); >+ close("cachedimap"); > // Don't use newState here, it would revert to mProgress (which is < current value when listing messages) > KPIM::ProgressItem *progressItem = mAccount->mailCheckProgressItem(); > QString str = i18n("Aborted"); >--- kmail/kmfolder.cpp 2006/10/28 17:04:18 599816 >+++ kmail/kmfolder.cpp 2007/03/28 14:44:39 647499 >@@ -426,12 +426,12 @@ > > int KMFolder::find( const KMMsgBase* msg ) const > { >- return mStorage->find( msg ); >+ return mStorage ? mStorage->find( msg ) : 0; > } > > int KMFolder::find( const KMMessage* msg ) const > { >- return mStorage->find( msg ); >+ return mStorage ? mStorage->find( msg ) : 0; > } > > int KMFolder::count( bool cache ) const >@@ -468,9 +468,9 @@ > mStorage->msgStatusChanged( oldStatus, newStatus, idx ); > } > >-int KMFolder::open() >+int KMFolder::open(const char *owner) > { >- return mStorage->open(); >+ return mStorage->open(owner); > } > > int KMFolder::canAccess() >@@ -478,9 +478,9 @@ > return mStorage->canAccess(); > } > >-void KMFolder::close( bool force ) >+void KMFolder::close( const char *owner, bool force ) > { >- mStorage->close( force ); >+ mStorage->close( owner, force ); > } > > void KMFolder::sync() >@@ -631,11 +631,13 @@ > mWhoField = "From"; > if ( this == kmkernel->outboxFolder() || > this == kmkernel->sentFolder() || >- this == kmkernel->draftsFolder() ) >+ this == kmkernel->draftsFolder() || >+ this == kmkernel->templatesFolder() ) > mWhoField = "To"; >- } else if ( identity.drafts() == idString() >- || identity.fcc() == idString() ) >- // drafts or sent of the identity >+ } else if ( identity.drafts() == idString() || >+ identity.templates() == idString() || >+ identity.fcc() == idString() ) >+ // drafts, templates or sent of the identity > mWhoField = "To"; > else > mWhoField = "From"; >--- kmail/kmfolderdia.h 2006/12/16 01:03:56 614026 >+++ kmail/kmfolderdia.h 2007/03/09 17:06:16 640993 >@@ -55,7 +55,7 @@ > class KPushButton; > > namespace KMail { >- class FolderRequester; >+ class FolderRequester; > /** > * This is the base class for tabs in the folder dialog. > * It uses the API from ConfigModuleTab (basically: it's a widget that can load and save) >@@ -161,16 +161,14 @@ > Q_OBJECT > > public: >- FolderDiaTemplatesTab( KMFolderDialog* dlg, >- const QString& aName, >- QWidget* parent, const char* name = 0 ); >+ FolderDiaTemplatesTab( KMFolderDialog *dlg, QWidget *parent ); > > virtual void load(); > virtual bool save(); > > public slots: > void slotEmitChanged(); // do nothing for now >- >+ > void slotCopyGlobal(); > > private: >--- kmail/kmfolderdia.cpp 2007/02/08 19:54:29 631698 >+++ kmail/kmfolderdia.cpp 2007/03/09 17:06:16 640993 >@@ -122,7 +122,7 @@ > tab = new FolderDiaGeneralTab( this, aName, box ); > addTab( tab ); > box = addVBoxPage( i18n("Templates") ); >- tab = new FolderDiaTemplatesTab( this, aName, box ); >+ tab = new FolderDiaTemplatesTab( this, box ); > addTab( tab ); > > KMFolder* refFolder = mFolder ? mFolder : mParentFolder; >@@ -666,9 +666,8 @@ > > //---------------------------------------------------------------------------- > KMail::FolderDiaTemplatesTab::FolderDiaTemplatesTab( KMFolderDialog* dlg, >- const QString& aName, >- QWidget* parent, const char* name ) >- : FolderDiaTab( parent, name ), mDlg( dlg ) >+ QWidget* parent ) >+ : FolderDiaTab( parent, 0 ), mDlg( dlg ) > { > > mIsLocalSystemFolder = mDlg->folder()->isSystemFolder() && >@@ -676,24 +675,24 @@ > mDlg->folder()->folderType() != KMFolderTypeCachedImap; > > QVBoxLayout *topLayout = new QVBoxLayout( this, 0, KDialog::spacingHint() ); >- >+ > mCustom = new QCheckBox( i18n("&Use custom message templates"), this ); > topLayout->addWidget( mCustom ); >- >+ > mWidget = new TemplatesConfiguration( this , "folder-templates" ); > mWidget->setEnabled( false ); > topLayout->addWidget( mWidget ); >- >+ > QHBoxLayout *btns = new QHBoxLayout( topLayout, KDialog::spacingHint() ); > mCopyGlobal = new KPushButton( i18n("&Copy global templates"), this ); > mCopyGlobal->setEnabled( false ); > btns->addWidget( mCopyGlobal ); >- >+ > connect( mCustom, SIGNAL(toggled(bool)), > mWidget, SLOT(setEnabled(bool)) ); > connect( mCustom, SIGNAL(toggled(bool)), > mCopyGlobal, SLOT(setEnabled(bool)) ); >- >+ > connect( mCopyGlobal, SIGNAL(clicked()), > this, SLOT(slotCopyGlobal()) ); > >@@ -705,23 +704,23 @@ > > void FolderDiaTemplatesTab::load() > { >- >+ > } > > void FolderDiaTemplatesTab::initializeWithValuesFromFolder( KMFolder* folder ) { > if ( !folder ) > return; >- >+ > mFolder = folder; > > QString fid = folder->idString(); >- >+ > Templates t( fid ); > > mCustom->setChecked(t.useCustomTemplates()); >- >+ > mIdentity = folder->identity(); >- >+ > mWidget->loadFromFolder( fid, mIdentity ); > } > >@@ -729,16 +728,16 @@ > bool FolderDiaTemplatesTab::save() > { > KMFolder* folder = mDlg->folder(); >- >+ > QString fid = folder->idString(); > Templates t(fid); >- >+ > kdDebug() << "use custom templates for folder " << fid << ": " << mCustom->isChecked() << endl; > t.setUseCustomTemplates(mCustom->isChecked()); > t.writeConfig(); >- >+ > mWidget->saveToFolder(fid); >- >+ > return true; > } > >--- kmail/kmfolderimap.h 2005/10/03 13:23:54 466810 >+++ kmail/kmfolderimap.h 2007/03/28 14:44:39 647499 >@@ -131,6 +131,11 @@ > /** Remove the IMAP folder on the server and if successful also locally */ > virtual void remove(); > >+ /** Close folder. If force is TRUE the files are closed even if >+ others still use it (e.g. other mail reader windows). This also >+ cancels all pending jobs. */ >+ virtual void close(const char *owner, bool force=FALSE); >+ > /** Automatically expunge deleted messages when leaving the folder */ > bool autoExpunge(); > >@@ -277,11 +282,6 @@ > /** imap folders cannot expire */ > virtual bool isAutoExpire() const { return false; } > >- /** Close folder. If force is TRUE the files are closed even if >- others still use it (e.g. other mail reader windows). This also >- cancels all pending jobs. */ >- virtual void close(bool force=FALSE); >- > void setCheckingValidity( bool val ) { mCheckingValidity = val; } > > /** Return the trash folder. */ >@@ -423,7 +423,7 @@ > /** See if all folders are still present on server, otherwise delete them */ > void checkFolders( const QStringList& folderNames, const QString& ns ); > >- void finishMailCheck( imapState state ); >+ void finishMailCheck( const char *func, imapState state ); > > protected slots: > >--- kmail/kmfolderimap.cpp 2006/08/08 15:14:51 571100 >+++ kmail/kmfolderimap.cpp 2007/03/28 15:07:15 647509++649334 >@@ -106,16 +106,22 @@ > > > //----------------------------------------------------------------------------- >-void KMFolderImap::close(bool aForced) >+void KMFolderImap::close(const char *owner, bool aForced) > { >- if (mOpenCount <= 0 ) return; > if (mOpenCount > 0) mOpenCount--; >- if (mOpenCount > 0 && !aForced) return; >- if (isSelected() && !aForced) { >+ if (mOpenCount == 0 && isSelected() && !aForced) { > kdWarning(5006) << "Trying to close the selected folder " << label() << >- " - ignoring!" << endl; >+ " - ignoring! " << kdBacktrace() << endl; >+ mOpenCount++; > return; > } >+ if (mOpenCount > 0 && !aForced) { >+ // The inherited close will decrement again, so we have to adjust. >+ mOpenCount++; >+ KMFolderMbox::close(owner, aForced); >+ return; >+ } >+ > // FIXME is this still needed? > if (mAccount) > mAccount->ignoreJobsForFolder( folder() ); >@@ -127,9 +133,12 @@ > msg->setTransferInProgress( false ); > } > } >+ >+ mCheckingValidity = false; >+ > // The inherited close will decrement again, so we have to adjust. > mOpenCount++; >- KMFolderMbox::close(aForced); >+ KMFolderMbox::close(owner, aForced); > } > > KMFolder* KMFolderImap::trashFolder() const >@@ -694,7 +700,6 @@ > KMFolderImap* f = static_cast<KMFolderImap*> ( fld->storage() ); > f->initializeFrom( this, mAccount->addPathToNamespace( name ), > "inode/directory" ); >- f->close(); > if ( !mAccount->listOnlyOpenFolders() ) > { > f->slotListResult( subfolderNames, subfolderPaths, >@@ -810,7 +815,6 @@ > KMFolder *fld = folder()->child()->createFolder(subfolderNames[i]); > if ( fld ) { > f = static_cast<KMFolderImap*> ( fld->storage() ); >- f->close(); > settingsChanged = true; > } else { > kdWarning(5006) << "can't create folder " << subfolderNames[i] << endl; >@@ -875,7 +879,6 @@ > if ( f ) > { > f->folder()->setLabel( i18n("inbox") ); >- f->close(); > } > kmkernel->imapFolderMgr()->contentsChanged(); > } >@@ -919,6 +922,9 @@ > const QString& myNamespace ) > { > QPtrList<KMFolder> toRemove; >+ if (!folder()->child()) >+ return; >+ > KMFolderNode *node = folder()->child()->first(); > while ( node ) > { >@@ -995,7 +1001,6 @@ > { > if (!mAccount) { > emit folderComplete(this, false); >- close(); > return; > } > KURL url = mAccount->getUrl(); >@@ -1011,7 +1016,6 @@ > kdDebug(5006) << "KMFolderImap::checkValidity - got no connection" << endl; > emit folderComplete(this, FALSE); > mContentState = imapNoInformation; >- close(); > return; > } else if ( connectionState == ImapAccountBase::Connecting ) { > // We'll wait for the connectionResult signal from the account. If it >@@ -1024,7 +1028,6 @@ > // Only check once at a time. > if (mCheckingValidity) { > kdDebug(5006) << "KMFolderImap::checkValidity - already checking" << endl; >- close(); > return; > } > // otherwise we already are inside a mailcheck >@@ -1044,6 +1047,7 @@ > if ( account()->mailCheckProgressItem() ) { > account()->mailCheckProgressItem()->setStatus( folder()->prettyURL() ); > } >+ open( "checkvalidity" ); > ImapAccountBase::jobData jd( url.url() ); > KIO::SimpleJob *job = KIO::get(url, FALSE, FALSE); > KIO::Scheduler::assignJobToSlave(mAccount->slave(), job); >@@ -1062,13 +1066,13 @@ > { > if ( mLastUid > 0 ) > return mLastUid; >- open(); >+ open("lastuid"); > if (count() > 0) > { > KMMsgBase * base = getMsgBase(count()-1); > mLastUid = base->UID(); > } >- close(); >+ close("lastuid"); > return mLastUid; > } > >@@ -1076,12 +1080,20 @@ > //----------------------------------------------------------------------------- > void KMFolderImap::slotCheckValidityResult(KIO::Job * job) > { >+ // if we closed the folder in between, we don't want this results >+ if (!mCheckingValidity) >+ return; >+ > kdDebug(5006) << "KMFolderImap::slotCheckValidityResult of: " << fileName() << endl; > mCheckingValidity = false; > ImapAccountBase::JobIterator it = mAccount->findJob(job); >- if ( it == mAccount->jobsEnd() ) return; >- if (job->error()) { >- if ( job->error() != KIO::ERR_ACCESS_DENIED ) { >+ if ( it == mAccount->jobsEnd() ) >+ { >+ // the job has been killed internally, so we're not interested in its results >+ job = 0; >+ } >+ if (!job || job->error()) { >+ if ( job && job->error() != KIO::ERR_ACCESS_DENIED ) { > // we suppress access denied messages because they are normally a result of > // explicitely set ACLs. Do not save this information (e.g. setNoContent) so that > // we notice when this changes >@@ -1089,7 +1097,7 @@ > } > mContentState = imapNoInformation; > emit folderComplete(this, FALSE); >- close(); >+ close("checkvalidity"); > } else { > QCString cstr((*it).data.data(), (*it).data.size() + 1); > int a = cstr.find("X-uidValidity: "); >@@ -1143,6 +1151,7 @@ > mMailCheckProgressItem->setCompletedItems( 0 ); > } > reallyGetFolder(startUid); >+ close("checkvalidity"); > } > } > >@@ -1170,13 +1179,14 @@ > emit folderComplete(this, true); > return; > } >- open(); >+ open("getfolder"); > mContentState = imapListingInProgress; > if (force) { > // force an update > mCheckFlags = TRUE; > } > checkValidity(); >+ close( "getfolder" ); > } > > >@@ -1188,7 +1198,6 @@ > { > mContentState = imapNoInformation; > emit folderComplete(this, FALSE); >- close(); > return; > } > quiet(true); >@@ -1198,6 +1207,7 @@ > mMailCheckProgressItem->setStatus( i18n("Retrieving message status") ); > url.setPath(imapPath() + ";SECTION=UID FLAGS"); > KIO::SimpleJob *job = KIO::listDir(url, FALSE); >+ open( "listfolder" ); > KIO::Scheduler::assignJobToSlave(mAccount->slave(), job); > ImapAccountBase::jobData jd( url.url(), folder() ); > jd.cancellable = true; >@@ -1217,6 +1227,7 @@ > KIO::Scheduler::assignJobToSlave(mAccount->slave(), newJob); > ImapAccountBase::jobData jd( url.url(), folder() ); > jd.cancellable = true; >+ open( "getMessage" ); > mAccount->insertJob(newJob, jd); > connect(newJob, SIGNAL(result(KIO::Job *)), > this, SLOT(slotGetLastMessagesResult(KIO::Job *))); >@@ -1237,7 +1248,7 @@ > mAccount->handleJobError( job, > i18n("Error while listing the contents of the folder %1.").arg( label() ) ); > mAccount->removeJob(it); >- finishMailCheck( imapNoInformation ); >+ finishMailCheck( "listfolder", imapNoInformation ); > return; > } > mCheckFlags = FALSE; >@@ -1290,7 +1301,7 @@ > jd.total = (*it).items.count(); > if (jd.total == 0) > { >- finishMailCheck( imapFinished ); >+ finishMailCheck( "listfolder", imapFinished ); > mAccount->removeJob(it); > return; > } >@@ -1309,6 +1320,11 @@ > else sets = makeSets( (*it).items ); > mAccount->removeJob(it); // don't use *it below > >+ if ( !sets.isEmpty() ) >+ open( "getMessage" ); >+ >+ close( "listfolder" ); >+ > // Now kick off the getting of envelopes for the new mails in the folder > for (QStringList::Iterator i = sets.begin(); i != sets.end(); ++i) > { >@@ -1475,7 +1491,7 @@ > if ( ok && exists < count() ) { > kdDebug(5006) << "KMFolderImap::slotGetMessagesData - server has less messages (" << > exists << ") then folder (" << count() << "), so reload" << endl; >- open(); >+ open("getMessage"); > reallyGetFolder( QString::null ); > (*it).cdata.remove(0, pos); > return; >@@ -1488,6 +1504,7 @@ > } > (*it).cdata.remove(0, pos); > } >+ open("digestsplit"); > pos = (*it).cdata.find("\r\n--IMAPDIGEST", 1); > int flags; > while (pos >= 0) >@@ -1569,6 +1586,7 @@ > (*it).done++; > pos = (*it).cdata.find("\r\n--IMAPDIGEST", 1); > } // while >+ close("digestsplit"); > } > > //------------------------------------------------------------- >@@ -1623,11 +1641,11 @@ > if ( it == mAccount->jobsEnd() ) return; > if (job->error()) { > mAccount->handleJobError( job, i18n("Error while retrieving messages.") ); >- finishMailCheck( imapNoInformation ); >+ finishMailCheck( "getMessage", imapNoInformation ); > return; > } > if (lastSet) { >- finishMailCheck( imapFinished ); >+ finishMailCheck( "getMessage", imapFinished ); > mAccount->removeJob(it); > } > } >@@ -1811,6 +1829,7 @@ > > void KMFolderImap::setStatus(QValueList<int>& ids, KMMsgStatus status, bool toggle) > { >+ open( "setstatus" ); > FolderStorage::setStatus(ids, status, toggle); > if (mReadOnly) return; > >@@ -1854,6 +1873,7 @@ > quiet( false ); > reallyGetFolder( QString::null ); > } >+ close( "setstatus" ); > } > > //----------------------------------------------------------------------------- >@@ -2306,12 +2326,12 @@ > } > } > >-void KMFolderImap::finishMailCheck( imapState state ) >+void KMFolderImap::finishMailCheck( const char *dbg, imapState state ) > { > quiet( false ); > mContentState = state; > emit folderComplete( this, mContentState == imapFinished ); >- close(); >+ close(dbg); > } > > #include "kmfolderimap.moc" >--- kmail/kmfolderindex.cpp 2005/07/26 18:54:59 438982 >+++ kmail/kmfolderindex.cpp 2007/03/28 14:44:39 647499 >@@ -463,11 +463,11 @@ > > void KMFolderIndex::fillMessageDict() > { >- open(); >+ open("fillDict"); > for (unsigned int idx = 0; idx < mMsgList.high(); idx++) > if ( mMsgList.at( idx ) ) > KMMsgDict::mutableInstance()->insert(0, mMsgList.at( idx ), idx); >- close(); >+ close("fillDict"); > } > > >--- kmail/kmfoldermaildir.cpp 2007/01/10 19:21:19 622120 >+++ kmail/kmfoldermaildir.cpp 2007/03/28 14:44:39 647499 >@@ -28,7 +28,6 @@ > #include <kstaticdeleter.h> > #include <kmessagebox.h> > >-#include <ctype.h> > #include <dirent.h> > #include <errno.h> > #include <stdlib.h> >@@ -59,7 +58,7 @@ > //----------------------------------------------------------------------------- > KMFolderMaildir::~KMFolderMaildir() > { >- if (mOpenCount>0) close(true); >+ if (mOpenCount>0) close("~foldermaildir", true); > if (kmkernel->undoStack()) kmkernel->undoStack()->folderDestroyed( folder() ); > } > >@@ -97,7 +96,7 @@ > } > > //----------------------------------------------------------------------------- >-int KMFolderMaildir::open() >+int KMFolderMaildir::open(const char *) > { > int rc = 0; > >@@ -220,7 +219,7 @@ > > > //----------------------------------------------------------------------------- >-void KMFolderMaildir::close(bool aForced) >+void KMFolderMaildir::close(const char *, bool aForced) > { > if (mOpenCount <= 0) return; > if (mOpenCount > 0) mOpenCount--; >@@ -406,7 +405,7 @@ > if ( !uidHeader.isEmpty() && stripUid ) > aMsg->removeHeaderField( "X-UID" ); > >- msgText = aMsg->asString(); >+ msgText = aMsg->asString(); // TODO use asDwString instead > len = msgText.length(); > > // Re-add the uid so that the take can make use of it, in case the >@@ -435,7 +434,7 @@ > if (!isOpened()) > { > opened = true; >- rc = open(); >+ rc = open("maildir"); > kdDebug(5006) << "KMFolderMaildir::addMsg-open: " << rc << " of folder: " << label() << endl; > if (rc) return rc; > } >@@ -446,7 +445,7 @@ > if (moveInternal(tmp_file, new_loc, filename, aMsg->status()).isNull()) > { > file.remove(); >- if (opened) close(); >+ if (opened) close("maildir"); > return -1; > } > >@@ -544,7 +543,7 @@ > emitMsgAddedSignals(idx); > needsCompact = true; > >- if (opened) close(); >+ if (opened) close("maildir" ); > /* > QFile fileD1( "testdat_xx-kmfoldermaildir-1" ); > if( fileD1.open( IO_WriteOnly ) ) { >@@ -734,7 +733,7 @@ > int cidx = contentTypeStr.find( "charset=" ); > if ( cidx != -1 ) { > charset = contentTypeStr.mid( cidx + 8 ); >- if ( charset[0] == '"' ) { >+ if ( !charset.isEmpty() && ( charset[0] == '"' ) ) { > charset = charset.mid( 1 ); > } > cidx = 0; >--- kmail/kmfoldermaildir.h 2005/07/26 18:54:59 438982 >+++ kmail/kmfoldermaildir.h 2007/03/28 14:44:39 647499 >@@ -60,7 +60,7 @@ > call close() first. > Returns zero on success and an error code equal to the c-library > fopen call otherwise (errno). */ >- virtual int open(); >+ virtual int open(const char *owner); > > virtual int canAccess(); > >@@ -69,7 +69,7 @@ > > /** Close folder. If force is TRUE the files are closed even if > others still use it (e.g. other mail reader windows). */ >- virtual void close(bool force=FALSE); >+ virtual void close(const char *owner, bool force=FALSE); > > /** Create the necessary folders for a maildir folder. Usually you will > want to use create() instead. >--- kmail/kmfoldermbox.cpp 2007/01/10 19:21:19 622120 >+++ kmail/kmfoldermbox.cpp 2007/03/28 14:44:39 647499 >@@ -84,19 +84,22 @@ > //----------------------------------------------------------------------------- > KMFolderMbox::~KMFolderMbox() > { >- if (mOpenCount>0) close(true); >+ if (mOpenCount>0) close("~kmfoldermbox", true); > if (kmkernel->undoStack()) kmkernel->undoStack()->folderDestroyed( folder() ); > } > > //----------------------------------------------------------------------------- >-int KMFolderMbox::open() >+int KMFolderMbox::open(const char *owner) > { > int rc = 0; > > mOpenCount++; > kmkernel->jobScheduler()->notifyOpeningFolder( folder() ); > >- if (mOpenCount > 1) return 0; // already open >+ if (mOpenCount > 1) { >+ assert(mStream); >+ return 0; // already open >+ } > > assert(!folder()->name().isEmpty()); > >@@ -253,11 +256,15 @@ > > > //----------------------------------------------------------------------------- >-void KMFolderMbox::close(bool aForced) >+void KMFolderMbox::close(const char *owner, bool aForced) > { >- if (mOpenCount <= 0 || !mStream) return; >+ if (!aForced) >+ assert(mOpenCount >= 0); >+ >+ if (mOpenCount <= 0 || !mStream) { mOpenCount = 0; return; } > if (mOpenCount > 0) mOpenCount--; >- if (mOpenCount > 0 && !aForced) return; >+ if (mOpenCount > 0 && !aForced) { assert(mStream); return; } >+ > #if 0 // removed hack that prevented closing system folders (see kmail-devel discussion about mail expiring) > if ( (folder() != kmkernel->inboxFolder()) > && folder()->isSystemFolder() && !aForced ) >@@ -870,12 +877,12 @@ > } > > //static >-QCString KMFolderMbox::escapeFrom( const QCString & str ) { >+QByteArray KMFolderMbox::escapeFrom( const DwString & str ) { > const unsigned int strLen = str.length(); > if ( strLen <= STRDIM("From ") ) >- return str; >+ return KMail::Util::ByteArray( str ); > // worst case: \nFrom_\nFrom_\nFrom_... => grows to 7/6 >- QCString result( int( strLen + 5 ) / 6 * 7 + 1 ); >+ QByteArray result( int( strLen + 5 ) / 6 * 7 + 1 ); > > const char * s = str.data(); > const char * const e = s + strLen - STRDIM("From "); >@@ -961,7 +968,7 @@ > { > if (!canAddMsgNow(aMsg, aIndex_ret)) return 0; > bool opened = false; >- QCString msgText; >+ QByteArray msgText; > char endStr[3]; > int idx = -1, rc; > KMFolder* msgParent; >@@ -971,7 +978,7 @@ > if (!mStream) > { > opened = true; >- rc = open(); >+ rc = open("mboxaddMsg"); > kdDebug(5006) << "KMFolderMBox::addMsg-open: " << rc << " of folder: " << label() << endl; > if (rc) return rc; > } >@@ -1018,15 +1025,15 @@ > if (aMsg->headerField("Content-Type").isEmpty()) // This might be added by > aMsg->removeHeaderField("Content-Type"); // the line above > } >- msgText = escapeFrom( aMsg->asString() ); >- size_t len = msgText.length(); >+ msgText = escapeFrom( aMsg->asDwString() ); >+ size_t len = msgText.size(); > > assert(mStream != 0); > clearerr(mStream); > if (len <= 0) > { > kdDebug(5006) << "Message added to folder `" << name() << "' contains no data. Ignoring it." << endl; >- if (opened) close(); >+ if (opened) close("mboxaddMsg"); > return 0; > } > >@@ -1052,14 +1059,14 @@ > int error = ferror(mStream); > if (error) > { >- if (opened) close(); >+ if (opened) close("mboxaddMsg"); > return error; > } > > QCString messageSeparator( aMsg->mboxMessageSeparator() ); > fwrite( messageSeparator.data(), messageSeparator.length(), 1, mStream ); > off_t offs = ftell(mStream); >- fwrite(msgText, len, 1, mStream); >+ fwrite(msgText.data(), len, 1, mStream); > if (msgText[(int)len-1]!='\n') fwrite("\n\n", 1, 2, mStream); > fflush(mStream); > size_t size = ftell(mStream) - offs; >@@ -1173,7 +1180,7 @@ > // some "paper work" > if (aIndex_ret) *aIndex_ret = idx; > emitMsgAddedSignals(idx); >- if (opened) close(); >+ if (opened) close("mboxaddMsg"); > > // All streams have been flushed without errors if we arrive here > // Return success! >@@ -1270,7 +1277,7 @@ > > if (openCount > 0) > { >- open(); >+ open("mboxcompact"); > mOpenCount = openCount; > } > // If this is the current folder, the changed signal will ultimately call >--- kmail/kmfoldersearch.cpp 2006/08/12 18:38:25 572453 >+++ kmail/kmfoldersearch.cpp 2007/03/29 01:00:34 647650 >@@ -146,6 +146,15 @@ > > void KMSearch::start() > { >+ //close all referenced folders >+ QValueListIterator<QGuardedPtr<KMFolder> > fit; >+ for (fit = mFolders.begin(); fit != mFolders.end(); ++fit) { >+ if (!(*fit)) >+ continue; >+ (*fit)->close("kmsearch"); >+ } >+ mFolders.clear(); >+ > if ( running() ) > return; > >@@ -220,7 +229,7 @@ > } > folder->storage()->search( 0 ); > mSearchCount += folder->count(); >- folder->close(); >+ folder->close("kmsearch"); > } > } > mRemainingFolders = -1; >@@ -248,7 +257,7 @@ > if ( folder ) > { > mLastFolder = folder->label(); >- folder->open(); >+ folder->open("kmsearch"); > mOpenedFolders.append( folder ); > connect( folder->storage(), > SIGNAL( searchResult( KMFolder*, QValueList<Q_UINT32>, const KMSearchPattern*, bool ) ), >@@ -286,7 +295,7 @@ > const KMSearchPattern*, bool ) ) ); > --mRemainingFolders; > mSearchCount += folder->count(); >- folder->close(); >+ folder->close("kmsearch"); > mOpenedFolders.remove( folder ); > if ( mRemainingFolders <= 0 ) > { >@@ -369,7 +378,7 @@ > delete mSearch; > mSearch = 0; > if (mOpenCount > 0) >- close(TRUE); >+ close("~foldersearch", TRUE); > } > > void KMFolderSearch::setSearch(KMSearch *search) >@@ -403,7 +412,7 @@ > /* TODO There is KMFolder::cleared signal now. Adjust. */ > if (mSearch) > mSearch->start(); >- open(); // will be closed in searchFinished >+ open("foldersearch"); // will be closed in searchFinished > } > > void KMFolderSearch::executeSearch() >@@ -423,7 +432,7 @@ > { > if (!success) > mSerNums.clear(); >- close(); >+ close("foldersearch"); > } > > void KMFolderSearch::addSerNum(Q_UINT32 serNum) >@@ -435,7 +444,7 @@ > KMMsgDict::instance()->getLocation(serNum, &aFolder, &idx); > assert(aFolder && (idx != -1)); > if(mFolders.findIndex(aFolder) == -1) { >- aFolder->open(); >+ aFolder->open("foldersearch"); > // Exceptional case, for when folder has invalid ids > if (mInvalid) > return; >@@ -499,7 +508,7 @@ > return mSearch->read(location()); > } > >-int KMFolderSearch::open() >+int KMFolderSearch::open(const char *) > { > mOpenCount++; > kmkernel->jobScheduler()->notifyOpeningFolder( folder() ); >@@ -537,7 +546,7 @@ > } > } > >-void KMFolderSearch::close(bool force) >+void KMFolderSearch::close(const char *, bool force) > { > if (mOpenCount <= 0) return; > if (mOpenCount > 0) mOpenCount--; >@@ -557,7 +566,7 @@ > for (fit = mFolders.begin(); fit != mFolders.end(); ++fit) { > if (!(*fit)) > continue; >- (*fit)->close(); >+ (*fit)->close("foldersearch"); > } > mFolders.clear(); > >@@ -852,7 +861,7 @@ > } > mSerNums.push_back(serNum); > if(mFolders.findIndex(folder) == -1) { >- folder->open(); >+ folder->open("foldersearch"); > if (mInvalid) //exceptional case for when folder has invalid ids > return false; > mFolders.append(folder); >@@ -910,7 +919,16 @@ > > void KMFolderSearch::clearIndex(bool, bool) > { >- mSerNums.clear(); >+ //close all referenced folders >+ QValueListIterator<QGuardedPtr<KMFolder> > fit; >+ for (fit = mFolders.begin(); fit != mFolders.end(); ++fit) { >+ if (!(*fit)) >+ continue; >+ (*fit)->close("foldersearch"); >+ } >+ mFolders.clear(); >+ >+ mSerNums.clear(); > } > > void KMFolderSearch::truncateIndex() >@@ -925,7 +943,7 @@ > if (!search()->inScope(aFolder)) > return; > if (!mTempOpened) { >- open(); >+ open( "foldersearch" ); > mTempOpened = true; > } > >@@ -937,7 +955,7 @@ > KMMsgDict::instance()->getLocation(serNum, &folder, &idx); > assert(folder && (idx != -1)); > assert(folder == aFolder); >- folder->open(); >+ folder->open("examineAddedMessage"); > > // if we are already checking this folder, refcount > if ( mFoldersCurrentlyBeingSearched.contains( folder ) ) { >@@ -952,6 +970,7 @@ > mFoldersCurrentlyBeingSearched.insert( folder, 1 ); > } > folder->storage()->search( search()->searchPattern(), serNum ); >+ folder->close("examineAddedMessage"); > } > > void KMFolderSearch::slotSearchExamineMsgDone( KMFolder* folder, >@@ -962,6 +981,7 @@ > if ( search()->searchPattern() != pattern ) return; > kdDebug(5006) << folder->label() << ": serNum " << serNum > << " matches?" << matches << endl; >+ folder->open("SearchExamineMsgDone"); > > if ( mFoldersCurrentlyBeingSearched.contains( folder ) ) { > unsigned int count = mFoldersCurrentlyBeingSearched[folder]; >@@ -979,7 +999,7 @@ > } else { > Q_ASSERT( 0 ); // Can't happen (TM) > } >- folder->close(); >+ folder->close("SearchExamineMsgDone"); > > if ( !matches ) { > QValueVector<Q_UINT32>::const_iterator it; >@@ -1009,7 +1029,7 @@ > if (!search()->inScope(folder)) > return; > if (!mTempOpened) { >- open(); >+ open("foldersearch"); > mTempOpened = true; > } > >@@ -1027,7 +1047,7 @@ > if (!search()->inScope(aFolder)) > return; > if (!mTempOpened) { >- open(); >+ open("foldersearch"); > mTempOpened = true; > } > QValueVector<Q_UINT32>::const_iterator it; >@@ -1046,7 +1066,7 @@ > if (!search()->inScope(folder)) > return; > if (mTempOpened) { >- close(); >+ close("foldersearch"); > mTempOpened = false; > } > >@@ -1063,7 +1083,7 @@ > return; > > if (!mTempOpened) { >- open(); >+ open("foldersearch"); > mTempOpened = true; > } > mExecuteSearchTimer->start(0, true); >@@ -1086,7 +1106,7 @@ > if (!search()->inScope(aFolder)) > return; > if (!mTempOpened) { >- open(); >+ open("foldersearch"); > mTempOpened = true; > } > >@@ -1100,7 +1120,7 @@ > ++pos; > } > // let's try if the message matches our search >- aFolder->open(); >+ aFolder->open("foldersearch"); > > // if we are already checking this folder, refcount > if ( mFoldersCurrentlyBeingSearched.contains( aFolder ) ) { >--- kmail/kmfoldersearch.h 2006/08/12 18:38:25 572453 >+++ kmail/kmfoldersearch.h 2007/03/28 14:44:39 647499 >@@ -171,10 +171,10 @@ > //See base class for documentation > virtual QCString& getMsgString(int idx, QCString& mDest); > virtual int addMsg(KMMessage* msg, int* index_return = 0); >- virtual int open(); >+ virtual int open(const char *owner); > virtual int canAccess(); > virtual void sync(); >- virtual void close(bool force=FALSE); >+ virtual void close(const char *owner, bool force=FALSE); > virtual int create(); > virtual int compact( bool ); > virtual bool isReadOnly() const; >--- kmail/kmfoldertree.cpp 2006/12/16 03:44:17 614049 >+++ kmail/kmfoldertree.cpp 2007/03/28 14:44:39 647499 >@@ -489,9 +489,9 @@ > if (!folderNode->isDir()) { > folder = static_cast<KMFolder*>(folderNode); > >- folder->open(); >+ folder->open("updateunread"); > folder->countUnread(); >- folder->close(); >+ folder->close("updateunread"); > } > } > >@@ -648,10 +648,10 @@ > > // open the folder and update the count > bool open = fti->folder()->isOpened(); >- if (!open) fti->folder()->open(); >+ if (!open) fti->folder()->open("updatecount"); > slotUpdateCounts(fti->folder()); > // restore previous state >- if (!open) fti->folder()->close(); >+ if (!open) fti->folder()->close("updatecount"); > > QTimer::singleShot( 0, this, SLOT(slotUpdateOneCount()) ); > } >--- kmail/kmkernel.cpp 2006/12/16 03:44:17 614049 >+++ kmail/kmkernel.cpp 2007/03/28 14:44:39 647499 >@@ -866,7 +866,7 @@ > > int i; > >- mAddMsgCurrentFolder->open(); >+ mAddMsgCurrentFolder->open("dcopadd"); > for( i=0; i<mAddMsgCurrentFolder->count(); i++) { > KMMsgBase *mb = mAddMsgCurrentFolder->getMsgBase(i); > QString id = mb->msgIdMD5(); >@@ -885,7 +885,7 @@ > mAddMessageMsgIds.append(id); > } > } >- mAddMsgCurrentFolder->close(); >+ mAddMsgCurrentFolder->close("dcopadd"); > } > > QString msgId = msg->msgIdMD5(); >@@ -1101,7 +1101,7 @@ > KMMsgDict::instance()->getLocation(serialNumber, &folder, &idx); > if (!folder || (idx == -1)) > return false; >- folder->open(); >+ folder->open("showmail"); > KMMsgBase *msgBase = folder->getMsgBase(idx); > if (!msgBase) > return false; >@@ -1118,7 +1118,7 @@ > > if (unGet) > folder->unGetMsg(idx); >- folder->close(); >+ folder->close("showmail"); > return true; > } > >@@ -1132,7 +1132,7 @@ > KMMsgDict::instance()->getLocation(serialNumber, &folder, &idx); > if (!folder || (idx == -1)) > return QString::null; >- folder->open(); >+ folder->open("getFrom"); > KMMsgBase *msgBase = folder->getMsgBase(idx); > if (!msgBase) > return QString::null; >@@ -1141,7 +1141,7 @@ > QString result = msg->from(); > if (unGet) > folder->unGetMsg(idx); >- folder->close(); >+ folder->close("getFrom"); > return result; > } > >@@ -1163,7 +1163,7 @@ > // different folder > if (folder && (idx != -1)) { > // everything is ok >- folder->open(); >+ folder->open("debugser"); > msg = folder->getMsgBase( idx ); > if (msg) { > res.append( QString( " subject %s,\n sender %s,\n date %s.\n" ) >@@ -1173,7 +1173,7 @@ > } else { > res.append( QString( "Invalid serial number." ) ); > } >- folder->close(); >+ folder->close("debugser"); > } else { > res.append( QString( "Invalid serial number." ) ); > } >@@ -1335,7 +1335,7 @@ > return; > > KMFolder folder( 0, pathName + "autosave", KMFolderTypeMaildir, false /* no index */ ); >- const int rc = folder.open(); >+ const int rc = folder.open("recover"); > if ( rc ) { > perror( "cannot open autosave folder" ); > return; >@@ -1351,7 +1351,7 @@ > win->show(); > } > } >- folder.close(); >+ folder.close("recover"); > } > > //----------------------------------------------------------------------------- >@@ -1395,7 +1395,7 @@ > * the index on each start to be on the save side. */ > //if ( the_outboxFolder->folderType() == KMFolderTypeMaildir ) > // unlink( QFile::encodeName( the_outboxFolder->indexLocation() ) ); >- the_outboxFolder->open(); >+ the_outboxFolder->open("kmkernel"); > > the_sentFolder = the_folderMgr->findOrCreate(cfg->readEntry("sentFolder", I18N_NOOP("sent-mail"))); > if (the_sentFolder->canAccess() != 0) { >@@ -1422,7 +1422,7 @@ > the_draftsFolder->setSystemFolder( TRUE ); > if ( the_draftsFolder->userWhoField().isEmpty() ) > the_draftsFolder->setUserWhoField( QString::null ); >- the_draftsFolder->open(); >+ the_draftsFolder->open("kmkernel"); > > the_templatesFolder = > the_folderMgr->findOrCreate( cfg->readEntry( "templatesFolder", >@@ -1433,7 +1433,7 @@ > the_templatesFolder->setSystemFolder( TRUE ); > if ( the_templatesFolder->userWhoField().isEmpty() ) > the_templatesFolder->setUserWhoField( QString::null ); >- the_templatesFolder->open(); >+ the_templatesFolder->open("kmkernel"); > } > > >@@ -1581,7 +1581,7 @@ > imapAcct = static_cast<KMAcctImap*>(acct); > fld->setAccount(imapAcct); > imapAcct->setImapFolder(fld); >- fld->close(); >+ fld->close( "kernel", true ); > } > the_imapFolderMgr->quiet(false); > >@@ -1612,7 +1612,7 @@ > cachedImapAcct = static_cast<KMAcctCachedImap*>(acct); > cfld->setAccount(cachedImapAcct); > cachedImapAcct->setImapFolder(cfld); >- cfld->close(); >+ cfld->close("kmkernel"); > } > the_dimapFolderMgr->quiet( false ); > } >@@ -1676,7 +1676,7 @@ > > if (the_trashFolder) { > >- the_trashFolder->close(TRUE); >+ the_trashFolder->close("kmkernel", TRUE); > > if (config->readBoolEntry("empty-trash-on-exit", true)) > { >@@ -1695,7 +1695,7 @@ > { > folder = *folders.at(i); > if (!folder || folder->isDir()) continue; >- folder->close(TRUE); >+ folder->close("kmkernel", TRUE); > } > strList.clear(); > folders.clear(); >@@ -1704,7 +1704,7 @@ > { > folder = *folders.at(i); > if (!folder || folder->isDir()) continue; >- folder->close(TRUE); >+ folder->close("kmkernel", TRUE); > } > > delete the_msgIndex; >@@ -1952,6 +1952,15 @@ > this, SLOT( slotConfigChanged() ) ); > } > >+ if( KMKernel::getKMMainWidget() == 0 ) >+ { >+ // ensure that there is a main widget available >+ // as parts of the configure dialog (identity) rely on this >+ // and this slot can be called when there is only a KMComposeWin showing >+ KMMainWin * win = new KMMainWin; >+ win->show(); >+ } >+ > if( mConfigureDialog->isHidden() ) > mConfigureDialog->show(); > else >--- kmail/kmmainwidget.cpp 2006/12/16 04:47:10 614050 >+++ kmail/kmmainwidget.cpp 2007/03/29 09:21:13 647728 >@@ -164,6 +164,7 @@ > mJob = 0; > mConfig = config; > mGUIClient = aGUIClient; >+ mOpenedImapFolder = false; > > mCustomReplyActionMenu = 0; > mCustomReplyAllActionMenu = 0; >@@ -265,11 +266,15 @@ > void KMMainWidget::readPreConfig(void) > { > const KConfigGroup geometry( KMKernel::config(), "Geometry" ); >- const KConfigGroup general( KMKernel::config(), "General" ); >+ const KConfigGroup reader( KMKernel::config(), "Reader" ); > > mLongFolderList = geometry.readEntry( "FolderList", "long" ) != "short"; > mReaderWindowActive = geometry.readEntry( "readerWindowMode", "below" ) != "hide"; > mReaderWindowBelow = geometry.readEntry( "readerWindowMode", "below" ) == "below"; >+ mThreadPref = geometry.readBoolEntry( "nestedMessages", false ); >+ >+ mHtmlPref = reader.readBoolEntry( "htmlMail", false ); >+ mHtmlLoadExtPref = reader.readBoolEntry( "htmlLoadExternal", false ); > } > > >@@ -336,14 +341,8 @@ > > } > >- // read "Reader" config options >- KConfigGroup readerConfig( config, "Reader" ); >- mHtmlPref = readerConfig.readBoolEntry( "htmlMail", false ); >- mHtmlLoadExtPref = readerConfig.readBoolEntry( "htmlLoadExternal", false ); >- > { // area for config group "Geometry" > KConfigGroupSaver saver(config, "Geometry"); >- mThreadPref = config->readBoolEntry( "nestedMessages", false ); > // size of the mainwin > QSize defaultSize(750,560); > siz = config->readSizeEntry("MainWin", &defaultSize); >@@ -464,7 +463,6 @@ > QString s; > KConfig *config = KMKernel::config(); > KConfigGroup geometry( config, "Geometry" ); >- KConfigGroup general( config, "General" ); > > if (mMsgView) > mMsgView->writeConfig(); >@@ -856,7 +854,7 @@ > > KMFolder *folder = kmkernel->findFolderById( *it ); > >- if ( !folder->ignoreNewMail() ) { >+ if ( folder && !folder->ignoreNewMail() ) { > showNotification = true; > if ( GlobalSettings::self()->verboseNewMailNotification() ) { > summary += "<br>" + i18n( "1 new message in %1", >@@ -1872,14 +1870,34 @@ > slotChangeCaption( mFolderTree->currentItem() ); > } > >+void KMMainWidget::openFolder() >+{ >+ if ( !mFolder || mFolder->folderType() != KMFolderTypeImap ) >+ return; >+ KMFolderImap *imap = static_cast<KMFolderImap*>(mFolder->storage()); >+ assert( !mOpenedImapFolder ); >+ imap->open("mainwidget"); // will be closed in the folderSelected slot >+ mOpenedImapFolder = true; >+ // first get new headers before we select the folder >+ imap->setSelected( true ); >+} >+ >+void KMMainWidget::closeFolder() >+{ >+ if ( !mFolder || mFolder->folderType() != KMFolderTypeImap ) >+ return; >+ assert( mOpenedImapFolder ); >+ KMFolderImap *imap = static_cast<KMFolderImap*>(mFolder->storage()); >+ imap->setSelected( false ); >+ mFolder->close( "mainwidget" ); >+ mOpenedImapFolder = false; >+} >+ > //----------------------------------------------------------------------------- > void KMMainWidget::folderSelected() > { > folderSelected( mFolder ); > updateFolderMenu(); >- // opened() before the getAndCheckFolder() in folderSelected >- if ( mFolder && mFolder->folderType() == KMFolderTypeImap ) >- mFolder->close(); > } > > //----------------------------------------------------------------------------- >@@ -1907,7 +1925,7 @@ > bool newFolder = ( mFolder != aFolder ); > bool isNewImapFolder = aFolder && aFolder->folderType() == KMFolderTypeImap && newFolder; > if( !mFolder >- || ( !isNewImapFolder && mShowBusySplashTimer && !mShowBusySplashTimer->isActive() ) >+ || ( !isNewImapFolder && mShowBusySplashTimer ) > || ( newFolder && mShowingOfflineScreen && !( isNewImapFolder && kmkernel->isOffline() ) ) ) { > if ( mMsgView ) { > mMsgView->enableMsgDisplay(); >@@ -1935,8 +1953,14 @@ > this, SLOT( updateMarkAsReadAction() ) ); > } > >+ if ( newFolder ) >+ closeFolder(); >+ > mFolder = aFolder; > >+ if ( newFolder ) >+ openFolder(); >+ > if ( aFolder && aFolder->folderType() == KMFolderTypeImap ) > { > if ( kmkernel->isOffline() ) { >@@ -1946,9 +1970,6 @@ > KMFolderImap *imap = static_cast<KMFolderImap*>(aFolder->storage()); > if ( newFolder && !mFolder->noContent() ) > { >- imap->open(); // will be closed in the folderSelected slot >- // first get new headers before we select the folder >- imap->setSelected( true ); > connect( imap, SIGNAL( folderComplete( KMFolderImap*, bool ) ), > this, SLOT( folderSelected() ) ); > imap->getAndCheckFolder(); >@@ -2724,10 +2745,10 @@ > actionCollection(), "refresh_folder" ); > mTroubleshootFolderAction = 0; // set in initializeIMAPActions > >- mEmptyFolderAction = new KAction( "foo", "edittrash", 0, this, >+ mEmptyFolderAction = new KAction( "foo" /*set in updateFolderMenu*/, "edittrash", 0, this, > SLOT(slotEmptyFolder()), actionCollection(), "empty" ); > >- mRemoveFolderAction = new KAction( "foo", "editdelete", 0, this, >+ mRemoveFolderAction = new KAction( "foo" /*set in updateFolderMenu*/, "editdelete", 0, this, > SLOT(slotRemoveFolder()), actionCollection(), "delete_folder" ); > > mPreferHtmlAction = new KToggleAction( i18n("Prefer &HTML to Plain Text"), 0, this, >@@ -3127,6 +3148,7 @@ > initializeIMAPActions( false ); // don't set state, config not read yet > updateMessageActions(); > updateCustomTemplateMenus(); >+ updateFolderMenu(); > } > > //----------------------------------------------------------------------------- >@@ -3397,10 +3419,8 @@ > mEmptyFolderAction->setText( (mFolder && kmkernel->folderIsTrash(mFolder)) > ? i18n("E&mpty Trash") : i18n("&Move All Messages to Trash") ); > mRemoveFolderAction->setEnabled( mFolder && !mFolder->isSystemFolder() && !mFolder->isReadOnly() ); >- if(mFolder) { >- mRemoveFolderAction->setText( mFolder->folderType() == KMFolderTypeSearch >+ mRemoveFolderAction->setText( mFolder && mFolder->folderType() == KMFolderTypeSearch > ? i18n("&Delete Search") : i18n("&Delete Folder") ); >- } > mExpireFolderAction->setEnabled( mFolder && mFolder->isAutoExpire() ); > updateMarkAsReadAction(); > // the visual ones only make sense if we are showing a message list >@@ -3465,6 +3485,7 @@ > > mMsgView->displayAboutPage(); > >+ closeFolder(); > mFolder = 0; > } > >@@ -3533,7 +3554,7 @@ > QMap< QString, QValueList<int> > idMD5s; > QValueList<int> redundantIds; > QValueList<int>::Iterator kt; >- mFolder->open(); >+ mFolder->open("removedups"); > for (int i = mFolder->count() - 1; i >= 0; --i) { > QString id = (*mFolder)[i]->msgIdMD5(); > if ( !id.isEmpty() ) { >@@ -3572,7 +3593,7 @@ > } > while (kt != redundantIds.begin()); > >- mFolder->close(); >+ mFolder->close("removedups"); > mHeaders->setFolder(oFolder); > QString msg; > if ( numDuplicates ) >--- kmail/kmmainwidget.h 2006/12/16 03:44:17 614049 >+++ kmail/kmmainwidget.h 2007/03/29 09:21:13 647728 >@@ -241,6 +241,10 @@ > void updateFileMenu(); > void newFromTemplate( KMMessage *msg ); > >+ // helper functions for keeping reference to mFolder >+ void openFolder(); >+ void closeFolder(); >+ > KActionCollection * actionCollection() const { return mActionCollection; } > > /** @return the correct config dialog depending on whether the parent of the mainWidget >@@ -531,6 +535,7 @@ > KXMLGUIClient *mGUIClient; > > static QValueList<KMMainWidget*>* s_mainWidgetList; >+ bool mOpenedImapFolder; > }; > > #endif >--- kmail/kmmessage.cpp 2007/01/13 19:16:48 623016 >+++ kmail/kmmessage.cpp 2007/03/23 06:43:35 645628 >@@ -64,6 +64,7 @@ > #include <klocale.h> > #include <stdlib.h> > #include <unistd.h> >+#include "util.h" > > #if ALLOW_GUI > #include <kmessagebox.h> >@@ -87,21 +88,11 @@ > > //----------------------------------------------------------------------------- > KMMessage::KMMessage(DwMessage* aMsg) >- : KMMsgBase(), >- mMsg(aMsg), >- mNeedsAssembly(true), >- mDecodeHTML(false), >- mOverrideCodec(0), >- mFolderOffset( 0 ), >- mMsgSize(0), >- mMsgLength( 0 ), >- mDate( 0 ), >- mEncryptionState( KMMsgEncryptionStateUnknown ), >- mSignatureState( KMMsgSignatureStateUnknown ), >- mMDNSentState( KMMsgMDNStateUnknown ), >- mUnencryptedMsg(0), >- mLastUpdated( 0 ) >+ : KMMsgBase() > { >+ init( aMsg ); >+ // aMsg might need assembly >+ mNeedsAssembly = true; > } > > //----------------------------------------------------------------------------- >@@ -138,10 +129,14 @@ > assign( other ); > } > >-void KMMessage::init() >+void KMMessage::init( DwMessage* aMsg ) > { > mNeedsAssembly = false; >+ if ( aMsg ) { >+ mMsg = aMsg; >+ } else { > mMsg = new DwMessage; >+ } > mOverrideCodec = 0; > mDecodeHTML = false; > mComplete = true; >@@ -157,6 +152,7 @@ > mUnencryptedMsg = 0; > mLastUpdated = 0; > mCursorPos = 0; >+ mIsParsed = false; > } > > void KMMessage::assign( const KMMessage& other ) >@@ -179,6 +175,7 @@ > mEncryptionState = other.mEncryptionState; > mSignatureState = other.mSignatureState; > mMDNSentState = other.mMDNSentState; >+ mIsParsed = other.mIsParsed; > mDate = other.mDate; > if( other.hasUnencryptedMsg() ) > mUnencryptedMsg = new KMMessage( *other.unencryptedMsg() ); >@@ -212,7 +209,7 @@ > { > DwHeaders& header = mMsg->Headers(); > if (header.HasMessageId()) >- return header.MessageId().AsString().c_str(); >+ return KMail::Util::CString( header.MessageId().AsString() ); > else > return ""; > } >@@ -294,7 +291,7 @@ > } > > //----------------------------------------------------------------------------- >-const DwMessage *KMMessage::asDwMessage() >+const DwMessage* KMMessage::asDwMessage() > { > if (mNeedsAssembly) > { >@@ -306,23 +303,21 @@ > > //----------------------------------------------------------------------------- > QCString KMMessage::asString() const { >- return asDwString().c_str(); >+ return KMail::Util::CString( asDwString() ); > } > > >-QCString KMMessage::asSendableString() const >+QByteArray KMMessage::asSendableString() const > { >- KMMessage msg; >- msg.fromString(asString()); >+ KMMessage msg( new DwMessage( *this->mMsg ) ); > msg.removePrivateHeaderFields(); > msg.removeHeaderField("Bcc"); >- return msg.asString(); >+ return KMail::Util::ByteArray( msg.asDwString() ); // and another copy again! > } > > QCString KMMessage::headerAsSendableString() const > { >- KMMessage msg; >- msg.fromString(asString()); >+ KMMessage msg( new DwMessage( *this->mMsg ) ); > msg.removePrivateHeaderFields(); > msg.removeHeaderField("Bcc"); > return msg.headerAsString().latin1(); >@@ -392,7 +387,7 @@ > } > > void KMMessage::fromString( const QCString & str, bool aSetStatus ) { >- return fromDwString( DwString( str.data() ), aSetStatus ); >+ return fromDwString( KMail::Util::dwString( str ), aSetStatus ); > } > > void KMMessage::fromDwString(const DwString& str, bool aSetStatus) >@@ -1105,11 +1100,9 @@ > > KMMessage* KMMessage::createRedirect( const QString &toStr ) > { >- KMMessage* msg = new KMMessage; >- KMMessagePart msgPart; >- > // copy the message 1:1 >- msg->fromDwString(this->asDwString()); >+ KMMessage* msg = new KMMessage( new DwMessage( *this->mMsg ) ); >+ KMMessagePart msgPart; > > uint id = 0; > QString strId = msg->headerField( "X-KMail-Identity" ).stripWhiteSpace(); >@@ -1195,6 +1188,7 @@ > // preserved > if ( type() == DwMime::kTypeMultipart || > ( type() == DwMime::kTypeText && subtype() == DwMime::kSubtypePlain ) ) { >+ // ## slow, we could probably use: delete msg->mMsg; msg->mMsg = new DwMessage( this->mMsg ); > msg->fromDwString( this->asDwString() ); > // remember the type and subtype, initFromMessage sets the contents type to > // text/plain, via initHeader, for unclear reasons >@@ -1250,7 +1244,7 @@ > KMMessagePart secondPart; > secondPart.setType( type() ); > secondPart.setSubtype( subtype() ); >- secondPart.setBody( mMsg->Body().AsString().c_str() ); >+ secondPart.setBody( mMsg->Body().AsString() ); > // use the headers of the original mail > applyHeadersToMessagePart( mMsg->Headers(), &secondPart ); > msg->addBodyPart(&secondPart); >@@ -1761,9 +1755,9 @@ > unixTime = header.Date().AsUnixTime(); > > QCString result = ctime(&unixTime); >- >- if (result[result.length()-1]=='\n') >- result.truncate(result.length()-1); >+ int len = result.length(); >+ if (result[len-1]=='\n') >+ result.truncate(len-1); > > return result; > } >@@ -2469,10 +2463,11 @@ > //----------------------------------------------------------------------------- > QCString KMMessage::body() const > { >- DwString body = mMsg->Body().AsString(); >- QCString str = body.c_str(); >- kdWarning( str.length() != body.length(), 5006 ) >- << "KMMessage::body(): body is binary but used as text!" << endl; >+ const DwString& body = mMsg->Body().AsString(); >+ QCString str = KMail::Util::CString( body ); >+ // Calls length() -> slow >+ //kdWarning( str.length() != body.length(), 5006 ) >+ // << "KMMessage::body(): body is binary but used as text!" << endl; > return str; > } > >@@ -2481,7 +2476,7 @@ > QByteArray KMMessage::bodyDecodedBinary() const > { > DwString dwstr; >- DwString dwsrc = mMsg->Body().AsString(); >+ const DwString& dwsrc = mMsg->Body().AsString(); > > switch (cte()) > { >@@ -2522,13 +2517,13 @@ > break; > } > >- unsigned int len = dwstr.size(); >- QCString result(len+1); >- memcpy(result.data(),dwstr.data(),len); >- result[len] = 0; >- kdWarning(result.length() != len, 5006) >- << "KMMessage::bodyDecoded(): body is binary but used as text!" << endl; >- return result; >+ return KMail::Util::CString( dwstr ); >+ >+ // Calling QCString::length() is slow >+ //QCString result = KMail::Util::CString( dwstr ); >+ //kdWarning(result.length() != len, 5006) >+ // << "KMMessage::bodyDecoded(): body is binary but used as text!" << endl; >+ //return result; > } > > >@@ -2609,7 +2604,7 @@ > bool allow8Bit, > bool willBeSigned ) > { >- CharFreq cf( aBuf.data(), aBuf.length() ); // it's safe to pass null strings >+ CharFreq cf( aBuf.data(), aBuf.size()-1 ); // it's safe to pass null strings > > allowedCte = determineAllowedCtes( cf, allow8Bit, willBeSigned ); > >@@ -2676,7 +2671,17 @@ > //----------------------------------------------------------------------------- > void KMMessage::setBody(const QCString& aStr) > { >- mMsg->Body().FromString(aStr.data()); >+ mMsg->Body().FromString(KMail::Util::dwString(aStr)); >+ mNeedsAssembly = TRUE; >+} >+void KMMessage::setBody(const DwString& aStr) >+{ >+ mMsg->Body().FromString(aStr); >+ mNeedsAssembly = TRUE; >+} >+void KMMessage::setBody(const char* aStr) >+{ >+ mMsg->Body().FromString(aStr); > mNeedsAssembly = TRUE; > } > >@@ -2874,14 +2879,14 @@ > > void applyHeadersToMessagePart( DwHeaders& headers, KMMessagePart* aPart ) > { >- // TODO: Instead of manually implementing RFC2231 header encoding (i.e. >- // possibly multiple values given as paramname*0=..; parmaname*1=..;... >+ // TODO: Instead of manually implementing RFC2231 header encoding (i.e. >+ // possibly multiple values given as paramname*0=..; parmaname*1=..;... > // or par as paramname*0*=..; parmaname*1*=..;..., which should be > // concatenated), use a generic method to decode the header, using RFC > // 2047 or 2231, or whatever future RFC might be appropriate! > // Right now, some fields are decoded, while others are not. E.g. > // Content-Disposition is not decoded here, rather only on demand in >- // KMMsgPart::fileName; Name however is decoded here and stored as a >+ // KMMsgPart::fileName; Name however is decoded here and stored as a > // decoded String in KMMsgPart... > // Content-type > QCString additionalCTypeParams; >@@ -2964,9 +2969,9 @@ > > // Body > if (withBody) >- aPart->setBody( aDwBodyPart->Body().AsString().c_str() ); >+ aPart->setBody( aDwBodyPart->Body().AsString() ); > else >- aPart->setBody( "" ); >+ aPart->setBody( QCString("") ); > > // Content-id > if ( headers.HasContentId() ) { >@@ -2987,7 +2992,7 @@ > //aPart->setName(" "); > aPart->setContentDescription(""); > aPart->setContentDisposition(""); >- aPart->setBody(""); >+ aPart->setBody(QCString("")); > aPart->setContentId(""); > } > } >@@ -3135,8 +3140,9 @@ > if (!contDisp.isEmpty()) > headers.ContentDisposition().FromString(contDisp); > >- if (!aPart->body().isNull()) >- part->Body().FromString(aPart->body()); >+ const DwString bodyStr = aPart->dwBody(); >+ if (!bodyStr.empty()) >+ part->Body().FromString(bodyStr); > else > part->Body().FromString(""); > >@@ -3194,7 +3200,7 @@ > //----------------------------------------------------------------------------- > QCString KMMessage::html2source( const QCString & src ) > { >- QCString result( 1 + 6*src.length() ); // maximal possible length >+ QCString result( 1 + 6*(src.size()-1) ); // maximal possible length > > QCString::ConstIterator s = src.begin(); > QCString::Iterator d = result.begin(); >@@ -4134,11 +4140,23 @@ > return; > } > >+ bool filenameEmpty = true; >+ if ( part->hasHeaders() ) { >+ if ( part->Headers().HasContentDisposition() ) { >+ DwDispositionType cd = part->Headers().ContentDisposition(); >+ filenameEmpty = cd.Filename().empty(); >+ if ( filenameEmpty ) { >+ // let's try if it is rfc 2231 encoded which mimelib can't handle >+ filenameEmpty = KMMsgBase::decodeRFC2231String( KMMsgBase::extractRFC2231HeaderField( cd.AsString().c_str(), "filename" ) ).isEmpty(); >+ } >+ } >+ } >+ > if ( part->hasHeaders() && > ( ( part->Headers().HasContentDisposition() && > !part->Headers().ContentDisposition().Filename().empty() ) || > ( part->Headers().HasContentType() && >- !part->Headers().ContentType().Name().empty() ) ) ) >+ !filenameEmpty ) ) ) > { > // now blacklist certain ContentTypes > if ( !part->Headers().HasContentType() || >--- kmail/kmmessage.h 2006/12/16 03:44:17 614049 >+++ kmail/kmmessage.h 2007/03/21 15:56:38 645047 >@@ -208,7 +208,7 @@ > /** Parse the string and create this message from it. */ > void fromDwString(const DwString& str, bool setStatus=FALSE); > void fromString(const QCString& str, bool setStatus=FALSE); >- void fromByteArray( const QByteArray & ba, bool setStatus=false ); >+ void fromByteArray(const QByteArray & ba, bool setStatus=false); > > /** Return the entire message contents in the DwString. This function > is *fast* even for large message since it does *not* involve a >@@ -230,7 +230,7 @@ > * Return the message contents with the headers that should not be > * sent stripped off. > */ >- QCString asSendableString() const; >+ QByteArray asSendableString() const; > > /** > * Return the message header with the headers that should not be >@@ -526,6 +526,8 @@ > > /** Set the message body. Does not encode the body. */ > void setBody(const QCString& aStr); >+ void setBody(const DwString& aStr); >+ void setBody(const char* aStr); // avoid ambiguous calls > > /** Hack to enable structured body parts to be set as flat text... */ > void setMultiPartBody( const QCString & aStr ); >@@ -853,10 +855,16 @@ > /** Set cursor position as offset from message start */ > void setCursorPos(int pos) { mCursorPos = pos; }; > >+ /* This is set in kmreaderwin if a message is being parsed to avoid >+ other parts of kmail (e.g. kmheaders) destroying the message. >+ Parsing can take longer and can be async (in case of gpg mails) */ >+ bool isBeingParsed() const { return mIsParsed; } >+ void setIsBeingParsed( bool t ) { mIsParsed = t; } >+ > private: > > /** Initialization shared by the ctors. */ >- void init(); >+ void init( DwMessage* aMsg = 0 ); > /** Assign the values of @param other to this message. Used in the copy c'tor. */ > void assign( const KMMessage& other ); > >@@ -867,6 +875,7 @@ > bool mDecodeHTML :1; > bool mReadyToShow :1; > bool mComplete :1; >+ bool mIsParsed : 1; > static const KMail::HeaderStrategy * sHeaderStrategy; > static QString sForwardStr; > const QTextCodec * mOverrideCodec; >--- kmail/kmmsgbase.cpp 2007/01/10 15:06:52 622052 >+++ kmail/kmmsgbase.cpp 2007/02/13 03:39:30 633069 >@@ -118,7 +118,7 @@ > //----------------------------------------------------------------------------- > bool KMMsgBase::isMessage(void) const > { >- return FALSE; >+ return false; > } > //----------------------------------------------------------------------------- > void KMMsgBase::toggleStatus(const KMMsgStatus aStatus, int idx) >@@ -152,7 +152,7 @@ > //----------------------------------------------------------------------------- > void KMMsgBase::setStatus(const KMMsgStatus aStatus, int idx) > { >- mDirty = TRUE; >+ mDirty = true; > KMMsgStatus oldStatus = status(); > switch (aStatus) { > case KMMsgStatusRead: >@@ -300,7 +300,7 @@ > void KMMsgBase::setEncryptionState( const KMMsgEncryptionState /*status*/, int idx ) > { > //kdDebug(5006) << "***setEncryptionState1( " << status << " )" << endl; >- mDirty = TRUE; >+ mDirty = true; > if (storage()) > storage()->headerOfMsgChanged(this, idx); > } >@@ -325,7 +325,7 @@ > void KMMsgBase::setSignatureState( const KMMsgSignatureState /*status*/, int idx ) > { > //kdDebug(5006) << "***setSignatureState1( " << status << " )" << endl; >- mDirty = TRUE; >+ mDirty = true; > if (storage()) > storage()->headerOfMsgChanged(this, idx); > } >@@ -542,7 +542,7 @@ > QString str = aStr; > > while (str[0] == ' ') str.remove(0,1); >- if (hasKeyword) *hasKeyword=FALSE; >+ if (hasKeyword) *hasKeyword=false; > > unsigned int strLength(str.length()); > for (i=0; i < strLength && i < maxChars; i++) >@@ -555,7 +555,7 @@ > do { > i++; > } while (str[i] == ' '); >- if (hasKeyword) *hasKeyword=TRUE; >+ if (hasKeyword) *hasKeyword=true; > return str.mid(i); > } > return str; >@@ -604,7 +604,7 @@ > { > encodings.append(KGlobal::charsets()->languageForEncoding(*it) > + " ( " + mimeName + " )"); >- mimeNames.insert(mimeName, TRUE); >+ mimeNames.insert(mimeName, true); > } > } > encodings.sort(); >@@ -686,7 +686,7 @@ > if (pos[0]!='=' || pos[1]!='?') { > result += LWSP_buffer + pos[0]; > LWSP_buffer = 0; >- lastWasEncodedWord = FALSE; >+ lastWasEncodedWord = false; > continue; > } > // found possible encoded-word >@@ -789,7 +789,7 @@ > > unsigned int start, stop, p, pos = 0, encLength; > QCString result; >- bool breakLine = FALSE; >+ bool breakLine = false; > const unsigned int maxLen = 75 - 7 - cset.length(); > > while (pos < strLength) >@@ -960,8 +960,8 @@ > pattern += QString::number(n) + "[*]?"; > } > pattern += "="; >- >- QRegExp fnamePart( pattern, FALSE ); >+ >+ QRegExp fnamePart( pattern, false ); > int startPart = fnamePart.search( aStr ); > int endPart; > found = ( startPart >= 0 ); >@@ -1112,19 +1112,19 @@ > QString ret; > > g_chunk_offset = 0; >- bool using_mmap = FALSE; >+ bool using_mmap = false; > bool swapByteOrder = storage()->indexSwapByteOrder(); > if (storage()->indexStreamBasePtr()) { > if (g_chunk) >- free(g_chunk); >- using_mmap = TRUE; >+ free(g_chunk); >+ using_mmap = true; > g_chunk = storage()->indexStreamBasePtr() + mIndexOffset; > g_chunk_length = mIndexLength; > } else { > if(!storage()->mIndexStream) > return ret; > if (g_chunk_length < mIndexLength) >- g_chunk = (uchar *)realloc(g_chunk, g_chunk_length = mIndexLength); >+ g_chunk = (uchar *)realloc(g_chunk, g_chunk_length = mIndexLength); > off_t first_off=ftell(storage()->mIndexStream); > fseek(storage()->mIndexStream, mIndexOffset, SEEK_SET); > fread( g_chunk, mIndexLength, 1, storage()->mIndexStream); >@@ -1181,13 +1181,13 @@ > off_t ret = 0; > > g_chunk_offset = 0; >- bool using_mmap = FALSE; >+ bool using_mmap = false; > int sizeOfLong = storage()->indexSizeOfLong(); > bool swapByteOrder = storage()->indexSwapByteOrder(); > if (storage()->indexStreamBasePtr()) { > if (g_chunk) > free(g_chunk); >- using_mmap = TRUE; >+ using_mmap = true; > g_chunk = storage()->indexStreamBasePtr() + mIndexOffset; > g_chunk_length = mIndexLength; > } else { >@@ -1371,7 +1371,7 @@ > bool KMMsgBase::syncIndexString() const > { > if(!dirty()) >- return TRUE; >+ return true; > int len; > const uchar *buffer = asIndexString(len); > if (len == mIndexLength) { >@@ -1379,9 +1379,9 @@ > fseek(storage()->mIndexStream, mIndexOffset, SEEK_SET); > assert( mIndexOffset > 0 ); > fwrite( buffer, len, 1, storage()->mIndexStream); >- return TRUE; >+ return true; > } >- return FALSE; >+ return false; > } > > static QStringList sReplySubjPrefixes, sForwardSubjPrefixes; >--- kmail/kmmsgdict.cpp 2006/08/25 21:15:06 577218 >+++ kmail/kmmsgdict.cpp 2007/03/09 17:06:16 640993 >@@ -16,6 +16,7 @@ > #include <stdio.h> > #include <unistd.h> > >+#include <string.h> > #include <errno.h> > > #include <config.h> >@@ -73,8 +74,7 @@ > KMMsgDictREntry(int size = 0) > { > array.resize(size); >- for (int i = 0; i < size; i++) >- array.at(i) = 0; >+ memset(array.data(), 0, array.size() * sizeof(KMMsgDictEntry *)); // faster than a loop > fp = 0; > swapByteOrder = false; > baseOffset = 0; >@@ -412,6 +412,19 @@ > if (swapByteOrder) > count = kmail_swap_32(count); > >+ // quick consistency check to avoid allocating huge amount of memory >+ // due to reading corrupt file (#71549) >+ long pos = ftell(fp); // store current position >+ fseek(fp, 0, SEEK_END); >+ long fileSize = ftell(fp); // how large is the file ? >+ fseek(fp, pos, SEEK_SET); // back to previous position >+ >+ // the file must at least contain what we try to read below >+ if ( (fileSize - pos) < (long)(count * sizeof(Q_UINT32)) ) { >+ fclose(fp); >+ return -1; >+ } >+ > KMMsgDictREntry *rentry = new KMMsgDictREntry(count); > > for (unsigned int index = 0; index < count; index++) { >--- kmail/kmmsgpart.cpp 2007/01/10 15:06:52 622052 >+++ kmail/kmmsgpart.cpp 2007/03/08 09:49:27 640496 >@@ -10,6 +10,7 @@ > #include "kmkernel.h" > #include "kmmessage.h" > #include "globalsettings.h" >+#include "util.h" > > #include <kasciistringtools.h> > #include <kmime_charfreq.h> >@@ -102,7 +103,29 @@ > //----------------------------------------------------------------------------- > void KMMessagePart::setBody(const QCString &aStr) > { >- mBody.duplicate( aStr.data(), aStr.length() ); >+ KMail::Util::setFromQCString( mBody, aStr ); >+ >+ int enc = cte(); >+ if (enc == DwMime::kCte7bit || enc == DwMime::kCte8bit || enc == DwMime::kCteBinary) >+ mBodyDecodedSize = mBody.size(); >+ else >+ mBodyDecodedSize = -1; // Can't know the decoded size >+} >+ >+void KMMessagePart::setBody(const DwString &aStr) >+{ >+ mBody.duplicate( aStr.c_str(), aStr.length() ); >+ >+ int enc = cte(); >+ if (enc == DwMime::kCte7bit || enc == DwMime::kCte8bit || enc == DwMime::kCteBinary) >+ mBodyDecodedSize = mBody.size(); >+ else >+ mBodyDecodedSize = -1; // Can't know the decoded size >+} >+ >+void KMMessagePart::setBody(const QByteArray &aStr) >+{ >+ mBody = aStr; > > int enc = cte(); > if (enc == DwMime::kCte7bit || enc == DwMime::kCte8bit || enc == DwMime::kCteBinary) >@@ -161,8 +184,7 @@ > //----------------------------------------------------------------------------- > void KMMessagePart::setBodyEncoded(const QCString& aStr) > { >- mBodyDecodedSize = aStr.length(); >- >+ mBodyDecodedSize = aStr.size() - 1; // same as aStr.length() but faster - assuming no embedded nuls > switch (cte()) > { > case DwMime::kCteQuotedPrintable: >@@ -191,6 +213,7 @@ > case DwMime::kCte7bit: > case DwMime::kCte8bit: > case DwMime::kCteBinary: >+ // This is slow and memory hungry - consider using setBodyEncodedBinary instead! > mBody.duplicate( aStr.data(), mBodyDecodedSize ); > break; > } >@@ -224,7 +247,7 @@ > bool allow8Bit, > bool willBeSigned ) > { >- mBodyDecodedSize = aBuf.length(); >+ mBodyDecodedSize = aBuf.size() - 1; // same as aStr.length() but faster - assuming no embedded nuls > > CharFreq cf( aBuf.data(), mBodyDecodedSize ); // save to pass null strings > >@@ -270,11 +293,37 @@ > case DwMime::kCte7bit: > case DwMime::kCte8bit: > case DwMime::kCteBinary: >- mBody.duplicate( aStr ); >+ //mBody.duplicate( aStr ); >+ mBody = aStr; >+ // Caller has to detach before it modifies aStr! > break; > } > } > >+//----------------------------------------------------------------------------- >+void KMMessagePart::setMessageBody( const QByteArray& aBuf ) >+{ >+ CharFreq cf( aBuf ); // it's safe to pass null arrays >+ mBodyDecodedSize = aBuf.size(); >+ >+ int cte; >+ switch ( cf.type() ) { >+ case CharFreq::SevenBitText: >+ case CharFreq::SevenBitData: >+ cte = DwMime::kCte7bit; >+ break; >+ case CharFreq::EightBitText: >+ case CharFreq::EightBitData: >+ cte = DwMime::kCte8bit; >+ break; >+ default: >+ kdWarning(5006) << "Calling " << k_funcinfo >+ << " with something containing neither 7 nor 8 bit text!" >+ << " Fix this caller: " << kdBacktrace() << endl; >+ } >+ setCte( cte ); >+ setBodyEncodedBinary( aBuf ); >+} > > //----------------------------------------------------------------------------- > QByteArray KMMessagePart::bodyDecodedBinary() const >@@ -348,13 +397,12 @@ > > if ( decodeBinary ) { > len = mBody.size(); >- result.resize( len+1 /* trailing NUL */ ); >- memcpy(result.data(), mBody.data(), len); >- result[len] = 0; >+ KMail::Util::setFromByteArray( result, mBody ); > } > >- kdWarning( result.length() != (unsigned int)len, 5006 ) >- << "KMMessagePart::bodyDecoded(): body is binary but used as text!" << endl; >+ // Calls length -> slow >+ //kdWarning( result.length() != (unsigned int)len, 5006 ) >+ // << "KMMessagePart::bodyDecoded(): body is binary but used as text!" << endl; > > result = result.replace( "\r\n", "\n" ); // CRLF -> LF conversion > >@@ -505,17 +553,17 @@ > QString KMMessagePart::fileName(void) const > { > QCString str; >- >- // Allow for multiple filname*0, filename*1, ... params (defined by RFC 2231) >+ >+ // Allow for multiple filname*0, filename*1, ... params (defined by RFC 2231) > // in the Content-Disposision > if ( mContentDisposition.contains( "filename*", FALSE ) ) { >- >+ > // It's RFC 2231 encoded, so extract the file name with the 2231 method > str = KMMsgBase::extractRFC2231HeaderField( mContentDisposition, "filename" ); > return KMMsgBase::decodeRFC2231String(str); >- >+ > } else { >- >+ > // Standard RFC 2047-encoded > // search the start of the filename > int startOfFilename = mContentDisposition.find("filename=", 0, FALSE); >@@ -540,14 +588,16 @@ > .stripWhiteSpace(); > return KMMsgBase::decodeRFC2047String(str, charset()); > } >- >+ > return QString::null; > } > >- >- > QCString KMMessagePart::body() const > { > return QCString( mBody.data(), mBody.size() + 1 ); // space for trailing NUL > } > >+DwString KMMessagePart::dwBody() const >+{ >+ return KMail::Util::dwString( mBody ); >+} >--- kmail/kmmsgpart.h 2005/08/30 10:59:19 454999 >+++ kmail/kmmsgpart.h 2007/03/08 09:49:27 640496 >@@ -27,6 +27,7 @@ > template <typename T> > class QValueList; > class QTextCodec; >+class DwString; > > class KMMessagePart > { >@@ -45,6 +46,10 @@ > /** Get or set the message body */ > QCString body(void) const; > void setBody(const QCString &aStr); >+ DwString dwBody() const; >+ void setBody(const DwString &aStr); >+ // warning, doesn't detach from 'arr' >+ void setBody(const QByteArray &arr); > > /** Sets this body part's content to @p str. @p str is subject to > automatic charset and CTE detection. >@@ -58,11 +63,11 @@ > /** Returns body as decoded string. Assumes that content-transfer-encoding > contains the correct encoding. This routine is meant for binary data. > No trailing 0 is appended. */ >- virtual QByteArray bodyDecodedBinary(void) const; >+ QByteArray bodyDecodedBinary(void) const; > > /** Returns body as decoded string. Assumes that content-transfer-encoding > contains the correct encoding. This routine is meant for text strings! */ >- virtual QCString bodyDecoded(void) const; >+ QCString bodyDecoded(void) const; > > /** Sets body, encoded in the best fitting > content-transfer-encoding, which is determined by character >@@ -73,26 +78,39 @@ > @param allow8Bit whether "8bit" is allowed as cte. > @param willBeSigned whether "7bit"/"8bit" is allowed as cte according to RFC 3156 > */ >- virtual void setBodyAndGuessCte(const QByteArray& aBuf, >+ void setBodyAndGuessCte(const QByteArray& aBuf, > QValueList<int>& allowedCte, > bool allow8Bit = false, > bool willBeSigned = false); > /** Same for text */ >- virtual void setBodyAndGuessCte(const QCString& aBuf, >+ void setBodyAndGuessCte(const QCString& aBuf, > QValueList<int>& allowedCte, > bool allow8Bit = false, > bool willBeSigned = false); > > /** Sets body, encoded according to the content-transfer-encoding. >- BEWARE: The entire aStr is used including trailing 0 of text strings! */ >- virtual void setBodyEncodedBinary(const QByteArray& aStr); >+ BEWARE: The entire aStr is used including trailing 0 of text strings! >+ This version is faster than setBodyEncoded, no duplication necessary. >+ */ >+ void setBodyEncodedBinary(const QByteArray& aStr); > > /** Sets body, encoded according to the content-transfer-encoding. >- This one is for text strings, the trailing 0 is not used. */ >- virtual void setBodyEncoded(const QCString& aStr); >+ This one is for text strings, the trailing 0 is not used. >+ >+ For speed reasons, prefer setBodyEncodedBinary. >+ When possible (the QCString isn't used afterwards), change setBodyEncoded(myQCString) into: >+ setBodyEncodedBinary(byteArrayFromQCStringNoDetach(myQCString)); >+ */ >+ void setBodyEncoded(const QCString& aStr); >+ >+ /** Set a full message string as the body of the message part, >+ disallowing anything but 7bit or 8bit encoding. >+ (RFC 1521 section 7.3) >+ */ >+ void setMessageBody( const QByteArray & aBuf ); > > /** Returns decoded length of body. */ >- virtual int decodedSize(void) const; >+ int decodedSize(void) const; > > /** Get or set the 'Content-Type' header field > The member functions that involve enumerated types (ints) >--- kmail/kmreadermainwin.cpp 2006/12/16 03:44:17 614049 >+++ kmail/kmreadermainwin.cpp 2007/03/28 14:44:39 647499 >@@ -132,13 +132,13 @@ > KMMsgDict::instance()->getLocation( mMsg->getMsgSerNum(), &parent, &index ); > if ( parent && !parent->isTrash() ) { > // open the folder (ref counted) >- parent->open(); >+ parent->open("trashmsg"); > KMMessage *msg = parent->getMsg( index ); > if (msg) { > KMDeleteMsgCommand *command = new KMDeleteMsgCommand( parent, msg ); > command->start(); > } >- parent->close(); >+ parent->close("trashmsg"); > } > close(); > } >--- kmail/kmreaderwin.cpp 2006/11/21 12:43:03 606698 >+++ kmail/kmreaderwin.cpp 2007/03/21 15:56:38 645047 >@@ -636,13 +636,13 @@ > mSelectEncodingAction->setItems( encodings ); > mSelectEncodingAction->setCurrentItem( 0 ); > >- mMailToComposeAction = new KAction( i18n("New Message To..."), 0, this, >- SLOT(slotMailtoCompose()), ac, >+ mMailToComposeAction = new KAction( i18n("New Message To..."), "mail_new", >+ 0, this, SLOT(slotMailtoCompose()), ac, > "mailto_compose" ); >- mMailToReplyAction = new KAction( i18n("Reply To..."), 0, this, >- SLOT(slotMailtoReply()), ac, >+ mMailToReplyAction = new KAction( i18n("Reply To..."), "mail_reply", >+ 0, this, SLOT(slotMailtoReply()), ac, > "mailto_reply" ); >- mMailToForwardAction = new KAction( i18n("Forward To..."), >+ mMailToForwardAction = new KAction( i18n("Forward To..."), "mail_forward", > 0, this, SLOT(slotMailtoForward()), ac, > "mailto_forward" ); > mAddAddrBookAction = new KAction( i18n("Add to Address Book"), >@@ -1354,7 +1354,7 @@ > "<p style='margin-bottom: 0px'> The KMail Team</p>") > .arg(KMAIL_VERSION) // KMail version > .arg("help:/kmail/index.html") // KMail help:// URL >- .arg("http://kmail.kde.org/") // KMail homepage URL >+ .arg("http://kontact.kde.org/kmail/") // KMail homepage URL > .arg("1.8").arg("3.4"); // prior KMail and KDE version > > QString featureItems; >@@ -1504,7 +1504,14 @@ > > assert(aMsg!=0); > >- delete mRootNode; >+ aMsg->setIsBeingParsed( true ); >+ >+ if ( mRootNode && !mRootNode->processed() ) >+ { >+ kdWarning() << "The root node is not yet processed! Danger!\n"; >+ return; >+ } else >+ delete mRootNode; > mRootNode = partNode::fromMessage( aMsg ); > const QCString mainCntTypeStr = mRootNode->typeString() + '/' + mRootNode->subTypeString(); > >@@ -1614,13 +1621,13 @@ > unencryptedMessage->setParent( 0 ); > // because this did not work: > /* >- DwMessage dwMsg( DwString( aMsg->asString() ) ); >+ DwMessage dwMsg( aMsg->asDwString() ); > dwMsg.Body() = DwBody( DwString( resultString.data() ) ); > dwMsg.Body().Parse(); > KMMessage* unencryptedMessage = new KMMessage( &dwMsg ); > */ >-kdDebug(5006) << "KMReaderWin - resulting message:" << unencryptedMessage->asString() << endl; >-kdDebug(5006) << "KMReaderWin - attach unencrypted message to aMsg" << endl; >+ //kdDebug(5006) << "KMReaderWin - resulting message:" << unencryptedMessage->asString() << endl; >+ kdDebug(5006) << "KMReaderWin - attach unencrypted message to aMsg" << endl; > aMsg->setUnencryptedMsg( unencryptedMessage ); > emitReplaceMsgByUnencryptedVersion = true; > } >@@ -1642,6 +1649,8 @@ > showHideMimeTree( rootNodeCntType == DwMime::kTypeText && > rootNodeCntSubtype == DwMime::kSubtypePlain ); > } >+ >+ aMsg->setIsBeingParsed( false ); > } > > >--- kmail/kmsearchpattern.cpp 2006/08/20 18:53:18 575078 >+++ kmail/kmsearchpattern.cpp 2007/03/28 14:44:39 647499 >@@ -762,7 +762,7 @@ > > bool opened = folder->isOpened(); > if ( !opened ) >- folder->open(); >+ folder->open("searchptr"); > KMMsgBase *msgBase = folder->getMsgBase(idx); > if (requiresBody() && !ignoreBody) { > bool unGet = !msgBase->isMessage(); >@@ -774,7 +774,7 @@ > res = matches( folder->getDwString(idx), ignoreBody ); > } > if ( !opened ) >- folder->close(); >+ folder->close("searchptr"); > return res; > } > >--- kmail/kmsender.cpp 2006/08/09 13:36:33 571372 >+++ kmail/kmsender.cpp 2007/03/28 14:44:39 647499 >@@ -161,8 +161,8 @@ > > if (sendNow==-1) sendNow = mSendImmediate; > >- kmkernel->outboxFolder()->open(); >- const KMFolderCloser openOutbox( kmkernel->outboxFolder() ); >+ kmkernel->outboxFolder()->open("outbox"); >+ const KMFolderCloser openOutbox( "outbox", kmkernel->outboxFolder() ); > > aMsg->setStatus(KMMsgStatusQueued); > >@@ -219,11 +219,11 @@ > > // open necessary folders > mOutboxFolder = kmkernel->outboxFolder(); >- mOutboxFolder->open(); >+ mOutboxFolder->open("dosendoutbox"); > mTotalMessages = mOutboxFolder->count(); > if (mTotalMessages == 0) { > // Nothing in the outbox. We are done. >- mOutboxFolder->close(); >+ mOutboxFolder->close("dosendoutbox"); > mOutboxFolder = 0; > return TRUE; > } >@@ -236,7 +236,7 @@ > mCurrentMsg = 0; > > mSentFolder = kmkernel->sentFolder(); >- mSentFolder->open(); >+ mSentFolder->open("dosendsent"); > kmkernel->filterMgr()->ref(); > > // start sending the messages >@@ -352,7 +352,7 @@ > sentFolder = kmkernel->sentFolder(); > > if ( sentFolder ) { >- if ( const int err = sentFolder->open() ) { >+ if ( const int err = sentFolder->open("sentFolder") ) { > Q_UNUSED( err ); > cleanup(); > return; >@@ -375,7 +375,7 @@ > "Moving failing message to \"sent-mail\" folder.")); > if ( sentFolder ) { > sentFolder->moveMsg(mCurrentMsg); >- sentFolder->close(); >+ sentFolder->close("sentFolder"); > } > cleanup(); > return; >@@ -446,7 +446,7 @@ > mCurrentMsg = 0; > // no more message: cleanup and done > if ( sentFolder != 0 ) >- sentFolder->close(); >+ sentFolder->close("sentFolder"); > if ( someSent ) { > if ( mSentMessages == mTotalMessages ) { > setStatusMsg(i18n("%n queued message successfully sent.", >@@ -605,7 +605,7 @@ > if ( messageIsDispositionNotificationReport( mCurrentMsg ) && GlobalSettings::self()->sendMDNsWithEmptySender() ) > sender = "<>"; > >- const QCString message = mCurrentMsg->asSendableString(); >+ const QByteArray message = mCurrentMsg->asSendableString(); > if ( sender.isEmpty() || !mSendProc->send( sender, to, cc, bcc, message ) ) { > if ( mCurrentMsg ) > mCurrentMsg->setTransferInProgress( false ); >@@ -636,13 +636,13 @@ > mCurrentMsg = 0; > } > if ( mSentFolder ) { >- mSentFolder->close(); >+ mSentFolder->close("dosendsent"); > mSentFolder = 0; > } > if ( mOutboxFolder ) { > disconnect( mOutboxFolder, SIGNAL(msgAdded(int)), > this, SLOT(outboxMsgAdded(int)) ); >- mOutboxFolder->close(); >+ mOutboxFolder->close("dosendoutbox"); > if ( mOutboxFolder->count( true ) == 0 ) { > mOutboxFolder->expunge(); > } >@@ -854,7 +854,7 @@ > int index = -1; > KMMsgDict::instance()->getLocation(msn, &folder, &index); > if (folder && index != -1) { >- folder->open(); >+ folder->open("setstatus"); > if ( status == KMMsgStatusDeleted ) { > // Move the message to the trash folder > KMDeleteMsgCommand *cmd = >@@ -863,7 +863,7 @@ > } else { > folder->setStatus(index, status); > } >- folder->close(); >+ folder->close("setstatus"); > } else { > kdWarning(5006) << k_funcinfo << "Cannot update linked message, it could not be found!" << endl; > } >@@ -963,7 +963,7 @@ > idle(); > } > >-bool KMSendSendmail::doSend( const QString & sender, const QStringList & to, const QStringList & cc, const QStringList & bcc, const QCString & message ) { >+bool KMSendSendmail::doSend( const QString & sender, const QStringList & to, const QStringList & cc, const QStringList & bcc, const QByteArray & message ) { > mMailerProc->clearArguments(); > *mMailerProc << mSender->transportInfo()->host > << "-i" << "-f" << sender >@@ -977,7 +977,7 @@ > return false; > } > mMsgPos = mMsgStr.data(); >- mMsgRest = mMsgStr.length(); >+ mMsgRest = mMsgStr.size(); > wroteStdin( mMailerProc ); > > return true; >@@ -1048,7 +1048,7 @@ > if (mJob) mJob->kill(); > } > >-bool KMSendSMTP::doSend( const QString & sender, const QStringList & to, const QStringList & cc, const QStringList & bcc, const QCString & message ) { >+bool KMSendSMTP::doSend( const QString & sender, const QStringList & to, const QStringList & cc, const QStringList & bcc, const QByteArray & message ) { > QString query = "headers=0&from="; > query += KURL::encode_string( sender ); > >@@ -1119,7 +1119,7 @@ > > // dotstuffing is now done by the slave (see setting of metadata) > mMessage = message; >- mMessageLength = mMessage.length(); >+ mMessageLength = mMessage.size(); > mMessageOffset = 0; > > if ( mMessageLength ) >--- kmail/kmstartup.cpp 2006/05/26 08:26:59 544826 >+++ kmail/kmstartup.cpp 2007/03/23 13:02:32 645708 >@@ -36,10 +36,12 @@ > > #include <errno.h> > #include <sys/types.h> >+#include <sys/param.h> > #include <signal.h> > #include <stdio.h> > #include <stdlib.h> > #include <unistd.h> >+#include <qfile.h> > > #undef Status // stupid X headers > >@@ -154,12 +156,34 @@ > bool first_instance = false; > if ( oldPid == -1 ) > first_instance = true; >- // check if the lock file is stale by trying to see if >- // the other pid is currently running. >- // Not 100% correct but better safe than sorry > else if (hostName == oldHostName && oldPid != getpid()) { >- if ( kill(oldPid, 0) == -1 ) >- first_instance = ( errno == ESRCH ); >+ // check if the lock file is stale >+#ifdef Q_OS_LINUX >+ if ( ::access("/proc", X_OK ) == 0 ) { >+ // On linux with /proc we can even check that it's really kmail and not something else >+ char path_buffer[MAXPATHLEN + 1]; >+ path_buffer[MAXPATHLEN] = 0; >+ const QString procPath = QString("/proc/%1/exe").arg(oldPid); >+ const int length = readlink (procPath.latin1(), path_buffer, MAXPATHLEN); >+ if ( length == -1 ) // not such pid >+ first_instance = true; >+ else { >+ path_buffer[length] = '\0'; >+ const QString path = QFile::decodeName(path_buffer); >+ kdDebug() << k_funcinfo << path << endl; >+ const int pos = path.findRev('/'); >+ const QString fileName = path.mid(pos+1); >+ kdDebug() << "Found process " << oldPid << " running. It's: " << fileName << endl; >+ first_instance = fileName != "kmail" && fileName != "kontact"; >+ } >+ } else >+#endif >+ { >+ // Otherwise we just check if the other pid is currently running. >+ // Not 100% correct but better safe than sorry. >+ if ( kill(oldPid, 0) == -1 ) >+ first_instance = ( errno == ESRCH ); >+ } > } > > if ( !first_instance ) { >--- kmail/kmtransport.cpp 2005/07/26 18:54:59 438982 >+++ kmail/kmtransport.cpp 2007/02/05 22:24:38 630633 >@@ -126,15 +126,15 @@ > if ( storePasswd() ) { > // write password into the wallet if possible and necessary > bool passwdStored = false; >+ Wallet *wallet = kmkernel->wallet(); > if ( mPasswdDirty ) { >- Wallet *wallet = kmkernel->wallet(); > if ( wallet && wallet->writePassword( "transport-" + QString::number(mId), passwd() ) == 0 ) { > passwdStored = true; > mPasswdDirty = false; > mStorePasswdInConfig = false; > } > } else { >- passwdStored = !mStorePasswdInConfig; // already in the wallet >+ passwdStored = wallet ? !mStorePasswdInConfig /*already in the wallet*/ : config->hasKey("pass"); > } > // wallet not available, ask the user if we should use the config file instead > if ( !passwdStored && ( mStorePasswdInConfig || KMessageBox::warningYesNo( 0, >--- kmail/messagecomposer.cpp 2006/08/10 20:01:05 571824 >+++ kmail/messagecomposer.cpp 2007/03/22 16:39:42 645446 >@@ -287,13 +287,14 @@ > > MessageComposer::MessageComposer( KMComposeWin* win, const char* name ) > : QObject( win, name ), mComposeWin( win ), mCurrentJob( 0 ), >- mKeyResolver( 0 ), mIdentityUid( 0 ) >+ mKeyResolver( 0 ), mIdentityUid( 0 ), mPerformingSignOperation( false ) > { > } > > MessageComposer::~MessageComposer() > { > delete mKeyResolver; mKeyResolver = 0; >+ delete mNewBodyPart; mNewBodyPart = 0; > } > > void MessageComposer::applyChanges( bool disableCrypto ) >@@ -338,7 +339,7 @@ > > if( mJobs.isEmpty() ) { > // No more jobs. Signal that we're done >- emit done( mRc ); >+ emitDone( mRc ); > return; > } > >@@ -348,7 +349,7 @@ > delete mJobs.front(); > mJobs.pop_front(); > } >- emit done( false ); >+ emitDone( false ); > return; > } > >@@ -356,6 +357,15 @@ > QTimer::singleShot( 0, this, SLOT( slotDoNextJob() ) ); > } > >+void MessageComposer::emitDone( bool b ) >+{ >+ // Save memory - before sending the mail >+ mEncodedBody = QByteArray(); >+ delete mNewBodyPart; mNewBodyPart = 0; >+ mOldBodyPart.clear(); >+ emit done( b ); >+} >+ > void MessageComposer::slotDoNextJob() > { > assert( !mCurrentJob ); >@@ -495,6 +505,7 @@ > mIsRichText = mComposeWin->mEditor->textFormat() == Qt::RichText; > mIdentityUid = mComposeWin->identityUid(); > mText = breakLinesAndApplyCodec(); >+ assert( mText.isEmpty() || mText[mText.size()-1] == '\n' ); > // Hopefully we can get rid of this eventually, it's needed to be able > // to break the plain/text version of a multipart/alternative (html) mail > // according to the line breaks of the richtext version. >@@ -1055,7 +1066,7 @@ > static inline const char * nestedContentType( Kleo::CryptoMessageFormat f, bool signing ) { > switch ( f ) { > case Kleo::OpenPGPMIMEFormat: >- return signing ? "application/pgp-signature" : "application/octet-stream" ; >+ return signing ? "application/pgp-signature; name=signature.asc \nContent-Description: This is a digitally signed message part." : "application/octet-stream" ; > case Kleo::SMIMEFormat: > if ( signing ) > return "application/pkcs7-signature; name=\"smime.p7s\""; >@@ -1115,18 +1126,18 @@ > class EncryptMessageJob : public MessageComposerJob { > public: > EncryptMessageJob( KMMessage* msg, const Kleo::KeyResolver::SplitInfo & si, >- bool doSign, bool doEncrypt, const QCString& encodedBody, >- int boundaryLevel, const KMMessagePart& oldBodyPart, >+ bool doSign, bool doEncrypt, const QByteArray& encodedBody, >+ int boundaryLevel, /*const KMMessagePart& oldBodyPart,*/ > KMMessagePart* newBodyPart, Kleo::CryptoMessageFormat format, > MessageComposer* composer ) > : MessageComposerJob( composer ), mMsg( msg ), mSplitInfo( si ), > mDoSign( doSign ), mDoEncrypt( doEncrypt ), mEncodedBody( encodedBody ), >- mBoundaryLevel( boundaryLevel ), mOldBodyPart( oldBodyPart ), >+ mBoundaryLevel( boundaryLevel ), /*mOldBodyPart( oldBodyPart ),*/ > mNewBodyPart( newBodyPart ), mFormat( format ) {} > > void execute() { > KMMessagePart tmpNewBodyPart; >- tmpNewBodyPart.duplicate( *mNewBodyPart ); >+ tmpNewBodyPart.duplicate( *mNewBodyPart ); // slow - we duplicate everything again > > // TODO: Async call > >@@ -1143,9 +1154,9 @@ > KMMessage* mMsg; > Kleo::KeyResolver::SplitInfo mSplitInfo; > bool mDoSign, mDoEncrypt; >- QCString mEncodedBody; >+ QByteArray mEncodedBody; > int mBoundaryLevel; >- KMMessagePart mOldBodyPart; >+ //KMMessagePart mOldBodyPart; > KMMessagePart* mNewBodyPart; > Kleo::CryptoMessageFormat mFormat; > }; >@@ -1162,38 +1173,12 @@ > } > }; > >-QCString MessageComposer::bodyText() >-{ >- QCString body = mText; >- >- if (body.isNull()) return body; >- >- if (body.isEmpty()) body = "\n"; // don't crash >- >- // From RFC 3156: >- // Note: The accepted OpenPGP convention is for signed data to end >- // with a <CR><LF> sequence. Note that the <CR><LF> sequence >- // immediately preceding a MIME boundary delimiter line is considered >- // to be part of the delimiter in [3], 5.1. Thus, it is not part of >- // the signed data preceding the delimiter line. An implementation >- // which elects to adhere to the OpenPGP convention has to make sure >- // it inserts a <CR><LF> pair on the last line of the data to be >- // signed and transmitted (signed message and transmitted message >- // MUST be identical). >- // So make sure that the body ends with a <LF>. >- if( body[body.length()-1] != '\n' ) { >- kdDebug(5006) << "Added an <LF> on the last line" << endl; >- body += "\n"; >- } >- return body; >-} >- > void MessageComposer::composeInlineOpenPGPMessage( KMMessage& theMessage, > bool doSign, bool doEncrypt ) > { > // preprocess the body text >- QCString body = bodyText(); >- if (body.isNull()) { >+ const QByteArray bodyData = mText; >+ if (bodyData.isNull()) { > mRc = false; > return; > } >@@ -1222,10 +1207,10 @@ > QByteArray encryptedBody; > if ( doSign ) { // Sign and encrypt > const std::vector<GpgME::Key> signingKeys = mKeyResolver->signingKeys( Kleo::InlineOpenPGPFormat ); >- result = pgpSignedAndEncryptedMsg( encryptedBody, body, signingKeys, >+ result = pgpSignedAndEncryptedMsg( encryptedBody, bodyData, signingKeys, > splitInfo.keys, Kleo::InlineOpenPGPFormat ); > } else { // Encrypt but don't sign >- result = pgpEncryptedMsg( encryptedBody, body, >+ result = pgpEncryptedMsg( encryptedBody, bodyData, > splitInfo.keys, Kleo::InlineOpenPGPFormat ); > } > if ( result != Kpgp::Ok ) { >@@ -1236,15 +1221,15 @@ > mOldBodyPart.setBodyEncodedBinary( encryptedBody ); > } else { > if ( doSign ) { // Sign but don't encrypt >- pgpSignedMsg( body, Kleo::InlineOpenPGPFormat ); >+ pgpSignedMsg( bodyData, Kleo::InlineOpenPGPFormat ); > if ( mSignature.isNull() ) { > mRc = false; > return; > } > mOldBodyPart.setBodyEncodedBinary( mSignature ); > } else { // don't sign nor encrypt -> nothing to do >- assert( !body.isNull() ); >- mOldBodyPart.setBodyEncoded( body ); >+ assert( !bodyData.isNull() ); >+ mOldBodyPart.setBodyEncodedBinary( bodyData ); > } > } > mOldBodyPart.setContentDisposition( "inline" ); >@@ -1254,7 +1239,7 @@ > mMessageList.push_back( msg ); > if ( it == splitInfos.begin() ) { > if ( doEncrypt && !saveMessagesEncrypted() ) { >- mOldBodyPart.setBodyEncoded( body ); >+ mOldBodyPart.setBodyEncodedBinary( bodyData ); > KMMessage* msgUnenc = new KMMessage( theMessage ); > addBodyAndAttachments( msgUnenc, splitInfo, false, false, mOldBodyPart, Kleo::InlineOpenPGPFormat ); > msg->setUnencryptedMsg( msgUnenc ); >@@ -1274,8 +1259,8 @@ > assert( chiasmus ); // kmcomposewin code should have made sure > > // preprocess the body text >- QCString body = bodyText(); >- if (body.isNull()) { >+ const QByteArray bodyData = mText; >+ if (bodyData.isNull()) { > mRc = false; > return; > } >@@ -1290,9 +1275,6 @@ > theMessage.removeHeaderField("Content-Type"); > theMessage.removeHeaderField("Content-Transfer-Encoding"); > >- QByteArray plainText; >- plainText.duplicate( body.data(), body.length() ); // hrmpf... >- > // This reads strange, but we know that AdjustCryptFlagsJob created a single splitinfo, > // under the given "format" (usually openpgp/mime; doesn't matter) > const std::vector<Kleo::KeyResolver::SplitInfo> splitInfos >@@ -1304,7 +1286,7 @@ > KMMessage* msg = new KMMessage( theMessage ); > QByteArray encryptedBody; > >- if ( !encryptWithChiasmus( chiasmus, plainText, encryptedBody ) ) { >+ if ( !encryptWithChiasmus( chiasmus, bodyData, encryptedBody ) ) { > mRc = false; > return; > } >@@ -1330,7 +1312,7 @@ > mMessageList.push_back( msg ); > > if ( it == splitInfos.begin() && !saveMessagesEncrypted() ) { >- mOldBodyPart.setBodyEncoded( body ); >+ mOldBodyPart.setBodyEncodedBinary( bodyData ); > KMMessage* msgUnenc = new KMMessage( theMessage ); > addBodyAndAttachments( msgUnenc, splitInfo, false, false, mOldBodyPart, Kleo::InlineOpenPGPFormat ); > msg->setUnencryptedMsg( msgUnenc ); >@@ -1361,8 +1343,8 @@ > theMessage.setBody( "This message is in MIME format." ); > > // preprocess the body text >- QCString body = bodyText(); >- if (body.isNull()) { >+ QByteArray bodyData = mText; >+ if (bodyData.isNull()) { > mRc = false; > return; > } >@@ -1430,14 +1412,14 @@ > QCString newbody; > DwMediaType tmpCT; > tmpCT.CreateBoundary( ++mPreviousBoundaryLevel ); >- boundaryCStr = tmpCT.Boundary().c_str(); >+ boundaryCStr = KMail::Util::CString( tmpCT.Boundary() ); > QValueList<int> allowedCTEs; > > KMMessagePart textBodyPart; > textBodyPart.setTypeStr("text"); > textBodyPart.setSubtypeStr("plain"); > >- QCString textbody = plainTextFromMarkup( mText ); >+ QCString textbody = plainTextFromMarkup( mText /* converted to QString */ ); > > // the signed body must not be 8bit encoded > textBodyPart.setBodyAndGuessCte( textbody, allowedCTEs, >@@ -1457,13 +1439,13 @@ > KMMessagePart htmlBodyPart; > htmlBodyPart.setTypeStr("text"); > htmlBodyPart.setSubtypeStr("html"); >- QCString htmlbody = mText; >+ QByteArray htmlbody = mText; > // the signed body must not be 8bit encoded > htmlBodyPart.setBodyAndGuessCte( htmlbody, allowedCTEs, > !kmkernel->msgSender()->sendQuotedPrintable() && !doSign, > doSign ); > htmlBodyPart.setCharset( mCharset ); >- htmlBodyPart.setBodyEncoded( htmlbody ); >+ htmlBodyPart.setBodyEncodedBinary( htmlbody ); > DwBodyPart* htmlDwPart = theMessage.createDWBodyPart( &htmlBodyPart ); > htmlDwPart->Assemble(); > newbody += "\n--"; >@@ -1476,8 +1458,8 @@ > newbody += "--"; > newbody += boundaryCStr; > newbody += "--\n"; >- body = newbody; >- mOldBodyPart.setBodyEncoded( newbody ); >+ bodyData = KMail::Util::byteArrayFromQCStringNoDetach( newbody ); >+ mOldBodyPart.setBodyEncodedBinary( bodyData ); > > mSaveBoundary = tmpCT.Boundary(); > } >@@ -1493,7 +1475,7 @@ > // eventually get rid of this: > if( it->sign || it->encrypt ) { > QCString cte = it->part->cteStr().lower(); >- if( ( "8bit" == cte ) >+ if( ( "8bit" == cte && it->part->type() != DwMime::kTypeMessage ) > || ( ( it->part->type() == DwMime::kTypeText ) > && ( "7bit" == cte ) ) ) { > const QByteArray body = it->part->bodyDecodedBinary(); >@@ -1518,28 +1500,30 @@ > innerBodyPart.setContentDisposition( "inline" ); > QValueList<int> allowedCTEs; > // the signed body must not be 8bit encoded >- innerBodyPart.setBodyAndGuessCte( body, allowedCTEs, >+ innerBodyPart.setBodyAndGuessCte( bodyData, allowedCTEs, > !kmkernel->msgSender()->sendQuotedPrintable() && !doSign, > doSign ); > if ( !mIsRichText ) > innerBodyPart.setCharset( mCharset ); >- innerBodyPart.setBodyEncoded( body ); // do we need this, since setBodyAndGuessCte does this already? >+ innerBodyPart.setBodyEncodedBinary( bodyData ); // do we need this, since setBodyAndGuessCte does this already? > DwBodyPart* innerDwPart = theMessage.createDWBodyPart( &innerBodyPart ); > innerDwPart->Assemble(); >+ QByteArray tmpbody = KMail::Util::ByteArray( innerDwPart->AsString() ); > if ( mIsRichText ) { // and add our mp/a boundary >- QCString tmpbody = innerDwPart->AsString().c_str(); > int boundPos = tmpbody.find( '\n' ); > if( -1 < boundPos ) { > QCString bStr( ";\n boundary=\"" ); > bStr += mSaveBoundary.c_str(); > bStr += "\""; >- body = innerDwPart->AsString().c_str(); >- body.insert( boundPos, bStr ); >- body = "--" + mMultipartMixedBoundary + "\n" + body; >+ bodyData = tmpbody; >+ KMail::Util::insert( bodyData, boundPos, bStr ); >+ KMail::Util::insert( bodyData, 0, "--" + mMultipartMixedBoundary + "\n" ); // prepend > } > } >- else >- body = "--" + mMultipartMixedBoundary + "\n" + innerDwPart->AsString().c_str(); >+ else { >+ bodyData = tmpbody; >+ KMail::Util::insert( bodyData, 0, "--" + mMultipartMixedBoundary + "\n" ); // prepend >+ } > delete innerDwPart; > innerDwPart = 0; > // add all matching Attachments >@@ -1548,22 +1532,23 @@ > if ( it->encrypt == doEncryptBody && it->sign == doSignBody ) { > innerDwPart = theMessage.createDWBodyPart( it->part ); > innerDwPart->Assemble(); >- body += "\n--" + mMultipartMixedBoundary + "\n" + innerDwPart->AsString().c_str(); >+ KMail::Util::append( bodyData, QCString( "\n--" + mMultipartMixedBoundary + "\n" ) ); >+ KMail::Util::append( bodyData, innerDwPart->AsString().c_str() ); > delete innerDwPart; > innerDwPart = 0; > } > } >- body += "\n--" + mMultipartMixedBoundary + "--\n"; >+ KMail::Util::append( bodyData, QCString( "\n--" + mMultipartMixedBoundary + "--\n" ) ); > } else { // !earlyAddAttachments > QValueList<int> allowedCTEs; > // the signed body must not be 8bit encoded >- mOldBodyPart.setBodyAndGuessCte(body, allowedCTEs, !kmkernel->msgSender()->sendQuotedPrintable() && !doSign, >+ mOldBodyPart.setBodyAndGuessCte(bodyData, allowedCTEs, !kmkernel->msgSender()->sendQuotedPrintable() && !doSign, > doSign); > if ( !mIsRichText ) > mOldBodyPart.setCharset(mCharset); > } > // create S/MIME body part for signing and/or encrypting >- mOldBodyPart.setBodyEncoded( body ); >+ mOldBodyPart.setBodyEncodedBinary( bodyData ); > > if( doSignBody || doEncryptBody ) { > // get string representation of body part (including the attachments) >@@ -1577,13 +1562,12 @@ > DwMediaType& ct = headers.ContentType(); > ct.SetBoundary(mSaveBoundary); > dwPart->Assemble(); >- mEncodedBody = dwPart->AsString().c_str(); > } > else { > dwPart = theMessage.createDWBodyPart( &mOldBodyPart ); > dwPart->Assemble(); >- mEncodedBody = dwPart->AsString().c_str(); > } >+ mEncodedBody = KMail::Util::ByteArray( dwPart->AsString() ); > delete dwPart; > dwPart = 0; > >@@ -1595,7 +1579,7 @@ > QCString bStr( ";\n boundary=\"" ); > bStr += mMultipartMixedBoundary; > bStr += "\""; >- mEncodedBody.insert( boundPos, bStr ); >+ KMail::Util::insert( mEncodedBody, boundPos, bStr.data() ); > } > } > >@@ -1606,8 +1590,10 @@ > } > > if ( doSignBody ) { >+ mPerformingSignOperation = true; // this lets the KMComposeWin know if it is safe to close the window. > pgpSignedMsg( mEncodedBody, format ); >- >+ mPerformingSignOperation = false; >+ > if ( mSignature.isEmpty() ) { > kdDebug() << "signature was empty" << endl; > mRc = false; >@@ -1655,7 +1641,7 @@ > Kleo::KeyResolver::SplitInfo( splitInfos.front().recipients ), doSign, > false, mEncodedBody, > mPreviousBoundaryLevel, >- mOldBodyPart, mNewBodyPart, >+ /*mOldBodyPart,*/ mNewBodyPart, > format, this ) ); > } > >@@ -1663,7 +1649,7 @@ > mJobs.push_front( new EncryptMessageJob( new KMMessage( theMessage ), *it, doSign, > doEncrypt, mEncodedBody, > mPreviousBoundaryLevel, >- mOldBodyPart, mNewBodyPart, >+ /*mOldBodyPart,*/ mNewBodyPart, > format, this ) ); > } > >@@ -1684,16 +1670,17 @@ > const bool doSignBody = doSign && mSignBody; > > if ( doEncryptBody ) { >- QCString innerContent; >+ QByteArray innerContent; > if ( doSignBody ) { > // extract signed body from newBodyPart > DwBodyPart* dwPart = msg->createDWBodyPart( &newBodyPart ); > dwPart->Assemble(); >- innerContent = dwPart->AsString().c_str(); >+ innerContent = KMail::Util::ByteArray( dwPart->AsString() ); > delete dwPart; > dwPart = 0; >- } else >+ } else { > innerContent = mEncodedBody; >+ } > > // now do the encrypting: > // replace simple LFs by CRLFs for all MIME supporting CryptPlugs >@@ -1784,7 +1771,7 @@ > > DwBodyPart* innerDwPart = msg->createDWBodyPart( it->part ); > innerDwPart->Assemble(); >- QCString encodedAttachment = innerDwPart->AsString().c_str(); >+ QByteArray encodedAttachment = KMail::Util::ByteArray( innerDwPart->AsString() ); > delete innerDwPart; > innerDwPart = 0; > >@@ -1795,10 +1782,8 @@ > > // sign this attachment > if( signThisNow ) { >- > pgpSignedMsg( encodedAttachment, format ); >- QByteArray signature = mSignature; >- mRc = !signature.isEmpty(); >+ mRc = !mSignature.isEmpty(); > if( mRc ) { > mRc = processStructuringInfo( "http://www.gnupg.org/aegypten/", > it->part->contentDescription(), >@@ -1808,14 +1793,14 @@ > it->part->contentTransferEncodingStr(), > encodedAttachment, > "signature", >- signature, >+ mSignature, > newAttachPart, true, format ); > if( mRc ) { > if( encryptThisNow ) { > rEncryptMessagePart = newAttachPart; > DwBodyPart* dwPart = msg->createDWBodyPart( &newAttachPart ); > dwPart->Assemble(); >- encodedAttachment = dwPart->AsString().c_str(); >+ encodedAttachment = KMail::Util::ByteArray( dwPart->AsString() ); > delete dwPart; > dwPart = 0; > } >@@ -1880,7 +1865,7 @@ > kdDebug(5006) << "MessageComposer::addBodyAndAttachments() : top level headers and body adjusted" << endl; > > // set body content >- msg->setBody(ourFineBodyPart.body() ); >+ msg->setBody( ourFineBodyPart.dwBody() ); > > } > >@@ -1902,12 +1887,13 @@ > const QCString contentSubtypeClear, > const QCString contentDispClear, > const QCString contentTEncClear, >- const QCString& clearCStr, >+ const QByteArray& clearCStr, > const QString /*contentDescCiph*/, > const QByteArray& ciphertext, > KMMessagePart& resultingPart, > bool signing, Kleo::CryptoMessageFormat format ) > { >+ assert( clearCStr.isEmpty() || clearCStr[clearCStr.size()-1] != '\0' ); // I was called with a QCString !? > bool bOk = true; > > if ( makeMimeObject( format, signing ) ) { >@@ -1955,12 +1941,13 @@ > KMMessage::bodyPart( &mainDwPa, &resultingPart ); > if( !makeMultiMime( format, signing ) ) { > if ( signing && includeCleartextWhenSigning( format ) ) { >- QCString bodyText( clearCStr ); >- bodyText += '\n'; >- bodyText += QCString( ciphertext.data(), ciphertext.size() + 1 ); >- resultingPart.setBodyEncoded( bodyText ); >- } else >+ QByteArray bodyText( clearCStr ); >+ KMail::Util::append( bodyText, "\n" ); >+ KMail::Util::append( bodyText, ciphertext ); >+ resultingPart.setBodyEncodedBinary( bodyText ); >+ } else { > resultingPart.setBodyEncodedBinary( ciphertext ); >+ } > } else { > // Build the encapsulated MIME parts. > // Build a MIME part holding the version information >@@ -1993,18 +1980,24 @@ > codeCStr += '\n' + QCString( ciphertext.data(), ciphertext.size() + 1 ); > > >- QCString mainStr = "--" + boundaryCStr; >+ QByteArray mainStr; >+ KMail::Util::append( mainStr, "--" ); >+ KMail::Util::append( mainStr, boundaryCStr ); > if ( signing && includeCleartextWhenSigning( format ) && >- !clearCStr.isEmpty() ) >- mainStr += "\n" + clearCStr + "\n--" + boundaryCStr; >+ !clearCStr.isEmpty() ) { >+ KMail::Util::append( mainStr, "\n" ); >+ // clearCStr is the one that can be very big for large attachments, don't merge with the other lines >+ KMail::Util::append( mainStr, clearCStr ); >+ KMail::Util::append( mainStr, "\n--" + boundaryCStr ); >+ } > if ( !versCStr.isEmpty() ) >- mainStr += "\n" + versCStr + "\n--" + boundaryCStr; >+ KMail::Util::append( mainStr, "\n" + versCStr + "\n--" + boundaryCStr ); > if( !codeCStr.isEmpty() ) >- mainStr += "\n" + codeCStr + "\n--" + boundaryCStr; >- mainStr += "--\n"; >+ KMail::Util::append( mainStr, "\n" + codeCStr + "\n--" + boundaryCStr ); >+ KMail::Util::append( mainStr, "--\n" ); > > //kdDebug(5006) << "processStructuringInfo: mainStr=" << mainStr << endl; >- resultingPart.setBodyEncoded( mainStr ); >+ resultingPart.setBodyEncodedBinary( mainStr ); > } > > } else { // not making a mime object, build a plain message body. >@@ -2014,14 +2007,14 @@ > resultingPart.setSubtypeStr( contentSubtypeClear ); > resultingPart.setContentDisposition( contentDispClear ); > resultingPart.setContentTransferEncodingStr( contentTEncClear ); >- QCString resultingBody; >+ QByteArray resultingBody; > > if ( signing && includeCleartextWhenSigning( format ) ) { > if( !clearCStr.isEmpty() ) >- resultingBody += clearCStr; >+ KMail::Util::append( resultingBody, clearCStr ); > } > if ( !ciphertext.isEmpty() ) >- resultingBody += QCString( ciphertext.data(), ciphertext.size() + 1 ); // null-terminate >+ KMail::Util::append( resultingBody, ciphertext ); > else { > // Plugin error! > KMessageBox::sorry( mComposeWin, >@@ -2031,7 +2024,7 @@ > .arg( bugURL ) ); > bOk = false; > } >- resultingPart.setBodyEncoded( resultingBody ); >+ resultingPart.setBodyEncodedBinary( resultingBody ); > } > > return bOk; >@@ -2065,7 +2058,7 @@ > } > > //----------------------------------------------------------------------------- >-QCString MessageComposer::breakLinesAndApplyCodec() >+QByteArray MessageComposer::breakLinesAndApplyCodec() > { > QString text; > QCString cText; >@@ -2103,17 +2096,33 @@ > i18n("Lose Characters"), i18n("Change Encoding") ) == KMessageBox::Yes ); > if( !anyway ) { > mComposeWin->mEditor->setText(oldText); >- return QCString(); >+ return QByteArray(); > } > } > >- return cText; >+ // From RFC 3156: >+ // Note: The accepted OpenPGP convention is for signed data to end >+ // with a <CR><LF> sequence. Note that the <CR><LF> sequence >+ // immediately preceding a MIME boundary delimiter line is considered >+ // to be part of the delimiter in [3], 5.1. Thus, it is not part of >+ // the signed data preceding the delimiter line. An implementation >+ // which elects to adhere to the OpenPGP convention has to make sure >+ // it inserts a <CR><LF> pair on the last line of the data to be >+ // signed and transmitted (signed message and transmitted message >+ // MUST be identical). >+ // So make sure that the body ends with a <LF>. >+ if( cText.isEmpty() || cText[cText.length()-1] != '\n' ) { >+ kdDebug(5006) << "Added an <LF> on the last line" << endl; >+ cText += "\n"; >+ } >+ return KMail::Util::byteArrayFromQCStringNoDetach( cText ); > } > > > //----------------------------------------------------------------------------- >-void MessageComposer::pgpSignedMsg( const QCString & cText, Kleo::CryptoMessageFormat format ) { >+void MessageComposer::pgpSignedMsg( const QByteArray& cText, Kleo::CryptoMessageFormat format ) { > >+ assert( cText.isEmpty() || cText[cText.size()-1] != '\0' ); // I was called with a QCString !? > mSignature = QByteArray(); > > const std::vector<GpgME::Key> signingKeys = mKeyResolver->signingKeys( format ); >@@ -2139,11 +2148,9 @@ > return; > } > >- QByteArray plainText; >- plainText.duplicate( cText.data(), cText.length() ); // hrmpf... > QByteArray signature; > const GpgME::SigningResult res = >- job->exec( signingKeys, plainText, signingMode( format ), signature ); >+ job->exec( signingKeys, cText, signingMode( format ), signature ); > if ( res.error().isCanceled() ) { > kdDebug() << "signing was canceled by user" << endl; > return; >@@ -2165,7 +2172,7 @@ > > //----------------------------------------------------------------------------- > Kpgp::Result MessageComposer::pgpEncryptedMsg( QByteArray & encryptedBody, >- const QCString & cText, >+ const QByteArray& cText, > const std::vector<GpgME::Key> & encryptionKeys, > Kleo::CryptoMessageFormat format ) > { >@@ -2187,11 +2194,8 @@ > return Kpgp::Failure; > } > >- QByteArray plainText; >- plainText.duplicate( cText.data(), cText.length() ); // hrmpf... >- > const GpgME::EncryptionResult res = >- job->exec( encryptionKeys, plainText, false, encryptedBody ); >+ job->exec( encryptionKeys, cText, false, encryptedBody ); > if ( res.error().isCanceled() ) { > kdDebug() << "encryption was canceled by user" << endl; > return Kpgp::Canceled; >@@ -2205,7 +2209,7 @@ > } > > Kpgp::Result MessageComposer::pgpSignedAndEncryptedMsg( QByteArray & encryptedBody, >- const QCString & cText, >+ const QByteArray& cText, > const std::vector<GpgME::Key> & signingKeys, > const std::vector<GpgME::Key> & encryptionKeys, > Kleo::CryptoMessageFormat format ) >@@ -2228,11 +2232,8 @@ > return Kpgp::Failure; > } > >- QByteArray plainText; >- plainText.duplicate( cText.data(), cText.length() ); // hrmpf... >- > const std::pair<GpgME::SigningResult,GpgME::EncryptionResult> res = >- job->exec( signingKeys, encryptionKeys, plainText, false, encryptedBody ); >+ job->exec( signingKeys, encryptionKeys, cText, false, encryptedBody ); > if ( res.first.error().isCanceled() || res.second.error().isCanceled() ) { > kdDebug() << "encrypt/sign was canceled by user" << endl; > return Kpgp::Canceled; >--- kmail/messagecomposer.h 2006/06/23 22:52:07 554389 >+++ kmail/messagecomposer.h 2007/03/22 16:39:42 645446 >@@ -92,6 +92,7 @@ > return mMessageList; > } > >+ bool isPerformingSignOperation() const { return mPerformingSignOperation; } > signals: > void done( bool ); > >@@ -135,9 +136,7 @@ > * Get message ready for sending or saving. > * This must be done _before_ signing and/or encrypting it. > */ >- QCString breakLinesAndApplyCodec(); >- /// Same as above but ensure \n termination >- QCString bodyText(); >+ QByteArray breakLinesAndApplyCodec(); > > /** > * Create a plain text version of a marked up mail for use as the plain >@@ -149,13 +148,13 @@ > * Get signature for a message (into mMessage). > * To build nice S/MIME objects signing and encoding must be separated. > */ >- void pgpSignedMsg( const QCString & cText, Kleo::CryptoMessageFormat f ); >+ void pgpSignedMsg( const QByteArray& cText, Kleo::CryptoMessageFormat f ); > /** > * Get encrypted message. > * To build nice S/MIME objects signing and encrypting must be separate. > */ > Kpgp::Result pgpEncryptedMsg( QByteArray& rEncryptedBody, >- const QCString & cText, >+ const QByteArray& cText, > const std::vector<GpgME::Key> & encryptionKeys, > Kleo::CryptoMessageFormat f ); > >@@ -164,7 +163,7 @@ > * To build nice S/MIME objects signing and encrypting must be separate. > */ > Kpgp::Result pgpSignedAndEncryptedMsg( QByteArray& rEncryptedBody, >- const QCString & cText, >+ const QByteArray& cText, > const std::vector<GpgME::Key> & signingKeys, > const std::vector<GpgME::Key> & encryptionKeys, > Kleo::CryptoMessageFormat f ); >@@ -192,7 +191,7 @@ > const QCString contentSubtypeClear, > const QCString contentDispClear, > const QCString contentTEncClear, >- const QCString& bodytext, >+ const QByteArray& bodytext, > const QString contentDescriptionCiph, > const QByteArray& ciphertext, > KMMessagePart& resultingPart, >@@ -213,6 +212,7 @@ > > private: > void doNextJob(); >+ void emitDone( bool ok ); > > int encryptionPossible( const QStringList & recipients, bool openPGP ); > bool determineWhetherToSign( bool doSignCompletely ); >@@ -256,14 +256,14 @@ > bool mRc; // Set this to false, if something fails during the processes > bool mHoldJobs; // Don't run the next job yet > >- QCString mText; // textual representation of the message text, encoded >+ QByteArray mText; // textual representation of the message text, encoded > unsigned int mLineBreakColumn; // used for line breaking > > // These are the variables of the big composeMessage(X,Y,Z) message > KMMessagePart* mNewBodyPart; > QByteArray mSignature; > >- QCString mEncodedBody; // Only needed if signing and/or encrypting >+ QByteArray mEncodedBody; // Only needed if signing and/or encrypting > bool mEarlyAddAttachments, mAllAttachmentsAreInBody; > KMMessagePart mOldBodyPart; > int mPreviousBoundaryLevel; >@@ -274,6 +274,7 @@ > > QValueList<MessageComposerJob*> mJobs; > bool mEncryptWithChiasmus; >+ bool mPerformingSignOperation; > }; > > #endif /* MESSAGECOMPOSER_H */ >--- kmail/objecttreeparser.cpp 2006/11/26 19:31:12 608103 >+++ kmail/objecttreeparser.cpp 2007/02/15 22:58:16 633978 >@@ -401,7 +401,7 @@ > > if ( doCheck && cryptPlug ) { > if ( data ) { >- cleartext = data->dwPart()->AsString().c_str(); >+ cleartext = KMail::Util::CString( data->dwPart()->AsString() ); > > dumpToFile( "dat_01_reader_signedtext_before_canonicalization", > cleartext.data(), cleartext.length() ); >@@ -970,9 +970,8 @@ > } > > bool ObjectTreeParser::processTextPlainSubtype( partNode * curNode, ProcessResult & result ) { >- const QCString cstr = curNode->msgPart().bodyDecoded(); > if ( !mReader ) { >- mRawReplyString = cstr; >+ mRawReplyString = curNode->msgPart().bodyDecoded(); > if ( curNode->isFirstTextPart() ) { > mTextualContent += curNode->msgPart().bodyToUnicode(); > mTextualContentCharset = curNode->msgPart().charset(); >@@ -980,13 +979,12 @@ > return true; > } > >- //resultingRawData += cstr; > if ( !curNode->isFirstTextPart() && > attachmentStrategy()->defaultDisplay( curNode ) != AttachmentStrategy::Inline && > !showOnlyOneMimePart() ) > return false; > >- mRawReplyString = cstr; >+ mRawReplyString = curNode->msgPart().bodyDecoded(); > if ( curNode->isFirstTextPart() ) { > mTextualContent += curNode->msgPart().bodyToUnicode(); > mTextualContentCharset = curNode->msgPart().charset(); >@@ -1029,7 +1027,7 @@ > // enable verification of the embedded messages' signatures > if ( !isMailmanMessage( curNode ) || > !processMailmanMessage( curNode ) ) >- writeBodyString( cstr, curNode->trueFromAddress(), >+ writeBodyString( mRawReplyString, curNode->trueFromAddress(), > codecFor( curNode ), result, !bDrawFrame ); > if ( bDrawFrame ) > htmlWriter()->queue( "</td></tr></table>" ); >--- kmail/partNode.cpp 2006/01/12 19:30:43 497436 >+++ kmail/partNode.cpp 2007/02/15 10:54:03 633777 >@@ -37,6 +37,7 @@ > #include <mimelib/utility.h> > #include <qregexp.h> > #include <kasciistricmp.h> >+#include "util.h" > > /* > =========================================================================== >@@ -179,7 +180,7 @@ > return mEncodedBody; > > if ( mDwPart ) >- mEncodedBody = mDwPart->Body().AsString().c_str(); >+ mEncodedBody = KMail::Util::CString( mDwPart->Body().AsString() ); > else > mEncodedBody = 0; > mEncodedOk = true; >--- kmail/recipientseditor.cpp 2006/11/25 20:10:16 607798 >+++ kmail/recipientseditor.cpp 2007/03/09 17:06:16 640993 >@@ -318,8 +318,9 @@ > // ------------ RecipientsView --------------------- > > RecipientsView::RecipientsView( QWidget *parent ) >- : QScrollView( parent ), mCurDelLine( 0 ), mModified( false ), >- mFirstColumnWidth( 0 ), mLineHeight( 0 ) >+ : QScrollView( parent ), mCurDelLine( 0 ), >+ mLineHeight( 0 ), mFirstColumnWidth( 0 ), >+ mModified( false ) > { > mCompletionMode = KGlobalSettings::completionMode(); > setHScrollBarMode( AlwaysOff ); >--- kmail/renamejob.cpp 2006/06/18 08:54:31 552548 >+++ kmail/renamejob.cpp 2007/03/28 14:44:39 647499 >@@ -228,7 +228,7 @@ > // move all messages to the new folder > QPtrList<KMMsgBase> msgList; > if ( !mStorage->isOpened() ) >- mStorageTempOpened = mStorage->open() ? mStorage : 0; >+ mStorageTempOpened = mStorage->open("renamejob") ? mStorage : 0; > for ( int i = 0; i < mStorage->count(); i++ ) > { > KMMsgBase* msgBase = mStorage->getMsgBase( i ); >@@ -251,7 +251,7 @@ > { > kdDebug(5006) << k_funcinfo << (command?command->result():0) << endl; > if ( mStorageTempOpened ) { >- mStorageTempOpened->close(); >+ mStorageTempOpened->close("renamejob"); > mStorageTempOpened = 0; > } > if ( command ) { >--- kmail/searchjob.cpp 2006/06/17 22:01:59 552469 >+++ kmail/searchjob.cpp 2007/03/22 12:54:32 645363 >@@ -222,7 +222,12 @@ > for ( QStringList::Iterator it = mImapSearchHits.begin(); > it != mImapSearchHits.end(); ++it ) > { >- serNums.append( mFolder->serNumForUID( (*it).toULong() ) ); >+ ulong serNum = mFolder->serNumForUID( (*it).toULong() ); >+ // we need to check that the local folder does contain a message for this UID. >+ // scenario: server responds with a list of UIDs. While the search was running, filtering or bad juju moved a message locally >+ // serNumForUID will happily return 0 for the missing message, and KMFolderSearch::addSerNum() will fail its assertion. >+ if ( serNum != 0 ) >+ serNums.append( serNum ); > } > emit searchDone( serNums, mSearchPattern, true ); > } else { >--- kmail/searchwindow.cpp 2006/08/29 17:58:11 578592 >+++ kmail/searchwindow.cpp 2007/03/28 14:44:39 647499 >@@ -313,7 +313,7 @@ > for ( fit = mFolders.begin(); fit != mFolders.end(); ++fit ) { > if (!(*fit)) > continue; >- (*fit)->close(); >+ (*fit)->close("searchwindow"); > } > > KConfig* config = KMKernel::config(); >@@ -470,7 +470,7 @@ > enableGUI(); > > if (mFolder && !mFolders.contains(mFolder.operator->()->folder())) { >- mFolder->open(); >+ mFolder->open("searchwindow"); > mFolders.append(mFolder.operator->()->folder()); > } > mTimer->start(200); >@@ -502,7 +502,7 @@ > KMFolder *pFolder = msg->parent(); > if (!mFolders.contains(pFolder)) { > mFolders.append(pFolder); >- pFolder->open(); >+ pFolder->open("searchwindow"); > } > if(pFolder->whoField() == "To") > from = msg->to(); >--- kmail/undostack.cpp 2005/07/26 18:54:59 438982 >+++ kmail/undostack.cpp 2007/03/28 14:44:39 647499 >@@ -88,7 +88,7 @@ > UndoInfo *info = mStack.take(0); > emit undoStackChanged(); > QValueList<ulong>::iterator itr; >- info->destFolder->open(); >+ info->destFolder->open("undodest"); > for( itr = info->serNums.begin(); itr != info->serNums.end(); ++itr ) { > serNum = *itr; > KMMsgDict::instance()->getLocation(serNum, &curFolder, &idx); >@@ -102,7 +102,7 @@ > if ( info->srcFolder->count() > 1 ) > info->srcFolder->unGetMsg( info->srcFolder->count() - 1 ); > } >- info->destFolder->close(); >+ info->destFolder->close("undodest"); > delete info; > } > else >--- kmail/util.cpp 2005/07/26 18:54:59 438982 >+++ kmail/util.cpp 2007/02/15 10:54:03 633777 >@@ -39,6 +39,7 @@ > > #include <stdlib.h> > #include <qcstring.h> >+#include <mimelib/string.h> > > size_t KMail::Util::crlf2lf( char* str, const size_t strLen ) > { >@@ -72,7 +73,7 @@ > > QCString KMail::Util::lf2crlf( const QCString & src ) > { >- QCString result( 1 + 2*src.length() ); // maximal possible length >+ QCString result( 1 + 2*src.size() ); // maximal possible length > > QCString::ConstIterator s = src.begin(); > QCString::Iterator d = result.begin(); >@@ -87,3 +88,107 @@ > result.truncate( d - result.begin() ); // adds trailing NUL > return result; > } >+ >+QByteArray KMail::Util::lf2crlf( const QByteArray & src ) >+{ >+ const char* s = src.data(); >+ if ( !s ) >+ return QByteArray(); >+ >+ QByteArray result( 2 * src.size() ); // maximal possible length >+ QByteArray::Iterator d = result.begin(); >+ // we use cPrev to make sure we insert '\r' only there where it is missing >+ char cPrev = '?'; >+ const char* end = src.end(); >+ while ( s != end ) { >+ if ( ('\n' == *s) && ('\r' != cPrev) ) >+ *d++ = '\r'; >+ cPrev = *s; >+ *d++ = *s++; >+ } >+ result.truncate( d - result.begin() ); // does not add trailing NUL, as expected >+ return result; >+} >+ >+QCString KMail::Util::CString( const DwString& str ) >+{ >+ const int strLen = str.size(); >+ QCString cstr( strLen + 1 ); >+ memcpy( cstr.data(), str.data(), strLen ); >+ cstr[ strLen ] = 0; >+ return cstr; >+} >+ >+QByteArray KMail::Util::ByteArray( const DwString& str ) >+{ >+ const int strLen = str.size(); >+ QByteArray arr( strLen ); >+ memcpy( arr.data(), str.data(), strLen ); >+ return arr; >+} >+ >+DwString KMail::Util::dwString( const QCString& str ) >+{ >+ if ( !str.data() ) // DwString doesn't like char*=0 >+ return DwString(); >+ return DwString( str.data(), str.size() - 1 ); >+} >+ >+DwString KMail::Util::dwString( const QByteArray& str ) >+{ >+ if ( !str.data() ) // DwString doesn't like char*=0 >+ return DwString(); >+ return DwString( str.data(), str.size() ); >+} >+ >+void KMail::Util::append( QByteArray& that, const QByteArray& str ) >+{ >+ that.detach(); >+ uint len1 = that.size(); >+ uint len2 = str.size(); >+ if ( that.resize( len1 + len2, QByteArray::SpeedOptim ) ) >+ memcpy( that.data() + len1, str.data(), len2 ); >+} >+ >+void KMail::Util::append( QByteArray& that, const char* str ) >+{ >+ if ( !str ) >+ return; // nothing to append >+ that.detach(); >+ uint len1 = that.size(); >+ uint len2 = qstrlen(str); >+ if ( that.resize( len1 + len2, QByteArray::SpeedOptim ) ) >+ memcpy( that.data() + len1, str, len2 ); >+} >+ >+void KMail::Util::append( QByteArray& that, const QCString& str ) >+{ >+ that.detach(); >+ uint len1 = that.size(); >+ uint len2 = str.size() - 1; >+ if ( that.resize( len1 + len2, QByteArray::SpeedOptim ) ) >+ memcpy( that.data() + len1, str.data(), len2 ); >+} >+ >+// Code taken from QCString::insert, but trailing nul removed >+void KMail::Util::insert( QByteArray& that, uint index, const char* s ) >+{ >+ int len = qstrlen(s); >+ if ( len == 0 ) >+ return; >+ uint olen = that.size(); >+ int nlen = olen + len; >+ if ( index >= olen ) { // insert after end of string >+ that.detach(); >+ if ( that.resize(nlen+index-olen, QByteArray::SpeedOptim ) ) { >+ memset( that.data()+olen, ' ', index-olen ); >+ memcpy( that.data()+index, s, len ); >+ } >+ } else { >+ that.detach(); >+ if ( that.resize(nlen, QByteArray::SpeedOptim ) ) { // normal insert >+ memmove( that.data()+index+len, that.data()+index, olen-index ); >+ memcpy( that.data()+index, s, len ); >+ } >+ } >+} >--- kmail/util.h 2005/07/26 18:54:59 438982 >+++ kmail/util.h 2007/02/15 10:54:03 633777 >@@ -41,6 +41,7 @@ > #include <stdlib.h> > #include <qobject.h> > #include <qcstring.h> >+class DwString; > > namespace KMail > { >@@ -66,10 +67,103 @@ > * @return The result string. > */ > QCString lf2crlf( const QCString & src ); >+ /** >+ * Convert "\n" line endings to "\r\n". >+ * @param src The source string to convert. NOT null-terminated. >+ * @return The result string. NOT null-terminated. >+ */ >+ QByteArray lf2crlf( const QByteArray & src ); >+ >+ /** >+ * Construct a QCString from a DwString >+ */ >+ QCString CString( const DwString& str ); >+ >+ /** >+ * Construct a QByteArray from a DwString >+ */ >+ QByteArray ByteArray( const DwString& str ); >+ >+ /** >+ * Construct a DwString from a QCString >+ */ >+ DwString dwString( const QCString& str ); >+ >+ /** >+ * Construct a DwString from a QByteArray >+ */ >+ DwString dwString( const QByteArray& str ); >+ >+ /** >+ * Fills a QByteArray from a QCString - removing the trailing null. >+ */ >+ void setFromQCString( QByteArray& arr, const QCString& cstr ); >+ >+ inline void setFromQCString( QByteArray& arr, const QCString& cstr ) >+ { >+ if ( cstr.size() ) >+ arr.duplicate( cstr.data(), cstr.size()-1 ); >+ else >+ arr.resize(0); >+ } >+ >+ /** >+ * Creates a QByteArray from a QCString without detaching (duplicating the data). >+ * Fast, but be careful, the QCString gets modified by this; this is only good for >+ * the case where the QCString is going to be thrown away afterwards anyway. >+ */ >+ QByteArray byteArrayFromQCStringNoDetach( QCString& cstr ); >+ inline QByteArray byteArrayFromQCStringNoDetach( QCString& cstr ) >+ { >+ QByteArray arr = cstr; >+ if ( arr.size() ) >+ arr.resize( arr.size() - 1 ); >+ return arr; >+ } >+ >+ /** >+ * Restore the QCString after byteArrayFromQCStringNoDetach modified it >+ */ >+ void restoreQCString( QCString& str ); >+ inline void restoreQCString( QCString& str ) >+ { >+ if ( str.data() ) >+ str.resize( str.size() + 1 ); >+ } >+ >+ /** >+ * Fills a QCString from a QByteArray - adding the trailing null. >+ */ >+ void setFromByteArray( QCString& cstr, const QByteArray& arr ); >+ >+ inline void setFromByteArray( QCString& result, const QByteArray& arr ) >+ { >+ const int len = arr.size(); >+ result.resize( len + 1 /* trailing NUL */ ); >+ memcpy(result.data(), arr.data(), len); >+ result[len] = 0; >+ } >+ >+ /** >+ * Append a bytearray to a bytearray. No trailing nuls anywhere. >+ */ >+ void append( QByteArray& that, const QByteArray& str ); >+ >+ /** >+ * Append a char* to a bytearray. Trailing nul not copied. >+ */ >+ void append( QByteArray& that, const char* str ); >+ >+ /** >+ * Append a QCString to a bytearray. Trailing nul not copied. >+ */ >+ void append( QByteArray& that, const QCString& str ); >+ >+ void insert( QByteArray& that, uint index, const char* s ); > > /** > * A LaterDeleter is intended to be used with the RAII ( Resource >- * Acquisiation is Initialization ) paradigm. When an instance of it >+ * Acquisition is Initialization ) paradigm. When an instance of it > * goes out of scope it deletes the associated object It can be > * disabled, in case the deletion needs to be avoided for some > * reason, since going out-of-scope cannot be avoided. >--- kmail/kmheaders.cpp 2007/01/05 18:17:45 620346 >+++ kmail/kmheaders.cpp 2007/03/28 14:44:39 647499 >@@ -15,6 +15,7 @@ > #include "kmmsgdict.h" > #include "kmdebug.h" > #include "kmfoldertree.h" >+#include "kmfolderimap.h" > #include "folderjob.h" > using KMail::FolderJob; > #include "actionscheduler.h" >@@ -215,7 +216,12 @@ > { > writeFolderConfig(); > writeSortOrder(); >- mFolder->close(); >+ if (mFolder->folderType() == KMFolderTypeImap) >+ { >+ KMFolderImap *imap = static_cast<KMFolderImap*>(mFolder->storage()); >+ imap->setSelected( false ); >+ } >+ mFolder->close("kmheaders"); > } > writeConfig(); > delete mRoot; >@@ -666,7 +672,7 @@ > BroadcastStatus::instance(), SLOT( setStatusMsg( const QString& ) ) ); > disconnect(mFolder, SIGNAL(viewConfigChanged()), this, SLOT(reset())); > writeSortOrder(); >- mFolder->close(); >+ mFolder->close("kmheaders"); > // System folders remain open but we also should write the index from > // time to time > if (mFolder->dirty()) mFolder->writeIndex(); >@@ -715,7 +721,7 @@ > > CREATE_TIMER(kmfolder_open); > START_TIMER(kmfolder_open); >- mFolder->open(); >+ mFolder->open("kmheaders"); > END_TIMER(kmfolder_open); > SHOW_TIMER(kmfolder_open); > >@@ -1725,6 +1731,9 @@ > > void KMHeaders::selectNextMessage() > { >+ KMMessage *cm = currentMsg(); >+ if ( cm && cm->isBeingParsed() ) >+ return; > QListViewItem *lvi = currentItem(); > if( lvi ) { > QListViewItem *below = lvi->itemBelow(); >@@ -1759,6 +1768,9 @@ > > void KMHeaders::selectPrevMessage() > { >+ KMMessage *cm = currentMsg(); >+ if ( cm && cm->isBeingParsed() ) >+ return; > QListViewItem *lvi = currentItem(); > if( lvi ) { > QListViewItem *above = lvi->itemAbove(); >@@ -1782,6 +1794,9 @@ > > void KMHeaders::incCurrentMessage() > { >+ KMMessage *cm = currentMsg(); >+ if ( cm && cm->isBeingParsed() ) >+ return; > QListViewItem *lvi = currentItem(); > if ( lvi && lvi->itemBelow() ) { > >@@ -1797,6 +1812,9 @@ > > void KMHeaders::decCurrentMessage() > { >+ KMMessage *cm = currentMsg(); >+ if ( cm && cm->isBeingParsed() ) >+ return; > QListViewItem *lvi = currentItem(); > if ( lvi && lvi->itemAbove() ) { > disconnect(this,SIGNAL(currentChanged(QListViewItem*)), >--- kmail/kmfilteraction.cpp 2006/12/16 00:58:17 614022 >+++ kmail/kmfilteraction.cpp 2007/03/28 15:05:05 647507 >@@ -22,6 +22,7 @@ > #include <libkdepim/kfileio.h> > #include <libkdepim/collectingprocess.h> > using KPIM::CollectingProcess; >+#include <mimelib/message.h> > #include "kmfawidgets.h" > #include "folderrequester.h" > using KMail::FolderRequester; >@@ -1377,18 +1378,19 @@ > // TODO opening and closing the folder is a trade off. > // Perhaps Copy is a seldomly used action for now, > // but I gonna look at improvements ASAP. >- if ( !mFolder && mFolder->open() != 0 ) >+ if ( !mFolder ) >+ return ErrorButGoOn; >+ if ( mFolder->open("filtercopy") != 0 ) > return ErrorButGoOn; > > // copy the message 1:1 >- KMMessage* msgCopy = new KMMessage; >- msgCopy->fromDwString(msg->asDwString()); >+ KMMessage* msgCopy = new KMMessage( new DwMessage( *msg->asDwMessage() ) ); > > int index; > int rc = mFolder->addMsg(msgCopy, &index); > if (rc == 0 && index != -1) > mFolder->unGetMsg( index ); >- mFolder->close(); >+ mFolder->close("filtercopy"); > > return GoOn; > } >--- kmail/kmcomposewin.cpp 2006/12/16 03:44:17 614049 >+++ kmail/kmcomposewin.cpp 2007/03/29 20:12:32 647900 >@@ -176,7 +176,8 @@ > mEncryptWithChiasmus( false ), > mComposer( 0 ), > mLabelWidth( 0 ), >- mAutoSaveTimer( 0 ), mLastAutoSaveErrno( 0 ) >+ mAutoSaveTimer( 0 ), mLastAutoSaveErrno( 0 ), >+ mPreserveUserCursorPosition( false ) > { > mClassicalRecipients = GlobalSettings::self()->recipientsEditorType() == > GlobalSettings::EnumRecipientsEditorType::Classic; >@@ -476,9 +477,13 @@ > if (!data.isEmpty()) { > KMMessagePart *msgPart = new KMMessagePart; > msgPart->setName(name); >- QValueList<int> dummy; >- msgPart->setBodyAndGuessCte(data, dummy, >- kmkernel->msgSender()->sendQuotedPrintable()); >+ if( type == "message" && subType == "rfc822" ) { >+ msgPart->setMessageBody( data ); >+ } else { >+ QValueList<int> dummy; >+ msgPart->setBodyAndGuessCte(data, dummy, >+ kmkernel->msgSender()->sendQuotedPrintable()); >+ } > msgPart->setTypeStr(type); > msgPart->setSubtypeStr(subType); > msgPart->setParameter(paramAttr,paramValue); >@@ -706,8 +711,8 @@ > if ( status == 0 ) { // no error > kdDebug(5006) << "autosaving message in " << filename << endl; > int fd = autoSaveFile.handle(); >- QCString msgStr = msg->asString(); >- if ( ::write( fd, msgStr, msgStr.length() ) == -1 ) >+ const DwString& msgStr = msg->asDwString(); >+ if ( ::write( fd, msgStr.data(), msgStr.length() ) == -1 ) > status = errno; > } > if ( status == 0 ) { >@@ -1701,6 +1706,7 @@ > return; > } > mMsg = newMsg; >+ KPIM::IdentityManager * im = kmkernel->identityManager(); > > mEdtFrom->setText(mMsg->from()); > mEdtReplyTo->setText(mMsg->replyTo()); >@@ -1712,6 +1718,7 @@ > mRecipientsEditor->setRecipientString( mMsg->to(), Recipient::To ); > mRecipientsEditor->setRecipientString( mMsg->cc(), Recipient::Cc ); > mRecipientsEditor->setRecipientString( mMsg->bcc(), Recipient::Bcc ); >+ mRecipientsEditor->setFocusBottom(); > } > mEdtSubject->setText(mMsg->subject()); > >@@ -1733,10 +1740,14 @@ > // make sure the header values are overwritten with the values of the > // sticky identity (the slot isn't called by the signal for new messages > // since the identity has already been set before the signal was connected) >- slotIdentityChanged( mId ); >+ uint savedId = mId; >+ if ( !newMsg->headerField("X-KMail-Identity").isEmpty() ) >+ mId = newMsg->headerField("X-KMail-Identity").stripWhiteSpace().toUInt(); >+ else >+ mId = im->defaultIdentity().uoid(); >+ slotIdentityChanged( savedId ); > } > >- KPIM::IdentityManager * im = kmkernel->identityManager(); > > const KPIM::Identity & ident = im->identityForUoid( mIdentity->currentIdentity() ); > >@@ -1839,20 +1850,32 @@ > > mEditor->setText( otp.textualContent() ); > mCharset = otp.textualContentCharset(); >- if ( mCharset.isEmpty() ) >- mCharset = mMsg->charset(); >- if ( mCharset.isEmpty() ) >- mCharset = mDefCharset; >- setCharset( mCharset ); >- > if ( partNode * n = root->findType( DwMime::kTypeText, DwMime::kSubtypeHtml ) ) > if ( partNode * p = n->parentNode() ) > if ( p->hasType( DwMime::kTypeMultipart ) && > p->hasSubType( DwMime::kSubtypeAlternative ) ) > if ( mMsg->headerField( "X-KMail-Markup" ) == "true" ) { > toggleMarkup( true ); >- mEditor->setText(n->encodedBody() ); >+ >+ // get cte decoded body part >+ mCharset = n->msgPart().charset(); >+ QCString bodyDecoded = n->msgPart().bodyDecoded(); >+ >+ // respect html part charset >+ const QTextCodec *codec = KMMsgBase::codecForName( mCharset ); >+ if ( codec ) { >+ mEditor->setText( codec->toUnicode( bodyDecoded ) ); >+ } else { >+ mEditor->setText( QString::fromLocal8Bit( bodyDecoded ) ); >+ } > } >+ >+ if ( mCharset.isEmpty() ) >+ mCharset = mMsg->charset(); >+ if ( mCharset.isEmpty() ) >+ mCharset = mDefCharset; >+ setCharset( mCharset ); >+ > /* Handle the special case of non-mime mails */ > if ( mMsg->numBodyParts() == 0 && otp.textualContent().isEmpty() ) { > mCharset=mMsg->charset(); >@@ -1870,8 +1893,6 @@ > } else > mEditor->setText(QString::fromLocal8Bit(bodyDecoded)); > } >- >- > #ifdef BROKEN_FOR_OPAQUE_SIGNED_OR_ENCRYPTED_MAILS > const int num = mMsg->numBodyParts(); > kdDebug(5006) << "KMComposeWin::setMsg() mMsg->numBodyParts=" >@@ -1973,6 +1994,12 @@ > // > QTimer::singleShot( 200, this, SLOT(slotAppendSignature()) ); > } >+ >+ if ( mMsg->getCursorPos() > 0 ) { >+ // The message has a cursor position explicitly set, so avoid >+ // changing it when appending the signature. >+ mPreserveUserCursorPosition = true; >+ } > setModified( isModified ); > > // do this even for new messages >@@ -2034,6 +2061,8 @@ > return false; > if ( kmkernel->shuttingDown() || kapp->sessionSaving() ) > return true; >+ if ( mComposer && mComposer->isPerformingSignOperation() ) // since the non-gpg-agent gpg plugin gets a passphrase using QDialog::exec() >+ return false; // the user can try to close the window, which destroys mComposer mid-call. > > if ( isModified() ) { > bool istemplate = ( mFolder!=0 && mFolder->isTemplates() ); >@@ -2637,9 +2666,15 @@ > msgPart = new KMMessagePart; > msgPart->setName(name); > QValueList<int> allowedCTEs; >- msgPart->setBodyAndGuessCte((*it).data, allowedCTEs, >- !kmkernel->msgSender()->sendQuotedPrintable()); >- kdDebug(5006) << "autodetected cte: " << msgPart->cteStr() << endl; >+ if ( mimeType == "message/rfc822" ) { >+ msgPart->setMessageBody( (*it).data ); >+ allowedCTEs << DwMime::kCte7bit; >+ allowedCTEs << DwMime::kCte8bit; >+ } else { >+ msgPart->setBodyAndGuessCte((*it).data, allowedCTEs, >+ !kmkernel->msgSender()->sendQuotedPrintable()); >+ kdDebug(5006) << "autodetected cte: " << msgPart->cteStr() << endl; >+ } > int slash = mimeType.find( '/' ); > if( slash == -1 ) > slash = mimeType.length(); >@@ -3766,13 +3801,23 @@ > "not have to enter it for each message.") ); > return; > } >- if (to().isEmpty() && cc().isEmpty() && bcc().isEmpty()) >- { >- if ( mEdtTo ) mEdtTo->setFocus(); >- KMessageBox::information( this, >- i18n("You must specify at least one receiver," >- "either in the To: field or as CC or as BCC.") ); >- return; >+ if ( to().isEmpty() ) { >+ if ( cc().isEmpty() && bcc().isEmpty()) { >+ if ( mEdtTo ) mEdtTo->setFocus(); >+ KMessageBox::information( this, >+ i18n("You must specify at least one receiver," >+ "either in the To: field or as CC or as BCC.") ); >+ return; >+ } else { >+ if ( mEdtTo )mEdtTo->setFocus(); >+ int rc = KMessageBox::questionYesNo( this, >+ i18n("To: field is empty. " >+ "Send message anyway?"), >+ i18n("No To: specified") ); >+ if ( rc == KMessageBox::No ) { >+ return; >+ } >+ } > } > > // Validate the To:, CC: and BCC fields >@@ -3891,12 +3936,12 @@ > if ( imapTheFolder && imapTheFolder->noContent() ) > imapTheFolder = 0; > >- if ( theFolder == 0 ) { >+ if ( theFolder == 0 ) > theFolder = ( mSaveIn==KMComposeWin::Drafts ? > kmkernel->draftsFolder() : kmkernel->templatesFolder() ); >- } else { >- theFolder->open(); >- } >+ >+ theFolder->open("composer"); >+ > kdDebug(5006) << k_funcinfo << "theFolder=" << theFolder->name() << endl; > if ( imapTheFolder ) > kdDebug(5006) << k_funcinfo << "imapTheFolder=" << imapTheFolder->name() << endl; >@@ -3914,6 +3959,7 @@ > (static_cast<KMFolderImap*>( imapTheFolder->storage() ))->getFolder(); > } > >+ theFolder->close( "composer" ); > return sentOk; > } > >@@ -4049,7 +4095,14 @@ > mEditor->append(mOldSigText); > mEditor->setModified(mod); > // mEditor->setContentsPos( 0, 0 ); >- mEditor->setCursorPositionFromStart( (unsigned int) mMsg->getCursorPos() ); >+ if ( mPreserveUserCursorPosition ) { >+ mEditor->setCursorPositionFromStart( (unsigned int) mMsg->getCursorPos() ); >+ // Only keep the cursor from the mMsg *once* based on the >+ // preserve-cursor-position setting; this handles the case where >+ // the message comes from a template with a specific cursor >+ // position set and the signature is appended automatically. >+ mPreserveUserCursorPosition = false; >+ } > mEditor->sync(); > } > } >@@ -4283,6 +4336,7 @@ > if ( oldIdentity.bcc() != ident.bcc() ) { > mRecipientsEditor->removeRecipient( oldIdentity.bcc(), Recipient::Bcc ); > mRecipientsEditor->addRecipient( ident.bcc(), Recipient::Bcc ); >+ mRecipientsEditor->setFocusBottom(); > } > } > >--- kmail/kmfoldermbox.h 2005/07/26 18:54:59 438982 >+++ kmail/kmfoldermbox.h 2007/03/28 14:44:39 647499 >@@ -77,11 +77,11 @@ > call close() first. > Returns zero on success and an error code equal to the c-library > fopen call otherwise (errno). */ >- virtual int open(); >+ virtual int open(const char *owner); > > /** Close folder. If force is TRUE the files are closed even if > others still use it (e.g. other mail reader windows). */ >- virtual void close(bool force=FALSE); >+ virtual void close(const char *owner, bool force=FALSE); > > virtual int canAccess(); > >@@ -109,7 +109,7 @@ > > void setProcmailLockFileName( const QString& ); > >- static QCString escapeFrom( const QCString & str ); >+ static QByteArray escapeFrom( const DwString & str ); > > virtual IndexStatus indexStatus(); > >--- kmail/kmsender_p.h 2005/07/26 18:54:59 438982 >+++ kmail/kmsender_p.h 2007/02/15 22:58:16 633978 >@@ -6,7 +6,6 @@ > #define __KMAIL_SENDER_P_H__ > #include "kmsender.h" > >-#include <qcstring.h> > #include <qstring.h> > #include <qstringlist.h> > #include <qobject.h> >@@ -33,7 +32,7 @@ > void start() { emit started( doStart() ); } > > /** Send given message. May return before message is sent. */ >- bool send( const QString & sender, const QStringList & to, const QStringList & cc, const QStringList & bcc, const QCString & message ) { >+ bool send( const QString & sender, const QStringList & to, const QStringList & cc, const QStringList & bcc, const QByteArray & message ) { > reset(); return doSend( sender, to, cc, bcc, message ); > } > >@@ -72,7 +71,7 @@ > > private: > virtual void doFinish() = 0; >- virtual bool doSend( const QString & sender, const QStringList & to, const QStringList & cc, const QStringList & bcc, const QCString & message ) = 0; >+ virtual bool doSend( const QString & sender, const QStringList & to, const QStringList & cc, const QStringList & bcc, const QByteArray & message ) = 0; > virtual bool doStart() = 0; > > protected: >@@ -102,12 +101,12 @@ > /** implemented from KMSendProc */ > void doFinish(); > /** implemented from KMSendProc */ >- bool doSend( const QString & sender, const QStringList & to, const QStringList & cc, const QStringList & bcc, const QCString & message ); >+ bool doSend( const QString & sender, const QStringList & to, const QStringList & cc, const QStringList & bcc, const QByteArray & message ); > /** implemented from KMSendProc */ > bool doStart(); > > private: >- QCString mMsgStr; >+ QByteArray mMsgStr; > char* mMsgPos; > int mMsgRest; > KProcess* mMailerProc; >@@ -132,14 +131,14 @@ > /** implemented from KMSendProc */ > void doFinish(); > /** implemented from KMSendProc */ >- bool doSend( const QString & sender, const QStringList & to, const QStringList & cc, const QStringList & bcc, const QCString & message ); >+ bool doSend( const QString & sender, const QStringList & to, const QStringList & cc, const QStringList & bcc, const QByteArray & message ); > /** implemented from KMSendProc */ > bool doStart() { return true; } > > void cleanup(); > > private: >- QCString mMessage; >+ QByteArray mMessage; > uint mMessageLength; > uint mMessageOffset; > >--- kmail/kmailicalifaceimpl.cpp 2005/12/30 00:15:02 492457 >+++ kmail/kmailicalifaceimpl.cpp 2007/03/28 14:44:39 647499 >@@ -70,6 +70,8 @@ > #include <kurl.h> > #include <ktempfile.h> > >+using namespace KMail; >+ > // Local helper methods > static void vPartMicroParser( const QString& str, QString& s ); > static void reloadFolderTree(); >@@ -480,9 +482,9 @@ > return 0; > } > >- f->open(); >+ f->open("kolabcount"); > int n = f->count(); >- f->close(); >+ f->close("kolabcount"); > kdDebug(5006) << "KMailICalIfaceImpl::incidencesKolabCount( " << mimetype << ", " > << resource << " ) returned " << n << endl; > return n; >@@ -507,7 +509,7 @@ > return aMap; > } > >- f->open(); >+ f->open("incidences"); > > int stopIndex = nbMessages == -1 ? f->count() : > QMIN( f->count(), startIndex + nbMessages ); >@@ -553,6 +555,7 @@ > #endif > } > } >+ f->close( "incidences" ); > return aMap; > } > >@@ -634,7 +637,7 @@ > kdDebug(5006) << k_funcinfo << endl; > QValueList<KMailICalIfaceImpl::SubResource> folderList = subresourcesKolab( contentsType ); > for ( QValueList<KMailICalIfaceImpl::SubResource>::const_iterator it( folderList.begin() ), >- end( folderList.end() ); >+ end( folderList.end() ); > it != end ; ++it ) { > KMFolder * const f = findResourceFolder( (*it).location ); > if ( !f ) continue; >@@ -723,7 +726,7 @@ > return rc; > } > >- f->open(); >+ f->open("ifaceupdate"); > > KMMessage* msg = 0; > if ( sernum != 0 ) { >@@ -751,7 +754,7 @@ > const KMail::FolderContentsType t = f->storage()->contentsType(); > const QCString type = msg->typeStr(); > const QCString subtype = msg->subtypeStr(); >- const bool messageWasIcalVcardFormat = ( type.lower() == "text" && >+ const bool messageWasIcalVcardFormat = ( type.lower() == "text" && > ( subtype.lower() == "calendar" || subtype.lower() == "x-vcard" ) ); > > if ( storageFormat( f ) == StorageIcalVcard ) { >@@ -806,7 +809,7 @@ > attachmentMimetypes ); > } > >- f->close(); >+ f->close("ifaceupdate"); > return rc; > } > >@@ -1691,7 +1694,7 @@ > folder->storage()->setContentsType( contentsType ); > folder->setSystemFolder( true ); > folder->storage()->writeConfig(); >- folder->open(); >+ folder->open("ifacefolder"); > connectFolder( folder ); > return folder; > } >@@ -1733,7 +1736,7 @@ > if( folder ) { > folder->setSystemFolder( false ); > folder->disconnect( _this ); >- folder->close(); >+ folder->close("ifacefolder"); > } > } > >--- kmail/actionscheduler.cpp 2005/12/07 19:54:11 486422 >+++ kmail/actionscheduler.cpp 2007/04/03 14:01:26 649957 >@@ -122,7 +122,7 @@ > { > schedulerList->remove( this ); > tempCloseFolders(); >- mSrcFolder->close(); >+ mSrcFolder->close("actionschedsrc"); > > if (mDeleteSrcFolder) > tempFolderMgr->remove(mSrcFolder); >@@ -151,11 +151,11 @@ > > void ActionScheduler::setSourceFolder( KMFolder *srcFolder ) > { >- srcFolder->open(); >+ srcFolder->open("actionschedsrc"); > if (mSrcFolder) { > disconnect( mSrcFolder, SIGNAL(msgAdded(KMFolder*, Q_UINT32)), > this, SLOT(msgAdded(KMFolder*, Q_UINT32)) ); >- mSrcFolder->close(); >+ mSrcFolder->close("actionschedsrc"); > } > mSrcFolder = srcFolder; > int i = 0; >@@ -170,7 +170,7 @@ > { > mFiltersAreQueued = true; > mQueuedFilters.clear(); >- >+ > QValueList<KMFilter*>::Iterator it = filters.begin(); > for (; it != filters.end(); ++it) > mQueuedFilters.append( **it ); >@@ -188,7 +188,7 @@ > if ( aFolder == mSrcFolder.operator->() ) > return 0; > >- int rc = aFolder->open(); >+ int rc = aFolder->open("actionsched"); > if (rc) > return rc; > >@@ -203,7 +203,7 @@ > for (it = mOpenFolders.begin(); it != mOpenFolders.end(); ++it) { > KMFolder *folder = *it; > if (folder) >- folder->close(); >+ folder->close("actionsched"); > } > mOpenFolders.clear(); > } >@@ -231,7 +231,7 @@ > void ActionScheduler::execFilters(Q_UINT32 serNum) > { > if (mResult != ResultOk) { >- if ((mResult != ResultCriticalError) && >+ if ((mResult != ResultCriticalError) && > !mExecuting && !mExecutingLock && !mFetchExecuting) { > mResult = ResultOk; // Recoverable error > if (!mFetchSerNums.isEmpty()) { >@@ -420,10 +420,10 @@ > fetchMessageTimer->start( 0, true ); > return; > } >- >+ > mFetchSerNums.remove( msg->getMsgSerNum() ); > >- // Note: This may not be necessary. What about when it's time to >+ // Note: This may not be necessary. What about when it's time to > // delete the original message? > // Is the new serial number being set correctly then? > if ((mSet & KMFilterMgr::Explicit) || >@@ -500,7 +500,7 @@ > > //If we got this far then there's a valid message to work with > KMMsgBase *msgBase = messageBase( *mMessageIt ); >- if (mResult != ResultOk) { >+ if (!msgBase || mResult != ResultOk) { > mExecuting = false; > return; > } >@@ -580,7 +580,7 @@ > if (mAlwaysMatch || > (*mFilterIt).pattern()->matches( *mMessageIt )) { > if ( FilterLog::instance()->isLogging() ) { >- FilterLog::instance()->add( i18n( "<b>Filter rules have matched.</b>" ), >+ FilterLog::instance()->add( i18n( "<b>Filter rules have matched.</b>" ), > FilterLog::patternResult ); > } > mFilterAction = (*mFilterIt).actions()->first(); >@@ -694,7 +694,7 @@ > msg = message( mOriginalSerNum ); > emit filtered( mOriginalSerNum ); > } >- >+ > mResult = mOldReturnCode; // ignore errors in deleting original message > KMCommand *cmd = 0; > if (msg && msg->parent()) { >@@ -710,7 +710,7 @@ > else > processMessageTimer->start( 0, true ); > } else { >- // Note: An alternative to consider is just calling >+ // Note: An alternative to consider is just calling > // finishTimer->start and returning > if (cmd) > connect( cmd, SIGNAL( completed( KMCommand * ) ), >@@ -727,7 +727,7 @@ > { > if ( command->result() != KMCommand::OK ) > actionMessage( KMFilterAction::ErrorButGoOn ); >- else >+ else > actionMessage(); > } > >@@ -786,7 +786,7 @@ > res.append( QString( "ResultCriticalError.\n" ) ); > else > res.append( QString( "Unknown.\n" ) ); >- >+ > ++i; > } > return res; >--- kmail/compactionjob.cpp 2005/07/26 18:54:59 438982 >+++ kmail/compactionjob.cpp 2007/03/28 14:44:39 647499 >@@ -65,7 +65,7 @@ > Q_ASSERT( mCancellable ); > // We must close the folder if we opened it and got interrupted > if ( mFolderOpen && mSrcFolder && mSrcFolder->storage() ) >- mSrcFolder->storage()->close(); >+ mSrcFolder->storage()->close("mboxcompactjob"); > > if ( mTmpFile ) > fclose( mTmpFile ); >@@ -124,7 +124,7 @@ > return errno; > } > mOpeningFolder = true; // Ignore open-notifications while opening the folder >- storage->open(); >+ storage->open("mboxcompactjob"); > mOpeningFolder = false; > mFolderOpen = true; > mOffset = 0; >@@ -170,13 +170,13 @@ > mbox->writeIndex(); > mbox->writeConfig(); > mbox->setAutoCreateIndex( false ); >- mbox->close(true); >+ mbox->close("mboxcompact", true); > mbox->setAutoCreateIndex( autoCreate ); > mbox->setNeedsCompacting( false ); // We are clean now > str = i18n( "Folder \"%1\" successfully compacted" ).arg( mSrcFolder->label() ); > kdDebug(5006) << str << endl; > } else { >- mbox->close(); >+ mbox->close("mboxcompact"); > str = i18n( "Error occurred while compacting \"%1\". Compaction aborted." ).arg( mSrcFolder->label() ); > kdDebug(5006) << "Error occurred while compacting " << mbox->location() << endl; > kdDebug(5006) << "Compaction aborted." << endl; >@@ -208,7 +208,7 @@ > Q_ASSERT( mCancellable ); > // We must close the folder if we opened it and got interrupted > if ( mFolderOpen && mSrcFolder && mSrcFolder->storage() ) >- mSrcFolder->storage()->close(); >+ mSrcFolder->storage()->close("maildircompact"); > > FolderJob::kill(); > } >@@ -220,7 +220,7 @@ > kdDebug(5006) << "Compacting " << mSrcFolder->idString() << endl; > > mOpeningFolder = true; // Ignore open-notifications while opening the folder >- storage->open(); >+ storage->open("maildircompact"); > mOpeningFolder = false; > mFolderOpen = true; > QString subdirNew(storage->location() + "/new/"); >@@ -262,7 +262,7 @@ > } > mErrorCode = rc; > storage->setNeedsCompacting( false ); >- storage->close(); >+ storage->close("maildircompact"); > if ( storage->isOpened() ) > storage->updateIndex(); > if ( !mSilent )
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 171346
:
113648
|
113652
|
113654
|
113657
|
113658
|
113659
|
113660
|
113703
|
113704
|
115351
| 115548