Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Attributes
nsMsgRDFDataSource Class Reference

#include <nsMsgRDFDataSource.h>

Inheritance diagram for nsMsgRDFDataSource:
Inheritance graph
[legend]
Collaboration diagram for nsMsgRDFDataSource:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsMsgRDFDataSource ()
virtual ~nsMsgRDFDataSource ()
virtual nsresult Init ()
NS_DECL_ISUPPORTS
NS_DECL_NSIMSGRDFDATASOURCE
NS_DECL_NSIRDFDATASOURCE
virtual NS_DECL_NSIOBSERVER
void 
Cleanup ()
nsIRDFResource GetSource (in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue)
 Find an RDF resource that points to a given node over the specified arc & truth value.
nsISimpleEnumerator GetSources (in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue)
 Find all RDF resources that point to a given node over the specified arc & truth value.
nsIRDFNode GetTarget (in nsIRDFResource aSource, in nsIRDFResource aProperty, in boolean aTruthValue)
 Find a child of that is related to the source by the given arc arc and truth value.
nsISimpleEnumerator GetTargets (in nsIRDFResource aSource, in nsIRDFResource aProperty, in boolean aTruthValue)
 Find all children of that are related to the source by the given arc arc and truth value.
void Assert (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue)
 Add an assertion to the graph.
void Unassert (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget)
 Remove an assertion from the graph.
void Change (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aOldTarget, in nsIRDFNode aNewTarget)
 Change an assertion from.
void Move (in nsIRDFResource aOldSource, in nsIRDFResource aNewSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget)
 'Move' an assertion from
boolean HasAssertion (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue)
 Query whether an assertion exists in this graph.
void AddObserver (in nsIRDFObserver aObserver)
 Add an observer to this data source.
void RemoveObserver (in nsIRDFObserver aObserver)
 Remove an observer from this data source.
nsISimpleEnumerator ArcLabelsIn (in nsIRDFNode aNode)
 Get a cursor to iterate over all the arcs that point into a node.
nsISimpleEnumerator ArcLabelsOut (in nsIRDFResource aSource)
 Get a cursor to iterate over all the arcs that originate in a resource.
nsISimpleEnumerator GetAllResources ()
 Retrieve all of the resources that the data source currently refers to.
boolean IsCommandEnabled (in nsISupportsArray aSources, in nsIRDFResource aCommand, in nsISupportsArray aArguments)
 Returns whether a given command is enabled for a set of sources.
void DoCommand (in nsISupportsArray aSources, in nsIRDFResource aCommand, in nsISupportsArray aArguments)
 Perform the specified command on set of sources.
nsISimpleEnumerator GetAllCmds (in nsIRDFResource aSource)
 Returns the set of all commands defined for a given source.
boolean hasArcIn (in nsIRDFNode aNode, in nsIRDFResource aArc)
 Returns true if the specified node is pointed to by the specified arc.
boolean hasArcOut (in nsIRDFResource aSource, in nsIRDFResource aArc)
 Returns true if the specified node has the specified outward arc.
void beginUpdateBatch ()
 Notify observers that the datasource is about to send several notifications at once.
void endUpdateBatch ()
 Notify observers that the datasource has completed issuing a notification group.
void observe (in nsISupports aSubject, in string aTopic, in wstring aData)
 Observe will be called when there is a notification for the topic |aTopic|.

Public Attributes

readonly attribute string URI
 The "URI" of the data source.
attribute nsIMsgWindow window

Protected Member Functions

nsIRDFServicegetRDFService ()
nsresult NotifyObservers (nsIRDFResource *subject, nsIRDFResource *property, nsIRDFNode *newObject, nsIRDFNode *oldObject, PRBool assert, PRBool change)
virtual nsresult NotifyPropertyChanged (nsIRDFResource *resource, nsIRDFResource *propertyResource, nsIRDFNode *newNode, nsIRDFNode *oldNode=nsnull)
nsresult GetTransactionManager (nsISupportsArray *sources, nsITransactionManager **aTransactionManager)

Static Protected Member Functions

static PRBool assertEnumFunc (nsISupports *aElement, void *aData)
static PRBool unassertEnumFunc (nsISupports *aElement, void *aData)
static PRBool changeEnumFunc (nsISupports *aElement, void *aData)

Protected Attributes

nsCOMPtr< nsIMsgWindowmWindow
PRBool m_shuttingDown
PRBool mInitialized

Private Attributes

nsCOMPtr< nsIRDFServicemRDFService
nsCOMPtr< nsISupportsArraymObservers

Detailed Description

Definition at line 53 of file nsMsgRDFDataSource.h.


Constructor & Destructor Documentation

Definition at line 49 of file nsMsgRDFDataSource.cpp.

Here is the call graph for this function:

Definition at line 59 of file nsMsgRDFDataSource.cpp.

{
    // final shutdown happens here
    NS_ASSERTION(!mInitialized, "Object going away without cleanup, possibly dangerous!");
    if (mInitialized) Cleanup();
}

Here is the call graph for this function:


Member Function Documentation

Add an observer to this data source.

If the datasource supports observers, the datasource source should hold a strong reference to the observer.

Here is the caller graph for this function:

Get a cursor to iterate over all the arcs that point into a node.

Returns:
NS_OK unless a catastrophic error occurs. If the method returns NS_OK, you may assume that labels points to a valid (but possible empty) nsISimpleEnumerator object.

Here is the caller graph for this function:

Get a cursor to iterate over all the arcs that originate in a resource.

Returns:
NS_OK unless a catastrophic error occurs. If the method returns NS_OK, you may assume that labels points to a valid (but possible empty) nsISimpleEnumerator object.

Here is the caller graph for this function:

void nsIRDFDataSource::Assert ( in nsIRDFResource  aSource,
in nsIRDFResource  aProperty,
in nsIRDFNode  aTarget,
in boolean  aTruthValue 
) [inherited]

Add an assertion to the graph.

Here is the caller graph for this function:

PRBool nsMsgRDFDataSource::assertEnumFunc ( nsISupports *  aElement,
void aData 
) [static, protected]

Definition at line 401 of file nsMsgRDFDataSource.cpp.

{
  nsMsgRDFNotification *note = (nsMsgRDFNotification *)aData;
  nsIRDFObserver* observer = (nsIRDFObserver *)aElement;
  
  observer->OnAssert(note->datasource,
                     note->subject,
                     note->property,
                     note->newObject);
  return PR_TRUE;
}

Here is the caller graph for this function:

Notify observers that the datasource is about to send several notifications at once.

This must be followed by calling endUpdateBatch(), otherwise viewers will get out of sync.

void nsIRDFDataSource::Change ( in nsIRDFResource  aSource,
in nsIRDFResource  aProperty,
in nsIRDFNode  aOldTarget,
in nsIRDFNode  aNewTarget 
) [inherited]

Change an assertion from.

[aSource]--[aProperty]-->[aOldTarget]

to

[aSource]--[aProperty]-->[aNewTarget]

Here is the caller graph for this function:

PRBool nsMsgRDFDataSource::changeEnumFunc ( nsISupports *  aElement,
void aData 
) [static, protected]

Definition at line 427 of file nsMsgRDFDataSource.cpp.

{
  nsMsgRDFNotification* note = (nsMsgRDFNotification *)aData;
  nsIRDFObserver* observer = (nsIRDFObserver *)aElement;

  observer->OnChange(note->datasource,
                     note->subject,
                     note->property,
                     note->oldObject, note->newObject);
  return PR_TRUE;
}

Here is the caller graph for this function:

Reimplemented in nsMsgRecentFoldersDataSource, nsMsgFlatFolderDataSource, nsMsgAccountManagerDataSource, and nsMsgFolderDataSource.

Definition at line 92 of file nsMsgRDFDataSource.cpp.

