Added nsIRDFDataSource::HasArcIn/HasArcOut. Changed nsXULTemplateBuilder.cpp to use it (ifdef'd for now). Speed up folder loading by about 24%. r=waterson,alecf

This commit is contained in:
warren%netscape.com 2000-07-19 03:58:25 +00:00
Родитель ff320436f0
Коммит de3523d540
39 изменённых файлов: 985 добавлений и 368 удалений

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

@ -257,6 +257,18 @@ nsChromeUIDataSource::RemoveObserver(nsIRDFObserver* aObserver)
return NS_OK;
}
NS_IMETHODIMP
nsChromeUIDataSource::HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, PRBool *result)
{
return mComposite->HasArcIn(aNode, aArc, result);
}
NS_IMETHODIMP
nsChromeUIDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *result)
{
return mComposite->HasArcOut(aSource, aArc, result);
}
NS_IMETHODIMP
nsChromeUIDataSource::ArcLabelsIn(nsIRDFNode* aTarget, nsISimpleEnumerator** aResult)
{

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

@ -97,6 +97,10 @@
#include "nsIFormControl.h"
#include "nsIDOMHTMLFormElement.h"
#if defined(DEBUG_warren) || defined(DEBUG_waterson) || defined(DEBUG_alecf) || defined(DEBUG_bienvenu) || defined(DEBUG_mscott)
#define RDF_USE_HAS_ARC_OUT 1
#endif
// Return values for EnsureElementHasGenericChild()
#define NS_RDF_ELEMENT_GOT_CREATED NS_RDF_NO_VALUE
#define NS_RDF_ELEMENT_WAS_THERE NS_OK
@ -5897,6 +5901,52 @@ nsXULTemplateBuilder::CheckContainer(nsIRDFResource* aResource, PRBool* aIsConta
// we know we'll have children.
nsresult rv;
#ifdef RDF_USE_HAS_ARC_OUT
*aIsContainer = PR_FALSE;
*aIsEmpty = PR_TRUE;
for (ResourceSet::ConstIterator property = mContainmentProperties.First();
property != mContainmentProperties.Last();
property++) {
PRBool hasArc;
rv = mDB->HasArcOut(aResource, *property, &hasArc);
if (NS_FAILED(rv)) return rv;
if (hasArc) {
// Well, it's a container...
*aIsContainer = PR_TRUE;
// ...is it empty?
nsCOMPtr<nsIRDFNode> dummy;
rv = mDB->GetTarget(aResource, *property, PR_TRUE, getter_AddRefs(dummy));
if (NS_FAILED(rv)) return rv;
if (dummy != nsnull) {
*aIsEmpty = PR_FALSE;
return NS_OK;
}
// Even if there isn't a target for *this* containment
// property, we have continue to check the other
// properties: one of them may have a target.
}
}
// If we get here, and it's a container, then it's an *empty*
// container.
if (*aIsContainer)
return NS_OK;
// Otherwise, just return whether or not it's an RDF container
rv = gRDFContainerUtils->IsContainer(mDB, aResource, aIsContainer);
if (NS_FAILED(rv)) return rv;
if (*aIsContainer) {
rv = gRDFContainerUtils->IsEmpty(mDB, aResource, aIsEmpty);
if (NS_FAILED(rv)) return rv;
}
return NS_OK;
#else
nsCOMPtr<nsISimpleEnumerator> arcs;
rv = mDB->ArcLabelsOut(aResource, getter_AddRefs(arcs));
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get arcs out");
@ -5954,6 +6004,7 @@ nsXULTemplateBuilder::CheckContainer(nsIRDFResource* aResource, PRBool* aIsConta
// Otherwise, just return whether or not it's an RDF container
return gRDFContainerUtils->IsContainer(mDB, aResource, aIsContainer);
#endif
}

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

@ -201,59 +201,7 @@ public:
NS_IMETHOD SetCurrentMailCharset(const PRUnichar * aCharset);
//--------------------------------------------------------------------------
// Interface nsIRDFDataSource [declaration]
NS_IMETHOD GetURI(char ** uri);
NS_IMETHOD GetSource(nsIRDFResource* property, nsIRDFNode* target,
PRBool tv, nsIRDFResource** source);
NS_IMETHOD GetSources(nsIRDFResource* property, nsIRDFNode* target,
PRBool tv, nsISimpleEnumerator** sources);
NS_IMETHOD GetTarget(nsIRDFResource* source, nsIRDFResource* property,
PRBool tv, nsIRDFNode** target);
NS_IMETHOD GetTargets(nsIRDFResource* source, nsIRDFResource* property,
PRBool tv, nsISimpleEnumerator** targets);
NS_IMETHOD Assert(nsIRDFResource* aSource, nsIRDFResource* aProperty,
nsIRDFNode* aTarget, PRBool aTruthValue);
NS_IMETHOD Unassert(nsIRDFResource* aSource, nsIRDFResource* aProperty,
nsIRDFNode* aTarget);
NS_IMETHOD Change(nsIRDFResource* aSource, nsIRDFResource* aProperty,
nsIRDFNode* aOldTarget, nsIRDFNode* aNewTarget);
NS_IMETHOD Move(nsIRDFResource* aOldSource, nsIRDFResource* aNewSource,
nsIRDFResource* aProperty, nsIRDFNode* aTarget);
NS_IMETHOD HasAssertion(nsIRDFResource* source, nsIRDFResource* property,
nsIRDFNode* target, PRBool tv, PRBool* hasAssertion);
NS_IMETHOD AddObserver(nsIRDFObserver* n);
NS_IMETHOD RemoveObserver(nsIRDFObserver* n);
NS_IMETHOD ArcLabelsIn( nsIRDFNode* node, nsISimpleEnumerator** labels);
NS_IMETHOD ArcLabelsOut(nsIRDFResource* source,
nsISimpleEnumerator** labels);
NS_IMETHOD GetAllResources(nsISimpleEnumerator** aCursor);
NS_IMETHOD GetAllCommands(nsIRDFResource* source, nsIEnumerator** commands);
NS_IMETHOD GetAllCmds(nsIRDFResource* source,
nsISimpleEnumerator** commands);
NS_IMETHOD IsCommandEnabled(nsISupportsArray* aSources,
nsIRDFResource * aCommand, nsISupportsArray* aArguments,
PRBool* aResult);
NS_IMETHOD DoCommand(nsISupportsArray* aSources, nsIRDFResource* aCommand,
nsISupportsArray* aArguments);
NS_DECL_NSIRDFDATASOURCE
};
//----------------------------------------------------------------------------
@ -1274,6 +1222,18 @@ NS_IMETHODIMP nsCharsetMenu::RemoveObserver(nsIRDFObserver* n)
return mInner->RemoveObserver(n);
}
NS_IMETHODIMP
nsCharsetMenu::HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, PRBool *result)
{
return mInner->HasArcIn(aNode, aArc, result);
}
NS_IMETHODIMP
nsCharsetMenu::HasArcOut(nsIRDFResource *source, nsIRDFResource *aArc, PRBool *result)
{
return mInner->HasArcOut(source, aArc, result);
}
NS_IMETHODIMP nsCharsetMenu::ArcLabelsIn(nsIRDFNode* node,
nsISimpleEnumerator** labels)
{

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

@ -281,6 +281,20 @@ NS_IMETHODIMP nsAbRDFDataSource::RemoveObserver(nsIRDFObserver* n)
}
NS_IMETHODIMP
nsAbRDFDataSource::HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, PRBool *result)
{
*result = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsAbRDFDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *result)
{
*result = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsAbRDFDataSource::ArcLabelsIn(nsIRDFNode* node,
nsISimpleEnumerator** labels)
{

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

@ -357,6 +357,32 @@ NS_IMETHODIMP nsAbCardDataSource::HasAssertion(nsIRDFResource* source,
return NS_OK;
}
NS_IMETHODIMP
nsAbCardDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *result)
{
nsresult rv;
nsCOMPtr<nsIAbCard> card(do_QueryInterface(aSource, &rv));
if (NS_SUCCEEDED(rv) && card) {
*result = (aArc == kNC_DisplayName ||
aArc == kNC_Name ||
aArc == kNC_Nickname ||
aArc == kNC_PrimaryEmail ||
aArc == kNC_SecondEmail ||
aArc == kNC_WorkPhone ||
aArc == kNC_HomePhone ||
aArc == kNC_Fax ||
aArc == kNC_Pager ||
aArc == kNC_Cellular ||
aArc == kNC_Title ||
aArc == kNC_Department ||
aArc == kNC_Organization);
}
else {
*result = PR_FALSE;
}
return NS_OK;
}
NS_IMETHODIMP nsAbCardDataSource::ArcLabelsOut(nsIRDFResource* source,
nsISimpleEnumerator** labels)
{
@ -365,7 +391,7 @@ NS_IMETHODIMP nsAbCardDataSource::ArcLabelsOut(nsIRDFResource* source,
nsCOMPtr<nsIAbCard> card(do_QueryInterface(source, &rv));
if (NS_SUCCEEDED(rv) && card) {
fflush(stdout);
// fflush(stdout); // huh?
rv = getCardArcLabelsOut(card, getter_AddRefs(arcs));
}
else {

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

@ -71,6 +71,8 @@ public:
PRBool tv,
PRBool* hasAssertion);
NS_IMETHOD HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *result);
NS_IMETHOD ArcLabelsOut(nsIRDFResource* source,
nsISimpleEnumerator** labels);

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

@ -289,6 +289,23 @@ NS_IMETHODIMP nsAbDirectoryDataSource::HasAssertion(nsIRDFResource* source,
return NS_OK;
}
NS_IMETHODIMP
nsAbDirectoryDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *result)
{
nsresult rv;
nsCOMPtr<nsIAbDirectory> directory(do_QueryInterface(aSource, &rv));
if (NS_SUCCEEDED(rv)) {
*result = (aArc == kNC_DirName ||
aArc == kNC_Child ||
aArc == kNC_CardChild ||
aArc == kNC_DirUri);
}
else {
*result = PR_FALSE;
}
return NS_OK;
}
NS_IMETHODIMP nsAbDirectoryDataSource::ArcLabelsOut(nsIRDFResource* source,
nsISimpleEnumerator** labels)
{
@ -297,8 +314,8 @@ NS_IMETHODIMP nsAbDirectoryDataSource::ArcLabelsOut(nsIRDFResource* source,
nsCOMPtr<nsIAbDirectory> directory(do_QueryInterface(source, &rv));
if (NS_SUCCEEDED(rv)) {
fflush(stdout);
rv = getDirectoryArcLabelsOut(directory, getter_AddRefs(arcs));
// fflush(stdout); // huh?
rv = getDirectoryArcLabelsOut(directory, getter_AddRefs(arcs));
}
else {
// how to return an empty cursor?

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

@ -75,6 +75,8 @@ public:
PRBool tv,
PRBool* hasAssertion);
NS_IMETHOD HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *result);
NS_IMETHOD ArcLabelsOut(nsIRDFResource* source,
nsISimpleEnumerator** labels);

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

@ -173,6 +173,13 @@ nsMsgSearchDataSource::HasAssertion(nsIRDFResource *aSource,
}
NS_IMETHODIMP
nsMsgSearchDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *result)
{
*result = aSource == mSearchRoot.get() && aArc == kNC_MessageChild;
return NS_OK;
}
/* nsISimpleEnumerator ArcLabelsOut (in nsIRDFResource aSource); */
NS_IMETHODIMP
nsMsgSearchDataSource::ArcLabelsOut(nsIRDFResource *aSource,

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

@ -52,6 +52,8 @@ public:
PRBool aTruthValue,
PRBool *aResult);
NS_IMETHOD HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *_retval);
NS_IMETHOD ArcLabelsOut(nsIRDFResource *aSource,
nsISimpleEnumerator **aResult);
nsresult Init();

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

