зеркало из https://github.com/mozilla/gecko-dev.git
Add copy messages.
This commit is contained in:
Родитель
d58487c55f
Коммит
509d88554d
|
@ -35,6 +35,7 @@
|
|||
#include "nsIRDFService.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsFileStream.h"
|
||||
|
||||
// we need this because of an egcs 1.0 (and possibly gcc) compiler bug
|
||||
// that doesn't allow you to call ::nsISupports::GetIID() inside of a class
|
||||
|
@ -84,7 +85,34 @@ nsMsgLocalMailFolder::~nsMsgLocalMailFolder(void)
|
|||
NS_IF_RELEASE(mMailDatabase);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsMsgLocalMailFolder, nsMsgFolder, nsIMsgLocalMailFolder)
|
||||
NS_IMPL_ADDREF_INHERITED(nsMsgLocalMailFolder, nsMsgFolder)
|
||||
NS_IMPL_RELEASE_INHERITED(nsMsgLocalMailFolder, nsMsgFolder)
|
||||
|
||||
NS_IMETHODIMP nsMsgLocalMailFolder::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (!aInstancePtr) return NS_ERROR_NULL_POINTER;
|
||||
*aInstancePtr = nsnull;
|
||||
if (aIID.Equals(nsIMsgLocalMailFolder::GetIID()))
|
||||
{
|
||||
*aInstancePtr = NS_STATIC_CAST(nsIMsgLocalMailFolder*, this);
|
||||
}
|
||||
else if (aIID.Equals(nsIDBChangeListener::GetIID()))
|
||||
{
|
||||
*aInstancePtr = NS_STATIC_CAST(nsIDBChangeListener*, this);
|
||||
}
|
||||
else if(aIID.Equals(nsICopyMessageListener::GetIID()))
|
||||
{
|
||||
*aInstancePtr = NS_STATIC_CAST(nsICopyMessageListener*, this);
|
||||
}
|
||||
|
||||
if(*aInstancePtr)
|
||||
{
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return nsMsgFolder::QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -295,6 +323,7 @@ nsMsgLocalMailFolder::GetMessages(nsIEnumerator* *result)
|
|||
nsresult rv = GetPath(path);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
//END DEBUGGING
|
||||
nsresult folderOpen;
|
||||
if(!NS_SUCCEEDED(folderOpen = nsMailDatabase::Open(path, PR_TRUE, &mMailDatabase, PR_FALSE)) &&
|
||||
folderOpen == NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE || folderOpen == NS_MSG_ERROR_FOLDER_SUMMARY_MISSING )
|
||||
|
@ -990,3 +1019,67 @@ NS_IMETHODIMP nsMsgLocalMailFolder::OnAnnouncerGoingAway(nsIDBChangeAnnouncer *
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
//nsICopyMessageListener
|
||||
NS_IMETHODIMP nsMsgLocalMailFolder::BeginCopy()
|
||||
{
|
||||
|
||||
PRBool isLocked;
|
||||
IsLocked(&isLocked);
|
||||
if(!isLocked)
|
||||
AcquireSemaphore(NS_STATIC_CAST(nsIMsgLocalMailFolder*, this));
|
||||
else
|
||||
return NS_MSG_FOLDER_BUSY;
|
||||
|
||||
nsFileSpec path;
|
||||
GetPath(path);
|
||||
mCopyState = new nsLocalMailCopyState;
|
||||
if(!mCopyState)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
//Before we continue we should verify that there is enough diskspace.
|
||||
//XXX How do we do this?
|
||||
mCopyState->fileStream = new nsOutputFileStream(path, PR_WRONLY | PR_CREATE_FILE);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgLocalMailFolder::CopyData(nsIInputStream *aIStream, PRInt32 aLength)
|
||||
{
|
||||
//check to make sure we have control of the write.
|
||||
PRBool haveSemaphore;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
rv = TestSemaphore(NS_STATIC_CAST(nsIMsgLocalMailFolder*, this), &haveSemaphore);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
if(!haveSemaphore)
|
||||
return NS_MSG_FOLDER_BUSY;
|
||||
|
||||
char *data = (char*)PR_MALLOC(aLength + 1);
|
||||
|
||||
if(!data)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
PRUint32 readCount;
|
||||
rv = aIStream->Read(data, aLength, &readCount);
|
||||
data[readCount] ='\0';
|
||||
mCopyState->fileStream->seek(PR_SEEK_END, 0);
|
||||
*(mCopyState->fileStream) << data;
|
||||
PR_Free(data);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgLocalMailFolder::EndCopy()
|
||||
{
|
||||
mCopyState->fileStream->close();
|
||||
delete mCopyState->fileStream;
|
||||
delete mCopyState;
|
||||
mCopyState = nsnull;
|
||||
|
||||
//we finished the copy so someone else can write to us.
|
||||
PRBool haveSemaphore;
|
||||
nsresult rv = TestSemaphore(NS_STATIC_CAST(nsIMsgLocalMailFolder*, this), &haveSemaphore);
|
||||
if(rv && haveSemaphore)
|
||||
ReleaseSemaphore(NS_STATIC_CAST(nsIMsgLocalMailFolder*, this));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -61,7 +61,6 @@ nsIRDFResource* nsMSGFolderDataSource::kNC_Child;
|
|||
nsIRDFResource* nsMSGFolderDataSource::kNC_MessageChild;
|
||||
nsIRDFResource* nsMSGFolderDataSource::kNC_Folder;
|
||||
nsIRDFResource* nsMSGFolderDataSource::kNC_Name;
|
||||
nsIRDFResource* nsMSGFolderDataSource::kNC_MSGFolderRoot;
|
||||
nsIRDFResource* nsMSGFolderDataSource::kNC_SpecialFolder;
|
||||
|
||||
nsIRDFResource* nsMSGFolderDataSource::kNC_Subject;
|
||||
|
@ -186,7 +185,6 @@ nsMSGFolderDataSource::~nsMSGFolderDataSource (void)
|
|||
NS_RELEASE2(kNC_MessageChild, refcnt);
|
||||
NS_RELEASE2(kNC_Folder, refcnt);
|
||||
NS_RELEASE2(kNC_Name, refcnt);
|
||||
NS_RELEASE2(kNC_MSGFolderRoot, refcnt);
|
||||
NS_RELEASE2(kNC_SpecialFolder, refcnt);
|
||||
|
||||
NS_RELEASE2(kNC_Subject, refcnt);
|
||||
|
@ -246,7 +244,6 @@ NS_IMETHODIMP nsMSGFolderDataSource::Init(const char* uri)
|
|||
gRDFService->GetResource(kURINC_MessageChild, &kNC_MessageChild);
|
||||
gRDFService->GetResource(kURINC_Folder, &kNC_Folder);
|
||||
gRDFService->GetResource(kURINC_Name, &kNC_Name);
|
||||
gRDFService->GetResource(kURINC_MSGFolderRoot, &kNC_MSGFolderRoot);
|
||||
gRDFService->GetResource(kURINC_SpecialFolder, &kNC_SpecialFolder);
|
||||
|
||||
gRDFService->GetResource(kURINC_Subject, &kNC_Subject);
|
||||
|
@ -258,29 +255,6 @@ NS_IMETHODIMP nsMSGFolderDataSource::Init(const char* uri)
|
|||
gRDFService->GetResource(kURINC_Reply, &kNC_Reply);
|
||||
gRDFService->GetResource(kURINC_Forward, &kNC_Forward);
|
||||
}
|
||||
#if 0
|
||||
//create the folder for the root folder
|
||||
nsresult rv;
|
||||
nsIMsgFolder *rootFolder;
|
||||
#if 0
|
||||
if(NS_SUCCEEDED(kNC_MSGFolderRoot->QueryInterface(nsIMsgFolder::GetIID(), (void**)&rootFolder)))
|
||||
{
|
||||
if(rootFolder)
|
||||
{
|
||||
rootFolder->SetName("Mail and News");
|
||||
rootFolder->SetDepth(0);
|
||||
nsNativeFileSpec startPath("c:\\program files\\netscape\\users\\putterman\\Mail", PR_FALSE);
|
||||
if (NS_FAILED(rv = InitLocalFolders(rootFolder, startPath, 1)))
|
||||
return rv;
|
||||
|
||||
NS_RELEASE(rootFolder);
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (NS_FAILED(rv = nsMsgFolder::GetRoot(&rootFolder)))
|
||||
return rv;
|
||||
#endif
|
||||
#endif
|
||||
mInitialized = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -322,7 +296,7 @@ NS_IMETHODIMP nsMSGFolderDataSource::GetTarget(nsIRDFResource* source,
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
nsString nameString(name);
|
||||
createNode(nameString, target);
|
||||
PR_FREEIF(name);
|
||||
delete[] name;
|
||||
return rv;
|
||||
}
|
||||
else if (peq(kNC_SpecialFolder, property)) {
|
||||
|
@ -771,9 +745,19 @@ nsMSGFolderDataSource::DoCommand(nsISupportsArray/*<nsIRDFResource>*/* aSources,
|
|||
nsIMsgFolder* folder;
|
||||
nsIMessage* message;
|
||||
if (NS_SUCCEEDED(source->QueryInterface(nsIMsgFolder::GetIID(), (void**)&folder))) {
|
||||
|
||||
PRUint32 itemCount = aArguments->Count();
|
||||
if (peq(aCommand, kNC_Delete)) {
|
||||
// XXX delete folder
|
||||
for(PRUint32 item = 0; item < itemCount; item++)
|
||||
{
|
||||
nsIMessage* deletedMessage;
|
||||
nsISupports* argument = (*aArguments)[item];
|
||||
if (rv = NS_SUCCEEDED(argument->QueryInterface(nsIMessage::GetIID(), (void**)&deletedMessage)))
|
||||
{
|
||||
rv = folder->DeleteMessage(deletedMessage);
|
||||
NS_RELEASE(deletedMessage);
|
||||
}
|
||||
NS_RELEASE(argument);
|
||||
}
|
||||
}
|
||||
|
||||
NS_RELEASE(folder);
|
||||
|
|
|
@ -82,6 +82,7 @@ nsMailboxProtocol::~nsMailboxProtocol()
|
|||
NS_IF_RELEASE(m_outputStream);
|
||||
NS_IF_RELEASE(m_outputConsumer);
|
||||
NS_IF_RELEASE(m_transport);
|
||||
NS_IF_RELEASE(m_runningUrl);
|
||||
}
|
||||
|
||||
void nsMailboxProtocol::Initialize(nsIURL * aURL)
|
||||
|
@ -167,6 +168,9 @@ NS_IMETHODIMP nsMailboxProtocol::OnStartBinding(nsIURL* aURL, const char *aConte
|
|||
m_mailboxParser->OnStartBinding(aURL, aContentType);
|
||||
|
||||
}
|
||||
else if(m_mailboxCopyHandler)
|
||||
m_mailboxCopyHandler->OnStartBinding(aURL, aContentType);
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
@ -183,7 +187,9 @@ NS_IMETHODIMP nsMailboxProtocol::OnStopBinding(nsIURL* aURL, nsresult aStatus, c
|
|||
// we need to inform our mailbox parser that there is no more incoming data...
|
||||
m_mailboxParser->OnStopBinding(aURL, 0, nsnull);
|
||||
}
|
||||
if (m_nextState == MAILBOX_READ_MESSAGE)
|
||||
else if (m_mailboxCopyHandler)
|
||||
m_mailboxCopyHandler->OnStopBinding(aURL, 0, nsnull);
|
||||
else if (m_nextState == MAILBOX_READ_MESSAGE)
|
||||
{
|
||||
// and close the article file if it was open....
|
||||
if (m_tempMessageFile)
|
||||
|
|
|
@ -312,7 +312,8 @@ NS_METHOD nsMailboxUrl::SetURLInfo(URL_Struct *URL_s)
|
|||
|
||||
/* Hook us up with the world. */
|
||||
m_URL_s = URL_s;
|
||||
if (m_mailboxAction == nsMailboxActionDisplayMessage)
|
||||
if (m_mailboxAction == nsMailboxActionDisplayMessage || m_mailboxAction == nsMailboxActionCopyMessage
|
||||
|| m_mailboxAction == nsMailboxActionMoveMessage)
|
||||
{
|
||||
// set the byte field range for the url struct...
|
||||
char * byteRange = PR_smprintf("bytes=%d-%d", m_messageKey, m_messageKey+m_messageSize - 1);
|
||||
|
|
|
@ -50,8 +50,11 @@ function MsgDeleteMessage()
|
|||
if (appCore != null) {
|
||||
dump("\nAppcore isn't null in MsgDeleteMessage\n");
|
||||
appCore.SetWindow(window);
|
||||
var NodeList = tree.getElementsByAttribute("selected", "true");
|
||||
appCore.DeleteMessage(tree, NodeList);
|
||||
//get the selected elements
|
||||
var messageList = tree.getElementsByAttribute("selected", "true");
|
||||
//get the current folder
|
||||
var srcFolder = tree.childNodes[5];
|
||||
appCore.DeleteMessage(tree, srcFolder, messageList);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,10 +90,44 @@ function MsgForwardAsQuoted()
|
|||
|
||||
function MsgCopyMessage(destFolder)
|
||||
{
|
||||
uri = destFolder.getAttribute('id');
|
||||
// Get the id for the folder we're copying into
|
||||
destUri = destFolder.getAttribute('id');
|
||||
dump(destUri);
|
||||
|
||||
dump(uri);
|
||||
var tree = frames[0].frames[1].document.getElementById('threadTree');
|
||||
if(tree)
|
||||
{
|
||||
//Get the selected messages to copy
|
||||
var messageList = tree.getElementsByAttribute("selected", "true");
|
||||
var appCore = FindMsgAppCore();
|
||||
if (appCore != null) {
|
||||
appCore.SetWindow(window);
|
||||
//get the current folder
|
||||
var srcFolder = tree.childNodes[5];
|
||||
appCore.CopyMessages(srcFolder, destFolder, messageList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function MsgMoveMessage(destFolder)
|
||||
{
|
||||
// Get the id for the folder we're copying into
|
||||
destUri = destFolder.getAttribute('id');
|
||||
dump(destUri);
|
||||
|
||||
var tree = frames[0].frames[1].document.getElementById('threadTree');
|
||||
if(tree)
|
||||
{
|
||||
//Get the selected messages to copy
|
||||
var messageList = tree.getElementsByAttribute("selected", "true");
|
||||
var appCore = FindMsgAppCore();
|
||||
if (appCore != null) {
|
||||
appCore.SetWindow(window);
|
||||
//get the current folder
|
||||
var srcFolder = tree.childNodes[5];
|
||||
appCore.MoveMessages(srcFolder, destFolder, messageList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function MsgNewFolder() {}
|
||||
|
|
Загрузка…
Ссылка в новой задаче