From b4d12ce82b8b2169d36b320ca0205bb9cc2bc07d Mon Sep 17 00:00:00 2001 From: Volker Krause Date: Thu, 23 Aug 2007 15:19:35 +0000 Subject: [PATCH] Merged revisions 703856-703887 via svnmerge from https://vkrause@svn.kde.org/home/kde/branches/work/~vkrause/enterprise ........ r703856 | vkrause | 2007-08-23 14:57:25 +0200 (Thu, 23 Aug 2007) | 2 lines Add migration infrastructure to transfer local flags to the server. ........ r703887 | vkrause | 2007-08-23 16:34:57 +0200 (Thu, 23 Aug 2007) | 5 lines Configuration update script to trigger migration of local IMAP flags to the server. This should solve a regression due to the recent changes to store the seen flag on the server also for read-only folders where all local flags were overwritten. ........ svn path=/branches/kdepim/enterprise/kdepim/; revision=703903 --- Makefile.am | 3 ++- kmail-3.5-trigger-flag-migration.pl | 39 +++++++++++++++++++++++++++++ kmail.upd | 7 +++++- kmfolderimap.cpp | 19 +++++++++++--- kmfolderimap.h | 8 +++++- kmstartup.cpp | 3 ++- 6 files changed, 72 insertions(+), 7 deletions(-) create mode 100644 kmail-3.5-trigger-flag-migration.pl diff --git a/Makefile.am b/Makefile.am index 5d8d28e24..d3ac69d98 100644 --- a/Makefile.am +++ b/Makefile.am @@ -191,7 +191,8 @@ update_SCRIPTS = upgrade-transport.pl kmail-pgpidentity.pl \ kmail-3.3-misc.pl \ kmail-3.3b1-misc.pl \ kmail-3.4-misc.pl \ - kmail-3.4.1-update-status-filters.pl + kmail-3.4.1-update-status-filters.pl \ + kmail-3.5-trigger-flag-migration.pl confdir = $(kde_confdir) conf_DATA = kmail.antispamrc kmail.antivirusrc diff --git a/kmail-3.5-trigger-flag-migration.pl b/kmail-3.5-trigger-flag-migration.pl new file mode 100644 index 000000000..809a611a1 --- /dev/null +++ b/kmail-3.5-trigger-flag-migration.pl @@ -0,0 +1,39 @@ +#!/usr/bin/perl +# +# Copyright (c) 2007 Volker Krause +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# 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, US +# + +$currentGroup = ""; + +$source = $ARGV[0]; + +while () { + chomp; + next if /^$/; + next if /^\#/; + + # recognize groups: + if ( /^\[(.+)\]$/ ) { + $currentGroup = $_; + next; + }; + + ($key,$value) = split /=/; + next if $key eq ""; + + if ( $currentGroup =~ /^\[Folder/ ) { + if( ($key eq "UploadAllFlags" or $key eq "StatusChangedLocally") and not $value eq "true" ) { + $value = "true"; + print "#DELETE $currentGroup $key\n"; + print "$currentGroup\n$key=$value\n" + } + } +} diff --git a/kmail.upd b/kmail.upd index 2c5494683..2b912b59d 100644 --- a/kmail.upd +++ b/kmail.upd @@ -139,7 +139,7 @@ Script=kmail-3.3b1-misc.pl,perl Id=3.4 File=kmailrc Script=kmail-3.4-misc.pl,perl -# Remove the MenuBar key so that menu bar will be visible in the separate reader window +# Remove the MenuBar key so that menu bar will be visible in the separate reader window Id=3.4a File=kmailrc Group=Separate Reader Window @@ -163,6 +163,11 @@ Id=3.5.4 File=kmailrc Group=FolderSelectionDialog RemoveKey=Size +# Trigger migration of all local imap flags to the server +Id=3.5.7-imap-flag-migration +Options=overwrite +File=kmailrc +Script=kmail-3.5-trigger-flag-migration.pl,perl # # Important notice: # If you add updates here, keep this text below them. diff --git a/kmfolderimap.cpp b/kmfolderimap.cpp index 176efb891..fde248388 100644 --- a/kmfolderimap.cpp +++ b/kmfolderimap.cpp @@ -62,7 +62,8 @@ using KMail::RenameJob; #include KMFolderImap::KMFolderImap(KMFolder* folder, const char* aName) - : KMFolderMbox(folder, aName) + : KMFolderMbox(folder, aName), + mUploadAllFlags( false ) { mContentState = imapNoInformation; mSubfolderState = imapNoInformation; @@ -205,6 +206,7 @@ void KMFolderImap::readConfig() } mNoContent = config->readBoolEntry("NoContent", false); mReadOnly = config->readBoolEntry("ReadOnly", false); + mUploadAllFlags = config->readBoolEntry( "UploadAllFlags", true ); KMFolderMbox::readConfig(); } @@ -219,6 +221,7 @@ void KMFolderImap::writeConfig() config->writeEntry("ImapPath", mImapPath); config->writeEntry("NoContent", mNoContent); config->writeEntry("ReadOnly", mReadOnly); + config->writeEntry( "UploadAllFlags", mUploadAllFlags ); KMFolderMbox::writeConfig(); } @@ -1851,9 +1854,19 @@ void KMFolderImap::setStatus(int idx, KMMsgStatus status, bool toggle) setStatus(ids, status, toggle); } -void KMFolderImap::setStatus(QValueList& ids, KMMsgStatus status, bool toggle) +void KMFolderImap::setStatus(QValueList& _ids, KMMsgStatus status, bool toggle) { - FolderStorage::setStatus(ids, status, toggle); + FolderStorage::setStatus(_ids, status, toggle); + QValueList ids; + if ( mUploadAllFlags ) { + kdDebug(5006) << k_funcinfo << "Migrating all flags to the server" << endl; + ids.clear(); + for ( int i = 0; i < count(); ++i ) + ids << i; + mUploadAllFlags = false; + } else { + ids = _ids; + } /* The status has been already set in the local index. Update the flags on * the server. To avoid doing that for each message individually, group them diff --git a/kmfolderimap.h b/kmfolderimap.h index dcce4f56d..12b5d592b 100644 --- a/kmfolderimap.h +++ b/kmfolderimap.h @@ -187,7 +187,7 @@ public: /** * Change the status of several messages indicated by @p ids */ - virtual void setStatus(QValueList& ids, KMMsgStatus status, bool toggle); + virtual void setStatus(QValueList& _ids, KMMsgStatus status, bool toggle); /** generates sets of uids */ static QStringList makeSets( QValueList&, bool sort = true); @@ -530,6 +530,12 @@ private: ProgressItem *mAddMessageProgressItem; // to-be-added folders QStringList mFoldersPendingCreation; + + // push all flags to the server instead of just the changed once + // when doing a flag change the next time + // this is needed for migrating local flags from the time where we didn't + // have the ability to store them on the server + bool mUploadAllFlags; }; #endif // kmfolderimap_h diff --git a/kmstartup.cpp b/kmstartup.cpp index f1bde9fbf..d1967a3e4 100644 --- a/kmstartup.cpp +++ b/kmstartup.cpp @@ -116,7 +116,8 @@ void checkConfigUpdates() { "3.4a", "3.4b", "3.4.1", - "3.5.4" + "3.5.4", + "3.5.7-imap-flag-migration" }; static const int numUpdates = sizeof updates / sizeof *updates; // Warning: do not remove entries in the above array, or the update-level check below will break