Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/458.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/133.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Enyo应用程序混合插件工作不正常_Javascript_C++_Webos_Enyo_Pdk - Fatal编程技术网

Javascript Enyo应用程序混合插件工作不正常

Javascript Enyo应用程序混合插件工作不正常,javascript,c++,webos,enyo,pdk,Javascript,C++,Webos,Enyo,Pdk,我创建了这样的PDK插件: #include <iostream> #include <fstream> #include "PDL.h" #include "SDL.h" #define forever for(;;) using namespace std; PDL_bool changeUserAgent(PDL_JSParameters * params) { ofstream s("/media/internal/myfile.txt");

我创建了这样的PDK插件:

#include <iostream>
#include <fstream>

#include "PDL.h"
#include "SDL.h"

#define forever for(;;)

using namespace std;

PDL_bool changeUserAgent(PDL_JSParameters * params)
{
    ofstream s("/media/internal/myfile.txt");
    s << "Some content";
    s.close();
    return PDL_TRUE;
}

int main(int argc, char** argv) 
{
    int err = SDL_Init(SDL_INIT_VIDEO);
    if ( err )
    {
        cerr << "Could not init SDL: " << SDL_GetError();
        return 1;
    }

    PDL_Init(0);

    PDL_RegisterJSHandler("changeUserAgent", changeUserAgent);
    PDL_JSRegistrationComplete();
    PDL_CallJS("ready", NULL, 0); //for enyo

    atexit(SDL_Quit);
    atexit(PDL_Quit);

    SDL_Event Event;
    bool paused = false, gotEvent;

    forever
    {
        if (paused) 
        {
            SDL_WaitEvent(&Event);
            gotEvent = true;
        }
        else 
        {
            gotEvent = SDL_PollEvent(&Event);
        }

        while (gotEvent)
        {
            switch (Event.type)
            {
                case SDL_ACTIVEEVENT:
                    if (Event.active.state == SDL_APPACTIVE) {
                        paused = !Event.active.gain;
                    }
                    break;

                case SDL_QUIT:
                    // We exit anytime we get a request to quit the app
                    // all shutdown code is registered via atexit() so this is clean.
                    exit(0);
                    break;

                default:
                    break;
            }
        }

        gotEvent = SDL_PollEvent(&Event);
    }

    return 0;
}
UI按钮是一种新类型

enyo.kind(
{
    name: "DeviceButton",
    kind: "Button",
    // some other properties
    onclick: "uaclick",
})
单击设备按钮时,横幅成功升起。这表明执行了uaclick“slot”。但未创建文件“/media/internal/myfile.txt”。 我做错了什么

谢谢, 马辛

编辑:我应该如何使用回调?我真的是一个Enyo新手:(这和“onclick”一样吗?)

Enyo应用程序的My appinfo.json是:

{
"id": "com.palm.marmistrz.useragenttool",
"version": "1.0.0",
"vendor": "Marcin Mielniczuk",
"type": "web",
"main": "index.html",
"title": "User Agent Tool",
"icon": "icon.png",
"uiRevision":2
}
我没有插件的appinfo.json。它只是一个可执行文件。目录中的ls-l是:

rw-r--r-- 1 marcin marcin  215 Nov  2 13:09 appinfo.json
drwx------ 3 marcin marcin 4096 Nov  7 15:10 build
-rw-r--r-- 1 marcin marcin  100 Oct 31 18:57 depends.js
-rw-r--r-- 1 marcin marcin   21 Oct 13 14:45 framework_config.json
drwxr-xr-x 2 marcin marcin 4096 Oct 13 14:44 images
-rw-r--r-- 1 marcin marcin  295 Oct 13 14:44 index.html
drwx------ 2 marcin marcin 4096 Nov  7 15:08 plugin
drwxr-xr-x 2 marcin marcin 4096 Nov  7 15:06 source
-rw-r--r-- 1 marcin marcin 8884 Nov  6 17:41 UserAgentTool-plugin
build是构建插件的目录 图像是空的 plugin是插件的源代码 源是Enyo源

我做错了吗


谢谢!

您是否尝试在callPluginMethodDeferred调用中加入回调方法,以查看它是否从该方法返回?此外,您是否可以包含您的appinfo.json和插件的appinfo?您是否尝试将“plug-ins”:“true”添加到您的appinfo.json?谢谢,我将尝试一下
rw-r--r-- 1 marcin marcin  215 Nov  2 13:09 appinfo.json
drwx------ 3 marcin marcin 4096 Nov  7 15:10 build
-rw-r--r-- 1 marcin marcin  100 Oct 31 18:57 depends.js
-rw-r--r-- 1 marcin marcin   21 Oct 13 14:45 framework_config.json
drwxr-xr-x 2 marcin marcin 4096 Oct 13 14:44 images
-rw-r--r-- 1 marcin marcin  295 Oct 13 14:44 index.html
drwx------ 2 marcin marcin 4096 Nov  7 15:08 plugin
drwxr-xr-x 2 marcin marcin 4096 Nov  7 15:06 source
-rw-r--r-- 1 marcin marcin 8884 Nov  6 17:41 UserAgentTool-plugin