[prev in list] [next in list] [prev in thread] [next in thread]
List: kmail-devel
Subject: [PATCH] Possible solution to vendor annotations support
From: Mario Teijeiro Otero <emeteo () escomposlinux ! org>
Date: 2004-12-18 14:56:50
Message-ID: 200412181556.56512.emeteo () escomposlinux ! org
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
[Attachment #4 (multipart/mixed)]
Hi,
With tha patch, kmail test to write a annotation
"/vendor/kolab/folder-test" with value.shared=true,
If the test is successfull nothing happen. If
the test has an error, setHasNoAnnotationSupport() is called.
This test is only checked one time for conection.
Regards
["kmail_testannotations.patch" (text/x-diff)]
? cppcomplete.tags
Index: kmacctcachedimap.cpp
===================================================================
RCS file: /home/kde/kdepim/kmail/kmacctcachedimap.cpp,v
retrieving revision 1.83
diff -u -p -r1.83 kmacctcachedimap.cpp
--- kmacctcachedimap.cpp 23 Oct 2004 09:07:48 -0000 1.83
+++ kmacctcachedimap.cpp 18 Dec 2004 14:45:02 -0000
@@ -59,7 +59,7 @@ using KMail::SieveConfig;
KMAcctCachedImap::KMAcctCachedImap( KMAcctMgr* aOwner,
const QString& aAccountName, uint id )
: KMail::ImapAccountBase( aOwner, aAccountName, id ), mFolder( 0 ),
- mProgressDialogEnabled( true )
+ mProgressDialogEnabled( true ), mAnnotattionCheckPassed(false)
{
// Never EVER set this for the cached IMAP account
mAutoExpunge = false;
Index: kmacctcachedimap.h
===================================================================
RCS file: /home/kde/kdepim/kmail/kmacctcachedimap.h,v
retrieving revision 1.47
diff -u -p -r1.47 kmacctcachedimap.h
--- kmacctcachedimap.h 7 Oct 2004 11:27:31 -0000 1.47
+++ kmacctcachedimap.h 18 Dec 2004 14:45:02 -0000
@@ -174,6 +174,10 @@ public:
* Returns the root folder of this account
*/
virtual FolderStorage* const rootFolder() const;
+
+ /** return if the account passed the annotation test */
+ bool annotattionCheckPassed(){ return mAnnotattionCheckPassed;};
+ void setAnnotattionCheckPassed( bool a ){ mAnnotattionCheckPassed = a; };
protected:
friend class KMAcctMgr;
@@ -198,6 +202,7 @@ private:
QStringList mDeletedFolders; // folders deleted in this session
QStringList mPreviouslyDeletedFolders; // folders deleted in a previous session
QMap<QString, RenamedFolder> mRenamedFolders;
+ bool mAnnotattionCheckPassed;
};
#endif /*KMAcctCachedImap_h*/
Index: kmfoldercachedimap.cpp
===================================================================
RCS file: /home/kde/kdepim/kmail/kmfoldercachedimap.cpp,v
retrieving revision 1.158
diff -u -p -r1.158 kmfoldercachedimap.cpp
--- kmfoldercachedimap.cpp 11 Dec 2004 11:20:36 -0000 1.158
+++ kmfoldercachedimap.cpp 18 Dec 2004 14:45:03 -0000
@@ -526,6 +526,7 @@ QString KMFolderCachedImap::state2String
{
switch( state ) {
case SYNC_STATE_INITIAL: return "SYNC_STATE_INITIAL";
+ case SYNC_STATE_TEST_ANNOTATIONS: return "SYNC_STATE_TEST_ANNOTATIONS";
case SYNC_STATE_PUT_MESSAGES: return "SYNC_STATE_PUT_MESSAGES";
case SYNC_STATE_UPLOAD_FLAGS: return "SYNC_STATE_UPLOAD_FLAGS";
case SYNC_STATE_CREATE_SUBFOLDERS: return "SYNC_STATE_CREATE_SUBFOLDERS";
@@ -613,6 +614,7 @@ void KMFolderCachedImap::serverSyncInter
emit folderComplete(this, FALSE);
break;
} else if ( cs == ImapAccountBase::Connecting ) {
+ mAccount->setAnnotattionCheckPassed( false );
// kdDebug(5006) << "makeConnection said Connecting, waiting for signal." << endl;
newState( mProgress, i18n("Connecting to %1").arg( mAccount->host() ) );
// We'll wait for the connectionResult signal from the account.
@@ -626,11 +628,12 @@ void KMFolderCachedImap::serverSyncInter
// Fall through to next state
}
}
+
case SYNC_STATE_GET_USERRIGHTS:
//kdDebug(5006) << "===== Syncing " << ( mImapPath.isEmpty() ? label() : mImapPath ) << endl;
- mSyncState = SYNC_STATE_RENAME_FOLDER;
+ mSyncState = SYNC_STATE_TEST_ANNOTATIONS;
if( !noContent() && mAccount->hasACLSupport() ) {
// Check the user's own rights. We do this every time in case they changed.
@@ -641,6 +644,33 @@ void KMFolderCachedImap::serverSyncInter
break;
}
+ #define KOLAB_FOLDERTEST "/vendor/kolab/folder-test"
+ case SYNC_STATE_TEST_ANNOTATIONS:
+ mSyncState = SYNC_STATE_RENAME_FOLDER;
+ // The first folder with user rights to write annotations
+ if( !mAccount->annotattionCheckPassed() &&
+ ( mUserRights <= 0 || ( mUserRights & ACLJobs::Administer ) )
+ ){
+ newState( mProgress, i18n("Checking annotattion support"));
+
+ KURL url = mAccount->getUrl();
+ url.setPath( imapPath() );
+ KMail::AnnotationList annotations; // to be set
+
+ KMail::AnnotationAttribute attr( KOLAB_FOLDERTEST, "value.shared", "true" );
+ annotations.append( attr );
+
+ kdDebug(5006) << "Setting test attribute to "<< url << endl;
+ KIO::Job* job = AnnotationJobs::multiSetAnnotation( mAccount->slave(),
+ url, annotations );
+ ImapAccountBase::jobData jd( url.url(), folder() );
+ jd.cancellable = true; // we can always do so later
+ mAccount->insertJob(job, jd);
+ connect(job, SIGNAL(result(KIO::Job *)),
+ SLOT(slotTestAnnotationResult(KIO::Job *)));
+ break;
+ }
+
case SYNC_STATE_RENAME_FOLDER:
{
mSyncState = SYNC_STATE_CHECK_UIDVALIDITY;
@@ -1921,6 +1951,25 @@ KMFolderCachedImap::slotAnnotationChange
}
}
+void KMFolderCachedImap::slotTestAnnotationResult(KIO::Job *job)
+{
+ KMAcctCachedImap::JobIterator it = mAccount->findJob(job);
+ Q_ASSERT( it != mAccount->jobsEnd() );
+ if ( it == mAccount->jobsEnd() ) return; // Shouldn't happen
+ Q_ASSERT( (*it).parent == folder() );
+ if ( (*it).parent != folder() ) return; // Shouldn't happen
+
+ mAccount->setAnnotattionCheckPassed( true );
+ if ( job->error() ) {
+ kdDebug(5006) << "Test Annotation was not passed, disabling annotation support" << endl;
+ mAccount->setHasNoAnnotationSupport( );
+ } else {
+ kdDebug(5006) << "Test Annotation was passed OK" << endl;
+ }
+ if (mAccount->slave()) mAccount->removeJob(job);
+ serverSyncInternal();
+}
+
void
KMFolderCachedImap::slotSetAnnotationResult(KIO::Job *job)
{
@@ -1931,9 +1980,9 @@ KMFolderCachedImap::slotSetAnnotationRes
bool cont = true;
if ( job->error() ) {
// Don't show error if the server doesn't support ANNOTATEMORE and this folder only contains mail
- if ( job->error() == KIO::ERR_UNSUPPORTED_ACTION && contentsType() == ContentsTypeMail ) {
+ if ( job->error() == KIO::ERR_UNSUPPORTED_ACTION && contentsType() == ContentsTypeMail )
if (mAccount->slave()) mAccount->removeJob(job);
- } else
+ else
cont = mAccount->handleJobError( job, i18n( "Error while setting annotation: " ) + '\n' );
} else {
if (mAccount->slave()) mAccount->removeJob(job);
Index: kmfoldercachedimap.h
===================================================================
RCS file: /home/kde/kdepim/kmail/kmfoldercachedimap.h,v
retrieving revision 1.69
diff -u -p -r1.69 kmfoldercachedimap.h
--- kmfoldercachedimap.h 12 Nov 2004 09:43:00 -0000 1.69
+++ kmfoldercachedimap.h 18 Dec 2004 14:45:04 -0000
@@ -259,6 +259,7 @@ protected slots:
void slotConnectionResult( int errorCode, const QString& errorMsg );
void slotCheckUidValidityResult( KMail::FolderJob* job );
+ void slotTestAnnotationResult(KIO::Job *job);
void slotGetAnnotationResult( KIO::Job* );
void slotSetAnnotationResult(KIO::Job *job);
void slotReceivedUserRights( KMFolder* );
@@ -336,6 +337,7 @@ private:
/** State variable for the synchronization mechanism */
enum {
SYNC_STATE_INITIAL,
+ SYNC_STATE_TEST_ANNOTATIONS,
SYNC_STATE_PUT_MESSAGES,
SYNC_STATE_UPLOAD_FLAGS,
SYNC_STATE_CREATE_SUBFOLDERS,
[Attachment #8 (application/pgp-signature)]
_______________________________________________
KMail developers mailing list
KMail-devel@kde.org
https://mail.kde.org/mailman/listinfo/kmail-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic