vendor/src
doc/generate-api/*
3rdparty/
+src/CMain/bin/*
+src/CMain/lib/*
# Test binary, build with `go test -c`
*.test
+# Output of c build
+*.o
+
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
*.html
+
+# VS Code
+.vscode/
\ No newline at end of file
GO_LDFLAGS := -ldflags '-extldflags "-static"'
# Target parameters
+PKG_NAME := edge-orchestration
BIN_DIR := $(BASE_DIR)/bin
-BINARY_FILE := edge-orchestration
+BINARY_FILE := $(PKG_NAME)
EXEC_SRC_DIR := GoMain
OBJ_SRC_DIR := interface
PKG_DIRS := devicemgr discoverymgr interface restapi/v1 servicemgr scoringmgr orchestrationapi configuremgr
+SERVICE_FILE := $(PKG_NAME).service
+MANIFEST_FILE := $(PKG_NAME).manifest
# CMain target
ORG_HEADER_FILE_C := liborchestration.h
CMAIN_BIN_DIR := $(CMAIN_DIR)/bin
CMAIN_LIB_DIR := $(CMAIN_DIR)/lib
+# Library package
+LIBPKG_LIB_FILE := liborchestration-client.so
+LIBPKG_HEADER_FILE := orchestration_client.h
+LIBPKG_DIR := $(BASE_DIR)/src/libedge-orchestration
+LIBPKG_LIB_DIR := $(LIBPKG_DIR)/lib
+LIBPKG_INC_DIR := $(LIBPKG_DIR)/inc
.DEFAULT_GOAL := help
-## test and build
-all: build
-
## edge-orchestration binary build
build-binary:
$(GOBUILD) -a $(GO_LDFLAGS) -o $(BIN_DIR)/$(BINARY_FILE) $(EXEC_SRC_DIR) || exit 1
build-object:
CGO_ENABLED=1 $(GOBUILD) -o $(CMAIN_LIB_DIR)/$(OBJECT_FILE_C) -buildmode=c-archive $(OBJ_SRC_DIR) || exit 1
mv $(CMAIN_LIB_DIR)/$(ORG_HEADER_FILE_C) $(CMAIN_INC_DIR)/$(HEADER_FILE_C)
+ ls -al $(CMAIN_LIB_DIR)
$(MAKE) -C $(CMAIN_DIR)
+ $(MAKE) -C $(LIBPKG_DIR)
+
+
+## install output files for packaing
+install:
+ -rm -rf $(DESTDIR)
+ install -d $(DESTDIR)/usr/bin
+ install -d $(DESTDIR)/etc/$(PKG_NAME)
+ install -d $(DESTDIR)/usr/lib/systemd/system/multi-user.target.wants
+ install -m 755 $(CMAIN_BIN_DIR)/$(BINARY_FILE) $(DESTDIR)/usr/bin/$(BINARY_FILE)
+ install -m 644 $(BASE_DIR)/$(SERVICE_FILE) $(DESTDIR)/usr/lib/systemd/system/$(SERVICE_FILE)
+ ln -s ../$(SERVICE_FILE) $(DESTDIR)/usr/lib/systemd/system/multi-user.target.wants/
+
+ install -d $(DESTDIR)/usr/lib
+ install -d $(DESTDIR)/usr/include/$(PKG_NAME)
+ install -m 644 $(LIBPKG_LIB_DIR)/$(LIBPKG_LIB_FILE) $(DESTDIR)/usr/lib
+ install -m 644 $(LIBPKG_INC_DIR)/$(LIBPKG_HEADER_FILE) $(DESTDIR)/usr/include/$(PKG_NAME)
## go test and coverage
test:
export GOARCH=amd64
export GOPATH=$GOPATH:$BASE_DIR:$BASE_DIR/vendor
+ORG_VENDOR_DIR='vendor'
+CUR_VENDOR_DIR='vendor/src'
+if [ ! -d $BASE_DIR/$CUR_VENDOR_DIR ]; then
+ ln -s $BASE_DIR/$ORG_VENDOR_DIR $BASE_DIR/$CUR_VENDOR_DIR
+fi
+
if [ "$1" = "all" ]; then
BUILD_ALL=true
fi
if [ "$BUILD_ALL" = true ]
then
- install_prerequisite
build_clean
+ install_prerequisite
build_test
build_object
build_binary
package: .
ignore:
+- configuremgr
- devicemgr
+- discoverymgr
+- orchestrationapi
+- restapi/httpclient
- restapi/v1
+- scoringmgr
- servicemgr
-- configuremgr
-- commons/logger
-- discovery
import:
+- package: github.com/fsnotify/fsnotify
- package: github.com/gorilla/mux
- package: github.com/grandcat/zeroconf
-- package: github.com/fsnotify/fsnotify
-- package: gopkg.in/go-ini/ini.v1
\ No newline at end of file
+- package: gopkg.in/sconf/ini.v0
+- package: gopkg.in/sconf/sconf.v0
Source3: lib%{name}.manifest
Source11: go1.12.linux-armv7.tar.gz
+
+
+
+###BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(gio-2.0)
+BuildRequires: pkgconfig(gio-unix-2.0)
+#BuildRequires: pkgconfig(cynara-client)
+#BuildRequires: pkgconfig(cynara-session)
+#BuildRequires: pkgconfig(cynara-creds-gdbus)
+Requires(post): dbus
Requires(post): /sbin/ldconfig, /usr/bin/systemctl
Requires(postun): /sbin/ldconfig, /usr/bin/systemctl
%setup -q
chmod g-w %_sourcedir/*
cp %{SOURCE1} ./%{name}.manifest
-cp %{SOURCE2} ./%{name}.services
+cp %{SOURCE2} ./%{name}.service
cp %{SOURCE3} ./lib%{name}.manifest
%ifarch armv7l
cp %{SOURCE11} ./
export GOPATH=%{_builddir}/%{name}-%{version}:%{_builddir}/%{name}-%{version}/vendor
export BASE_DIR=.
+make clean
make build-object %{?_smp_mflags}
%install
-rm -rf %{buildroot}
-install -d %{buildroot}%{_bindir}
-install -p -m 755 ./bin/%{name} %{buildroot}%{_bindir}/%{name}
-mkdir -p %{buildroot}/usr/lib/systemd/system/multi-user.target.wants
-install -m 0644 %{SOURCE2} %{buildroot}/usr/lib/systemd/system/%{name}.service
-ln -s ../%{name}.service %{buildroot}/usr/lib/systemd/system/multi-user.target.wants/
-mkdir -p %{buildroot}%{_sysconfdir}/%{name}
+export BASE_DIR=.
+%make_install
%files
%manifest %{name}.manifest
%{_bindir}/%{name}
%{_unitdir}/%{name}.service
%{_unitdir}/multi-user.target.wants/%{name}.service
+%dir %{_sysconfdir}/%{name}
-%dir %{_sysconfdir}/%{name}
\ No newline at end of file
+%files -n libedge-orchestration
+%manifest lib%{name}.manifest
+%license LICENSE.Apache-2.0
+%defattr(-,root,root,-)
+%{_libdir}/liborchestration-client.so
+
+%files -n libedge-orchestration-devel
+%manifest lib%{name}.manifest
+%license LICENSE.Apache-2.0
+%defattr(-,root,root,-)
+%{_libdir}/liborchestration-client.so
+%{_includedir}/%{name}/orchestration_client.h
\ No newline at end of file
# Makefile
#
-CC=gcc
-all: orchestration
+# Target parameters
+BIN_DIR := $(BASE_DIR)/bin
+LIB_DIR := $(BASE_DIR)/lib
+INC_DIR := $(BASE_DIR)/inc
+SRC_DIR := $(BASE_DIR)/src
+LIBRARY_FILE := orchestration
+BINARY_FILE := edge-orchestration
+SRC_FILES := \
+ $(SRC_DIR)/main.c \
+ $(SRC_DIR)/orchestration_server.c
-# %.o: %.c
-# $(CC) -Wall -c `pkg-config --cflags dbus-1`
-# lt; -o $@
+# Build parameter
+CC := gcc
+CFLAGS := -g -Wall -Werror -fPIE -pie
-orchestration: main.o dbus_interface.o
- $(CC) -g -Wall -Werror ./src/main.o ./src/dbus_interface.o -o ./bin/orchestration -I ./inc `pkg-config --libs --cflags gio-2.0 gio-unix-2.0 glib-2.0 dbus-glib-1 dbus-1` -L./lib -lorchestration
+all: clean build
-main.o: ./src/main.c
- $(CC) -Wall ./src/main.c -c -o ./src/main.o -I ./inc `pkg-config --libs --cflags glib-2.0`
+build:
+ mkdir -p $(BIN_DIR)
+ $(CC) $(CFLAGS) -o $(BIN_DIR)/$(BINARY_FILE) -I $(INC_DIR) `pkg-config --libs --cflags gio-2.0 gio-unix-2.0 glib-2.0` $(SRC_FILES) -L$(LIB_DIR) -l$(LIBRARY_FILE)
-dbus_interface.o: ./src/dbus_interface.c
- $(CC) -Wall ./src/dbus_interface.c -c -o ./src/dbus_interface.o -I ./inc `pkg-config --libs --cflags gio-2.0 gio-unix-2.0 glib-2.0 dbus-glib-1 dbus-1`
-
-
-.PHONY: clean
clean:
- -rm ./src/*.o ./bin/orchestration
\ No newline at end of file
+ -rm -f $(SRC_DIR)/*.o
+ -rm -f $(BIN_DIR)/$(BINARY_FILE)
+
+.PHONY: build clean
\ No newline at end of file
+++ /dev/null
-#ifndef __ORCHESTRATION_DBUS_H__
-#define __ORCHESTRATION_DBUS_H__
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-typedef enum {
- ORCH_ERROR_NONE = 0,
- ORCH_ERROR_INVALID_PARAMETER = -1,
- ORCH_ERROR_FAULT = -2,
-} ORCH_DBUS_ERROR;
-
-typedef void (*request_service_cb)(char* app_name, char* service_info);
-
-ORCH_DBUS_ERROR orch_dbus_initialize(request_service_cb cb);
-void orch_dbus_finish(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __ORCHESTRATION_DBUS_H__ */
\ No newline at end of file
--- /dev/null
+#ifndef __ORCHESTRATION_SERVER_H__
+#define __ORCHESTRATION_SERVER_H__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+typedef enum {
+ ORCH_ERROR_NONE = 0,
+ ORCH_ERROR_INVALID_PARAMETER,
+ ORCH_ERROR_DBUS_FAILURE,
+ ORCH_ERROR_FAULT,
+} _orchestration_state_e;
+
+typedef void (*request_service_cb)(char* app_name, char* service_info);
+
+int orchestration_server_initialize(request_service_cb cb);
+void orchestration_server_finish(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __ORCHESTRATION_SERVER_H__ */
\ No newline at end of file
+++ /dev/null
-#include <gio/gio.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <dbus_interface.h>
-
-/* ---------------------------------------------------------------------------------------------------- */
-static guint owner_id;
-static GDBusConnection *_gdbus_conn;
-static GDBusNodeInfo *introspection_data = NULL;
-
-request_service_cb _request_service_cb = NULL;
-
-#define _ORCHESTRATION_BUS_NAME "org.tizen.orchestration"
-#define _ORCHESTRATION_OBJECT_PATH "/org/tizen/orchestration"
-#define _ORCHESTRATION_SVC_ERROR_DOMAIN "orchestration"
-
-GDBusErrorEntry _orchestration_svc_errors[] = {
- {ORCH_ERROR_NONE, "NoError"},
- {ORCH_ERROR_INVALID_PARAMETER, "Invalid parameter"},
- {ORCH_ERROR_FAULT, "Orchestration Failed"},
-};
-
-/* Introspection data for the service we are exporting */
-static gchar introspection_xml[] =
- " <node>"
- " <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'/>"
- " </method>"
- " </interface>"
- " </node>";
-/* ---------------------------------------------------------------------------------------------------- */
-
-static GQuark _ORCHESTRATION_ERROR_quark(void)
-{
- static volatile gsize quark_volatile = 0;
- g_dbus_error_register_error_domain(_ORCHESTRATION_SVC_ERROR_DOMAIN,
- &quark_volatile,
- _orchestration_svc_errors,
- G_N_ELEMENTS(_orchestration_svc_errors));
- return (GQuark)quark_volatile;
-}
-
-int _request_service(GVariant *parameters, GVariant **reply_body)
-{
- char *app_name, *service_info;
-
- g_variant_get(parameters, "(&ss)", &app_name, &service_info);
-
- if (app_name == NULL)
- return ORCH_ERROR_INVALID_PARAMETER;
- if (service_info == NULL)
- return ORCH_ERROR_INVALID_PARAMETER;
-
- _request_service_cb(app_name, service_info);
-
- return ORCH_ERROR_NONE;
-}
-
-static void _handle_method_call(
- GDBusConnection *connection,
- const gchar *sender,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *method_name,
- GVariant *parameters,
- GDBusMethodInvocation *invocation,
- gpointer user_data)
-{
- int ret = ORCH_ERROR_NONE;
- GVariant *reply_body = NULL;
-
- if (g_strcmp0(method_name, "request_service") == 0)
- {
- ret = _request_service(parameters, &reply_body);
- }
- if (ret == ORCH_ERROR_NONE)
- {
- printf("Orchestration service Success, method name : %s\n", method_name);
- g_dbus_method_invocation_return_value(invocation, reply_body);
- }
- else
- {
- printf("Orchestration service fail, method name : %s\n", method_name);
-
- GError *error = g_error_new(_ORCHESTRATION_ERROR_quark(), ret, "request service failed");
- g_dbus_method_invocation_return_gerror(invocation, error);
- g_error_free(error);
- }
-}
-
-static const GDBusInterfaceVTable _interface_vtable =
-{
- _handle_method_call,
- NULL,
- NULL
-};
-
-static int _dbus_init(void)
-{
- GError *error = NULL;
-
- if (_gdbus_conn == NULL)
- {
- _gdbus_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
- if (_gdbus_conn == NULL)
- {
- if (error != NULL)
- {
- printf("Failed to get dbus [%s]", error->message);
- g_error_free(error);
- }
- return ORCH_ERROR_FAULT;
- }
- }
-
- return ORCH_ERROR_NONE;
-}
-
-void orch_dbus_finish(void)
-{
- g_bus_unown_name(owner_id);
- g_dbus_node_info_unref(introspection_data);
-}
-
-ORCH_DBUS_ERROR orch_dbus_initialize(request_service_cb cb)
-{
- int result;
- guint orch_registration_id;
-
- GError *error = NULL;
-
- if (cb == NULL)
- {
- result = ORCH_ERROR_INVALID_PARAMETER;
- goto out;
- }
- _request_service_cb = cb;
-
- result = _dbus_init();
- if (result != ORCH_ERROR_NONE)
- {
- printf("Can't init dbus [%d]", result);
- goto out;
- }
- owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
- _ORCHESTRATION_BUS_NAME,
- G_BUS_NAME_OWNER_FLAGS_NONE,
- NULL,
- NULL,
- NULL,
- NULL, NULL);
- if (!owner_id)
- {
- printf("Failed to own name");
- result = ORCH_ERROR_FAULT;
- goto out;
- }
-
- introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, &error);
- if (!introspection_data)
- {
- printf("g_dbus_node_info_new_for_xml is failed.");
- if (error != NULL)
- {
- printf("g_dbus_node_info_new_for_xml err [%s]", error->message);
- g_error_free(error);
- }
- result = ORCH_ERROR_FAULT;
- goto out;
- }
-
- orch_registration_id = g_dbus_connection_register_object(_gdbus_conn,
- _ORCHESTRATION_OBJECT_PATH, introspection_data->interfaces[0],
- &_interface_vtable, NULL, NULL, NULL);
-
- if (orch_registration_id == 0)
- {
- printf("Failed to g_dbus_connection_register_object");
- result = ORCH_ERROR_FAULT;
- goto out;
- }
-
-out:
- if (introspection_data)
- {
- g_dbus_node_info_unref(introspection_data);
- }
-
- return result;
-}
\ No newline at end of file
#include <stdio.h>
#include <gio/gio.h>
-#include <dbus_interface.h>
+#include <orchestration_server.h>
#include <orchestration.h>
void request_cb(char* app_name, char* service_info){
int main(void){
int result;
+
GMainLoop *loop;
+
+ printf("OrchestrationInit call");
OrchestrationInit();
- result = orch_dbus_initialize(request_cb);
+
+ printf("orchestration_server_initialize call");
+ result = orchestration_server_initialize(request_cb);
if(result != ORCH_ERROR_NONE){
- printf("dbus error\n");
+ printf("orchestration_server_initialize failed\n");
+ orchestration_server_finish();
}
- loop = g_main_loop_new(NULL, FALSE);
+ loop = g_main_loop_new(NULL, FALSE);
if (!loop)
- return -1;
+ return -1;
- g_main_loop_run (loop);
+ g_main_loop_run (loop);
+ orchestration_server_finish();
return 0;
}
\ No newline at end of file
--- /dev/null
+#include <gio/gio.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <orchestration_server.h>
+
+/* ---------------------------------------------------------------------------------------------------- */
+static guint owner_id;
+static GDBusConnection *_gdbus_conn;
+static GDBusNodeInfo *introspection_data = NULL;
+
+request_service_cb _request_service_cb = NULL;
+
+#define _ORCHESTRATION_BUS_NAME "org.tizen.orchestration"
+#define _ORCHESTRATION_OBJECT_PATH "/org/tizen/orchestration"
+#define _ORCHESTRATION_SVC_ERROR_DOMAIN "orchestration"
+
+GDBusErrorEntry _orchestration_svc_errors[] = {
+ {ORCH_ERROR_NONE, "NoError"},
+ {ORCH_ERROR_INVALID_PARAMETER, "Invalid parameter"},
+ {ORCH_ERROR_FAULT, "Orchestration Failed"},
+};
+
+/* Introspection data for the service we are exporting */
+static gchar introspection_xml[] =
+ " <node>"
+ " <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'/>"
+ " </method>"
+ " </interface>"
+ " </node>";
+/* ---------------------------------------------------------------------------------------------------- */
+
+static GQuark _ORCHESTRATION_ERROR_quark(void)
+{
+ static volatile gsize quark_volatile = 0;
+ g_dbus_error_register_error_domain(_ORCHESTRATION_SVC_ERROR_DOMAIN,
+ &quark_volatile,
+ _orchestration_svc_errors,
+ G_N_ELEMENTS(_orchestration_svc_errors));
+ return (GQuark)quark_volatile;
+}
+
+static int _request_service(GVariant *parameters, GVariant **reply_body)
+{
+ char *app_name, *service_info;
+
+ g_variant_get(parameters, "(&ss)", &app_name, &service_info);
+
+ if (app_name == NULL)
+ return ORCH_ERROR_INVALID_PARAMETER;
+ if (service_info == NULL)
+ return ORCH_ERROR_INVALID_PARAMETER;
+
+ _request_service_cb(app_name, service_info);
+
+ return ORCH_ERROR_NONE;
+}
+
+static void _handle_method_call(
+ GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ int ret = ORCH_ERROR_NONE;
+ GVariant *reply_body = NULL;
+
+ if (g_strcmp0(method_name, "request_service") == 0)
+ {
+ ret = _request_service(parameters, &reply_body);
+ }
+ if (ret == ORCH_ERROR_NONE)
+ {
+ printf("Orchestration service Success, method name : %s\n", method_name);
+ g_dbus_method_invocation_return_value(invocation, reply_body);
+ }
+ else
+ {
+ printf("Orchestration service fail, method name : %s\n", method_name);
+
+ GError *error = g_error_new(_ORCHESTRATION_ERROR_quark(), ret, "request service failed");
+ g_dbus_method_invocation_return_gerror(invocation, error);
+ g_error_free(error);
+ }
+}
+
+static const GDBusInterfaceVTable _interface_vtable =
+{
+ _handle_method_call,
+ NULL,
+ NULL
+};
+
+static int _dbus_init(void)
+{
+ GError *error = NULL;
+
+ if (_gdbus_conn == NULL)
+ {
+ _gdbus_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (_gdbus_conn == NULL)
+ {
+ if (error != NULL)
+ {
+ printf("Failed to get dbus [%s]", error->message);
+ g_error_free(error);
+ }
+ return ORCH_ERROR_DBUS_FAILURE;
+ }
+ }
+
+ return ORCH_ERROR_NONE;
+}
+
+static int orch_dbus_initialize()
+{
+ int result;
+ guint orch_registration_id;
+
+ GError *error = NULL;
+
+ result = _dbus_init();
+ if (result != ORCH_ERROR_NONE)
+ {
+ printf("Failed to _dbus_init");
+ goto out;
+ }
+ owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
+ _ORCHESTRATION_BUS_NAME,
+ G_BUS_NAME_OWNER_FLAGS_NONE,
+ NULL,
+ NULL,
+ NULL,
+ NULL, NULL);
+ if (!owner_id)
+ {
+ printf("Failed to own name");
+ result = ORCH_ERROR_DBUS_FAILURE;
+ goto out;
+ }
+
+ introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, &error);
+ if (!introspection_data)
+ {
+ printf("g_dbus_node_info_new_for_xml is failed.");
+ if (error != NULL)
+ {
+ printf("g_dbus_node_info_new_for_xml err [%s]", error->message);
+ g_error_free(error);
+ }
+ result = ORCH_ERROR_DBUS_FAILURE;
+ goto out;
+ }
+
+ orch_registration_id = g_dbus_connection_register_object(_gdbus_conn,
+ _ORCHESTRATION_OBJECT_PATH, introspection_data->interfaces[0],
+ &_interface_vtable, NULL, NULL, NULL);
+
+ if (orch_registration_id == 0)
+ {
+ printf("Failed to g_dbus_connection_register_object");
+ result = ORCH_ERROR_DBUS_FAILURE;
+ goto out;
+ }
+
+out:
+ return result;
+}
+
+
+int orchestration_server_initialize(request_service_cb cb)
+{
+ int result;
+
+ if (cb == NULL)
+ {
+ result = ORCH_ERROR_INVALID_PARAMETER;
+ printf("request_service_cb is null.");
+ goto out;
+ }
+ _request_service_cb = cb;
+
+ result = orch_dbus_initialize();
+ if(result != ORCH_ERROR_NONE)
+ {
+ printf("orch_dbus_initialize is failed");
+ goto out;
+ }
+
+out:
+ return result;
+}
+
+void orchestration_server_finish(void)
+{
+ if (owner_id)
+ {
+ g_bus_unown_name(owner_id);
+ }
+ if (introspection_data)
+ {
+ g_dbus_node_info_unref(introspection_data);
+ }
+}
--- /dev/null
+#
+# Makefile
+#
+
+# Target parameters
+INC_DIR := $(BASE_DIR)/inc
+LIB_DIR := $(BASE_DIR)/lib
+SRC_DIR := $(BASE_DIR)/src
+LIBRARY_FILE := liborchestration-client.so
+SRC_FILES := \
+ $(SRC_DIR)/orchestration_client.c \
+ $(SRC_DIR)/dbus_consumer.c
+OBJ_FILES := $(BASE_DIR)/*.o
+
+# Build parameter
+CC := gcc
+CFLAGS := -fPIC -Wall
+
+all: clean build
+
+build:
+ mkdir -p $(LIB_DIR)
+ $(CC) $(CFLAGS) -c -I $(INC_DIR) `pkg-config --libs --cflags gio-2.0 gio-unix-2.0 glib-2.0` $(SRC_FILES)
+ $(CC) -shared -g -Wall -Werror -o $(LIB_DIR)/$(LIBRARY_FILE) -I $(INC_DIR) $(OBJ_FILES)
+
+clean:
+ -rm -f $(OBJ_FILES)
+ -rm -f $(LIB_DIR)/$(LIBRARY_FILE)
+
+.PHONY: build clean
+
--- /dev/null
+#ifndef __ORCHESTRATION_DBUS_CONSUMER_H__
+#define __ORCHESTRATION_DBUS_CONSUMER_H__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+typedef enum {
+ ORCH_DBUS_ERROR_NONE = 0,
+ ORCH_DBUS_ERROR_INVALID_PARAMETER,
+ ORCH_DBUS_ERROR_FAULT,
+} _orchestration_dbus_state_e;
+
+int dbus_consumer_initailze();
+int request_service_execute(char* app_name, char* exec_param);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __ORCHESTRATION_DBUS_CONSUMER_H__ */
+
\ No newline at end of file
--- /dev/null
+#ifndef __ORCHESTRATION_CLIENT_H__
+#define __ORCHESTRATION_CLIENT_H__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+typedef enum
+{
+ ORCH_CLIENT_ERROR_NONE = 0,
+ ORCH_CLIENT_ERROR_INVALID_PARAMETER,
+ ORCH_CLIENT_ERROR_FAULT,
+} orchestration_client_state_e;
+
+typedef enum
+{
+ ORCHESTRATION_SERVICE_STATUS_STARTED = 0,
+ ORCHESTRATION_SERVICE_STATUS_COMPLETED,
+ ORCHESTRATION_SERVICE_STATUS_FAILED,
+ ORCHESTRATION_SERVICE_STATUS_UNDEFINED_ERROR,
+} orchestration_service_status_e;
+
+typedef struct
+{
+ char *exec_parameter;
+} orchestration_service_info_s;
+
+typedef void (*orchestration_changed_service_status_cb)(orchestration_service_status_e staus, void *user_data);
+
+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);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __ORCHESTRATION_CLIENT_H__ */
+
--- /dev/null
+#include <stdio.h>
+#include <orchestration_client.h>
+
+void status_cb(orchestration_service_status_e staus, void* user_data)
+{
+
+}
+
+int main() {
+ orchestration_service_info_s service_info;
+ service_info.exec_parameter = "param";
+ orchestration_request_service("app_name12312313", service_info, status_cb, NULL);
+ return 0;
+}
\ No newline at end of file
--- /dev/null
+#include <gio/gio.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <dbus_consumer.h>
+
+/* ---------------------------------------------------------------------------------------------------- */
+GDBusConnection *_gdbus_conn;
+gchar* _name_owner;
+
+#define _ORCHESTRATION_BUS_NAME "org.tizen.orchestration"
+#define _ORCHESTRATION_OBJECT_PATH "/org/tizen/orchestration"
+#define _ORCHESTRATION_INTERFACE "org.tizen.orchestration.agent"
+#define _ORCHESTRATION_REQUEST_SERVICE_METHOD "request_service"
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+int dbus_consumer_initailze()
+{
+ GError *error = NULL;
+
+ _gdbus_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (error)
+ {
+ printf ("Failed to get bus access - %i : %s\n", error->code, error->message);
+ g_error_free (error);
+ error = NULL;
+ return ORCH_DBUS_ERROR_FAULT;
+ }
+ return ORCH_DBUS_ERROR_NONE;
+}
+
+int request_service_execute(char* app_name, char* exec_param)
+{
+ GError *error = NULL;
+
+ GVariant *result =
+ g_dbus_connection_call_sync (_gdbus_conn,
+ _ORCHESTRATION_BUS_NAME,
+ _ORCHESTRATION_OBJECT_PATH,
+ _ORCHESTRATION_INTERFACE,
+ _ORCHESTRATION_REQUEST_SERVICE_METHOD,
+ g_variant_new ("(ss)", app_name, exec_param),
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ if (result)
+ g_variant_unref (result);
+
+ if (error)
+ {
+ printf("Failed to call remote method - %i : %s\n", error->code, error->message);
+ g_error_free (error);
+ error = NULL;
+ g_object_unref (_gdbus_conn);
+ return ORCH_DBUS_ERROR_FAULT;
+ }
+
+ return ORCH_DBUS_ERROR_NONE;
+}
\ No newline at end of file
--- /dev/null
+#include <stdlib.h>
+#include <stdio.h>
+#include <orchestration_client.h>
+#include <dbus_consumer.h>
+
+/* ---------------------------------------------------------------------------------------------------- */
+orchestration_changed_service_status_cb _changed_service_status_cb;
+
+#define _ORCHESTRATION_BUS_NAME "org.tizen.orchestration"
+#define _ORCHESTRATION_OBJECT_PATH "/org/tizen/orchestration"
+#define _ORCHESTRATION_INTERFACE "org.tizen.orchestration.agent"
+#define _ORCHESTRATION_REQUEST_SERVICE_METHOD "request_service"
+
+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)
+{
+ int result = 0;
+
+ if (app_name == NULL)
+ {
+ printf("app_name is null\n");
+ return ORCH_CLIENT_ERROR_INVALID_PARAMETER;
+ }
+ if (service_info.exec_parameter == NULL)
+ {
+ printf("service_info is null\n");
+ return ORCH_CLIENT_ERROR_INVALID_PARAMETER;
+ }
+ if (cb == NULL)
+ {
+ printf("orchestration_changed_service_status_cb is null\n");
+ return ORCH_CLIENT_ERROR_INVALID_PARAMETER;
+ }
+ _changed_service_status_cb = cb;
+
+ result = dbus_consumer_initailze();
+ if (result != ORCH_DBUS_ERROR_NONE)
+ {
+ printf("dbus_consumer_initailze failed\n");
+ return ORCH_CLIENT_ERROR_FAULT;
+ }
+
+ result = request_service_execute(app_name, service_info.exec_parameter);
+ if (result != ORCH_DBUS_ERROR_NONE)
+ {
+ printf("request_service_execute failed\n");
+ return ORCH_CLIENT_ERROR_FAULT;
+ }
+
+ return ORCH_CLIENT_ERROR_NONE;
+}
+
"testing"
)
-
const (
serviceName = "ls"
serviceName2 = "main2"