Add internal base component API 23/210023/7
authorhyunho <hhstark.kang@samsung.com>
Mon, 15 Jul 2019 05:47:29 +0000 (14:47 +0900)
committerhyunho <hhstark.kang@samsung.com>
Wed, 24 Jul 2019 04:07:33 +0000 (13:07 +0900)
Change-Id: Iec5367a5bbd74074156388fdefd9a2c9db8c7b67
Signed-off-by: hyunho <hhstark.kang@samsung.com>
17 files changed:
component_based/base/CMakeLists.txt
component_based/base/api/base_component.h [new file with mode: 0644]
component_based/base/api/base_frame_component.h [new file with mode: 0644]
component_based/base/api/base_service_component.h [new file with mode: 0644]
component_based/base/api/component_based_app_base.h [new file with mode: 0644]
component_based/base/api/component_common.h [new file with mode: 0644]
component_based/base/frame_component.cc
component_based/base/frame_window.cc [new file with mode: 0644]
component_based/base/frame_window.h [new file with mode: 0644]
component_based/base/stub.cc [new file with mode: 0644]
component_based/efl_base/CMakeLists.txt
component_based/efl_base/api/component_based_app.h
component_based/efl_base/api/component_common.h [deleted file]
component_based/efl_base/component-based-application.pc.in
component_based/efl_base/stub.cc
packaging/component-based.spec
unit_tests/CMakeLists.txt

index a0725c436baca3d4b86ae21ef38efca990f601a5..ec231f61dd0f2dcd3f7b30fe3823cada061b1b69 100644 (file)
@@ -24,7 +24,7 @@ SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
 SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
 
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../)
-#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/api)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/api)
 
 AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCES)
 ADD_LIBRARY(${PROJECT_NAME} SHARED ${SOURCES})
@@ -46,6 +46,6 @@ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc
 INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
        DESTINATION ${INCLUDE_INSTALL_DIR}/component_based/base
        FILES_MATCHING PATTERN "*.h")
-#INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/api DESTINATION ${INCLUDE_INSTALL_DIR}/component_based/base
-#      FILES_MATCHING PATTERN "*.h")
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/api DESTINATION ${INCLUDE_INSTALL_DIR}/component_based/base
+       FILES_MATCHING PATTERN "*.h")
 
