This commit is contained in:
cls%seawood.org 2001-07-03 07:32:27 +00:00
Родитель fcc1853b99
Коммит 19a8175c16
3 изменённых файлов: 66 добавлений и 66 удалений

Просмотреть файл

@ -350,9 +350,9 @@ const nsMsgBiffState nsMsgBiffState_Unknown = 2; // We dunno whether there is ne
boolean shouldStoreMsgOffline(in nsMsgKey msgKey);
boolean hasMsgOffline(in nsMsgKey msgKey);
nsITransport getOfflineFileTransport(in nsMsgKey msgKey, out PRUint32 offset, out PRUint32 size);
nsITransport getOfflineFileTransport(in nsMsgKey msgKey, out PRUint32 offset, out PRUint32 size);
readonly attribute nsIOutputStream offlineStoreOutputStream;
readonly attribute nsIInputStream offlineStoreInputStream;
readonly attribute nsIInputStream offlineStoreInputStream;
void DownloadMessagesForOffline(in nsISupportsArray messages, in nsIMsgWindow window);
nsIMsgFolder getChildWithURI(in string uri, in boolean deep, in boolean caseInsensitive);
void downloadAllForOffline(in nsIUrlListener listener, in nsIMsgWindow window);

Просмотреть файл

@ -4725,62 +4725,62 @@ nsresult nsImapMailFolder::GetOriginalOp(nsIMsgOfflineImapOperation *op, nsIMsgO
*originalOp = returnOp;
return rv;
}
nsresult nsImapMailFolder::CopyOfflineMsgBody(nsIMsgFolder *srcFolder, nsIMsgDBHdr *destHdr, nsIMsgDBHdr *origHdr)
{
nsCOMPtr<nsIOutputStream> outputStream;
nsresult rv = GetOfflineStoreOutputStream(getter_AddRefs(outputStream));
nsCOMPtr <nsIRandomAccessStore> randomStore;
PRInt32 curStorePos;
randomStore = do_QueryInterface(outputStream);
if (randomStore)
{
nsMsgKey messageOffset;
PRUint32 messageSize;
origHdr->GetMessageOffset(&messageOffset);
origHdr->GetOfflineMessageSize(&messageSize);
randomStore->Tell(&curStorePos);
destHdr->SetMessageOffset(curStorePos);
nsCOMPtr <nsIInputStream> offlineStoreInputStream;
rv = srcFolder->GetOfflineStoreInputStream(getter_AddRefs(offlineStoreInputStream));
if (NS_SUCCEEDED(rv) && offlineStoreInputStream)
{
nsCOMPtr<nsIRandomAccessStore> seekStream = do_QueryInterface(offlineStoreInputStream);
NS_ASSERTION(seekStream, "non seekable stream - can't read from offline msg");
if (seekStream)
{
rv = seekStream->Seek(PR_SEEK_SET, messageOffset);
if (NS_SUCCEEDED(rv))
{
// now, copy the dest folder offline store msg to the temp file
PRInt32 inputBufferSize = 10240;
char *inputBuffer = (char *) PR_Malloc(inputBufferSize);
PRUint32 bytesLeft, bytesRead, bytesWritten;
bytesLeft = messageSize;
rv = (inputBuffer) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
while (bytesLeft > 0 && NS_SUCCEEDED(rv))
{
rv = offlineStoreInputStream->Read(inputBuffer, inputBufferSize, &bytesRead);
if (NS_SUCCEEDED(rv) && bytesRead > 0)
{
rv = outputStream->Write(inputBuffer, bytesRead, &bytesWritten);
NS_ASSERTION(bytesWritten == bytesRead, "wrote out correct number of bytes");
}
else
break;
bytesLeft -= bytesRead;
}
PR_FREEIF(inputBuffer);
outputStream->Flush();
}
}
}
}
return rv;
}
nsresult nsImapMailFolder::CopyOfflineMsgBody(nsIMsgFolder *srcFolder, nsIMsgDBHdr *destHdr, nsIMsgDBHdr *origHdr)
{
nsCOMPtr<nsIOutputStream> outputStream;
nsresult rv = GetOfflineStoreOutputStream(getter_AddRefs(outputStream));
nsCOMPtr <nsIRandomAccessStore> randomStore;
PRInt32 curStorePos;
randomStore = do_QueryInterface(outputStream);
if (randomStore)
{
nsMsgKey messageOffset;
PRUint32 messageSize;
origHdr->GetMessageOffset(&messageOffset);
origHdr->GetOfflineMessageSize(&messageSize);
randomStore->Tell(&curStorePos);
destHdr->SetMessageOffset(curStorePos);
nsCOMPtr <nsIInputStream> offlineStoreInputStream;
rv = srcFolder->GetOfflineStoreInputStream(getter_AddRefs(offlineStoreInputStream));
if (NS_SUCCEEDED(rv) && offlineStoreInputStream)
{
nsCOMPtr<nsIRandomAccessStore> seekStream = do_QueryInterface(offlineStoreInputStream);
NS_ASSERTION(seekStream, "non seekable stream - can't read from offline msg");
if (seekStream)
{
rv = seekStream->Seek(PR_SEEK_SET, messageOffset);
if (NS_SUCCEEDED(rv))
{
// now, copy the dest folder offline store msg to the temp file
PRInt32 inputBufferSize = 10240;
char *inputBuffer = (char *) PR_Malloc(inputBufferSize);
PRUint32 bytesLeft, bytesRead, bytesWritten;
bytesLeft = messageSize;
rv = (inputBuffer) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
while (bytesLeft > 0 && NS_SUCCEEDED(rv))
{
rv = offlineStoreInputStream->Read(inputBuffer, inputBufferSize, &bytesRead);
if (NS_SUCCEEDED(rv) && bytesRead > 0)
{
rv = outputStream->Write(inputBuffer, bytesRead, &bytesWritten);
NS_ASSERTION(bytesWritten == bytesRead, "wrote out correct number of bytes");
}
else
break;
bytesLeft -= bytesRead;
}
PR_FREEIF(inputBuffer);
outputStream->Flush();
}
}
}
}
return rv;
}
// this imap folder is the destination of an offline move/copy.
// We are either offline, or doing a pseudo-offline delete (where we do an offline
@ -4953,11 +4953,11 @@ nsresult nsImapMailFolder::CopyMessagesOffline(nsIMsgFolder* srcFolder,
if (NS_SUCCEEDED(stopit))
{
PRBool hasMsgOffline = PR_FALSE;
srcFolder->HasMsgOffline(originalKey, &hasMsgOffline);
if (hasMsgOffline)
CopyOfflineMsgBody(srcFolder, newMailHdr, mailHdr);
PRBool hasMsgOffline = PR_FALSE;
srcFolder->HasMsgOffline(originalKey, &hasMsgOffline);
if (hasMsgOffline)
CopyOfflineMsgBody(srcFolder, newMailHdr, mailHdr);
nsCOMPtr <nsIMsgOfflineImapOperation> destOp;
mDatabase->GetOfflineOpForKey(fakeBase + sourceKeyIndex, PR_TRUE, getter_AddRefs(destOp));
if (destOp)

Просмотреть файл

@ -189,7 +189,7 @@ public:
NS_IMETHOD DownloadAllForOffline(nsIUrlListener *listener, nsIMsgWindow *msgWindow);
NS_IMETHOD ShouldStoreMsgOffline(nsMsgKey msgKey, PRBool *result);
NS_IMETHOD GetOfflineStoreOutputStream(nsIOutputStream **outputStream);
NS_IMETHOD GetOfflineStoreOutputStream(nsIOutputStream **outputStream);
NS_IMETHOD GetCanFileMessages(PRBool *aCanFileMessages);
// nsIMsgImapMailFolder methods
NS_DECL_NSIMSGIMAPMAILFOLDER
@ -346,8 +346,8 @@ protected:
nsIMsgWindow *msgWindow,
nsIMsgCopyServiceListener* listener);
nsresult CopyOfflineMsgBody(nsIMsgFolder *srcFolder, nsIMsgDBHdr *destHdr, nsIMsgDBHdr *origHdr);
nsresult CopyOfflineMsgBody(nsIMsgFolder *srcFolder, nsIMsgDBHdr *destHdr, nsIMsgDBHdr *origHdr);
PRBool m_initialized;
PRBool m_haveDiscoveredAllFolders;
PRBool m_haveReadNameFromDB;