PhoneGap webos 3.0+

发布于 2024-12-29 21:59:54 字数 2692 浏览 1 评论 0原文

我有一个phonegap iOS 应用程序,我将其移植到触摸板上的webos,该应用程序运行良好,除了我使用的一个iOS 插件。它基本上将画布数据保存到照片卷中。根据我对 webos 的理解,我需要创建一个 node.js 服务并将数据写入缓冲区,最后写入文件系统,论坛中有一个示例。但是我不知道如何从我的phonegap应用程序中调用所有这些。我相信我的 index.html 文件中需要包含以下内容。

    <script src="/opt/PalmSDK/Current/share/framework/enyo/1.0/framework/enyo.js" type="text/javascript"></script>

and something like
    enyo.create({kind: "Main"}).renderInto(document.body);    

我猜我还必须将所有“种类”数据保存在 js 文件中。但是我如何从我的应用程序的 js 文件中执行一小步来与创建的服务进行通信。我查看了phonegap 1.0.js 文件,发现他们以这种方式调用服务。

            this.service = navigator.service.Request('palm://com.palm.applicationManager', {
    method: 'launch',
    parameters: {
    id: 'com.palm.app.camera',
    params: {
            appId: 'com.palm.app.camera',
            name: 'capture',
            sublaunch: true,
            filename: filename
        }
    },
    onSuccess: successCallback,
    onFailure: errorCallback
}); 

但我也注意到,这似乎都是魔力,而我正在做的就是 enyo,所以是的,我现在很困惑......

似乎在 webos 中调用服务应该很容易,比如说这里是一串图像数据并将其从我现有的phonegap应用程序写入文件系统。而不必在 enyo 中做所有事情。有人有这样的 webos 插件的样本吗?或者知道在哪里指点我?

谢谢蒂姆

**更新

我现在已经创建了一个节点服务,如下定义,我认为它有效,我正在尝试调用该服务,但它没有到达它。测试应用程序在我的触摸板上运行,但是当我按下按钮保存图像时,我无法进入该服务。我尝试跟踪在phonegap0.0.1.js 文件中对相机所做的操作,这是我的服务的副本,我如何定义它以及如何调用它。任何想法我做错了什么。

services.json =

"id": "com.tim.pgmojo1.service",
"description": "FileIO Service",
"services": [
  {
"name": "com.tim.pgmojo1.service",
"description": "FileIO Service",
"commands": [
    {
      "name": "writefile",
      "assistant": "WriteFileAssistant",
      "public": true
    }]
  }]
}

** 服务代码
var 库 = MojoLoader.require({ name: "foundations", version: "1.0" }); var fs = IMPORTS.require("fs"); var sys = require('sys');

var WriteFileAssistant = function() {}

WriteFileAssistant.prototype.run = function(future) {
 var mypath = this.controller.args.thepath;
 var mydata = this.controller.args.thedata;
 console.log("in write file");
 console.log("path=" + thepath);
 console.log("image data=" + thedata);

 var data = content.replace(/^data:image\/\w+;base64,/, "");
 var buf = new Buffer(data, 'base64');
 fs.writeFile('/media/internal/downloads/timimage.png', buf);
}

我对服务的调用**

this.service = navigator.service.Request('palm://com.tim.pgmojo.service', { 方法:'写入文件', 参数:{

            thepath: '/media/internal/downloads/timimage.png',
            thedata: canvasData
    },
    onSuccess: mySuccess,
    onFailure: myFailure
}); 

目前我在我的index.html文件中有这个,因为它仅用于测试..

I have a phonegap iOS app that i ported to webos on the touchpad the app works great except for the one iOS plugin that i used. it basically saved the canvas data to the photo roll. From my understanding of webos i will need to create a node.js service and write the data to a buffer and finally to the file system, there is an example for that in the forums. however what i can not figure out is how to call all of this from my phonegap app. I believe i will need to have the following in my index.html file.

    <script src="/opt/PalmSDK/Current/share/framework/enyo/1.0/framework/enyo.js" type="text/javascript"></script>

and something like
    enyo.create({kind: "Main"}).renderInto(document.body);    

my guess i will also have to have all of the "kind" data in a js file. but how do i do the little step from my app's js file to communicate with the service that is created. I looked in the phonegap 1.0.js file and see that they are calling services this way.

            this.service = navigator.service.Request('palm://com.palm.applicationManager', {
    method: 'launch',
    parameters: {
    id: 'com.palm.app.camera',
    params: {
            appId: 'com.palm.app.camera',
            name: 'capture',
            sublaunch: true,
            filename: filename
        }
    },
    onSuccess: successCallback,
    onFailure: errorCallback
}); 

but i also noticed it appears that it is all mojo and what i am doing is enyo, so yes i am pretty confused the moment...

seems it should be easy to call a service in webos, say here is a string of image data and write it to the file system from my existing phonegap app. and not have to do everything in enyo. anyone have a sample of a webos plugin like this or know where to point me?

thanks tim

**Update

I have created a node service now as defined below, i think that works and i am trying to make the call to the service, but it does not get to it. the test app runs on my touchpad, but when i push the button to save the image i do not get into the service. I tried to follow what was done for the camera in the phonegap0.0.1.js file this is a copy of my service, how i defined it and how i am calling it. any ideas what i am doing wrong.

services.json =

"id": "com.tim.pgmojo1.service",
"description": "FileIO Service",
"services": [
  {
"name": "com.tim.pgmojo1.service",
"description": "FileIO Service",
"commands": [
    {
      "name": "writefile",
      "assistant": "WriteFileAssistant",
      "public": true
    }]
  }]
}

** service code
var libraries = MojoLoader.require({ name: "foundations", version: "1.0" });
var fs = IMPORTS.require("fs");
var sys = require('sys');

var WriteFileAssistant = function() {}

WriteFileAssistant.prototype.run = function(future) {
 var mypath = this.controller.args.thepath;
 var mydata = this.controller.args.thedata;
 console.log("in write file");
 console.log("path=" + thepath);
 console.log("image data=" + thedata);

 var data = content.replace(/^data:image\/\w+;base64,/, "");
 var buf = new Buffer(data, 'base64');
 fs.writeFile('/media/internal/downloads/timimage.png', buf);
}

my call to the service**

this.service = navigator.service.Request('palm://com.tim.pgmojo.service', {
method: 'writefile',
parameters: {

            thepath: '/media/internal/downloads/timimage.png',
            thedata: canvasData
    },
    onSuccess: mySuccess,
    onFailure: myFailure
}); 

currently i have this in my index.html file since it is only for testing..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无名指的心愿 2025-01-05 21:59:54

Mojo 仍然包含在触摸板上。您可以使用与 PhoneGap 相同的服务调用功能。

Mojo is still included on the TouchPad. You can use the same service-calling functions as PhoneGap is doing.

陈独秀 2025-01-05 21:59:54

在 Enyo 中,对设备上服务的访问由 enyo.PalmService 类型处理。您可以在查看包含node.js服务的应用程序示例以及如何调用该服务。 https://github.com/palm/txjs-fortunecookie

In Enyo, access to on-device services is handled by the enyo.PalmService kind. You can see an example of an app that has a node.js service included and how calls are made to this service at https://github.com/palm/txjs-fortunecookie

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文