diff --git a/component_based/base/api/base_component.h b/component_based/base/api/base_component.h
new file mode 100644 (file)
index 0000000..753f0e3
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TIZEN_COMPONENT_BASED_BASE_COMPONENT_H__
+#define __TIZEN_COMPONENT_BASED_BASE_COMPONENT_H__
+
+#include <app_control.h>
+#include <bundle.h>
+
+#include <component_common.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void (*base_component_restore_content_cb)(
+               component_h context,
+               bundle *content,
+               void *user_data);
+
+typedef void (*base_component_save_content_cb)(
+               component_h context,
+               bundle *content,
+               void *user_data);
+
+typedef void (*base_component_device_orientation_changed_cb)(
+               component_h context,
+               component_device_orientation_e orientation,
+               void *user_data);
+
+typedef void (*base_component_language_changed_cb)(
+               component_h context,
+               const char *language,
+               void *user_data);
+
+typedef void (*base_component_region_format_changed_cb)(
+               component_h context,
+               const char *region,
+               void *user_data);
+
+typedef void (*base_component_low_battery_cb)(
+               component_h context,
+               component_low_battery_status_e status,
+               void *user_data);
+
+typedef void (*base_component_low_memory_cb)(
+               component_h context,
+               component_low_memory_status_e status,
+               void *user_data);
+
+typedef void (*base_component_suspended_state_changed_cb)(
+               component_h context,
+               component_suspended_state_e state,
+               void *user_data);
+
+typedef struct {
+       base_component_restore_content_cb restore_content;
+       base_component_save_content_cb save_content;
+       base_component_device_orientation_changed_cb device_orientation_changed;
+       base_component_language_changed_cb language_changed;
+       base_component_region_format_changed_cb region_format_changed;
+       base_component_low_battery_cb low_battery;
+       base_component_low_memory_cb low_memory;
+       base_component_suspended_state_changed_cb suspended_state_changed;
+} base_component_lifecycle_callback_s;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_COMPONENT_BASED_BASE_COMPONENT_H__ */
+
diff --git a/component_based/base/api/base_frame_component.h b/component_based/base/api/base_frame_component.h
new file mode 100644 (file)
index 0000000..3ba90e5
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TIZEN_COMPONENT_BASED_BASE_FRAME_COMPONENT_H__
+#define __TIZEN_COMPONENT_BASED_BASE_FRAME_COMPONENT_H__
+
+#include <app_control.h>
+#include <bundle.h>
+
+#include <component_common.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct frame_window_s *frame_window_h;
+
+int base_frame_create_window(frame_window_h *handle, int id, void *raw);
+int base_frame_window_get_id(frame_window_h handle, int *id);
+int base_frame_window_get_raw(frame_window_h handle, void **raw);
+
+typedef frame_window_h (*base_frame_component_create_cb)(
+               component_h context,
+               void *user_data);
+
+typedef void (*base_frame_component_start_cb)(
+               component_h context,
+               app_control_h app_control,
+               bool restarted,
+               void *user_data);
+
+typedef void (*base_frame_component_resume_cb)(
+               component_h context,
+               void *user_data);
+
+typedef void (*base_frame_component_pause_cb)(
+               component_h context,
+               void *user_data);
+
+typedef void (*base_frame_component_stop_cb)(
+               component_h context,
+               void *user_data);
+
+typedef void (*base_frame_component_destroy_cb)(
+               component_h context,
+               void *user_data);
+
+typedef void (*base_frame_component_restore_content_cb)(
+               component_h context,
+               bundle *content,
+               void *user_data);
+
+typedef void (*base_frame_component_save_content_cb)(
+               component_h context,
+               bundle *content,
+               void *user_data);
+
+typedef void (*base_frame_component_action_cb)(
+               component_h context,
+               const char *action,
+               app_control_h app_control,
+               void *user_data);
+
+typedef void (*base_frame_component_device_orientation_changed_cb)(
+               component_h context,
+               component_device_orientation_e orientation,
+               void *user_data);
+
+typedef void (*base_frame_component_language_changed_cb)(
+               component_h context,
+               const char *language,
+               void *user_data);
+
+typedef void (*base_frame_component_region_format_changed_cb)(
+               component_h context,
+               const char *region,
+               void *user_data);
+
+typedef void (*base_frame_component_low_battery_cb)(
+               component_h context,
+               component_low_battery_status_e status,
+               void *user_data);
+
+typedef void (*base_frame_component_low_memory_cb)(
+               component_h context,
+               component_low_memory_status_e status,
+               void *user_data);
+
+typedef void (*base_frame_component_suspended_state_changed_cb)(
+               component_h context,
+               component_suspended_state_e state,
+               void *user_data);
+
+typedef struct {
+       base_frame_component_create_cb create;
+       base_frame_component_start_cb start;
+       base_frame_component_resume_cb resume;
+       base_frame_component_pause_cb pause;
+       base_frame_component_stop_cb stop;
+       base_frame_component_destroy_cb destroy;
+       base_frame_component_restore_content_cb restore_content;
+       base_frame_component_save_content_cb save_content;
+       base_frame_component_action_cb action;
+       base_frame_component_device_orientation_changed_cb device_orientation_changed;
+       base_frame_component_language_changed_cb language_changed;
+       base_frame_component_region_format_changed_cb region_format_changed;
+       base_frame_component_low_battery_cb low_battery;
+       base_frame_component_low_memory_cb low_memory;
+       base_frame_component_suspended_state_changed_cb suspended_state_changed;
+} base_frame_component_lifecycle_callback_s;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_COMPONENT_BASED_BASE_FRAME_COMPONENT_H__ */
+
diff --git a/component_based/base/api/base_service_component.h b/component_based/base/api/base_service_component.h
new file mode 100644 (file)
index 0000000..0f2cace
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TIZEN_COMPONENT_BASED_BASE_SERVICE_COMPONENT_H__
+#define __TIZEN_COMPONENT_BASED_BASE_SERVICE_COMPONENT_H__
+
+#include <app_control.h>
+#include <bundle.h>
+
+#include <component_common.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef bool(*base_service_component_create_cb)(
+               component_h context,
+               void *user_data);
+
+typedef void (*base_service_component_start_command_cb)(
+               component_h context,
+               app_control_h app_control,
+               bool restarted,
+               void *user_data);
+
+typedef void (*base_service_component_destroy_cb)(
+               component_h context,
+               void *user_data);
+
+typedef void (*base_service_component_restore_content_cb)(
+               component_h context,
+               bundle *content,
+               void *user_data);
+
+typedef void (*base_service_component_save_content_cb)(
+               component_h context,
+               bundle *content,
+               void *user_data);
+
+typedef void (*base_service_component_action_cb)(
+               component_h context,
+               const char *action,
+               app_control_h app_control,
+               void *user_data);
+
+typedef void (*base_service_component_device_orientation_changed_cb)(
+               component_h context,
+               component_device_orientation_e orientation,
+               void *user_data);
+
+typedef void (*base_service_component_language_changed_cb)(
+               component_h context,
+               const char *language,
+               void *user_data);
+
+typedef void (*base_service_component_region_format_changed_cb)(
+               component_h context,
+               const char *region,
+               void *user_data);
+
+typedef void (*base_service_component_low_battery_cb)(
+               component_h context,
+               component_low_battery_status_e status,
+               void *user_data);
+
+typedef void (*base_service_component_low_memory_cb)(
+               component_h context,
+               component_low_memory_status_e status,
+               void *user_data);
+
+typedef void (*base_service_component_suspended_state_changed_cb)(
+               component_h context,
+               component_suspended_state_e state,
+               void *user_data);
+
+typedef struct {
+       base_service_component_create_cb create;
+       base_service_component_start_command_cb start_command;
+       base_service_component_destroy_cb destroy;
+       base_service_component_restore_content_cb restore_content;
+       base_service_component_save_content_cb save_content;
+       base_service_component_action_cb action;
+       base_service_component_device_orientation_changed_cb device_orientation_changed;
+       base_service_component_language_changed_cb language_changed;
+       base_service_component_region_format_changed_cb region_format_changed;
+       base_service_component_low_battery_cb low_battery;
+       base_service_component_low_memory_cb low_memory;
+       base_service_component_suspended_state_changed_cb suspended_state_changed;
+} base_service_component_lifecycle_callback_s;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_COMPONENT_BASED_BASE_SERVICE_COMPONENT_H__ */
+
diff --git a/component_based/base/api/component_based_app_base.h b/component_based/base/api/component_based_app_base.h
new file mode 100644 (file)
index 0000000..ced8b5a
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TIZEN_COMPONENT_BASED_BASE_APPLICATION_H__
+#define __TIZEN_COMPONENT_BASED_BASE_APPLICATION_H__
+
+#include <app_common.h>
+
+#include <component_common.h>
+#include <base_frame_component.h>
+#include <base_service_component.h>
+#include <base_component.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void (*component_based_app_base_init_cb)(int argc, char **argv, void *user_data);
+typedef void (*component_based_app_base_fini_cb)(void *user_data);
+typedef void (*component_based_app_base_run_cb)(void *user_data);
+typedef void (*component_based_app_base_exit_cb)(void *user_data);
+typedef component_class_h (*component_based_app_base_create_cb)(void *user_data);
+typedef void (*component_based_app_base_terminate_cb)(void *user_data);
+
+typedef enum {
+       COMPONENT_TYPE_FRAME,
+       COMPONENT_TYPE_SERVICE,
+} component_type_e;
+
+typedef struct {
+       component_based_app_base_init_cb init;
+       component_based_app_base_fini_cb fini;
+       component_based_app_base_run_cb run;
+       component_based_app_base_exit_cb exit;
+       component_based_app_base_create_cb create;
+       component_based_app_base_terminate_cb terminate;
+} component_based_app_base_lifecycle_callback_s;
+
+int component_based_app_base_main(int argc, char **argv,
+               component_based_app_base_lifecycle_callback_s *callback,
+               void *user_data);
+
+int component_based_app_base_exit(void);
+
+component_class_h component_based_app_base_add_frame_component(
+               component_class_h comp_class,
+               const char *comp_id,
+               base_frame_component_lifecycle_callback_s *callback,
+               void *user_data);
+
+component_class_h component_based_app_base_add_service_component(
+               component_class_h comp_class,
+               const char *comp_id,
+               base_service_component_lifecycle_callback_s *callback,
+               void *user_data);
+
+component_class_h component_based_app_base_add_base_component(
+               component_class_h comp_class,
+               component_type_e type,
+               const char *comp_id,
+               base_component_lifecycle_callback_s *callback,
+               void *user_data);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __TIZEN_COMPONENT_BASED_BASE_APPLICATION_H__ */
+
diff --git a/component_based/base/api/component_common.h b/component_based/base/api/component_common.h
new file mode 100644 (file)
index 0000000..58aa6d3
--- /dev/null
@@ -0,0 +1,269 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TIZEN_COMPONENT_BASED_COMPONENT_COMMON_H__
+#define __TIZEN_COMPONENT_BASED_COMPONENT_COMMON_H__
+
+#include <tizen.h>
+#include <app_control.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef TIZEN_ERROR_COMPONENT
+#define TIZEN_ERROR_COMPONENT -0x03030000
+#endif
+
+/**
+ * @addtogroup COMPONENT_BASED_COMPONENT_COMMON_MODULE
+ * @{
+ */
+
+
+/**
+ * @brief Enumeration for component error.
+ * @since_tizen 5.5
+ */
+typedef enum {
+       COMPONENT_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+       COMPONENT_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+       COMPONENT_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+       COMPONENT_ERROR_INVALID_CONTEXT = TIZEN_ERROR_COMPONENT | 0x01, /**< Invalid component context */
+       COMPONENT_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */
+       COMPONENT_ERROR_NOT_FOUND = TIZEN_ERROR_COMPONENT | 0x02, /**< Not found */
+       COMPONENT_ERROR_LAUNCH_REJECTED = TIZEN_ERROR_COMPONENT | 0x03, /**< The application cannot be launched now */
+       COMPONENT_ERROR_LAUNCH_FAILED = TIZEN_ERROR_COMPONENT | 0x04, /**< Internal launch error */
+       COMPONENT_ERROR_TIMED_OUT = TIZEN_ERROR_TIMED_OUT, /**< Time out */
+       COMPONENT_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
+} component_error_e;
+
+/**
+ * @brief Enumeration for device orientation.
+ * @since_tizen 5.5
+ */
+typedef enum {
+       COMPONENT_DEVICE_ORIENTATION_0 = 0, /**< The device is oriented in a natural position */
+       COMPONENT_DEVICE_ORIENTATION_90 = 90, /**< The device's left side is at the top */
+       COMPONENT_DEVICE_ORIENTATION_180 = 180, /**< The device is upside down */
+       COMPONENT_DEVICE_ORIENTATION_270 = 270, /**< The device's right side is at the top */
+} component_device_orientation_e;
+
+/**
+ * @brief Enumeration for low memory status.
+ * @since_tizen 5.5
+ */
+typedef enum {
+       COMPONENT_LOW_MEMORY_NONE = 0x00, /**< None */
+       COMPONENT_LOW_MEMORY_NORMAL = 0x01, /**< Normal status */
+       COMPONENT_LOW_MEMORY_SOFT_WARNING = 0x02, /**< Soft warning status */
+       COMPONENT_LOW_MEMORY_HARD_WARNING = 0x04, /**< Hard warning status */
+} component_low_memory_status_e;
+
+/**
+ * @brief Enumeration for battery status.
+ * @since_tizen 5.5
+ */
+typedef enum {
+       COMPONENT_LOW_BATTERY_NONE, /**< None */
+       COMPONENT_LOW_BATTERY_POWER_OFF, /**< The battery status is under 1% */
+       COMPONENT_LOW_BATTERY_CRITICAL_LOW, /**< The battery status is under 5% */
+} component_low_battery_status_e;
+
+/**
+ * @brief Enumeration for suspended state.
+ * @since_tizen 5.5
+ */
+typedef enum {
+       COMPONENT_SUSPENDED_STATE_WILL_ENTER = 0, /**< The component will enter the suspended state */
+       COMPONENT_SUSPENDED_STATE_DID_EXIT, /**< The component did exit from the suspended state */
+} component_suspended_state_e;
+
+/**
+ * @brief Enumeration for display status.
+ * @since_tizen 5.5
+ */
+typedef enum {
+        COMPONENT_DISPLAY_STATUS_ON, /**< The display status is on */
+        COMPONENT_DISPLAY_STATUS_OFF, /**< The display status is off */
+} component_display_status_e;
+
+/**
+ * @brief The component class handle.
+ * @since_tizen 5.5
+ */
+typedef void *component_class_h;
+
+/**
+ * @brief The component context handle.
+ * @since_tizen 5.5
+ */
+typedef void *component_h;
+
+/**
+ * @brief Gets the ID of the component.
+ * @since_tizen 5.5
+ * @remarks @c id must be released using free().
+ *
+ * @param[in]   context         The context of the component instance
+ * @param[out]  id              The ID of the component
+ * @return      @c 0 on success,
+ *              otherwise a negative error value
+ * @retval #COMPONENT_ERROR_NONE Successful
+ * @retval #COMPONENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #COMPONENT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int component_get_id(component_h context, char **id);
+
+/**
+ * @brief Gets the instance ID of the component.
+ * @since_tizen 5.5
+ * @remarks @c instance_id must be released using free().
+ *
+ * @param[in]   context         The context of the component instance
+ * @param[out]  instance_id     The instance ID of the component
+ * @return      @c 0 on success,
+ *              otherwise a negative error value
+ * @retval #COMPONENT_ERROR_NONE Successful
+ * @retval #COMPONENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #COMPONENT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int component_get_instance_id(component_h context, char **instance_id);
+
+/**
+ * @brief Registers the app_control action.
+ * @details This function is for handling each application control action.
+ *          @a action must match id attribute of app_control element in the tizen-manifest.xml.
+ * @since_tizen 5.5
+ *
+ * @param[in]   context         The context of the component instance
+ * @param[in]   action          The name of the app_control action
+ *
+ * @return      @c 0 on success,
+ *              otherwise a negative error value
+ * @retval #COMPONENT_ERROR_NONE Successful
+ * @retval #COMPONENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see frame_component_action_cb()
+ * @see component_deregister_action()
+ */
+int component_register_action(component_h context, const char *action);
+
+/**
+ * @brief Deregisters the registered app_control action.
+ * @since_tizen 5.5
+ *
+ * @param[in]   context         The context of the component instance
+ * @param[in]   action          The name of the app_control action
+ *
+ * @return      @c 0 on success,
+ *              otherwise a negative error value
+ * @retval #COMPONENT_ERROR_NONE Successful
+ * @retval #COMPONENT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int component_deregister_action(component_h context,
+               const char *action);
+
+/**
+ * @brief Sends the launch request asynchronously.
+ * @defails To use group mode, you must use this function instead of app_control_send_launch_request_async().
+ * @since_tizen 5.5
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/appmanager.launch
+ *
+ * @param[in]   context         The context of the component instance
+ * @param[in]   app_control     The app_control handle
+ * @param[in]   result_cb       The callback function to be called when the result is delivered
+ * @param[in]   reply_cb        The callback function to be called when the reply is delivered
+ * @param[in]   user_data       The user data to be passed to the callback function
+ *
+ * @return      @c 0 on success,
+ *              otherwise a negative error value
+ * @retval #COMPONENT_ERROR_NONE Successful
+ * @retval #COMPONENT_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #COMPONENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #COMPONENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #COMPONENT_ERROR_NOT_FOUND The application to run the given launch request is not found
+ * @retval #COMPONENT_ERROR_LAUNCH_REJECTED The application cannot be launched in current context
+ * @retval #COMPONENT_ERROR_LAUNCH_FAILED Failed to launch the application
+ * @retval #COMPONENT_ERROR_TIMED_OUT Failed due to timeout. The application that handles @a app_control may be busy
+ * @see app_control_result_cb()
+ * @see app_control_reply_to_launch_request()
+ * @see app_control_reply_cb()
+ * @see app_control_enable_app_started_result_event()
+ * @see app_control_send_launch_request_async()
+ */
+int component_send_launch_request_async(component_h context,
+               app_control_h app_control,
+                app_control_result_cb result_cb,
+                app_control_reply_cb reply_cb,
+                void *user_data);
+
+/**
+ * @brief Sends the launch request synchronously.
+ * @details To use group mode, you must use this function instead of app_control_send_launch_request_sync().
+ * @since_tizen 5.5
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/appmanager.launch
+ * @remarks The @a reply must be released using app_control_destroy().
+ *
+ * @param[in]   context         The context of the component instance
+ * @param[in]   app_control     The app_control handle
+ * @param[out]  reply           The app_control handle in which the results of the callee are contained
+ * @param[out]  result          The result code of the launch request
+ *
+ * @return      @c 0 on success,
+ *              otherwise a negative error value
+ * @retval #COMPONENT_ERROR_NONE Successful
+ * @retval #COMPONENT_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #COMPONENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #COMPONENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #COMPONENT_ERROR_NOT_FOUND The application to run the given launch request is not found
+ * @retval #COMPONENT_ERROR_LAUNCH_REJECTED The application cannot be launched in current context
+ * @retval #COMPONENT_ERROR_LAUNCH_FAILED Failed to launch the application
+ * @retval #COMPONENT_ERROR_TIMED_OUT Failed due to timeout. The application that handles @a app_control may be busy
+ * @see app_control_destroy()
+ * @see app_control_send_launch_request_sync()
+ */
+int component_send_launch_request_sync(component_h context,
+                app_control_h app_control,
+                app_control_h *reply,
+               app_control_result_e *result);
+
+/**
+ * @brief Finishes the component instance.
+ * @since_tizen 5.5
+ *
+ * @param[in]   context         The context of the component instance
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #COMPONENT_ERROR_NONE Successful
+ * @retval #COMPONENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see frame_component_destroy_cb()
+ * @see service_component_destroy_cb()
+ */
+int component_finish(component_h context);
+
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __TIZEN_COMPONENT_BASED_COMPONENT_COMMON_H__ */
+
index d003277db4a6bbec3787c5c6f8deb31397fb0aa3..1aafc981b9f9fae813173d3bdfb461bc0b2f43c8 100644 (file)
@@ -78,13 +78,12 @@ void FrameComponent::OnBaseDestroy() {
 }
 
 void FrameComponent::OnBaseStart(AppControl control, bool restarted) {
-    tizen_base::Bundle content = GetContent();
-    OnBaseRestoreContent(content);
-    OnStart(control, restarted);
+  tizen_base::Bundle content = GetContent();
+  OnBaseRestoreContent(content);
+  OnStart(control, restarted);
 }
 
 void FrameComponent::OnBaseResume() {
-
   if (GetState() == State::Paused ||
       GetState() == State::Started ||
       GetState() == State::Stopped) {
diff --git a/component_based/base/frame_window.cc b/component_based/base/frame_window.cc
new file mode 100644 (file)
index 0000000..79fec95
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "component_based/base/frame_window.h"
+
+namespace component_based {
+
+FrameWindow::FrameWindow(int id, void* raw) : id_(id), raw_(raw) {
+}
+
+FrameWindow::~FrameWindow() {
+
+}
+
+int FrameWindow::GetResID() const {
+  return id_;
+}
+
+void* FrameWindow::GetRaw() {
+  return raw_;
+}
+
+}  // namespace component_based
diff --git a/component_based/base/frame_window.h b/component_based/base/frame_window.h
new file mode 100644 (file)
index 0000000..20ab243
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef COMPONENT_BASED_BASE_FRAME_WINDOW_H_
+#define COMPONENT_BASED_BASE_FRAME_WINDOW_H_
+
+#include <string>
+
+#include "component_based/base/window_interface.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+namespace component_based {
+
+class EXPORT_API FrameWindow : public IWindow {
+ public:
+  FrameWindow(int id, void* raw);
+  virtual ~FrameWindow();
+
+  int GetResID() const override;
+  void* GetRaw() override;
+
+ private:
+  int id_;
+  void* raw_ = nullptr;
+};
+
+}  // namespace component_based
+
+#endif  // COMPONENT_BASED_BASE_FRAME_WINDOW_H_
diff --git a/component_based/base/stub.cc b/component_based/base/stub.cc
new file mode 100644 (file)
index 0000000..8e2690a
--- /dev/null
@@ -0,0 +1,896 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dlog.h>
+#include <glib.h>
+#include <unistd.h>
+#include <app_control_internal.h>
+
+#include <list>
+
+#include "component_based/base/api/component_common.h"
+#include "component_based/common/exception.h"
+#include "component_based/base/component.h"
+#include "component_based/base/frame_window.h"
+#include "component_based/base/frame_component.h"
+#include "component_based/base/service_component.h"
+#include "component_based/base/application_base.h"
+#include "component_based/base/api/component_based_app_base.h"
+#include "component_based/base/api/base_component.h"
+#include "component_based/base/api/base_frame_component.h"
+#include "component_based/base/api/base_service_component.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "CAPI_COMPONENT_BASED_APPLICATION"
+
+#ifdef EXPORT_API
+#undef EXPORT_API
+#endif
+#define EXPORT_API __attribute__((visibility("default")))
+
+struct frame_window_s {
+  int id;
+  void* raw;
+};
+
+namespace {
+
+class ComponentClass {
+ public:
+  void Add(std::string comp_id,
+           std::unique_ptr<component_based::Component::Factory> factory) {
+    auto iter = facs_.find(comp_id);
+    if (iter != facs_.end())
+      LOGW("Already exists");
+
+    facs_[comp_id] = std::move(factory);
+  }
+
+  std::map<std::string, std::unique_ptr<component_based::Component::Factory>>
+  Detach() {
+    return std::move(facs_);
+  }
+
+ private:
+  std::map<std::string, std::unique_ptr<component_based::Component::Factory>> facs_;
+};
+
+class StubApplicationBase : public component_based::ApplicationBase {
+ private:
+  StubApplicationBase() = default;
+  ~StubApplicationBase() = default;
+
+ public:
+  enum class State {
+    LAUNCHED,
+    CREATED,
+    RUNNING,
+    DYING,
+  };
+
+  static StubApplicationBase& GetInst() {
+    static StubApplicationBase inst;
+    return inst;
+  }
+
+  void SetLifecycleCallback(component_based_app_base_lifecycle_callback_s cb) {
+    cb_ = cb;
+  }
+
+  void SetUserData(void* user_data) {
+    user_data_ = user_data;
+  }
+
+  State GetState() {
+    return state_;
+  }
+
+ private:
+  void OnInit(int argc, char** argv) override {
+    component_based::ApplicationBase::OnInit(argc, argv);
+    if (cb_.init)
+      cb_.init(argc, argv, user_data_);
+  }
+
+  void OnFini() override {
+    state_ = State::DYING;
+    component_based::ApplicationBase::OnFini();
+    if (cb_.fini)
+      cb_.fini(user_data_);
+  }
+
+  void OnRun() override {
+    state_ = State::RUNNING;
+    component_based::ApplicationBase::OnRun();
+    if (cb_.run)
+      cb_.run(user_data_);
+  }
+
+  void OnExit() override {
+    component_based::ApplicationBase::OnExit();
+    if (cb_.exit)
+      cb_.exit(user_data_);
+  }
+
+  std::map<std::string, std::unique_ptr<component_based::Component::Factory>>
+  OnCreate() override {
+    std::map<std::string, std::unique_ptr<component_based::Component::Factory>> facs;
+    component_class_h h = nullptr;
+    if (cb_.create)
+      h = cb_.create(user_data_);
+
+    if (h == nullptr)
+      return facs;
+
+    auto cls = static_cast<ComponentClass*>(h);
+    facs = std::move(cls->Detach());
+    delete cls;
+
+    state_ = State::CREATED;
+    return facs;
+  }
+
+  void OnTerminate() override {
+    if (cb_.terminate)
+      cb_.terminate(user_data_);
+  }
+
+ private:
+  State state_ = State::LAUNCHED;
+  component_based_app_base_lifecycle_callback_s cb_;
+  void* user_data_;
+};
+
+class StubBaseComponent : public component_based::Component {
+ public:
+  class Factory : public component_based::Component::Factory {
+   public:
+    Factory(component_type_e type, base_component_lifecycle_callback_s cb, void* user_data)
+      : type_(type), cb_(cb), user_data_(user_data) {
+    }
+
+    std::unique_ptr<component_based::Component> Create(std::string comp_id,
+        std::string inst_id) override {
+      return std::unique_ptr<component_based::Component>(
+          new (std::nothrow) StubBaseComponent(type_,
+            std::move(comp_id), std::move(inst_id), cb_, user_data_));
+    }
+
+   private:
+    component_type_e type_;
+    base_component_lifecycle_callback_s cb_;
+    void* user_data_;
+  };
+
+  StubBaseComponent(component_type_e type, std::string comp_id,
+                     std::string inst_id,
+                     base_component_lifecycle_callback_s cb,
+                     void* user_data)
+    : component_based::Component((component_based::Component::Type)type,
+      std::move(comp_id),
+      std::move(inst_id)),
+      cb_(cb),
+      user_data_(user_data) {
+  }
+
+  ~StubBaseComponent() = default;
+
+ public:
+
+  void OnBaseRestoreContent(tizen_base::Bundle content) override {
+    if (cb_.restore_content)
+      cb_.restore_content(this, content.GetHandle(), user_data_);
+  }
+
+  void OnBaseSaveContent(tizen_base::Bundle& content) override {
+    if (cb_.save_content)
+      cb_.save_content(this, content.GetHandle(), user_data_);
+  }
+
+  void OnBaseDeviceOrientationChanged(
+      component_based::DeviceOrientation::Orientation orientation) override {
+    if (cb_.device_orientation_changed) {
+      cb_.device_orientation_changed(this,
+          static_cast<component_device_orientation_e>(orientation),
+          user_data_);
+    }
+  }
+
+  void OnBaseLanguageChanged(std::string language) override {
+    if (cb_.language_changed)
+      cb_.language_changed(this, language.c_str(), user_data_);
+  }
+
+  void OnBaseRegionFormatChanged(std::string region) override {
+    if (cb_.region_format_changed)
+      cb_.region_format_changed(this, region.c_str(), user_data_);
+  }
+
+  void OnBaseLowBattery(component_based::LowBattery::Status status) override {
+    if (cb_.low_battery) {
+      cb_.low_battery(this,
+          static_cast<component_low_battery_status_e>(status),
+          user_data_);
+    }
+  }
+
+  void OnBaseLowMemory(component_based::LowMemory::Status status) override {
+    if (cb_.low_memory) {
+      cb_.low_memory(this,
+          static_cast<component_low_memory_status_e>(status),
+          user_data_);
+    }
+  }
+
+  void OnBaseSuspendedStateChanged(
+      component_based::SuspendedState::State state) override {
+    if (cb_.suspended_state_changed) {
+      cb_.suspended_state_changed(this,
+          static_cast<component_suspended_state_e>(state),
+          user_data_);
+    }
+  }
+
+ private:
+  base_component_lifecycle_callback_s cb_;
+  void* user_data_;
+};
+
+class StubFrameComponent : public component_based::FrameComponent {
+ public:
+  class Factory : public component_based::FrameComponent::Factory {
+   public:
+    Factory(base_frame_component_lifecycle_callback_s cb, void* user_data)
+      : cb_(cb), user_data_(user_data) {
+    }
+
+    std::unique_ptr<component_based::Component> Create(std::string comp_id,
+        std::string inst_id) override {
+      return std::unique_ptr<component_based::Component>(
+          new (std::nothrow) StubFrameComponent(
+            std::move(comp_id), std::move(inst_id), cb_, user_data_));
+    }
+
+   private:
+    base_frame_component_lifecycle_callback_s cb_;
+    void* user_data_;
+  };
+
+  StubFrameComponent(std::string comp_id,
+                     std::string inst_id,
+                     base_frame_component_lifecycle_callback_s cb,
+                     void* user_data)
+    : component_based::FrameComponent(std::move(comp_id), std::move(inst_id)),
+      cb_(cb),
+      user_data_(user_data) {
+  }
+
+  ~StubFrameComponent() = default;
+
+ public:
+  std::unique_ptr<component_based::IWindow> OnCreate() override {
+    frame_window_h win = cb_.create(this, user_data_);
+    if (win == nullptr) {
+      LOGE("window is nullptr");
+      return nullptr;
+    }
+
+    component_based::FrameWindow* frm_win =
+        new (std::nothrow) component_based::FrameWindow(win->id, win->raw);
+    if (frm_win == nullptr) {
+      LOGE("Out of memory");
+      return nullptr;
+    }
+
+    return std::unique_ptr<component_based::IWindow>(
+        static_cast<component_based::IWindow*>(frm_win));
+  }
+
+  void OnStart(component_based::AppControl app_control,
+               bool restarted) override {
+    if (cb_.start)
+      cb_.start(this, app_control.GetHandle(), restarted, user_data_);
+  }
+
+  void OnResume() override {
+    if (cb_.resume)
+      cb_.resume(this, user_data_);
+  }
+
+  void OnPause() override {
+    if (cb_.pause)
+      cb_.pause(this, user_data_);
+  }
+
+  void OnStop() override {
+    if (cb_.stop)
+      cb_.stop(this, user_data_);
+  }
+
+  void OnDestroy() override {
+    if (cb_.destroy)
+      cb_.destroy(this, user_data_);
+  }
+
+  void OnBaseRestoreContent(tizen_base::Bundle content) override {
+    if (cb_.restore_content)
+      cb_.restore_content(this, content.GetHandle(), user_data_);
+  }
+
+  void OnBaseSaveContent(tizen_base::Bundle& content) override {
+    if (cb_.save_content)
+      cb_.save_content(this, content.GetHandle(), user_data_);
+  }
+
+  void OnBaseAction(std::string action,
+                component_based::AppControl app_control) override {
+    if (cb_.action)
+      cb_.action(this, action.c_str(), app_control.GetHandle(), user_data_);
+  }
+
+  void OnBaseDeviceOrientationChanged(
+      component_based::DeviceOrientation::Orientation orientation) override {
+    if (cb_.device_orientation_changed) {
+      cb_.device_orientation_changed(this,
+          static_cast<component_device_orientation_e>(orientation),
+          user_data_);
+    }
+  }
+
+  void OnBaseLanguageChanged(std::string language) override {
+    if (cb_.language_changed)
+      cb_.language_changed(this, language.c_str(), user_data_);
+  }
+
+  void OnBaseRegionFormatChanged(std::string region) override {
+    if (cb_.region_format_changed)
+      cb_.region_format_changed(this, region.c_str(), user_data_);
+  }
+
+  void OnBaseLowBattery(component_based::LowBattery::Status status) override {
+    if (cb_.low_battery) {
+      cb_.low_battery(this,
+          static_cast<component_low_battery_status_e>(status),
+          user_data_);
+    }
+  }
+
+  void OnBaseLowMemory(component_based::LowMemory::Status status) override {
+    if (cb_.low_memory) {
+      cb_.low_memory(this,
+          static_cast<component_low_memory_status_e>(status),
+          user_data_);
+    }
+  }
+
+  void OnBaseSuspendedStateChanged(
+      component_based::SuspendedState::State state) override {
+    if (cb_.suspended_state_changed) {
+      cb_.suspended_state_changed(this,
+          static_cast<component_suspended_state_e>(state),
+          user_data_);
+    }
+  }
+
+ private:
+  base_frame_component_lifecycle_callback_s cb_;
+  void* user_data_;
+};
+
+class StubServiceComponent : public component_based::ServiceComponent {
+ public:
+  class Factory : public component_based::ServiceComponent::Factory {
+   public:
+    Factory(base_service_component_lifecycle_callback_s cb, void* user_data)
+      : cb_(cb), user_data_(user_data) {
+    }
+
+    std::unique_ptr<component_based::Component> Create(std::string comp_id,
+        std::string inst_id) override {
+      return std::unique_ptr<component_based::Component>(
+          new (std::nothrow) StubServiceComponent(std::move(comp_id),
+              std::move(inst_id), cb_, user_data_));
+    }
+
+   private:
+    base_service_component_lifecycle_callback_s cb_;
+    void* user_data_;
+  };
+
+  StubServiceComponent(std::string comp_id,
+                       std::string inst_id,
+                       base_service_component_lifecycle_callback_s cb,
+                       void* user_data)
+    : component_based::ServiceComponent(std::move(comp_id), std::move(inst_id)),
+      cb_(cb),
+      user_data_(user_data) {
+  }
+
+  ~StubServiceComponent() = default;
+
+ public:
+  bool OnCreate() override {
+    return cb_.create(this, user_data_);
+  }
+
+  void OnStartCommand(component_based::AppControl app_control,
+                      bool restarted) override {
+    if (cb_.start_command)
+      cb_.start_command(this, app_control.GetHandle(), restarted, user_data_);
+  }
+
+  void OnDestroy() override {
+    if (cb_.destroy)
+      cb_.destroy(this, user_data_);
+  }
+
+  void OnBaseRestoreContent(tizen_base::Bundle content) override {
+    if (cb_.restore_content)
+      cb_.restore_content(this, content.GetHandle(), user_data_);
+  }
+
+  void OnBaseSaveContent(tizen_base::Bundle& content) override {
+    if (cb_.save_content)
+      cb_.save_content(this, content.GetHandle(), user_data_);
+  }
+
+  void OnBaseAction(std::string action,
+                component_based::AppControl app_control) override {
+    if (cb_.action)
+      cb_.action(this, action.c_str(), app_control.GetHandle(), user_data_);
+  }
+
+  void OnBaseDeviceOrientationChanged(
+      component_based::DeviceOrientation::Orientation orientation) override {
+    if (cb_.device_orientation_changed) {
+      cb_.device_orientation_changed(this,
+          static_cast<component_device_orientation_e>(orientation),
+          user_data_);
+    }
+  }
+
+  void OnBaseLanguageChanged(std::string language) override {
+    if (cb_.language_changed)
+      cb_.language_changed(this, language.c_str(), user_data_);
+  }
+
+  void OnBaseRegionFormatChanged(std::string region) override {
+    if (cb_.region_format_changed)
+      cb_.region_format_changed(this, region.c_str(), user_data_);
+  }
+
+  void OnBaseLowBattery(component_based::LowBattery::Status status) override {
+    if (cb_.low_battery) {
+      cb_.low_battery(this,
+          static_cast<component_low_battery_status_e>(status),
+          user_data_);
+    }
+  }
+
+  void OnBaseLowMemory(component_based::LowMemory::Status status) override {
+    if (cb_.low_memory) {
+      cb_.low_memory(this,
+          static_cast<component_low_memory_status_e>(status),
+          user_data_);
+    }
+  }
+
+  void OnBaseSuspendedStateChanged(
+      component_based::SuspendedState::State state) override {
+    if (cb_.suspended_state_changed) {
+      cb_.suspended_state_changed(this,
+          static_cast<component_suspended_state_e>(state),
+          user_data_);
+    }
+  }
+
+ private:
+  base_service_component_lifecycle_callback_s cb_;
+  void* user_data_;
+};
+
+}  // namespace
+
+extern "C" EXPORT_API int base_frame_create_window(frame_window_h* handle,
+    int id, void* raw) {
+  if (handle == nullptr || raw == nullptr) {
+    LOGE("Invalid parameter");
+    return COMPONENT_ERROR_INVALID_PARAMETER;
+  }
+
+  frame_window_h h = (frame_window_h)calloc(1, sizeof(struct frame_window_s));
+  if (h == nullptr) {
+    LOGE("Out of memory");
+    return COMPONENT_ERROR_OUT_OF_MEMORY;
+  }
+  h->id = id;
+  h->raw = raw;
+  *handle = h;
+
+  return COMPONENT_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int base_frame_window_get_id(frame_window_h handle,
+    int* id) {
+  if (handle == nullptr || id == nullptr) {
+    LOGE("Invalid parameter");
+    return COMPONENT_ERROR_INVALID_PARAMETER;
+  }
+  *id = handle->id;
+  return COMPONENT_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int base_frame_window_get_raw(frame_window_h handle,
+    void** raw) {
+  if (handle == nullptr || raw == nullptr) {
+    LOGE("Invalid parameter");
+    return COMPONENT_ERROR_INVALID_PARAMETER;
+  }
+  *raw = handle->raw;
+  return COMPONENT_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int component_based_app_base_main(int argc, char** argv,
+    component_based_app_base_lifecycle_callback_s *callback, void* user_data) {
+  if (argc < 1 || argv == nullptr || !callback || !callback->create) {
+    LOGE("Invalid parameter");
+    return APP_ERROR_INVALID_PARAMETER;
+  }
+
+  auto& inst = ::StubApplicationBase::GetInst();
+  if (inst.GetState() == ::StubApplicationBase::State::RUNNING) {
+    LOGE("Already running");
+    return APP_ERROR_ALREADY_RUNNING;
+  }
+
+  inst.SetLifecycleCallback(*callback);
+  inst.SetUserData(user_data);
+
+  inst.Run(argc, argv);
+
+  return APP_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int component_based_app_base_exit(void) {
+  auto& inst = ::StubApplicationBase::GetInst();
+  inst.Exit();
+  return APP_ERROR_NONE;
+}
+
+extern "C" EXPORT_API component_class_h
+component_based_app_base_add_frame_component(
+    component_class_h comp_class,
+    const char* comp_id,
+    base_frame_component_lifecycle_callback_s* callback,
+    void* user_data) {
+  if (comp_id == nullptr || callback == nullptr) {
+    LOGE("Invalid parameter");
+    set_last_result(APP_ERROR_INVALID_PARAMETER);
+    return nullptr;
+  }
+
+  if (callback->create == nullptr) {
+    LOGE("Invalid parameter");
+    set_last_result(APP_ERROR_INVALID_PARAMETER);
+    return nullptr;
+  }
+
+  ::ComponentClass* handle;
+  if (comp_class == nullptr) {
+    handle = new (std::nothrow) ::ComponentClass();
+    if (handle == nullptr) {
+      LOGE("Out of memory");
+      set_last_result(APP_ERROR_OUT_OF_MEMORY);
+      return nullptr;
+    }
+  } else {
+    handle = static_cast<::ComponentClass*>(comp_class);
+  }
+
+  ::StubFrameComponent::Factory* factory =
+      new (std::nothrow) ::StubFrameComponent::Factory(*callback, user_data);
+  if (factory == nullptr) {
+    LOGE("Out of memory");
+    set_last_result(APP_ERROR_OUT_OF_MEMORY);
+    return nullptr;
+  }
+
+  handle->Add(comp_id,
+      std::unique_ptr<component_based::Component::Factory>(factory));
+
+  comp_class = static_cast<component_class_h>(handle);
+  return comp_class;
+}
+
+extern "C" EXPORT_API component_class_h
+component_based_app_base_add_service_component(
+    component_class_h comp_class,
+    const char* comp_id,
+    base_service_component_lifecycle_callback_s* callback,
+    void* user_data) {
+  if (comp_id == nullptr || callback == nullptr) {
+    LOGE("Invalid parameter");
+    set_last_result(APP_ERROR_INVALID_PARAMETER);
+    return nullptr;
+  }
+
+  if (callback->create == nullptr) {
+    LOGE("Invalid parameter");
+    set_last_result(APP_ERROR_INVALID_PARAMETER);
+    return nullptr;
+  }
+
+  ::ComponentClass* handle;
+  if (comp_class == nullptr) {
+    handle = new ::ComponentClass();
+    if (handle == nullptr) {
+      LOGE("Out of memory");
+      set_last_result(APP_ERROR_OUT_OF_MEMORY);
+      return nullptr;
+    }
+  } else {
+    handle = static_cast<::ComponentClass*>(comp_class);
+  }
+
+  ::StubServiceComponent::Factory* factory =
+      new (std::nothrow) ::StubServiceComponent::Factory(*callback, user_data);
+  if (factory == nullptr) {
+    LOGE("Out of memory");
+    set_last_result(APP_ERROR_OUT_OF_MEMORY);
+    return nullptr;
+  }
+
+  handle->Add(comp_id,
+      std::unique_ptr<component_based::Component::Factory>(factory));
+
+  comp_class = static_cast<component_class_h>(handle);
+  return comp_class;
+}
+
+extern "C" EXPORT_API component_class_h
+component_based_app_base_add_base_component(
+    component_class_h comp_class,
+    component_type_e type,
+    const char* comp_id,
+    base_component_lifecycle_callback_s* callback,
+    void* user_data) {
+  if (comp_id == nullptr || callback == nullptr) {
+    LOGE("Invalid parameter");
+    set_last_result(APP_ERROR_INVALID_PARAMETER);
+    return nullptr;
+  }
+
+  ::ComponentClass* handle;
+  if (comp_class == nullptr) {
+    handle = new ::ComponentClass();
+    if (handle == nullptr) {
+      LOGE("Out of memory");
+      set_last_result(APP_ERROR_OUT_OF_MEMORY);
+      return nullptr;
+    }
+  } else {
+    handle = static_cast<::ComponentClass*>(comp_class);
+  }
+
+  ::StubBaseComponent::Factory* factory =
+      new (std::nothrow) ::StubBaseComponent::Factory(type, *callback, user_data);
+  if (factory == nullptr) {
+    LOGE("Out of memory");
+    set_last_result(APP_ERROR_OUT_OF_MEMORY);
+    return nullptr;
+  }
+
+  handle->Add(comp_id,
+      std::unique_ptr<component_based::Component::Factory>(factory));
+
+  comp_class = static_cast<component_class_h>(handle);
+  return comp_class;
+}
+
+extern "C" EXPORT_API int component_get_id(component_h context,
+    char** id) {
+  if (context == nullptr || id == nullptr) {
+    LOGE("Invalid parameter");
+    return COMPONENT_ERROR_INVALID_PARAMETER;
+  }
+
+  component_based::Component* component =
+      static_cast<component_based::Component*>(context);
+  *id = strdup(component->GetComponentID().c_str());
+  if (*id == nullptr) {
+    LOGE("Out of memory");
+    return COMPONENT_ERROR_OUT_OF_MEMORY;
+  }
+
+  return COMPONENT_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int component_get_instance_id(component_h context,
+    char** instance_id) {
+  if (context == nullptr || instance_id == nullptr) {
+    LOGE("Invalid parameter");
+    return COMPONENT_ERROR_INVALID_PARAMETER;
+  }
+
+  component_based::Component* component =
+      static_cast<component_based::Component*>(context);
+  *instance_id = strdup(component->GetInstanceID().c_str());
+  if (*instance_id == nullptr) {
+    LOGE("Out of memory");
+    return COMPONENT_ERROR_OUT_OF_MEMORY;
+  }
+
+  return COMPONENT_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int component_register_action(component_h context,
+    const char* action) {
+  if (context == nullptr || action == nullptr) {
+    LOGE("Invalid parameter");
+    return COMPONENT_ERROR_INVALID_PARAMETER;
+  }
+
+  component_based::Component* component =
+      static_cast<component_based::Component*>(context);
+  try {
+    component->RegisterAction(action);
+  } catch (component_based::Exception& ex) {
+    LOGE("Exception occurred (%s)", ex.what());
+    return COMPONENT_ERROR_INVALID_CONTEXT;
+  }
+
+  return COMPONENT_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int component_deregister_action(
+    component_h context, const char* action) {
+  if (context == nullptr || action == nullptr) {
+    LOGE("Invalid parameter");
+    return COMPONENT_ERROR_INVALID_PARAMETER;
+  }
+
+  component_based::Component* component =
+      static_cast<component_based::Component*>(context);
+  if (!component->DeregisterAction(action)) {
+    LOGE("Deregister fail");
+    return COMPONENT_ERROR_INVALID_PARAMETER;
+  }
+
+  return COMPONENT_ERROR_NONE;
+}
+
+static int __app_control_error_convert(int error) {
+  switch (error) {
+  case APP_CONTROL_ERROR_INVALID_PARAMETER:
+    return COMPONENT_ERROR_INVALID_PARAMETER;
+  case APP_CONTROL_ERROR_OUT_OF_MEMORY:
+    return COMPONENT_ERROR_OUT_OF_MEMORY;
+  case APP_CONTROL_ERROR_APP_NOT_FOUND:
+    return COMPONENT_ERROR_NOT_FOUND;
+  case APP_CONTROL_ERROR_LAUNCH_REJECTED:
+    return COMPONENT_ERROR_LAUNCH_REJECTED;
+  case APP_CONTROL_ERROR_LAUNCH_FAILED:
+    return COMPONENT_ERROR_LAUNCH_FAILED;
+  case APP_CONTROL_ERROR_TIMED_OUT:
+    return COMPONENT_ERROR_TIMED_OUT;
+  case APP_CONTROL_ERROR_PERMISSION_DENIED:
+    return COMPONENT_ERROR_PERMISSION_DENIED;
+  default:
+    return COMPONENT_ERROR_INVALID_CONTEXT;
+  }
+}
+
+static int __app_control_send_launch_request_async(
+    const char* inst_id,
+    app_control_h app_control,
+    app_control_result_cb result_cb,
+    app_control_reply_cb reply_cb,
+    void* user_data) {
+  int r = app_control_set_caller_instance_id(app_control, inst_id);
+  if (r != APP_CONTROL_ERROR_NONE) {
+    LOGE("Failed to set caller instance ID");
+    return __app_control_error_convert(r);
+  }
+
+  r = app_control_send_launch_request_async(app_control, result_cb, reply_cb,
+      user_data);
+  if (r != APP_CONTROL_ERROR_NONE) {
+    LOGE("Failed to send launch request async. error(%d)", r);
+    return __app_control_error_convert(r);
+  }
+
+  return COMPONENT_ERROR_NONE;
+}
+
+static int __app_control_send_launch_request_sync(
+    const char* inst_id,
+    app_control_h app_control,
+    app_control_h* reply, app_control_result_e* result) {
+  int r = app_control_set_caller_instance_id(app_control, inst_id);
+  if (r != APP_CONTROL_ERROR_NONE) {
+    LOGE("Failed to set caller instance ID");
+    return __app_control_error_convert(r);
+  }
+
+  r = app_control_send_launch_request_sync(app_control, reply, result);
+  if (r != APP_CONTROL_ERROR_NONE) {
+    LOGE("Failed to send launch request sync. error(%d)", r);
+    return __app_control_error_convert(r);
+  }
+
+  return COMPONENT_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int component_send_launch_request_async(
+    component_h context,
+    app_control_h app_control,
+    app_control_result_cb result_cb,
+    app_control_reply_cb reply_cb,
+    void* user_data) {
+  if (context == nullptr || app_control == nullptr || result_cb == nullptr) {
+    LOGE("Invalid parameter");
+    return COMPONENT_ERROR_INVALID_PARAMETER;
+  }
+
+  component_based::Component* component =
+      static_cast<component_based::Component*>(context);
+  int r = __app_control_send_launch_request_async(
+      component->GetInstanceID().c_str(), app_control, result_cb, reply_cb,
+      user_data);
+  if (r != COMPONENT_ERROR_NONE) {
+    LOGE("Failed to send launch request async. error(%d)", r);
+    return r;
+  }
+
+  return COMPONENT_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int component_send_launch_request_sync(
+    component_h context,
+    app_control_h app_control,
+    app_control_h* reply, app_control_result_e* result) {
+  if (context == nullptr || app_control == nullptr || reply == nullptr ||
+      result == nullptr) {
+    LOGE("Invalid parameter");
+    return COMPONENT_ERROR_INVALID_PARAMETER;
+  }
+
+  component_based::Component* component =
+      static_cast<component_based::Component*>(context);
+  int r = __app_control_send_launch_request_sync(
+      component->GetInstanceID().c_str(), app_control, reply, result);
+  if (r != COMPONENT_ERROR_NONE) {
+    LOGE("Failed to send launch request sync. error(%d)", r);
+    return r;
+  }
+
+  return COMPONENT_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int component_finish(component_h context) {
+  if (context == nullptr) {
+    LOGE("Invalid parameter");
+    return COMPONENT_ERROR_INVALID_PARAMETER;
+  }
+
+  component_based::Component* component =
+      static_cast<component_based::Component*>(context);
+  component->Finish();
+
+  return COMPONENT_ERROR_NONE;
+}
\ No newline at end of file
index fe210f49b9d0c32eb226368e238ff537b3003dfb..e7518aaeb80db503205311997e19c6a6a7e0deed 100644 (file)
@@ -24,6 +24,7 @@ SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
 
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../)
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../base/)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../base/api/)
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/api/)
 
 AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCES)
index a2e5b653c24512974eddd2fd5170432fba41d021..b01aa37df76be1dfbe32d680e8d9961b1583b796 100644 (file)
@@ -147,7 +147,6 @@ component_class_h component_based_app_add_service_component(
                service_component_lifecycle_callback_s *callback,
                void *user_data);
 
-
 /**
  * @}
  */
diff --git a/component_based/efl_base/api/component_common.h b/component_based/efl_base/api/component_common.h
deleted file mode 100644 (file)
index 58aa6d3..0000000
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __TIZEN_COMPONENT_BASED_COMPONENT_COMMON_H__
-#define __TIZEN_COMPONENT_BASED_COMPONENT_COMMON_H__
-
-#include <tizen.h>
-#include <app_control.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef TIZEN_ERROR_COMPONENT
-#define TIZEN_ERROR_COMPONENT -0x03030000
-#endif
-
-/**
- * @addtogroup COMPONENT_BASED_COMPONENT_COMMON_MODULE
- * @{
- */
-
-
-/**
- * @brief Enumeration for component error.
- * @since_tizen 5.5
- */
-typedef enum {
-       COMPONENT_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
-       COMPONENT_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
-       COMPONENT_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
-       COMPONENT_ERROR_INVALID_CONTEXT = TIZEN_ERROR_COMPONENT | 0x01, /**< Invalid component context */
-       COMPONENT_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */
-       COMPONENT_ERROR_NOT_FOUND = TIZEN_ERROR_COMPONENT | 0x02, /**< Not found */
-       COMPONENT_ERROR_LAUNCH_REJECTED = TIZEN_ERROR_COMPONENT | 0x03, /**< The application cannot be launched now */
-       COMPONENT_ERROR_LAUNCH_FAILED = TIZEN_ERROR_COMPONENT | 0x04, /**< Internal launch error */
-       COMPONENT_ERROR_TIMED_OUT = TIZEN_ERROR_TIMED_OUT, /**< Time out */
-       COMPONENT_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
-} component_error_e;
-
-/**
- * @brief Enumeration for device orientation.
- * @since_tizen 5.5
- */
-typedef enum {
-       COMPONENT_DEVICE_ORIENTATION_0 = 0, /**< The device is oriented in a natural position */
-       COMPONENT_DEVICE_ORIENTATION_90 = 90, /**< The device's left side is at the top */
-       COMPONENT_DEVICE_ORIENTATION_180 = 180, /**< The device is upside down */
-       COMPONENT_DEVICE_ORIENTATION_270 = 270, /**< The device's right side is at the top */
-} component_device_orientation_e;
-
-/**
- * @brief Enumeration for low memory status.
- * @since_tizen 5.5
- */
-typedef enum {
-       COMPONENT_LOW_MEMORY_NONE = 0x00, /**< None */
-       COMPONENT_LOW_MEMORY_NORMAL = 0x01, /**< Normal status */
-       COMPONENT_LOW_MEMORY_SOFT_WARNING = 0x02, /**< Soft warning status */
-       COMPONENT_LOW_MEMORY_HARD_WARNING = 0x04, /**< Hard warning status */
-} component_low_memory_status_e;
-
-/**
- * @brief Enumeration for battery status.
- * @since_tizen 5.5
- */
-typedef enum {
-       COMPONENT_LOW_BATTERY_NONE, /**< None */
-       COMPONENT_LOW_BATTERY_POWER_OFF, /**< The battery status is under 1% */
-       COMPONENT_LOW_BATTERY_CRITICAL_LOW, /**< The battery status is under 5% */
-} component_low_battery_status_e;
-
-/**
- * @brief Enumeration for suspended state.
- * @since_tizen 5.5
- */
-typedef enum {
-       COMPONENT_SUSPENDED_STATE_WILL_ENTER = 0, /**< The component will enter the suspended state */
-       COMPONENT_SUSPENDED_STATE_DID_EXIT, /**< The component did exit from the suspended state */
-} component_suspended_state_e;
-
-/**
- * @brief Enumeration for display status.
- * @since_tizen 5.5
- */
-typedef enum {
-        COMPONENT_DISPLAY_STATUS_ON, /**< The display status is on */
-        COMPONENT_DISPLAY_STATUS_OFF, /**< The display status is off */
-} component_display_status_e;
-
-/**
- * @brief The component class handle.
- * @since_tizen 5.5
- */
-typedef void *component_class_h;
-
-/**
- * @brief The component context handle.
- * @since_tizen 5.5
- */
-typedef void *component_h;
-
-/**
- * @brief Gets the ID of the component.
- * @since_tizen 5.5
- * @remarks @c id must be released using free().
- *
- * @param[in]   context         The context of the component instance
- * @param[out]  id              The ID of the component
- * @return      @c 0 on success,
- *              otherwise a negative error value
- * @retval #COMPONENT_ERROR_NONE Successful
- * @retval #COMPONENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #COMPONENT_ERROR_OUT_OF_MEMORY Out of memory
- */
-int component_get_id(component_h context, char **id);
-
-/**
- * @brief Gets the instance ID of the component.
- * @since_tizen 5.5
- * @remarks @c instance_id must be released using free().
- *
- * @param[in]   context         The context of the component instance
- * @param[out]  instance_id     The instance ID of the component
- * @return      @c 0 on success,
- *              otherwise a negative error value
- * @retval #COMPONENT_ERROR_NONE Successful
- * @retval #COMPONENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #COMPONENT_ERROR_OUT_OF_MEMORY Out of memory
- */
-int component_get_instance_id(component_h context, char **instance_id);
-
-/**
- * @brief Registers the app_control action.
- * @details This function is for handling each application control action.
- *          @a action must match id attribute of app_control element in the tizen-manifest.xml.
- * @since_tizen 5.5
- *
- * @param[in]   context         The context of the component instance
- * @param[in]   action          The name of the app_control action
- *
- * @return      @c 0 on success,
- *              otherwise a negative error value
- * @retval #COMPONENT_ERROR_NONE Successful
- * @retval #COMPONENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see frame_component_action_cb()
- * @see component_deregister_action()
- */
-int component_register_action(component_h context, const char *action);
-
-/**
- * @brief Deregisters the registered app_control action.
- * @since_tizen 5.5
- *
- * @param[in]   context         The context of the component instance
- * @param[in]   action          The name of the app_control action
- *
- * @return      @c 0 on success,
- *              otherwise a negative error value
- * @retval #COMPONENT_ERROR_NONE Successful
- * @retval #COMPONENT_ERROR_INVALID_PARAMETER Invalid parameter
- */
-int component_deregister_action(component_h context,
-               const char *action);
-
-/**
- * @brief Sends the launch request asynchronously.
- * @defails To use group mode, you must use this function instead of app_control_send_launch_request_async().
- * @since_tizen 5.5
- * @privlevel public
- * @privilege %http://tizen.org/privilege/appmanager.launch
- *
- * @param[in]   context         The context of the component instance
- * @param[in]   app_control     The app_control handle
- * @param[in]   result_cb       The callback function to be called when the result is delivered
- * @param[in]   reply_cb        The callback function to be called when the reply is delivered
- * @param[in]   user_data       The user data to be passed to the callback function
- *
- * @return      @c 0 on success,
- *              otherwise a negative error value
- * @retval #COMPONENT_ERROR_NONE Successful
- * @retval #COMPONENT_ERROR_PERMISSION_DENIED Permission denied
- * @retval #COMPONENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #COMPONENT_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #COMPONENT_ERROR_NOT_FOUND The application to run the given launch request is not found
- * @retval #COMPONENT_ERROR_LAUNCH_REJECTED The application cannot be launched in current context
- * @retval #COMPONENT_ERROR_LAUNCH_FAILED Failed to launch the application
- * @retval #COMPONENT_ERROR_TIMED_OUT Failed due to timeout. The application that handles @a app_control may be busy
- * @see app_control_result_cb()
- * @see app_control_reply_to_launch_request()
- * @see app_control_reply_cb()
- * @see app_control_enable_app_started_result_event()
- * @see app_control_send_launch_request_async()
- */
-int component_send_launch_request_async(component_h context,
-               app_control_h app_control,
-                app_control_result_cb result_cb,
-                app_control_reply_cb reply_cb,
-                void *user_data);
-
-/**
- * @brief Sends the launch request synchronously.
- * @details To use group mode, you must use this function instead of app_control_send_launch_request_sync().
- * @since_tizen 5.5
- * @privlevel public
- * @privilege %http://tizen.org/privilege/appmanager.launch
- * @remarks The @a reply must be released using app_control_destroy().
- *
- * @param[in]   context         The context of the component instance
- * @param[in]   app_control     The app_control handle
- * @param[out]  reply           The app_control handle in which the results of the callee are contained
- * @param[out]  result          The result code of the launch request
- *
- * @return      @c 0 on success,
- *              otherwise a negative error value
- * @retval #COMPONENT_ERROR_NONE Successful
- * @retval #COMPONENT_ERROR_PERMISSION_DENIED Permission denied
- * @retval #COMPONENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #COMPONENT_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #COMPONENT_ERROR_NOT_FOUND The application to run the given launch request is not found
- * @retval #COMPONENT_ERROR_LAUNCH_REJECTED The application cannot be launched in current context
- * @retval #COMPONENT_ERROR_LAUNCH_FAILED Failed to launch the application
- * @retval #COMPONENT_ERROR_TIMED_OUT Failed due to timeout. The application that handles @a app_control may be busy
- * @see app_control_destroy()
- * @see app_control_send_launch_request_sync()
- */
-int component_send_launch_request_sync(component_h context,
-                app_control_h app_control,
-                app_control_h *reply,
-               app_control_result_e *result);
-
-/**
- * @brief Finishes the component instance.
- * @since_tizen 5.5
- *
- * @param[in]   context         The context of the component instance
- *
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #COMPONENT_ERROR_NONE Successful
- * @retval #COMPONENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see frame_component_destroy_cb()
- * @see service_component_destroy_cb()
- */
-int component_finish(component_h context);
-
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* __TIZEN_COMPONENT_BASED_COMPONENT_COMMON_H__ */
-
index 4e6edff5f2641316f7a30f7108112c122c196551..0e34ca93eb5bdcac93e0fe20b286f6d1f8daa83e 100644 (file)
@@ -7,5 +7,5 @@ Name: @PC_NAME@
 Description: Support development of the Tizen Extensive App Model
 Version: @VERSION@
 Requires: @PC_REQUIRED@
-Libs: -L${libdir} -lcomponent-based-application
-Cflags: -I${includedir} -I${includedir}/appfw -I${includedir}/component_based -I${includedir}/component_based/efl_base -I${includedir}/component_based/efl_base/api
+Libs: -L${libdir} -lcomponent-based-core-base -lcomponent-based-application
+Cflags: -I${includedir} -I${includedir}/appfw -I${includedir}/component_based -I${includedir}/component_based/base/api -I${includedir}/component_based/efl_base -I${includedir}/component_based/efl_base/api
index 1e311f701c6913ba0a3841457d445939008413e7..90a142c87d92d007ccbd2df7deb35aa37d15b6a5 100644 (file)
@@ -21,9 +21,9 @@
 
 #include <list>
 
-#include "component_based/efl_base/api/component_common.h"
-#include "component_based/efl_base/api/frame_component.h"
+#include "component_based/base/api/component_common.h"
 #include "component_based/efl_base/api/service_component.h"
+#include "component_based/efl_base/api/frame_component.h"
 #include "component_based/efl_base/api/component_based_app.h"
 
 #include "component_based/common/exception.h"
@@ -512,198 +512,6 @@ component_based_app_add_service_component(
   return comp_class;
 }
 
-extern "C" EXPORT_API int component_get_id(component_h context,
-    char** id) {
-  if (context == nullptr || id == nullptr) {
-    LOGE("Invalid parameter");
-    return COMPONENT_ERROR_INVALID_PARAMETER;
-  }
-
-  component_based::Component* component =
-      static_cast<component_based::Component*>(context);
-  *id = strdup(component->GetComponentID().c_str());
-  if (*id == nullptr) {
-    LOGE("Out of memory");
-    return COMPONENT_ERROR_OUT_OF_MEMORY;
-  }
-
-  return COMPONENT_ERROR_NONE;
-}
-
-extern "C" EXPORT_API int component_get_instance_id(component_h context,
-    char** instance_id) {
-  if (context == nullptr || instance_id == nullptr) {
-    LOGE("Invalid parameter");
-    return COMPONENT_ERROR_INVALID_PARAMETER;
-  }
-
-  component_based::Component* component =
-      static_cast<component_based::Component*>(context);
-  *instance_id = strdup(component->GetInstanceID().c_str());
-  if (*instance_id == nullptr) {
-    LOGE("Out of memory");
-    return COMPONENT_ERROR_OUT_OF_MEMORY;
-  }
-
-  return COMPONENT_ERROR_NONE;
-}
-
-extern "C" EXPORT_API int component_register_action(component_h context,
-    const char* action) {
-  if (context == nullptr || action == nullptr) {
-    LOGE("Invalid parameter");
-    return COMPONENT_ERROR_INVALID_PARAMETER;
-  }
-
-  component_based::Component* component =
-      static_cast<component_based::Component*>(context);
-  try {
-    component->RegisterAction(action);
-  } catch (component_based::Exception& ex) {
-    LOGE("Exception occurred (%s)", ex.what());
-    return COMPONENT_ERROR_INVALID_CONTEXT;
-  }
-
-  return COMPONENT_ERROR_NONE;
-}
-
-extern "C" EXPORT_API int component_deregister_action(
-    component_h context, const char* action) {
-  if (context == nullptr || action == nullptr) {
-    LOGE("Invalid parameter");
-    return COMPONENT_ERROR_INVALID_PARAMETER;
-  }
-
-  component_based::Component* component =
-      static_cast<component_based::Component*>(context);
-  if (!component->DeregisterAction(action)) {
-    LOGE("Deregister fail");
-    return COMPONENT_ERROR_INVALID_PARAMETER;
-  }
-
-  return COMPONENT_ERROR_NONE;
-}
-
-static int __app_control_error_convert(int error) {
-  switch (error) {
-  case APP_CONTROL_ERROR_INVALID_PARAMETER:
-    return COMPONENT_ERROR_INVALID_PARAMETER;
-  case APP_CONTROL_ERROR_OUT_OF_MEMORY:
-    return COMPONENT_ERROR_OUT_OF_MEMORY;
-  case APP_CONTROL_ERROR_APP_NOT_FOUND:
-    return COMPONENT_ERROR_NOT_FOUND;
-  case APP_CONTROL_ERROR_LAUNCH_REJECTED:
-    return COMPONENT_ERROR_LAUNCH_REJECTED;
-  case APP_CONTROL_ERROR_LAUNCH_FAILED:
-    return COMPONENT_ERROR_LAUNCH_FAILED;
-  case APP_CONTROL_ERROR_TIMED_OUT:
-    return COMPONENT_ERROR_TIMED_OUT;
-  case APP_CONTROL_ERROR_PERMISSION_DENIED:
-    return COMPONENT_ERROR_PERMISSION_DENIED;
-  default:
-    return COMPONENT_ERROR_INVALID_CONTEXT;
-  }
-}
-
-static int __app_control_send_launch_request_async(
-    const char* inst_id,
-    app_control_h app_control,
-    app_control_result_cb result_cb,
-    app_control_reply_cb reply_cb,
-    void* user_data) {
-  int r = app_control_set_caller_instance_id(app_control, inst_id);
-  if (r != APP_CONTROL_ERROR_NONE) {
-    LOGE("Failed to set caller instance ID");
-    return __app_control_error_convert(r);
-  }
-
-  r = app_control_send_launch_request_async(app_control, result_cb, reply_cb,
-      user_data);
-  if (r != APP_CONTROL_ERROR_NONE) {
-    LOGE("Failed to send launch request async. error(%d)", r);
-    return __app_control_error_convert(r);
-  }
-
-  return COMPONENT_ERROR_NONE;
-}
-
-static int __app_control_send_launch_request_sync(
-    const char* inst_id,
-    app_control_h app_control,
-    app_control_h* reply, app_control_result_e* result) {
-  int r = app_control_set_caller_instance_id(app_control, inst_id);
-  if (r != APP_CONTROL_ERROR_NONE) {
-    LOGE("Failed to set caller instance ID");
-    return __app_control_error_convert(r);
-  }
-
-  r = app_control_send_launch_request_sync(app_control, reply, result);
-  if (r != APP_CONTROL_ERROR_NONE) {
-    LOGE("Failed to send launch request sync. error(%d)", r);
-    return __app_control_error_convert(r);
-  }
-
-  return COMPONENT_ERROR_NONE;
-}
-
-extern "C" EXPORT_API int component_send_launch_request_async(
-    component_h context,
-    app_control_h app_control,
-    app_control_result_cb result_cb,
-    app_control_reply_cb reply_cb,
-    void* user_data) {
-  if (context == nullptr || app_control == nullptr || result_cb == nullptr) {
-    LOGE("Invalid parameter");
-    return COMPONENT_ERROR_INVALID_PARAMETER;
-  }
-
-  component_based::Component* component =
-      static_cast<component_based::Component*>(context);
-  int r = __app_control_send_launch_request_async(
-      component->GetInstanceID().c_str(), app_control, result_cb, reply_cb,
-      user_data);
-  if (r != COMPONENT_ERROR_NONE) {
-    LOGE("Failed to send launch request async. error(%d)", r);
-    return r;
-  }
-
-  return COMPONENT_ERROR_NONE;
-}
-
-extern "C" EXPORT_API int component_send_launch_request_sync(
-    component_h context,
-    app_control_h app_control,
-    app_control_h* reply, app_control_result_e* result) {
-  if (context == nullptr || app_control == nullptr || reply == nullptr ||
-      result == nullptr) {
-    LOGE("Invalid parameter");
-    return COMPONENT_ERROR_INVALID_PARAMETER;
-  }
-
-  component_based::Component* component =
-      static_cast<component_based::Component*>(context);
-  int r = __app_control_send_launch_request_sync(
-      component->GetInstanceID().c_str(), app_control, reply, result);
-  if (r != COMPONENT_ERROR_NONE) {
-    LOGE("Failed to send launch request sync. error(%d)", r);
-    return r;
-  }
-
-  return COMPONENT_ERROR_NONE;
-}
-
-extern "C" EXPORT_API int component_finish(component_h context) {
-  if (context == nullptr) {
-    LOGE("Invalid parameter");
-    return COMPONENT_ERROR_INVALID_PARAMETER;
-  }
-
-  ::StubFrameComponent* component = static_cast<::StubFrameComponent*>(context);
-  component->Finish();
-
-  return COMPONENT_ERROR_NONE;
-}
-
 extern "C" EXPORT_API int frame_component_get_display_status(
     component_h context, component_display_status_e* display_status) {
   if (context == nullptr || display_status == nullptr) {
@@ -719,7 +527,12 @@ extern "C" EXPORT_API int frame_component_get_display_status(
   }
 
   ::StubFrameComponent* frame_component =
-    static_cast<::StubFrameComponent*>(context);
+    dynamic_cast<::StubFrameComponent*>(component);
+  if (frame_component == nullptr) {
+    LOGE("Invalid parameter");
+    return COMPONENT_ERROR_INVALID_PARAMETER;
+  }
+
   auto status = frame_component->GetDisplayStatus();
   if (status == component_based::FrameComponent::DisplayStatus::Unknown) {
     LOGE("Invalid context");
@@ -747,7 +560,11 @@ extern "C" EXPORT_API int frame_component_get_window(
   }
 
   ::StubFrameComponent* frame_component =
-      static_cast<::StubFrameComponent*>(context);
+      dynamic_cast<::StubFrameComponent*>(component);
+  if (frame_component == nullptr) {
+    LOGE("Invalid parameter");
+    return COMPONENT_ERROR_INVALID_PARAMETER;
+  }
   const component_based::ElmWindow* win =
       static_cast<const component_based::ElmWindow*>(
           frame_component->GetWindow());
@@ -756,4 +573,4 @@ extern "C" EXPORT_API int frame_component_get_window(
   *window = static_cast<Evas_Object*>(elm_win->GetRaw());
 
   return COMPONENT_ERROR_NONE;
-}
+}
\ No newline at end of file
index 75c7065d1dcab73529e57e4105d1e1787d8f3a94..ea4e01e6b69e2d7aee578073d21aad10b4a82e8f 100644 (file)
@@ -160,6 +160,7 @@ install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj
 
 %files devel
 %{_includedir}/component_based/base/*.h
+%{_includedir}/component_based/base/api/*.h
 %{_includedir}/component_based/app_control/*.h
 %{_includedir}/component_based/uri/*.h
 %{_libdir}/libcomponent-based-core-base.so
index 32bb5b1c663aaa7a739b5dd4e5950adf97ad4377..6ede563c49f0c81132a17b5e8bdea5ffb89b57e9 100644 (file)
@@ -24,6 +24,7 @@ SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
 SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
 
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../component_based/base)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../component_based/base/api)
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../component_based/uri)
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../component_based/app_control)
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../component_based/efl_base)