I am on Linux an using Gedit to create the files for the XPCOM lab:
NOTE: Substitute $(objdir) for the path to your build directory
- mozila/extensions/firstxpcom/public/IFirstXpcom.idl
- Generate uuid through firebot for the .idl file -> 9de38b2d-6d9e-4350-
bc8a-b5330de0accf - mozilla/extensions/firstxpcom/Makefile.in
- mozilla/extensions/firstxpcom/public/Makefile.in
- mozilla/extensions/firstxpcom/src/Makefile.in
- mozilla/extensions/firstxpcom/install.rdf
- Add ac_add_options --enable-extensions=default,firstxpcom to .mozconfig
- $ cd $(objdir)
$ ../build/autoconf/make-makefile extensions/firstxpcom //to do an incremental build and create the objects in the objdir - $ cd $(objdir)/extensions/firstxpcom
$ make - This will create the public and src directories on the obj-dir, as well as generate the Makefiles necessary in each
- $ cd $(objdir)/extensions/firstxpcom/public
$ make - As a result of this first (partially) successful run of make, exported and generated header files (i.e.,from our IDL) will be placed in $(objdir)/dist/include/firstxpcom
- Within $(objdir)/dist/include/firstxpcom/IFirstXpcom.h you'll see the following block of code:
#if 0
/* Use the code below as a template for the implementation class for this interface. */
...
/* End of implementation class template. */
#endif - Copy and paste this implementation stub into the following file: mozilla/extensions/firstxpcom/src/FirstXpcom.cpp
- We also have to add the Module Code (read more ) at the bottom of the CPP file and #include "nsIGenericFactory.h" and in that code we will use these macros:
- NS_GENERIC_FACTORY_CONSTRUCTOR(FirstXpcom)
- NS_IMPL_NSGETMODULE(FirstXpcomModule, components)
- $ cd $(objdir)/extensions/firstxpcom
$ make - I had to change this statment for the next one:
mName.Assign(L"FirstXpcom Component");
mName.AssignLiteral("FirstXpcom Component");
because I was getting this errors:../../../../extensions/firstxpcom/src/FirstXpcom.cpp: In constructor ‘FirstXpcom::FirstXpcom()’:
../../../../extensions/firstxpcom/src/FirstXpcom.cpp:28: error: no matching function for call to ‘nsString_external::Assign(const wchar_t [21])’
../../../dist/include/xpcom/nsStringAPI.h:124: note: candidates are: void nsAString::Assign(const nsAString&)
../../../dist/include/xpcom/nsStringAPI.h:128: note: void nsAString::Assign(const PRUnichar*, PRUint32)
../../../dist/include/xpcom/nsStringAPI.h:132: note: void nsAString::Assign(PRUnichar)
make[2]: *** [FirstXpcom.o] Error 1
- Assuming this works without errors, here's what has happened:
* Generated makefiles for your project were created in extensions/firstxpcom/ (remember, we're under /mozilla/$(MOZ_OBJDIR)/.
* Exported header files and generated header files (from IDL) in dist/include/firstxpcom/
* Static libraries for your modules in dist/lib/ (in case other modules want to link statically instead of using XPCOM).
* XPI file in dist/xpi-stage/firstxpcom.xpi.
* Everything else in dist/bin/extensions/firstxpcom@senecac.on.ca
- I try to run the Firefox and see if it gets loaded and visible in the Addon Manager but I get this message:
"Malformed File: Minefield could not install this item because "insall.rdf" (provided by the item) is not well-formed or does not exist. Please contact the author about this problem" - Ben Hearsum told me to try this: XML.com: RUWF? The XML syntax checker
and the message I got was this:xml declaration
not at start of external entity at line 1, column 1, byte 1:
1.0" encoding="UTF-8"?>
^
- I have been able to make, it seems to load BUT I can't see "FirstXpcom" as one of the extensions or add-ons
- Anyway, let's continue and let's install the Extension Developer's Extension but it does not work on FF3, I have read in Rueen's blog post this:
Problem: Can’t get the Extension Developer’s Extension to install on Firefox 3 due to extension security reasons.
Answer: Install it in Firefox 2. Open Firefox 3. Type: about:config in the URL bar above. Right click on any Row and choose “new” then “boolean”. Now for name type: “extensions.checkUpdateSecurity” then click Ok. For value type: “false” and click Ok. Finally go to extension’s page and try to install it again. (Thanks Cesar) - You can skip to add to FF2, just add extensions.checkUpdateSecurity as false
- After trying the rest of the lab I saw that I had to get the firstxpcom to be in the addons manager
- After a while I realized that inside $(objdir)/dist/bin/extensions I had two folders I recognized "firstxpcom@senecac.on.ca" and "azambran@learn.senecac.on.ca", hehe, I know I have done something wrong
- I went to the install.rdf and changed my email address to "firstxpcom@senecac.on.ca" since on the cpp I registered the component with "@senecac.on.ca/firstxpcom;1"
- I delete both folders in the $(objdir)/dist/bin/extensions and $(objdir)/extensions/firstxpcom
- $ cd $(objdir)
$ ../build/autoconf/make-makefile extensions/firstxpcom - $ cd $(objdir)/extensions/firstxpcom
$ make - run minefield and there we go! the firstpcom shows as one of the addons
- Let's test the Java Script shell, Tools > Extension Developer > Javascript Shell
-
const cid = "@senecac.on.ca/firstxpcom;1"
var obj = Components.classes[cid].createInstance()
obj = obj.QueryInterface(Components.interfaces.IFirstXpcom) //We are QI it to IFirstXpcom...
var sum
sum = obj.add(4,5)
obj.name = name
print(obj.name)
alert(obj.name)
No comments:
Post a Comment