andreasgal/gaia — pull request #899 by davidflanagan (2012-03-22 05:55:44+00:00)
Title: use mozApps API in homescreen/js/app_manager.js

This pull request changes the homescreen to use the mozApps api to obtain the list of installed apps. This is a critical step toward having real installable apps. It does not work, however, unless you have a relatively recent version of B2G. So if you haven't flashed or rebuilt b2g this week, you may need to do that. Also, it pretty much breaks any version of Gaia running in Firefox. And it breaks desktop b2g until you take a few one-time steps described below.

This change does not handle app installation yet, however, so the app manifests and an webapps.json file must be copied into the B2G profile directory in order for the API to work. For the phone, the Makefile has been modified so that make install-gaia copies the necessary files to the profile directory.

For desktop b2g, things are slightly more complicated, and there is some one-time setup you must do your development environment. First, create the profile/webapps directory. This used to be part of the gaia repo, but this patch removes it. You need to create your own directories. The master copies of the app manifests are stored in the app directories, and they'll be copied here as needed:

cd $GAIA
mkdir profile
mkdir profile/webapps

Next, copy the manifests plus apps/webapps.api to those new directories:

make copy-manifests

This is a new target in the makefile. It is run automatically when you do make install-gaia, but you have to do it manually for desktop b2g if you edit a manifest file or add a new app.

Finally, for the desktop, you must create a symbolic link from the b2g profile directory to this profile/webapps directory. Use a command like this:

ln -s $GAIA/profile/webapps $B2G_PROFILE_DIR/webapps

$GAIA is your gaia/ directory, and $B2G_PROFILE_DIR is the profile dir. On MacOS it is something like
~/Library/Application\ Support/B2G/Profiles/*.default/

After this pull request lands, each app's manifest file is manifest.json and it is stored in the top-level of the app directory. Note that this is similar to, but not the same as the manifest.webapp file that would be served from a webserver. This is the processed version of the webapp manifest that gecko stores in the profile. The API also requires a master list of installed apps. That is the webapps.json file. It lives in gaia/apps/, and is copied to the profile dir as needed. So, to add a new app to the homescreen, add it to webapps.json, and create a manifest.json file in the app dir.

Questions to @fabricedesre or @davidflanagan