Snippets code from my daily experience

September 27, 2008

Using nsIObserverService.notifyObservers subject argument from Javascript

Filed under: extension,nsIObserverService,xpcom,xul — dafi @ 9:37 am

When a XUL extension developer needs to notify a global modification (ie not strictly related to a single document window) can use the nsIObserverService service, it is easy and well documented.

The notifyObservers method does the work, it accepts three parameters

  • subject
  • topic
  • someData

topic is a string containing the “command”, someData is a string specific for topic and can be null (read more at MDC docs).

The subject argument can contain a pointer to application data, not only a simple string but a complex object.

The subject argument can be very useful to pass informations from notifier to callback function but using it from extension can be a bit complicated because it requires the presence of the wrappedJSObject property.

I never used subject‘s notifyObservers parameter, I’ve always set it to null but on my last MoreKomodo release I’ve tried to use it discovering my usage was unsuccessful without wrappedJSObject.

The correct usage requires you declare a wrappedJSObject property inside your data referring to itself 😎

var data = {
document : viewDoc,
newDocument : newDoc,
command : “rename”
};

data.wrappedJSObject = data;

then call notifyObservers passing it into first parameter (subject)

Components.classes[“@mozilla.org/observer-service;1”]
.getService(Components.interfaces.nsIObserverService)
.notifyObservers(data, “morekomodo_command”, null);

The observe callback must “unwrap” received subject to access to user defined properties

observe : function(subject, topic, data) {
switch (topic) {
case “morekomodo_command”:
var unwrapped = subject.wrappedJSObject;

var doc = unwrapped.document;
break;
}
},

Another little lesson learned 😉

Advertisements

September 26, 2008

MoreKomodo 1.4.2

Filed under: komodo — dafi @ 1:00 pm

I’ve just released MoreKomodo 1.4.2, it contains minor fixes for Komodo 4.4.x but significant modifications for better Komodo 5.x support.

The principal fixes are related to the new Komodo 5 multi window feature.

More details are available at MoreKomodo website.

September 21, 2008

Sourceforge improvements for project administrators

Filed under: sourceforge — dafi @ 4:58 pm

Sourceforge hosts all my open source projects since 2002, I’m been always satisfied of services offered to me

  • Unlimited web space
  • MySQL database support
  • SSH shell access (from command line)
  • Forum, Mailing List
  • CVS and SVN

Honestly not all is amazing, the in house written forum is very ugly and MySQL version frozen to 4.x quickly became a limitation.

This year SF has started many improvements starting from website look and feel ending to datacenter migration to Chicago.

I think now the migration is closer to the end and I want to make a review.

Intensive RSS feeds usage

Communication with hosted project administrators has been powered by RSS feeds, I don’t find it very confortable especially when I must wait replies to help requests, I prefer the old “receive email when new posts are submitted” checkbox message 😉

SF team is very reactive to community needs so they have added mailing lists, you can find more info here.

New Hosted Apps

This is a great news (read more here), SF hosts three new applications

You no more need to install them inside your own web space, they are managed directly by SF team in a dedicated, separated and secured web space, when necessary updates and critical patches are applied by SF, cool!

MySQL version

Finally MySQL has been upgraded to 5.0.x version, no other words 😛

I thought to move to tuxfamily.org because I needed MySql 5 but now I’m again SF addicted.

Sorry shell.sf.net no more accessible

Shell access from command line has been revoked.

Initially I was irritated by this decision but considering every operation is possible using SCP or rsync over SSH I can live without the SF linux box access.

New way to log in

When you want to access using SFTP/SCP/rsync you must specify username and project name separated by a comma as shown below:

USERNAME,PROJECTNAME@web.sourceforge.net

Take a look also at new server address web.sourceforge.net

Except the new connection URI you continue to use your SSH key or your login credential (username/password pair).

You can find a good project shell discussion here

Sorry, no more unlimited web space

Bad news guys, the web space size now is fixed to 100Mb, no more unlimited land my dear open source pioneer.

My wish list

I have my personal wish list, it is very short.

I want HTTPS access for web projects, no matter if not enabled by default or available only after a submission request but I would appreciate its availability very much.

SF team said me in chat HTTPS feature is not planned so I think this item will remain for a long time in the list.

The last wish is the Drupal application hosted directly on SF like phpBB, this seems possible because SF encourages new application hosting request.

Create a free website or blog at WordPress.com.