зеркало из https://github.com/mozilla/pjs.git
start of changes for http://bugscape/show_bug.cgi?id=1149
allow for default templates for the "Local Folders" account. r=alecf
This commit is contained in:
Родитель
c8c5ae145c
Коммит
3537df95e2
|
@ -2701,8 +2701,6 @@ nsMsgLocalMailFolder::OnStopRunningUrl(nsIURI * aUrl, nsresult aExitCode)
|
|||
NS_IMETHODIMP
|
||||
nsMsgLocalMailFolder::SetFlagsOnDefaultMailboxes(PRUint32 flags)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (flags & MSG_FOLDER_FLAG_INBOX)
|
||||
setSubfolderFlag(kInboxName, MSG_FOLDER_FLAG_INBOX);
|
||||
|
||||
|
|
|
@ -35,6 +35,10 @@
|
|||
#include "nsMsgLocalCID.h"
|
||||
#include "nsMsgFolderFlags.h"
|
||||
#include "nsIMsgLocalMailFolder.h"
|
||||
#include "nsFileLocations.h"
|
||||
#include "nsIFileLocator.h"
|
||||
|
||||
static NS_DEFINE_CID(kFileLocatorCID, NS_FILELOCATOR_CID);
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED2(nsNoIncomingServer,
|
||||
nsMsgIncomingServer,
|
||||
|
@ -73,7 +77,7 @@ nsNoIncomingServer::SetFlagsOnDefaultMailboxes()
|
|||
do_QueryInterface(rootFolder, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// pop3 gets all flags
|
||||
// "none" doesn't have an inbox, but it does have a queue (unsent messages)
|
||||
localFolder->SetFlagsOnDefaultMailboxes(MSG_FOLDER_FLAG_SENTMAIL |
|
||||
MSG_FOLDER_FLAG_DRAFTS |
|
||||
MSG_FOLDER_FLAG_TEMPLATES |
|
||||
|
@ -82,6 +86,46 @@ nsNoIncomingServer::SetFlagsOnDefaultMailboxes()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsNoIncomingServer::CopyDefaultMessages(const char *defaultFolderName, nsIFileSpec *path)
|
||||
{
|
||||
nsresult rv;
|
||||
PRBool exists;
|
||||
if (!defaultFolderName || !path) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsIFileLocator> locator = do_GetService(kFileLocatorCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIFileSpec> defaultMessagesFile;
|
||||
rv = locator->GetFileLocation(nsSpecialFileSpec::App_DefaultsFolder50, getter_AddRefs(defaultMessagesFile));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// bin/defaults better exist
|
||||
rv = defaultMessagesFile->Exists(&exists);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (!exists) return NS_ERROR_FAILURE;
|
||||
|
||||
// bin/defaults/messenger doesn't have to exist
|
||||
rv = defaultMessagesFile->AppendRelativeUnixPath("messenger");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = defaultMessagesFile->Exists(&exists);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (!exists) return NS_OK;
|
||||
|
||||
// bin/defaults/messenger/<defaultFolderName> doesn't have to exist
|
||||
rv = defaultMessagesFile->AppendRelativeUnixPath(defaultFolderName);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = defaultMessagesFile->Exists(&exists);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (!exists) return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIFileSpec> parentDir;
|
||||
rv = path->GetParent(getter_AddRefs(parentDir));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = defaultMessagesFile->CopyToDir(parentDir);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsNoIncomingServer::CreateDefaultMailboxes(nsIFileSpec *path)
|
||||
{
|
||||
nsresult rv;
|
||||
|
@ -120,6 +164,11 @@ NS_IMETHODIMP nsNoIncomingServer::CreateDefaultMailboxes(nsIFileSpec *path)
|
|||
|
||||
rv = path->SetLeafName("Templates");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// if they exist, use the default templates
|
||||
rv = CopyDefaultMessages("Templates",path);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = path->Exists(&exists);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (!exists) {
|
||||
|
@ -135,7 +184,8 @@ NS_IMETHODIMP nsNoIncomingServer::CreateDefaultMailboxes(nsIFileSpec *path)
|
|||
rv = path->Touch();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsNoIncomingServer::GetNewMail(nsIMsgWindow *aMsgWindow, nsIUrlListener *aUrlListener, nsIURI **aResult)
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "nsINoIncomingServer.h"
|
||||
#include "nsILocalMailIncomingServer.h"
|
||||
#include "nsMsgIncomingServer.h"
|
||||
#include "nsIFileSpec.h"
|
||||
|
||||
/* get some implementation from nsMsgIncomingServer */
|
||||
class nsNoIncomingServer : public nsMsgIncomingServer,
|
||||
|
@ -43,6 +44,10 @@ public:
|
|||
virtual ~nsNoIncomingServer();
|
||||
|
||||
NS_IMETHOD GetLocalStoreType(char * *type);
|
||||
private:
|
||||
// copies messages from bin/defaults/messenger/<defaultFolderName> into <path>
|
||||
nsresult CopyDefaultMessages(const char *defaultFolderName, nsIFileSpec *path);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -223,13 +223,12 @@ nsPop3IncomingServer::SetFlagsOnDefaultMailboxes()
|
|||
do_QueryInterface(rootFolder, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// pop3 gets all flags
|
||||
// pop3 gets an inbox, but no queue (unsent messages)
|
||||
localFolder->SetFlagsOnDefaultMailboxes(MSG_FOLDER_FLAG_INBOX |
|
||||
MSG_FOLDER_FLAG_SENTMAIL |
|
||||
MSG_FOLDER_FLAG_DRAFTS |
|
||||
MSG_FOLDER_FLAG_TEMPLATES |
|
||||
MSG_FOLDER_FLAG_TRASH |
|
||||
MSG_FOLDER_FLAG_QUEUE);
|
||||
MSG_FOLDER_FLAG_TRASH);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -285,15 +284,7 @@ NS_IMETHODIMP nsPop3IncomingServer::CreateDefaultMailboxes(nsIFileSpec *path)
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
rv = path->SetLeafName("Unsent Messages");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = path->Exists(&exists);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (!exists) {
|
||||
rv = path->Touch();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
return rv;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPop3IncomingServer::GetNewMail(nsIMsgWindow *aMsgWindow, nsIUrlListener *aUrlListener, nsIURI **aResult)
|
||||
|
|
Загрузка…
Ссылка в новой задаче