nsIComponentManager *pIComponentManager = NULL;
nsIDOMDocument *pIDOMDocument = NULL;
nsISupports *pISupports = NULL;
nsIURL *pIURL = NULL;
do
{
rv = NS_GetComponentManager(&pIComponentManager);
if(pIComponentManager == NULL)
break;
rv =
pIComponentManager->GetClassObjectByContractID("@mozilla.org/network/standard-url;1",
NS_GET_IID(nsISupports), (void**)&pISupports);
if(pISupports == NULL)
{
rv = pISupports->QueryInterface(NS_GET_IID(nsIURL), (void**)&pIURL); //<---
fails here with no interface available
}
if(pISupports != NULL)
{
pISupports->Release();
pISupports = NULL;
}
rv =
pIComponentManager->GetClassObjectByContractID("@mozilla.org/xul/xul-document;1",
NS_GET_IID(nsISupports), (void**)&pISupports);
if(pISupports)
rv = pISupports->QueryInterface(NS_GET_IID(nsIDOMDocument),
(void**)&pIDOMDocument); //<--- fails here with no interface available
}while(false);
if(pIDOMDocument != NULL)
pIDOMDocument->Release();
if(pIURL != NULL)
pIURL->Release();
if(pISupports != NULL)
pISupports->Release();
if(pIComponentManager != NULL)
pIComponentManager->Release();
With the above code, I can get the components nsISupports and but can
not get expected interfaces. What is wrong with the above code? Why does my
code fail? I can not find any clues from Internet by doing Yahoo and Google
searches.
Please give me a help!
What URL are you trying to get? From your sample code it looks like you're
trying to create a new URL.
> rv =
> pIComponentManager->GetClassObjectByContractID("@mozilla.org/network/standard-url;1",
> NS_GET_IID(nsISupports), (void**)&pISupports);
The class object is typically the object that implements nsIFactory, and it
is hardly ever necessary to call this method. You typically create new XPCOM
objects by calling CreateInstanceByContractID or GetServiceByContractID.
Furthermore, I can guarantee that you don't actually want to be creating a
new standardurl by hand. If you want to make a new URL, you should do so by
asking the IOService to create one using the correct protocol handler
(nsIIOService->NewURI).
--BDS
Regards
"Benjamin Smedberg" <benj...@smedbergs.us> wrote in message
news:VZSdnTF8Ip0GOrnZ...@mozilla.org...
"yekerui" <nos...@yahoo.com> wrote in message
news:wO6dnfRtqrmpn7XZ...@mozilla.org...
What kind of browser? What object(s) do you have a reference to? XPCOM
doesn't really have any concept of a browser, you have to have a reference
to the browser object that you want to query, and then you ask it what
location is loaded.
--BDS
Regards,
Yuancai (Charlie) Ye
"Benjamin Smedberg" <benj...@smedbergs.us> wrote in message
news:8d-dnZ15Usqsl7XZ...@mozilla.org...
yekerui wrote:
> Hi, Benjamin Smedberg:
> I am porting an activeX control for IE onto mozilla plugin.
This isn't really an XPCOM question. A valid from: address would also be
nice. Anyway...
If you use NPN_GetURL, you automatically get a security check
(checkLoadURI, not same-origin). You could also use the method mentioned
in
http://groups.google.com/group/netscape.public.mozilla.plugins/msg/93166efa554a191b
to get the URI of the page the plugin is in.
As this is a plugin issue I've set followup-to mozilla.dev.tech.plugins
only, let's continue this discussion there.
The NPAPI gives you the ability to get access to the nsIDOMWindow object
which contains the current plugin via the "NPNVDOMElement" enum[1] passed to
NPN_GetValue. This returns an addrefed nsIDOMElement[2] interface pointer
from which you can call .ownerDocument (on nsIDOMNode [3]), QueryInterface
that object to nsIDOM3Document[4], and call .documentURI.
1) http://lxr.mozilla.org/mozilla/source/modules/plugin/base/public/npapi.h#420
2)
http://lxr.mozilla.org/mozilla/source/dom/public/idl/core/nsIDOMElement.idl
3)
http://lxr.mozilla.org/mozilla/source/dom/public/idl/core/nsIDOMNode.idl#82
4)
http://lxr.mozilla.org/mozilla/source/dom/public/idl/core/nsIDOM3Document.idl#63
--BDS
This way of getting the URI is also compatible with older versions of
the browser (compared to my suggestion), but has the downside of
requiring C++. (and is inherently incompatible with other browsers
implementing the NPAPI)
Regards,
"Christian Biesinger" <cbies...@web.de> wrote in message
news:NbKdnWtf9fXTvLXZ...@mozilla.org...
(as opposed to C)
If you want the URI of the resource for which the plug-in is invoked,
the most NPAPI-friendly way to do that is to get it from the NPStream
that is passed to NPP_NewStream.
Braden
error LNK2019: unresolved external symbol _NPN_GetProperty referenced in
function "public: virtual unsigned int __stdcall
CWindowExternalImp::GetWXcom(class nsIWXcom * *)"
(?GetWXcom@CWindowExternalImp@@UAGIPAPAVnsIWXcom@@@Z)
nsUpdateCenterPeer.obj : error LNK2019: unresolved external symbol
_NPN_GetStringIdentifier referenced in function "public: virtual unsigned
int __stdcall CWindowExternalImp::GetWXcom(class nsIWXcom * *)"
(?GetWXcom@CWindowExternalImp@@UAGIPAPAVnsIWXcom@@@Z)
What *.lib file do I need to link against?
"Christian Biesinger" <cbies...@web.de> wrote in message
news:GLmdnYlFqNC...@mozilla.org...