--- kdepim/kmail/kmheaders.cpp 2006/03/02 12:26:51 515022
+++ kdepim/kmail/kmheaders.cpp 2006/04/22 08:13:05 532593
@@ -1841,7 +1841,7 @@
bool foundUnreadMessage = false;
if (!mFolder) return -1;
- if (!(mFolder->count()) > 0) return -1;
+ if (mFolder->count() <= 0) return -1;
if ((aStartAt >= 0) && (aStartAt < (int)mItems.size()))
item = mItems[aStartAt];
@@ -2041,7 +2041,7 @@
int idx = item->msgId();
KMMessage *msg = mFolder->getMsg(idx);
- if (!msg->transferInProgress())
+ if (msg && !msg->transferInProgress())
{
emit activated(mFolder->getMsg(idx));
}
@@ -3280,7 +3280,8 @@
unlink(QFile::encodeName(sortFile));
kdWarning(5006) << "Error: Failure modifying " << sortFile << " (No space left on device?)" << endl;
kdWarning(5006) << __FILE__ << ":" << __LINE__ << endl;
- //kmkernel->emergencyExit( i18n("Failure modifying %1\n(No space left on device?)").arg( sortFile ));
+
+ return true;
}
if(sortStream)
fclose(sortStream);
--- kdepim/kmail/imapaccountbase.cpp 2006/02/23 14:32:38 512746
+++ kdepim/kmail/imapaccountbase.cpp 2006/04/15 13:05:11 530119
@@ -1098,10 +1098,10 @@
{
DwBodyPart* newparent = dwpart;
const DwMessage* newmsg = dwmsg;
- if ( part->originalContentTypeStr() == "MESSAGE/RFC822" &&
+ if ( part->originalContentTypeStr() == "MESSAGE/RFC822" && dwpart &&
dwpart->Body().Message() )
{
- // set the encapsulated message as new parent message
+ // set the encapsulated message as the new message
newparent = 0;
newmsg = dwpart->Body().Message();
}
@@ -1281,7 +1281,8 @@
if ( delim.isEmpty() ) {
delim = "/";
}
- if ( !newName.endsWith( delim ) && !folderName.startsWith( delim ) ) {
+ if ( !newName.isEmpty() &&
+ !newName.endsWith( delim ) && !folderName.startsWith( delim ) ) {
newName = newName + delim;
}
newName = newName + folderName;
--- kdepim/kmail/kmfolderimap.cpp 2006/03/15 14:19:26 518857
+++ kdepim/kmail/kmfolderimap.cpp 2006/04/15 13:05:11 530119
@@ -110,6 +110,11 @@
if (mOpenCount <= 0 ) return;
if (mOpenCount > 0) mOpenCount--;
if (mOpenCount > 0 && !aForced) return;
+ if (isSelected() && !aForced) {
+ kdWarning(5006) << "Trying to close the selected folder " << label() <<
+ " - ignoring!" << endl;
+ return;
+ }
// FIXME is this still needed?
if (mAccount)
mAccount->ignoreJobsForFolder( folder() );
@@ -873,8 +878,10 @@
}
kmkernel->imapFolderMgr()->contentsChanged();
}
- f->initializeFrom( this, "/INBOX/", "message/directory" );
- f->setChildrenState( QString::null );
+ if ( f ) {
+ f->initializeFrom( this, "/INBOX/", "message/directory" );
+ f->setChildrenState( QString::null );
+ }
// so we have an INBOX
mAccount->setHasInbox( true );
}
@@ -1086,17 +1093,20 @@
int a = cstr.find("X-uidValidity: ");
int b = cstr.find("\r\n", a);
QString uidv;
- if ( (b - a - 15) >= 0 ) uidv = cstr.mid(a + 15, b - a - 15);
+ if ( (b - a - 15) >= 0 )
+ uidv = cstr.mid(a + 15, b - a - 15);
a = cstr.find("X-Access: ");
b = cstr.find("\r\n", a);
QString access;
- if ( (b - a - 10) >= 0 ) access = cstr.mid(a + 10, b - a - 10);
+ if ( (b - a - 10) >= 0 )
+ access = cstr.mid(a + 10, b - a - 10);
mReadOnly = access == "Read only";
a = cstr.find("X-Count: ");
b = cstr.find("\r\n", a);
int exists = -1;
- bool ok;
- if ( (b - a - 9) >= 0 ) exists = cstr.mid(a + 9, b - a - 9).toInt(&ok);
+ bool ok = false;
+ if ( (b - a - 9) >= 0 )
+ exists = cstr.mid(a + 9, b - a - 9).toInt(&ok);
if ( !ok ) exists = -1;
QString startUid;
if (uidValidity() != uidv)
--- kdepim/kmail/kmfoldercachedimap.cpp 2006/02/11 22:39:04 508499
+++ kdepim/kmail/kmfoldercachedimap.cpp 2006/05/01 18:24:21 536266
@@ -539,8 +539,11 @@
mRecurse = recurse;
assert( account() );
- mAccount->mailCheckProgressItem()->reset();
- mAccount->mailCheckProgressItem()->setTotalItems( 100 );
+ ProgressItem *progressItem = mAccount->mailCheckProgressItem();
+ if ( progressItem ) {
+ progressItem->reset();
+ progressItem->setTotalItems( 100 );
+ }
mProgress = 0;
#if 0
@@ -1115,12 +1118,12 @@
job->start();
return;
} else {
- const QString msg ( i18n( "
There are new messages in this folder, which "
+ const QString msg ( i18n( "
There are new messages in this folder (%1), which "
"have not been uploaded to the server yet, but you do not seem to "
"have sufficient access rights on the folder now to upload them. "
"Please contact your administrator to allow upload of new messages "
"to you, or move them out of this folder.
"
- "Do you want to move these messages to another folder now?
") );
+ "Do you want to move these messages to another folder now?
").arg( folder()->prettyURL() ) );
if ( KMessageBox::warningYesNo( 0, msg, QString::null, i18n("Move"), i18n("Do Not Move") ) == KMessageBox::Yes ) {
KMail::KMFolderSelDlg dlg( kmkernel->getKMMainWidget(),
i18n("Move Messages to Folder"), true );
@@ -1746,11 +1749,14 @@
f = static_cast(newFolder->storage());
}
}
- f->setAccount( mAccount );
- f->setImapPath( "/INBOX/" );
- f->folder()->setLabel( i18n("inbox") );
+ if ( f ) {
+ f->setAccount( mAccount );
+ f->setImapPath( "/INBOX/" );
+ f->folder()->setLabel( i18n("inbox") );
+ }
if (!node) {
- f->close();
+ if ( f )
+ f->close();
kmkernel->dimapFolderMgr()->contentsChanged();
}
// so we have an INBOX
--- kdepim/kmail/kmfoldertree.cpp 2006/02/13 20:29:00 509156
+++ kdepim/kmail/kmfoldertree.cpp 2006/04/28 09:54:26 534978
@@ -139,7 +139,7 @@
KIconLoader * il = KGlobal::instance()->iconLoader();
QPixmap pm = il->loadIcon( icon, KIcon::Small, size,
KIcon::DefaultState, 0, true );
- if ( pm.isNull() ) {
+ if ( mFolder && pm.isNull() ) {
pm = il->loadIcon( mFolder->normalIconPath(), KIcon::Small, size,
KIcon::DefaultState, 0, true );
}
@@ -157,7 +157,7 @@
pm = normalIcon( size );
KIconLoader * il = KGlobal::instance()->iconLoader();
- if ( mFolder->useCustomIcons() ) {
+ if ( mFolder && mFolder->useCustomIcons() ) {
pm = il->loadIcon( mFolder->unreadIconPath(), KIcon::Small, size,
KIcon::DefaultState, 0, true );
if ( pm.isNull() )
@@ -1020,10 +1020,10 @@
mMainWidget->action("compact")->plug(folderMenu);
folderMenu->insertSeparator();
- if ( !fti->folder()->isSystemFolder() )
+ if ( !fti->folder()->isSystemFolder() ) {
mMainWidget->action("delete_folder")->plug(folderMenu);
-
- folderMenu->insertSeparator();
+ folderMenu->insertSeparator();
+ }
mMainWidget->action("empty")->plug(folderMenu);
folderMenu->insertSeparator();
}
@@ -1472,7 +1472,7 @@
KMFolderTreeItem *fti = static_cast(item);
- if (fti && fti->folder() && col != 0 && !currentFolder()->child())
+ if ((!fti) || (fti && fti->folder() && col != 0 && !currentFolder()->child()))
return;
QString fldName, oldFldName;
@@ -1546,10 +1546,12 @@
// get the unread count
int count = 0;
- if (folder->noContent()) // always empty
+ if (folder && folder->noContent()) // always empty
count = -1;
- else
- count = fti->folder()->countUnread();
+ else {
+ if ( fti->folder() )
+ count = fti->folder()->countUnread();
+ }
// set it
bool repaint = false;
@@ -1848,6 +1850,9 @@
void KMFolderTree::moveFolder( KMFolder* destination )
{
KMFolder* folder = currentFolder();
+ if (!folder)
+ return;
+
KMFolderDir* parent = &(kmkernel->folderMgr()->dir());
if ( destination )
parent = destination->createChildFolder();
@@ -1857,7 +1862,7 @@
KMFolderDir* folderDir = parent;
// check that the folder can be moved
- if ( folder && folder->child() )
+ if ( folder->child() )
{
while ( folderDir && ( folderDir != &kmkernel->folderMgr()->dir() ) &&
( folderDir != folder->parent() ) )
@@ -1871,13 +1876,13 @@
}
}
- if( folder && folder->child() && parent &&
+ if( folder->child() && parent &&
( parent->path().find( folder->child()->path() + "/" ) == 0 ) ) {
KMessageBox::error( this, message );
return;
}
- if( folder && folder->child()
+ if( folder->child()
&& ( parent == folder->child() ) ) {
KMessageBox::error( this, message );
return;
--- kdepim/kmail/imapjob.cpp 2005/08/12 17:17:32 446148
+++ kdepim/kmail/imapjob.cpp 2006/05/04 21:30:58 537478
@@ -97,11 +97,12 @@
// imap folder, use its account for keeping track of the job. Otherwise,
// this is a get job and the src folder is an imap one. Use its account
// then.
- KMAcctImap *account;
+ KMAcctImap *account = 0;
if (folder) {
account = folder->account();
} else {
- account = static_cast(msg_parent->storage())->account();
+ if ( msg_parent && msg_parent->storage() )
+ account = static_cast(msg_parent->storage())->account();
}
if ( !account ||
account->makeConnection() == ImapAccountBase::Error ) {
@@ -127,7 +128,7 @@
url.setPath( folder->imapPath() + ";SECTION=" + flags );
ImapAccountBase::jobData jd;
jd.parent = 0; jd.offset = 0; jd.done = 0;
- jd.total = ( curMsg->msgSizeServer() > 0 ) ?
+ jd.total = ( curMsg->msgSizeServer() > 0 ) ?
curMsg->msgSizeServer() : curMsg->msgSize();
jd.msgList.append( curMsg );
QCString cstr( curMsg->asString() );
@@ -192,7 +193,7 @@
"ImapJobCopyMove"+ProgressManager::getUniqueID(),
i18n("Server operation"),
i18n("Source folder: %1 - Destination folder: %2")
- .arg( msg_parent->prettyURL(),
+ .arg( msg_parent->prettyURL(),
mDestFolder->prettyURL() ),
true,
account->useSSL() || account->useTLS() );
@@ -223,21 +224,23 @@
if ( mDestFolder )
{
KMAcctImap *account = static_cast(mDestFolder->storage())->account();
- if ( account && mJob ) {
- ImapAccountBase::JobIterator it = account->findJob( mJob );
- if ( it != account->jobsEnd() ) {
- if( (*it).progressItem ) {
- (*it).progressItem->setComplete();
- (*it).progressItem = 0;
- }
- if ( !(*it).msgList.isEmpty() ) {
- for ( QPtrListIterator mit( (*it).msgList ); mit.current(); ++mit )
- mit.current()->setTransferInProgress( false );
+ if ( account ) {
+ if ( mJob ) {
+ ImapAccountBase::JobIterator it = account->findJob( mJob );
+ if ( it != account->jobsEnd() ) {
+ if( (*it).progressItem ) {
+ (*it).progressItem->setComplete();
+ (*it).progressItem = 0;
+ }
+ if ( !(*it).msgList.isEmpty() ) {
+ for ( QPtrListIterator mit( (*it).msgList ); mit.current(); ++mit )
+ mit.current()->setTransferInProgress( false );
+ }
}
+ account->removeJob( mJob );
}
- account->removeJob( mJob );
+ account->mJobList.remove( this );
}
- account->mJobList.remove( this );
mDestFolder->close();
}
@@ -245,21 +248,23 @@
if (!mDestFolder || mDestFolder != mSrcFolder) {
if (! (mSrcFolder->folderType() == KMFolderTypeImap) ) return;
KMAcctImap *account = static_cast(mSrcFolder->storage())->account();
- if ( account && mJob ) {
- ImapAccountBase::JobIterator it = account->findJob( mJob );
- if ( it != account->jobsEnd() ) {
- if( (*it).progressItem ) {
- (*it).progressItem->setComplete();
- (*it).progressItem = 0;
- }
- if ( !(*it).msgList.isEmpty() ) {
- for ( QPtrListIterator mit( (*it).msgList ); mit.current(); ++mit )
- mit.current()->setTransferInProgress( false );
+ if ( account ) {
+ if ( mJob ) {
+ ImapAccountBase::JobIterator it = account->findJob( mJob );
+ if ( it != account->jobsEnd() ) {
+ if( (*it).progressItem ) {
+ (*it).progressItem->setComplete();
+ (*it).progressItem = 0;
+ }
+ if ( !(*it).msgList.isEmpty() ) {
+ for ( QPtrListIterator mit( (*it).msgList ); mit.current(); ++mit )
+ mit.current()->setTransferInProgress( false );
+ }
}
+ account->removeJob( mJob ); // remove the associated kio job
}
- account->removeJob( mJob ); // remove the associated kio job
+ account->mJobList.remove( this ); // remove the folderjob
}
- account->mJobList.remove( this ); // remove the folderjob
}
mSrcFolder->close();
}
@@ -270,15 +275,15 @@
void ImapJob::slotGetNextMessage()
{
KMMessage *msg = mMsgList.first();
- KMFolderImap *msgParent = static_cast(msg->storage());
- KMAcctImap *account = msgParent->account();
- if ( msg->UID() == 0 )
+ KMFolderImap *msgParent = msg ? static_cast(msg->storage()) : 0;
+ if ( !msgParent || msg->UID() == 0 )
{
// broken message
emit messageRetrieved( 0 );
deleteLater();
return;
}
+ KMAcctImap *account = msgParent->account();
KURL url = account->getUrl();
QString path = msgParent->imapPath() + ";UID=" + QString::number(msg->UID());
ImapAccountBase::jobData jd;
@@ -391,7 +396,7 @@
dataSize = Util::crlf2lf( (*it).data.data(), dataSize ); // always <=
(*it).data.resize( dataSize );
- // During the construction of the message from the byteArray it does
+ // During the construction of the message from the byteArray it does
// not have a uid. Therefore we have to make sure that no connected
// slots are called, since they would operate on uid == 0.
msg->parent()->storage()->blockSignals( true );
@@ -445,7 +450,7 @@
parent->ignoreJobsForMessage( msg );
int idx = parent->find( msg );
if (idx != -1) parent->removeMsg( idx, true );
- // the removeMsg will unGet the message, which will delete all
+ // the removeMsg will unGet the message, which will delete all
// jobs, including this one
return;
}
--- kdepim/kmail/kmacctcachedimap.cpp 2005/07/26 18:54:59 438982
+++ kdepim/kmail/kmacctcachedimap.cpp 2006/05/06 09:14:35 537923
@@ -381,14 +381,14 @@
//-----------------------------------------------------------------------------
void KMAcctCachedImap::addDeletedFolder( KMFolder* folder )
{
- if ( folder->folderType() != KMFolderTypeCachedImap )
+ if ( !folder || folder->folderType() != KMFolderTypeCachedImap )
return;
KMFolderCachedImap* storage = static_cast(folder->storage());
addDeletedFolder( storage->imapPath() );
kdDebug(5006) << k_funcinfo << storage->imapPath() << endl;
// Add all child folders too
- if( folder && folder->child() ) {
+ if( folder->child() ) {
KMFolderNode *node = folder->child()->first();
while( node ) {
if( !node->isDir() ) {
--- kdepim/kmail/kmcommands.cpp 2006/03/14 20:17:40 518656
+++ kdepim/kmail/kmcommands.cpp 2006/05/06 09:14:35 537923
@@ -1724,7 +1724,7 @@
msg = srcFolder->getMsg(idx);
}
- if (srcFolder &&
+ if (srcFolder && mDestFolder &&
(srcFolder->folderType()== KMFolderTypeImap) &&
(mDestFolder->folderType() == KMFolderTypeImap) &&
(static_cast(srcFolder->storage())->account() ==
@@ -1761,7 +1761,7 @@
}
}
- if (!isMessage && list.isEmpty())
+ if (srcFolder && !isMessage && list.isEmpty())
{
assert(idx != -1);
srcFolder->unGetMsg( idx );