Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions | Variables
nsWindowDataSource.cpp File Reference
#include "nsWindowDataSource.h"
#include "nsIXULWindow.h"
#include "rdf.h"
#include "nsIRDFContainerUtils.h"
#include "nsIServiceManager.h"
#include "nsReadableUtils.h"
#include "nsObserverService.h"
#include "nsIWindowMediator.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIDocShell.h"

Go to the source code of this file.

Classes

struct  findWindowClosure

Functions

 DEFINE_RDF_VOCAB (NC_NAMESPACE_URI, NC, Name)
 DEFINE_RDF_VOCAB (NC_NAMESPACE_URI, NC, KeyIndex)
 NS_IMPL_ISUPPORTS4 (nsWindowDataSource, nsIObserver, nsIWindowMediatorListener, nsIWindowDataSource, nsIRDFDataSource) NS_IMETHODIMP nsWindowDataSource
 findWindow (nsHashKey *aKey, void *aData, void *aClosure)

Variables

static const char kURINC_WindowRoot [] = "NC:WindowMediatorRoot"

Class Documentation

struct findWindowClosure

Definition at line 326 of file nsWindowDataSource.cpp.

Collaboration diagram for findWindowClosure:
Class Members
nsIXULWindow * resultWindow
nsIRDFResource * targetResource

Function Documentation

DEFINE_RDF_VOCAB ( NC_NAMESPACE_URI  ,
NC  ,
Name   
)
DEFINE_RDF_VOCAB ( NC_NAMESPACE_URI  ,
NC  ,
KeyIndex   
)
findWindow ( nsHashKey *  aKey,
void aData,
void aClosure 
)

Definition at line 332 of file nsWindowDataSource.cpp.

{
    nsVoidKey *thisKey = NS_STATIC_CAST(nsVoidKey*, aKey);

    nsIRDFResource *resource =
        NS_STATIC_CAST(nsIRDFResource*, aData);
    
    findWindowClosure* closure =
        NS_STATIC_CAST(findWindowClosure*, aClosure);

    if (resource == closure->targetResource) {
        closure->resultWindow =
            NS_STATIC_CAST(nsIXULWindow*,
                           thisKey->GetValue());
        return PR_FALSE;         // stop enumerating
    }
    return PR_TRUE;
}

Here is the call graph for this function:

Definition at line 162 of file nsWindowDataSource.cpp.

{
    nsresult rv;
    
    nsVoidKey key(window);

    nsCOMPtr<nsISupports> sup =
        dont_AddRef(mWindowResources.Get(&key));

    // oops, make sure this window is in the hashtable!
    if (!sup) {
        OnOpenWindow(window);
        sup = dont_AddRef(mWindowResources.Get(&key));
    }
    
    NS_ENSURE_TRUE(sup, NS_ERROR_UNEXPECTED);

    nsCOMPtr<nsIRDFResource> windowResource =
        do_QueryInterface(sup);

    nsCOMPtr<nsIRDFLiteral> newTitleLiteral;
    rv = gRDFService->GetLiteral(newTitle, getter_AddRefs(newTitleLiteral));
    NS_ENSURE_SUCCESS(rv, rv);

    // get the old title
    nsCOMPtr<nsIRDFNode> oldTitleNode;
    rv = GetTarget(windowResource, kNC_Name, PR_TRUE,
                   getter_AddRefs(oldTitleNode));
    
    // assert the change
    if (NS_SUCCEEDED(rv) && oldTitleNode)
        // has an existing window title, update it
        rv = Change(windowResource, kNC_Name, oldTitleNode, newTitleLiteral);
    else
        // removed from the tasklist
        rv = Assert(windowResource, kNC_Name, newTitleLiteral, PR_TRUE);

    if (rv != NS_RDF_ASSERTION_ACCEPTED)
    {
      NS_ERROR("unable to set window name");
    }
    
    return NS_OK;
}

Here is the call graph for this function:


Variable Documentation

const char kURINC_WindowRoot[] = "NC:WindowMediatorRoot" [static]

Definition at line 61 of file nsWindowDataSource.cpp.