more work to get mailbox parsing working

This commit is contained in:
bienvenu%netscape.com 1999-02-14 22:33:19 +00:00
parent 999831a000
commit 59ce6832d9
4 changed files with 38 additions and 8 deletions

View File

@ -30,12 +30,14 @@ CPPSRCS= nsMsgDatabase.cpp\
nsDBFolderInfo.cpp\
nsMailDatabase.cpp\
nsMsgHdr.cpp\
mdbstubs.cpp \
$(NULL)
CPP_OBJS= .\$(OBJDIR)\nsMsgDatabase.obj \
.\$(OBJDIR)\nsDBFolderInfo.obj\
.\$(OBJDIR)\nsMailDatabase.obj\
.\$(OBJDIR)\nsMsgHdr.obj\
.\$(OBJDIR)\mdbstubs.obj\
$(NULL)

View File

@ -43,7 +43,7 @@ nsDBFolderInfo::nsDBFolderInfo(nsMsgDatabase *mdb)
{
m_mdbTable = NULL;
m_mdbRow = NULL;
m_version = 0; // for upgrading...
m_version = 1; // for upgrading...
m_sortType = 0; // the last sort type open on this db.
m_csid = 0; // default csid for these messages
m_IMAPHierarchySeparator = 0; // imap path separator

View File

@ -206,6 +206,7 @@ nsMsgDatabase::nsMsgDatabase() : m_dbName("")
m_mdbStore = NULL;
m_mdbAllMsgHeadersTable = NULL;
m_mdbTokensInitialized = FALSE;
m_dbFolderInfo = NULL;
}
nsMsgDatabase::~nsMsgDatabase()
@ -236,7 +237,7 @@ nsrefcnt nsMsgDatabase::Release(void)
if (!gMDBFactory)
{
// ### hook up class factory code when it's working
// gMDBFactory = new mdbFactory;
gMDBFactory = new mdbFactory;
}
return gMDBFactory;
}
@ -254,7 +255,13 @@ nsresult nsMsgDatabase::OpenMDB(const char *dbName, PRBool create)
if (NS_SUCCEEDED(ret))
{
mdbThumb *thumb;
ret = myMDBFactory->OpenFileStore(m_mdbEnv, dbName, NULL, /* const mdbOpenPolicy* inOpenPolicy */
struct stat st;
m_dbName = dbName;
if (stat(dbName, &st))
ret = NS_MSG_ERROR_FOLDER_SUMMARY_MISSING;
else
ret = myMDBFactory->OpenFileStore(m_mdbEnv, dbName, NULL, /* const mdbOpenPolicy* inOpenPolicy */
&thumb);
if (NS_SUCCEEDED(ret))
{
@ -404,6 +411,7 @@ nsresult nsMsgDatabase::InitNewDB()
// create the unique table for the dbFolderInfo.
mdb_err err = store->NewTable(GetEnv(), m_hdrRowScopeToken,
m_hdrTableKindToken, PR_FALSE, &m_mdbAllMsgHeadersTable);
m_dbFolderInfo = dbFolderInfo;
}
else
@ -420,6 +428,9 @@ nsresult nsMsgDatabase::InitExistingDB()
if (err == NS_OK)
{
err = GetStore()->GetTable(GetEnv(), &gAllMsgHdrsTableOID, &m_mdbAllMsgHeadersTable);
if (err == NS_OK)
m_dbFolderInfo = new nsDBFolderInfo(this);
}
return err;
}

View File

@ -99,7 +99,7 @@ NS_IMETHODIMP nsMsgHdr::GetFlags(PRUint32 *result)
NS_IMETHODIMP nsMsgHdr::SetFlags(PRUint32 flags)
{
m_flags = flags;
SetUInt32Column(m_mdb->m_flagsColumnToken, m_flags);
SetUInt32Column(m_flags, m_mdb->m_flagsColumnToken);
return NS_OK;
}
@ -218,24 +218,24 @@ NS_IMETHODIMP nsMsgHdr::SetCCList(const char *ccList)
NS_IMETHODIMP nsMsgHdr::SetMessageSize(PRUint32 messageSize)
{
SetUInt32Column(m_mdb->m_messageSizeColumnToken, messageSize);
SetUInt32Column(messageSize, m_mdb->m_messageSizeColumnToken);
return NS_OK;
}
NS_IMETHODIMP nsMsgHdr::SetLineCount(PRUint32 lineCount)
{
SetUInt32Column(m_mdb->m_numLinesColumnToken, lineCount);
SetUInt32Column(lineCount, m_mdb->m_numLinesColumnToken);
return NS_OK;
}
NS_IMETHODIMP nsMsgHdr::SetStatusOffset(PRUint32 statusOffset)
{
return SetUInt32Column(m_mdb->m_statusOffsetColumnToken, statusOffset);
return SetUInt32Column(statusOffset, m_mdb->m_statusOffsetColumnToken);
}
NS_IMETHODIMP nsMsgHdr::SetDate(time_t date)
{
return SetUInt32Column(m_mdb->m_dateColumnToken, (PRUint32) date);
return SetUInt32Column((PRUint32) date, m_mdb->m_dateColumnToken);
}
NS_IMETHODIMP nsMsgHdr::GetStatusOffset(PRUint32 *result)
@ -259,6 +259,15 @@ NS_IMETHODIMP nsMsgHdr::GetMessageOffset(PRUint32 *result)
return NS_OK;
}
NS_IMETHODIMP nsMsgHdr::GetMessageSize(PRUint32 *result)
{
PRUint32 size;
nsresult res = GetUInt32Column(m_mdb->m_messageSizeColumnToken, &size);
*result = size;
return res;
}
NS_IMETHODIMP nsMsgHdr::SetPriority(const char *priority)
{
// ### TODO
@ -273,12 +282,20 @@ nsresult nsMsgHdr::SetStringColumn(const char *str, mdb_token token)
yarn.mYarn_Size = PL_strlen((const char *) yarn.mYarn_Buf) + 1;
yarn.mYarn_Fill = yarn.mYarn_Size;
yarn.mYarn_Form = 0;
yarn.mYarn_Grow = NULL;
return m_mdbRow->AddColumn(m_mdb->GetEnv(), token, &yarn);
}
nsresult nsMsgHdr::SetUInt32Column(PRUint32 value, mdb_token token)
{
char yarnBuf[100];
struct mdbYarn yarn;
yarn.mYarn_Buf = (void *) yarnBuf;
yarn.mYarn_Size = sizeof(yarnBuf);
yarn.mYarn_Fill = yarn.mYarn_Size;
yarn.mYarn_Form = 0;
yarn.mYarn_Grow = NULL;
return m_mdbRow->AddColumn(m_mdb->GetEnv(), token, nsMsgDatabase::UInt32ToYarn(&yarn, value));
}