[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kmail-devel
Subject:    Re: Help needed for fixing bug 114985
From:       Andreas Gungl <a.gungl () gmx ! de>
Date:       2005-11-22 12:54:06
Message-ID: 200511221354.14028 () gungl-dd ! de
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


Am Dienstag, 15. November 2005 18:08 schrieb Andreas Gungl:
> In the 3.5 branch, there I try to find a solution for
> http://bugs.kde.org/show_bug.cgi?id=114985 which in simple words means to
> care for subfolders during a move of a folder.

Find attached the patch which implements the moving of nested folders from a 
local to a disconnected IMAP account. Moving into the opposite direction is 
not supported yet (i.e. still fails and you will loose your messages in the 
subfolders).

> I attach what I've implemented so far. However, I can't find a way to add a
> proper KMFolderDir to a folder when it has been moved to an dIMAP account.
> Can someone give me a hint?
> The problem is in RenameJob::slotMoveSubFolders where
> mNewFolder->createChildFolder(); creates a child which seems to have the
> standard type later on. Instead, it should have the CachedIMAP type.

createChildFolder() was incomplete (and IMO it is still after applying my 
patch). It handles only some of the folder types properly.


Anyway, KMail development for KDE 3.5 seems to be nearly dead ATM. I wonder if 
it's worth putting effort into 3.5 at all. Wouldn't it be better to 
concentrate on KDE 4 only?

Regards,
Andreas

["kmail-foldermove-dimap.diff" (text/x-diff)]

Index: renamejob.cpp
===================================================================
--- renamejob.cpp	(revision 481276)
+++ renamejob.cpp	(working copy)
@@ -58,6 +58,7 @@
    mStorage( storage ), mNewParent( newParent ),
    mNewName( newName ), mNewFolder( 0 )
 {
+  mStorageTempOpened = 0;
   mOldName = storage->name();
   if ( storage->folderType() == KMFolderTypeImap ) {
     mOldImapPath = static_cast<KMFolderImap*>(storage)->imapPath();
@@ -131,7 +132,12 @@
       KMFolderCachedImap* newStorage = static_cast<KMFolderCachedImap*>(mNewFolder->storage());
       KMFolderCachedImap* owner = static_cast<KMFolderCachedImap*>(mNewParent->owner()->storage());
       newStorage->initializeFrom( owner );
-      slotMoveMessages();
+      // move child folders recursive
+      KMFolderDir* child = mStorage->folder()->child();
+      if ( child ) {
+        slotMoveSubFolders( "", true );
+      }
+      else slotMoveMessages();
     } else
     {
       // local
@@ -219,6 +225,8 @@
   mStorage->blockSignals( true );
   // move all messages to the new folder
   QPtrList<KMMsgBase> msgList;
+  if ( !mStorage->isOpened() )
+    mStorageTempOpened = mStorage->open() ? mStorage : 0;
   for ( int i = 0; i < mStorage->count(); i++ )
   {
     KMMsgBase* msgBase = mStorage->getMsgBase( i );
@@ -240,6 +248,10 @@
 void RenameJob::slotMoveCompleted( KMCommand* command )
 {
   kdDebug(5006) << k_funcinfo << (command?command->result():0) << endl;
+  if ( mStorageTempOpened ) {
+    mStorageTempOpened->close();
+    mStorageTempOpened = 0;
+  }
   if ( command ) {
     // just make sure nothing bounces
     disconnect( command, SIGNAL( completed( KMCommand * ) ),
@@ -315,4 +327,27 @@
   delete this;
 }
 
+void RenameJob::slotMoveSubFolders( QString newName, bool success )
+{
+  if ( !success ) {
+      emit renameDone( mNewName, false );
+  } else {
+    KMFolderDir* child = mStorage->folder()->child();
+    if ( child && child->first() )
+    {
+      KMFolderNode* node = child->first();
+      {
+        FolderStorage* childStorage = static_cast<KMFolder*>(node)->storage();
+        if ( !mNewFolder->child() )
+          mNewFolder->createChildFolder();
+        RenameJob* job = new RenameJob( childStorage, childStorage->name(), mNewFolder->child() );
+        connect( job, SIGNAL( renameDone( QString, bool ) ),
+            this, SLOT( slotMoveSubFolders( QString, bool ) ) );
+        job->start();
+      }
+    }
+    else slotMoveMessages();
+  }
+}
+
 #include "renamejob.moc"
Index: renamejob.h
===================================================================
--- renamejob.h	(revision 481276)
+++ renamejob.h	(working copy)
@@ -73,12 +73,15 @@
   /** All messages are moved so remove the original folder */
   void slotMoveCompleted( KMCommand *command );
 
+  void slotMoveSubFolders( QString newName, bool success );
+
 signals:
   /** Emitted when the job is done, check the success bool */
   void renameDone( QString newName, bool success );
 
 protected:
   FolderStorage* mStorage;
+  FolderStorage* mStorageTempOpened;
   KMFolderDir* mNewParent;
   QString mNewName;
   QString mNewImapPath;
Index: kmfolder.cpp
===================================================================
--- kmfolder.cpp	(revision 481276)
+++ kmfolder.cpp	(working copy)
@@ -263,8 +263,13 @@
     }
   }
 
-  mChild = new KMFolderDir( this, parent(), childName,
-    (folderType() == KMFolderTypeImap) ? KMImapDir : KMStandardDir);
+  KMFolderDirType newType = KMStandardDir;
+  if( folderType() == KMFolderTypeCachedImap )
+    newType = KMDImapDir;
+  else if( folderType() == KMFolderTypeImap )
+    newType = KMImapDir;
+
+  mChild = new KMFolderDir( this, parent(), childName, newType );
   if( !mChild )
     return 0;
   mChild->reload();

[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