[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdepim-runtime/KDE/4.7] resources/maildir: Watch the root maildir
From: Andras Mantia <amantia () kde ! org>
Date: 2011-09-27 6:24:43
Message-ID: 20110927062443.51C5EA60D1 () git ! kde ! org
[Download RAW message or body]
Git commit c286c4f295eec81c7719c973d3008803692b65e9 by Andras Mantia.
Committed on 17/09/2011 at 07:39.
Pushed by amantia into branch 'KDE/4.7'.
Watch the root maildir and the .NAME.directory folders for changes to recognize there \
newly moved mails and folders. Fix recognizing newly created mails in the maildir \
folders.
BUG: 223476
M +8 -0 resources/maildir/libmaildir/maildir.cpp
M +5 -0 resources/maildir/libmaildir/maildir.h
M +19 -9 resources/maildir/maildirresource.cpp
M +2 -2 resources/maildir/retrieveitemsjob.cpp
http://commits.kde.org/kdepim-runtime/c286c4f295eec81c7719c973d3008803692b65e9
diff --git a/resources/maildir/libmaildir/maildir.cpp \
b/resources/maildir/libmaildir/maildir.cpp index f462974..b090599 100644
--- a/resources/maildir/libmaildir/maildir.cpp
+++ b/resources/maildir/libmaildir/maildir.cpp
@@ -380,6 +380,14 @@ QStringList Maildir::listNew() const
return result;
}
+QString Maildir::subDirPath() const
+{
+ QDir dir( d->path );
+ dir.cdUp();
+ return dir.path() + QDir::separator() + d->subDirPath();
+}
+
+
QStringList Maildir::subFolderList() const
{
diff --git a/resources/maildir/libmaildir/maildir.h \
b/resources/maildir/libmaildir/maildir.h index 6da0347..0dc023c 100644
--- a/resources/maildir/libmaildir/maildir.h
+++ b/resources/maildir/libmaildir/maildir.h
@@ -106,6 +106,11 @@ public:
QStringList listCurrent() const;
/**
+ * Returns the full path to the subdir (the NAME.directory folder ).
+ **/
+ QString subDirPath() const;
+
+ /**
* Return the full path to the file identified by key (it can be either in the \
"new" or "cur" folder
**/
QString findRealKey( const QString& key ) const;
diff --git a/resources/maildir/maildirresource.cpp \
b/resources/maildir/maildirresource.cpp index 08e8d30..7e00f0d 100644
--- a/resources/maildir/maildirresource.cpp
+++ b/resources/maildir/maildirresource.cpp
@@ -337,9 +337,13 @@ void MaildirResource::itemRemoved(const Akonadi::Item & item)
Collection::List MaildirResource::listRecursive( const Collection &root, const \
Maildir &dir ) {
- if ( !dir.isRoot() && mSettings->monitorFilesystem() ) {
+ if ( mSettings->monitorFilesystem() ) {
m_fsWatcher->addDir( dir.path() + QDir::separator() + QLatin1String( "new" ) );
m_fsWatcher->addDir( dir.path() + QDir::separator() + QLatin1String( "cur" ) );
+ m_fsWatcher->addDir( dir.subDirPath() );
+ if ( dir.isRoot() ) {
+ m_fsWatcher->addDir( dir.path() );
+ }
}
Collection::List list;
@@ -567,15 +571,24 @@ bool MaildirResource::ensureSaneConfiguration()
}
void MaildirResource::slotDirChanged(const QString& dir)
-{
- qDebug()<< Q_FUNC_INFO << dir;
-
+{
QFileInfo fileInfo(dir);
if (fileInfo.isFile()) {
slotFileChanged(dir);
return;
}
+ if (dir == mSettings->path() ) {
+ synchronizeCollectionTree();
+ synchronizeCollection( Collection::root().id() );
+ return;
+ }
+
+ if ( dir.endsWith( QLatin1String( ".directory") ) ) {
+ synchronizeCollectionTree(); //might be too much, but this is not a common case \
anyway + return;
+ }
+
QDir d( dir );
if ( !d.cdUp() )
return;
@@ -589,7 +602,7 @@ void MaildirResource::slotDirChanged(const QString& dir)
kDebug() << "unable to find collection for path" << dir;
return;
}
-
+
CollectionFetchJob *job = new CollectionFetchJob( col, \
Akonadi::CollectionFetchJob::Base, this ); connect( job, SIGNAL(result(KJob*)), \
SLOT(fsWatchDirFetchResult(KJob*)) ); }
@@ -604,7 +617,6 @@ void MaildirResource::fsWatchDirFetchResult(KJob* job)
if ( cols.isEmpty() )
return;
- qDebug() << "Request collection sync";
synchronizeCollection( cols.first().id() );
}
@@ -622,9 +634,7 @@ void MaildirResource::slotFileChanged( const QString& fileName )
const Maildir md( path );
if ( !md.isValid() )
return;
-
- qDebug() << "md valid";
-
+
const Collection col = collectionForMaildir( md );
if ( col.remoteId().isEmpty() ) {
kDebug() << "unable to find collection for path" << fileInfo.path();
diff --git a/resources/maildir/retrieveitemsjob.cpp \
b/resources/maildir/retrieveitemsjob.cpp index 8623db7..cddb819 100644
--- a/resources/maildir/retrieveitemsjob.cpp
+++ b/resources/maildir/retrieveitemsjob.cpp
@@ -85,7 +85,7 @@ void RetrieveItemsJob::processEntry(qint64 index)
QString entry = m_entryList[index];
const qint64 currentMtime = m_maildir.lastModified( entry ).toMSecsSinceEpoch();
m_highestMtime = qMax( m_highestMtime, currentMtime );
- if ( currentMtime <= m_previousMtime ) { // old, we got this one already
+ if ( currentMtime <= m_previousMtime && m_localItems.contains(entry)) { // old, we \
got this one already m_localItems.remove( entry );
processEntry(index+1);
return;
@@ -129,7 +129,7 @@ void RetrieveItemsJob::entriesProcessed()
}
// update mtime
- if ( m_highestMtime != m_previousMtime ) {
+ if ( m_highestMtime != m_previousMtime ) {
Akonadi::Collection newCol( m_collection );
newCol.setRemoteRevision( QString::number( m_highestMtime ) );
Akonadi::CollectionModifyJob *job = new Akonadi::CollectionModifyJob( newCol, \
transaction() );
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic