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

List:       kmail-devel
Subject:    [Bug 111624] Cannot create folder with disconnected IMAP
From:       Carsten Burghardt <burghardt () kde ! org>
Date:       2005-08-30 20:24:03
Message-ID: 20050830202403.3789.qmail () ktown ! kde ! org
[Download RAW message or body]

------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=111624         
burghardt kde org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From burghardt kde org  2005-08-30 22:24 -------
SVN commit 455223 by burghard:

Use the correct delimiter for disconnected imap. Refactor this stuff a bit to make the creation of
imapPaths easier.
BUGS: 111624


 M  +44 -0     imapaccountbase.cpp  
 M  +14 -1     imapaccountbase.h  
 M  +1 -14     kmfolderimap.cpp  
 M  +3 -3      newfolderdialog.cpp  


--- branches/KDE/3.5/kdepim/kmail/imapaccountbase.cpp #455222:455223
 @ -1263,6 +1263,50  @
     return map;
   }
 
+  //------------------------------------------------------------------------------
+  QString ImapAccountBase::createImapPath( const QString& parent, 
+                                           const QString& folderName )
+  {
+    QString newName = parent;
+    // strip / at the end
+    if ( newName.endsWith("/") ) {
+      newName = newName.left( newName.length() - 1 );
+    }
+    // add correct delimiter
+    QString delim = delimiterForNamespace( parent );
+    // should not happen...
+    if ( delim.isEmpty() ) {
+      delim = "/";
+    }
+    if ( !newName.endsWith( delim ) && !folderName.startsWith( delim ) ) {
+      newName = newName + delim;
+    }
+    newName = newName + folderName;
+    // add / at the end
+    if ( !newName.endsWith("/") ) {
+      newName = newName + "/";
+    }
+
+    return newName;
+  }
+
+  //------------------------------------------------------------------------------
+  QString ImapAccountBase::createImapPath( FolderStorage* parent, 
+                                           const QString& folderName )
+  {
+    QString path;
+    if ( parent->folderType() == KMFolderTypeImap ) {
+      path = static_cast<KMFolderImap*>( parent )->imapPath();
+    } else if ( parent->folderType() == KMFolderTypeCachedImap ) {
+      path = static_cast<KMFolderCachedImap*>( parent )->imapPath();
+    } else {
+      // error
+      return path;
+    }
+    
+    return createImapPath( path, folderName );
+  }
+
 } // namespace KMail
 
 #include "imapaccountbase.moc"
--- branches/KDE/3.5/kdepim/kmail/imapaccountbase.h #455222:455223
 @ -352,8 +352,21  @
       * Returns true if the account has the given capability
       */
      bool hasCapability( const QString& capa ) {
-      return mCapabilities.contains( capa ); } 
+      return mCapabilities.contains( capa ); }
 
+     /**
+      * Create an IMAP path for a parent folder and a foldername
+      * Parent and folder are separated with the delimiter of the account
+      * The path starts and ends with '/' 
+      */
+     QString createImapPath( FolderStorage* parent, const QString& folderName );
+
+     /**
+      * Create an IMAP path for a parent imapPath and a folderName
+      */
+     QString createImapPath( const QString& parent, const QString& folderName );
+
+
   public slots:
     /**
      * Call this to get the namespaces
--- branches/KDE/3.5/kdepim/kmail/kmfolderimap.cpp #455222:455223
 @ -1622,20 +1622,7  @
   }
   KURL url = mAccount->getUrl();
   QString parent = ( parentPath.isEmpty() ? imapPath() : parentPath );
-  if ( parent.endsWith("/") ) {
-    // strip / (which kmail uses this internally)
-    parent = parent.left( parent.length()-1 );
-  }
-  QString delim = mAccount->delimiterForFolder( this );
-  if ( delim.isEmpty() ) {
-    // better be safe
-    delim = "/";
-  }
-  if ( !parent.endsWith(delim) ) {
-    // add the correct delimiter
-    parent += delim;
-  }
-  QString path = parent + name;
+  QString path = mAccount->createImapPath( parent, name );
   if ( askUser ) {
     path += "/;INFO=ASKUSER";
   }
--- branches/KDE/3.5/kdepim/kmail/newfolderdialog.cpp #455222:455223
 @ -250,7 +250,7  @
         if ( mNamespacesComboBox ) {
           // create folder with namespace
           parent = anAccount->addPathToNamespace( mNamespacesComboBox->currentText() );
-          imapPath = anAccount->addPathToNamespace( parent ) + fldName;
+          imapPath = anAccount->createImapPath( parent, fldName );
         }
         KMFolderImap* newStorage = static_cast<KMFolderImap*>( newFolder->storage() );
         selectedStorage->createFolder(fldName, parent); // create it on the server
 @ -267,8 +267,8  @
       newStorage->initializeFrom( selectedStorage );
       if ( mNamespacesComboBox ) {
         // create folder with namespace
-        QString path = selectedStorage->account()->addPathToNamespace(
-            mNamespacesComboBox->currentText() ) + fldName;
+        QString path = selectedStorage->account()->createImapPath( 
+            mNamespacesComboBox->currentText(), fldName );
         newStorage->setImapPathForCreation( path );
       }
       success = true;
_______________________________________________
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