modify orchestration_request_service API 08/212508/3 accepted/tizen/unified/20190826.012737 submit/tizen/20190823.053839
authorwansu.yoo <wansu.yoo@samsung.com>
Thu, 22 Aug 2019 07:45:11 +0000 (16:45 +0900)
committerwansu.yoo <wansu.yoo@samsung.com>
Thu, 22 Aug 2019 09:16:25 +0000 (18:16 +0900)
-. update interface of go library for multiple input services.
-. add /var/data/db directory for boltdb pkg.
-. update dbus interface at server and client.
-. update generated lib.

Change-Id: I98c3e0ea1a2e9e5b566752fd40203601b481a393
Signed-off-by: wansu.yoo <wansu.yoo@samsung.com>
16 files changed:
.gitmodules
CMain/inc/orchestration.h
CMain/inc/orchestration_server.h
CMain/lib/liborchestration.a
CMain/src/main.c
CMain/src/orchestration_server.c
Makefile
build.sh
edge-home-orchestration-go
libedge-orchestration/inc/dbus_consumer.h
libedge-orchestration/inc/orchestration_client.h
libedge-orchestration/sample/main.c
libedge-orchestration/sample/main_chrome.c
libedge-orchestration/src/dbus_consumer.c [changed mode: 0644->0755]
libedge-orchestration/src/orchestration_client.c [changed mode: 0644->0755]
packaging/edge-orchestration.spec

index 6c01e2c..f26d41a 100644 (file)
@@ -1,4 +1,3 @@
 [submodule "edge-home-orchestration-go"]
        path = edge-home-orchestration-go
        url = https://github.com/lf-edge/edge-home-orchestration-go.git
-       ignore = dirty
index 859cd69..55bb5ae 100644 (file)
@@ -3,14 +3,16 @@
 /* package interfaces/capi */
 
 
-#line 1 "cgo-builtin-prolog"
+#line 1 "cgo-builtin-export-prolog"
 
 #include <stddef.h> /* for ptrdiff_t below */
 
 #ifndef GO_CGO_EXPORT_PROLOGUE_H
 #define GO_CGO_EXPORT_PROLOGUE_H
 
+#ifndef GO_CGO_GOSTRING_TYPEDEF
 typedef struct { const char *p; ptrdiff_t n; } _GoString_;
+#endif
 
 #endif
 
@@ -34,6 +36,22 @@ typedef struct { const char *p; ptrdiff_t n; } _GoString_;
  * limitations under the License.
  *
  *******************************************************************************/
+#define MAX_SVC_INFO_NUM 3
+typedef struct {
+       char* ExecutionType;
+       char* ExeCmd;
+} RequestServiceInfo;
+
+typedef struct {
+       char* ExecutionType;
+       char* Target;
+} TargetInfo;
+
+typedef struct {
+       char*      Message;
+       char*      ServiceName;
+       TargetInfo RemoteTargetInfo;
+} ResponseService;
 
 #line 1 "cgo-generated-wrapper"
 
@@ -69,7 +87,9 @@ typedef double _Complex GoComplex128;
 */
 typedef char _check_for_32_bit_pointer_matching_GoInt[sizeof(void*)==32/8 ? 1:-1];
 
+#ifndef GO_CGO_GOSTRING_TYPEDEF
 typedef _GoString_ GoString;
+#endif
 typedef void *GoMap;
 typedef void *GoChan;
 typedef struct { void *t; void *v; } GoInterface;
