[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdepim/kmail
From: Thomas McGuire <mcguire () kde ! org>
Date: 2009-03-02 13:35:28
Message-ID: 1236000928.551049.21596.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 934167 by tmcguire:
Only update the status of changed messages when syncing cached imap folders,
to speed up folder syncing by a large amount for people with many messages
in their folders.
Thanks to Bonne Eggleston and Jim Hague for the patches!
I slightly modified the patch for config compatibility.
Bonne, please close the review request as submitted.
http://reviewboard.kde.org/r/199/
CCMAIL: bonne@ixum.net
BUG: 151916
M +42 -11 kmfoldercachedimap.cpp
M +11 -5 kmfoldercachedimap.h
--- trunk/KDE/kdepim/kmail/kmfoldercachedimap.cpp #934166:934167
@@ -203,7 +203,8 @@
/*mHoldSyncs( false ),*/
mFolderRemoved( false ),
mRecurse( true ),
- mStatusChangedLocally( false ), mAnnotationFolderTypeChanged( false ),
+ mStatusChangedLocally( false ),
+ mAnnotationFolderTypeChanged( false ),
mIncidencesForChanged( false ),
mSharedSeenFlagsChanged( false ),
mPersonalNamespacesCheckDone( true ),
@@ -307,6 +308,10 @@
KMFolderMaildir::readConfig();
mStatusChangedLocally = group.readEntry( "StatusChangedLocally", false );
+ QStringList uidsChanged = group.readEntry( "UIDStatusChangedLocally", QStringList() );
+ foreach( const QString &uid, uidsChanged ) {
+ mUIDsOfLocallyChangedStatuses.append( uid.toUInt() );
+ }
mAnnotationFolderTypeChanged = group.readEntry( "AnnotationFolderTypeChanged", false );
mIncidencesForChanged = group.readEntry( "IncidencesForChanged", false );
mSharedSeenFlagsChanged = group.readEntry( "SharedSeenFlagsChanged", false );
@@ -314,12 +319,12 @@
mImapPathCreation = group.readEntry("ImapPathCreation");
}
- QStringList uids = group.readEntry( "UIDSDeletedSinceLastSync", QStringList() );
+ QStringList delUids = group.readEntry( "UIDSDeletedSinceLastSync" , QStringList() );
#if MAIL_LOSS_DEBUGGING
kDebug( 5006 ) << "READING IN UIDSDeletedSinceLastSync: " << folder()->prettyUrl() << endl << uids;
#endif
- for ( QStringList::iterator it = uids.begin(); it != uids.end(); ++it ) {
- mDeletedUIDsSinceLastSync.insert( (*it).toULong(), 0);
+ for ( QStringList::iterator it = delUids.begin(); it != delUids.end(); it++ ) {
+ mDeletedUIDsSinceLastSync.insert( (*it).toULong(), 0);
}
}
@@ -336,7 +341,14 @@
configGroup.writeEntry( "NoContent", mNoContent );
configGroup.writeEntry( "ReadOnly", mReadOnly );
configGroup.writeEntry( "FolderAttributes", mFolderAttributes );
- configGroup.writeEntry( "StatusChangedLocally", mStatusChangedLocally );
+
+ // StatusChangedLocally is always false, as we use UIDStatusChangedLocally now
+ configGroup.writeEntry( "StatusChangedLocally", false );
+ QStringList uidsToWrite;
+ foreach( const ulong uid, mUIDsOfLocallyChangedStatuses ) {
+ uidsToWrite.append( QString::number( uid ) );
+ }
+ configGroup.writeEntry( "UIDStatusChangedLocally", uidsToWrite );
if ( !mImapPathCreation.isEmpty() ) {
if ( mImapPath.isEmpty() ) {
configGroup.writeEntry( "ImapPathCreation", mImapPathCreation );
@@ -960,12 +972,13 @@
// Upload flags, unless we know from the ACL that we're not allowed
// to do that or they did not change locally
if ( mUserRights <= 0 || ( mUserRights & KMail::ACLJobs::WriteFlags ) ) {
- if ( mStatusChangedLocally ) {
+ if ( !mUIDsOfLocallyChangedStatuses.isEmpty() || mStatusChangedLocally ) {
uploadFlags();
break;
}
- } else if ( mUserRights & KMail::ACLJobs::WriteSeenFlag ) {
- if ( mStatusChangedLocally ) {
+ }
+ else if ( mUserRights & KMail::ACLJobs::WriteSeenFlag ) {
+ if ( !mUIDsOfLocallyChangedStatuses.isEmpty() || mStatusChangedLocally ) {
uploadSeenFlags();
break;
}
@@ -1441,6 +1454,10 @@
// Either not a valid message or not one that is on the server yet
continue;
}
+ if ( mUIDsOfLocallyChangedStatuses.indexOf( msg->UID() ) < 0 && !mStatusChangedLocally ) {
+ // This message has not had its status changed locally
+ continue;
+ }
QString flags = KMFolderImap::statusToFlags( msg->status(), mPermanentFlags );
// Collect uids for each typem of flags.
@@ -1484,6 +1501,11 @@
// Either not a valid message or not one that is on the server yet
continue;
+ if ( mUIDsOfLocallyChangedStatuses.indexOf( msg->UID() ) < 0 && !mStatusChangedLocally ) {
+ // This message has not had its status changed locally
+ continue;
+ }
+
if ( msg->status().isOld() || msg->status().isRead() )
seenUids.append( msg->UID() );
else
@@ -1541,13 +1563,21 @@
void KMFolderCachedImap::setStatus( int idx, const MessageStatus &status, bool toggle )
{
KMFolderMaildir::setStatus( idx, status, toggle );
- mStatusChangedLocally = true;
+ const KMMsgBase *msg = getMsgBase( idx );
+ Q_ASSERT( msg );
+ if ( msg )
+ mUIDsOfLocallyChangedStatuses.append( msg->UID() );
}
void KMFolderCachedImap::setStatus( QList<int> &ids, const MessageStatus &status, bool toggle )
{
KMFolderMaildir::setStatus( ids, status, toggle );
- mStatusChangedLocally = true;
+ foreach( const int id, ids ) {
+ const KMMsgBase *msg = getMsgBase( id );
+ Q_ASSERT( msg );
+ if ( msg )
+ mUIDsOfLocallyChangedStatuses.append( msg->UID() );
+ }
}
/* Upload new folders to server */
@@ -1904,7 +1934,8 @@
} else {
if ( lastSet ) { // always true here (this comes from online-imap...)
mContentState = imapFinished;
- mStatusChangedLocally = false; // we are up to date again
+ mUIDsOfLocallyChangedStatuses.clear(); // we are up to date again
+ mStatusChangedLocally = false;
}
}
serverSyncInternal();
--- trunk/KDE/kdepim/kmail/kmfoldercachedimap.h #934166:934167
@@ -633,12 +633,18 @@
bool mFolderRemoved;
bool mRecurse;
+ /**
+ * UIDs added by setStatus. Indicates that the client has changed
+ * the status of those mails. The mail flags for changed mails will be
+ * uploaded to the server, overwriting the server's notion of the status
+ * of the mails in this folder.
+ */
+ QList<ulong> mUIDsOfLocallyChangedStatuses;
+
/**
- Set to true by setStatus. Indicates that the client has changed
- the status of at least one mail. The mail flags will therefore be
- uploaded to the server, overwriting the server's notion of the status
- of the mails in this folder.
- */
+ * Same as above, but uploads the flags of all mails, even if not all changed.
+ * Only still here for config compatibility.
+ */
bool mStatusChangedLocally;
/**
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic