19 #include "folderutil.h"
22 #include "kmfolderimap.h"
23 #include "kmfoldercachedimap.h"
24 #include "kmfoldermgr.h"
26 #include <tdemessagebox.h>
28 using namespace KMail;
29 using namespace FolderUtil;
32 const TQString &folderName,
const TQString &namespaceName,
33 KMFolderType localFolderType )
37 if ( parentFolder && parentFolder->
folderType() == KMFolderTypeImap ) {
38 KMFolderImap* selectedStorage =
static_cast<KMFolderImap*
>( parentFolder->storage() );
39 KMAcctImap *anAccount = selectedStorage->account();
41 if (anAccount->makeConnection() == ImapAccountBase::Connected) {
42 newFolder = kmkernel->imapFolderMgr()->createFolder( folderName,
false, KMFolderTypeImap, parentDir );
44 TQString imapPath, parent;
45 if ( !namespaceName.isEmpty() ) {
47 parent = anAccount->addPathToNamespace( namespaceName );
48 imapPath = anAccount->createImapPath( parent, folderName );
50 imapPath = anAccount->createImapPath( selectedStorage->imapPath(), folderName );
52 KMFolderImap* newStorage =
static_cast<KMFolderImap*
>( newFolder->storage() );
53 selectedStorage->createFolder(folderName, parent);
54 newStorage->initializeFrom( selectedStorage, imapPath, TQString() );
55 static_cast<KMFolderImap*
>(parentFolder->storage())->setAccount( selectedStorage->account() );
59 }
else if ( parentFolder && parentFolder->
folderType() == KMFolderTypeCachedImap ) {
60 newFolder = kmkernel->dimapFolderMgr()->createFolder( folderName,
false, KMFolderTypeCachedImap,
63 KMFolderCachedImap* selectedStorage =
static_cast<KMFolderCachedImap*
>( parentFolder->storage() );
64 KMFolderCachedImap* newStorage =
static_cast<KMFolderCachedImap*
>( newFolder->storage() );
65 newStorage->initializeFrom( selectedStorage );
66 if ( !namespaceName.isEmpty() ) {
68 TQString path = selectedStorage->account()->createImapPath(
69 namespaceName, folderName );
70 newStorage->setImapPathForCreation( path );
76 Q_ASSERT( localFolderType == KMFolderTypeMaildir || localFolderType == KMFolderTypeMbox );
77 newFolder = kmkernel->folderMgr()->createFolder( folderName,
false, localFolderType,
85 void KMail::FolderUtil::deleteFolder(
KMFolder *folderToDelete, TQWidget *parent )
89 for ( AccountList::Iterator it (folderToDelete->acctList()->begin() ),
90 end( folderToDelete->acctList()->end() ); it != end; ++it ) {
91 (*it)->setFolder( kmkernel->inboxFolder() );
92 KMessageBox::information(parent,
93 i18n(
"<qt>The folder you deleted was associated with the account "
94 "<b>%1</b> which delivered mail into it. The folder the account "
95 "delivers new mail into was reset to the main Inbox folder.</qt>").arg( (*it)->name()));
98 if (folderToDelete->
folderType() == KMFolderTypeImap)
99 kmkernel->imapFolderMgr()->remove(folderToDelete);
100 else if (folderToDelete->
folderType() == KMFolderTypeCachedImap) {
102 KMFolderCachedImap* storage =
static_cast<KMFolderCachedImap*
>( folderToDelete->storage() );
103 KMAcctCachedImap* acct = storage->account();
105 acct->addDeletedFolder( folderToDelete );
107 kmkernel->dimapFolderMgr()->remove(folderToDelete);
109 else if (folderToDelete->
folderType() == KMFolderTypeSearch)
110 kmkernel->searchFolderMgr()->remove(folderToDelete);
112 kmkernel->folderMgr()->remove(folderToDelete);
KMail list that manages the contents of one directory that may contain folders and/or other directori...
KMFolderType folderType() const
Returns the type of this folder.
bool hasAccounts() const
Returns TRUE if accounts are associated with this folder.