зеркало из https://github.com/mozilla/pjs.git
handle propagating user defined keywords to .msf file when imap server doesn't support user defined keywords, esp useful for junk mail status r/sr=mscott 216612
This commit is contained in:
Родитель
2317ba9006
Коммит
d7b7f2f5dc
|
@ -42,13 +42,13 @@
|
|||
class nsImapMailDatabase : public nsMailDatabase
|
||||
{
|
||||
public:
|
||||
// OK, it's dumb that this should require a fileSpec, since there is no file
|
||||
// for the folder. This is mainly because we're deriving from nsMailDatabase;
|
||||
// Perhaps we shouldn't...
|
||||
nsImapMailDatabase();
|
||||
virtual ~nsImapMailDatabase();
|
||||
|
||||
NS_IMETHOD Open(nsIFileSpec *folderName, PRBool create, PRBool upgrading, nsIMsgDatabase** pMessageDB);
|
||||
// OK, it's dumb that this should require a fileSpec, since there is no file
|
||||
// for the folder. This is mainly because we're deriving from nsMailDatabase;
|
||||
// Perhaps we shouldn't...
|
||||
nsImapMailDatabase();
|
||||
virtual ~nsImapMailDatabase();
|
||||
|
||||
NS_IMETHOD Open(nsIFileSpec *folderName, PRBool create, PRBool upgrading, nsIMsgDatabase** pMessageDB);
|
||||
|
||||
NS_IMETHOD StartBatch();
|
||||
NS_IMETHOD EndBatch();
|
||||
|
@ -56,13 +56,22 @@ public:
|
|||
NS_IMETHOD DeleteMessages(nsMsgKeyArray* nsMsgKeys, nsIDBChangeListener *instigator);
|
||||
virtual nsresult AdjustExpungedBytesOnDelete(nsIMsgDBHdr *msgHdr);
|
||||
|
||||
NS_IMETHOD ForceClosed();
|
||||
NS_IMETHOD SetFolderStream(nsIOFileStream *aFileStream);
|
||||
NS_IMETHOD AddNewHdrToDB(nsIMsgDBHdr *newHdr, PRBool notify);
|
||||
NS_IMETHOD SetAttributesOnPendingHdr(nsIMsgDBHdr *pendingHdr, const char *property,
|
||||
const char *propertyVal, PRInt32 flags);
|
||||
|
||||
protected:
|
||||
// IMAP does not set local file flags, override does nothing
|
||||
virtual void UpdateFolderFlag(nsIMsgDBHdr *msgHdr, PRBool bSet,
|
||||
MsgFlags flag, nsIOFileStream **ppFileStream);
|
||||
// IMAP does not set local file flags, override does nothing
|
||||
virtual void UpdateFolderFlag(nsIMsgDBHdr *msgHdr, PRBool bSet,
|
||||
MsgFlags flag, nsIOFileStream **ppFileStream);
|
||||
virtual PRBool SetHdrFlag(nsIMsgDBHdr *msgHdr, PRBool bSet, MsgFlags flag);
|
||||
|
||||
nsresult GetAllPendingHdrsTable();
|
||||
mdb_token m_pendingHdrsRowScopeToken;
|
||||
mdb_token m_pendingHdrsTableKindToken;
|
||||
nsCOMPtr <nsIMdbTable> m_mdbAllPendingHdrsTable;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999-2003
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -47,8 +47,13 @@
|
|||
#include "nsLocalFolderSummarySpec.h"
|
||||
#include "nsIFileSpec.h"
|
||||
|
||||
const char *kPendingHdrsScope = "ns:msg:db:row:scope:pending:all"; // scope for all offine ops table
|
||||
const char *kPendingHdrsTableKind = "ns:msg:db:table:kind:pending";
|
||||
struct mdbOid gAllPendingHdrsTableOID;
|
||||
|
||||
nsImapMailDatabase::nsImapMailDatabase()
|
||||
{
|
||||
m_mdbAllPendingHdrsTable = nsnull;
|
||||
}
|
||||
|
||||
nsImapMailDatabase::~nsImapMailDatabase()
|
||||
|
@ -57,122 +62,120 @@ nsImapMailDatabase::~nsImapMailDatabase()
|
|||
|
||||
NS_IMETHODIMP nsImapMailDatabase::Open(nsIFileSpec *aFolderName, PRBool create, PRBool upgrading, nsIMsgDatabase** pMessageDB)
|
||||
{
|
||||
nsImapMailDatabase *mailDB;
|
||||
PRBool summaryFileExists;
|
||||
struct stat st;
|
||||
PRBool newFile = PR_FALSE;
|
||||
nsImapMailDatabase *mailDB;
|
||||
PRBool summaryFileExists;
|
||||
struct stat st;
|
||||
PRBool newFile = PR_FALSE;
|
||||
#ifdef DEBUG_bienvenu
|
||||
NS_ASSERTION(m_folder, "folder should be set");
|
||||
#endif
|
||||
if (!aFolderName)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsFileSpec folderName;
|
||||
aFolderName->GetFileSpec(&folderName);
|
||||
|
||||
nsLocalFolderSummarySpec summarySpec(folderName);
|
||||
|
||||
nsIDBFolderInfo *folderInfo = NULL;
|
||||
|
||||
*pMessageDB = NULL;
|
||||
|
||||
nsFileSpec dbPath(summarySpec);
|
||||
|
||||
mailDB = (nsImapMailDatabase *) FindInCache(dbPath);
|
||||
if (mailDB)
|
||||
{
|
||||
*pMessageDB = mailDB;
|
||||
return(NS_OK);
|
||||
}
|
||||
|
||||
if (!aFolderName)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsFileSpec folderName;
|
||||
aFolderName->GetFileSpec(&folderName);
|
||||
|
||||
nsLocalFolderSummarySpec summarySpec(folderName);
|
||||
|
||||
nsIDBFolderInfo *folderInfo = NULL;
|
||||
|
||||
*pMessageDB = NULL;
|
||||
|
||||
nsFileSpec dbPath(summarySpec);
|
||||
|
||||
mailDB = (nsImapMailDatabase *) FindInCache(dbPath);
|
||||
if (mailDB)
|
||||
{
|
||||
*pMessageDB = mailDB;
|
||||
return(NS_OK);
|
||||
}
|
||||
|
||||
#if defined(DEBUG_bienvenu) || defined(DEBUG_jefft)
|
||||
printf("really opening db in nsImapMailDatabase::Open(%s, %s, %p, %s) -> %s\n",
|
||||
(const char*)folderName, create ? "TRUE":"FALSE",
|
||||
pMessageDB, upgrading ? "TRUE":"FALSE", (const char*)folderName);
|
||||
printf("really opening db in nsImapMailDatabase::Open(%s, %s, %p, %s) -> %s\n",
|
||||
(const char*)folderName, create ? "TRUE":"FALSE",
|
||||
pMessageDB, upgrading ? "TRUE":"FALSE", (const char*)folderName);
|
||||
#endif
|
||||
// if the old summary doesn't exist, we're creating a new one.
|
||||
if (!summarySpec.Exists() && create)
|
||||
newFile = PR_TRUE;
|
||||
|
||||
mailDB = new nsImapMailDatabase;
|
||||
|
||||
if (!mailDB)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
mailDB->m_folderSpec = new nsFileSpec(folderName);
|
||||
// if the old summary doesn't exist, we're creating a new one.
|
||||
if (!summarySpec.Exists() && create)
|
||||
newFile = PR_TRUE;
|
||||
|
||||
mailDB = new nsImapMailDatabase;
|
||||
|
||||
if (!mailDB)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
mailDB->m_folderSpec = new nsFileSpec(folderName);
|
||||
mailDB->m_folder = m_folder;
|
||||
mailDB->AddRef();
|
||||
// stat file before we open the db, because if we've latered
|
||||
// any messages, handling latered will change time stamp on
|
||||
// folder file.
|
||||
summaryFileExists = summarySpec.Exists();
|
||||
|
||||
char *nativeFolderName = nsCRT::strdup((const char *) folderName);
|
||||
|
||||
mailDB->AddRef();
|
||||
// stat file before we open the db, because if we've latered
|
||||
// any messages, handling latered will change time stamp on
|
||||
// folder file.
|
||||
summaryFileExists = summarySpec.Exists();
|
||||
|
||||
char *nativeFolderName = nsCRT::strdup((const char *) folderName);
|
||||
|
||||
#if defined(XP_WIN) || defined(XP_OS2) || defined(XP_MAC)
|
||||
UnixToNative(nativeFolderName);
|
||||
UnixToNative(nativeFolderName);
|
||||
#endif
|
||||
stat (nativeFolderName, &st);
|
||||
PR_FREEIF(nativeFolderName);
|
||||
|
||||
nsresult err = NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE;
|
||||
|
||||
err = mailDB->OpenMDB((const char *) summarySpec, create);
|
||||
|
||||
if (err == NS_OK)
|
||||
{
|
||||
mailDB->GetDBFolderInfo(&folderInfo);
|
||||
if (folderInfo == NULL)
|
||||
{
|
||||
err = NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// compare current version of db versus filed out version info.
|
||||
PRUint32 version;
|
||||
folderInfo->GetVersion(&version);
|
||||
if (mailDB->GetCurVersion() != version)
|
||||
err = NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE;
|
||||
NS_RELEASE(folderInfo);
|
||||
}
|
||||
if (err != NS_OK)
|
||||
{
|
||||
// this will make the db folder info release its ref to the mail db...
|
||||
NS_IF_RELEASE(mailDB->m_dbFolderInfo);
|
||||
mailDB->ForceClosed();
|
||||
if (err == NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE)
|
||||
summarySpec.Delete(PR_FALSE);
|
||||
|
||||
mailDB = NULL;
|
||||
}
|
||||
}
|
||||
if (err != NS_OK || newFile)
|
||||
{
|
||||
// if we couldn't open file, or we have a blank one, and we're supposed
|
||||
// to upgrade, updgrade it.
|
||||
if (newFile && !upgrading) // caller is upgrading, and we have empty summary file,
|
||||
{ // leave db around and open so caller can upgrade it.
|
||||
err = NS_MSG_ERROR_FOLDER_SUMMARY_MISSING;
|
||||
}
|
||||
else if (err != NS_OK)
|
||||
{
|
||||
*pMessageDB = NULL;
|
||||
stat (nativeFolderName, &st);
|
||||
PR_FREEIF(nativeFolderName);
|
||||
|
||||
nsresult err = NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE;
|
||||
|
||||
err = mailDB->OpenMDB((const char *) summarySpec, create);
|
||||
|
||||
if (err == NS_OK)
|
||||
{
|
||||
mailDB->GetDBFolderInfo(&folderInfo);
|
||||
if (folderInfo == NULL)
|
||||
{
|
||||
err = NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// compare current version of db versus filed out version info.
|
||||
PRUint32 version;
|
||||
folderInfo->GetVersion(&version);
|
||||
if (mailDB->GetCurVersion() != version)
|
||||
err = NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE;
|
||||
NS_RELEASE(folderInfo);
|
||||
}
|
||||
if (err != NS_OK)
|
||||
{
|
||||
// this will make the db folder info release its ref to the mail db...
|
||||
NS_IF_RELEASE(mailDB->m_dbFolderInfo);
|
||||
mailDB->ForceClosed();
|
||||
if (err == NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE)
|
||||
summarySpec.Delete(PR_FALSE);
|
||||
|
||||
mailDB = NULL;
|
||||
}
|
||||
}
|
||||
if (err != NS_OK || newFile)
|
||||
{
|
||||
// if we couldn't open file, or we have a blank one, and we're supposed
|
||||
// to upgrade, updgrade it.
|
||||
if (newFile && !upgrading) // caller is upgrading, and we have empty summary file,
|
||||
{ // leave db around and open so caller can upgrade it.
|
||||
err = NS_MSG_ERROR_FOLDER_SUMMARY_MISSING;
|
||||
}
|
||||
else if (err != NS_OK)
|
||||
{
|
||||
*pMessageDB = NULL;
|
||||
if (mailDB)
|
||||
mailDB->Close(PR_FALSE);
|
||||
delete mailDB;
|
||||
delete mailDB;
|
||||
summarySpec.Delete(PR_FALSE); // blow away the db if it's corrupt.
|
||||
mailDB = NULL;
|
||||
}
|
||||
}
|
||||
if (err == NS_OK || err == NS_MSG_ERROR_FOLDER_SUMMARY_MISSING)
|
||||
{
|
||||
*pMessageDB = mailDB;
|
||||
if (mailDB)
|
||||
GetDBCache()->AppendElement(mailDB);
|
||||
// if (err == NS_OK)
|
||||
// mailDB->HandleLatered();
|
||||
|
||||
}
|
||||
return err;
|
||||
mailDB = NULL;
|
||||
}
|
||||
}
|
||||
if (err == NS_OK || err == NS_MSG_ERROR_FOLDER_SUMMARY_MISSING)
|
||||
{
|
||||
*pMessageDB = mailDB;
|
||||
if (mailDB)
|
||||
GetDBCache()->AppendElement(mailDB);
|
||||
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImapMailDatabase::SetSummaryValid(PRBool /* valid */)
|
||||
|
@ -182,7 +185,7 @@ NS_IMETHODIMP nsImapMailDatabase::SetSummaryValid(PRBool /* valid */)
|
|||
|
||||
// IMAP does not set local file flags, override does nothing
|
||||
void nsImapMailDatabase::UpdateFolderFlag(nsIMsgDBHdr * /* msgHdr */, PRBool /* bSet */,
|
||||
MsgFlags /* flag */, nsIOFileStream ** /* ppFileStream */)
|
||||
MsgFlags /* flag */, nsIOFileStream ** /* ppFileStream */)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -204,7 +207,7 @@ NS_IMETHODIMP nsImapMailDatabase::EndBatch()
|
|||
|
||||
NS_IMETHODIMP nsImapMailDatabase::DeleteMessages(nsMsgKeyArray* nsMsgKeys, nsIDBChangeListener *instigator)
|
||||
{
|
||||
return nsMsgDatabase::DeleteMessages(nsMsgKeys, instigator);
|
||||
return nsMsgDatabase::DeleteMessages(nsMsgKeys, instigator);
|
||||
}
|
||||
|
||||
nsresult nsImapMailDatabase::AdjustExpungedBytesOnDelete(nsIMsgDBHdr *msgHdr)
|
||||
|
@ -220,9 +223,136 @@ nsresult nsImapMailDatabase::AdjustExpungedBytesOnDelete(nsIMsgDBHdr *msgHdr)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImapMailDatabase::ForceClosed()
|
||||
{
|
||||
m_mdbAllPendingHdrsTable = nsnull;
|
||||
return nsMailDatabase::ForceClosed();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImapMailDatabase::SetFolderStream(nsIOFileStream *aFileStream)
|
||||
{
|
||||
NS_ASSERTION(0, "Trying to set folderStream, not implemented");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult nsImapMailDatabase::GetAllPendingHdrsTable()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (!m_mdbAllPendingHdrsTable)
|
||||
rv = GetTableCreateIfMissing(kPendingHdrsScope, kPendingHdrsTableKind, getter_AddRefs(m_mdbAllPendingHdrsTable),
|
||||
m_pendingHdrsRowScopeToken, m_pendingHdrsTableKindToken) ;
|
||||
return rv;
|
||||
}
|
||||
|
||||
static const char *kFlagsName = "flags";
|
||||
|
||||
NS_IMETHODIMP nsImapMailDatabase::AddNewHdrToDB(nsIMsgDBHdr *newHdr, PRBool notify)
|
||||
{
|
||||
nsresult rv = nsMsgDatabase::AddNewHdrToDB(newHdr, notify);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = GetAllPendingHdrsTable();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mdb_count numPendingHdrs = 0;
|
||||
m_mdbAllPendingHdrsTable->GetCount(GetEnv(), &numPendingHdrs);
|
||||
if (numPendingHdrs > 0)
|
||||
{
|
||||
mdbYarn messageIdYarn;
|
||||
nsCOMPtr <nsIMdbRow> pendingRow;
|
||||
mdbOid outRowId;
|
||||
|
||||
nsXPIDLCString messageId;
|
||||
newHdr->GetMessageId(getter_Copies(messageId));
|
||||
messageIdYarn.mYarn_Buf = (void*)messageId.get();
|
||||
messageIdYarn.mYarn_Fill = messageId.Length();
|
||||
messageIdYarn.mYarn_Form = 0;
|
||||
messageIdYarn.mYarn_Size = messageIdYarn.mYarn_Fill;
|
||||
|
||||
m_mdbStore->FindRow(GetEnv(), m_pendingHdrsRowScopeToken,
|
||||
m_messageIdColumnToken, &messageIdYarn, &outRowId, getter_AddRefs(pendingRow));
|
||||
if (pendingRow)
|
||||
{
|
||||
mdb_count numCells;
|
||||
mdbYarn cellYarn;
|
||||
mdb_column cellColumn;
|
||||
|
||||
pendingRow->GetCount(GetEnv(), &numCells);
|
||||
// iterate over the cells in the pending hdr setting properties on the newHdr.
|
||||
// we skip cell 0, which is the messageId;
|
||||
for (mdb_count cellIndex = 1; cellIndex < numCells; cellIndex++)
|
||||
{
|
||||
mdb_err err = pendingRow->SeekCellYarn(GetEnv(), cellIndex, &cellColumn, nsnull);
|
||||
if (err == 0)
|
||||
{
|
||||
err = pendingRow->AliasCellYarn(GetEnv(), cellColumn, &cellYarn);
|
||||
if (err == 0)
|
||||
{
|
||||
nsMsgHdr* msgHdr = NS_STATIC_CAST(nsMsgHdr*, newHdr); // closed system, cast ok
|
||||
nsIMdbRow *row = msgHdr->GetMDBRow();
|
||||
if (row)
|
||||
row->AddColumn(GetEnv(), cellColumn, &cellYarn);
|
||||
}
|
||||
}
|
||||
}
|
||||
m_mdbAllPendingHdrsTable->CutRow(GetEnv(), pendingRow);
|
||||
pendingRow->CutAllColumns(GetEnv());
|
||||
}
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImapMailDatabase::SetAttributesOnPendingHdr(nsIMsgDBHdr *pendingHdr, const char *property,
|
||||
const char *propertyVal, PRInt32 flags)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(pendingHdr);
|
||||
nsresult rv = GetAllPendingHdrsTable();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mdbYarn messageIdYarn;
|
||||
nsCOMPtr <nsIMdbRow> pendingRow;
|
||||
nsIMdbRow *newHdrRow;
|
||||
mdbOid outRowId;
|
||||
mdb_err err;
|
||||
nsXPIDLCString messageId;
|
||||
pendingHdr->GetMessageId(getter_Copies(messageId));
|
||||
messageIdYarn.mYarn_Buf = (void*)messageId.get();
|
||||
messageIdYarn.mYarn_Fill = messageId.Length();
|
||||
messageIdYarn.mYarn_Form = 0;
|
||||
messageIdYarn.mYarn_Size = messageIdYarn.mYarn_Fill;
|
||||
|
||||
err = m_mdbStore->FindRow(GetEnv(), m_pendingHdrsRowScopeToken,
|
||||
m_messageIdColumnToken, &messageIdYarn, &outRowId, getter_AddRefs(pendingRow));
|
||||
|
||||
if (!pendingRow)
|
||||
{
|
||||
err = m_mdbStore->NewRow(GetEnv(), m_pendingHdrsRowScopeToken, &newHdrRow);
|
||||
pendingRow = do_QueryInterface(newHdrRow);
|
||||
}
|
||||
NS_ENSURE_SUCCESS(err, err);
|
||||
if (pendingRow)
|
||||
{
|
||||
// now we need to add cells to the row to remember the messageid, property and property value, and flags.
|
||||
// Then, when hdrs are added to the db, we'll check if they have a matching message-id, and if so,
|
||||
// set the property and flags
|
||||
nsXPIDLCString messageId;
|
||||
pendingHdr->GetMessageId(getter_Copies(messageId));
|
||||
// we're just going to ignore messages without a message-id. They should be rare. If SPAM messages often
|
||||
// didn't have message-id's, they'd be filtered on the server, most likely, and spammers would then
|
||||
// start putting in message-id's.
|
||||
if (!messageId.IsEmpty())
|
||||
{
|
||||
extern const char *kMessageIdColumnName;
|
||||
m_mdbAllPendingHdrsTable->AddRow(GetEnv(), pendingRow);
|
||||
// make sure this is the first cell so that when we ignore the first
|
||||
// cell in nsImapMailDatabase::AddNewHdrToDB, we're ignoring the right one
|
||||
(void) SetProperty(pendingRow, kMessageIdColumnName, messageId.get());
|
||||
(void) SetProperty(pendingRow, property, propertyVal);
|
||||
(void) SetUint32Property(pendingRow, kFlagsName, (PRUint32) flags);
|
||||
}
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,26 +43,27 @@ interface nsIMAPNamespace;
|
|||
[scriptable, uuid(76cbfa2e-c7f2-11d3-a54e-0060b0fc04b7)]
|
||||
interface nsIMailboxSpec : nsISupports
|
||||
{
|
||||
attribute long folder_UIDVALIDITY;
|
||||
attribute long number_of_messages;
|
||||
attribute long number_of_unseen_messages;
|
||||
attribute long number_of_recent_messages;
|
||||
attribute long folder_UIDVALIDITY;
|
||||
attribute long number_of_messages;
|
||||
attribute long number_of_unseen_messages;
|
||||
attribute long number_of_recent_messages;
|
||||
|
||||
attribute unsigned long box_flags;
|
||||
attribute unsigned long box_flags;
|
||||
attribute unsigned long supportedUserFlags;
|
||||
|
||||
attribute string allocatedPathName;
|
||||
attribute wstring unicharPathName;
|
||||
attribute char hierarchySeparator;
|
||||
attribute string hostName;
|
||||
|
||||
attribute nsIImapFlagAndUidState flagState;
|
||||
|
||||
attribute boolean folderSelected;
|
||||
attribute boolean discoveredFromLsub;
|
||||
attribute string allocatedPathName;
|
||||
attribute wstring unicharPathName;
|
||||
attribute char hierarchySeparator;
|
||||
attribute string hostName;
|
||||
|
||||
attribute boolean onlineVerified;
|
||||
attribute nsIImapFlagAndUidState flagState;
|
||||
|
||||
[noscript] attribute nsIMAPNamespace namespaceForFolder;
|
||||
attribute boolean folderSelected;
|
||||
attribute boolean discoveredFromLsub;
|
||||
|
||||
attribute boolean onlineVerified;
|
||||
|
||||
[noscript] attribute nsIMAPNamespace namespaceForFolder;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -187,6 +187,7 @@ public:
|
|||
PRInt32 number_of_recent_messages;
|
||||
|
||||
PRUint32 box_flags;
|
||||
PRUint32 supportedUserFlags;
|
||||
|
||||
char *allocatedPathName;
|
||||
PRUnichar *unicharPathName;
|
||||
|
@ -231,7 +232,7 @@ typedef enum
|
|||
|
||||
|
||||
// This class is only used for passing data
|
||||
// between the IMAP and mozilla threadns
|
||||
// between the IMAP and mozilla threads
|
||||
class nsIMAPACLRightsInfo
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -151,7 +151,7 @@ nsImapFlagAndUidState::nsImapFlagAndUidState(const nsImapFlagAndUidState& state,
|
|||
|
||||
nsImapFlagAndUidState::~nsImapFlagAndUidState()
|
||||
{
|
||||
PR_FREEIF(fFlags);
|
||||
PR_Free(fFlags);
|
||||
if (m_customFlagsHash)
|
||||
{
|
||||
m_customFlagsHash->Reset(FreeCustomFlags, nsnull);
|
||||
|
|
|
@ -2325,6 +2325,11 @@ NS_IMETHODIMP nsImapMailFolder::UpdateImapMailboxInfo(
|
|||
|
||||
aSpec->GetFlagState(getter_AddRefs(flagState));
|
||||
|
||||
// remember what the supported user flags are.
|
||||
PRUint32 supportedUserFlags;
|
||||
aSpec->GetSupportedUserFlags(&supportedUserFlags);
|
||||
SetSupportedUserFlags(supportedUserFlags);
|
||||
|
||||
m_uidValidity = folderValidity;
|
||||
if ((imapUIDValidity != folderValidity) /* && // if UIDVALIDITY Changed
|
||||
!NET_IsOffline() */)
|
||||
|
@ -6251,6 +6256,34 @@ nsImapMailFolder::CopyMessages(nsIMsgFolder* srcFolder,
|
|||
rv = dstServer->Equals(srcServer, &sameServer);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
|
||||
PRUint32 supportedUserFlags;
|
||||
GetSupportedUserFlags(&supportedUserFlags);
|
||||
|
||||
if (! (supportedUserFlags & kImapMsgSupportUserFlag))
|
||||
{
|
||||
PRUint32 count = 0;
|
||||
PRUint32 i;
|
||||
|
||||
rv = messages->Count(&count);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// check if any msg hdr has special flags or properties set
|
||||
// that we need to set on the dest hdr
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
nsCOMPtr <nsIMsgDBHdr> msgDBHdr = do_QueryElementAt(messages, i, &rv);
|
||||
if (mDatabase && msgDBHdr)
|
||||
{
|
||||
nsXPIDLCString junkScore, junkScoreOrigin;
|
||||
msgDBHdr->GetStringProperty("junkscore", getter_Copies(junkScore));
|
||||
msgDBHdr->GetStringProperty("junkscoreorigin", getter_Copies(junkScoreOrigin));
|
||||
if (!junkScore.IsEmpty()) // ignore already scored messages.
|
||||
mDatabase->SetAttributesOnPendingHdr(msgDBHdr, "junkscore", junkScore.get(), 0);
|
||||
if (!junkScoreOrigin.IsEmpty())
|
||||
mDatabase->SetAttributesOnPendingHdr(msgDBHdr, "junkscoreorigin", junkScore.get(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
// if the folders aren't on the same server, do a stream base copy
|
||||
if (!sameServer)
|
||||
{
|
||||
|
@ -7261,15 +7294,18 @@ nsImapMailFolder::OnMessageClassified(const char *aMsgURI, nsMsgJunkStatus aClas
|
|||
{
|
||||
nsCOMPtr<nsIMsgFolder> folder;
|
||||
rv = GetExistingFolder(spamFolderURI, getter_AddRefs(folder));
|
||||
if (NS_SUCCEEDED(rv) && folder) {
|
||||
if (NS_SUCCEEDED(rv) && folder)
|
||||
{
|
||||
rv = folder->SetFlag(MSG_FOLDER_FLAG_JUNK);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
if (NS_SUCCEEDED(GetMoveCoalescer())) {
|
||||
if (NS_SUCCEEDED(GetMoveCoalescer()))
|
||||
{
|
||||
m_moveCoalescer->AddMove(folder, msgKey);
|
||||
willMoveMessage = PR_TRUE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
// XXX TODO
|
||||
// JUNK MAIL RELATED
|
||||
// the listener should do
|
||||
|
|
|
@ -2771,19 +2771,12 @@ nsImapMailboxSpec *nsImapServerResponseParser::CreateCurrentMailboxSpec(const ch
|
|||
const char *mailboxNameToConvert = (mailboxName) ? mailboxName : fSelectedMailboxName;
|
||||
if (mailboxNameToConvert)
|
||||
{
|
||||
const char *serverKey =
|
||||
fServerConnection.GetImapServerKey();
|
||||
const char *serverKey = fServerConnection.GetImapServerKey();
|
||||
nsIMAPNamespace *ns = nsnull;
|
||||
if (serverKey && fHostSessionList)
|
||||
{
|
||||
fHostSessionList->GetNamespaceForMailboxForHost(serverKey, mailboxNameToConvert, ns); // for
|
||||
// delimiter
|
||||
}
|
||||
|
||||
if (ns)
|
||||
returnSpec->hierarchySeparator = ns->GetDelimiter();
|
||||
else
|
||||
returnSpec->hierarchySeparator = '/'; // a guess?
|
||||
returnSpec->hierarchySeparator = (ns) ? ns->GetDelimiter(): '/';
|
||||
|
||||
}
|
||||
|
||||
|
@ -2793,6 +2786,8 @@ nsImapMailboxSpec *nsImapServerResponseParser::CreateCurrentMailboxSpec(const ch
|
|||
returnSpec->number_of_unseen_messages = fNumberOfUnseenMessages;
|
||||
returnSpec->number_of_recent_messages = fNumberOfRecentMessages;
|
||||
|
||||
returnSpec->supportedUserFlags = fSupportsUserDefinedFlags;
|
||||
|
||||
returnSpec->box_flags = kNoFlags; // stub
|
||||
returnSpec->onlineVerified = PR_FALSE; // we're fabricating this. The flags aren't verified.
|
||||
returnSpec->allocatedPathName = nsCRT::strdup(mailboxNameToConvert);
|
||||
|
@ -2802,7 +2797,8 @@ nsImapMailboxSpec *nsImapServerResponseParser::CreateCurrentMailboxSpec(const ch
|
|||
nsIURI * aUrl = nsnull;
|
||||
nsresult rv = NS_OK;
|
||||
returnSpec->connection->GetCurrentUrl()->QueryInterface(NS_GET_IID(nsIURI), (void **) &aUrl);
|
||||
if (NS_SUCCEEDED(rv) && aUrl) {
|
||||
if (NS_SUCCEEDED(rv) && aUrl)
|
||||
{
|
||||
nsCAutoString host;
|
||||
aUrl->GetHost(host);
|
||||
returnSpec->hostName = ToNewCString(host);
|
||||
|
|
|
@ -138,6 +138,7 @@ nsImapURI2Path(const char* rootURI, const char* uriStr, nsFileSpec& pathResult)
|
|||
rv = localPath->GetFileSpec(&pathResult);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// nsFileSpec tempPath(pathResult.GetNativePathCString(), PR_TRUE); // This is needed so that we dont get imapservername.sbd See bug 210683
|
||||
pathResult.CreateDirectory();
|
||||
}
|
||||
|
||||
|
@ -281,6 +282,7 @@ nsImapMailboxSpec::nsImapMailboxSpec()
|
|||
number_of_recent_messages = 0;
|
||||
|
||||
box_flags = 0;
|
||||
supportedUserFlags = 0;
|
||||
|
||||
allocatedPathName = nsnull;
|
||||
unicharPathName = nsnull;
|
||||
|
@ -311,6 +313,7 @@ NS_IMPL_GETSET(nsImapMailboxSpec, DiscoveredFromLsub, PRBool, discoveredFromLsub
|
|||
NS_IMPL_GETSET(nsImapMailboxSpec, OnlineVerified, PRBool, onlineVerified)
|
||||
NS_IMPL_GETSET_STR(nsImapMailboxSpec, HostName, hostName)
|
||||
NS_IMPL_GETSET_STR(nsImapMailboxSpec, AllocatedPathName, allocatedPathName)
|
||||
NS_IMPL_GETSET(nsImapMailboxSpec, SupportedUserFlags, PRUint32, supportedUserFlags)
|
||||
NS_IMPL_GETSET(nsImapMailboxSpec, Box_flags, PRUint32, box_flags)
|
||||
NS_IMPL_GETSET(nsImapMailboxSpec, NamespaceForFolder, nsIMAPNamespace *, namespaceForFolder)
|
||||
|
||||
|
@ -353,7 +356,8 @@ nsImapMailboxSpec& nsImapMailboxSpec::operator=(const nsImapMailboxSpec& aCopy)
|
|||
number_of_recent_messages = aCopy.number_of_recent_messages;
|
||||
|
||||
box_flags = aCopy.box_flags;
|
||||
|
||||
supportedUserFlags = aCopy.supportedUserFlags;
|
||||
|
||||
allocatedPathName = (aCopy.allocatedPathName) ? strdup(aCopy.allocatedPathName) : nsnull;
|
||||
unicharPathName = (aCopy.unicharPathName) ? nsCRT::strdup(aCopy.unicharPathName) : nsnull;
|
||||
hierarchySeparator = aCopy.hierarchySeparator;
|
||||
|
|
Загрузка…
Ссылка в новой задаче