start working on making nsMsgDatabase scriptable

This commit is contained in:
bienvenu%netscape.com 1999-06-25 19:46:47 +00:00
Родитель dbe26fc300
Коммит 5374b0377c
17 изменённых файлов: 73 добавлений и 43 удалений

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

@ -73,7 +73,7 @@ public:
class nsIMsgDatabase : public nsIDBChangeAnnouncer {
public:
// open local folder...
NS_IMETHOD Open(nsFileSpec &folderName, PRBool create, nsIMsgDatabase** pMessageDB, PRBool upgrading) = 0;
NS_IMETHOD Open(nsIFileSpec *folderName, PRBool create, nsIMsgDatabase** pMessageDB, PRBool upgrading) = 0;
NS_IMETHOD Close(PRBool forceCommit) = 0;
NS_IMETHOD OpenMDB(const char *dbName, PRBool create) = 0;
NS_IMETHOD CloseMDB(PRBool commit) = 0;

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

@ -29,7 +29,7 @@ public:
nsImapMailDatabase();
virtual ~nsImapMailDatabase();
NS_IMETHOD Open(nsFileSpec &folderName, PRBool create, nsIMsgDatabase** pMessageDB, PRBool upgrading /*=PR_FALSE*/);
NS_IMETHOD Open(nsIFileSpec *folderName, PRBool create, nsIMsgDatabase** pMessageDB, PRBool upgrading /*=PR_FALSE*/);
NS_IMETHOD SetSummaryValid(PRBool valid = TRUE);

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

@ -40,7 +40,7 @@ class nsMailDatabase : public nsMsgDatabase
public:
nsMailDatabase();
virtual ~nsMailDatabase();
NS_IMETHOD Open(nsFileSpec &folderName, PRBool create, nsIMsgDatabase** pMessageDB,
NS_IMETHOD Open(nsIFileSpec *aFolderName, PRBool create, nsIMsgDatabase** pMessageDB,
PRBool upgrading = PR_FALSE);
static nsresult CloneInvalidDBInfoIntoNewDB(nsFileSpec &pathName, nsMailDatabase** pMailDB);

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

@ -57,7 +57,7 @@ public:
//////////////////////////////////////////////////////////////////////////////
// nsIMsgDatabase methods:
NS_IMETHOD Open(nsFileSpec &folderName, PRBool create, nsIMsgDatabase** pMessageDB, PRBool upgrading);
NS_IMETHOD Open(nsIFileSpec *folderName, PRBool create, nsIMsgDatabase** pMessageDB, PRBool upgrading);
NS_IMETHOD Close(PRBool forceCommit);
// argh, these two shouldn't be Interface methods, but I can't diddle the interfaces

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

@ -35,7 +35,7 @@ public:
virtual ~nsNewsDatabase();
virtual nsresult MessageDBOpenUsingURL(const char * groupURL);
char *GetGroupURL() { return m_groupURL; }
NS_IMETHOD Open(nsFileSpec &newsgroupName, PRBool create, nsIMsgDatabase** pMessageDB, PRBool upgrading /*=PR_FALSE*/);
NS_IMETHOD Open(nsIFileSpec *newsgroupName, PRBool create, nsIMsgDatabase** pMessageDB, PRBool upgrading /*=PR_FALSE*/);
NS_IMETHOD Close(PRBool forceCommit);
NS_IMETHOD ForceClosed();
NS_IMETHOD Commit(nsMsgDBCommitType commitType);

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

@ -29,12 +29,18 @@ nsImapMailDatabase::~nsImapMailDatabase()
{
}
NS_IMETHODIMP nsImapMailDatabase::Open(nsFileSpec &folderName, PRBool create, nsIMsgDatabase** pMessageDB, PRBool upgrading /*=PR_FALSE*/)
NS_IMETHODIMP nsImapMailDatabase::Open(nsIFileSpec *aFolderName, PRBool create, nsIMsgDatabase** pMessageDB, PRBool upgrading /*=PR_FALSE*/)
{
nsImapMailDatabase *mailDB;
PRBool summaryFileExists;
struct stat st;
PRBool newFile = PR_FALSE;
if (!aFolderName)
return NS_ERROR_NULL_POINTER;
nsFileSpec folderName;
aFolderName->GetFileSpec(&folderName);
nsLocalFolderSummarySpec summarySpec(folderName);
#ifdef DEBUG_bienvenu

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

@ -38,11 +38,16 @@ nsMailDatabase::~nsMailDatabase()
NS_IMETHODIMP nsMailDatabase::Open(nsFileSpec &folderName, PRBool create, nsIMsgDatabase** pMessageDB, PRBool upgrading /*=PR_FALSE*/)
NS_IMETHODIMP nsMailDatabase::Open(nsIFileSpec *aFolderName, PRBool create, nsIMsgDatabase** pMessageDB, PRBool upgrading /*=PR_FALSE*/)
{
nsMailDatabase *mailDB;
PRBool summaryFileExists;
PRBool newFile = PR_FALSE;
nsFileSpec folderName;
if (!aFolderName)
return NS_ERROR_NULL_POINTER;
aFolderName->GetFileSpec(&folderName);
nsLocalFolderSummarySpec summarySpec(folderName);
nsIDBFolderInfo *folderInfo = NULL;

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

@ -491,7 +491,7 @@ void nsMsgDatabase::NativeToUnix(char*& ioPath)
}
#endif /* XP_MAC */
NS_IMETHODIMP nsMsgDatabase::Open(nsFileSpec &folderName, PRBool create, nsIMsgDatabase** pMessageDB, PRBool upgrading /*=PR_FALSE*/)
NS_IMETHODIMP nsMsgDatabase::Open(nsIFileSpec *folderName, PRBool create, nsIMsgDatabase** pMessageDB, PRBool upgrading /*=PR_FALSE*/)
{
NS_ASSERTION(FALSE, "must override");
return NS_ERROR_NOT_IMPLEMENTED;

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

@ -38,9 +38,16 @@ nsresult nsNewsDatabase::MessageDBOpenUsingURL(const char * groupURL)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsNewsDatabase::Open(nsFileSpec &newsgroupName, PRBool create, nsIMsgDatabase** pMessageDB, PRBool upgrading /*=PR_FALSE*/)
NS_IMETHODIMP nsNewsDatabase::Open(nsIFileSpec *aNewsgroupName, PRBool create, nsIMsgDatabase** pMessageDB, PRBool upgrading /*=PR_FALSE*/)
{
nsNewsDatabase *newsDB;
if (!aNewsgroupName)
return NS_ERROR_NULL_POINTER;
nsFileSpec newsgroupName;
aNewsgroupName->GetFileSpec(&newsgroupName);
nsNewsSummarySpec summarySpec(newsgroupName);
nsresult err = NS_OK;

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

@ -394,15 +394,11 @@ nsresult nsImapMailFolder::GetDatabase()
nsresult rv = GetPath(getter_AddRefs(pathSpec));
if (NS_FAILED(rv)) return rv;
nsFileSpec path;
rv = pathSpec->GetFileSpec(&path);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIMsgDatabase> mailDBFactory;
rv = nsComponentManager::CreateInstance(kCImapDB, nsnull, nsIMsgDatabase::GetIID(), (void **) getter_AddRefs(mailDBFactory));
if (NS_SUCCEEDED(rv) && mailDBFactory)
folderOpen = mailDBFactory->Open(path, PR_TRUE, getter_AddRefs(mDatabase), PR_TRUE);
folderOpen = mailDBFactory->Open(pathSpec, PR_TRUE, getter_AddRefs(mDatabase), PR_TRUE);
if(mDatabase)
{
@ -533,7 +529,9 @@ NS_IMETHODIMP nsImapMailFolder::CreateSubfolder(const char *folderName)
if (NS_SUCCEEDED(rv) && mailDBFactory)
{
nsCOMPtr<nsIMsgDatabase> unusedDB;
rv = mailDBFactory->Open(path, PR_TRUE, (nsIMsgDatabase **) getter_AddRefs(unusedDB), PR_TRUE);
nsCOMPtr <nsIFileSpec> dbFileSpec;
NS_NewFileSpecWithSpec(path, getter_AddRefs(dbFileSpec));
rv = mailDBFactory->Open(dbFileSpec, PR_TRUE, (nsIMsgDatabase **) getter_AddRefs(unusedDB), PR_TRUE);
if (NS_SUCCEEDED(rv) && unusedDB)
{
@ -547,8 +545,7 @@ NS_IMETHODIMP nsImapMailFolder::CreateSubfolder(const char *folderName)
}
//Now let's create the actual new folder
rv = AddSubfolder(folderNameStr,
getter_AddRefs(child));
rv = AddSubfolder(folderNameStr, getter_AddRefs(child));
unusedDB->SetSummaryValid(PR_TRUE);
unusedDB->Commit(kLargeCommit);
unusedDB->Close(PR_TRUE);
@ -861,11 +858,7 @@ nsresult nsImapMailFolder::GetDBFolderInfoAndDB(
rv = GetPath(getter_AddRefs(pathSpec));
if (NS_FAILED(rv)) return rv;
nsFileSpec dbName;
rv = pathSpec->GetFileSpec(&dbName);
if (NS_FAILED(rv)) return rv;
openErr = mailDBFactory->Open(dbName, PR_FALSE, (nsIMsgDatabase **) &mailDB, PR_FALSE);
openErr = mailDBFactory->Open(pathSpec, PR_FALSE, (nsIMsgDatabase **) &mailDB, PR_FALSE);
}
*db = mailDB;
@ -1144,7 +1137,7 @@ NS_IMETHODIMP nsImapMailFolder::UpdateImapMailboxInfo(
{
// if we pass in PR_TRUE for upgrading, the db code will ignore the
// summary out of date problem for now.
rv = mailDBFactory->Open(dbName, PR_TRUE, (nsIMsgDatabase **)
rv = mailDBFactory->Open(pathSpec, PR_TRUE, (nsIMsgDatabase **)
getter_AddRefs(mDatabase), PR_TRUE);
if (NS_FAILED(rv))
return rv;
@ -1184,7 +1177,7 @@ NS_IMETHODIMP nsImapMailFolder::UpdateImapMailboxInfo(
// Create a new summary file, update the folder message counts, and
// Close the summary file db.
rv = mailDBFactory->Open(dbName, PR_TRUE, getter_AddRefs(mDatabase), PR_TRUE);
rv = mailDBFactory->Open(pathSpec, PR_TRUE, getter_AddRefs(mDatabase), PR_TRUE);
// ********** Important *************
// David, help me here I don't know this is right or wrong

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

@ -362,12 +362,12 @@ nsresult nsMsgLocalMailFolder::GetDatabase()
rv = nsComponentManager::CreateInstance(kCMailDB, nsnull, nsIMsgDatabase::GetIID(), getter_AddRefs(mailDBFactory));
if (NS_SUCCEEDED(rv) && mailDBFactory)
{
folderOpen = mailDBFactory->Open(path, PR_TRUE, getter_AddRefs(mDatabase), PR_FALSE);
folderOpen = mailDBFactory->Open(pathSpec, PR_TRUE, getter_AddRefs(mDatabase), PR_FALSE);
if(!NS_SUCCEEDED(folderOpen) &&
folderOpen == NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE || folderOpen == NS_MSG_ERROR_FOLDER_SUMMARY_MISSING )
{
// if it's out of date then reopen with upgrade.
if(!NS_SUCCEEDED(rv = mailDBFactory->Open(path, PR_TRUE, getter_AddRefs(mDatabase), PR_TRUE)))
if(!NS_SUCCEEDED(rv = mailDBFactory->Open(pathSpec, PR_TRUE, getter_AddRefs(mDatabase), PR_TRUE)))
{
return rv;
}
@ -514,7 +514,9 @@ NS_IMETHODIMP nsMsgLocalMailFolder::CreateSubfolder(const char *folderName)
if (NS_SUCCEEDED(rv) && mailDBFactory)
{
nsIMsgDatabase *unusedDB = NULL;
rv = mailDBFactory->Open(path, PR_TRUE, (nsIMsgDatabase **) &unusedDB, PR_TRUE);
nsCOMPtr <nsIFileSpec> dbFileSpec;
NS_NewFileSpecWithSpec(path, getter_AddRefs(dbFileSpec));
rv = mailDBFactory->Open(dbFileSpec, PR_TRUE, (nsIMsgDatabase **) &unusedDB, PR_TRUE);
if (NS_SUCCEEDED(rv) && unusedDB)
{
@ -777,7 +779,9 @@ nsresult nsMsgLocalMailFolder::GetDBFolderInfoAndDB(nsIDBFolderInfo **folderInf
nsresult rv = nsComponentManager::CreateInstance(kCMailDB, nsnull, nsIMsgDatabase::GetIID(), getter_AddRefs(mailDBFactory));
if (NS_SUCCEEDED(rv) && mailDBFactory)
{
openErr = mailDBFactory->Open(*mPath, PR_FALSE, (nsIMsgDatabase **) &mailDB, PR_FALSE);
nsCOMPtr <nsIFileSpec> dbFileSpec;
NS_NewFileSpecWithSpec(*mPath, getter_AddRefs(dbFileSpec));
openErr = mailDBFactory->Open(dbFileSpec, PR_FALSE, (nsIMsgDatabase **) &mailDB, PR_FALSE);
}
*db = mailDB;

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

@ -287,8 +287,11 @@ NS_IMETHODIMP nsMailboxUrl::GetMessageHeader(nsIMsgDBHdr ** aMsgHdr)
rv = nsComponentManager::CreateInstance(kCMailDB, nsnull, nsIMsgDatabase::GetIID(),
(void **) getter_AddRefs(mailDBFactory));
nsCOMPtr <nsIFileSpec> dbFileSpec;
NS_NewFileSpecWithSpec(*m_filePath, getter_AddRefs(dbFileSpec));
if (NS_SUCCEEDED(rv) && mailDBFactory)
rv = mailDBFactory->Open((nsFileSpec&) *m_filePath, PR_FALSE, (nsIMsgDatabase **) getter_AddRefs(mailDB), PR_FALSE);
rv = mailDBFactory->Open(dbFileSpec, PR_FALSE, (nsIMsgDatabase **) getter_AddRefs(mailDB), PR_FALSE);
if (NS_SUCCEEDED(rv) && mailDB) // did we get a db back?
rv = mailDB->GetMsgHdrForKey(m_messageKey, aMsgHdr);
}

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

@ -82,7 +82,11 @@ NS_IMETHODIMP nsMsgMailboxParser::OnStartBinding(nsIURI* aURL, const char *aCont
nsCOMPtr<nsIMsgDatabase> mailDB;
rv = nsComponentManager::CreateInstance(kCMailDB, nsnull, nsIMsgDatabase::GetIID(), (void **) getter_AddRefs(mailDB));
if (NS_SUCCEEDED(rv) && mailDB)
rv = mailDB->Open(dbName, PR_TRUE, (nsIMsgDatabase **) getter_AddRefs(m_mailDB), PR_TRUE);
{
nsCOMPtr <nsIFileSpec> dbFileSpec;
NS_NewFileSpecWithSpec(dbName, getter_AddRefs(dbFileSpec));
rv = mailDB->Open(dbFileSpec, PR_TRUE, (nsIMsgDatabase **) getter_AddRefs(m_mailDB), PR_TRUE);
}
NS_ASSERTION(m_mailDB, "failed to open mail db parsing folder");
printf("url file = %s\n", fileName);
}
@ -1369,7 +1373,11 @@ nsParseNewMailState::Init(nsIFolder *rootFolder, nsFileSpec &folder, nsIOFileStr
nsCOMPtr<nsIMsgDatabase> mailDB;
rv = nsComponentManager::CreateInstance(kCMailDB, nsnull, nsIMsgDatabase::GetIID(), (void **) getter_AddRefs(mailDB));
if (NS_SUCCEEDED(rv) && mailDB)
rv = mailDB->Open(folder, PR_TRUE, (nsIMsgDatabase **) getter_AddRefs(m_mailDB), PR_FALSE);
{
nsCOMPtr <nsIFileSpec> dbFileSpec;
NS_NewFileSpecWithSpec(folder, getter_AddRefs(dbFileSpec));
rv = mailDB->Open(dbFileSpec, PR_TRUE, (nsIMsgDatabase **) getter_AddRefs(m_mailDB), PR_FALSE);
}
// rv = nsMailDatabase::Open(folder, PR_TRUE, &m_mailDB, PR_FALSE);
if (NS_FAILED(rv))
return rv;

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

@ -151,7 +151,7 @@ nsresult
nsNNTPNewsgroupList::GetDatabase(const char *uri, nsIMsgDatabase **db)
{
if (*db == nsnull) {
nsNativeFileSpec path;
nsFileSpec path;
nsresult rv = nsNewsURI2Path(kNewsRootURI, uri, path);
if (NS_FAILED(rv)) return rv;
@ -160,7 +160,9 @@ nsNNTPNewsgroupList::GetDatabase(const char *uri, nsIMsgDatabase **db)
rv = nsComponentManager::CreateInstance(kCNewsDB, nsnull, nsIMsgDatabase::GetIID(), (void **) &newsDBFactory);
if (NS_SUCCEEDED(rv) && newsDBFactory) {
newsDBOpen = newsDBFactory->Open(path, PR_TRUE, (nsIMsgDatabase **) db, PR_FALSE);
nsCOMPtr <nsIFileSpec> dbFileSpec;
NS_NewFileSpecWithSpec(path, getter_AddRefs(dbFileSpec));
newsDBOpen = newsDBFactory->Open(dbFileSpec, PR_TRUE, (nsIMsgDatabase **) db, PR_FALSE);
#ifdef DEBUG_NEWS
if (NS_SUCCEEDED(newsDBOpen)) {
printf ("newsDBFactory->Open() succeeded\n");

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

@ -504,17 +504,13 @@ nsresult nsMsgNewsFolder::GetDatabase()
rv = GetPath(getter_AddRefs(pathSpec));
if (NS_FAILED(rv)) return rv;
nsFileSpec path;
rv = pathSpec->GetFileSpec(&path);
if (NS_FAILED(rv)) return rv;
nsresult folderOpen = NS_OK;
nsCOMPtr <nsIMsgDatabase> newsDBFactory;
rv = nsComponentManager::CreateInstance(kCNewsDB, nsnull, nsIMsgDatabase::GetIID(), getter_AddRefs(newsDBFactory));
if (NS_SUCCEEDED(rv) && newsDBFactory)
{
folderOpen = newsDBFactory->Open(path, PR_TRUE, getter_AddRefs(mDatabase), PR_FALSE);
folderOpen = newsDBFactory->Open(pathSpec, PR_TRUE, getter_AddRefs(mDatabase), PR_FALSE);
#ifdef DEBUG_NEWS
if (NS_SUCCEEDED(folderOpen)) {
printf ("newsDBFactory->Open() succeeded\n");
@ -872,7 +868,9 @@ nsresult nsMsgNewsFolder::GetDBFolderInfoAndDB(nsIDBFolderInfo **folderInfo, ns
nsresult rv = nsComponentManager::CreateInstance(kCNewsDB, nsnull, nsIMsgDatabase::GetIID(), getter_AddRefs(newsDBFactory));
if (NS_SUCCEEDED(rv) && newsDBFactory) {
openErr = newsDBFactory->Open(*mPath, PR_FALSE, (nsIMsgDatabase **) &newsDB, PR_FALSE);
nsCOMPtr <nsIFileSpec> dbFileSpec;
NS_NewFileSpecWithSpec(*mPath, getter_AddRefs(dbFileSpec));
openErr = newsDBFactory->Open(dbFileSpec, PR_FALSE, (nsIMsgDatabase **) &newsDB, PR_FALSE);
}
else {
return rv;

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

@ -202,7 +202,7 @@ nsresult nsNntpService::ConvertNewsMessageURI2NewsURI(const char *messageURI, ns
printf("ConvertNewsMessageURI2NewsURI(%s,??) -> %s %u\n", messageURI, newsgroupName.GetBuffer(), *key);
#endif
nsNativeFileSpec pathResult;
nsFileSpec pathResult;
rv = nsNewsURI2Path(kNewsMessageRootURI, messageUriWithoutKey.GetBuffer(), pathResult);
if (NS_FAILED(rv)) {
@ -217,7 +217,9 @@ nsresult nsNntpService::ConvertNewsMessageURI2NewsURI(const char *messageURI, ns
return rv;
}
rv = newsDBFactory->Open(pathResult, PR_TRUE, getter_AddRefs(newsDB), PR_FALSE);
nsCOMPtr <nsIFileSpec> dbFileSpec;
NS_NewFileSpecWithSpec(pathResult, getter_AddRefs(dbFileSpec));
rv = newsDBFactory->Open(dbFileSpec, PR_TRUE, getter_AddRefs(newsDB), PR_FALSE);
if (NS_FAILED(rv) || (!newsDB)) {
return rv;

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

@ -513,7 +513,7 @@ nsresult nsNntpUrl::GetMessageToPost(nsINNTPNewsgroupPost **aPost)
NS_IMETHODIMP nsNntpUrl::GetMessageHeader(nsIMsgDBHdr ** aMsgHdr)
{
nsresult rv = NS_OK;
nsNativeFileSpec pathResult;
nsFileSpec pathResult;
if (!aMsgHdr) return NS_ERROR_NULL_POINTER;
@ -540,7 +540,9 @@ NS_IMETHODIMP nsNntpUrl::GetMessageHeader(nsIMsgDBHdr ** aMsgHdr)
return rv;
}
rv = newsDBFactory->Open(pathResult, PR_TRUE, getter_AddRefs(newsDB), PR_FALSE);
nsCOMPtr <nsIFileSpec> dbFileSpec;
NS_NewFileSpecWithSpec(pathResult, getter_AddRefs(dbFileSpec));
rv = newsDBFactory->Open(dbFileSpec, PR_TRUE, getter_AddRefs(newsDB), PR_FALSE);
if (NS_FAILED(rv) || (!newsDB)) {
return rv;