Search code examples
cordovacordova-pluginsfirefox-os

Developing Cordova plugins for Firefox OS


How does one go about creating cordova plugins on Firefox OS?

I've got a cordova plugin that I've written for iOS and Android that I'd like to add firefox OS support to. Specifically, it enumerates the fonts that have been installed on the mobile device (my use case is a mostly-offline editor / translation tool).

It looks like firefox OS uses the Android Open Source Project at a lower layer of its OS called Gonk. But, it also looks like Gronk is buried a couple layers deeper than the applications live. Is this where I need to be writing the plugin code? It doesn't seem like code written there would be exposed through the gecko / gaia layers, and unfortunately the Cordova plugin developer's guide doesn't have any info on where to begin.


Solution

  • Okay, it looks like this is a two-part answer:

    1. For the general question of "how does one create a cordova plugin for firefox os?" the answer is "in javascript." If you go poking around in the source code for Cordova's own plugins, drilling down into the src/firefoxos directories, you'll note that each of the plugins that do implement the functionality on firefox os do so with javascript. This kind of brings up the point that EdoPut and zalun make -- Cordova plugins don't drill down and expose anything that isn't already exposed via javascript, and conversely anything that isn't exposed to javascript is unavailable to client apps. This is the glory and pain of firefox os.
    2. For my specific case of "I want to dynamically retrieve the fonts installed on the device" the answer is you can't. There isn't a direct way to do this with the current API, and as this google group topic adds, returning a static list isn't guaranteed to be correct between versions or vendors.

    There is kind of a hack-y way to dynamically get fonts based on whether a browser is doing font substitution here: http://www.lalit.org/lab/javascript-css-font-detect/. I had tried this earlier and it did work on firefox, but not on webkit/chrome -- hence my desire to make this plugin for iOS/Android in the first place. I might end up using this method for the firefoxos port of my plugin.