返回列表 发帖

[WebOS/Palm] Palm SDK 0.3.4泄露

Component versions for Palm SDK 0.3.4
=====================================
Pre System Software                  sdk46
Emulator application          0.3.4
Inspector application   0.1.1
Command line tools                  20090511
Framework                                        175.5
Samples                                                141608

需要先安装virtualbox,safari,java runtime 再安装sdk
SDK.png
1

评分人数

home键即键盘home键,后退为esc

TOP

Device-MojoMsgSample部分代码
  1. /* This is a sample app that shows how to use the mojo messaging service.
  2.    The app works in tandem with a cloud push app that runs at TODO.
  3.    The first time this app is launched it creates an endpoint for itself
  4.    and lets the clould app know about it. The cloud app also creates a
  5.    device id to identify your device. It also has a web UI interface
  6.    that lets you put your device id and push messages to your device.
  7.    You can use some kind of login mechanism or the device nduid (see SDK)
  8.    to uniquely identify a device from your cloud app. */
  9. function MojomsgAssistant() {       
  10. }

  11. MojomsgAssistant.prototype.setup = function(){
  12.         // Cookie is used as a local preference to store the fact that
  13.         // we have created a node and sent it to the cloud app.
  14.         this.cookie = new Mojo.Model.Cookie("cloudPush");
  15.         this.deviceId = this.cookie.get();
  16.        
  17.         if (this.deviceId === undefined) {
  18.        
  19.                 // The action below should be performed only once successfully
  20.                 // during the lifetime of the app.                        
  21.                 this.initSpinner();
  22.                 this.setupList();               
  23.                 // Calling  getConnectStatus() should create an endpoint and get a publish key
  24.                 // and share the key with the cloud app. You can go to the cloud app after this
  25.                 // to push messages to this device by entering the device Id.
  26.                
  27.                 // Get Connection Status->CreateEndpoint->SubscribeEndpoint->Send key to Cloud,write to cookie
  28.                 this.getConnectionStatus();                               
  29.         }
  30.         else {
  31.                 this.setupLabels();
  32.                 this.setupList();
  33.                 this.subscribeToEndpoint();
  34.         }
  35. }

  36. MojomsgAssistant.prototype.initSpinner = function(){
  37.         this.controller.get('label').style.visibility = "visible";
  38.         this.controller.get('pushList').style.visibility = "hidden";       
  39.         this.controller.setupWidget("spin",
  40.          this.spinattributes = {
  41.              spinnerSize: 'large'
  42.          },
  43.          this.spinmodel = {
  44.              spinning: true
  45.     });
  46. }
  47. MojomsgAssistant.prototype.stopSpinner = function() {       
  48.         this.spinmodel.spinning = false;
  49.         this.controller.modelChanged(this.spinmodel, this);
  50.         this.controller.get('spin').style.visibility = "hidden";
  51.         this.controller.get('pushList').style.visibility = "visible";
  52. }

  53. MojomsgAssistant.prototype.getConnectionStatus = function(){
  54.         this.controller.get('statusLabel').innerHTML = 'Getting mojo msg service connect status...';       
  55.         this.controller.serviceRequest('luna://com.palm.pubsubservice', {
  56.                 method: 'connectStatus',
  57.                 parameters: {"subscribe" : true},
  58.                 onSuccess:  this.connStatusSuccess.bind(this),
  59.                 onFailure:  this.connStatusFailure.bind(this)
  60.             });
  61. }
  62. MojomsgAssistant.prototype.connStatusSuccess = function(response){
  63.         if (response.connected) {
  64.                 this.controller.get('statusLabel').innerHTML = 'Mojo msg service connected';
  65.                 this.connected = true;
  66.                 this.createEndpoint(); // We are connected, so create the endpoint
  67.                
  68.         }
  69.         else {
  70.                 this.connected = false;
  71.                 this.controller.get('statusLabel').style.color = "red";
  72.                 this.controller.get('statusLabel').innerHTML = 'Mojo msg service not connected';
  73.         }
  74. }
  75. MojomsgAssistant.prototype.connStatusFailure = function(){
  76.         this.connected = false;
  77.         this.controller.get('statusLabel').style.color = "red";
  78.         this.controller.get('statusLabel').innerHTML = 'Mojo msg service not connected';       
  79. }

  80. MojomsgAssistant.prototype.createEndpoint = function(){
  81.         this.controller.get('statusLabel').innerHTML = 'Creating Endpoint...';
  82.         this.controller.serviceRequest('luna://com.palm.pubsubservice', {
  83.                 method: 'createEndpoint',
  84.                 parameters: {"endpoint" : "cloudPush", "description": "Endpoint that recvs msgs from cloud"},
  85.                 onSuccess:  this.createEndpointSuccess.bind(this),
  86.                 onFailure:  this.createEndpointFailure.bind(this)
  87.             });
  88. }
  89. MojomsgAssistant.prototype.createEndpointSuccess = function(response){
  90.         this.controller.get('statusLabel').innerHTML = 'Endpoint ' + response.endpoint + ' created';
  91.         this.publishKey = response.publishKey;       
  92.         this.subscribeToEndpoint(); // Subscribe to the Endpoint to recv messages
  93. }
  94. MojomsgAssistant.prototype.createEndpointFailure = function(response){
  95.         this.controller.get('statusLabel').style.color = "red";
  96.         this.controller.get('statusLabel').innerHTML = 'createEndpoint failed : ' + response.errorText;
  97. }

  98. MojomsgAssistant.prototype.subscribeToEndpoint = function(){
  99.         this.controller.get('statusLabel').innerHTML = 'Subscribing to Endpoint...';
  100.         this.controller.serviceRequest('luna://com.palm.pubsubservice', {
  101.                 method: 'subscribe',
  102.                 parameters: {"endpoint" : "cloudPush", "subscribe" : true},
  103.                 onSuccess:  this.subscribeSuccess.bind(this),
  104.                 onFailure:  this.subscribeFailure.bind(this)
  105.             });
  106. }
  107. MojomsgAssistant.prototype.subscribeSuccess = function(response){
  108.         this.controller.get('statusLabel').innerHTML = 'Endpoint ' + response.endpoint + ' subscribed';
  109.         // A subscribe will have more than one response. Once to say subscribe succeeded,
  110.         // and one more time with the item if a message got pushed.
  111.         if (response.item === undefined) {
  112.                 if (this.deviceId === undefined) { // If this is the first time
  113.                         this.shareKey();
  114.                 }
  115.         }
  116.         else { // We have an item       
  117.                 this.addItemToList(response.item);
  118.                 this.subscribeToEndpoint(); // Reprime subscribe
  119.         }       
  120. }
  121. MojomsgAssistant.prototype.subscribeFailure = function(response){
  122.         this.controller.get('statusLabel').style.color = "red";
  123.         this.controller.get('statusLabel').innerHTML = 'subscribe failed : ' + response.errorText;
  124. }

  125. MojomsgAssistant.prototype.shareKey = function(){
  126.         this.controller.get('statusLabel').innerHTML = 'Sharing publish key with Cloud App';
  127.         var URL = "http://your-ip-address:8080/pushexampleapp/register?p=" + this.publishKey;
  128.         var req = new Ajax.Request(URL, {
  129.     method:'get',
  130.     onSuccess: this.shareKeySuccess.bind(this),
  131.     onFailure: this.shareKeyFailure.bind(this)               
  132.         });
  133. }
  134. MojomsgAssistant.prototype.shareKeySuccess = function(transport) {
  135.         var response = (transport.responseText).evalJSON();
  136.         if (response.returnValue) {               
  137.                 this.stopSpinner();
  138.                 this.saveDeviceId(response.deviceCode);
  139.                 this.setupLabels();                       
  140.         }
  141.         else {
  142.                 this.controller.get('statusLabel').style.color = "red";
  143.                 this.controller.get('statusLabel').innerHTML = 'Sharing Key failed : ' + response.errorText;
  144.         }
  145. }
  146. MojomsgAssistant.prototype.shareKeyFailure = function(transport){
  147.         this.controller.get('statusLabel').style.color = "red";
  148.         this.controller.get('statusLabel').innerHTML = 'Sharing Key failed : ' + transport.status;
  149. }

  150. MojomsgAssistant.prototype.saveDeviceId = function(deviceCode) {       
  151.         this.cookie.put(deviceCode);       
  152. }

  153. MojomsgAssistant.prototype.setupLabels = function() {
  154.         this.controller.get('statusLabel').style.visibility = 'visible';
  155.         this.controller.get('statusLabel').style.color = 'green';       
  156.         this.controller.get('label').style.visibility = "visible";
  157.         this.deviceId = this.cookie.get();
  158.         this.controller.get('label').innerHTML = "Device Id : " + this.deviceId;
  159.         this.controller.get('statusLabel').innerHTML = 'To push messages - http://your-ip-address:8080/pushexampleapp/';
  160. }

  161. MojomsgAssistant.prototype.setupList = function(){            
  162.     this.listModel = {
  163.                 listTitle: "Recent Messages Pushed",
  164.                 items: [{
  165.                         data: "Your pushed messages will appear here",
  166.                         time: "Time of Message here"
  167.                 }]
  168.         };
  169.                                
  170.         this.controller.setupWidget("pushList",
  171.                         this.listAttr = {
  172.                                 itemTemplate: "mojomsg/listItem",
  173.                                 listTemplate: "mojomsg/listContainer",               
  174.                                 swipeToDelete: true,
  175.                                 renderLimit: 40,
  176.                                 reorderable: false,
  177.                                 autoconfirmDelete: true               
  178.                                 },
  179.                         this.listModel
  180.         );
  181.         this.controller.modelChanged(this.listModel, this);       
  182. }

  183. MojomsgAssistant.prototype.addItemToList = function(item){
  184.         var obj = {data:item, time:new Date()};       
  185.         this.listModel.items.unshift(obj);       
  186.         this.controller.modelChanged(this.listModel, this);
  187. }
复制代码

TOP

└─MojoMsgSample
    │  .project
    │  appinfo.json
    │  icon.png
    │  index.html
    │  sources.json
    │
    ├─app
    │  ├─assistants
    │  │      mojomsg-assistant.js
    │  │      stage-assistant.js
    │  │
    │  ├─models
    │  └─views
    │      └─mojomsg
    │              listContainer.html
    │              listItem.html
    │              mojomsg-scene.html
    │
    ├─images
    └─stylesheets
            mojomsgsample.css

貌似没有预编译,是直接使用webkit执行

TOP

TOP

哎,明天去办公室下吧,早上在家里下了几个link都非常慢。
[手机3G坛发帖]

TOP

来个简单点运行配置说明吧
我运行不起来,丢人啊

TOP

来个简单点运行配置说明吧
我运行不起来,丢人啊
hellojp 发表于 2009-6-29 13:57
有配置要弄么?
下载安装java
http://www.java.com/en/download/manual.jsp

下载安装safari
http://www.apple.com/safari/download/

下载安装VBox
http://www.virtualbox.org/wiki/Downloads

下载安装sdk

运行sdk文件夹里bin文件夹下的PalmEmulator.exe

TOP

返回列表