{
    nsresult rv;
    mRDFService = nsnull;
    
    // release ourselves from the observer service
    nsCOMPtr<nsIObserverService> obs = do_GetService("@mozilla.org/observer-service;1",
                                                     &rv);
    if (NS_SUCCEEDED(rv)) {
        rv = obs->RemoveObserver(NS_STATIC_CAST(nsIObserver*, this),
                                 NS_XPCOM_SHUTDOWN_OBSERVER_ID);
    }
    
    // release the window
       mWindow = nsnull;

    mInitialized = PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIRDFDataSource::DoCommand ( in nsISupportsArray  aSources,
in nsIRDFResource  aCommand,
in nsISupportsArray  aArguments 
) [inherited]

Perform the specified command on set of sources.

Here is the caller graph for this function:

Notify observers that the datasource has completed issuing a notification group.

Returns the set of all commands defined for a given source.

Here is the caller graph for this function:

Retrieve all of the resources that the data source currently refers to.

Here is the caller graph for this function:

Definition at line 356 of file nsMsgRDFDataSource.cpp.

{
    if (!mRDFService && !m_shuttingDown) {
        nsresult rv;
        mRDFService = do_GetService(kRDFServiceCID, &rv);
        if (NS_FAILED(rv)) return nsnull;
    }
    
    return mRDFService;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIRDFResource nsIRDFDataSource::GetSource ( in nsIRDFResource  aProperty,
in nsIRDFNode  aTarget,
in boolean  aTruthValue 
) [inherited]

Find an RDF resource that points to a given node over the specified arc & truth value.

Returns:
NS_RDF_NO_VALUE if there is no source that leads to the target with the specified property.

Here is the caller graph for this function:

nsISimpleEnumerator nsIRDFDataSource::GetSources ( in nsIRDFResource  aProperty,
in nsIRDFNode  aTarget,
in boolean  aTruthValue 
) [inherited]

Find all RDF resources that point to a given node over the specified arc & truth value.

Returns:
NS_OK unless a catastrophic error occurs. If the method returns NS_OK, you may assume that nsISimpleEnumerator points to a valid (but possibly empty) cursor.

Here is the caller graph for this function:

nsIRDFNode nsIRDFDataSource::GetTarget ( in nsIRDFResource  aSource,
in nsIRDFResource  aProperty,
in boolean  aTruthValue 
) [inherited]

Find a child of that is related to the source by the given arc arc and truth value.

Returns:
NS_RDF_NO_VALUE if there is no target accessable from the source via the specified property.

Here is the caller graph for this function:

nsISimpleEnumerator nsIRDFDataSource::GetTargets ( in nsIRDFResource  aSource,
in nsIRDFResource  aProperty,
in boolean  aTruthValue 
) [inherited]

Find all children of that are related to the source by the given arc arc and truth value.

Returns:
NS_OK unless a catastrophic error occurs. If the method returns NS_OK, you may assume that nsISimpleEnumerator points to a valid (but possibly empty) cursor.

Here is the caller graph for this function:

nsresult nsMsgRDFDataSource::GetTransactionManager ( nsISupportsArray sources,
nsITransactionManager **  aTransactionManager 
) [protected]

Definition at line 439 of file nsMsgRDFDataSource.cpp.

{
  if(!aTransactionManager)
    return NS_ERROR_NULL_POINTER;
  
  *aTransactionManager = nsnull;
  nsresult rv = NS_OK;
  
  nsCOMPtr<nsITransactionManager> transactionManager;
  
  PRUint32 cnt;
  
  rv = aSources->Count(&cnt);
  if (NS_FAILED(rv)) return rv;
  
  if (cnt > 0)
  {
    transactionManager = do_QueryElementAt(aSources, 0, &rv);
    if (NS_SUCCEEDED(rv) && transactionManager)
    {
      aSources->RemoveElementAt(0);
      NS_IF_ADDREF(*aTransactionManager = transactionManager);
    }
  }
  
  return NS_OK;      
}

Here is the call graph for this function:

boolean nsIRDFDataSource::hasArcIn ( in nsIRDFNode  aNode,
in nsIRDFResource  aArc 
) [inherited]

Returns true if the specified node is pointed to by the specified arc.

Equivalent to enumerating ArcLabelsIn and comparing for the specified arc.

Returns true if the specified node has the specified outward arc.

Equivalent to enumerating ArcLabelsOut and comparing for the specified arc.

boolean nsIRDFDataSource::HasAssertion ( in nsIRDFResource  aSource,
in nsIRDFResource  aProperty,
in nsIRDFNode  aTarget,
in boolean  aTruthValue 
) [inherited]

Query whether an assertion exists in this graph.

Here is the caller graph for this function:

Reimplemented in nsMsgFlatFolderDataSource, nsMsgAccountManagerDataSource, and nsMsgFolderDataSource.

Definition at line 70 of file nsMsgRDFDataSource.cpp.

{
    nsresult rv=NS_OK;

    if (mInitialized)
        return NS_ERROR_ALREADY_INITIALIZED;
    
    /* Add an observer to XPCOM shutdown */
    nsCOMPtr<nsIObserverService> obs = do_GetService("@mozilla.org/observer-service;1",
                                                     &rv);
    if (NS_FAILED(rv)) return rv;
    rv = obs->AddObserver(NS_STATIC_CAST(nsIObserver*, this), NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_TRUE);
    if (NS_FAILED(rv)) return rv;

    /* Get and keep the rdf service. Will be released by the observer */
    getRDFService();
    
    mInitialized=PR_TRUE;
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

boolean nsIRDFDataSource::IsCommandEnabled ( in nsISupportsArray  aSources,
in nsIRDFResource  aCommand,
in nsISupportsArray  aArguments 
) [inherited]

Returns whether a given command is enabled for a set of sources.

Here is the caller graph for this function:

void nsIRDFDataSource::Move ( in nsIRDFResource  aOldSource,
in nsIRDFResource  aNewSource,
in nsIRDFResource  aProperty,
in nsIRDFNode  aTarget 
) [inherited]

'Move' an assertion from

[aOldSource]--[aProperty]-->[aTarget]

to

[aNewSource]--[aProperty]-->[aTarget]

Here is the caller graph for this function:

nsresult nsMsgRDFDataSource::NotifyObservers ( nsIRDFResource subject,
nsIRDFResource property,
nsIRDFNode newObject,
nsIRDFNode oldObject,
PRBool  assert,
PRBool  change 
) [protected]

Definition at line 378 of file nsMsgRDFDataSource.cpp.

{
    NS_ASSERTION(!(change && assert),
                 "Can't change and assert at the same time!\n");
    
       if(mObservers)
       {
              nsMsgRDFNotification note = { this, subject, property, newObject, oldObject };
              if(change)
                     mObservers->EnumerateForwards(changeEnumFunc, &note);
              else if (assert)
                     mObservers->EnumerateForwards(assertEnumFunc, &note);
              else
                     mObservers->EnumerateForwards(unassertEnumFunc, &note);
  }
       return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgRDFDataSource::NotifyPropertyChanged ( nsIRDFResource resource,
nsIRDFResource propertyResource,
nsIRDFNode newNode,
nsIRDFNode oldNode = nsnull 
) [protected, virtual]

Reimplemented in nsMsgRecentFoldersDataSource, and nsMsgUnreadFoldersDataSource.

Definition at line 367 of file nsMsgRDFDataSource.cpp.

{

  NotifyObservers(resource, propertyResource, newNode, oldNode, PR_FALSE, PR_TRUE);
  return NS_OK;

}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIObserver::observe ( in nsISupports  aSubject,
in string  aTopic,
in wstring  aData 
) [inherited]

Observe will be called when there is a notification for the topic |aTopic|.

This assumes that the object implementing this interface has been registered with an observer service such as the nsIObserverService.

If you expect multiple topics/subjects, the impl is responsible for filtering.

You should not modify, add, remove, or enumerate notifications in the implemention of observe.

Parameters:
aSubject: Notification specific interface pointer.
aTopic: The notification topic or subject.
aData: Notification specific wide string. subject event.

Remove an observer from this data source.

Here is the caller graph for this function:

void nsIRDFDataSource::Unassert ( in nsIRDFResource  aSource,
in nsIRDFResource  aProperty,
in nsIRDFNode  aTarget 
) [inherited]

Remove an assertion from the graph.

Here is the caller graph for this function:

PRBool nsMsgRDFDataSource::unassertEnumFunc ( nsISupports *  aElement,
void aData 
) [static, protected]

Definition at line 414 of file nsMsgRDFDataSource.cpp.

{
  nsMsgRDFNotification* note = (nsMsgRDFNotification *)aData;
  nsIRDFObserver* observer = (nsIRDFObserver *)aElement;

  observer->OnUnassert(note->datasource,
                       note->subject,
                       note->property,
                       note->newObject);
  return PR_TRUE;
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 88 of file nsMsgRDFDataSource.h.

Definition at line 89 of file nsMsgRDFDataSource.h.

Definition at line 93 of file nsMsgRDFDataSource.h.

Definition at line 92 of file nsMsgRDFDataSource.h.

Definition at line 86 of file nsMsgRDFDataSource.h.

readonly attribute string nsIRDFDataSource::URI [inherited]

The "URI" of the data source.

This used by the RDF service's |GetDataSource()| method to cache datasources.

Definition at line 56 of file nsIRDFDataSource.idl.

Definition at line 47 of file nsIMsgRDFDataSource.idl.


The documentation for this class was generated from the following files: