Search completed in 1.17 seconds.
36 results for "Getter_AddRefs":
Your results are loading. Please wait...
Reference Manual
don't qi qi addref t*, dont_queryinterface(t*) do_queryinterface(nsisupports*), do_queryinterface(nsisupports*, nsresult*) do_queryreferent(nsiweakreference*), do_queryreferent(nsiweakreference*, nsresult*) don't addref dont_addref(t*), getter_addrefs(t*) n/a e.g., one of the possibilities for assigning into an nscomptr, but you don't want to addref the pointer you are assigning (because it has already been addrefed for some reason) is dont_addref(t*) found at the intersection of "don't addref" and "don't qi".
...nsresult rv; nscomptr<nsifoo> foo( do_queryinterface(abarptr, &rv) ); // or foo = do_queryinterface(abarptr, &rv); nscomptr<t> = dont_addref( t* ), nscomptr<t> = getter_addrefs( t* ) sometimes, you happen to have a pointer lying around that's already addrefed, but you want to put it into an nscomptr.
... nscomptr<nsifoo> foo( getter_addrefs(createafoo()) ); // |getter_addrefs| is a synonym for |dont_addref| that may look better to // you when applied to functions that return |addref|ed pointers nscomptr<nsifoo> foo( dont_addref(createafoo()) ); // or, maybe you don't like it better...
...And 12 more matches
Starting WebLock
nscomptr<nsicategorymanager> catman; rv = servman->getservicebycontractid(ns_categorymanager_contractid, ns_get_iid(nsicategorymanager), getter_addrefs(catman)); if (ns_failed(rv)) return rv; there are two service getters on the nsiservicemanager interface: one that takes a cid and another interface that takes a contract id.
... const nsmodulecomponentinfo *info) { nsresult rv; nscomptr<nsiservicemanager> servman = do_queryinterface((nsisupports*)acompmgr, &rv); if (ns_failed(rv)) return rv; nscomptr<nsicategorymanager> catman; rv = servman->getservicebycontractid(ns_categorymanager_contractid, ns_get_iid(nsicategorymanager), getter_addrefs(catman)); if (ns_failed(rv)) return rv; char* previous = nsnull; rv = catman->addcategoryentry("xpcom-startup", "weblock", weblock_contractid, pr_true, pr_true, &previous); if (previous) nsmemory::free(previous); retur...
... const nsmodulecomponentinfo *info) { nsresult rv; nscomptr<nsiservicemanager> servman = do_queryinterface((nsisupports*)acompmgr, &rv); if (ns_failed(rv)) return rv; nscomptr<nsicategorymanager> catman; rv = servman->getservicebycontractid(ns_categorymanager_contractid, ns_get_iid(nsicategorymanager), getter_addrefs(catman)); if (ns_failed(rv)) return rv; rv = catman->deletecategoryentry("xpcom-startup", "weblock", pr_true); return rv; } ns_generic_factory_constructor(weblock) static const nsmodulecomponentinfo components[] = { { "weblock", weblock_cid, weblock_contractid, weblockconstructor, weblockregi...
...And 5 more matches
Getting Started Guide
you have to `annotate' the nscomptr with the getter_addrefs directive.
...differences: apply getter_addrefs when using an nscomptr as a `out parameter'.
... nscomptr<nsifoo> foo; getfoo(getter_addrefs(foo)); that's it.
...And 4 more matches
Working with Multiple Versions of Interfaces
nscomptr<nsiaccessible> accnode; rv = refp->getaccessiblefor(node, getter_addrefs(accnode)); if(ns_failed(rv)){ return self; } void *wh = null; nscomptr<nsiaccessibledocument> accdocnode; accdocnode = do_queryinterface(accnode, &rv); if(ns_failed(rv)){ return self; } rv = accdocnode->getwindowhandle(&wh); if(ns_succeeded(rv)){ self = static_cast<hwnd>(wh); } return self; } this approach worked, as is, for versions as early as firefox 1.5.
... hwnd gethwndb(nsidomnode *node){ hwnd self = null; nsresult rv; nscomptr<nsicomponentmanager> compmgr; rv = ns_getcomponentmanager(getter_addrefs(compmgr)); if (ns_failed(rv)){ return self; } nscomptr<nsiaccessibleretrieval> refp; rv = compmgr->createinstancebycontractid(accretcid, 0, iar_iid_old, getter_addrefs(refp)); if (ns_failed(rv)){ return self; } nscomptr<nsiaccessible> accnode; rv = refp->getaccessiblefor(node, getter_addrefs(accnode)); if(ns_failed(rv)){ return self; } void *wh = null; nscomptr<nsiaccessibledoc...
...ument> accdocnode; rv = accnode->queryinterface(iad_iid_old, getter_addrefs(accdocnode)); if(ns_failed(rv)){ return self; } rv = accdocnode->getwindowhandle(&wh); if(ns_succeeded(rv)){ self = static_cast<hwnd>(wh); } return self; } there is good news and bad news.
...And 3 more matches
XPCOM array guide
MozillaTechXPCOMGuideArrays
void notifyobservers(nsiarray* aarray) { pruint32 length; aarray->getlength(&length); for (pruint32 i=0; i<length; ++i) { nscomptr<nsimyobserver> element; aarray->queryelementat(i, ns_get_iid(nsielement), getter_addrefs(element)); element->observe(); } } a simpler option is to use the helper do_queryelementat which is typesafe.
...// get the array nscomptr<nsiarray> array; foo->getelements(getter_addrefs(array)); // make an enumerator nscomptr<nsisimpleenumerator> enumerator; array->enumerate(getter_addrefs(enumerator)); // now enumerate the elements ...
...nscomptr<nsistringenumerator> enumerator; ns_newstringenumerator(getter_addrefs(enumerator), melementnames); // now call a method on "this" that has a known behavior processnames(enumerator); // now enumerator is used up, and can be released ...
... ns_imethod getstrings(nsistringenumerator** aresult); private: nscstringarray melementnames; }; ns_imethodimp nsfoo::getstrings(nsistringenumerator** aresult) { nscomptr<nsiutf8stringenumerator> enumerator; nsresult rv = ns_newutf8stringenumerator(getter_addrefs(enumerator), melementnames, this); ns_ensure_success(rv, rv); return callqueryinterface(enumerator, aresult); } obsolete arrays and enumerators nsisupportsarray nsienumerator (includes nsibidirectionalenumerator) ...
Finishing the Component
const nsmodulecomponentinfo *info) { nsresult rv; nscomptr<nsiservicemanager> servman = do_queryinterface((nsisupports*)acompmgr, &rv); if (ns_failed(rv)) return rv; nscomptr<nsicategorymanager> catman; servman->getservicebycontractid(ns_categorymanager_contractid, ns_get_iid(nsicategorymanager), getter_addrefs(catman)); if (ns_failed(rv)) return rv; char* previous = nsnull; rv = catman->addcategoryentry("xpcom-startup", "weblock", weblock_contractid, pr_true, pr_true, &previous); if (previous) nsmemory::free(previous); rv = c...
...the code for getting the io service from the service manager looks like this: // get a pointer to the ioservice rv = servman->getservicebycontractid("@mozilla.org/network/io-service;1", ns_get_iid(nsiioservice), getter_addrefs(mioservice)); once you have this interface pointer, you can easily create nsiuri objects from a string, as in the following snippet: nscomptr<nsiuri> uri; nsembedcstring urlstring(node->urlstring); mioservice->newuri(urlstring, nsnull, nsnull, getter_addrefs(uri)); this code wraps a c-string with a nsembedcstring, which you'll recall i...
... *_retval = pr_false; nsresult rv; nscomptr<nsiservicemanager> servman; rv = ns_getservicemanager(getter_addrefs(servman)); if (ns_failed(rv)) return rv; nscomptr<nsiioservice> mioservice; // get a pointer to the ioservice rv = servman->getservicebycontractid("@mozilla.org/network/io-service;1", ns_get_iid(nsiioservice), getter_addrefs(mioservice)); if (ns_failed(rv)) return rv; urlnode* node = mrooturlnode; ...
... prbool match = pr_false; while (node) { nscomptr<nsiuri> uri; nsembedcstring urlstring(node->urlstring); rv = mioservice->newuri(urlstring, nsnull, nsnull, getter_addrefs(uri)); // if anything bad happens, just abort if (ns_failed(rv)) return rv; nsembedcstring host; uri->gethost(host); if (strcmp(hosttoload.get(), host.get()) == 0) { // match found.
Storage
rvices.jsm"); components.utils.import("resource://gre/modules/fileutils.jsm"); let file = fileutils.getfile("profd", ["my_db_file_name.sqlite"]); let dbconn = services.storage.opendatabase(file); // will also create the file if it does not exist likewise, the c++ would look like this: nscomptr<nsifile> dbfile; rv = ns_getspecialdirectory(ns_app_user_profile_50_dir, getter_addrefs(dbfile)); ns_ensure_success(rv, rv); rv = dbfile->append(ns_literal_string("my_db_file_name.sqlite")); ns_ensure_success(rv, rv); nscomptr<mozistorageservice> dbservice = do_getservice(moz_storage_service_contractid, &rv); ns_ensure_success(rv, rv); nscomptr<mozistorageconnection> dbconn; rv = dbservice->opendatabase(dbfile, getter_addrefs(dbconn)); ns_ensure_success(rv, rv); note: moz_stora...
...similarly, the c++ looks like this: nscomptr<mozistoragestatement> statement; rv = dbconn->createstatement(ns_literal_cstring("select * from table_name where column_name = ?1"), getter_addrefs(statement)); ns_ensure_success(rv, rv); this example uses the numbered placeholder indexed by zero for a parameter to be bound later (described in binding parameters).
... c++ example: nscomptr<mozistoragestatement> statement; rv = mdbconn->createstatement(ns_literal_cstring("select * from table_name where id = ?1"), getter_addrefs(statement)); ns_ensure_success(rv, rv); rv = statement->bindint32parameter(0, 1234); ns_ensure_success(rv, rv); note: numerical indexes for parameters are always one less than the number you write in the sql.
... nsresult rv = mdbconn->createstatement(ns_literal_cstring("delete from table_name"), getter_addrefs(statement)); ns_ensure_success(rv, rv); return statement->execute(); // once this function returns, mspecialstatement will be reset, and statement will // be destroyed.
Creating Custom Events That Can Pass Data
wwatcher->getactivewindow(getter_addrefs(awindow)); //get the active window.
... awindow->getdocument(getter_addrefs(adoc)); //get the document from the window.
... docevent->createevent(ns_literal_string("nsdommyevent"), getter_addrefs(event)); //create the event event->initevent(ns_literal_string("nsdommyevent"), pr_true, pr_true); //initialize it twindow = do_queryinterface(awindow); //use the window for a target.
Mozilla DOM Hacking Guide
nscomptr<nsidomwindow> window(do_queryinterface(native)); ns_ensure_true(window, ns_error_unexpected); nscomptr<nsidomlocation> location; rv = window->getlocation(getter_addrefs(location)); ns_ensure_success(rv, rv); // use the dom to get the location object of the window object.
... nscomptr<nsisupports> native; wrapper->getnative(getter_addrefs(native)); // get the pointer to the content object that was wrapped.
... nscomptr<nsidomlocation> location; nsresult rv = window->getlocation(getter_addrefs(location)); ns_ensure_success(rv, rv); // get the location object for this window.
Using XPCOM Utilities to Make Things Easier
using smart pointers, the code above can be simplified to: { nscomptr<nsisupports> value; object->method(getter_addrefs(value)); if (!value) return; // ...
...when you pass them to a getter, you must do something special, however: you must wrap the variable with the function getter_addrefs, as in the example above.
...this is a common pattern when you have a local nscomptr in a function and you must pass back a reference to it, as in the following: someclass::get(nsisupports** aresult) { if (!aresult) return ns_error_null_pointer; nscomptr<nsisupports> value; object->method(getter_addrefs(value)); *aresult = value.get(); ns_if_addref(*aresult); return ns_ok; } the first thing that this method does is check to see that the caller passed a valid address.
Introduction to XPCOM for the DOM
nscomptr<nsifoo> ifooptr; getinterfaceifoo(getter_addrefs(ifooptr)); ifooptr->functionofnsifoo(); the peculiar syntax, getter_addrefs(pointer), is the nscomptr counterpart to the usual "&" (address-of) c operator.
...we have already seen what getter_addrefs() does to nscomptr's.
...i had to use the second solution: nscomptr<nsicontent> content = getter_addrefs(ns_static_cast(nsicontent*, this)); // or, if you want to do the refcounting yourself, nsicontent *content = ns_static_cast(nsicontent*, this); the second form should be used with care, and is recommended only for advanced xpcom'ers.
Using Dependent Libraries In Extension Components - Archive of obsolete content
// assume that we're in <extensiondir>/components, and we want to find // <extensiondir>/libraries nscomptr<nsifile> libraries; rv = alocation->getparent(getter_addrefs(libraries)); if (ns_failed(rv)) return rv; nscomptr<nsilocalfile> library(do_queryinterface(libraries)); if (!library) return ns_error_unexpected; library->setnativeleafname(ns_literal_cstring("libraries")); library->appendnative(ns_literal_cstring("dummy")); // loop through and load dependent libraries for (char const *const *dependent = kdependentlibraries; *depe...
... // assume that we're in <extensiondir>/components, and we want to find // <extensiondir>/libraries nscomptr<nsifile> libraries; rv = alocation->getparent(getter_addrefs(libraries)); if (ns_failed(rv)) return rv; nscomptr<nsilocalfile> library(do_queryinterface(libraries)); if (!library) return ns_error_unexpected; library->setnativeleafname(ns_literal_cstring("libraries")); library->appendnative(ns_literal_cstring("dummy")); nscstring path; // loop through and load dependent libraries for (char const *const *dependent = kdependentlibraries; ...
Editor Embedding Guide - Archive of obsolete content
nscomptr<nsieditingsession> editingsession; nsiwebbrowser->do_getinterface(getter_addrefs(editingsession)); if (editingsession) editingsession->makewindoweditable(domwindow, "html", pr_true); the valid editor types are: "text" (similar to notepad or a textarea; does not allow for html) "textmail" (similar to "text" but html can be inserted; intended for plaintext mail usage and handling of citations) "html" (this is the default type if no type is specified; it allows for all htm...
...get the nsicommandmanager from the nsiwebbrowser using do_getinterface: nscomptr<nsicommandmanager> commandmanager; nsiwebbrowser->do_getinterface(getter_addrefs(commandmgr)); 2.
Multiprocess on Windows
there is also a mozilla::mscom::getter_addrefs() function that allows these pointers to receive outparams.
... simple example now you know about mainthreadhandoff::wrapinterface and about the smart pointers, you're ready to wrap an interface: accessible* myaccessible = ....; mozilla::mscom::stauniqueptr<iaccessible> acctowrap; myaccessible->getnativeinterface(mozilla::mscom::getter_addrefs(acctowrap)); mozilla::mscom::proxyuniqueptr<iaccessible> wrapped; hresult hr = mozilla::mscom::mainthreadhandoff::wrapinterface(mozilla::move(acctowrap), mozilla::mscom::getter_addrefs(wrapped)); if (failed(hr)) { // handle your error here } // the wrapped interface should be given to the at from within the mta.
nsICategoryManager
nsresult printallcategories() { nsresult rv; nscomptr<nsiservicemanager> svcmgr; rv = ns_getservicemanager(getter_addrefs(svcmgr)); if (ns_failed(rv)) return rv; nscomptr<nsicategorymanager> catmgr; rv = svcmgr->getservicebycontractid(ns_categorymanager_contractid, ns_get_iid(nsicategorymanager), getter_addrefs(catmgr)); if (ns_failed(rv)) return rv; nscomptr<nsisimpleenumerator> cats; rv = catmgr->enumeratecatego...
...ries(getter_addrefs(cats)); if (ns_failed(rv)) return rv; prbool hasmore; while (ns_succeeded(cats->hasmoreelements(&hasmore) && hasmore) { nscomptr<nsisupports> elem; cats->getnext(getter_addrefs(elem)); nscomptr<nsisupportscstring> category = do_queryinterface(elem, &rv); if (ns_failed(rv)) break; nsembedcstring categoryname; rv = category->getdata(categoryname); if (ns_failed(rv)) break; printf("%s\n", categoryname.get()); } return ns_ok; } this snippet shows how to print out a list of all categories in javascript.
Status, Recent Changes, and Plans
made getter_addrefs( nscomptr& ) apply the same type-safety check that the simple assignment forms do.
... eliminated the need to cast getter_addrefs when an nsisupports** is needed.
Finding window handles - Archive of obsolete content
like this hwnd gethwnd(nsibasewindow *window) { nscomptr< nsiwidget > widget; window->getmainwidget(getter_addrefs(widget)); if (widget) return (hwnd) widget->getnativedata(ns_native_window); } yet another way to find a window handle (parent window handle) this method is for people who want to get the top level window hwnd from the window object in javascript.
Common Pitfalls - Archive of obsolete content
terfaces.nsiioservice); var uriobj = ioserv.newuri(uristring, uricharset, baseuri); } catch (e) { // may want to catch ns_error_malformed_uri for some applications } c++: nsresult rv; nscomptr<nsiioservice> ioserv = do_getservice("@mozilla.org/network/io-service;1"); ns_ensure_success(rv, rv); nscomptr<nsiuri> uriobj; rv = ioserv->newuri(uristring, uricharset, baseuri, getter_addrefs(uriobj)); if (ns_failed(rv)) { // may want to handle ns_error_malformed_uri for // some applications return rv; } or, if the code can include nsnetutil.h: nscomptr<nsiuri> uriobj; nsresult rv = ns_newuri(getter_addrefs(uriobj), uristring, uricharset, baseuri); in all cases the baseuri can be null if the uristring should be treated as an absolute uri and uricharset can be null if there ...
Migrating from Internal Linkage to Frozen Linkage - Archive of obsolete content
(see xpcom:arrays.) nscomptr<nsisupportsarray> array; - rv = ns_newisupportsarray(getter_addrefs(array)); + array = do_createinstance(ns_supportsarray_contractid); - nscomptr<nsiinputstream> rawstream;- rv = ns_newbyteinputstream(getter_addrefs(rawstream),- (const char*)data, length); + nscomptr<nsistringinputstream> rawstream =+ do_createinstance(ns_stringinputstream_contractid, &rv);+ ns_ensure_success(rv, rv);++ rv = rawstream->setdata((const char*)data, leng...
Index - Archive of obsolete content
nscomptr<nsieditingsession> editingsession; nsiwebbrowser->do_getinterface(getter_addrefs(editingsession)); if (editingsession) editingsession->makewindoweditable(domwindow, "html", pr_tru?e); 430 embedding faq embedding mozilla no summary!
Tree Widget Changes - Archive of obsolete content
nscomptr<nsiatom> atom; acol->getatom(getter_addrefs(atom)); if (atom = kmycol) ...
Using LDAP XPCOM with XULRunner - Archive of obsolete content
ix, moz_dll_prefix "prldap50" moz_dll_suffix, #endif //ns_unix nsnull }; // component.dll on windows, libcomponent.dll on linux static char krealcomponent[] = moz_dll_prefix "mozldap" moz_dll_suffix; nsresult nsgetmodule(nsicomponentmanager* acompmgr, nsifile* alocation, nsimodule* *aresult) { nsresult rv; nscomptr<nsifile> libraries; rv = alocation->getparent(getter_addrefs(libraries)); if (ns_failed(rv)) return rv; nscomptr<nsilocalfile> library(do_queryinterface(libraries)); if (!library) return ns_error_unexpected; library->setnativeleafname(ns_literal_cstring("libraries")); library->appendnative(ns_literal_cstring("dummy")); // loop through and load dependent libraries for (char const *const *dependent = kdependentlibraries; *depe...
nsIContentPolicy - Archive of obsolete content
char* previous = nsnull; nscomptr<nsicategorymanager> catman; servman->getservicebycontractid(ns_categorymanager_contractid, ns_get_iid(nsicategorymanager), getter_addrefs(catman)); rv = catman->addcategoryentry("content-policy", component_classname, component_contractid, pr_true, pr_true, &previous); javascript developers can also implement an xpcom component that extends nsicontentpolicy.
Embedding Tips
nscomptr<nsidomdocument> doc; nscomptr<nsidomwindow> window; webbrowser->getcontentdomwindow(getter_addrefs(window)); if (window) { window->getdocument(getter_addrefs(doc)); } what is the docshell?
Pork Tools
in this case all of the callsites are modified to: a) getter_addrefs case: getter(getter_addrefs(foo)) -> foo = getter() b) all other cases: getter(&foo) -> foo = getter().get() ...
Aggregating the In-Memory Datasource
private: nscomptr<nsisupports> minner; }; construct the datasource delegate when your object is constructed (or, at worst, when somebody qi's for it): rv = nscomponentmanager::createinstance( krdfinmemorydatasourcecid, this, /* the "outer" */ nscomtypeinfo<nsisupports>::getiid(), getter_addrefs(minner)); note passing this as the "outer" parameter.
Using XPCOM Components
managing cookies from cpp nscomptr<nsiservicemanager> servman; nsresult rv = ns_getservicemanager(getter_addrefs(servman)); if (ns_failed(rv)) return -1; nscomptr<nsicookiemanager> cookiemanager; rv = servman->getservicebycontractid("@mozilla.org/cookiemanager", ns_get_iid(nsicookiemanager), getter_addrefs(cookiemanager)); if (ns_failed(rv)) return -1; pruint32 len; deletedcookies->getlength(&len); for (int c=0; c<len; c++) ...
Making cross-thread calls using runnables
int mdigits; }; putting it all together to start a new thread, create it using the thread manager: #include "nsxpcomcidinternal.h" void calculatepiasynchronously(int digits, picallback callback) { // to create a new thread, get the thread manager nscomptr<nsithreadmanager> tm = do_getservice(ns_threadmanager_contractid); nscomptr<nsithread> mythread; nsresult rv = tm->newthread(0, 0, getter_addrefs(mythread)); if (ns_failed(rv)) { // in case of failure, call back immediately with an empty string which indicates failure callback(emptycstring()); return; } nscomptr<nsirunnable> r = new picalculatetask(callback, digits); mythread->dispatch(r, nsieventtarget::dispatch_normal); // the result callback will shut down the worker thread, we can let it go here...
nsDirectoryService
*/ nsresult gettempdir(nsifile **aresult) { nsresult rv; nscomptr<nsiservicemanager> svcmgr; rv = ns_getservicemanager(getter_addrefs(svcmgr)); if (ns_failed(rv)) return rv; nscomptr<nsiproperties> directory; rv = svcmgr->getservicebycontractid("@mozilla.org/file/directory_service;1", ns_get_iid(nsiproperties), getter_addrefs(directory)); if (ns_failed(rv)) return rv; rv = directory->get(ns_os_temp_dir, ns_get_iid(nsifile), aresult);...
NS_NewLocalFile
example code // create a local file that references c:\foo.txt nsresult rv; nscomptr<nsilocalfile> file; rv = ns_newlocalfile(nsembedstring(l"c:\\foo.txt"), pr_false, getter_addrefs(file)); if (ns_failed(rv)) return rv; note: gcc requires the -fshort-wchar option to compile this example since prunichar is an unsigned short.
NS_NewNativeLocalFile
example code // create a local file that references c:\foo.txt nsresult rv; nscomptr<nsilocalfile> file; rv = ns_newnativelocalfile(nsembedcstring("c:\\foo.txt"), pr_false, getter_addrefs(file)); if (ns_failed(rv)) return rv; here, nsembedcstring is used to convert the ascii string literal to an object that can be passed as a const nsacstring& parameter.
mozIStorageAggregateFunction
nscomptr<mozistoragestatement> stmt; rv = dbconn->createstatement(ns_literal_cstring( "select stddev(value) from some_table"), getter_addrefs(stmt) ); ns_ensure_success(rv, rv); prbool hasmore; while (ns_succeeded(stmt->executestep(&hasmore)) && hasmore) { // handle the results } ...
mozIStorageFunction
nscomptr<mozistoragestatement> stmt; rv = dbconn->createstatement(ns_literal_cstring( "select square(value) from some_table"), getter_addrefs(stmt) ); ns_ensure_success(rv, rv); prbool hasmore; while (ns_succeeded(stmt->executestep(&hasmore)) && hasmore) { // handle the results } see also storage introduction and how-to article mozistorageconnection database connection to a specific file or in-memory data storage mozistoragestatement create and execute sql statements on a sqlite database.
nsISupports proxies
lt rv = ns_ok; nscomptr<nsiproxyobjectmanager> piproxyobjectmanager(do_getservice("@mozilla.org/xpcomproxy;1", &rv)); if(ns_failed(rv)) return rv; nscomptr<ifoo> ptestobj(do_createinstance(foo_contractid, &rv)); if(ns_failed(rv)) return rv; nscomptr<ifoo> pproxy; rv = piproxyobjectmanager->getproxyforobject(ns_proxy_to_main_thread, ifoo::getiid(), ptestobj, ns_proxy_sync | ns_proxy_always, getter_addrefs(pproxy)); if(ns_failed(rv)) return rv; // we do not care about the real object anymore.
Using nsIDirectoryService
c++ nscomptr<nsifile> dir; ns_getspecialdirectory(prop, getter_addrefs(dir)); if (!dir) return ns_error_failure; javascript: var file = components.classes["@mozilla.org/file/directory_service;1"] .getservice(components.interfaces.nsiproperties) .get("profd", components.interfaces.nsifile); (the example is taken from the code snippets section of this site.) adding a location: there are currently two ways to add ...
Weak reference
nsresult nsobservable::addobserver( nsiobserver* aobserver ) { mobserver = getter_addrefs( ns_getweakreference(aobserver) ); // ...or append this to the list of observers return ns_ok; } nsresult nsobservable::notifyobservers( nsimessage* amessage ) { nscomptr<nsiobserver> observer = do_queryreferent(mobserver); if ( observer ) observer->noticemessage(amessage); else mobserver = 0; // or remove this observer from the list, he's gone away ...