enabled Compact This Folder command; implemented MoveFolder(), RenameLeaf() methods

This commit is contained in:
jefft%netscape.com 1999-08-06 13:43:49 +00:00
parent 1f85f838f6
commit 56a02adde8
5 changed files with 129 additions and 1 deletions

View File

@ -153,7 +153,16 @@ public:
nsIUrlListener* aUrlListener,
nsIURI** aURL,
nsISupports* copyState) = 0;
NS_IMETHOD MoveFolder(nsIEventQueue* aClientEventQ,
nsIMsgFolder* srcFolder,
nsIMsgFolder* dstFolder,
nsIUrlListener* urlListener,
nsIURI** aUrl) = 0;
NS_IMETHOD RenameLeaf(nsIEventQueue* aClientEventQ,
nsIMsgFolder* srcFolder,
const char* leafName,
nsIUrlListener* urlListener,
nsIURI** url) = 0;
};

View File

@ -550,6 +550,17 @@ NS_IMETHODIMP nsImapMailFolder::RemoveSubFolder (nsIMsgFolder *which)
return rv;
}
NS_IMETHODIMP nsImapMailFolder::Compact()
{
nsresult rv;
NS_WITH_SERVICE(nsIImapService, imapService, kCImapService, &rv);
if (NS_SUCCEEDED(rv) && imapService)
{
rv = imapService->Expunge(m_eventQueue, this, nsnull, nsnull);
}
return rv;
}
NS_IMETHODIMP nsImapMailFolder::Delete ()
{
nsresult rv = NS_ERROR_FAILURE;

View File

@ -111,6 +111,7 @@ public:
NS_IMETHOD CreateSubfolder(const char *folderName);
NS_IMETHOD RemoveSubFolder (nsIMsgFolder *which);
NS_IMETHOD Compact();
NS_IMETHOD Delete ();
NS_IMETHOD Rename (const char *newName);
NS_IMETHOD Adopt(nsIMsgFolder *srcFolder, PRUint32 *outPos);

View File

@ -144,6 +144,8 @@ nsImapService::SelectFolder(nsIEventQueue * aClientEventQueue,
if (NS_SUCCEEDED(rv) && imapUrl)
{
// nsImapUrl::SetSpec() will set the imap action properly
// rv = imapUrl->SetImapAction(nsIImapUrl::nsImapSelectFolder);
rv = imapUrl->SetImapAction(nsIImapUrl::nsImapSelectFolder);
nsCOMPtr <nsIMsgMailNewsUrl> mailNewsUrl = do_QueryInterface(imapUrl);
@ -1321,6 +1323,101 @@ nsImapService::GetImapConnectionAndLoadUrl(nsIEventQueue* aClientEventQueue,
return rv;
}
NS_IMETHODIMP
nsImapService::MoveFolder(nsIEventQueue* eventQueue, nsIMsgFolder* srcFolder,
nsIMsgFolder* dstFolder,
nsIUrlListener* urlListener, nsIURI** url)
{
NS_ASSERTION(eventQueue && srcFolder && dstFolder,
"Oops ... null pointer");
if (!eventQueue || !srcFolder || !dstFolder)
return NS_ERROR_NULL_POINTER;
nsIImapUrl* imapUrl;
nsString2 urlSpec(eOneByte);
nsresult rv;
rv = CreateStartOfImapUrl(imapUrl, dstFolder, urlSpec);
if (NS_SUCCEEDED(rv) && imapUrl)
{
rv = SetImapUrlSink(dstFolder, imapUrl);
if (NS_SUCCEEDED(rv))
{
char hierarchySeparator = kOnlineHierarchySeparatorUnknown;
nsString2 folderName(eOneByte);
GetFolderName(srcFolder, folderName);
urlSpec.Append("/movefolderhierarchy>");
urlSpec.Append(hierarchySeparator);
urlSpec.Append(folderName.GetBuffer());
urlSpec.Append('>');
folderName.SetLength(0);
GetFolderName(dstFolder, folderName);
urlSpec.Append(hierarchySeparator);
urlSpec.Append(folderName.GetBuffer());
nsCOMPtr<nsIURI> uri = do_QueryInterface(imapUrl, &rv);
if (NS_SUCCEEDED(rv) && uri)
{
rv = uri->SetSpec((char*) urlSpec.GetBuffer());
if (NS_SUCCEEDED(rv))
rv = GetImapConnectionAndLoadUrl(eventQueue, imapUrl,
urlListener, nsnull,
url);
}
}
NS_RELEASE(imapUrl);
}
return rv;
}
NS_IMETHODIMP
nsImapService::RenameLeaf(nsIEventQueue* eventQueue, nsIMsgFolder* srcFolder,
const char* newLeafName, nsIUrlListener* urlListener,
nsIURI** url)
{
NS_ASSERTION(eventQueue && srcFolder && newLeafName && *newLeafName,
"Oops ... [RenameLeaf] null pointers");
if (!eventQueue || !srcFolder || !newLeafName || !*newLeafName)
return NS_ERROR_NULL_POINTER;
nsIImapUrl* imapUrl;
nsString2 urlSpec(eOneByte);
nsresult rv;
rv = CreateStartOfImapUrl(imapUrl, srcFolder, urlSpec);
if (NS_SUCCEEDED(rv) && imapUrl)
{
rv = SetImapUrlSink(srcFolder, imapUrl);
if (NS_SUCCEEDED(rv))
{
char hierarchySeparator = '/';
nsString2 folderName(eOneByte);
GetFolderName(srcFolder, folderName);
urlSpec.Append("/rename>");
urlSpec.Append(hierarchySeparator);
urlSpec.Append(folderName.GetBuffer());
urlSpec.Append('>');
PRInt32 leafNameStart =
folderName.RFindChar('/'); // ** troublesome hierarchyseparator
if (leafNameStart != -1)
folderName.SetLength(leafNameStart+1);
urlSpec.Append(hierarchySeparator);
urlSpec.Append(folderName.GetBuffer());
urlSpec.Append(newLeafName);
nsCOMPtr<nsIURI> uri = do_QueryInterface(imapUrl, &rv);
if (NS_SUCCEEDED(rv) && uri)
{
rv = uri->SetSpec((char*) urlSpec.GetBuffer());
if (NS_SUCCEEDED(rv))
rv = GetImapConnectionAndLoadUrl(eventQueue, imapUrl,
urlListener, nsnull,
url);
} // if (NS_SUCCEEDED(rv) && uri)
} // if (NS_SUCCEEDED(rv))
NS_RELEASE(imapUrl);
} // if (NS_SUCCEEDED(rv) && imapUrl)
return rv;
}
#ifdef HAVE_PORT
/* fetching the headers of RFC822 messages */

View File

@ -149,6 +149,16 @@ public:
nsIUrlListener* aUrlListener,
nsIURI** aURL,
nsISupports* copyState);
NS_IMETHOD MoveFolder(nsIEventQueue* eventQueue,
nsIMsgFolder* srcFolder,
nsIMsgFolder* dstFolder,
nsIUrlListener* urlListener,
nsIURI** url);
NS_IMETHOD RenameLeaf(nsIEventQueue* eventQueue,
nsIMsgFolder* srcFolder,
const char* leafName,
nsIUrlListener* urlListener,
nsIURI** url);
////////////////////////////////////////////////////////////////////////////////////////
// End support of nsIImapService interface
////////////////////////////////////////////////////////////////////////////////////////