you know webOS
Markus Leutwyler
www.thinmachine.ch
www.twitter.com/twtomcat
tomcat@inorbit.com
do you know HTML?
do you know CSS?
do you know Javascript?
you can develop for webOS!
what is webOS?
embedded linux
http://opensource.palm.com
what is webOS?
V8
what is webOS?
WebKit
how to write apps for webOS?
SDK: HTML
- HTML, CSS, Javascript
- HTML5 Standard (Canvas,CSS3,Storage,...)
- Mojo and Prototype Framework
| |
|
PDK: Plugin Development Kit
- C/C++
- Posix, OpenGL ES, SDL, PDL
- Fullscreen or Hybrid
- Games: Angry Birds (iPhone Port)
- Tools: wIRC (Hybrid)
Linux Tools
| ipkg | gzip |
| awk | grep |
| strace | gdb |
| oprofile | vmstat |
| iostat | top |
back to programming please?
App Anatomy: Stages & Scenes
Stage
- The base of your application
- Analogy: Browser Tab
App Anatomy: Stages & Scenes
Scene
- Scenes are pushed onto the stage
- can have many but must have one
- contains ui widgets
- scene assistant contains javascript
- Analogy: pages on a website
|
|
Mojo Framework
- GUI Widgets
- Javascript APIs
- follows the MVC-Pattern
- View: HTML
- Model/Controller: Javascript
|
|
HTML Example
<div id="text-field" x-mojo-element="TextField"></div>
Javascript Example
var attributes= { focusMode: Mojo.Widget.focusSelectMode, maxLength: 30 };
this.model = {
original: 'Please enter something',
disabled: false };
this.controller.setupWidget("text-field",attributes,this.model);
Service API
- Asynchronous dbus communication
- JSON Data
- Subscription
- Java/C Services
- node.js Services
Service API
- Hardware
- Accelerometer,GPS,Screen,Camera
- Application Services
- Alarms,Contacts,Calendar,Pictures,Up/Download
- Application Actions
- E-Mail,Maps,Phone,Browser
Example
this.controller.serviceRequest('palm://com.palm.connectionmanager',
{ method: 'getstatus',
parameters: { subscribe:true},
onSuccess: this.handleOKResponse,
onFailure: this.handleErrResponse
});
how to develop for webOS?
- Pick your favourite editor
how to develop for webOS?
- command-line SDK-Tools
- Plugins for Eclipse,Komodo Edit,TextMate
- Pick your OS: OS X, Linux, Windows
webOS Emulator
- Based on VirtualBox
- running a x86 Version of webOS
- does not support all hardware
- missing hardware can be emulated
Jailbreak, Rooting?
Enable Developer Mode
webos20090606
Jailbreak, Rooting?
- novacom -t open tty://
- root@palm-webos-device
- ssh localhost -p 5522 -l root
- luna-send -n 1 palm://com.palm.pmradiosimulator/set_incomingcall
Palm Ares
- WYSIWYG Programming for webOS in your Browser
- Ares Log Viewer
- Ares V8 Debugger
Palm Ares
your first app
palm-generate helloWorld
appinfo.json
{
"id": "com.yourdomain.helloworld",
"version": "1.0.0",
"vendor": "My Company",
"type": "web",
"main": "index.html",
"title": "helloWorld",
"icon": "icon.png"
}
index.html
<!DOCTYPE html>
<html>
<head>
<title>Hello World</title>
<script src = "/usr/palm/frameworks/mojo/mojo.js"
x-mojo-version="1"></script>
<link href="/stylesheets/helloworld.css" media="screen" rel="stylesheet" type="text/css">
</head>
</html>
Package & Install
palm-package helloWorld
palm-install com.yourdomain.helloworld_1.0.0_all.ipk
Add a Scene
palm-generate -t new_scene -p "name=first" helloWorld
HTML
app/views/first-scene.html
<div id="main" class="palm-hasheader">
<div class="palm-header">First Scene</div>
<div class="palm-text">Welcome to my World</div>
<div x-mojo-element="Button" id="button1"></div>
<div>
Javascript
Pushing the first scene
StageAssistant.prototype.setup = function() {
/* this function is for setup tasks that have to happen when the stage is first created */
Mojo.Controller.stageController.pushScene("first");
};
Setting up the first scene
app/assistants/first-assistant.js
this.controller.setupWidget("button1",
this.attributes = {},
this.model = {
label : "OK",
disabled: false
}
);
Adding handlers
this.handleButton1=this.handleButtonPress1.bindAsEventListener(this);
Mojo.Event.listen(this.controller.get("button1"), Mojo.Event.tap, this.handleButton1);
FirstAssistant.prototype.handleButtonPress1 = function(event){
Mojo.Controller.stageController.pushScene("second");
}
helloWorld
App Catalog
- Comes preinstalled on every device
- Not international yet (US/CA/MX/DE/UK/IR/FR)
- 70/30 Revenue Split
- Developer Account: free
- App Submit Fee: none
- Web- and Beta Feed (no review)
Ressources
- developer.palm.com
- 5 part tutorial at mobile.tutsplus.com
- IRC: #webos
- webos-internals.org
- me :)
Questions?