@ -279,6 +279,82 @@ NS_IMETHODIMP nsMessageViewDataSource::RemoveObserver(nsIRDFObserver* n)
return NS_OK;
}
nsresult
nsMessageViewDataSource::GetMessageEnumerator(nsIMessage* message, nsISimpleEnumerator* *result)
{
nsresult rv;
nsCOMPtr<nsIMsgFolder> folder;
rv = message->GetMsgFolder(getter_AddRefs(folder));
if (NS_FAILED(rv)) return rv;
NS_ASSERTION(folder, "GetMsgFolder returned NS_OK, but no folder");
nsCOMPtr<nsIMsgThread> thread;
rv = folder->GetThreadForMessage(message, getter_AddRefs(thread));
if (NS_FAILED(rv)) return rv;
NS_ASSERTION(folder, "GetThreadForMessage returned NS_OK, but no thread");
nsMsgKey msgKey;
rv = message->GetMessageKey(&msgKey);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISimpleEnumerator> messages;
rv = thread->EnumerateMessages(msgKey, getter_AddRefs(messages));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsMessageFromMsgHdrEnumerator> converter;
rv = NS_NewMessageFromMsgHdrEnumerator(messages, folder, getter_AddRefs(converter));
if (NS_FAILED(rv)) return rv;
nsMessageViewMessageEnumerator* messageEnumerator =
new nsMessageViewMessageEnumerator(converter, nsIMessageView::eShowAll);
if (!messageEnumerator)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(messageEnumerator);
*result = messageEnumerator;
return NS_OK;
}
NS_IMETHODIMP
nsMessageViewDataSource::HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, PRBool *result)
{
*result = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsMessageViewDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *result)
{
nsresult rv;
nsCOMPtr<nsIMessage> message;
if(mShowThreads && NS_SUCCEEDED(aSource->QueryInterface(NS_GET_IID(nsIMessage), getter_AddRefs(message))))
{
if (aArc == kNC_Subject ||
aArc == kNC_Sender ||
aArc == kNC_Date ||
aArc == kNC_Status) {
*result = PR_TRUE;
return NS_OK;
}
else if (aArc == kNC_MessageChild) {
nsCOMPtr<nsISimpleEnumerator> messageEnumerator;
rv = GetMessageEnumerator(message, getter_AddRefs(messageEnumerator));
if (NS_SUCCEEDED(rv)) {
PRBool hasMore = PR_FALSE;
if (NS_SUCCEEDED(messageEnumerator->HasMoreElements(&hasMore)) && hasMore) {
*result = PR_TRUE;
return NS_OK;
}
}
}
}
if (mDataSource)
return mDataSource->HasArcOut(aSource, aArc, result);
else
*result = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsMessageViewDataSource::ArcLabelsIn(nsIRDFNode* node,
nsISimpleEnumerator** labels)
{
@ -291,7 +367,6 @@ NS_IMETHODIMP nsMessageViewDataSource::ArcLabelsIn(nsIRDFNode* node,
NS_IMETHODIMP nsMessageViewDataSource::ArcLabelsOut(nsIRDFResource* source,
nsISimpleEnumerator** labels)
{
nsCOMPtr<nsIMessage> message;
if(mShowThreads && NS_SUCCEEDED(source->QueryInterface(NS_GET_IID(nsIMessage), getter_AddRefs(message))))
{
@ -301,38 +376,20 @@ NS_IMETHODIMP nsMessageViewDataSource::ArcLabelsOut(nsIRDFResource* source,
if (arcs == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
arcs->AppendElement(kNC_Subject);
arcs->AppendElement(kNC_Subject);
arcs->AppendElement(kNC_Sender);
arcs->AppendElement(kNC_Date);
arcs->AppendElement(kNC_Status);
nsCOMPtr<nsIMsgFolder> folder;
rv = message->GetMsgFolder(getter_AddRefs(folder));
if(NS_SUCCEEDED(rv) && folder)
{
nsCOMPtr<nsIMsgThread> thread;
rv =folder->GetThreadForMessage(message, getter_AddRefs(thread));
if(thread && NS_SUCCEEDED(rv))
{
nsCOMPtr<nsISimpleEnumerator> messageEnumerator;
rv = GetMessageEnumerator(message, getter_AddRefs(messageEnumerator));
if (NS_SUCCEEDED(rv)) {
PRBool hasMore = PR_FALSE;
if (NS_SUCCEEDED(messageEnumerator->HasMoreElements(&hasMore)) && hasMore) {
arcs->AppendElement(kNC_MessageChild);
}
}
nsCOMPtr<nsISimpleEnumerator> messages;
nsMsgKey msgKey;
message->GetMessageKey(&msgKey);
thread->EnumerateMessages(msgKey, getter_AddRefs(messages));
nsCOMPtr<nsMessageFromMsgHdrEnumerator> converter;
NS_NewMessageFromMsgHdrEnumerator(messages, folder, getter_AddRefs(converter));
nsMessageViewMessageEnumerator * messageEnumerator =
new nsMessageViewMessageEnumerator(converter, nsIMessageView::eShowAll);
if(!messageEnumerator)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(messageEnumerator);
PRBool hasMore = PR_FALSE;
if(NS_SUCCEEDED(messageEnumerator->HasMoreElements(&hasMore)) && hasMore)
arcs->AppendElement(kNC_MessageChild);
NS_IF_RELEASE(messageEnumerator);
}
}
return NS_NewArrayEnumerator(labels, arcs);
}
if(mDataSource)

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

@ -55,10 +55,9 @@ public:
virtual ~nsMessageViewDataSource (void);
virtual nsresult Init();
protected:
nsresult createMessageNode(nsIMessage *message, nsIRDFResource *property, nsIRDFNode **target);
nsresult GetMessageEnumerator(nsIMessage* message, nsISimpleEnumerator* *result);
// caching frequently used resources
protected:

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

@ -384,7 +384,7 @@ NS_IMETHODIMP nsMsgFolderDataSource::GetTargets(nsIRDFResource* source,
}
}
else if ((kNC_Name == property) ||
(kNC_FolderTreeName == property) ||
(kNC_FolderTreeName == property) ||
(kNC_SpecialFolder == property) ||
(kNC_IsServer == property) ||
(kNC_IsSecure == property) ||
@ -461,6 +461,35 @@ NS_IMETHODIMP nsMsgFolderDataSource::HasAssertion(nsIRDFResource* source,
}
NS_IMETHODIMP
nsMsgFolderDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *result)
{
nsresult rv;
nsCOMPtr<nsIMsgFolder> folder(do_QueryInterface(aSource, &rv));
if (NS_SUCCEEDED(rv)) {
*result = (aArc == kNC_Name ||
aArc == kNC_FolderTreeName ||
aArc == kNC_SpecialFolder ||
aArc == kNC_ServerType ||
aArc == kNC_IsServer ||
aArc == kNC_IsSecure ||
aArc == kNC_CanSubscribe ||
aArc == kNC_CanFileMessages ||
aArc == kNC_CanCreateSubfolders ||
aArc == kNC_CanRename ||
aArc == kNC_TotalMessages ||
aArc == kNC_TotalUnreadMessages ||
aArc == kNC_Charset ||
aArc == kNC_BiffState ||
aArc == kNC_Child ||
aArc == kNC_NoSelect);
}
else {
*result = PR_FALSE;
}
return NS_OK;
}
NS_IMETHODIMP nsMsgFolderDataSource::ArcLabelsIn(nsIRDFNode* node,
nsISimpleEnumerator** labels)
{
@ -781,7 +810,6 @@ nsMsgFolderDataSource::OnItemBoolPropertyChanged(nsISupports *item,
PRBool oldValue,
PRBool newValue)
{
nsresult rv;
nsCOMPtr<nsIMsgFolder> folder(do_QueryInterface(item));
if(folder)
{

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

@ -86,6 +86,8 @@ public:
PRBool tv,
PRBool* hasAssertion);
NS_IMETHOD HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *result);
NS_IMETHOD ArcLabelsIn(nsIRDFNode* node,
nsISimpleEnumerator** labels);

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

@ -565,6 +565,44 @@ NS_IMETHODIMP nsMsgMessageDataSource::HasAssertion(nsIRDFResource* source,
}
NS_IMETHODIMP
nsMsgMessageDataSource::HasArcOut(nsIRDFResource *source, nsIRDFResource *aArc, PRBool *result)
{
nsresult rv;
*result = PR_FALSE;
nsCOMPtr<nsIMessage> message(do_QueryInterface(source, &rv));
if (NS_SUCCEEDED(rv)) {
PRBool showThreads;
rv = GetIsThreaded(&showThreads);
// handle this failure gracefully - not all datasources have views.
if (NS_SUCCEEDED(rv) && showThreads) {
*result = (aArc == kNC_Total ||
aArc == kNC_Unread ||
aArc == kNC_MessageChild);
}
*result = (*result ||
aArc == kNC_Subject ||
aArc == kNC_Sender ||
aArc == kNC_Recipient ||
aArc == kNC_Date ||
aArc == kNC_Status ||
aArc == kNC_StatusString ||
aArc == kNC_Flagged ||
aArc == kNC_Priority ||
aArc == kNC_PriorityString ||
aArc == kNC_Size ||
aArc == kNC_IsUnread ||
aArc == kNC_HasAttachment ||
aArc == kNC_IsImapDeleted ||
aArc == kNC_MessageType ||
aArc == kNC_OrderReceived);
return NS_OK;
}
return NS_OK;
}
NS_IMETHODIMP nsMsgMessageDataSource::ArcLabelsIn(nsIRDFNode* node,
nsISimpleEnumerator** labels)
{

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

@ -93,6 +93,8 @@ public:
PRBool tv,
PRBool* hasAssertion);
NS_IMETHOD HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *result);
NS_IMETHOD ArcLabelsIn(nsIRDFNode* node,
nsISimpleEnumerator** labels);

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

@ -199,6 +199,20 @@ nsMsgRDFDataSource::RemoveObserver(nsIRDFObserver *aObserver)
}
NS_IMETHODIMP
nsMsgRDFDataSource::HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, PRBool *result)
{
*result = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsMsgRDFDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *result)
{
*result = PR_FALSE;
return NS_OK;
}
/* nsISimpleEnumerator ArcLabelsIn (in nsIRDFNode aNode); */
NS_IMETHODIMP
nsMsgRDFDataSource::ArcLabelsIn(nsIRDFNode *aNode, nsISimpleEnumerator **_retval)

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

@ -306,6 +306,34 @@ NS_IMETHODIMP nsSmtpDataSource::RemoveObserver(nsIRDFObserver *aObserver)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsSmtpDataSource::HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, PRBool *result)
{
*result = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsSmtpDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *result)
{
nsresult rv;
if (aSource == kNC_SmtpServers.get()) {
*result = mServerRootArcsOut->IndexOf(aArc) != -1;
}
else {
nsCOMPtr<nsISmtpServer> smtpServer;
rv = aSource->GetDelegate("smtpserver", NS_GET_IID(nsISmtpServer),
(void **)getter_AddRefs(smtpServer));
if (NS_SUCCEEDED(rv)) {
*result = mServerArcsOut->IndexOf(aArc) != -1;
}
else {
*result = PR_FALSE;
}
}
return NS_OK;
}
/* nsISimpleEnumerator ArcLabelsIn (in nsIRDFNode aNode); */
NS_IMETHODIMP nsSmtpDataSource::ArcLabelsIn(nsIRDFNode *aNode, nsISimpleEnumerator **aResult)
{

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

@ -40,6 +40,9 @@ interface nsIRDFContainerUtils : nsISupports {
// Return 'true' if the specified resource is a container
boolean IsContainer(in nsIRDFDataSource aDataSource, in nsIRDFResource aResource);
// Return 'true' if the specified resource is a container and it is empty
boolean IsEmpty(in nsIRDFDataSource aDataSource, in nsIRDFResource aResource);
// Return 'true' if the specified resource is a bag
boolean IsBag(in nsIRDFDataSource aDataSource, in nsIRDFResource aResource);
@ -65,4 +68,4 @@ interface nsIRDFContainerUtils : nsISupports {
%{C++
extern nsresult
NS_NewRDFContainerUtils(nsIRDFContainerUtils** aResult);
%}
%}

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

@ -196,5 +196,16 @@ interface nsIRDFDataSource : nsISupports
*/
nsISimpleEnumerator GetAllCmds(in nsIRDFResource aSource);
/**
* Returns true if the specified node is pointed to by the specified arc.
* Equivalent to enumerating ArcLabelsIn and comparing for the specified arc.
*/
boolean hasArcIn(in nsIRDFNode aNode, in nsIRDFResource aArc);
/**
* Returns true if the specified node has the specified outward arc.
* Equivalent to enumerating ArcLabelsOut and comparing for the specified arc.
*/
boolean hasArcOut(in nsIRDFResource aSource, in nsIRDFResource aArc);
};

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

@ -1083,6 +1083,38 @@ CompositeDataSourceImpl::RemoveObserver(nsIRDFObserver* aObserver)
return NS_OK;
}
NS_IMETHODIMP
CompositeDataSourceImpl::HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, PRBool *result)
{
nsresult rv;
*result = PR_FALSE;
PRInt32 count = mDataSources.Count();
for (PRInt32 i = 0; i < count; ++i) {
nsIRDFDataSource* ds = NS_STATIC_CAST(nsIRDFDataSource*, mDataSources[i]);
rv = ds->HasArcIn(aNode, aArc, result);
if (NS_FAILED(rv)) return rv;
if (*result == PR_TRUE)
return NS_OK;
}
return NS_OK;
}
NS_IMETHODIMP
CompositeDataSourceImpl::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *result)
{
nsresult rv;
*result = PR_FALSE;
PRInt32 count = mDataSources.Count();
for (PRInt32 i = 0; i < count; ++i) {
nsIRDFDataSource* ds = NS_STATIC_CAST(nsIRDFDataSource*, mDataSources[i]);
rv = ds->HasArcOut(aSource, aArc, result);
if (NS_FAILED(rv)) return rv;
if (*result == PR_TRUE)
return NS_OK;
}
return NS_OK;
}
NS_IMETHODIMP
CompositeDataSourceImpl::ArcLabelsIn(nsIRDFNode* aTarget, nsISimpleEnumerator** aResult)
{

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

@ -1414,6 +1414,42 @@ InMemoryDataSource::RemoveObserver(nsIRDFObserver* aObserver)
return NS_OK;
}
NS_IMETHODIMP
InMemoryDataSource::HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, PRBool *result)
{
NS_AUTOLOCK(mDataSource->mLock);
Assertion* ass = GetReverseArcs(aNode);
while (ass) {
nsIRDFResource* elbow = ass->mProperty;
if (elbow == aArc) {
*result = PR_TRUE;
return NS_OK;
}
ass = ass->mInvNext;
}
*result = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
InMemoryDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *result)
{
NS_AUTOLOCK(mDataSource->mLock);
Assertion* ass = GetForwardArcs(aSource);
while (ass) {
nsIRDFResource* elbow = ass->mProperty;
if (elbow == aArc) {
*result = PR_TRUE;
return NS_OK;
}
ass = ass->mNext;
}
*result = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
InMemoryDataSource::ArcLabelsIn(nsIRDFNode* aTarget, nsISimpleEnumerator** aResult)
{

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

@ -74,6 +74,7 @@ private:
static nsIRDFResource* kRDF_Bag;
static nsIRDFResource* kRDF_Seq;
static nsIRDFResource* kRDF_Alt;
static nsIRDFLiteral* kOne;
};
@ -84,6 +85,7 @@ nsIRDFResource* RDFContainerUtilsImpl::kRDF_nextVal;
nsIRDFResource* RDFContainerUtilsImpl::kRDF_Bag;
nsIRDFResource* RDFContainerUtilsImpl::kRDF_Seq;
nsIRDFResource* RDFContainerUtilsImpl::kRDF_Alt;
nsIRDFLiteral* RDFContainerUtilsImpl::kOne;
////////////////////////////////////////////////////////////////////////
// nsISupports interface
@ -228,6 +230,36 @@ RDFContainerUtilsImpl::IsContainer(nsIRDFDataSource *aDataSource, nsIRDFResource
}
NS_IMETHODIMP
RDFContainerUtilsImpl::IsEmpty(nsIRDFDataSource* aDataSource, nsIRDFResource* aResource, PRBool* _retval)
{
if (! aDataSource)
return NS_ERROR_NULL_POINTER;
nsresult rv;
// By default, say that we're an empty container. Even if we're not
// really even a container.
*_retval = PR_TRUE;
nsCOMPtr<nsIRDFNode> nextValNode;
rv = aDataSource->GetTarget(aResource, kRDF_nextVal, PR_TRUE, getter_AddRefs(nextValNode));
if (NS_FAILED(rv)) return rv;
if (rv == NS_RDF_NO_VALUE)
return NS_OK;
nsCOMPtr<nsIRDFLiteral> nextValLiteral;
rv = nextValNode->QueryInterface(NS_GET_IID(nsIRDFLiteral), getter_AddRefs(nextValLiteral));
if (NS_FAILED(rv)) return rv;
if (nextValLiteral.get() != kOne)
*_retval = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
RDFContainerUtilsImpl::IsBag(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, PRBool *_retval)
{
@ -331,6 +363,7 @@ RDFContainerUtilsImpl::RDFContainerUtilsImpl()
gRDFService->GetResource(RDF_NAMESPACE_URI "Bag", &kRDF_Bag);
gRDFService->GetResource(RDF_NAMESPACE_URI "Seq", &kRDF_Seq);
gRDFService->GetResource(RDF_NAMESPACE_URI "Alt", &kRDF_Alt);
gRDFService->GetLiteral(NS_LITERAL_STRING("1"), &kOne);
}
}
}
@ -354,6 +387,7 @@ RDFContainerUtilsImpl::~RDFContainerUtilsImpl()
NS_IF_RELEASE(kRDF_Bag);
NS_IF_RELEASE(kRDF_Seq);
NS_IF_RELEASE(kRDF_Alt);
NS_IF_RELEASE(kOne);
}
}

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

