mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Add GetPath to nsIMsgFolder.
This commit is contained in:
parent
ea7bde4716
commit
8c5fcdb576
@ -20,9 +20,9 @@
|
||||
#include "nsIFolder.idl"
|
||||
#include "nsIMsgThread.idl"
|
||||
#include "nsIMsgIncomingServer.idl"
|
||||
#include "nsIFileSpec.idl"
|
||||
|
||||
%{ C++
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsIMessage.h"
|
||||
#include "nsITransactionManager.h"
|
||||
@ -136,6 +136,8 @@ interface nsIMsgFolder : nsIFolder {
|
||||
readonly attribute wstring NewMessagesNotificationDescription;
|
||||
readonly attribute nsIMsgFolder RootFolder;
|
||||
readonly attribute nsIMsgDatabase msgDatabase;
|
||||
|
||||
readonly attribute nsIFileSpec Path;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1378,6 +1378,12 @@ nsMsgFolder::GetMsgDatabase(nsIMsgDatabase** aMsgDatabase)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgFolder::GetPath(nsIFileSpec * *aPath)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult nsMsgFolder::NotifyPropertyChanged(char *property, char *oldValue, char* newValue)
|
||||
{
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
|
@ -276,7 +276,8 @@ public:
|
||||
NS_IMETHOD GetNewMessagesNotificationDescription(PRUnichar * *adescription);
|
||||
|
||||
NS_IMETHOD GetRootFolder(nsIMsgFolder * *aRootFolder);
|
||||
NS_IMETHOD GetMsgDatabase(nsIMsgDatabase** aMsgDatabase);
|
||||
NS_IMETHOD GetMsgDatabase(nsIMsgDatabase** aMsgDatabase);
|
||||
NS_IMETHOD GetPath(nsIFileSpec * *aPath);
|
||||
|
||||
protected:
|
||||
nsresult NotifyPropertyChanged(char *property, char* oldValue, char* newValue);
|
||||
|
@ -161,18 +161,20 @@ NS_IMETHODIMP nsImapMailFolder::QueryInterface(REFNSIID aIID, void** aInstancePt
|
||||
return nsMsgFolder::QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImapMailFolder::GetPathName(nsNativeFileSpec& aPathName)
|
||||
NS_IMETHODIMP nsImapMailFolder::GetPath(nsIFileSpec** aPathName)
|
||||
{
|
||||
nsresult rv;
|
||||
if (! m_pathName)
|
||||
{
|
||||
m_pathName = new nsNativeFileSpec("");
|
||||
if (! m_pathName)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult rv = nsImapURI2Path(kImapRootURI, mURI, *m_pathName);
|
||||
rv = nsImapURI2Path(kImapRootURI, mURI, *m_pathName);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
aPathName = *m_pathName;
|
||||
rv = NS_NewFileSpecWithSpec(*m_pathName, aPathName);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -301,9 +303,13 @@ NS_IMETHODIMP nsImapMailFolder::GetSubFolders(nsIEnumerator* *result)
|
||||
if (!m_initialized)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsNativeFileSpec path;
|
||||
rv = GetPathName(path);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIFileSpec> pathSpec;
|
||||
rv = GetPath(getter_AddRefs(pathSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsFileSpec path;
|
||||
rv = pathSpec->GetFileSpec(&path);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// host directory does not need .sbd tacked on
|
||||
if (mDepth > 0)
|
||||
@ -384,8 +390,12 @@ nsresult nsImapMailFolder::GetDatabase()
|
||||
nsresult folderOpen = NS_OK;
|
||||
if (!mDatabase)
|
||||
{
|
||||
nsNativeFileSpec path;
|
||||
nsresult rv = GetPathName(path);
|
||||
nsCOMPtr<nsIFileSpec> pathSpec;
|
||||
nsresult rv = GetPath(getter_AddRefs(pathSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsFileSpec path;
|
||||
rv = pathSpec->GetFileSpec(&path);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIMsgDatabase> mailDBFactory;
|
||||
@ -473,11 +483,14 @@ NS_IMETHODIMP nsImapMailFolder::CreateSubfolder(const char *folderName)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsFileSpec path;
|
||||
//Get a directory based on our current path.
|
||||
rv = GetPathName(path);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
nsCOMPtr<nsIFileSpec> pathSpec;
|
||||
rv = GetPath(getter_AddRefs(pathSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsFileSpec path;
|
||||
rv = pathSpec->GetFileSpec(&path);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = CreateDirectoryForFolder(path);
|
||||
if(NS_FAILED(rv))
|
||||
@ -843,9 +856,15 @@ nsresult nsImapMailFolder::GetDBFolderInfoAndDB(
|
||||
nsresult rv = nsComponentManager::CreateInstance(kCImapDB, nsnull, nsIMsgDatabase::GetIID(), getter_AddRefs(mailDBFactory));
|
||||
if (NS_SUCCEEDED(rv) && mailDBFactory)
|
||||
{
|
||||
nsNativeFileSpec dbName;
|
||||
|
||||
GetPathName(dbName);
|
||||
nsCOMPtr<nsIFileSpec> pathSpec;
|
||||
rv = GetPath(getter_AddRefs(pathSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsFileSpec dbName;
|
||||
rv = pathSpec->GetFileSpec(&dbName);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
openErr = mailDBFactory->Open(dbName, PR_FALSE, (nsIMsgDatabase **) &mailDB, PR_FALSE);
|
||||
}
|
||||
|
||||
@ -1107,9 +1126,14 @@ NS_IMETHODIMP nsImapMailFolder::UpdateImapMailboxInfo(
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIMsgDatabase> mailDBFactory;
|
||||
nsNativeFileSpec dbName;
|
||||
|
||||
GetPathName(dbName);
|
||||
nsCOMPtr<nsIFileSpec> pathSpec;
|
||||
rv = GetPath(getter_AddRefs(pathSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsFileSpec dbName;
|
||||
rv = pathSpec->GetFileSpec(&dbName);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kCImapDB, nsnull,
|
||||
nsIMsgDatabase::GetIID(),
|
||||
|
@ -59,8 +59,6 @@ public:
|
||||
virtual ~nsImapMailFolder();
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
// nsIMsgImapMailFolder methods
|
||||
NS_IMETHOD GetPathName(nsNativeFileSpec& aPathName);
|
||||
|
||||
// nsICollection methods:
|
||||
NS_IMETHOD Enumerate(nsIEnumerator* *result);
|
||||
@ -112,6 +110,7 @@ public:
|
||||
**message);
|
||||
NS_IMETHOD GetNewMessages();
|
||||
|
||||
NS_IMETHOD GetPath(nsIFileSpec** aPathName);
|
||||
// nsIImapMailFolderSink methods
|
||||
// Tell mail master about a discovered imap mailbox
|
||||
NS_IMETHOD PossibleImapMailbox(nsIImapProtocol* aProtocol,
|
||||
|
@ -286,10 +286,13 @@ NS_IMETHODIMP
|
||||
nsMsgLocalMailFolder::GetSubFolders(nsIEnumerator* *result)
|
||||
{
|
||||
if (!mInitialized) {
|
||||
nsFileSpec path;
|
||||
nsresult rv = GetPath(path);
|
||||
nsCOMPtr<nsIFileSpec> pathSpec;
|
||||
nsresult rv = GetPath(getter_AddRefs(pathSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsFileSpec path;
|
||||
rv = pathSpec->GetFileSpec(&path);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
#if 0
|
||||
//Make sure our path isn't the empty path.
|
||||
nsFileSpec emptyPath("");
|
||||
@ -339,8 +342,12 @@ nsresult nsMsgLocalMailFolder::GetDatabase()
|
||||
nsresult rv = NS_OK;
|
||||
if (!mDatabase)
|
||||
{
|
||||
nsNativeFileSpec path;
|
||||
rv = GetPath(path);
|
||||
nsCOMPtr<nsIFileSpec> pathSpec;
|
||||
rv = GetPath(getter_AddRefs(pathSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsFileSpec path;
|
||||
rv = pathSpec->GetFileSpec(&path);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
#if 0
|
||||
@ -413,17 +420,24 @@ nsMsgLocalMailFolder::GetMessages(nsIEnumerator* *result)
|
||||
|
||||
NS_IMETHODIMP nsMsgLocalMailFolder::BuildFolderURL(char **url)
|
||||
{
|
||||
const char *urlScheme = "mailbox:";
|
||||
const char *urlScheme = "mailbox:";
|
||||
|
||||
if(!url)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
if(!url)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsFileSpec path;
|
||||
nsresult rv = GetPath(path);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsAutoString tmpPath((nsFilePath)path, eOneByte);
|
||||
*url = PR_smprintf("%s%s", urlScheme, tmpPath.GetBuffer());
|
||||
return NS_OK;
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIFileSpec> pathSpec;
|
||||
rv = GetPath(getter_AddRefs(pathSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsFileSpec path;
|
||||
rv = pathSpec->GetFileSpec(&path);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsAutoString tmpPath((nsFilePath)path, eOneByte);
|
||||
*url = PR_smprintf("%s%s", urlScheme, tmpPath.GetBuffer());
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
@ -435,9 +449,12 @@ nsresult nsMsgLocalMailFolder::CreateDirectoryForFolder(nsFileSpec &path)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
rv = GetPath(path);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
nsCOMPtr<nsIFileSpec> pathSpec;
|
||||
rv = GetPath(getter_AddRefs(pathSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = pathSpec->GetFileSpec(&path);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if(!path.IsDirectory())
|
||||
{
|
||||
@ -550,8 +567,13 @@ NS_IMETHODIMP nsMsgLocalMailFolder::Delete()
|
||||
mDatabase = null_nsCOMPtr();
|
||||
}
|
||||
|
||||
nsFileSpec path;
|
||||
rv = GetPath(path);
|
||||
nsCOMPtr<nsIFileSpec> pathSpec;
|
||||
rv = GetPath(getter_AddRefs(pathSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsFileSpec path;
|
||||
rv = pathSpec->GetFileSpec(&path);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
//Clean up .sbd folder if it exists.
|
||||
if(NS_SUCCEEDED(rv))
|
||||
@ -995,18 +1017,20 @@ NS_IMETHODIMP nsMsgLocalMailFolder::GetRememberedPassword(char ** password)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgLocalMailFolder::GetPath(nsFileSpec& aPathName)
|
||||
NS_IMETHODIMP nsMsgLocalMailFolder::GetPath(nsIFileSpec ** aPathName)
|
||||
{
|
||||
nsresult rv;
|
||||
if (! mPath) {
|
||||
mPath = new nsNativeFileSpec("");
|
||||
mPath = new nsFileSpec("");
|
||||
if (! mPath)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult rv = nsLocalURI2Path(kMailboxRootURI, mURI, *mPath);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
aPathName = *mPath;
|
||||
return NS_OK;
|
||||
rv = NS_NewFileSpecWithSpec(*mPath, aPathName);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
// OK, this is kind of silly, but for now, we'll just tack the subFolderName
|
||||
@ -1181,8 +1205,15 @@ NS_IMETHODIMP nsMsgLocalMailFolder::BeginCopy(nsIMessage *message)
|
||||
else
|
||||
return NS_MSG_FOLDER_BUSY;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIFileSpec> pathSpec;
|
||||
rv = GetPath(getter_AddRefs(pathSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsFileSpec path;
|
||||
GetPath(path);
|
||||
rv = pathSpec->GetFileSpec(&path);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mCopyState = new nsLocalMailCopyState;
|
||||
if(!mCopyState)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -101,7 +101,7 @@ public:
|
||||
NS_IMETHOD GetNewMessages();
|
||||
|
||||
// nsIMsgMailFolder
|
||||
NS_IMETHOD GetPath(nsNativeFileSpec& aPathName);
|
||||
NS_IMETHOD GetPath(nsIFileSpec ** aPathName);
|
||||
|
||||
//nsICopyMessageListener
|
||||
NS_IMETHOD BeginCopy(nsIMessage *message);
|
||||
|
@ -462,9 +462,14 @@ NS_IMETHODIMP
|
||||
nsMsgNewsFolder::GetSubFolders(nsIEnumerator* *result)
|
||||
{
|
||||
if (!mInitialized) {
|
||||
nsFileSpec path;
|
||||
nsresult rv = GetPath(path);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIFileSpec> pathSpec;
|
||||
rv = GetPath(getter_AddRefs(pathSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsFileSpec path;
|
||||
rv = pathSpec->GetFileSpec(&path);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = CreateSubFolders(path);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
@ -494,8 +499,13 @@ nsresult nsMsgNewsFolder::GetDatabase()
|
||||
{
|
||||
if (!mDatabase)
|
||||
{
|
||||
nsNativeFileSpec path;
|
||||
nsresult rv = GetPath(path);
|
||||
nsCOMPtr<nsIFileSpec> pathSpec;
|
||||
nsresult rv;
|
||||
rv = GetPath(getter_AddRefs(pathSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsFileSpec path;
|
||||
rv = pathSpec->GetFileSpec(&path);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsresult folderOpen = NS_OK;
|
||||
@ -627,8 +637,12 @@ NS_IMETHODIMP nsMsgNewsFolder::BuildFolderURL(char **url)
|
||||
if(!url)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsIFileSpec> pathSpec;
|
||||
nsresult rv = GetPath(getter_AddRefs(pathSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsFileSpec path;
|
||||
nsresult rv = GetPath(path);
|
||||
rv = pathSpec->GetFileSpec(&path);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
#if defined(XP_MAC)
|
||||
nsAutoString tmpPath((nsFilePath)path, eOneByte); //ducarroz: please don't cast a nsFilePath to char* on Mac
|
||||
@ -1046,18 +1060,19 @@ NS_IMETHODIMP nsMsgNewsFolder::GetRememberedPassword(char ** password)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgNewsFolder::GetPath(nsFileSpec& aPathName)
|
||||
NS_IMETHODIMP nsMsgNewsFolder::GetPath(nsIFileSpec** aPathName)
|
||||
{
|
||||
nsresult rv;
|
||||
if (! mPath) {
|
||||
mPath = new nsNativeFileSpec("");
|
||||
if (! mPath)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult rv = nsNewsURI2Path(kNewsRootURI, mURI, *mPath);
|
||||
rv = nsNewsURI2Path(kNewsRootURI, mURI, *mPath);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
aPathName = *mPath;
|
||||
return NS_OK;
|
||||
rv = NS_NewFileSpecWithSpec(*mPath, aPathName);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* this is news, so remember that DeleteMessage is really CANCEL */
|
||||
|
@ -92,8 +92,7 @@ public:
|
||||
NS_IMETHOD CreateMessageFromMsgDBHdr(nsIMsgDBHdr *msgDBHdr, nsIMessage **message);
|
||||
NS_IMETHOD GetNewMessages();
|
||||
|
||||
// nsIMsgNewsFolder
|
||||
NS_IMETHOD GetPath(nsNativeFileSpec& aPathName);
|
||||
NS_IMETHOD GetPath(nsIFileSpec** aPathName);
|
||||
|
||||
NS_IMETHOD GetMsgKeySetStr(char * *aMsgKeySetStr);
|
||||
NS_IMETHOD SetMsgKeySetStr(char * aMsgKeySetStr);
|
||||
|
Loading…
Reference in New Issue
Block a user