зеркало из https://github.com/mozilla/pjs.git
Added NS_New functions for a bunch of datasources.
This commit is contained in:
Родитель
1c0f98e020
Коммит
ab4c7dafe3
|
@ -247,36 +247,15 @@ nsMsgFactory::CreateInstance(nsISupports * /* aOuter */,
|
|||
}
|
||||
else if (mClassID.Equals(kMailNewsFolderDataSourceCID))
|
||||
{
|
||||
nsMsgFolderDataSource * folderDataSource = new nsMsgFolderDataSource();
|
||||
if (folderDataSource == nsnull)
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
else {
|
||||
rv = folderDataSource->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(rv))
|
||||
delete folderDataSource;
|
||||
}
|
||||
rv = NS_NewMsgFolderDataSource(aIID, aResult);
|
||||
}
|
||||
else if (mClassID.Equals(kMailNewsMessageDataSourceCID))
|
||||
{
|
||||
nsMsgMessageDataSource * messageDataSource = new nsMsgMessageDataSource();
|
||||
if (messageDataSource == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
else {
|
||||
rv = messageDataSource->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(rv))
|
||||
delete messageDataSource;
|
||||
}
|
||||
rv = NS_NewMsgMessageDataSource(aIID, aResult);
|
||||
}
|
||||
else if (mClassID.Equals(kCMessageViewDataSourceCID))
|
||||
{
|
||||
nsMessageViewDataSource * msgView = new nsMessageViewDataSource();
|
||||
if (msgView == nsnull)
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
else {
|
||||
rv = msgView->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(rv))
|
||||
delete msgView;
|
||||
}
|
||||
rv = NS_NewMessageViewDataSource(aIID, aResult);
|
||||
}
|
||||
|
||||
// account manager RDF datasources
|
||||
|
|
|
@ -251,3 +251,7 @@ protected:
|
|||
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
PR_EXTERN(nsresult)
|
||||
NS_NewMessageViewDataSource(const nsIID& iid, void **result);
|
||||
|
|
|
@ -69,17 +69,7 @@ nsMsgFolderDataSource::nsMsgFolderDataSource():
|
|||
mInitialized(PR_FALSE),
|
||||
mRDFService(nsnull)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = Init();
|
||||
|
||||
// XXX This call should be moved to a NS_NewMsgFooDataSource()
|
||||
// method that the factory calls, so that failure to construct
|
||||
// will return an error code instead of returning a partially
|
||||
// initialized object.
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "uh oh, initialization failed");
|
||||
if (NS_FAILED(rv)) return /* rv */;
|
||||
|
||||
return /* NS_OK */;
|
||||
}
|
||||
|
||||
nsMsgFolderDataSource::~nsMsgFolderDataSource (void)
|
||||
|
@ -727,6 +717,12 @@ nsMsgFolderDataSource::createFolderSpecialNode(nsIMsgFolder *folder,
|
|||
specialFolderString = "Trash";
|
||||
else if(flags & MSG_FOLDER_FLAG_QUEUE)
|
||||
specialFolderString = "Unsent Messages";
|
||||
else if(flags & MSG_FOLDER_FLAG_SENTMAIL)
|
||||
specialFolderString = "Sent";
|
||||
else if(flags & MSG_FOLDER_FLAG_DRAFTS)
|
||||
specialFolderString = "Drafts";
|
||||
else if(flags & MSG_FOLDER_FLAG_TEMPLATES)
|
||||
specialFolderString = "Templates";
|
||||
else
|
||||
specialFolderString = "none";
|
||||
|
||||
|
@ -1050,3 +1046,24 @@ nsresult nsMsgFolderDataSource::DoFolderHasAssertion(nsIMsgFolder *folder, nsIRD
|
|||
|
||||
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewMsgFolderDataSource(const nsIID& iid, void **result)
|
||||
{
|
||||
NS_PRECONDITION(result != nsnull, "null ptr");
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsMsgFolderDataSource* datasource = new nsMsgFolderDataSource();
|
||||
if (! datasource)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult rv;
|
||||
rv = datasource->Init();
|
||||
if (NS_FAILED(rv)) {
|
||||
delete datasource;
|
||||
return rv;
|
||||
}
|
||||
|
||||
return datasource->QueryInterface(iid, result);
|
||||
}
|
|
@ -175,3 +175,6 @@ protected:
|
|||
static nsIRDFResource* kNC_Move;
|
||||
|
||||
};
|
||||
|
||||
PR_EXTERN(nsresult)
|
||||
NS_NewMsgFolderDataSource(const nsIID& iid, void **result);
|
||||
|
|
|
@ -63,41 +63,8 @@ nsMsgMessageDataSource::nsMsgMessageDataSource():
|
|||
mRDFService(nsnull),
|
||||
mHeaderParser(nsnull)
|
||||
{
|
||||
nsresult rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
nsIRDFService::GetIID(),
|
||||
(nsISupports**) &mRDFService); // XXX probably need shutdown listener here
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kMsgHeaderParserCID,
|
||||
NULL,
|
||||
nsIMsgHeaderParser::GetIID(),
|
||||
(void **) &mHeaderParser);
|
||||
|
||||
nsILocaleFactory *localeFactory;
|
||||
rv = nsComponentManager::FindFactory(kLocaleFactoryCID, (nsIFactory**)&localeFactory);
|
||||
|
||||
if(NS_SUCCEEDED(rv) && localeFactory)
|
||||
{
|
||||
rv = localeFactory->GetApplicationLocale(getter_AddRefs(mApplicationLocale));
|
||||
NS_IF_RELEASE(localeFactory);
|
||||
}
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kDateTimeFormatCID, NULL,
|
||||
kIDateTimeFormatIID, getter_AddRefs(mDateTimeFormat));
|
||||
|
||||
NS_WITH_SERVICE(nsIMsgMailSession, mailSession, kMsgMailSessionCID, &rv);
|
||||
if(NS_SUCCEEDED(rv))
|
||||
mailSession->AddFolderListener(this);
|
||||
PR_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
// XXX This call should be moved to a NS_NewMsgFooDataSource()
|
||||
// method that the factory calls, so that failure to construct
|
||||
// will return an error code instead of returning a partially
|
||||
// initialized object.
|
||||
rv = Init();
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "uh oh, initialization failed");
|
||||
if (NS_FAILED(rv)) return /* rv */;
|
||||
|
||||
return /* NS_OK */;
|
||||
}
|
||||
|
||||
nsMsgMessageDataSource::~nsMsgMessageDataSource (void)
|
||||
|
@ -128,25 +95,62 @@ nsMsgMessageDataSource::~nsMsgMessageDataSource (void)
|
|||
|
||||
nsresult nsMsgMessageDataSource::Init()
|
||||
{
|
||||
if (mInitialized)
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
if (mInitialized)
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
|
||||
mRDFService->RegisterDataSource(this, PR_FALSE);
|
||||
|
||||
if (! kNC_Subject) {
|
||||
nsresult rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
nsIRDFService::GetIID(),
|
||||
(nsISupports**) &mRDFService); // XXX probably need shutdown listener here
|
||||
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
mRDFService->RegisterDataSource(this, PR_FALSE);
|
||||
rv = nsComponentManager::CreateInstance(kMsgHeaderParserCID,
|
||||
NULL,
|
||||
nsIMsgHeaderParser::GetIID(),
|
||||
(void **) &mHeaderParser);
|
||||
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsILocaleFactory *localeFactory;
|
||||
rv = nsComponentManager::FindFactory(kLocaleFactoryCID, (nsIFactory**)&localeFactory);
|
||||
|
||||
if(NS_SUCCEEDED(rv) && localeFactory)
|
||||
{
|
||||
rv = localeFactory->GetApplicationLocale(getter_AddRefs(mApplicationLocale));
|
||||
NS_IF_RELEASE(localeFactory);
|
||||
}
|
||||
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kDateTimeFormatCID, NULL,
|
||||
kIDateTimeFormatIID, getter_AddRefs(mDateTimeFormat));
|
||||
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
NS_WITH_SERVICE(nsIMsgMailSession, mailSession, kMsgMailSessionCID, &rv);
|
||||
if(NS_SUCCEEDED(rv))
|
||||
mailSession->AddFolderListener(this);
|
||||
PR_ASSERT(NS_SUCCEEDED(rv));
|
||||
if (! kNC_Subject) {
|
||||
|
||||
mRDFService->GetResource(NC_RDF_SUBJECT, &kNC_Subject);
|
||||
mRDFService->GetResource(NC_RDF_SENDER, &kNC_Sender);
|
||||
mRDFService->GetResource(NC_RDF_DATE, &kNC_Date);
|
||||
mRDFService->GetResource(NC_RDF_STATUS, &kNC_Status);
|
||||
mRDFService->GetResource(NC_RDF_SUBJECT, &kNC_Subject);
|
||||
mRDFService->GetResource(NC_RDF_SENDER, &kNC_Sender);
|
||||
mRDFService->GetResource(NC_RDF_DATE, &kNC_Date);
|
||||
mRDFService->GetResource(NC_RDF_STATUS, &kNC_Status);
|
||||
|
||||
mRDFService->GetResource(NC_RDF_MARKREAD, &kNC_MarkRead);
|
||||
mRDFService->GetResource(NC_RDF_MARKUNREAD, &kNC_MarkUnread);
|
||||
mRDFService->GetResource(NC_RDF_TOGGLEREAD, &kNC_ToggleRead);
|
||||
mRDFService->GetResource(NC_RDF_MARKREAD, &kNC_MarkRead);
|
||||
mRDFService->GetResource(NC_RDF_MARKUNREAD, &kNC_MarkUnread);
|
||||
mRDFService->GetResource(NC_RDF_TOGGLEREAD, &kNC_ToggleRead);
|
||||
|
||||
}
|
||||
mInitialized = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
mInitialized = PR_TRUE;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsMsgMessageDataSource, nsMsgRDFDataSource)
|
||||
|
@ -636,4 +640,23 @@ nsresult nsMsgMessageDataSource::NotifyPropertyChanged(nsIRDFResource *resource,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewMsgMessageDataSource(const nsIID& iid, void **result)
|
||||
{
|
||||
NS_PRECONDITION(result != nsnull, "null ptr");
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsMsgMessageDataSource* datasource = new nsMsgMessageDataSource();
|
||||
if (! datasource)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult rv;
|
||||
rv = datasource->Init();
|
||||
if (NS_FAILED(rv)) {
|
||||
delete datasource;
|
||||
return rv;
|
||||
}
|
||||
|
||||
return datasource->QueryInterface(iid, result);
|
||||
}
|
||||
|
|
|
@ -160,3 +160,6 @@ protected:
|
|||
|
||||
|
||||
};
|
||||
|
||||
PR_EXTERN(nsresult)
|
||||
NS_NewMsgMessageDataSource(const nsIID& iid, void **result);
|
||||
|
|
Загрузка…
Ссылка в новой задаче