@ -613,7 +613,7 @@ RDFServiceImpl::GetResource(const char* aURI, nsIRDFResource** aResource)
// that we just tried to use...
prefixlen = (p - aURI);
if ((mLastFactory) && (prefixlen == mLastPrefixlen) &&
if ((mLastFactory) && ((PRInt32)prefixlen == mLastPrefixlen) &&
(aURI[0] == mLastURIPrefix[0]) &&
(0 == PL_strncmp(aURI, mLastURIPrefix, prefixlen))) {
factory = mLastFactory;

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

@ -306,6 +306,14 @@ public:
return mInner->RemoveObserver(aObserver);
}
NS_IMETHOD HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, PRBool *_retval) {
return mInner->HasArcIn(aNode, aArc, _retval);
}
NS_IMETHOD HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *_retval) {
return mInner->HasArcOut(aSource, aArc, _retval);
}
NS_IMETHOD ArcLabelsIn(nsIRDFNode* node,
nsISimpleEnumerator** labels) {
return mInner->ArcLabelsIn(node, labels);

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

@ -257,6 +257,18 @@ nsChromeUIDataSource::RemoveObserver(nsIRDFObserver* aObserver)
return NS_OK;
}
NS_IMETHODIMP
nsChromeUIDataSource::HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, PRBool *result)
{
return mComposite->HasArcIn(aNode, aArc, result);
}
NS_IMETHODIMP
nsChromeUIDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *result)
{
return mComposite->HasArcOut(aSource, aArc, result);
}
NS_IMETHODIMP
nsChromeUIDataSource::ArcLabelsIn(nsIRDFNode* aTarget, nsISimpleEnumerator** aResult)
{

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

@ -97,6 +97,10 @@
#include "nsIFormControl.h"
#include "nsIDOMHTMLFormElement.h"
#if defined(DEBUG_warren) || defined(DEBUG_waterson) || defined(DEBUG_alecf) || defined(DEBUG_bienvenu) || defined(DEBUG_mscott)
#define RDF_USE_HAS_ARC_OUT 1
#endif
// Return values for EnsureElementHasGenericChild()
#define NS_RDF_ELEMENT_GOT_CREATED NS_RDF_NO_VALUE
#define NS_RDF_ELEMENT_WAS_THERE NS_OK
@ -5897,6 +5901,52 @@ nsXULTemplateBuilder::CheckContainer(nsIRDFResource* aResource, PRBool* aIsConta
// we know we'll have children.
nsresult rv;
#ifdef RDF_USE_HAS_ARC_OUT
*aIsContainer = PR_FALSE;
*aIsEmpty = PR_TRUE;
for (ResourceSet::ConstIterator property = mContainmentProperties.First();
property != mContainmentProperties.Last();
property++) {
PRBool hasArc;
rv = mDB->HasArcOut(aResource, *property, &hasArc);
if (NS_FAILED(rv)) return rv;
if (hasArc) {
// Well, it's a container...
*aIsContainer = PR_TRUE;
// ...is it empty?
nsCOMPtr<nsIRDFNode> dummy;
rv = mDB->GetTarget(aResource, *property, PR_TRUE, getter_AddRefs(dummy));
if (NS_FAILED(rv)) return rv;
if (dummy != nsnull) {
*aIsEmpty = PR_FALSE;
return NS_OK;
}
// Even if there isn't a target for *this* containment
// property, we have continue to check the other
// properties: one of them may have a target.
}
}
// If we get here, and it's a container, then it's an *empty*
// container.
if (*aIsContainer)
return NS_OK;
// Otherwise, just return whether or not it's an RDF container
rv = gRDFContainerUtils->IsContainer(mDB, aResource, aIsContainer);
if (NS_FAILED(rv)) return rv;
if (*aIsContainer) {
rv = gRDFContainerUtils->IsEmpty(mDB, aResource, aIsEmpty);
if (NS_FAILED(rv)) return rv;
}
return NS_OK;
#else
nsCOMPtr<nsISimpleEnumerator> arcs;
rv = mDB->ArcLabelsOut(aResource, getter_AddRefs(arcs));
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get arcs out");
@ -5954,6 +6004,7 @@ nsXULTemplateBuilder::CheckContainer(nsIRDFResource* aResource, PRBool* aIsConta
// Otherwise, just return whether or not it's an RDF container
return gRDFContainerUtils->IsContainer(mDB, aResource, aIsContainer);
#endif
}

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

@ -87,101 +87,45 @@ static const char kURINC_FileSystemRoot[] = "NC:FilesRoot";
class FileSystemDataSource : public nsIRDFFileSystemDataSource
{
private:
nsCOMPtr<nsISupportsArray> mObservers;
nsCOMPtr<nsISupportsArray> mObservers;
static PRInt32 gRefCnt;
// pseudo-constants
static nsIRDFResource *kNC_FileSystemRoot;
static nsIRDFResource *kNC_Child;
static nsIRDFResource *kNC_Name;
static nsIRDFResource *kNC_URL;
static nsIRDFResource *kNC_FileSystemObject;
static nsIRDFResource *kNC_pulse;
static nsIRDFResource *kRDF_InstanceOf;
static nsIRDFResource *kRDF_type;
static nsIRDFResource *kNC_FileSystemRoot;
static nsIRDFResource *kNC_Child;
static nsIRDFResource *kNC_Name;
static nsIRDFResource *kNC_URL;
static nsIRDFResource *kNC_FileSystemObject;
static nsIRDFResource *kNC_pulse;
static nsIRDFResource *kRDF_InstanceOf;
static nsIRDFResource *kRDF_type;
#ifdef XP_WIN
static nsIRDFResource *kNC_IEFavoriteObject;
static nsIRDFResource *kNC_IEFavoriteFolder;
static char *ieFavoritesDir;
nsCOMPtr<nsIUnicodeDecoder> mUnicodeDecoder;
static nsIRDFResource *kNC_IEFavoriteObject;
static nsIRDFResource *kNC_IEFavoriteFolder;
static char *ieFavoritesDir;
nsCOMPtr<nsIUnicodeDecoder> mUnicodeDecoder;
#endif
#ifdef XP_BEOS
static nsIRDFResource *kNC_NetPositiveObject;
static char *netPositiveDir;
static nsIRDFResource *kNC_NetPositiveObject;
static char *netPositiveDir;
#endif
public:
NS_DECL_ISUPPORTS
NS_DECL_ISUPPORTS
FileSystemDataSource(void);
virtual ~FileSystemDataSource(void);
// nsIRDFDataSource methods
NS_IMETHOD GetURI(char **uri);
NS_IMETHOD GetSource(nsIRDFResource *property,
nsIRDFNode *target,
PRBool tv,
nsIRDFResource **source /* out */);
NS_IMETHOD GetSources(nsIRDFResource *property,
nsIRDFNode *target,
PRBool tv,
nsISimpleEnumerator **sources /* out */);
NS_IMETHOD GetTarget(nsIRDFResource *source,
nsIRDFResource *property,
PRBool tv,
nsIRDFNode **target /* out */);
NS_IMETHOD GetTargets(nsIRDFResource *source,
nsIRDFResource *property,
PRBool tv,
nsISimpleEnumerator **targets /* out */);
NS_IMETHOD Assert(nsIRDFResource *source,
nsIRDFResource *property,
nsIRDFNode *target,
PRBool tv);
NS_IMETHOD Unassert(nsIRDFResource *source,
nsIRDFResource *property,
nsIRDFNode *target);
NS_IMETHOD Change(nsIRDFResource* aSource,
nsIRDFResource* aProperty,
nsIRDFNode* aOldTarget,
nsIRDFNode* aNewTarget);
NS_IMETHOD Move(nsIRDFResource* aOldSource,
nsIRDFResource* aNewSource,
nsIRDFResource* aProperty,
nsIRDFNode* aTarget);
NS_IMETHOD HasAssertion(nsIRDFResource *source,
nsIRDFResource *property,
nsIRDFNode *target,
PRBool tv,
PRBool *hasAssertion /* out */);
NS_IMETHOD ArcLabelsIn(nsIRDFNode *node,
nsISimpleEnumerator **labels /* out */);
NS_IMETHOD ArcLabelsOut(nsIRDFResource *source,
nsISimpleEnumerator **labels /* out */);
NS_IMETHOD GetAllResources(nsISimpleEnumerator** aResult);
NS_IMETHOD AddObserver(nsIRDFObserver *n);
NS_IMETHOD RemoveObserver(nsIRDFObserver *n);
NS_IMETHOD GetAllCommands(nsIRDFResource* source,
nsIEnumerator/*<nsIRDFResource>*/** commands);
NS_IMETHOD GetAllCmds(nsIRDFResource* source,
nsISimpleEnumerator/*<nsIRDFResource>*/** commands);
NS_IMETHOD IsCommandEnabled(nsISupportsArray/*<nsIRDFResource>*/* aSources,
nsIRDFResource* aCommand,
nsISupportsArray/*<nsIRDFResource>*/* aArguments,
PRBool* aResult);
NS_IMETHOD DoCommand(nsISupportsArray/*<nsIRDFResource>*/* aSources,
nsIRDFResource* aCommand,
nsISupportsArray/*<nsIRDFResource>*/* aArguments);
FileSystemDataSource(void);
virtual ~FileSystemDataSource(void);
// nsIRDFDataSource methods
NS_DECL_NSIRDFDATASOURCE
// helper methods
static PRBool isFileURI(nsIRDFResource* aResource);
static PRBool isDirURI(nsIRDFResource* aSource);
static nsresult GetVolumeList(nsISimpleEnumerator **aResult);
static nsresult GetFolderList(nsIRDFResource *source, PRBool allowHidden, PRBool onlyFirst, nsISimpleEnumerator **aResult);
@ -250,6 +194,41 @@ FileSystemDataSource::isFileURI(nsIRDFResource *r)
return(isFileURIFlag);
}
PRBool
FileSystemDataSource::isDirURI(nsIRDFResource* source)
{
nsresult rv;
const char *uri = nsnull;
rv = source->GetValueConst(&uri);
if (NS_FAILED(rv)) return PR_FALSE;
nsCOMPtr<nsIURI> fileURI;
if (NS_FAILED(rv = NS_NewURI(getter_AddRefs(fileURI), uri)))
return(rv);
if (!fileURI) return PR_FALSE;
nsCOMPtr<nsIChannel> channel;
rv = NS_OpenURI(getter_AddRefs(channel), fileURI, nsnull, nsnull);
if (NS_FAILED(rv))
return PR_FALSE;
if (!channel) return PR_FALSE;
nsCOMPtr<nsIFileChannel> fileChannel = do_QueryInterface(channel);
if (!fileChannel) return PR_FALSE;
nsCOMPtr<nsIFile> aDir;
rv = fileChannel->GetFile(getter_AddRefs(aDir));
if (NS_FAILED(rv))
return PR_FALSE;
PRBool isDirFlag = PR_FALSE;
rv = aDir->IsDirectory(&isDirFlag);
if (NS_FAILED(rv)) return PR_FALSE;
return isDirFlag;
}
FileSystemDataSource::FileSystemDataSource(void)
{
@ -743,6 +722,36 @@ FileSystemDataSource::HasAssertion(nsIRDFResource *source,
}
NS_IMETHODIMP
FileSystemDataSource::HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, PRBool *result)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
FileSystemDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *result)
{
if (aSource == kNC_FileSystemRoot) {
*result = (aArc == kNC_Child || aArc == kNC_pulse);
}
else if (isFileURI(aSource)) {
if (aArc == kNC_pulse) {
*result = PR_TRUE;
}
else if (isDirURI(aSource)) {
#ifdef XP_WIN
*result = isValidFolder(aSource);
#else
*result = PR_TRUE;
#endif
}
}
else {
*result = PR_FALSE;
}
return NS_OK;
}
NS_IMETHODIMP
FileSystemDataSource::ArcLabelsIn(nsIRDFNode *node,
@ -756,94 +765,63 @@ FileSystemDataSource::ArcLabelsIn(nsIRDFNode *node,
NS_IMETHODIMP
FileSystemDataSource::ArcLabelsOut(nsIRDFResource *source,
nsISimpleEnumerator **labels /* out */)
nsISimpleEnumerator **labels /* out */)
{
NS_PRECONDITION(source != nsnull, "null ptr");
if (! source)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(source != nsnull, "null ptr");
if (! source)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(labels != nsnull, "null ptr");
if (! labels)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(labels != nsnull, "null ptr");
if (! labels)
return NS_ERROR_NULL_POINTER;
nsresult rv;
nsresult rv;
if (source == kNC_FileSystemRoot)
{
nsCOMPtr<nsISupportsArray> array;
rv = NS_NewISupportsArray(getter_AddRefs(array));
if (NS_FAILED(rv)) return rv;
if (source == kNC_FileSystemRoot) {
nsCOMPtr<nsISupportsArray> array;
rv = NS_NewISupportsArray(getter_AddRefs(array));
if (NS_FAILED(rv)) return rv;
array->AppendElement(kNC_Child);
array->AppendElement(kNC_pulse);
array->AppendElement(kNC_Child);
array->AppendElement(kNC_pulse);
nsISimpleEnumerator* result = new nsArrayEnumerator(array);
if (! result)
return NS_ERROR_OUT_OF_MEMORY;
nsISimpleEnumerator* result = new nsArrayEnumerator(array);
if (! result)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(result);
*labels = result;
return NS_OK;
}
else if (isFileURI(source))
{
const char *uri = nsnull;
rv = source->GetValueConst( &uri );
if (NS_FAILED(rv)) return rv;
NS_ADDREF(result);
*labels = result;
return NS_OK;
}
else if (isFileURI(source)) {
nsCOMPtr<nsISupportsArray> array;
rv = NS_NewISupportsArray(getter_AddRefs(array));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIURI> fileURI;
if (NS_FAILED(rv = NS_NewURI(getter_AddRefs(fileURI), uri)))
return(rv);
if (!fileURI) return(NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIChannel> channel;
if (NS_FAILED(rv = NS_OpenURI(getter_AddRefs(channel), fileURI, nsnull, nsnull)))
return(rv);
if (!channel) return(NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIFileChannel> fileChannel = do_QueryInterface(channel);
if (!fileChannel) return(NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIFile> aDir;
if (NS_FAILED(rv = fileChannel->GetFile(getter_AddRefs(aDir))))
return(rv);
PRBool isDirFlag = PR_FALSE;
// ignore any errors from IsDirectory()
// so that non-existant file URLs don't confuse the template builder
nsresult temprv;
temprv = aDir->IsDirectory(&isDirFlag);
nsCOMPtr<nsISupportsArray> array;
rv = NS_NewISupportsArray(getter_AddRefs(array));
if (NS_FAILED(rv)) return rv;
if (isDirFlag == PR_TRUE)
{
if (isDirURI(source)) {
#ifdef XP_WIN
if (isValidFolder(source) == PR_TRUE)
{
array->AppendElement(kNC_Child);
}
if (isValidFolder(source) == PR_TRUE)
{
array->AppendElement(kNC_Child);
}
#else
array->AppendElement(kNC_Child);
array->AppendElement(kNC_Child);
#endif
array->AppendElement(kNC_pulse);
}
array->AppendElement(kRDF_type);
nsISimpleEnumerator* result = new nsArrayEnumerator(array);
if (! result)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(result);
*labels = result;
return NS_OK;
array->AppendElement(kNC_pulse);
}
return NS_NewEmptyEnumerator(labels);
array->AppendElement(kRDF_type);
nsISimpleEnumerator* result = new nsArrayEnumerator(array);
if (! result)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(result);
*labels = result;
return NS_OK;
}
return NS_NewEmptyEnumerator(labels);
}

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

@ -159,6 +159,14 @@ public:
return NS_OK;
}
NS_IMETHOD HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, PRBool *_retval) {
return mInner->HasArcIn(aNode, aArc, _retval);
}
NS_IMETHOD HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *_retval) {
return mInner->HasArcOut(aSource, aArc, _retval);
}
NS_IMETHOD ArcLabelsIn(nsIRDFNode* aNode,
nsISimpleEnumerator** aLabels) {
return mInner->ArcLabelsIn(aNode, aLabels);

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

@ -1040,11 +1040,27 @@ nsRDFDOMDataSource::RemoveObserver(nsIRDFObserver *aObserver)
}
NS_IMETHODIMP
nsRDFDOMDataSource::HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, PRBool *result)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsRDFDOMDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *result)
{
*result = (aArc == kNC_Name ||
aArc == kNC_Value ||
aArc == kNC_Type ||
aArc == kNC_Child);
return NS_OK;
}
/* nsISimpleEnumerator ArcLabelsIn (in nsIRDFNode aNode); */
NS_IMETHODIMP
nsRDFDOMDataSource::ArcLabelsIn(nsIRDFNode *aNode, nsISimpleEnumerator **_retval)
{
return NS_RDF_NO_VALUE;
return NS_RDF_NO_VALUE;
}
@ -1052,17 +1068,15 @@ nsRDFDOMDataSource::ArcLabelsIn(nsIRDFNode *aNode, nsISimpleEnumerator **_retval
NS_IMETHODIMP
nsRDFDOMDataSource::ArcLabelsOut(nsIRDFResource *aSource, nsISimpleEnumerator **_retval)
{
nsresult rv=NS_OK;
nsCOMPtr<nsISupportsArray> arcs;
rv = NS_NewISupportsArray(getter_AddRefs(arcs));
if (NS_FAILED(rv)) return rv;
#ifdef DEBUG_alecf_
nsXPIDLCString sourceval;
aSource->GetValue(getter_Copies(sourceval));
#ifdef DEBUG_alecf_
printf("ArcLabelsOut(%s)\n", (const char*)sourceval);
#endif

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

@ -129,6 +129,14 @@ public:
return mInner->RemoveObserver(n);
}
NS_IMETHOD HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, PRBool *_retval) {
return mInner->HasArcIn(aNode, aArc, _retval);
}
NS_IMETHOD HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *_retval) {
return mInner->HasArcOut(aSource, aArc, _retval);
}
NS_IMETHOD ArcLabelsIn( nsIRDFNode* node, nsISimpleEnumerator** labels)
{
return mInner->ArcLabelsIn(node, labels);

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

@ -1822,6 +1822,23 @@ public:
NS_IMETHOD AddObserver(nsIRDFObserver* aObserver);
NS_IMETHOD RemoveObserver(nsIRDFObserver* aObserver);
NS_IMETHOD HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, PRBool *_retval) {
return mInner->HasArcIn(aNode, aArc, _retval);
}
NS_IMETHOD HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *_retval) {
#ifdef XP_MAC
// on the Mac, IE favorites are stored in an HTML file.
// Defer importing this files contents until necessary.
if ((aSource == kNC_IEFavoritesRoot) && (mIEFavoritesAvailable == PR_FALSE))
{
ReadFavorites();
}
#endif
return mInner->HasArcOut(aSource, aArc, _retval);
}
NS_IMETHOD ArcLabelsIn(nsIRDFNode* node,
nsISimpleEnumerator** labels) {
return mInner->ArcLabelsIn(node, labels);
@ -1840,6 +1857,7 @@ public:
ReadFavorites();
}
#endif
return mInner->ArcLabelsOut(source, labels);
}

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

