Gaia/HackingOffline

From MozillaWiki
Jump to: navigation, search

Some deep changes to Gaia landed last week. Gaia now uses the Offline Cache mechanism and the Web Apps mechnism to load applications (see Using_Application_Cache for more details on Offline Cache and Apps/Apps_JavaScript_API for details about the Apps API).

Since every changes the team does lands on the github repository this make the task more complex for external contributors temporarily (should be fixed in the next few weeks).

As a result there is a few more steps for the moment:

In the Gaia root folder you need to run:

 make copy-manifests && make offline

This step will generate a profile/ folder in your gaia directory that should contains a webapps/ folder and a OfflineCache/ folder.

Now you have to change your B2G_HOMESCREEN env variable to point to http://homescreen.gaiamobile.org

Then starts b2g with the usual command followed by a '-P' to create a new profile that points to gaia/profile.

Use this profile and now you should have a homescreen full of apps.


All the content of the applications will be loaded via the offline cache (not from gaiamobile.org) and the platform will check if there are updates on gaiamobile.org via the offline cache manifest.

The homescreen will use the Apps API to install/uninstall/enumerate/launch apps.

So once you are here you have a working homescreen that checks for updates. For now it will check on our demo server gaiamobile.org, which is convenient if you are using something just to try but cmplicate if you want to hack yourself.

So if you want to use another server — yours! — there are a few additional steps to do but not so much:

In the Gaia root folder run:

 declare -x GAIA_DOMAIN=yourdomain.com
 make appcache-manifests && make copy-manifests && make offline

Now you have an offline cache database built for your own domain. But there are still some reference to gaiamobile.org in the preferences on the platform (will be fixed) but you can change them via a prefs.js file dropped into the profile/ folder.

The file should be called prefs.js and contains:

 // All the privileges
 pref("b2g.privileged.domains", "http://browser.localhost,
                                 http://calculator.localhost,
                                 http://contacts.localhost,
                                 http://camera.localhost,
                                 http://clock.localhost,
                                 http://crystalskull.localhost,
                                 http://cubevid.localhost,
                                 http://dialer.localhost,
                                 http://gallery.localhost,
                                 http://homescreen.localhost,
                                 http://maps.localhost,
                                 http://market.localhost,
                                 http://music.localhost,
                                 http://penguinpop.localhost,
                                 http://settings.localhost,
                                 http://sms.localhost,
                                 http://towerjelly.localhost,
                                 http://video.localhost");
 
 pref("dom.telephony.app.phone.url", "http://dialer.localhost,http://homescreen.localhost");
 
 pref("dom.mozScreenWhitelist", "http://homescreen.localhost,http://settings.localhost");
 
 pref("dom.mozBrowserFramesWhitelist", "http://homescreen.localhost,http://browser.localhost");
 
 pref("dom.sms.whitelist", "file://,http://homescreen.localhost,http://sms.localhost");
 
 pref("dom.mozContacts.whitelist", "http://dialer.localhost,http://sms.localhost");
 
 pref("dom.power.whitelist", "http://homescreen.localhost,http://settings.localhost");

Replace localhost with the name of your domain.

Restart and now you should have a working version of the homescreen that loads from the Offline Cache and check update on your own server! (make sure to have some file on your server that contains at least <html manifest="manifest.appcache"></html>, otherwise your offline cache will be evicted and the apps will be gone — will be fixed by bug 674728.

I plan to put all that in a wiki page on http://wiki.mozilla.org/Gaia soon. This is a 'bit' complicated for the moment because of the changes of last week but think are going to be simplified in the coming weeks. I will keep the wiki page up to date once it has been written.

Vivien.