зеркало из https://github.com/mozilla/pjs.git
Changing CRLF line endings to LF to fix IRIX bustage.
This commit is contained in:
Родитель
35defc0bba
Коммит
f4147f10d0
|
@ -2050,7 +2050,7 @@ NS_IMETHODIMP nsImapMailFolder::GetNewMessages(nsIMsgWindow *aWindow, nsIUrlList
|
|||
if (NS_SUCCEEDED(rv) && imapServer)
|
||||
imapServer->GetDownloadBodiesOnGetNewMail(&m_downloadingFolderForOfflineUse);
|
||||
|
||||
inbox->SetGettingNewMessages(PR_TRUE);
|
||||
inbox->SetGettingNewMessages(PR_TRUE);
|
||||
m_urlListener = aListener;
|
||||
rv = imapService->SelectFolder(eventQ, inbox, this, aWindow, nsnull);
|
||||
|
||||
|
@ -3944,12 +3944,12 @@ nsImapMailFolder::OnStopRunningUrl(nsIURI *aUrl, nsresult aExitCode)
|
|||
// Only send the OnStopCopy notification if we have no copy state (which means we're doing an online
|
||||
// move/copy, and have cleared the copy state above) or if we've finished the move/copy
|
||||
// of multiple imap messages, one msg at a time (i.e., moving to a local folder).
|
||||
if (listener && sendEndCopyNotification)
|
||||
listener->OnStopCopy(aExitCode);
|
||||
if (m_urlListener)
|
||||
{
|
||||
m_urlListener->OnStopRunningUrl(aUrl, aExitCode);
|
||||
m_urlListener = nsnull;
|
||||
if (listener && sendEndCopyNotification)
|
||||
listener->OnStopCopy(aExitCode);
|
||||
if (m_urlListener)
|
||||
{
|
||||
m_urlListener->OnStopRunningUrl(aUrl, aExitCode);
|
||||
m_urlListener = nsnull;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -358,7 +358,7 @@ protected:
|
|||
nsMsgKey m_curMsgUid;
|
||||
PRUint32 m_uidValidity;
|
||||
PRInt32 m_nextMessageByteLength;
|
||||
nsCOMPtr<nsIEventQueue> m_eventQueue;
|
||||
nsCOMPtr<nsIEventQueue> m_eventQueue;
|
||||
nsCOMPtr<nsIUrlListener> m_urlListener;
|
||||
PRBool m_urlRunning;
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ nsImapOfflineSync::nsImapOfflineSync(nsIMsgWindow *window, nsIUrlListener *liste
|
|||
m_window->SetStopped(PR_FALSE);
|
||||
|
||||
mCurrentPlaybackOpType = nsIMsgOfflineImapOperation::kFlagsChanged;
|
||||
m_mailboxupdatesStarted = PR_FALSE;
|
||||
m_mailboxupdatesStarted = PR_FALSE;
|
||||
m_mailboxupdatesFinished = PR_FALSE;
|
||||
m_createdOfflineFolders = PR_FALSE;
|
||||
m_pseudoOffline = PR_FALSE;
|
||||
|
@ -859,48 +859,48 @@ nsImapOfflineDownloader::~nsImapOfflineDownloader()
|
|||
nsresult nsImapOfflineDownloader::ProcessNextOperation()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (!m_mailboxupdatesStarted)
|
||||
{
|
||||
m_mailboxupdatesStarted = PR_TRUE;
|
||||
// Update the INBOX first so the updates on the remaining
|
||||
// folders pickup the results of any filter moves.
|
||||
NS_WITH_SERVICE(nsIMsgAccountManager, accountManager, kMsgAccountManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsISupportsArray> servers;
|
||||
|
||||
rv = accountManager->GetAllServers(getter_AddRefs(servers));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
if (!m_mailboxupdatesFinished)
|
||||
{
|
||||
AdvanceToNextServer();
|
||||
if (m_currentServer)
|
||||
{
|
||||
nsCOMPtr <nsIFolder> rootFolder;
|
||||
m_currentServer->GetRootFolder(getter_AddRefs(rootFolder));
|
||||
nsCOMPtr<nsIMsgFolder> inbox;
|
||||
if (rootFolder)
|
||||
{
|
||||
nsCOMPtr<nsIMsgFolder> rootMsgFolder = do_QueryInterface(rootFolder, &rv);
|
||||
if (rootMsgFolder)
|
||||
{
|
||||
PRUint32 numFolders;
|
||||
rootMsgFolder->GetFoldersWithFlag(MSG_FOLDER_FLAG_INBOX, 1, &numFolders, getter_AddRefs(inbox));
|
||||
if (inbox)
|
||||
return inbox->GetNewMessages(m_window, this);
|
||||
}
|
||||
}
|
||||
else
|
||||
return ProcessNextOperation(); // recurse and do next server.
|
||||
}
|
||||
else
|
||||
{
|
||||
m_allServers = nsnull;
|
||||
m_mailboxupdatesFinished = PR_TRUE;
|
||||
}
|
||||
}
|
||||
AdvanceToNextFolder();
|
||||
|
||||
if (!m_mailboxupdatesStarted)
|
||||
{
|
||||
m_mailboxupdatesStarted = PR_TRUE;
|
||||
// Update the INBOX first so the updates on the remaining
|
||||
// folders pickup the results of any filter moves.
|
||||
NS_WITH_SERVICE(nsIMsgAccountManager, accountManager, kMsgAccountManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsISupportsArray> servers;
|
||||
|
||||
rv = accountManager->GetAllServers(getter_AddRefs(servers));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
if (!m_mailboxupdatesFinished)
|
||||
{
|
||||
AdvanceToNextServer();
|
||||
if (m_currentServer)
|
||||
{
|
||||
nsCOMPtr <nsIFolder> rootFolder;
|
||||
m_currentServer->GetRootFolder(getter_AddRefs(rootFolder));
|
||||
nsCOMPtr<nsIMsgFolder> inbox;
|
||||
if (rootFolder)
|
||||
{
|
||||
nsCOMPtr<nsIMsgFolder> rootMsgFolder = do_QueryInterface(rootFolder, &rv);
|
||||
if (rootMsgFolder)
|
||||
{
|
||||
PRUint32 numFolders;
|
||||
rootMsgFolder->GetFoldersWithFlag(MSG_FOLDER_FLAG_INBOX, 1, &numFolders, getter_AddRefs(inbox));
|
||||
if (inbox)
|
||||
return inbox->GetNewMessages(m_window, this);
|
||||
}
|
||||
}
|
||||
else
|
||||
return ProcessNextOperation(); // recurse and do next server.
|
||||
}
|
||||
else
|
||||
{
|
||||
m_allServers = nsnull;
|
||||
m_mailboxupdatesFinished = PR_TRUE;
|
||||
}
|
||||
}
|
||||
AdvanceToNextFolder();
|
||||
|
||||
while (m_currentFolder)
|
||||
{
|
||||
PRUint32 folderFlags;
|
||||
|
|
|
@ -69,7 +69,7 @@ protected:
|
|||
nsCOMPtr <nsISupportsArray> m_allFolders;
|
||||
nsCOMPtr <nsIMsgIncomingServer> m_currentServer;
|
||||
nsCOMPtr <nsIEnumerator> m_serverEnumerator;
|
||||
nsCOMPtr <nsIFileSpec> m_curTempFile;
|
||||
nsCOMPtr <nsIFileSpec> m_curTempFile;
|
||||
|
||||
nsMsgKeyArray m_CurrentKeys;
|
||||
PRUint32 m_KeyIndex;
|
||||
|
@ -77,7 +77,7 @@ protected:
|
|||
nsCOMPtr <nsIUrlListener> m_listener;
|
||||
PRInt32 mCurrentUIDValidity;
|
||||
PRInt32 mCurrentPlaybackOpType; // kFlagsChanged -> kMsgCopy -> kMsgMoved
|
||||
PRBool m_mailboxupdatesStarted;
|
||||
PRBool m_mailboxupdatesStarted;
|
||||
PRBool m_mailboxupdatesFinished;
|
||||
PRBool m_pseudoOffline; // for queueing online events in offline db
|
||||
PRBool m_createdOfflineFolders;
|
||||
|
|
|
@ -4706,7 +4706,7 @@ void nsImapProtocol::UploadMessageFromFile (nsIFileSpec* fileSpec,
|
|||
IncrementCommandTagNumber();
|
||||
|
||||
PRUint32 fileSize = 0;
|
||||
PRInt32 totalSize;
|
||||
PRInt32 totalSize;
|
||||
PRUint32 readCount;
|
||||
char *dataBuffer = nsnull;
|
||||
nsCString command(GetServerCommandTag());
|
||||
|
@ -4718,10 +4718,10 @@ void nsImapProtocol::UploadMessageFromFile (nsIFileSpec* fileSpec,
|
|||
PRBool hasLiteralPlus = (GetServerStateParser().GetCapabilityFlag() &
|
||||
kLiteralPlusCapability);
|
||||
|
||||
nsCOMPtr <nsIInputStream> fileInputStream;
|
||||
|
||||
nsCOMPtr <nsIInputStream> fileInputStream;
|
||||
|
||||
if (escapedName)
|
||||
{
|
||||
{
|
||||
command.Append(" append \"");
|
||||
command.Append(escapedName);
|
||||
command.Append("\" (");
|
||||
|
@ -4834,8 +4834,8 @@ void nsImapProtocol::UploadMessageFromFile (nsIFileSpec* fileSpec,
|
|||
}
|
||||
}
|
||||
done:
|
||||
PR_FREEIF(dataBuffer);
|
||||
fileSpec->CloseStream();
|
||||
PR_FREEIF(dataBuffer);
|
||||
fileSpec->CloseStream();
|
||||
nsMemory::Free(escapedName);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,13 +62,13 @@
|
|||
#include "nsICacheService.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsMsgUtf7Utils.h"
|
||||
#include "nsIOutputStream.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsICopyMsgStreamListener.h"
|
||||
#include "nsIFileStream.h"
|
||||
#include "nsIMsgParseMailMsgState.h"
|
||||
#include "nsMsgLineBuffer.h"
|
||||
#include "nsMsgLocalCID.h"
|
||||
#include "nsIOutputStream.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsICopyMsgStreamListener.h"
|
||||
#include "nsIFileStream.h"
|
||||
#include "nsIMsgParseMailMsgState.h"
|
||||
#include "nsMsgLineBuffer.h"
|
||||
#include "nsMsgLocalCID.h"
|
||||
|
||||
#define PREF_MAIL_ROOT_IMAP "mail.root.imap"
|
||||
|
||||
|
@ -1888,114 +1888,114 @@ nsImapService::OnlineMessageCopy(nsIEventQueue* aClientEventQueue,
|
|||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsImapService::OfflineAppendFromFile(nsIFileSpec* aFileSpec,
|
||||
nsIURI *aUrl,
|
||||
nsIMsgFolder* aDstFolder,
|
||||
const char* messageId, // te be replaced
|
||||
PRBool inSelectedState, // needs to be in
|
||||
nsIUrlListener* aListener,
|
||||
nsIURI** aURL,
|
||||
nsISupports* aCopyState)
|
||||
{
|
||||
nsCOMPtr <nsIMsgDatabase> destDB;
|
||||
nsresult rv = aDstFolder->GetMsgDatabase(nsnull, getter_AddRefs(destDB));
|
||||
// ### might need to send some notifications instead of just returning
|
||||
|
||||
if (NS_SUCCEEDED(rv) && destDB)
|
||||
{
|
||||
nsMsgKey fakeKey;
|
||||
destDB->GetNextFakeOfflineMsgKey(&fakeKey);
|
||||
|
||||
nsCOMPtr <nsIMsgOfflineImapOperation> op;
|
||||
rv = destDB->GetOfflineOpForKey(fakeKey, PR_TRUE, getter_AddRefs(op));
|
||||
if (NS_SUCCEEDED(rv) && op)
|
||||
{
|
||||
nsXPIDLCString destFolderUri;
|
||||
|
||||
aDstFolder->GetURI(getter_Copies(destFolderUri));
|
||||
op->SetOperation(nsIMsgOfflineImapOperation::kAppendDraft); // ### do we care if it's a template?
|
||||
op->SetDestinationFolderURI(destFolderUri);
|
||||
nsCOMPtr <nsIOutputStream> offlineStore;
|
||||
rv = aDstFolder->GetOfflineStoreOutputStream(getter_AddRefs(offlineStore));
|
||||
|
||||
if (NS_SUCCEEDED(rv) && offlineStore)
|
||||
{
|
||||
PRInt32 curOfflineStorePos = 0;
|
||||
nsCOMPtr <nsIRandomAccessStore> randomStore = do_QueryInterface(offlineStore);
|
||||
if (randomStore)
|
||||
randomStore->Tell(&curOfflineStorePos);
|
||||
else
|
||||
{
|
||||
NS_ASSERTION(PR_FALSE, "needs to be a random store!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
nsCOMPtr <nsIInputStream> inputStream;
|
||||
nsCOMPtr <nsIMsgParseMailMsgState> msgParser = do_CreateInstance(NS_PARSEMAILMSGSTATE_CONTRACTID, &rv);
|
||||
msgParser->SetMailDB(destDB);
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = aFileSpec->GetInputStream(getter_AddRefs(inputStream));
|
||||
if (NS_SUCCEEDED(rv) && inputStream)
|
||||
{
|
||||
// now, copy the temp file to the offline store for the dest folder.
|
||||
PRInt32 inputBufferSize = 10240;
|
||||
nsMsgLineStreamBuffer *inputStreamBuffer = new nsMsgLineStreamBuffer(inputBufferSize, CRLF, PR_TRUE /* allocate new lines */, PR_FALSE /* leave CRLFs on the returned string */);
|
||||
PRUint32 fileSize;
|
||||
aFileSpec->GetFileSize(&fileSize);
|
||||
PRUint32 bytesWritten;
|
||||
rv = NS_OK;
|
||||
// rv = inputStream->Read(inputBuffer, inputBufferSize, &bytesRead);
|
||||
// if (NS_SUCCEEDED(rv) && bytesRead > 0)
|
||||
msgParser->SetState(nsIMsgParseMailMsgState::ParseHeadersState);
|
||||
// set the env pos to fake key so the msg hdr will have that for a key
|
||||
msgParser->SetEnvelopePos(fakeKey);
|
||||
PRBool needMoreData = PR_FALSE;
|
||||
char * newLine = nsnull;
|
||||
PRUint32 numBytesInLine = 0;
|
||||
do
|
||||
{
|
||||
newLine = inputStreamBuffer->ReadNextLine(inputStream, numBytesInLine, needMoreData);
|
||||
if (newLine)
|
||||
{
|
||||
msgParser->ParseAFolderLine(newLine, numBytesInLine);
|
||||
rv = offlineStore->Write(newLine, numBytesInLine, &bytesWritten);
|
||||
nsCRT::free(newLine);
|
||||
}
|
||||
}
|
||||
while (newLine);
|
||||
nsCOMPtr <nsIMsgDBHdr> fakeHdr;
|
||||
|
||||
msgParser->FinishHeader();
|
||||
msgParser->GetNewMsgHdr(getter_AddRefs(fakeHdr));
|
||||
if (fakeHdr)
|
||||
{
|
||||
if (NS_SUCCEEDED(rv) && fakeHdr)
|
||||
{
|
||||
PRUint32 resultFlags;
|
||||
fakeHdr->SetMessageOffset(curOfflineStorePos);
|
||||
fakeHdr->OrFlags(MSG_FLAG_OFFLINE | MSG_FLAG_READ, &resultFlags);
|
||||
fakeHdr->SetOfflineMessageSize(fileSize);
|
||||
destDB->AddNewHdrToDB(fakeHdr, PR_TRUE /* notify */);
|
||||
aDstFolder->SetFlag(MSG_FOLDER_FLAG_OFFLINEEVENTS);
|
||||
}
|
||||
}
|
||||
// tell the listener we're done.
|
||||
aListener->OnStopRunningUrl(aUrl, NS_OK);
|
||||
delete inputStreamBuffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (destDB)
|
||||
destDB->Close(PR_TRUE);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsImapService::OfflineAppendFromFile(nsIFileSpec* aFileSpec,
|
||||
nsIURI *aUrl,
|
||||
nsIMsgFolder* aDstFolder,
|
||||
const char* messageId, // te be replaced
|
||||
PRBool inSelectedState, // needs to be in
|
||||
nsIUrlListener* aListener,
|
||||
nsIURI** aURL,
|
||||
nsISupports* aCopyState)
|
||||
{
|
||||
nsCOMPtr <nsIMsgDatabase> destDB;
|
||||
nsresult rv = aDstFolder->GetMsgDatabase(nsnull, getter_AddRefs(destDB));
|
||||
// ### might need to send some notifications instead of just returning
|
||||
|
||||
if (NS_SUCCEEDED(rv) && destDB)
|
||||
{
|
||||
nsMsgKey fakeKey;
|
||||
destDB->GetNextFakeOfflineMsgKey(&fakeKey);
|
||||
|
||||
nsCOMPtr <nsIMsgOfflineImapOperation> op;
|
||||
rv = destDB->GetOfflineOpForKey(fakeKey, PR_TRUE, getter_AddRefs(op));
|
||||
if (NS_SUCCEEDED(rv) && op)
|
||||
{
|
||||
nsXPIDLCString destFolderUri;
|
||||
|
||||
aDstFolder->GetURI(getter_Copies(destFolderUri));
|
||||
op->SetOperation(nsIMsgOfflineImapOperation::kAppendDraft); // ### do we care if it's a template?
|
||||
op->SetDestinationFolderURI(destFolderUri);
|
||||
nsCOMPtr <nsIOutputStream> offlineStore;
|
||||
rv = aDstFolder->GetOfflineStoreOutputStream(getter_AddRefs(offlineStore));
|
||||
|
||||
if (NS_SUCCEEDED(rv) && offlineStore)
|
||||
{
|
||||
PRInt32 curOfflineStorePos = 0;
|
||||
nsCOMPtr <nsIRandomAccessStore> randomStore = do_QueryInterface(offlineStore);
|
||||
if (randomStore)
|
||||
randomStore->Tell(&curOfflineStorePos);
|
||||
else
|
||||
{
|
||||
NS_ASSERTION(PR_FALSE, "needs to be a random store!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
nsCOMPtr <nsIInputStream> inputStream;
|
||||
nsCOMPtr <nsIMsgParseMailMsgState> msgParser = do_CreateInstance(NS_PARSEMAILMSGSTATE_CONTRACTID, &rv);
|
||||
msgParser->SetMailDB(destDB);
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = aFileSpec->GetInputStream(getter_AddRefs(inputStream));
|
||||
if (NS_SUCCEEDED(rv) && inputStream)
|
||||
{
|
||||
// now, copy the temp file to the offline store for the dest folder.
|
||||
PRInt32 inputBufferSize = 10240;
|
||||
nsMsgLineStreamBuffer *inputStreamBuffer = new nsMsgLineStreamBuffer(inputBufferSize, CRLF, PR_TRUE /* allocate new lines */, PR_FALSE /* leave CRLFs on the returned string */);
|
||||
PRUint32 fileSize;
|
||||
aFileSpec->GetFileSize(&fileSize);
|
||||
PRUint32 bytesWritten;
|
||||
rv = NS_OK;
|
||||
// rv = inputStream->Read(inputBuffer, inputBufferSize, &bytesRead);
|
||||
// if (NS_SUCCEEDED(rv) && bytesRead > 0)
|
||||
msgParser->SetState(nsIMsgParseMailMsgState::ParseHeadersState);
|
||||
// set the env pos to fake key so the msg hdr will have that for a key
|
||||
msgParser->SetEnvelopePos(fakeKey);
|
||||
PRBool needMoreData = PR_FALSE;
|
||||
char * newLine = nsnull;
|
||||
PRUint32 numBytesInLine = 0;
|
||||
do
|
||||
{
|
||||
newLine = inputStreamBuffer->ReadNextLine(inputStream, numBytesInLine, needMoreData);
|
||||
if (newLine)
|
||||
{
|
||||
msgParser->ParseAFolderLine(newLine, numBytesInLine);
|
||||
rv = offlineStore->Write(newLine, numBytesInLine, &bytesWritten);
|
||||
nsCRT::free(newLine);
|
||||
}
|
||||
}
|
||||
while (newLine);
|
||||
nsCOMPtr <nsIMsgDBHdr> fakeHdr;
|
||||
|
||||
msgParser->FinishHeader();
|
||||
msgParser->GetNewMsgHdr(getter_AddRefs(fakeHdr));
|
||||
if (fakeHdr)
|
||||
{
|
||||
if (NS_SUCCEEDED(rv) && fakeHdr)
|
||||
{
|
||||
PRUint32 resultFlags;
|
||||
fakeHdr->SetMessageOffset(curOfflineStorePos);
|
||||
fakeHdr->OrFlags(MSG_FLAG_OFFLINE | MSG_FLAG_READ, &resultFlags);
|
||||
fakeHdr->SetOfflineMessageSize(fileSize);
|
||||
destDB->AddNewHdrToDB(fakeHdr, PR_TRUE /* notify */);
|
||||
aDstFolder->SetFlag(MSG_FOLDER_FLAG_OFFLINEEVENTS);
|
||||
}
|
||||
}
|
||||
// tell the listener we're done.
|
||||
aListener->OnStopRunningUrl(aUrl, NS_OK);
|
||||
delete inputStreamBuffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (destDB)
|
||||
destDB->Close(PR_TRUE);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* append message from file url */
|
||||
/* imap://HOST>appendmsgfromfile>DESTINATIONMAILBOXPATH */
|
||||
/* imap://HOST>appenddraftfromfile>DESTINATIONMAILBOXPATH>UID>messageId */
|
||||
|
@ -2051,11 +2051,11 @@ nsImapService::AppendMessageFromFile(nsIEventQueue* aClientEventQueue,
|
|||
}
|
||||
|
||||
rv = uri->SetSpec(urlSpec.get());
|
||||
if (WeAreOffline())
|
||||
{
|
||||
return OfflineAppendFromFile(aFileSpec, uri, aDstFolder, messageId, inSelectedState, aListener, aURL, aCopyState);
|
||||
// handle offline append to drafts or templates folder here.
|
||||
}
|
||||
if (WeAreOffline())
|
||||
{
|
||||
return OfflineAppendFromFile(aFileSpec, uri, aDstFolder, messageId, inSelectedState, aListener, aURL, aCopyState);
|
||||
// handle offline append to drafts or templates folder here.
|
||||
}
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = GetImapConnectionAndLoadUrl(aClientEventQueue, imapUrl,
|
||||
nsnull, aURL);
|
||||
|
|
Загрузка…
Ссылка в новой задаче