@webos-tools/cli 3.1.2 → 3.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,51 +1,56 @@
1
- {
2
- "webapp": {
3
- "type": "webapp",
4
- "path": "$cli-root/files/templates/apollo-sdk-templates/bootplate-web",
5
- "description": "web app for Apollo",
6
- "metadata": {
7
- "id": "webappinfo"
8
- },
9
- "deps": [
10
- "icon"
11
- ],
12
- "default": true
13
- },
14
- "hosted_webapp": {
15
- "type": "webapp",
16
- "path": "$cli-root/files/templates/apollo-sdk-templates/hosted-webapp",
17
- "description": "hosted web app for Apollo",
18
- "metadata": {
19
- "id": "webappinfo"
20
- },
21
- "deps": [
22
- "icon"
23
- ]
24
- },
25
- "webappinfo": {
26
- "type": "webappinfo",
27
- "path": "$cli-root/files/templates/apollo-sdk-templates/appinfo/appinfo.json",
28
- "description": "appinfo.json for web app"
29
- },
30
- "js_service": {
31
- "type": "jsservice",
32
- "path": "$cli-root/files/templates/apollo-sdk-templates/js-service",
33
- "description": "js service for Apollo",
34
- "metadata": {
35
- "id": "jsserviceinfo"
36
- }
37
- },
38
- "jsserviceinfo": {
39
- "type": "jsserviceinfo",
40
- "path": [
41
- "$cli-root/files/templates/apollo-sdk-templates/serviceinfo/services.json",
42
- "$cli-root/files/templates/apollo-sdk-templates/serviceinfo/package.json"
43
- ],
44
- "description": "services.json, package.json for JS service"
45
- },
46
- "icon": {
47
- "type": "icon",
48
- "path": "$cli-root/files/templates/apollo-sdk-templates/icon",
49
- "description": "app icon files [80x80]"
50
- }
1
+ {
2
+ "webapp": {
3
+ "type": "webapp",
4
+ "path": "$cli-root/files/templates/apollo-sdk-templates/bootplate-web",
5
+ "description": "web app for Apollo",
6
+ "metadata": {
7
+ "id": "webappinfo"
8
+ },
9
+ "deps": [
10
+ "icon"
11
+ ],
12
+ "default": true
13
+ },
14
+ "hosted_webapp": {
15
+ "type": "webapp",
16
+ "path": "$cli-root/files/templates/apollo-sdk-templates/hosted-webapp",
17
+ "description": "hosted web app for Apollo",
18
+ "metadata": {
19
+ "id": "webappinfo"
20
+ },
21
+ "deps": [
22
+ "icon"
23
+ ]
24
+ },
25
+ "webappinfo": {
26
+ "type": "webappinfo",
27
+ "path": "$cli-root/files/templates/apollo-sdk-templates/appinfo/appinfo.json",
28
+ "description": "appinfo.json for web app"
29
+ },
30
+ "js_service": {
31
+ "type": "jsservice",
32
+ "path": "$cli-root/files/templates/apollo-sdk-templates/js-service",
33
+ "description": "js service for Apollo",
34
+ "metadata": {
35
+ "id": "jsserviceinfo"
36
+ }
37
+ },
38
+ "jsserviceinfo": {
39
+ "type": "jsserviceinfo",
40
+ "path": [
41
+ "$cli-root/files/templates/apollo-sdk-templates/serviceinfo/services.json",
42
+ "$cli-root/files/templates/apollo-sdk-templates/serviceinfo/package.json"
43
+ ],
44
+ "description": "services.json, package.json for JS service"
45
+ },
46
+ "native_service": {
47
+ "type": "nativeservice",
48
+ "path": "$cli-root/files/templates/apollo-sdk-templates/native-service",
49
+ "description": "native service for Apollo"
50
+ },
51
+ "icon": {
52
+ "type": "icon",
53
+ "path": "$cli-root/files/templates/apollo-sdk-templates/icon",
54
+ "description": "app icon files [80x80]"
55
+ }
51
56
  }
@@ -0,0 +1,72 @@
1
+ # Copyright (c) 2020-2024 LG Electronics, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ #
15
+ # SPDX-License-Identifier: Apache-2.0
16
+
17
+ cmake_minimum_required(VERSION 2.8.7)
18
+ project(nativeService C)
19
+
20
+ # set link directory
21
+ #link_directories(${CMAKE_SOURCE_DIR}/pkg_$ENV{ARCH}/lib)
22
+
23
+ # ---
24
+ # add include files
25
+ include_directories(${CMAKE_SOURCE_DIR})
26
+ include_directories(${CMAKE_SOURCE_DIR}/src)
27
+ include_directories(${CMAKE_SOURCE_DIR}/include)
28
+
29
+ # ---
30
+ # find required packages
31
+ include(FindPkgConfig)
32
+
33
+ pkg_check_modules(GTHREAD2 REQUIRED gthread-2.0)
34
+ include_directories(${GTHREAD2_INCLUDE_DIRS})
35
+
36
+ pkg_check_modules(PBNJSON REQUIRED pbnjson_c)
37
+ include_directories(${PBNJSON_INCLUDE_DIRS})
38
+
39
+ # -- check for glib 2.0
40
+ pkg_check_modules(GLIB2 REQUIRED glib-2.0)
41
+ include_directories(${GLIB2_INCLUDE_DIRS})
42
+
43
+ pkg_check_modules(LS2 REQUIRED luna-service2)
44
+ include_directories(${LS2_INCLUDE_DIRS})
45
+
46
+ pkg_check_modules(PMLOG REQUIRED PmLogLib)
47
+ include_directories(${PMLOG_INCLUDE_DIRS})
48
+
49
+ # ---
50
+ # create executable file
51
+ set(BIN_NAME echo_service)
52
+
53
+ set(SRC_LIST
54
+ ${CMAKE_SOURCE_DIR}/src/main.c
55
+ )
56
+
57
+ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/pkg_$ENV{OECORE_TARGET_ARCH}/")
58
+ add_executable(${BIN_NAME} ${SRC_LIST})
59
+
60
+ # ignore shared library
61
+ set(CMAKE_EXE_LINKER_FLAGS "-Wl,--allow-shlib-undefined")
62
+ set_target_properties(${BIN_NAME} PROPERTIES LINKER_LANGUAGE C)
63
+
64
+ target_link_libraries (${BIN_NAME}
65
+ ${GTHREAD2_LDFLAGS}
66
+ ${PBNJSON_LDFLAGS}
67
+ ${LS2_LDFLAGS}
68
+ ${GLIB2_LDFLAGS}
69
+ ${PMLOG_LDFLAGS}
70
+ )
71
+
72
+ file(COPY ${CMAKE_SOURCE_DIR}/services.json DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
@@ -0,0 +1,11 @@
1
+ {
2
+ "id": "com.domain.app.service",
3
+ "description": "Native echo service",
4
+ "engine": "native",
5
+ "executable": "echo_service",
6
+ "services": [ {
7
+ "name": "com.domain.app.service",
8
+ "description": "Native echo service"
9
+ }]
10
+ }
11
+
@@ -0,0 +1,144 @@
1
+ // Copyright (c) 2020-2024 LG Electronics, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ //
15
+ // SPDX-License-Identifier: Apache-2.0
16
+
17
+ #include <stdlib.h>
18
+ #include <string.h>
19
+ #include <glib.h>
20
+ #include <stdio.h>
21
+ #include <glib-object.h>
22
+ #include <luna-service2/lunaservice.h>
23
+ #include <pbnjson.h>
24
+
25
+ // This service name
26
+ #define SERVICE_NAME "SERVICE_ID"
27
+ #define BUF_SIZE 64
28
+
29
+ // Main loop for aliving background service
30
+ GMainLoop *gmainLoop;
31
+
32
+ LSHandle *sh = NULL;
33
+ LSMessage *message;
34
+
35
+ // Declare of each method
36
+ // All method format must be : bool function(LSHandle*, LSMessage*, void*)
37
+ bool echo(LSHandle *sh, LSMessage *message, void *data);
38
+
39
+ LSMethod sampleMethods[] = {
40
+ {"echo", echo}, // luna://SERVICE_ID/echo
41
+ };
42
+
43
+
44
+ /*
45
+ * Define luna://SERVICE_ID/echo
46
+ * - A method that always returns the same value
47
+ *
48
+ * +----------------------------+ +--------------------------------+
49
+ * | APP_ID | | SERVICE_ID |
50
+ * | Foreground Application | | Background Service |
51
+ * +----------------------------+ +--------------------------------+
52
+ * | |
53
+ * | |
54
+ * | 1. Request to luna://SERVICE_ID/echo |
55
+ * | with parameters { input: "Hello, World!" } |
56
+ * | |
57
+ * | ---------------------------------------------------------------------> |
58
+ * | |
59
+ * | |
60
+ * | 2. Response to APP_ID |
61
+ * | with result '{ "echoMessage" : "Hello, World!" }' |
62
+ * | |
63
+ * | <--------------------------------------------------------------------- |
64
+ * | |
65
+ * \|/ \|/
66
+ * ' '
67
+ */
68
+ bool echo(LSHandle *sh, LSMessage *message, void *data)
69
+ {
70
+ LSError lserror;
71
+ JSchemaInfo schemaInfo;
72
+ jvalue_ref parsed = {0}, value = {0};
73
+ jvalue_ref jobj = {0}, jreturnValue = {0};
74
+ const char *input = NULL;
75
+ char buf[BUF_SIZE] = {0, };
76
+
77
+ LSErrorInit(&lserror);
78
+
79
+ // Initialize schema
80
+ jschema_info_init (&schemaInfo, jschema_all(), NULL, NULL);
81
+
82
+ // get message from LS2 and parsing to make object
83
+ parsed = jdom_parse(j_cstr_to_buffer(LSMessageGetPayload(message)), DOMOPT_NOOPT, &schemaInfo);
84
+
85
+ if (jis_null(parsed)) {
86
+ j_release(&parsed);
87
+ return true;
88
+ }
89
+
90
+ // Get value from payload.input
91
+ value = jobject_get(parsed, j_cstr_to_buffer("input"));
92
+
93
+ // JSON Object to string without schema validation check
94
+ input = jvalue_tostring_simple(value);
95
+
96
+ /**
97
+ * JSON create test
98
+ */
99
+ jobj = jobject_create();
100
+ if (jis_null(jobj)) {
101
+ j_release(&jobj);
102
+ return true;
103
+ }
104
+
105
+ jreturnValue = jboolean_create(TRUE);
106
+ jobject_set(jobj, j_cstr_to_buffer("returnValue"), jreturnValue);
107
+ jobject_set(jobj, j_cstr_to_buffer("echoMessage"), value);
108
+
109
+ LSMessageReply(sh, message, jvalue_tostring_simple(jobj), &lserror);
110
+
111
+ j_release(&parsed);
112
+ return true;
113
+ }
114
+
115
+ // Register background service and initialize
116
+ int main(int argc, char* argv[])
117
+ {
118
+ LSError lserror;
119
+ LSHandle *handle = NULL;
120
+ bool bRetVal = FALSE;
121
+
122
+ LSErrorInit(&lserror);
123
+
124
+ // create a GMainLoop
125
+ gmainLoop = g_main_loop_new(NULL, FALSE);
126
+
127
+ bRetVal = LSRegister(SERVICE_NAME, &handle, &lserror);
128
+ if (FALSE== bRetVal) {
129
+ LSErrorFree( &lserror );
130
+ return 0;
131
+ }
132
+ sh = LSMessageGetConnection(message);
133
+
134
+ LSRegisterCategory(handle,"/",sampleMethods, NULL, NULL, &lserror);
135
+
136
+ LSGmainAttach(handle, gmainLoop, &lserror);
137
+
138
+ // run to check continuously for new events from each of the event sources
139
+ g_main_loop_run(gmainLoop);
140
+ // Decreases the reference count on a GMainLoop object by one
141
+ g_main_loop_unref(gmainLoop);
142
+
143
+ return 0;
144
+ }