here is my question... is it possible to access xpcom components from
an external app?
Let me explain better. I would like to use xpcom components into a
cppunit test application, I tried to compile it dynamically specifying
the dynamic libraries (libxpcom.dylib, libxpcom_core.dylib, etc...)
location at runtime. For example I tried to get a Service like this:
nsCOMPtr<nsIRDFService> rdfService;
nsCOMPtr<nsIRDFResource> resource;
nsCOMPtr<nsIServiceManager> servMan;
NS_GetServiceManager(getter_AddRefs(servMan));
servMan->GetServiceByContractID("@mozilla.org/rdf/rdf-service;1",
NS_GET_IID(nsIRDFService),
getter_AddRefs(rdfService));
but at the end rdfservice is null !!
is it possible to make it work?
Thanks
Carlo
Absolutely. This process is known as embedding Mozilla. Another
alternative is to build the app *on* *top* of Mozilla, then it is called
XULRunner application or xul app.
> Let me explain better. I would like to use xpcom components into a
> cppunit test application, I tried to compile it dynamically specifying
> the dynamic libraries (libxpcom.dylib, libxpcom_core.dylib, etc...)
> location at runtime. For example I tried to get a Service like this:
>
> nsCOMPtr<nsIRDFService> rdfService;
> nsCOMPtr<nsIRDFResource> resource;
>
> nsCOMPtr<nsIServiceManager> servMan;
> NS_GetServiceManager(getter_AddRefs(servMan));
>
> servMan->GetServiceByContractID("@mozilla.org/rdf/rdf-service;1",
> NS_GET_IID(nsIRDFService),
> getter_AddRefs(rdfService));
>
> but at the end rdfservice is null !!
> is it possible to make it work?
I've little to no experience with embedding (unlike xul apps), but at
least this code should have initialized XPCOM. This may be tricky, but
there were some examples of minimum embedding applications posted to
m.d.t.embedding.
As a side note, I tried to use libcppunit in my xul app around 2 years
ago with little success. So I've created my own jUnit-style framework
for XPCOM. You may see the source code at [1].
Mozilla also has fairly advanced automated test framework, which is
described at [2].
1. http://repo.or.cz/w/abstract.git?a=tree;f=xpunit
2. http://developer.mozilla.org/en/docs/Mozilla_automated_testing
--
Sergey Yanovich
I don't want to embed a Mozilla application, I want to access to the
installed Thunderbird XPCOM Components from an external application
(cppunit application)... I developed a XPCOM component which manages
address book and calendar items, and I want to test it from the
cppunit app. Is this possible?
Thanks for your help
Carlo
To use XPCOM components you'll to initialize XPCOM framework. Generally
speaking, you have 3 options here:
1. from an extension to an existing application;
2. from a new XULRunner application;
3. from a new embedding application. That's the name of what you
described you want to achieve (use XPCOM component in a non-XULRunner
based application).
> Is this possible?
>> As a side note, I tried to use libcppunit in my xul app around 2 years
>> ago with little success. So I've created my own jUnit-style framework
>> for XPCOM. You may see the source code at [1].
>>
>> Mozilla also has fairly advanced automated test framework, which is
>> described at [2].
>>
>> 1.http://repo.or.cz/w/abstract.git?a=tree;f=xpunit
>> 2.http://developer.mozilla.org/en/docs/Mozilla_automated_testing
As I said, having libcppunit to work correctly with XPCOM may be a hard
task. From my experience, you may have much better luck if you start
with a xul app from the beginning, and use Mozilla-based test framework.
--
Sergey Yanovich