@ -1316,6 +1316,32 @@ nsHTTPIndex::RemoveObserver(nsIRDFObserver *aObserver)
return(rv);
}
NS_IMETHODIMP
nsHTTPIndex::HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, PRBool *result)
{
if (!mInner) {
*result = PR_FALSE;
return NS_OK;
}
return mInner->HasArcIn(aNode, aArc, result);
}
NS_IMETHODIMP
nsHTTPIndex::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *result)
{
if (aArc == kNC_Child && isWellknownContainerURI(aSource)) {
*result = PR_TRUE;
return NS_OK;
}
if (mInner) {
return mInner->HasArcOut(aSource, aArc, result);
}
*result = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsHTTPIndex::ArcLabelsIn(nsIRDFNode *aNode, nsISimpleEnumerator **_retval)
{
@ -1348,8 +1374,9 @@ nsHTTPIndex::ArcLabelsOut(nsIRDFResource *aSource, nsISimpleEnumerator **_retval
nsCOMPtr<nsISimpleEnumerator> anonArcs;
rv = mInner->ArcLabelsOut(aSource, getter_AddRefs(anonArcs));
PRBool hasResults = PR_TRUE;
while (NS_SUCCEEDED(rv) && (anonArcs->HasMoreElements(&hasResults) &&
(hasResults == PR_TRUE)))
while (NS_SUCCEEDED(rv) &&
NS_SUCCEEDED(anonArcs->HasMoreElements(&hasResults)) &&
hasResults == PR_TRUE)
{
nsCOMPtr<nsISupports> anonArc;
if (NS_FAILED(anonArcs->GetNext(getter_AddRefs(anonArc))))

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

@ -1314,6 +1314,49 @@ nsGlobalHistory::RemoveObserver(nsIRDFObserver* aObserver)
return NS_OK;
}
NS_IMETHODIMP
nsGlobalHistory::HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, PRBool *result)
{
NS_PRECONDITION(aNode != nsnull, "null ptr");
if (! aNode)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIRDFResource> resource = do_QueryInterface(aNode);
if (resource && IsURLInHistory(resource)) {
*result = (aArc == kNC_child);
}
else {
*result = PR_FALSE;
}
return NS_OK;
}
NS_IMETHODIMP
nsGlobalHistory::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *result)
{
NS_PRECONDITION(aSource != nsnull, "null ptr");
if (! aSource)
return NS_ERROR_NULL_POINTER;
if ((aSource == kNC_HistoryRoot) ||
(aSource == kNC_HistoryBySite) ||
(aSource == kNC_HistoryByDate)) {
*result = (aArc == kNC_child);
}
else if (IsURLInHistory(aSource)) {
// If the URL is in the history, then it'll have all the
// appropriate attributes.
*result = (aArc == kNC_Date ||
aArc == kNC_VisitCount ||
aArc == kNC_Name ||
aArc == kNC_Referrer);
}
else {
*result = PR_FALSE;
}
return NS_OK;
}
NS_IMETHODIMP
nsGlobalHistory::ArcLabelsIn(nsIRDFNode* aNode,
nsISimpleEnumerator** aLabels)

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

@ -584,6 +584,82 @@ nsRegistryDataSource::RemoveObserver(nsIRDFObserver *aObserver)
}
NS_IMETHODIMP
nsRegistryDataSource::HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, PRBool *result)
{
*result = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsRegistryDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *result)
{
NS_PRECONDITION(aSource != nsnull, "null ptr");
if (! aSource)
return NS_ERROR_NULL_POINTER;
PRInt32 key = GetKey(aSource);
if (key == -1) {
*result = PR_FALSE;
return NS_OK;
}
nsresult rv;
if (aArc == kSubkeys) {
*result = PR_TRUE;
return NS_OK;
}
if (key != nsIRegistry::Common) {
// XXX In hopes that we'll all be using nsISimpleEnumerator someday
nsCOMPtr<nsIEnumerator> values0;
rv = mRegistry->EnumerateValues(key, getter_AddRefs(values0));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISimpleEnumerator> values;
rv = NS_NewAdapterEnumerator(getter_AddRefs(values), values0);
if (NS_FAILED(rv)) return rv;
do {
PRBool hasMore;
rv = values->HasMoreElements(&hasMore);
if (NS_FAILED(rv)) return rv;
if (! hasMore)
break;
nsCOMPtr<nsISupports> isupports;
rv = values->GetNext(getter_AddRefs(isupports));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIRegistryValue> value = do_QueryInterface(isupports);
NS_ASSERTION(value != nsnull, "not a registry value");
if (! value)
return NS_ERROR_UNEXPECTED;
nsXPIDLCString valueStr;
rv = value->GetNameUTF8(getter_Copies(valueStr));
if (NS_FAILED(rv)) return rv;
nsCAutoString propertyStr(kValuePrefix);
propertyStr += (const char*) valueStr;
nsCOMPtr<nsIRDFResource> property;
rv = gRDF->GetResource(propertyStr, getter_AddRefs(property));
if (NS_FAILED(rv)) return rv;
if (aArc == property) {
*result = PR_TRUE;
return NS_OK;
}
} while (1);
}
*result = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsRegistryDataSource::ArcLabelsIn(nsIRDFNode *aNode, nsISimpleEnumerator **_retval)
{

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

@ -559,67 +559,8 @@ private:
public:
NS_DECL_ISUPPORTS
// nsIRelatedLinksHandler methods
NS_DECL_NSIRELATEDLINKSHANDLER
// nsIRDFDataSource methods
NS_IMETHOD GetURI(char **uri);
NS_IMETHOD GetSource(nsIRDFResource *property,
nsIRDFNode *target,
PRBool tv,
nsIRDFResource **source /* out */);
NS_IMETHOD GetSources(nsIRDFResource *property,
nsIRDFNode *target,
PRBool tv,
nsISimpleEnumerator **sources /* out */);
NS_IMETHOD GetTarget(nsIRDFResource *source,
nsIRDFResource *property,
PRBool tv,
nsIRDFNode **target /* out */);
NS_IMETHOD GetTargets(nsIRDFResource *source,
nsIRDFResource *property,
PRBool tv,
nsISimpleEnumerator **targets /* out */);
NS_IMETHOD Assert(nsIRDFResource *source,
nsIRDFResource *property,
nsIRDFNode *target,
PRBool tv);
NS_IMETHOD Unassert(nsIRDFResource *source,
nsIRDFResource *property,
nsIRDFNode *target);
NS_IMETHOD Change(nsIRDFResource* aSource,
nsIRDFResource* aProperty,
nsIRDFNode* aOldTarget,
nsIRDFNode* aNewTarget);
NS_IMETHOD Move(nsIRDFResource* aOldSource,
nsIRDFResource* aNewSource,
nsIRDFResource* aProperty,
nsIRDFNode* aTarget);
NS_IMETHOD HasAssertion(nsIRDFResource *source,
nsIRDFResource *property,
nsIRDFNode *target,
PRBool tv,
PRBool *hasAssertion /* out */);
NS_IMETHOD ArcLabelsIn(nsIRDFNode *node,
nsISimpleEnumerator **labels /* out */);
NS_IMETHOD ArcLabelsOut(nsIRDFResource *source,
nsISimpleEnumerator **labels /* out */);
NS_IMETHOD GetAllResources(nsISimpleEnumerator** aCursor);
NS_IMETHOD AddObserver(nsIRDFObserver *n);
NS_IMETHOD RemoveObserver(nsIRDFObserver *n);
NS_IMETHOD GetAllCommands(nsIRDFResource* source,
nsIEnumerator/*<nsIRDFResource>*/** commands);
NS_IMETHOD GetAllCmds(nsIRDFResource* source,
nsISimpleEnumerator/*<nsIRDFResource>*/** commands);
NS_IMETHOD IsCommandEnabled(nsISupportsArray/*<nsIRDFResource>*/* aSources,
nsIRDFResource* aCommand,
nsISupportsArray/*<nsIRDFResource>*/* aArguments,
PRBool* aResult);
NS_IMETHOD DoCommand(nsISupportsArray/*<nsIRDFResource>*/* aSources,
nsIRDFResource* aCommand,
nsISupportsArray/*<nsIRDFResource>*/* aArguments);
NS_DECL_NSIRDFDATASOURCE
};
@ -937,7 +878,32 @@ RelatedLinksHandlerImpl::HasAssertion(nsIRDFResource *aSource,
return mInner->HasAssertion(aSource, aProperty, aTarget, aTruthValue, aResult);
}
NS_IMETHODIMP
RelatedLinksHandlerImpl::HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, PRBool *result)
{
return mInner->HasArcIn(aNode, aArc, result);
}
NS_IMETHODIMP
RelatedLinksHandlerImpl::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *result)
{
nsresult rv;
PRBool hasValueFlag = PR_FALSE;
if (aArc == kNC_Child &&
(aSource == kNC_RelatedLinksRoot) ||
(NS_SUCCEEDED(rv = mInner->HasAssertion(aSource, kRDF_type,
kNC_RelatedLinksTopic, PR_TRUE,
&hasValueFlag))) &&
(hasValueFlag == PR_TRUE))
{
*result = PR_TRUE;
}
else {
*result = PR_FALSE;
}
return NS_OK;
}
NS_IMETHODIMP
RelatedLinksHandlerImpl::ArcLabelsIn(nsIRDFNode *aTarget,

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

@ -1570,7 +1570,74 @@ InternetSearchDataSource::HasAssertion(nsIRDFResource *source,
return(rv);
}
NS_IMETHODIMP
InternetSearchDataSource::HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, PRBool *result)
{
if (mInner) {
return mInner->HasArcIn(aNode, aArc, result);
}
else {
*result = PR_FALSE;
}
return NS_OK;
}
NS_IMETHODIMP
InternetSearchDataSource::HasArcOut(nsIRDFResource *source, nsIRDFResource *aArc, PRBool *result)
{
NS_PRECONDITION(source != nsnull, "null ptr");
if (! source)
return NS_ERROR_NULL_POINTER;
nsresult rv;
if ((source == kNC_SearchEngineRoot) || (source == kNC_LastSearchRoot) || isSearchURI(source))
{
*result = (aArc == kNC_Child);
return NS_OK;
}
if ((isSearchCategoryURI(source)) && (categoryDataSource))
{
const char *uri = nsnull;
source->GetValueConst(&uri);
if (!uri) return(NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIRDFResource> category;
if (NS_FAILED(rv = gRDFService->GetResource(uri,
getter_AddRefs(category))))
return(rv);
return categoryDataSource->HasArcOut(source, aArc, result);
}
if (isSearchCategoryEngineURI(source))
{
nsCOMPtr<nsIRDFResource> trueEngine;
rv = resolveSearchCategoryEngineURI(source, getter_AddRefs(trueEngine));
if (NS_FAILED(rv) || (rv == NS_RDF_NO_VALUE)) return(rv);
if (!trueEngine) {
*result = PR_FALSE;
return NS_OK;
}
source = trueEngine;
}
if (isEngineURI(source))
{
// if we're asking for info on a search engine, (deferred) load it if needed
nsCOMPtr<nsIRDFLiteral> dataLit;
FindData(source, getter_AddRefs(dataLit));
}
if (mInner)
{
return mInner->HasArcOut(source, aArc, result);
}
*result = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
InternetSearchDataSource::ArcLabelsIn(nsIRDFNode *node,

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

@ -100,64 +100,7 @@ public:
nsresult Init();
NS_DECL_NSILOCALSEARCHSERVICE
// nsIRDFDataSource methods
NS_IMETHOD GetURI(char **uri);
NS_IMETHOD GetSource(nsIRDFResource *property,
nsIRDFNode *target,
PRBool tv,
nsIRDFResource **source /* out */);
NS_IMETHOD GetSources(nsIRDFResource *property,
nsIRDFNode *target,
PRBool tv,
nsISimpleEnumerator **sources /* out */);
NS_IMETHOD GetTarget(nsIRDFResource *source,
nsIRDFResource *property,
PRBool tv,
nsIRDFNode **target /* out */);
NS_IMETHOD GetTargets(nsIRDFResource *source,
nsIRDFResource *property,
PRBool tv,
nsISimpleEnumerator **targets /* out */);
NS_IMETHOD Assert(nsIRDFResource *source,
nsIRDFResource *property,
nsIRDFNode *target,
PRBool tv);
NS_IMETHOD Unassert(nsIRDFResource *source,
nsIRDFResource *property,
nsIRDFNode *target);
NS_IMETHOD Change(nsIRDFResource* aSource,
nsIRDFResource* aProperty,
nsIRDFNode* aOldTarget,
nsIRDFNode* aNewTarget);
NS_IMETHOD Move(nsIRDFResource* aOldSource,
nsIRDFResource* aNewSource,
nsIRDFResource* aProperty,
nsIRDFNode* aTarget);
NS_IMETHOD HasAssertion(nsIRDFResource *source,
nsIRDFResource *property,
nsIRDFNode *target,
PRBool tv,
PRBool *hasAssertion /* out */);
NS_IMETHOD ArcLabelsIn(nsIRDFNode *node,
nsISimpleEnumerator **labels /* out */);
NS_IMETHOD ArcLabelsOut(nsIRDFResource *source,
nsISimpleEnumerator **labels /* out */);
NS_IMETHOD GetAllResources(nsISimpleEnumerator** aCursor);
NS_IMETHOD AddObserver(nsIRDFObserver *n);
NS_IMETHOD RemoveObserver(nsIRDFObserver *n);
NS_IMETHOD GetAllCommands(nsIRDFResource* source,
nsIEnumerator/*<nsIRDFResource>*/** commands);
NS_IMETHOD GetAllCmds(nsIRDFResource* source,
nsISimpleEnumerator/*<nsIRDFResource>*/** commands);
NS_IMETHOD IsCommandEnabled(nsISupportsArray/*<nsIRDFResource>*/* aSources,
nsIRDFResource* aCommand,
nsISupportsArray/*<nsIRDFResource>*/* aArguments,
PRBool* aResult);
NS_IMETHOD DoCommand(nsISupportsArray/*<nsIRDFResource>*/* aSources,
nsIRDFResource* aCommand,
nsISupportsArray/*<nsIRDFResource>*/* aArguments);
NS_DECL_NSIRDFDATASOURCE
};
@ -788,7 +731,29 @@ LocalSearchDataSource::HasAssertion(nsIRDFResource *source,
return (rv);
}
NS_IMETHODIMP
LocalSearchDataSource::HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, PRBool *result)
{
*result = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
LocalSearchDataSource::HasArcOut(nsIRDFResource *source, nsIRDFResource *aArc, PRBool *result)
{
NS_PRECONDITION(source != nsnull, "null ptr");
if (! source)
return NS_ERROR_NULL_POINTER;
if ((aArc == kNC_Child ||
aArc == kNC_pulse)) {
*result = isFindURI(source);
}
else {
*result = PR_FALSE;
}
return NS_OK;
}
NS_IMETHODIMP
LocalSearchDataSource::ArcLabelsIn(nsIRDFNode *node,

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

@ -481,7 +481,6 @@ nsSHistory::CompareSHEntry(nsISHEntry * aPrevEntry, nsISHEntry * aNextEntry, nsI
if (!aPrevEntry || !aNextEntry || !aParent)
return PR_FALSE;
nsresult rv;
PRBool result = PR_FALSE;
nsCOMPtr<nsIURI> prevURI, nextURI;