@@ -86,7 +106,7 @@ extern "C" {
 
 extern int OrchestrationInit();
 
-extern int OrchestrationRequestService(char* p0, char* p1);
+extern ResponseService OrchestrationRequestService(char* p0, RequestServiceInfo* p1, int p2);
 
 extern int PrintLog(char* p0);
 
index f5bb154..3e2105a 100644 (file)
@@ -23,6 +23,8 @@ extern "C"
 {
 #endif
 
+#include <orchestration.h>
+
 #define DEBUG(format, ...)     printLog("[%s:%d] "format, __FILE__, __LINE__, ##__VA_ARGS__);
 
 typedef enum  {
@@ -39,7 +41,7 @@ typedef enum  {
        ORCH_ERROR_NONE = 0,
 } _orchestration_state_e;
 
-typedef int (*request_service_cb)(char* app_name, char* service_info);
+typedef int (*request_service_cb)(char* app_name, RequestServiceInfo service_info[], int count);
 
 void set_default_dbus_interface(void);
 int orchestration_server_initialize(request_service_cb cb);
index 87377d2..8257abf 100644 (file)
Binary files a/CMain/lib/liborchestration.a and b/CMain/lib/liborchestration.a differ
index ec369b5..306f51a 100644 (file)
 #include <pthread.h>
 
 #include <orchestration_server.h>
-#include <orchestration.h>
 
-int request_cb(char* app_name, char* service_info){
-       int result = ORCH_ERROR_FAULT;
+int request_cb(char* app_name, RequestServiceInfo service_info[], int count){
+       int ret = ORCH_ERROR_NONE;
+       ResponseService result;
 
-       DEBUG("app_name : %s\n", app_name);
-       DEBUG("service_info : %s\n", service_info);
-       result = OrchestrationRequestService(app_name, service_info);
+       DEBUG("[orchestration_server]\n")
+       DEBUG("\t app_name : %s\n", app_name);
+       DEBUG("\t count : %d\n", count);
+       for (int ix = 0; ix < count; ix++) {
+               DEBUG("\t service_info[%d].ExecutionType : %s\n", ix, service_info[ix].ExecutionType);
+               DEBUG("\t service_info[%d].ExeCmd : %s\n", ix, service_info[ix].ExeCmd);
+       }
+
+       result = OrchestrationRequestService(app_name, service_info, count);
+       DEBUG("result = %s\n", result.Message);
 
-       return result;
+       /* TO DO : parsing API response */
+       return ret;
 }
 
 void* thread_orchestration() {
@@ -42,7 +50,7 @@ void* thread_orchestration() {
 
 int main(void){
        int result;
-        pthread_t p_thread;
+       pthread_t p_thread;
 
        GMainLoop *loop;
 
index d65fc3a..6836df7 100644 (file)
@@ -38,7 +38,8 @@ static gchar introspection_xml[] =
     "  <interface name='org.tizen.orchestration.agent'>"
     "        <method name='request_service'>"
     "          <arg type='s' name='app_name' direction='in'/>"
-    "          <arg type='s' name='service_info' direction='in'/>"
+    "          <arg type='a(ss)' name='service_info' direction='in'/>"
+    "          <arg type='i' name='count' direction='in'/>"
     "          <arg type='i' name='return_value' direction='out'/>"
     "        </method>"
     "  </interface>"
@@ -61,18 +62,34 @@ static int _request_service(GVariant *parameters)
 {
     int result = ORCH_ERROR_NONE;
 
-    char *app_name, *service_info;
+    char *app_name;
+    int count;
+    GVariantIter *iter;
+    RequestServiceInfo service_info[MAX_SVC_INFO_NUM] = {NULL, };
 
     if (!parameters)
     {
         return ORCH_ERROR_INVALID_PARAMETER;
     }
 
-    g_variant_get(parameters, "(&ss)", &app_name, &service_info);
+    g_variant_get(parameters, "(sa(ss)i)", &app_name, &iter, &count);
+
+    DEBUG("[orchestration dbus_interface] _request_service\n");
+    DEBUG("\t app_name = %s\n", app_name);
+    DEBUG("\t count = %d\n", count);
+
+    for (int i = 0; i < count; i++) {
+        g_variant_iter_loop (iter, "(ss)", &service_info[i].ExecutionType, &service_info[i].ExeCmd);
+
+        DEBUG("\t service_info[%d].ExecutionType = %s\n", i, service_info[i].ExecutionType);
+        DEBUG("\t service_info[%d].ExeCmd = %s\n", i, service_info[i].ExeCmd);
+    }
+    g_variant_iter_free (iter);
+
     if (g_strcmp0(app_name, "") == 0)
         return ORCH_ERROR_INVALID_PARAMETER;
 
-    result = _request_service_cb(app_name, service_info);
+    result = _request_service_cb(app_name, service_info, count);
 
     return result;
 }
index 69557f2..6760c8e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -62,6 +62,7 @@ install:
        install -d $(DESTDIR)/usr/bin
        install -d $(DESTDIR)/etc/$(PKG_NAME)
        install -d $(DESTDIR)/var/log/$(PKG_NAME)
+       install -d $(DESTDIR)/var/data/db
        install -d $(DESTDIR)/usr/lib/systemd/system/multi-user.target.wants
        install -d $(DESTDIR)/usr/share/dbus-1/system-services
        install -d $(DESTDIR)/etc/dbus-1/system.d
index f76b602..69c7804 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -25,7 +25,6 @@ function build_init() {
     echo "=================================================================="
     submodule_init
     submodule_sync
-    submodule_update
 }
 
 function build_c_interface() {
@@ -117,6 +116,13 @@ case "$1" in
         build_c_interface
         build_package
         ;;
+    "init")
+        build_clean
+        build_init
+        submodule_update
+        build_c_interface
+        build_package
+        ;;
     "local")
         build_clean
         build_c_interface
@@ -133,6 +139,7 @@ case "$1" in
         echo "Usage:"
         echo "--------------------------------------------------------------"
         echo "  $0          : build C-Archive & RPM packages from Submodule"
+        echo "  $0 init     : build from latest Submodule"
         echo "  $0 local    : build from local Submodule"
         echo "  $0 test     : build test"
         echo "  $0 clean    : build clean"
index 69c8a60..a7243de 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 69c8a60f9016d3ad483b1734cc69d88206f23f03
+Subproject commit a7243de06d809dd7377d4bde7b4d7786f2150998
index 505f9f8..3d59e61 100644 (file)
@@ -23,6 +23,8 @@ extern "C"
 {
 #endif
 
+#include <orchestration_client.h>
+
 typedef enum  {
     ORCH_DBUS_ERROR_NONE = 0,
     ORCH_DBUS_ERROR_INVALID_PARAMETER,
@@ -30,11 +32,10 @@ typedef enum  {
 } _orchestration_dbus_state_e;
 
 int dbus_consumer_initailze();
-int request_service_execute(char* app_name, char* exec_param);
+int request_service_execute(char* app_name, service_info_s service_info[], int count);
 
 #ifdef __cplusplus
 }
 #endif
 
 #endif /* __ORCHESTRATION_DBUS_CONSUMER_H__ */
\ No newline at end of file
index a150880..4ab6899 100644 (file)
@@ -38,9 +38,17 @@ typedef enum
     ORCHESTRATION_SERVICE_STATUS_UNDEFINED_ERROR,
 } orchestration_service_status_e;
 
+#define MAX_SVC_INFO_NUM 3
 typedef struct
 {
+    char *exec_type;
     char *exec_parameter;
+} service_info_s;
+
+typedef struct
+{
+    int count;
+    service_info_s services[MAX_SVC_INFO_NUM];
 } orchestration_service_info_s;
 
 typedef void (*orchestration_changed_service_status_cb)(orchestration_service_status_e staus, void *user_data);
@@ -48,7 +56,7 @@ typedef void (*orchestration_changed_service_status_cb)(orchestration_service_st
 orchestration_client_state_e orchestration_request_service(char *app_name,
                                                 orchestration_service_info_s service_info,
                                                 orchestration_changed_service_status_cb cb,
-                                                void *user_data);                                               
+                                                void *user_data);
 
 #ifdef __cplusplus
 }
index 489bccf..bb2c14a 100644 (file)
@@ -25,7 +25,11 @@ void status_cb(orchestration_service_status_e staus, void* user_data)
 
 int main() {
     orchestration_service_info_s service_info;
-    service_info.exec_parameter = "ls -al";
+    service_info.count = 2;
+    service_info.services[0].exec_type = "native";
+    service_info.services[0].exec_parameter = "ls -al";
+    service_info.services[1].exec_type = "container";
+    service_info.services[1].exec_parameter = "docker run hello-world";
     orchestration_request_service("list_segments", service_info, status_cb, NULL);
     return 0;
 }
\ No newline at end of file
index a43ce3c..4b6e0d2 100644 (file)
@@ -56,8 +56,10 @@ int main() {
         return 0;
     }
     orchestration_service_info_s service_info;
-    service_info.exec_parameter = strcat(command, ipstr);
-    printf("service_info.exec_parameter: %s\n", service_info.exec_parameter);
+    service_info.count = 1;
+    service_info.services[0].exec_type = "native";
+    service_info.services[0].exec_parameter = strcat(command, ipstr);
+    printf("service_info.exec_parameter: %s\n", service_info.services[0].exec_parameter);
     orchestration_request_service("org.tizen.chromium-efl", service_info, status_cb, NULL);
     return 0;
 }
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index cd87744..882d419
@@ -47,9 +47,33 @@ int dbus_consumer_initailze()
     return ORCH_DBUS_ERROR_NONE;
 }
 
-int request_service_execute(char* app_name, char* exec_param)
+int request_service_execute(char* app_name, service_info_s service_info[], int count)
 {
+    int idx;
     GError *error = NULL;
+    GVariant *services;
+    GVariantBuilder *builder;
+
+    printf("[orchestration dbus_consumer] request_service_execute\n");
+    printf("\t app_name = %s\n", app_name);
+    printf("\t count = %d\n", count);
+    for (idx = 0; idx < count; idx++) {
+        printf("\t service_info[%d].exec_type = %s\n", idx, service_info[idx].exec_type);
+        printf("\t service_info[%d].exec_parameter = %s\n", idx, service_info[idx].exec_parameter);
+    }
+
+    builder = g_variant_builder_new (G_VARIANT_TYPE ("a(ss)"));
+    for (idx = 0; idx < count; idx++) {
+        g_variant_builder_add (
+            builder,
+            "(ss)",
+            service_info[idx].exec_type,
+            service_info[idx].exec_parameter
+        );
+    }
+
+    services = g_variant_new ("(sa(ss)i)", app_name, builder, count);
+    g_variant_builder_unref (builder);
 
     GVariant *result =
         g_dbus_connection_call_sync (_gdbus_conn,
@@ -57,7 +81,7 @@ int request_service_execute(char* app_name, char* exec_param)
                                 _ORCHESTRATION_OBJECT_PATH,
                                 _ORCHESTRATION_INTERFACE,
                                 _ORCHESTRATION_REQUEST_SERVICE_METHOD,
-                                g_variant_new ("(ss)", app_name, exec_param),
+                                services,
                                 NULL,
                                 G_DBUS_CALL_FLAGS_NONE,
                                 -1,
@@ -65,7 +89,7 @@ int request_service_execute(char* app_name, char* exec_param)
                                 &error);
        if (result)
         g_variant_unref (result);
-    
+
     if (error)
     {
                printf("Failed to call remote method - %i : %s\n", error->code, error->message);
old mode 100644 (file)
new mode 100755 (executable)
index 024f256..6a96d95
@@ -18,7 +18,6 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <orchestration_client.h>
 #include <dbus_consumer.h>
 
 /* ---------------------------------------------------------------------------------------------------- */
@@ -55,7 +54,15 @@ orchestration_client_state_e orchestration_request_service(char *app_name,
         return ORCH_CLIENT_ERROR_FAULT;
     }
 
-    result = request_service_execute(app_name, service_info.exec_parameter);
+    printf("[orchestration_client]\n");
+       printf("\t app_name : %s\n", app_name);
+       printf("\t count : %d\n", service_info.count);
+       for (int i = 0; i < service_info.count; i++) {
+               printf("\t service_info[%d]->exec_type : %s\n", i, service_info.services[i].exec_type);
+               printf("\t service_info[%d]->exec_parameter : %s\n", i, service_info.services[i].exec_parameter);
+       }
+
+    result = request_service_execute(app_name, service_info.services, service_info.count);
     if (result != ORCH_DBUS_ERROR_NONE)
     {
         printf("request_service_execute failed\n");
index 83e4294..e02cf2b 100644 (file)
@@ -108,6 +108,7 @@ ln -sf %{_sysconfdir}/%{name}/apps/myscoring2/libmyscoring2.so.1.0.1 %{_sysconfd
 %attr(644,root,root)%{_datadir}/dbus-1/system-services/org.tizen.orchestration.service
 %attr(644,root,root)%{_sysconfdir}/dbus-1/system.d/org.tizen.orchestration.conf
 %attr(755,system_fw,system_fw)%dir /var/log/%{name}
+%attr(755,system_fw,system_fw)%dir /var/data/db
 %attr(755,system_fw,system_fw)%dir %{_sysconfdir}/%{name}
 %attr(755,system_fw,system_fw)%dir %{_sysconfdir}/%{name}/apps