Olivier Danes wrote:
Hi all,
I try to embed Gecko into an app in order to access to the DOM tree. I
take the Gecko 1.8 SDK for linux from
http://developer.mozilla.org/en/docs/Gecko_SDK.
I call NS_InitEmbedding() but it fails and returns the code
NS_ERROR_NOT_INITIALIZED.
Here is my compilation procedure :
$> g++ -Wall -Wno-non-virtual-dtor -fno-rtti -fno-exceptions
-IPATH_TO_GECKO_SDK/include gecko.cc
-LPATH_TO_GECKO_SDK/lib -lembed_base_s -lxpcomglue -ldl -o gecko
how I start my test :
$> ./gecko
apitest running...
NS_InitEmbedding FAILED (rv = 0xc1f30001)
NS_TermEmbedding FAILED (rv = 0xc1f30001)
apitest complete
I may also the specify a path as a first arg for NS_InitEmbedding() and
give PATH_TO_GECKO_SDK/lib, but I've got the same result...
what is missing ? what I do wrong ?
Thx. Olivier.
Here is my code:
#include <stdio.h>
#include <xpcom-config.h>
#include <nsEmbedAPI.h>
#include <nsEmbedString.h>
#include <nsCOMPtr.h>
int main(int argc, char *argv[]) {
char *pszBinDirPath = nsnull;
nsresult rv;
if (argc > 1) {
pszBinDirPath = argv[1];
}
printf("apitest running...\n");
nsCOMPtr<nsILocalFile> binDir=nsnull;
if( pszBinDirPath )
NS_NewLocalFile(nsEmbedString((const PRUnichar*)pszBinDirPath),
PR_TRUE, getter_AddRefs(binDir));
rv = NS_InitEmbedding(binDir, nsnull);
if (NS_FAILED(rv)) {
printf("NS_InitEmbedding FAILED (rv = 0x%08x)\n", rv);
// DROP THROUGH - NS_TermEmbedding should cope
}
else {
printf("NS_InitEmbedding SUCCEEDED (rv = 0x%08x)\n", rv);
}
rv = NS_TermEmbedding();
if (NS_FAILED(rv)) {
printf("NS_TermEmbedding FAILED (rv = 0x%08x)\n", rv);
// DROP THROUGH
}
else {
printf("NS_TermEmbedding SUCCEEDED (rv = 0x%08x)\n", rv);
}
printf("apitest complete\n");
return 0;
}
Olivier,
I'm no where an expert on this, but I'll try to help.
I don't know too much about the SDK you mentioned, but are you trying to
make a plugin/addon to an existing Mozilla/Firefox product or are you
trying to create your own embedded app? From the docs I read there on
the SDK, it looks like its only for use with an existing product. If
you are trying to embed Gecko into your own app, I believe you will need
to something different. I've created an embedded app myself, and it
works quite well, but what I had to do is download the actual source
code for Firefox and compile it. It creates a /bin directory which is
what you pass NS_InitEmbedding (). It has all the dlls needed to embed
your application. This is the only way I know how to embed Gecko into
your application. I hope this helps, good luck!
Nik Williams
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding