Saturday, November 17, 2007

Session 16 - XPCOM lab - retry

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)
Awesome, my first XPCOM component!!!

Friday, November 16, 2007

Python script - Automatic l10n string replacer - 0.2.3 release update

Our script now has been released in our wiki page, with some instructions and screenshots by Rueen.

In the other hand, we are trying to get more help on the bug on how to add make more regular expressions substitutions to a tree rather than just one change.

My personal feeling of this project is that I still don't see how this script would be used in the end but maybe someone will end up stepping in and bring some insightful ideas.

Another issue is that it should not be called TOOL, it is a scrip that would be run where an l10n source tree is and once run it would generate another l10n source tree with the changes made.

I hope this script could go really far, since it could be really useful once people would understand it.

Thursday, November 15, 2007

Session 15 - Building on Linux another nightmare

BREAKING NEWS (this has happen after this post):
----------------------------------------------------
This is what I tried to run minefield:

  • firefox -P development -no-remote //does not work
  • /home/armen/sandbox/mozilla/obj-i686-pc-linux-gnu/dist/bin/firefox -P development -no-remote //it did work
  • ./firefox -P development -no-remote //which works
Thanks Andrew

BEGINNING OF POST:
-------------------------

I have installed Virtual Box and I am running Ubuntu 7.something (Gutsy), which I got from the Freedom Toaster at Seneca. I also added the Guest Additions to have better video resolution and others.

This means that now I can build on my laptop but I gotta say that in Linux I am having more problems to build than on Windows. In Windows everything seems to be more straight forward.


I tried to check-out and I got this error message:

  • armen@armen-linux:/tmp/sandbox$ cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co mozilla/client.mk
    The program 'cvs' can be found in the following packages:
    * cvsnt
    * cvs
    Try: sudo apt-get install
    bash: cvs: command not found

Therefore I tried the suggestion:
  • sudo apt-get install cvs


Now, I have CVS installed, let's check-out:
I am trying to build and it seems that the are more problems:
checking for gcc... gcc
checking whether the C compiler (gcc ) works... no
configure: error: installation or configuration problem: C compiler cannot create executables.
I have tried this, since I tried to use "package" to get a package manager or something:
  • sudo apt-get install mailagent //I don't think this was necessary
The gcc version is:
  • gcc version 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)

I am checking the build requirements on developers.m.o:
  • It seems that pkg-config --version is 0.22, rather than 0.9 //doesn't apply, it must be a typo or something

I just found that the whole problem is that I need the package build-essential that depends in few others and Ubuntu would always ask me for a CD. This is the way around thanks to Ben Hearsum :D

I had to comment the line:
# deb cdrom:[Ubuntu 7.10 _Gutsy Gibbon_ - Release i386
(20071016)]/ gutsy main restricted
in the file: /etc/apt/sources.
list
REMEMBER to use SUDO(root privileges) when modifying the file and when running the update:
  • sudo apt-get update
  • sudo apt-get install build-essential

At this point, I am at home, keep on trying and now on #developers Joshua and fantasai
It seems that now these packages are missing:
  • checking gtk+-2.0 >= 1.8.0 gdk-x11-2.0 glib-2.0 gobject-2.0... Not found, bla, bla
A guy in developer told me to get this:
  • sudo apt-get install libgtk2.0-dev //but it wasn't enough
  • sudo apt-get build-dep firefox
Now, I get this:
  • checking for libcurl... no
  • sudo apt-get install libcurl3-dev
Finally it seems that is working!

Mullin says to use this next time: sudo apt-cache search
libcurl

I was able to do all of this because there were some people on IRC who knew this, not because I was able to read it from developers website!

-------------------------------


I also tried to do the lab for Thursday but I had some errors on copy and pasting and when it seemes that everything actually got made, Minefield crashed saying that I had a problem with an rdf or a manifest, I can't recall.

I have downloaded the source code again and built again, but now I have a new problem, IT ALWAYS OPEN FF2 EVEN IF I CREATE A NEW PROFILE!!!!


This wouldn't be my blog if I would be able to do something at the first try :(