Add descriptions of APIs 00/306500/43
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 22 Feb 2024 06:14:49 +0000 (15:14 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 6 Mar 2024 04:46:45 +0000 (13:46 +0900)
Change-Id: I5e30e3c2934e321c8cd70bdbcb132bdb32590b12
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
13 files changed:
doc/tizen_core_doc.h [new file with mode: 0644]
include/tizen_core.h
include/tizen_core_channel.h
include/tizen_core_event.h
include/tizen_core_event_internal.h [new file with mode: 0644]
tests/tizen-core_unittests/tizen_core_channel_test.cc
tests/tizen-core_unittests/tizen_core_event.cc
tests/tizen-core_unittests/tizen_core_test.cc
tizen_base/channel/channel_object.h
tizen_base/event/event_object.h
tizen_base/stub.cc
tizen_base/stub_channel.cc
tizen_base/stub_event.cc

diff --git a/doc/tizen_core_doc.h b/doc/tizen_core_doc.h
new file mode 100644 (file)
index 0000000..13c3166
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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_APPFW_TIZEN_CORE_DOC_H__
+#define __TIZEN_APPFW_TIZEN_CORE_DOC_H__
+
+/**
+ * @ingroup CAPI_APPLICATION_FRAMEWORK
+ * @defgroup CAPI_TIZEN_CORE_MODULE Tizen Core
+ * @brief A new main loop model that provides improved functionality over the existing GMainLoop.
+ * @section CAPI_TIZEN_CORE_MODULE_HEADER Required Header
+ * \#include <tizen_core.h>
+ *
+ * @section CAPI_TIZEN_CORE_MODULE_OVERVIEW Overview
+ * Tizen Core is a new main loop model that provides improved functionality over the existing GMainLoop.
+ * It allows for the creation of multiple loops in different threads, enabling safe communication between them.
+ */
+
+/**
+ * @ingroup CAPI_TIZEN_CORE_MODULE
+ * @defgroup CAPI_TIZEN_CORE_CHANNEL_MODULE Channel
+ * @brief The tizen core channel API provides functions to send messages between threads.
+ * @section CAPI_TIZEN_CORE_CHANNEL_MODULE_HEADER Required Header
+ * \#include <tizen_core.h>
+ *
+ * @section CAPI_TIZEN_CORE_CHANNEL_MODULE_OVERVIEW Overview
+ * The tizen core channel can send messages securely between threads without risk of corruption or loss.
+ * It provides functions to create channel sender/receiver pair and communication APIs.
+ */
+
+/**
+ * @ingroup CAPI_TIZEN_CORE_MODULE
+ * @defgroup CAPI_TIZEN_CORE_EVENT_MODULE Event
+ * @brief The tizen core event API provides functions to add event handlers and transmit events
+ * @section CAPI_TIZEN_CORE_EVENT_MODULE_HEADER Required Header
+ * \#include <tizen_core.h>
+ *
+ * @section CAPI_TIZEN_CORE_EVENT_MODULE_OVERVIEW Overview
+ * The tizen core event can transmit events to event handlers.
+ * It provides functions to add event handlers and emit events APIs.
+ */
+
+#endif /* __TIZEN_APPFW_TIZEN_CORE_DOC_H__ */
index ef6c0e6de7cb062992201f65441ed9e309887291..315a3e99222a501583392b04e2f87a49bebc13a8 100644 (file)
 extern "C" {
 #endif
 
+/**
+ * @file tizen_core.h
+ */
+
+/**
+ * @addtogroup CAPI_TIZEN_CORE_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumeration for the tizen core result.
+ * @since_tizen 9.0
+ */
 typedef enum {
-  TIZEN_CORE_ERROR_NONE = TIZEN_ERROR_NONE,
-  TIZEN_CORE_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER,
-  TIZEN_CORE_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY,
-  TIZEN_CORE_ERROR_INVALID_CONTEXT = TIZEN_ERROR_APPLICATION | 0x01,
+  TIZEN_CORE_ERROR_NONE = TIZEN_ERROR_NONE,  /**< Successful */
+  TIZEN_CORE_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER,  /**< Invalid parameter */
+  TIZEN_CORE_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY,  /**< Out of memory */
+  TIZEN_CORE_ERROR_INVALID_CONTEXT = TIZEN_ERROR_APPLICATION | 0x01,  /**< Invalid context */
 } tizen_core_error_e;
 
+/**
+ * @brief Enumeration for the priority of tizen core source.
+ * @since_tizen 9.0
+ */
 typedef enum {
-  TIZEN_CORE_PRIORITY_HIGH = -100,
-  TIZEN_CORE_PRIORITY_DEFAULT = 0,
-  TIZEN_CORE_PRIORITY_HIGH_IDLE = 100,
-  TIZEN_CORE_PRIORITY_DEFAULT_IDLE = 200,
-  TIZEN_CORE_PRIORITY_LOW = 300,
+  TIZEN_CORE_PRIORITY_HIGH = -100,  /**< High priority */
+  TIZEN_CORE_PRIORITY_DEFAULT = 0,  /**< Default priority */
+  TIZEN_CORE_PRIORITY_HIGH_IDLE = 100,  /**< High idle priority */
+  TIZEN_CORE_PRIORITY_DEFAULT_IDLE = 200,  /**< Default idle priority */
+  TIZEN_CORE_PRIORITY_LOW = 300,  /**< Low priority */
 } tizen_core_priority_e;
 
+/**
+ * @brief Enumeration for the event of tizen core poll fd.
+ * @since_tizen 9.0
+ * @see tizen_core_poll_fd_set_events()
+ * @see tizen_core_poll_fd_get_events()
+ * @see tizen_core_poll_fd_set_returned_events()
+ * @see tizen_core_poll_fd_get_returned_events()
+ */
 typedef enum {
-  TIZEN_CORE_POLL_EVENT_IN = POLLIN,
-  TIZEN_CORE_POLL_EVENT_PRI = POLLPRI,
-  TIZEN_CORE_POLL_EVENT_OUT = POLLOUT,
-  TIZEN_CORE_POLL_EVENT_ERR = POLLERR,
-  TIZEN_CORE_POLL_EVENT_HUP = POLLHUP,
-  TIZEN_CORE_POLL_EVENT_NVAL = POLLNVAL,
+  TIZEN_CORE_POLL_EVENT_IN = POLLIN,  /**< There is data to read */
+  TIZEN_CORE_POLL_EVENT_PRI = POLLPRI,  /**< There is some exceptional condition on the file descriptor */
+  TIZEN_CORE_POLL_EVENT_OUT = POLLOUT,  /**< Writing is now possible */
+  TIZEN_CORE_POLL_EVENT_ERR = POLLERR,  /**< Error condition */
+  TIZEN_CORE_POLL_EVENT_HUP = POLLHUP,  /**< Hang up */
+  TIZEN_CORE_POLL_EVENT_NVAL = POLLNVAL,  /**< Invalid request: fd not open */
 } tizen_core_poll_event_e;
 
+/**
+ * @brief The tizen core handle.
+ * @since_tizen 9.0
+ */
 typedef void *tizen_core_h;
 
+
+/**
+ * @brief The tizen core task handle.
+ * @since_tizen 9.0
+ */
 typedef void *tizen_core_task_h;
 
+/**
+ * @brief The tizen core source handle.
+ * @since_tizen 9.0
+ */
 typedef void *tizen_core_source_h;
 
+/**
+ * @brief The tizen core poll fd handle.
+ * @since_tizen 9.0
+ */
 typedef void *tizen_core_poll_fd_h;
 
-typedef bool (*tizen_core_cb)(void *user_data);
+/**
+ * @brief Called when the channel object is received.
+ * @since_tizen 9.0
+ * @remarks The @a object must not be deallocated by the application.
+ *
+ * @param[in] object The tizen core channel object handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see tizen_core_add_channel()
+ */
+typedef void (*tizen_core_channel_receive_cb)(
+    tizen_core_channel_object_h object, void *user_data);
+
+/**
+ * @brief Called when the tizen core idle or timer event is emitted.
+ * @since_tizen 9.0
+ *
+ * @param[in] user_data The user data passed from the callback registration function
+ * @return @c true to repeat calling the callback function,
+ *         otherwise @c false to remove the added source.
+ * @see tizen_core_add_idle_job()
+ * @see tizen_core_add_timer()
+ */
+typedef bool (*tizen_core_task_cb)(void *user_data);
 
+/**
+ * @brief Called before all file descriptors are polled.
+ * @details The @a source is the same object for which the callback was set.
+ * @details The function returns a timeout value to ensure that the poll()
+ *          call doesn't block too long and miss the next timeout.
+ *          The timeout value is -1 to indicate that it doesn't mind how long
+ *          the poll() call blocks.
+ * @since_tizen 9.0
+ * @remarks The @a source should be released using tizen_core_source_destroy() when no longer needed.
+ *          The @a timeout should not be released. The @a timeout can be used only in the callback.
+ *
+ * @param[in] source The tizen core source handle
+ * @param[out] timeout The timeout
+ * @param[in] user_data The user data passed from the callback registration function
+ * @return @c true to indicate that the source is always ready to be processed,
+ *         otherwise @c false to wait until poll() has been called before it knows whether any events need to be processed.
+ * @see tizen_core_source_set_prepare_cb()
+ */
 typedef bool (*tizen_core_source_prepare_cb)(tizen_core_source_h source,
                                              int *timeout, void *user_data);
 
+/**
+ * @brief Called when checks whether the source is ready to be processed or not.
+ * @details The @a source is the same object for which the callback was set.
+ * @details The function should return 'true' if it's ready to be dispatched.
+ * @since_tizen 9.0
+ * @remarks The @a source should be released using tizen_core_source_destroy() when no longer needed.
+ *
+ * @param[in] source The tizen core source handle
+ * @param[in] user_data The user data passed from the callback registration function
+ * @return @c true to indicate that the source is always ready to be processed,
+ *         otherwise @c false to indicate that the source is not ready to be processed.
+ * @see tizen_core_source_set_check_cb()
+ */
 typedef bool (*tizen_core_source_check_cb)(tizen_core_source_h source,
                                            void *user_data);
 
+/**
+ * @brief Called when dispatches events.
+ * @details The @a source is the same object for which the callback was set.
+ * @since_tizen 9.0
+ * @remarks The @a source should be released using tizen_core_source_destroy() when no longer needed.
+ *
+ * @param[in] source The tizen core source handle
+ * @param[in] user_data The user data passed from the callback registration function
+ * @return @c true to indicate that the process is ready to dispatch the event.
+ * @see tizen_core_source_set_dispatch_cb()
+ */
 typedef bool (*tizen_core_source_dispatch_cb)(tizen_core_source_h source,
                                               void *user_data);
 
+/**
+ * @brief Called when the source is finalized.
+ * @details The @a source is the same object for which the callback was set.
+ * @since_tizen 9.0
+ * @remarks The @a source should not be released. The @a source is managed by the platform.
+ * @remarks The @a source is managed by the platform and will be released when the callback returns.
+ *
+ * @param[in] source The tizen core source handle
+ * @param[in] user_data The user data passed from the callback registration function
+ * @see tizen_core_source_set_finalize_cb()
+ */
 typedef void (*tizen_core_source_finalize_cb)(tizen_core_source_h source,
                                               void *user_data);
 
-int tizen_core_init(void);
+/**
+ * @brief Initializes the tizen core.
+ * @since_tizen 9.0
+ *
+ * @see tizen_core_shutdown()
+ * @see tizen_core_ready()
+ */
+void tizen_core_init(void);
 
-int tizen_core_shutdown(void);
+/**
+ * @brief Shutdowns the tizen core.
+ * @since_tizen 9.0
+ *
+ * @see tizen_core_init()
+ * @see tizen_core_ready()
+ */
+void tizen_core_shutdown(void);
 
+/**
+ * @brief Checks whether the tizen core is ready or not.
+ * @since_tizen 9.0
+ *
+ * @return @c true if the tizen core is ready, otherwise @c false.
+ *
+ * @see tizen_core_init()
+ * @see tizen_core_shutdown()
+ */
 bool tizen_core_ready(void);
 
+/**
+ * @brief Creates the tizen core task handle.
+ * @details If the @a name is "main", the @a use_thread should be set to 'false'.
+ *          Otherwise, it returns #TIZEN_CORE_ERROR_INVALID_PARAMETER.
+ * @since_tizen 9.0
+ * @remarks The @a task should be released using tizen_core_task_destroy().
+ *
+ * @param[in] name The name of the task
+ * @param[in] use_thread true, if the task should be run in a separate thread, otherwise @c false
+ * @param[out] task The tizen core task handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TIZEN_CORE_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #TIZEN_CORE_ERROR_INVALID_CONTEXT Invalid context
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_task_h task = NULL;
+  int ret;
+
+  tizen_core_init();
+  ret = tizen_core_task_create("main", false, &task);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    tizen_core_shutdown();
+    return -1;
+  }
+}
+ * @endcode
+ *
+ * @see tizen_core_task_destroy()
+ */
 int tizen_core_task_create(const char *name, bool use_thread,
                            tizen_core_task_h *task);
 
+/**
+ * @brief Destroys the tizen core task handle.
+ * @since_tizen 9.0
+ *
+ * @param[in] task The tizen core task handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_task_h task = NULL;
+  int ret;
+
+  tizen_core_init();
+  ret = tizen_core_task_create("main", false, &task);
+  if (ret != TIZEN_CORE_ERROR_NONE)
+    return ret;
+
+  ret = tizen_core_task_destroy(task);
+  if (ret != TIZEN_CORE_ERROR_NONE)
+    return ret;
+}
+ * @endcode
+ *
+ * @see tizen_core_task_create()
+ */
 int tizen_core_task_destroy(tizen_core_task_h task);
 
+/**
+ * @brief Runs the main loop of the tizen core task.
+ * @since_tizen 9.0
+ *
+ * @param[in] task The tizen core task handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TIZEN_CORE_ERROR_INVALID_CONTEXT Invalid context
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_task_h task = NULL;
+  int ret;
+
+  tizen_core_init();
+  ret = tizen_core_task_create("worker", true, &task);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    tizen_core_shutdown();
+    return ret;
+  }
+
+  ret = tizen_core_task_run(task);
+  if (ret != TIZEN_CORE_ERROR_NONE)
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to run task");
+}
+ * @endcode
+ *
+ * @see tizen_core_task_quit()
+ */
 int tizen_core_task_run(tizen_core_task_h task);
 
+/**
+ * @brief Checks whether the tizen core task is running or not.
+ * @since_tizen 9.0
+ *
+ * @param[in] task The tizen core task handle
+ * @param[out] running @c true if the core task is running, \n
+ *                     otherwise @c false if not running
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_task_h task = NULL;
+  bool running = false;
+  int ret;
+
+  tizen_core_init();
+  ret = tizen_core_task_create("worker", true, &task);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    tizen_core_shutdown();
+    return ret;
+  }
+
+  ret = tizen_core_task_run(task);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to run task");
+    tizen_core_task_destroy(task);
+    tizen_core_shutdown();
+    return ret;
+  }
+
+  ret = tizen_core_task_is_running(task, &running);
+  if (ret != TIZEN_CORE_ERROR_NONE)
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to check whether the task is running or not");
+  else
+    dlog_print(DLOG_INFO, LOG_TAG, "worker task is %s", running ? "running" : "not running");
+}
+ * @endcode
+ *
+ * @see tizen_core_task_run()
+ * @see tizen_core_task_quit()
+ */
 int tizen_core_task_is_running(tizen_core_task_h task, bool *running);
 
+/**
+ * @brief Exits the main loop of the tizen core task.
+ * @since_tizen 9.0
+ *
+ * @param[in] task The tizen core task handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_task_h task = NULL;
+  int ret;
+
+  tizen_core_init();
+  tizen_core_task_create("worker", true, &task);
+  tizen_core_task_run(task);
+  ret = tizen_core_task_quit(task);
+  if (ret != TIZEN_CORE_ERROR_NONE)
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to exit the main loop");
+}
+ * @endcode
+ *
+ * @see tizen_core_task_run()
+ */
 int tizen_core_task_quit(tizen_core_task_h task);
 
+/**
+ * @brief Gets the tizen core from the tizen core task handle.
+ * @since_tizen 9.0
+ * @remarks The @a core should not be released.
+ * @remarks The @a core is available until the @a task is released.
+ *
+ * @param[in] task The tizen core task handle
+ * @param[out] core The tizen core handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_task_h task = NULL;
+  tizen_core_h core = NULL;
+  int ret;
+
+  tizen_core_init();
+  tizen_core_task_create("worker", true, &task);
+  ret = tizen_core_task_get_tizen_core(task, &core);
+  if (ret != TIZEN_CORE_ERROR_NONE)
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to get tizen core");
+}
+ * @endcode
+ */
 int tizen_core_task_get_tizen_core(tizen_core_task_h task, tizen_core_h *core);
 
+/**
+ * @brief Finds the tizen core from the name.
+ * @since_tizen 9.0
+ * @remarks The @a core should not be released.
+ * @remarks The @a core is available until #tizen_core_task_h of the @a core is released.
+ *
+ * @param[in] name The tizen core task name
+ * @param[out] core The tizen core handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TIZEN_CORE_ERROR_INVALID_CONTEXT Invalid context
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_h core = NULL;
+  int ret;
+
+  ret = tizen_core_find("worker", &core);
+  if (ret != TIZEN_CORE_ERROR_NONE)
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to find tizen core");
+}
+ * @endcode
+ */
 int tizen_core_find(const char *name, tizen_core_h *core);
 
+/**
+ * @brief Finds the tizen core from this thread.
+ * @since_tizen 9.0
+ * @remarks The @a core should not be released.
+ * @remarks The @a core is available until #tizen_core_task_h of the @a core is released.
+ *
+ * @param[out] core The tizen core handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TIZEN_CORE_ERROR_INVALID_CONTEXT Invalid context
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_h core = NULL;
+  int ret;
+
+  ret = tizen_core_find_from_this_thread(&core);
+  if (ret != TIZEN_CORE_ERROR_NONE)
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to find tizen core from this thread");
+}
+ * @endcode
+ */
 int tizen_core_find_from_this_thread(tizen_core_h *core);
 
-int tizen_core_add_idle_job(tizen_core_h core, tizen_core_cb callback,
+/**
+ * @brief Adds an idle job to the tizen core.
+ * @details The callback function will be called whenever there are
+ *          no higher priority events pending to the tizen core.
+ *          The given callback function is called repeatedly until it returns false,
+ *          at which point the idler @a source is automatically destroyed and
+ *          the callback function will not be called again.
+ * @since_tizen 9.0
+ * @remarks The @a source should be released using tizen_core_remove_source().
+ *
+ * @param[in] core The tizen core handle
+ * @param[in] callback The callback function to be invoked when the idle job is emitted
+ * @param[in] user_data The user data to be passed to the callback function
+ * @param[out] source The tizen core source handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TIZEN_CORE_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @code
+#include <tizen_core.h>
+static bool idle_cb(void *user_data)
+{
+  dlog_print(DLOG_INFO, LOG_TAG, "idler is invoked");
+  return true;
+}
+
+static tizen_core_source_h add_idle_job(void)
+{
+  tizen_core_source_h source = NULL;
+  tizen_core_h core = NULL;
+  int ret;
+
+  tizen_core_find("main", &core);
+  ret = tizen_core_add_idle_job(core, idle_cb, NULL, &source);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to add idle job");
+    return NULL;
+  }
+
+  return source;
+}
+ * @endcode
+ *
+ * @see tizen_core_remove_source()
+ * @see tizen_core_task_cb()
+ */
+int tizen_core_add_idle_job(tizen_core_h core, tizen_core_task_cb callback,
                             void *user_data, tizen_core_source_h *source);
 
+/**
+ * @brief Adds a timer to the tizen core.
+ * @details The callback function will be called at regular intervals.
+ *          The given callback function is called repeatedly until it returns false,
+ *          at which point the timer @a source is automatically destroyed and
+ *          the callback function will not be called again.
+ * @since_tizen 9.0
+ * @remarks The @a source should be released using tizen_core_remove_source().
+ *
+ * @param[in] core The tizen core handle
+ * @param[in] interval The interval of the timer in milliseconds
+ * @param[in] callback The callback function to be invoked when the timer is expired
+ * @param[in] user_data The user data to be passed to the callback function
+ * @param[out] source The tizen core source handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TIZEN_CORE_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @code
+#include <tizen_core.h>
+
+static bool timeout_cb(void *user_data)
+{
+  dlog_print(DLOG_INFO, LOG_TAG, "timeout cb is invoked");
+  return true;
+}
+
+static tizen_core_source_h add_timer(unsigned int interval)
+{
+  tizen_core_source_h source = NULL;
+  tizen_core_h core = NULL;
+  int ret;
+
+  tizen_core_find("main", &core);
+  ret = tizen_core_add_timer(core, interval, timeout_cb, NULL, &source);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to add timer");
+    return NULL;
+  }
+
+  return source;
+}
+ * @endcode
+ *
+ * @see tizen_core_remove_source()
+ * @see tizen_core_task_cb()
+ */
 int tizen_core_add_timer(tizen_core_h core, unsigned int interval,
-                         tizen_core_cb callback, void *user_data,
+                         tizen_core_task_cb callback, void *user_data,
                          tizen_core_source_h *source);
 
+/**
+ * @brief Adds a channel receiver to the tizen core.
+ * @details The callback function will be called when the channel event is received.
+ * @since_tizen 9.0
+ * @remarks The @a source should be released using tizen_core_remove_source().
+ *
+ * @param[in] core The tizen core handle
+ * @param[in] receiver The channel receiver handle
+ * @param[in] callback The callback function to be invoked when the channel event is received
+ * @param[in] user_data The user data to be passed to the callback function
+ * @param[out] source The tizen core source handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TIZEN_CORE_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @code
+#include <tizen_core.h>
+static void channel_receiver_cb(tizen_core_channel_object_h object, void *user_data)
+{
+  dlog_print(DLOG_INFO, LOG_TAG, "channel object is received");
+}
+
+static tizen_core_source_h add_channel_event(tizen_core_channel_receiver_h receiver)
+{
+  tizen_core_source_h source = NULL;
+  tizen_core_h core = NULL;
+  int ret;
+
+  tizen_core_find("main", &core);
+  ret = tizen_core_add_channel(core, receiver, channel_receiver_cb, NULL, &source);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to add channel");
+    return NULL;
+  }
+
+  return source;
+}
+ * @endcode
+ *
+ * @see tizen_core_remove_source()
+ */
 int tizen_core_add_channel(tizen_core_h core,
                            tizen_core_channel_receiver_h receiver,
-                           tizen_core_channel_cb callback, void *user_data,
-                           tizen_core_source_h *source);
+                           tizen_core_channel_receive_cb callback,
+                           void *user_data, tizen_core_source_h *source);
+
+/**
+ * @brief Adds an event to the tizen core.
+ * @details The event handler added to the event handle is called
+ *          using the corresponding core loop when the event emit occurs.
+ * @since_tizen 9.0
+ * @remarks The @a source should be released using tizen_core_remove_source().
+ *
+ * @param[in] core The tizen core handle
+ * @param[in] event The tizen core event handle
+ * @param[out] source The tizen core source handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TIZEN_CORE_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @code
+#include <tizen_core.h>
+static tizen_core_source_h add_event_source(tizen_core_event_h event)
+{
+  tizen_core_source_h source = NULL;
+  tizen_core_h core = NULL;
+  int ret;
 
+  tizen_core_find("main", &core);
+  ret = tizen_core_add_event(core, event, &source);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to add event");
+    return NULL;
+  }
+
+  return source;
+}
+ * @endcode
+ *
+ * @see tizen_core_remove_source()
+ */
 int tizen_core_add_event(tizen_core_h core, tizen_core_event_h event,
                          tizen_core_source_h *source);
 
+/**
+ * @brief Emits the event to the tizen core.
+ * @details The event is emitted to the event handler registered in the corresponding tizen_core.
+ * @since_tizen 9.0
+ *
+ * @param[in] core The tizen core handle
+ * @param[in] object The tizen core event object handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+static int emit_event(tizen_core_event_object_h object)
+{
+  tizen_core_h core = NULL;
+  int ret;
+
+  tizen_core_find("main", &core);
+  ret = tizen_core_emit_event(core, object);
+  if (ret != TIZEN_CORE_ERROR_NONE)
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to emit event");
+
+  return ret;
+}
+ * @endcode
+ *
+ * @see tizen_core_add_event()
+ */
 int tizen_core_emit_event(tizen_core_h core, tizen_core_event_object_h object);
 
+/**
+ * @brief Adds a source to the tizen core.
+ * @since_tizen 9.0
+ * @remarks The @a source should be removed using tizen_core_remove_source().
+ *
+ * @param[in] core The tizen core handle
+ * @param[in] source The tizen core source handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_source_h source = NULL;
+  tizen_core_h core = NULL;
+  int ret;
+
+  tizen_core_source_create(&source);
+  tizen_core_find("main", &core);
+  ret = tizen_core_add_source(core, source);
+  if (ret != TIZEN_CORE_ERROR_NONE)
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to add source");
+}
+ * @endcode
+ *
+ * @see tizen_core_remove_source()
+ */
 int tizen_core_add_source(tizen_core_h core, tizen_core_source_h source);
 
+/**
+ * @brief Removes the source from the tizen core.
+ * @since_tizen 9.0
+ * @remarks If the source is not added to the tizen core, this function returns
+ *          #TIZEN_CORE_ERROR_INVALID_CONTEXT.
+ *
+ * @param[in] core The tizen core handle
+ * @param[in] source The tizen core source handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TIZEN_CORE_ERROR_INVALID_CONTEXT Invalid context
+ *
+ * @code
+#include <tizen_core.h>
+static void remove_source(tizen_core_source_h source)
+{
+  tizen_core_h core = NULL;
+  int ret;
+
+  tizen_core_find("main", &core);
+  ret = tizen_core_remove_source(core, source);
+  if (ret != TIZEN_CORE_ERROR_NONE)
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to remove source");
+  else
+    dlog_print(DLOG_INFO, LOG_TAG, "source is removed");
+}
+ * @endcode
+ *
+ * @see tizen_core_add_source()
+ */
 int tizen_core_remove_source(tizen_core_h core, tizen_core_source_h source);
 
+/**
+ * @brief Creates a tizen core source handle.
+ * @since_tizen 9.0
+ * @remarks The @a source should be released using tizen_core_source_destroy().
+ *
+ * @param[out] source The tizen core source handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TIZEN_CORE_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #TIZEN_CORE_ERROR_INVALID_CONTEXT Invalid context
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_source_h source = NULL;
+  int ret;
+
+  ret = tizen_core_source_create(&source);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create source");
+    return ret;
+  }
+}
+ * @endcode
+ *
+ * @see tizen_core_add_source()
+ * @see tizen_core_remove_source()
+ * @see tizen_core_source_destroy()
+ */
 int tizen_core_source_create(tizen_core_source_h *source);
 
+/**
+ * @brief Destroys the tizen core source handle.
+ * @since_tizen 9.0
+ *
+ * @param[in] source The tizen core source handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_source_h source = NULL;
+  int ret;
+
+  ret = tizen_core_source_create(&source);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create source");
+    return ret;
+  }
+
+  ret = tizen_core_source_destroy(source);
+  if (ret != TIZEN_CORE_ERROR_NONE)
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to destroy source");
+}
+ * @endcode
+ * @see tizen_core_source_create()
+ * @see tizen_core_remove_source()
+ */
 int tizen_core_source_destroy(tizen_core_source_h source);
 
+/**
+ * @brief Waits for some events on the file descriptor.
+ * @details The tizen core source must be created using the tizen_core_source_create().
+ * @since_tizen 9.0
+ *
+ * @param[in] source The tizen core source handle
+ * @param[in] poll_fd The poll fd handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TIZEN_CORE_ERROR_INVALID_CONTEXT Invalid context
+ *
+ * @code
+#include <tizen_core.h>
+static tizen_core_poll_fd_h add_poll_fd_to_source(tizen_core_source_h source, int fd)
+{
+  tizen_core_poll_fd_h poll_fd = NULL;
+  int ret;
+
+  tizen_core_poll_fd_create(&poll_fd);
+  tizen_core_poll_fd_set_fd(poll_fd, fd);
+  tizen_core_poll_fd_set_events(poll_fd, TIZEN_CORE_POLL_EVENT_IN);
+  ret = tizen_core_source_add_poll(source, poll_fd);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to add poll fd");
+    tizen_core_poll_fd_destroy(poll_fd);
+    return NULL;
+  }
+
+  return poll_fd;
+}
+ * @endcode
+ *
+ * @see tizen_core_source_create()
+ * @see tizen_core_source_set_prepare_cb()
+ * @see tizen_core_source_set_check_cb()
+ * @see tizen_core_source_set_dispatch_cb()
+ * @see tizen_core_source_set_finalize_cb()
+ * @see tizen_core_source_remove_poll()
+ */
 int tizen_core_source_add_poll(tizen_core_source_h source,
                                tizen_core_poll_fd_h poll_fd);
 
+/**
+ * @brief Removes to waits for some events on the file descriptor.
+ * @since_tizen 9.0
+ *
+ * @param[in] source The tizen core source handle
+ * @param[in] poll_fd The poll fd handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TIZEN_CORE_ERROR_INVALID_CONTEXT Invalid context
+ *
+ * @code
+#include <tizen_core.h>
+static void remove_poll_from_source(tizen_core_source_h source, tizen_core_poll_fd_h poll_fd)
+{
+  int ret;
+
+  ret = tizen_core_source_remove_poll(source, poll_fd);
+  if (ret != TIZEN_CORE_ERROR_NONE)
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to remove poll fd");
+  else
+    dlog_print(DLOG_INFO, LOG_TAG, "Poll fd is removed");
+}
+ * @endcode
+ *
+ * @see tizen_core_source_create()
+ * @see tizen_core_source_add_poll()
+ */
 int tizen_core_source_remove_poll(tizen_core_source_h source,
                                   tizen_core_poll_fd_h poll_fd);
 
+/**
+ * @brief Sets the prepare callback function to the tizen core source.
+ * @details This function is not mandatory.
+ *          If you want to set a timeout value to ensure that the poll(),
+ *          the @a callback function should be set.
+ * @since_tizen 9.0
+ *
+ * @param[in] source The tizen core source handle
+ * @param[in] callback The callback function to be invoked when the source is ready to be processed
+ * @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 #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+static bool source_prepare_cb(tizen_core_source_h source, int *timeout, void *user_data)
+{
+  dlog_print(DLOG_INFO, LOG_TAG, "prepare callback is invoked");
+  return true;
+}
+
+static bool source_check_cb(tizen_core_source_h source, void *user_data)
+{
+  dlog_print(DLOG_INFO, LOG_TAG, "check callback is invoked");
+  return true;
+}
+
+static bool source_dispatch_cb(tizen_core_source_h source, void *user_data)
+{
+  dlog_print(DLOG_INFO, LOG_TAG, "dispatch callback is invoked");
+  return true;
+}
+
+static tizen_core_source_h create_source(void)
+{
+  tizen_core_source_h source = NULL;
+  int ret;
+
+  ret = tizen_core_source_create(&source);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create source");
+    return NULL;
+  }
+
+  ret = tizen_core_source_set_prepare_cb(source, source_prepare_cb, NULL);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set prepare callback");
+    tizen_core_source_destroy(source);
+    return NULL;
+  }
+
+  tizen_core_source_set_check_cb(source, source_check_cb, NULL);
+  tizen_core_source_set_dispatch_cb(source, source_dispatch_cb, NULL);
+
+  return source;
+}
+ * @endcode
+ *
+ * @see tizen_core_source_create()
+ * @see tizen_core_source_prepare_cb()
+ * @see tizen_core_source_add_poll()
+ */
 int tizen_core_source_set_prepare_cb(
     tizen_core_source_h source, tizen_core_source_prepare_cb callback,
     void *user_data);
 
+/**
+ * @brief Sets the check callback function to the tizen core source.
+ * @details This function is not mandatory.
+ *          If the @a callback function is not set, the tizen core source is processed.
+ * @since_tizen 9.0
+ *
+ * @param[in] source The tizen core source handle
+ * @param[in] callback The callback function to be invoked when the source is ready to be processed
+ * @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 #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+static bool source_prepare_cb(tizen_core_source_h source, int *timeout, void *user_data)
+{
+  dlog_print(DLOG_INFO, LOG_TAG, "prepare callback is invoked");
+  return true;
+}
+
+static bool source_check_cb(tizen_core_source_h source, void *user_data)
+{
+  dlog_print(DLOG_INFO, LOG_TAG, "check callback is invoked");
+  return true;
+}
+
+static bool source_dispatch_cb(tizen_core_source_h source, void *user_data)
+{
+  dlog_print(DLOG_INFO, LOG_TAG, "dispatch callback is invoked");
+  return true;
+}
+
+static tizen_core_source_h create_source(void)
+{
+  tizen_core_source_h source = NULL;
+  int ret;
+
+  ret = tizen_core_source_create(&source);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create source");
+    return NULL;
+  }
+
+  tizen_core_source_set_prepare_cb(source, source_prepare_cb, NULL);
+  tizen_core_source_set_dispatch_cb(source, source_dispatch_cb, NULL);
+
+  ret = tizen_core_source_set_check_cb(source, source_check_cb, NULL);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set check callback");
+    tizen_core_source_destroy(source);
+    return NULL;
+  }
+
+  return source;
+}
+ * @endcode
+ *
+ * @see tizen_core_source_create()
+ * @see tizen_core_source_check_cb()
+ */
 int tizen_core_source_set_check_cb(tizen_core_source_h source,
-                                         tizen_core_source_check_cb callback,
-                                         void *user_data);
+                                   tizen_core_source_check_cb callback,
+                                   void *user_data);
 
+/**
+ * @brief Sets the dispatch callback function to the tizen core source.
+ * @details This function is mandatory. Before adding the @a source handle to
+ *          the #tizen_core_h using tizen_core_add_source(),
+ *          the @a callback function should be set.
+ * @since_tizen 9.0
+ *
+ * @param[in] source The tizen core source handle
+ * @param[in] callback The callback function to be dispatched events
+ * @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 #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+static bool source_prepare_cb(tizen_core_source_h source, int *timeout, void *user_data)
+{
+  dlog_print(DLOG_INFO, LOG_TAG, "prepare callback is invoked");
+  return true;
+}
+
+static bool source_check_cb(tizen_core_source_h source, void *user_data)
+{
+  dlog_print(DLOG_INFO, LOG_TAG, "check callback is invoked");
+  return true;
+}
+
+static bool source_dispatch_cb(tizen_core_source_h source, void *user_data)
+{
+  dlog_print(DLOG_INFO, LOG_TAG, "dispatch callback is invoked");
+  return true;
+}
+
+static tizen_core_source_h create_source(void)
+{
+  tizen_core_source_h source = NULL;
+  int ret;
+
+  ret = tizen_core_source_create(&source);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create source");
+    return NULL;
+  }
+
+  tizen_core_source_set_prepare_cb(source, source_prepare_cb, NULL);
+  tizen_core_source_set_check_cb(source, source_check_cb, NULL);
+
+  ret = tizen_core_source_set_dispatch_cb(source, source_dispatch_cb, NULL);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set dispatch callback");
+    tizen_core_source_destroy(source);
+    return NULL;
+  }
+
+  return source;
+}
+ * @endcode
+ *
+ * @see tizen_core_source_create()
+ * @see tizen_core_source_dispatch_cb()
+ */
 int tizen_core_source_set_dispatch_cb(
     tizen_core_source_h source, tizen_core_source_dispatch_cb callback,
     void *user_data);
 
+/**
+ * @brief Sets the finalize callback function to the tizen core source.
+ * @details This function is not mandatory.
+ *          If there is anything you need to do when the source is removed,
+ *          use this function to set the callback function.
+ * @since_tizen 9.0
+ *
+ * @param[in] source The tizen core source handle
+ * @param[in] callback The callback function to finalize the source
+ * @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 #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+static bool source_prepare_cb(tizen_core_source_h source, int *timeout, void *user_data)
+{
+  dlog_print(DLOG_INFO, LOG_TAG, "prepare callback is invoked");
+  return true;
+}
+
+static bool source_check_cb(tizen_core_source_h source, void *user_data)
+{
+  dlog_print(DLOG_INFO, LOG_TAG, "check callback is invoked");
+  return true;
+}
+
+static bool source_dispatch_cb(tizen_core_source_h source, void *user_data)
+{
+  dlog_print(DLOG_INFO, LOG_TAG, "dispatch callback is invoked");
+  return true;
+}
+
+static void source_finalize_cb(tizen_core_source_h source, void *user_data)
+{
+  dlog_print(DLOG_INFO, LOG_TAG, "finalize callback is invoked");
+}
+
+static tizen_core_source_h create_source(void)
+{
+  tizen_core_source_h source = NULL;
+  int ret;
+
+  ret = tizen_core_source_create(&source);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create source");
+    return NULL;
+  }
+
+  tizen_core_source_set_prepare_cb(source, source_prepare_cb, NULL);
+  tizen_core_source_set_check_cb(source, source_check_cb, NULL);
+  tizen_core_source_set_dispatch_cb(source, source_dispatch_cb, NULL);
+
+  ret = tizen_core_source_set_finalize_cb(source, source_finalize_cb, NULL);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set finalize callback");
+    tizen_core_source_destroy(source);
+    return NULL;
+  }
+
+  return source;
+}
+ * @endcode
+ *
+ * @see tizen_core_source_create()
+ * @see tizen_core_source_finalize_cb()
+ * @see tizen_core_remove_source()
+ * @see tizen_core_source_destroy()
+ */
 int tizen_core_source_set_finalize_cb(
     tizen_core_source_h source, tizen_core_source_finalize_cb callback,
     void *user_data);
 
+/**
+ * @brief Sets the priority to the tizen core source.
+ * @since_tizen 9.0
+ *
+ * @param[in] source The tizen core source handle
+ * @param[in] priority The priority value
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+static bool idle_job_cb(void *user_data)
+{
+  dlog_print(DLOG_INFO, LOG_TAG, "idler is invoked");
+  return true;
+}
+
+static tizen_core_source_h create_idle_source(void)
+{
+  tizen_core_source_h source = NULL;
+  tizen_core_h core = NULL;
+  int ret;
+
+  tizen_core_find("main", &core);
+  ret = tizen_core_add_idle_job(core, idle_job_cb, NULL, &source);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to add idle job");
+    return NULL;
+  }
+
+  ret = tizen_core_source_set_priority(source, TIZEN_CORE_PRIORITY_HIGH);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set priority");
+    tizen_core_source_destroy(source);
+    return NULL;
+  }
+
+  return source;
+}
+ * @endcode
+ *
+ * @see tizen_core_priority_e
+ */
 int tizen_core_source_set_priority(tizen_core_source_h source,
                                    tizen_core_priority_e priority);
 
+/**
+ * @brief Creates a tizen core poll fd handle.
+ * @since_tizen 9.0
+ * @remarks The @a poll_fd should be released using tizen_core_poll_fd_destroy().
+ *
+ * @param[out] poll_fd The tizen core poll fd handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TIZEN_CORE_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_poll_fd_h poll_fd = NULL;
+  int ret;
+
+  ret = tizen_core_poll_fd_create(&poll_fd);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create poll fd");
+    return;
+  }
+}
+ * @endcode
+ *
+ * @see tizen_core_poll_fd_destroy()
+ */
 int tizen_core_poll_fd_create(tizen_core_poll_fd_h *poll_fd);
 
+/**
+ * @brief Destroys the tizen core poll fd (file descriptor) handle.
+ * @since_tizen 9.0
+ * @remarks If the handle is already added to the source using the tizen_core_source_add_poll(),
+ *          the handle will be removed from the source automatically after this function is called.
+ *
+ * @param[in] poll_fd The tizen core poll fd handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_poll_fd_h poll_fd = NULL;
+  int ret;
+
+  ret = tizen_core_poll_fd_create(&poll_fd);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create poll fd");
+    return;
+  }
+
+  ret = tizen_core_poll_fd_destroy(poll_fd);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to destroy poll fd");
+  }
+}
+ * @endcode
+ *
+ * @see tizen_core_poll_fd_create()
+ */
 int tizen_core_poll_fd_destroy(tizen_core_poll_fd_h poll_fd);
 
+/**
+ * @brief Sets the file descriptor to the poll fd handle.
+ * @since_tizen 9.0
+ *
+ * @param[in] poll_fd The tizen core poll fd handle
+ * @param[in] fd The file descriptor
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_poll_fd_h poll_fd = NULL;
+  int ret;
+
+  ret = tizen_core_poll_fd_create(&poll_fd);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create poll fd");
+    return;
+  }
+
+  ret = tizen_core_poll_fd_set_fd(poll_fd, 0);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set fd to poll fd");
+    tizen_core_poll_fd_destroy(poll_fd);
+    return;
+  }
+}
+ * @endcode
+ *
+ * @see tizen_core_poll_fd_get_fd()
+ */
 int tizen_core_poll_fd_set_fd(tizen_core_poll_fd_h poll_fd, int fd);
 
+/**
+ * @brief Gets the file descriptor from the poll fd handle.
+ * @since_tizen 9.0
+ *
+ * @param[in] poll_fd The tizen core poll fd handle
+ * @param[out] fd The file descriptor
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_poll_fd_h poll_fd = NULL;
+  int fd = -1;
+  int ret;
+
+  ret = tizen_core_poll_fd_create(&poll_fd);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create poll fd");
+    return;
+  }
+
+  tizen_core_poll_fd_set_fd(poll_fd, 0);
+
+  ret = tizen_core_poll_fd_get_fd(poll_fd, &fd);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to get fd from poll fd");
+    tizen_core_poll_fd_destroy(poll_fd);
+    return;
+  }
+}
+ * @endcode
+ *
+ * @see tizen_core_poll_fd_set_fd()
+ */
 int tizen_core_poll_fd_get_fd(tizen_core_poll_fd_h poll_fd, int *fd);
 
+/**
+ * @brief Sets the requested events to the poll fd handle.
+ * @since_tizen 9.0
+ *
+ * @param[in] poll_fd The tizen core poll fd handle
+ * @param[in] events The requested events
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_poll_fd_h poll_fd = NULL;
+  int ret;
+
+  ret = tizen_core_poll_fd_create(&poll_fd);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create poll fd");
+    return;
+  }
+
+  tizen_core_poll_fd_set_fd(poll_fd, 0);
+
+  ret = tizen_core_poll_fd_set_events(poll_fd,
+      TIZEN_CORE_POLL_EVENT_IN | TIZEN_CORE_POLL_EVENT_OUT);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set events");
+    tizen_core_poll_fd_destroy(poll_fd);
+    return;
+  }
+}
+ * @endcode
+ *
+ * @see tizen_core_poll_fd_get_events()
+ * @see tizen_core_poll_event_e
+ */
 int tizen_core_poll_fd_set_events(tizen_core_poll_fd_h poll_fd,
                                   uint16_t events);
 
+/**
+ * @brief Gets the requested events from the poll fd handle.
+ * @since_tizen 9.0
+ *
+ * @param[in] poll_fd The tizen core poll fd handle
+ * @param[out] events The requested events
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_poll_fd_h poll_fd = NULL;
+  uint16_t events;
+  int ret;
+
+  ret = tizen_core_poll_fd_create(&poll_fd);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create poll fd");
+    return;
+  }
+
+  tizen_core_poll_fd_set_fd(poll_fd, 0);
+  tizen_core_poll_fd_set_events(poll_fd,
+      TIZEN_CORE_POLL_EVENT_IN | TIZEN_CORE_POLL_EVENT_HUP);
+
+  ret = tizen_core_poll_fd_get_events(poll_fd, &events);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to get events from poll fd");
+    tizen_core_poll_fd_destroy(poll_fd);
+    return;
+  }
+}
+ * @endcode
+ *
+ * @see tizen_core_poll_fd_set_events()
+ * @see tizen_core_poll_event_e
+ */
 int tizen_core_poll_fd_get_events(tizen_core_poll_fd_h poll_fd,
                                   uint16_t *events);
 
+/**
+ * @brief Sets the returned events to the poll fd handle.
+ * @since_tizen 9.0
+ *
+ * @param[in] poll_fd The tizen core poll fd handle
+ * @param[in] returned_events The returned events
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_poll_fd_h poll_fd = NULL;
+  int ret;
+
+  ret = tizen_core_poll_fd_create(&poll_fd);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create poll fd");
+    return;
+  }
+
+  ret = tizen_core_poll_fd_set_returned_events(poll_fd,
+      TIZEN_CORE_POLL_EVENT_IN | TIZEN_CORE_POLL_EVENT_OUT);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set returned events");
+    tizen_core_poll_fd_destroy(poll_fd);
+    return;
+  }
+}
+ * @endcode
+ *
+ * @see tizen_core_poll_fd_get_events()
+ * @see tizen_core_poll_event_e
+ */
 int tizen_core_poll_fd_set_returned_events(tizen_core_poll_fd_h poll_fd,
                                            uint16_t returned_events);
 
+/**
+ * @brief Gets the returned events from the poll fd handle.
+ * @since_tizen 9.0
+ *
+ * @param[in] poll_fd The tizen core poll fd handle
+ * @param[out] returned_events The returned events
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+static bool source_prepare_cb(tizen_core_source_h source, int *timeout, void *user_data)
+{
+  *timeout = -1;
+  return true;
+}
+
+static bool source_check_cb(tizen_core_source_h source, void *user_data)
+{
+  tizen_core_poll_fd_h poll_fd = (tizen_core_poll_fd_h)user_data;
+  uint16_t returned_events = 0;
+
+  tizen_core_poll_fd_get_returned_events(poll_fd, &returned_events);
+  if (returned_events & TIZEN_CORE_POLL_EVENT_IN)
+    return true;
+
+  return false;
+}
+
+static bool source_dispatch_cb(tizen_core_source_h source, void *user_data)
+{
+  tizen_core_poll_fd_h poll_fd = (tizen_core_poll_fd_h)user_data;
+  ssize_t bytes;
+  int ret = 0;
+  int fd;
+
+  tizen_core_poll_fd_get_fd(poll_fd, &fd);
+  bytes = read(fd, (void *)&ret, sizeof(ret));
+  if (bytes < 0) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to read data. errno=%d", errno);
+  } else if (bytes == 0) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "socket was closed. fd=%d", fd);
+    tizen_core_source_destroy(source);
+  } else {
+    dlog_print(DLOG_INFO, LOG_TAG, "result=%d", ret);
+  }
+
+  return true;
+}
+
+static void source_finalize_cb(tizen_core_source_h source, void *user_data)
+{
+  tizen_core_poll_fd_h poll_fd = (tizen_core_poll_fd_h)user_data;
+
+  tizen_core_poll_fd_destroy(poll_fd);
+}
+
+static tizen_core_source_h create_io_source(int fd, uint16_t events)
+{
+  tizen_core_source_h source = NULL;
+  tizen_core_poll_fd_h poll_fd = NULL;
+  tizen_core_h core = NULL;
+
+  tizen_core_poll_fd_create(&poll_fd);
+  tizen_core_poll_fd_set_fd(poll_fd, fd);
+  tizen_core_poll_fd_set_events(poll_fd, events);
+
+  tizen_core_source_create(&source);
+  tizen_core_source_set_prepare_cb(source, source_prepare_cb, poll_fd);
+  tizen_core_source_set_check_cb(source, source_check_cb, poll_fd);
+  tizen_core_source_set_dispatch_cb(source, source_dispatch_cb, poll_fd);
+  tizen_core_source_set_finalize_cb(source, source_finalize_cb, poll_fd);
+
+  tizen_core_find("main", &core);
+  tizen_core_add_source(core, source);
+
+  return source;
+}
+ * @endcode
+ *
+ * @see tizen_core_poll_fd_set_events()
+ * @see tizen_core_poll_event_e
+ */
 int tizen_core_poll_fd_get_returned_events(tizen_core_poll_fd_h poll_fd,
                                            uint16_t *returned_events);
 
+/**
+ * @}
+ */
+
 #ifdef __cplusplus
 }
 #endif
index 2a42249a55c6c6a723772b36457c111f980dab5d..8b1a23bce8dbdd90f31932e5ee606811d918940f 100644 (file)
 extern "C" {
 #endif
 
+/**
+ * @file tizen_core_channel.h
+ */
+
+/**
+ * @addtogroup CAPI_TIZEN_CORE_CHANNEL_MODULE
+ * @{
+ */
+
+/**
+ * @brief The tizen core channel sender handle.
+ * @since_tizen 9.0
+ */
 typedef void *tizen_core_channel_sender_h;
 
+/**
+ * @brief The tizen core channel receiver handle.
+ * @since_tizen 9.0
+ */
 typedef void *tizen_core_channel_receiver_h;
 
+/**
+ * @brief The tizen core channel object handle.
+ * @since_tizen 9.0
+ */
 typedef void *tizen_core_channel_object_h;
 
-typedef void (*tizen_core_channel_cb)(tizen_core_channel_object_h object,
-                                      void *user_data);
+/**
+ * @brief Called when the channel object is received.
+ * @since_tizen 9.0
+ * @remarks The @a object must not be deallocated by the application.
+ *
+ * @param[in] object The tizen core channel object handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see tizen_core_add_channel()
+ */
+typedef void (*tizen_core_channel_receive_cb)(
+    tizen_core_channel_object_h object, void *user_data);
 
+/**
+ * @brief Makes a pair of channel sender and receiver.
+ * @since_tizen 9.0
+ * @remarks The @a sender should be released using tizen_core_channel_sender_destroy().
+ * @remarks The @a receiver should be released using tizen_core_channel_receiver_destroy().
+ *
+ * @param[out] sender The tizen core channel sender handle
+ * @param[out] receiver The tizen core channel receiver handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TIZEN_CORE_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #TIZEN_CORE_ERROR_INVALID_CONTEXT Invalid context
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_channel_sender_h sender = NULL;
+  tizen_core_channel_receiver_h receiver = NULL;
+  int ret;
+
+  ret = tizen_core_channel_make_pair(&sender, &receiver);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to make channel pair");
+    return;
+  }
+}
+ * @endcode
+ *
+ * @see tizen_core_channel_sender_destroy()
+ * @see tizen_core_channel_receiver_destroy()
+ */
 int tizen_core_channel_make_pair(tizen_core_channel_sender_h *sender,
                                  tizen_core_channel_receiver_h *receiver);
 
+/**
+ * @brief Sends the channel object to the receiver.
+ * @since_tizen 9.0
+ *
+ * @param[in] sender The tizen core channel sender handle
+ * @param[in] object The tizen core channel object handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_channel_sender_h sender = NULL;
+  tizen_core_channel_receiver_h receiver = NULL;
+  tizen_core_channel_object_h object = NULL;
+  int ret;
+
+  tizen_core_channel_make_pair(&sender, &receiver);
+  tizen_core_channel_object_create(&object);
+  tizen_core_channel_object_set_type(object, 22);
+  tizen_core_channel_object_set_data(object, strdup("22"));
+
+  int ret = tizen_core_channel_sender_send(sender, object);
+  if (ret != TIZEN_CORE_ERROR_NONE)
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to send object");
+
+  tizen_core_channel_object_destroy(object);
+}
+ * @endcode
+ *
+ * @see tizen_core_channel_object_create()
+ */
 int tizen_core_channel_sender_send(tizen_core_channel_sender_h sender,
                                    tizen_core_channel_object_h object);
 
+/**
+ * @brief Destroys the channel sender handle.
+ * @since_tizen 9.0
+ *
+ * @param[in] sender The tizen core channel sender handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_channel_sender_h sender = NULL;
+  tizen_core_channel_receiver_h receiver = NULL;
+  int ret;
+
+  tizen_core_channel_make_pair(&sender, &receiver);
+  tizen_core_channel_receiver_destroy(receiver);
+
+  ret = tizen_core_channel_sender_destroy(sender);
+  if (ret != TIZEN_CORE_ERROR_NONE)
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to destroy channel sender");
+}
+ * @endcode
+ *
+ * @see tizen_core_channel_make_pair()
+ * @see tizen_core_channel_sender_clone()
+ */
 int tizen_core_channel_sender_destroy(tizen_core_channel_sender_h sender);
 
+/**
+ * @brief Creates and returns a copy of the given the @a sender handle.
+ * @since_tizen 9.0
+ * @remarks The @a cloned_sender should be released using tizen_core_channel_sender_destroy().
+ *
+ * @param[in] sender The tizen core channel sender handle
+ * @param[out] cloned_sender If successful, a newly created tizen core channel sender handle will be returned
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TIZEN_CORE_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_channel_sender_h sender = NULL;
+  tizen_core_channel_sender_h cloned_sender = NULL;
+  tizen_core_channel_receiver_h receiver = NULL;
+  int ret;
+
+  tizen_core_channel_make_pair(&sender, &receiver);
+
+  ret = tizen_core_channel_sender_clone(sender, &cloned_sender);
+  if (ret != TIZEN_CORE_ERROR_NONE)
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to clone channel sender");
+}
+ * @endcode
+ *
+ * @see tizen_core_channel_sender_destroy()
+ */
 int tizen_core_channel_sender_clone(tizen_core_channel_sender_h sender,
                                     tizen_core_channel_sender_h *cloned_sender);
 
+/**
+ * @brief Receives the channel object from the sender.
+ * @since_tizen 9.0
+ * @remarks The @a object should be released using tizen_core_channel_object_destroy().
+ *
+ * @param[in] receiver The tizen core channel receiver handle
+ * @param[out] object The tizen core channel object handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TIZEN_CORE_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_channel_sender_h sender = NULL;
+  tizen_core_channel_receiver_h receiver = NULL;
+  tizen_core_channel_object_h object = NULL;
+  int id = -1;
+  char *data = NULL;
+  int ret;
+
+  tizen_core_channel_make_pair(&sender, &receiver);
+  tizen_core_channel_object_create(&object);
+  tizen_core_channel_object_set_id(object, 22);
+  tizen_core_channel_object_set_data(object, strdup("22"));
+
+  tizen_core_channel_sender_send(sender, object);
+  tizen_core_channel_object_destroy(object);
+  object = NULL;
+
+  ret = tizen_core_channel_receiver_receive(receiver, &object);
+  if (ret == TIZEN_CORE_ERROR_NONE) {
+    tizen_core_channel_object_get_id(object, &id);
+    tizen_core_channel_object_get_data(object, &data);
+    dlog_print(DLOG_INFO, LOG_TAG, "id=%d, data=%s", id, data);
+    free(data);
+    tizen_core_channel_object_destroy(object);
+  }
+
+  tizen_core_channel_sender_destroy(sender);
+  tizen_core_channel_receiver_destroy(receiver);
+}
+ * @endcode
+ *
+ * @see tizen_core_channel_object_destroy()
+ */
 int tizen_core_channel_receiver_receive(tizen_core_channel_receiver_h receiver,
                                         tizen_core_channel_object_h *object);
 
+/**
+ * @brief Destroys the tizen core channel receiver handle.
+ * @since_tizen 9.0
+ *
+ * @param[in] receiver The tizen core channel receiver handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_channel_sender_h sender = NULL;
+  tizen_core_channel_receiver_h receiver = NULL;
+  int ret;
+
+  tizen_core_channel_make_pair(&sender, &receiver);
+  tizen_core_channel_sender_destroy(sender);
+
+  ret = tizen_core_channel_receiver_destroy(receiver);
+  if (ret != TIZEN_CORE_ERROR_NONE)
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to destroy channel receiver");
+}
+ * @endcode
+ *
+ * @see tizen_core_channel_make_pair()
+ */
 int tizen_core_channel_receiver_destroy(tizen_core_channel_receiver_h receiver);
 
+/**
+ * @brief Creates the tizen core channel object handle.
+ * @since_tizen 9.0
+ * @remarks The @a object should be released using tizen_core_channel_object_destroy().
+ *
+ * @param[out] object The tizen core channel object handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TIZEN_CORE_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #TIZEN_CORE_ERROR_INVALID_CONTEXT Invalid context
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_channel_object_h object = NULL;
+  int ret;
+
+  ret = tizen_core_channel_object_create(&object);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create channel object");
+    return;
+  }
+
+  tizen_core_channel_object_destroy(object);
+}
+ * @endcode
+ *
+ * @see tizen_core_channel_object_destroy()
+ */
 int tizen_core_channel_object_create(tizen_core_channel_object_h *object);
 
+/**
+ * @brief Destroys the tizen core channel object handle.
+ * @since_tizen 9.0
+ *
+ * @param[in] object The tizen core channel object handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_channel_object_h object = NULL;
+  int ret;
+
+  tizen_core_channel_object_create(&object);
+
+  ret = tizen_core_channel_object_destroy(object);
+  if (ret != TIZEN_CORE_ERROR_NONE)
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to destroy channel object");
+}
+ * @endcode
+ *
+ * @see tizen_core_channel_object_create()
+ */
 int tizen_core_channel_object_destroy(tizen_core_channel_object_h object);
 
-int tizen_core_channel_object_set_type(tizen_core_channel_object_h object,
-                                       int type);
+/**
+ * @brief Sets the ID to the tizen core channel object handle.
+ * @since_tizen 9.0
+ *
+ * @param[in] object The tizen core channel object handle
+ * @param[in] id  The channel ID
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_channel_object_h object = NULL;
+  int ret;
+
+  tizen_core_channel_object_create(&object);
+
+  ret = tizen_core_channel_object_set_id(object, 22);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set channel type");
+    tizen_core_channel_object_destroy(object);
+    return;
+  }
+
+  tizen_core_channel_object_destroy(object);
+}
+ * @endcode
+ *
+ * @see tizen_core_channel_object_get_type()
+ */
+int tizen_core_channel_object_set_id(tizen_core_channel_object_h object,
+                                     int id);
+
+/**
+ * @brief Gets the ID from the tizen core channel object handle.
+ * @since_tizen 9.0
+ *
+ * @param[in] object The tizen core channel object handle
+ * @param[out] id The channel ID
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_channel_object_h object = NULL;
+  int id = 0;
+  int ret;
+
+  tizen_core_channel_object_create(&object);
+  tizen_core_channel_object_set_id(object, 22);
 
-int tizen_core_channel_object_get_type(tizen_core_channel_object_h object,
-                                       int *type);
+  ret = tizen_core_channel_object_get_id(object, &id);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to get channel type");
+    return;
+  }
 
+  tizen_core_channel_object_destroy(object);
+}
+ * @endcode
+ *
+ * @see tizen_core_channel_object_set_id()
+ */
+int tizen_core_channel_object_get_id(tizen_core_channel_object_h object,
+                                     int *id);
+
+/**
+ * @brief Sets the data to the tizen core channel object handle.
+ * @since_tizen 9.0
+ * @remarks The @a data should be released using release function
+ *          if the @a data is created by the memory allocation.
+ *
+ * @param[in] object The tizen core channel object handle
+ * @param[in] data The channel data
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_channel_object_h object = NULL;
+  char *data = NULL;
+  int ret;
+
+  tizen_core_channel_object_create(&object);
+
+  ret = tizen_core_channel_object_set_data(object, strdup("22"));
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set channel data");
+    tizen_core_channel_object_destroy(object);
+    return;
+  }
+
+  tizen_core_channel_object_get_data(object, &data);
+  free(data);
+  tizen_core_channel_object_destroy(object);
+}
+ * @endcode
+ *
+ * @see tizen_core_channel_object_get_data()
+ */
 int tizen_core_channel_object_set_data(tizen_core_channel_object_h object,
                                        void *data);
 
+/**
+ * @brief Gets the data from the tizen core channel object handle.
+ * @since_tizen 9.0
+ * @remarks The @a data should be released using release function.
+ *
+ * @param[in] object The tizen core channel object handle
+ * @param[out] data The channel data
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_channel_object_h object = NULL;
+  char *data = NULL;
+  int ret;
+
+  tizen_core_channel_object_create(&object);
+  tizen_core_channel_object_set_data(object, strdup("22"));
+
+  ret = tizen_core_channel_object_get_data(object, &data);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to get channel data");
+    tizen_core_channel_object_destroy(object);
+    return;
+  }
+
+  dlog_print(DLOG_INFO, LOG_TAG, "data=%s", data);
+  free(data);
+  tizen_core_channel_object_destroy(object);
+}
+ * @endcode
+ *
+ * @see tizen_core_channel_object_set_data()
+ */
 int tizen_core_channel_object_get_data(tizen_core_channel_object_h object,
                                        void **data);
 
+/**
+ * @brief Gets the sender task name from the tizen core channel object handle.
+ * @since_tizen 9.0
+ * @remarks The @a task_name must not be deallocated by the application.
+ *
+ * @param[in] object The tizen core channel object handle
+ * @param[out] task_name The sender task name
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TIZEN_CORE_ERROR_INVALID_CONTEXT Invalid context
+ *
+ * @code
+#include <tizen_core.h>
+
+static void print_task_name(tizen_core_channel_object_h object)
+{
+  const char *task_name = NULL;
+  int ret;
+
+  ret = tizen_core_channel_object_get_sender_task_name(object, &task_name);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to get sender task name");
+    return;
+  }
+
+  dlog_print(DLOG_INFO, LOG_TAG, "sender task=%s", task_name");
+}
+ * @endcode
+ *
+ * @see tizen_core_channel_sender_send()
+ * @see tizen_core_channel_receiver_receive()
+ */
 int tizen_core_channel_object_get_sender_task_name(
     tizen_core_channel_object_h object, const char **task_name);
 
+/**
+ * @}
+ */
+
 #ifdef __cplusplus
 }
 #endif
index 984c9de49329fc1c8ccefefaaf2aa8785a15f99f..4dbad29066adb0de041027b8d3e56ce2e38da6aa 100644 (file)
 extern "C" {
 #endif
 
+/**
+ * @file tizen_core_event.h
+ */
+
+/**
+ * @addtogroup CAPI_TIZEN_CORE_EVENT_MODULE
+ * @{
+ */
+
+/**
+ * @brief The tizen core event handle.
+ * @since_tizen 9.0
+ */
 typedef void *tizen_core_event_h;
 
+/**
+ * @brief The tizen core event object handle.
+ * @since_tizen 9.0
+ */
 typedef void *tizen_core_event_object_h;
 
+/**
+ * @brief The tizen core event handler handle.
+ * @since_tizen 9.0
+ */
 typedef void *tizen_core_event_handler_h;
 
+/**
+ * @brief Called when the event is emitted.
+ * @since_tizen 9.0
+ * @remarks The @a object must not be deallocated by the application.
+ *
+ * @param[in] object The tizen core event object handle
+ * @param[in] user_data The user data passed from the callback registration function
+ * @return @c true to continue with the next iteration of the loop,
+ *         otherwise @c false to break out of the loop
+ * @see tizen_core_event_add_handler()
+ */
 typedef bool (*tizen_core_event_handler_cb)(tizen_core_event_object_h object,
                                             void *user_data);
 
-typedef void (*tizen_core_event_object_on_destroy_cb)(void *data,
-                                                      void *user_data);
+/**
+ * @brief Called when the event object is destroyed.
+ * @since_tizen 9.0
+ * @remarks The @a event_data should be released using release function if it's needed.
+ *
+ * @param[in] event_data The event data of the event object
+ * @param[in] user_data The user data passed from the callback registration function
+ * @see tizen_core_event_object_set_destroy_cb()
+ * @see tizen_core_event_object_destroy()
+ */
+typedef void (*tizen_core_event_object_destroy_cb)(void *event_data,
+                                                   void *user_data);
+
+/**
+ * @brief Creates the tizen core event handle.
+ * @since_tizen 9.0
+ * @remarks The @a event should be released using tizen_core_event_destroy().
+ *
+ * @param[out] event The tizen core event handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TIZEN_CORE_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #TIZEN_CORE_ERROR_INVALID_CONTEXT Invalid context
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_event_h event = NULL;
+  int ret;
+
+  ret = tizen_core_event_create(&event);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create event");
+    return;
+  }
 
+  tizen_core_event_destroy(event);
+}
+ * @endcode
+ *
+ * @see tizen_core_event_destroy()
+ */
 int tizen_core_event_create(tizen_core_event_h *event);
 
+/**
+ * @brief Destroys the tizen core event handle.
+ * @since_tizen 9.0
+ *
+ * @param[in] event The tizen core event handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_event_h event = NULL;
+  int ret;
+
+  tizen_core_event_create(&event);
+
+  ret = tizen_core_event_destroy(event);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to destroy event");
+    return;
+  }
+}
+ * @endcode
+ *
+ * @see tizen_core_event_create()
+ */
 int tizen_core_event_destroy(tizen_core_event_h event);
 
+/**
+ * @brief Adds the event handler to the tizen core event.
+ * @details The @a event_handler is added at the back of the handler list of the tizen core event.
+ *          When tizen_core_emit_event() is called, the @a callback function of the @a event_handler is called first.
+ * @since_tizen 9.0
+ * @remarks The @a event_handler should be released using tizen_core_event_remove_handler().
+ *
+ * @param[in] event The tizen core event handle
+ * @param[in] callback The callback function to be invoked when the event is emitted
+ * @param[in] user_data The user data to be passed to the callback function
+ * @param[out] event_handler The tizen core event handler handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TIZEN_CORE_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @code
+#include <tizen_core.h>
+static void event_handler_cb(tizen_core_event_object_h object, void *user_data)
+{
+  int event_id = 0;
+  chat *event_data = NULL;
+
+  tizen_core_event_object_get_id(object, &event_id);
+  tizen_core_event_object_get_data(object, &event_data);
+
+  dlog_print(DLOG_INFO, LOG_TAG, "id=%d, data=%s", event_id, event_data);
+}
+
+static void add_event_handler(tizen_core_event_h event)
+{
+  tizen_core_event_handler_h event_handler = NULL;
+  int ret;
+
+  ret = tizen_core_event_add_handler(event, event_handler_cb, NULL, &event_handler);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to add event handler");
+    return;
+  }
+}
+ * @endcode
+ *
+ * @see tizen_core_event_emit()
+ * @see tizen_core_emit_event()
+ * @see tizen_core_event_remove_handler()
+ */
 int tizen_core_event_add_handler(
     tizen_core_event_h event, tizen_core_event_handler_cb callback,
     void *user_data, tizen_core_event_handler_h *event_handler);
 
+/**
+ * @brief Prepends the event handler to the tizen core event.
+ * @details The @a event_handler is added to the front of the handler list of the tizen core event.
+ *          When tizen_core_emit_event() is called, the @a callback function of the @a event_handler is called first.
+ * @since_tizen 9.0
+ * @remarks The @a event_handler should be released using tizen_core_event_remove_handler().
+ *
+ * @param[in] event The tizen core event handle
+ * @param[in] callback The callback function to be invoked when the event is emitted
+ * @param[in] user_data The user data to be passed to the callback function
+ * @param[out] event_handler The tizen core event handler handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TIZEN_CORE_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @code
+#include <tizen_core.h>
+static void event_handler_cb(tizen_core_event_object_h object, void *user_data)
+{
+  int event_id = 0;
+  chat *event_data = NULL;
+
+  tizen_core_event_object_get_id(object, &event_id);
+  tizen_core_event_object_get_data(object, &event_data);
+
+  dlog_print(DLOG_INFO, LOG_TAG, "id=%d, data=%s", event_id, data);
+}
+
+static void prepend_event_handler(tizen_core_event_h event)
+{
+  tizen_core_event_handler_h event_handler = NULL;
+  int ret;
+
+  ret = tizen_core_event_prepend_handler(event, event_handler_cb, NULL, &event_handler);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to prepend event handler");
+    return;
+  }
+}
+ * @endcode
+ *
+ * @see tizen_core_event_emit()
+ * @see tizen_core_emit_event()
+ * @see tizen_core_event_remove_handler()
+ */
 int tizen_core_event_prepend_handler(
     tizen_core_event_h event, tizen_core_event_handler_cb callback,
     void *user_data, tizen_core_event_handler_h *event_handler);
 
+/**
+ * @brief Removes the event handler from the tizen core event.
+ * @since_tizen 9.0
+ *
+ * @param[in] event The tizen core event handle
+ * @param[in] event_handler The tizen core event handler handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+static void remove_event_handler(tizen_core_event_h event, tizen_core_event_handler_h handler)
+{
+  int ret;
+
+  ret = tizen_core_event_remove_handler(event, handler);
+  if (ret != TIZEN_CORE_ERROR_NONE)
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to remove event handler");
+}
+ * @endcode
+ *
+ * @see tizen_core_event_add_handler()
+ */
 int tizen_core_event_remove_handler(
     tizen_core_event_h event, tizen_core_event_handler_h event_handler);
 
+/**
+ * @brief Emits the event to the tizen core event.
+ * @details The event is emitted to the tizen core event.
+ * @since_tizen 9.0
+ * @remarks The @a object will be released automatically.
+ *          You MUST NOT release the @a object using tizen_core_event_object_destroy()
+ *          when calling the function is successful.
+ *          If this function returns an error, the @a object should be released
+ *          using tizen_core_event_object_destroy().
+ *
+ * @param[in] event The tizen core event handle
+ * @param[in] object The tizen core event object handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+static void object_destroy_cb(void *event_data, void *user_data)
+{
+  char* value = (char *)event_data;
+
+  if (value)
+    free(value);
+}
+
+static void emit_event(tizen_core_event_h event)
+{
+  tizen_core_event_object_h object = NULL;
+  char buf[12];
+  int event_id = 99;
+  int ret;
+
+  snprintf(buf, sizeof(buf), "%d", event_id);
+  tizen_core_event_object_create(&object, event_id, strdup(buf));
+  tizen_core_event_object_set_destroy_cb(object, object_destroy_cb, NULL);
+
+  ret = tizen_core_event_emit(event, object);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to emit event");
+    tizen_core_event_object_destroy(object);
+    return;
+  }
+}
+ * @endcode
+ *
+ * @see tizen_core_event_add_handler()
+ */
 int tizen_core_event_emit(tizen_core_event_h event,
                           tizen_core_event_object_h object);
 
-int tizen_core_event_object_create(tizen_core_event_object_h *object, int type,
-                                   void *data);
+/**
+ * @brief Creates the tizen core event object handle.
+ * @details The @a data can be nullptr.
+ *          If the @a data is memory allocated, the @a data can be released
+ *          using the tizen_core_event_object_set_destroy_cb() function.
+ *          When tizen_core_event_object_destroy() calls, the callback function
+ *          set in tizen_core_event_object_set_destroy_cb() is called.
+ * @since_tizen 9.0
+ * @remarks The @a object should be released using tizen_core_event_object_destroy().
+ * @remarks The @a object should not be released when the @a object is emitted
+ *          using tizen_core_event_emit().
+ *
+ * @param[out] object The tizen core event object handle
+ * @param[in] id The event ID
+ * @param[in] data The event data
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TIZEN_CORE_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #TIZEN_CORE_ERROR_INVALID_CONTEXT Invalid context
+ *
+ * @code
+#include <tizen_core.h>
+
+static void object_destroy_cb(void *event_data, void *user_data)
+{
+  char *value = (char *)event_data;
+
+  if (value)
+    free(value);
+}
+
+static tizen_core_event_object_h create_event_object(void)
+{
+  tizen_core_event_object_h object = NULL;
+  char buf[12];
+  int event_id = 99;
+  int ret;
+
+  snprintf(buf, sizeof(buf), "%d", event_id);
+  ret = tizen_core_event_object_create(&object, event_id, strdup(buf));
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create event object");
+    return NULL;
+  }
+
+  tizen_core_event_object_set_destroy_cb(object, object_destroy_cb, NULL);
 
+  return object;
+}
+ * @endcode
+ *
+ * @see tizen_core_event_object_set_destroy_cb()
+ * @see tizen_core_event_object_destroy()
+ * @see tizen_core_event_emit()
+ */
+int tizen_core_event_object_create(tizen_core_event_object_h *object,
+                                   int id, void *data);
+
+/**
+ * @brief Destroys the tizen core event object handle.
+ * @since_tizen 9.0
+ *
+ * @param[in] object The tizen core event object handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_event_object_h object = NULL;
+  int event_id = 99;
+  int ret;
+
+  tizen_core_event_object_create(&object, event_id, NULL);
+
+  ret = tizen_core_event_object_destroy(object);
+  if (ret != TIZEN_CORE_ERROR_NONE)
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to destroy event object");
+}
+ * @endcode
+ *
+ * @see tizen_core_event_object_create()
+ * @see tizen_core_event_object_set_destroy_cb()
+ */
 int tizen_core_event_object_destroy(tizen_core_event_object_h object);
 
-int tizen_core_event_object_set_on_destroy(
+/**
+ * @brief Sets the destroy callback function to invoke when the event object is destroyed.
+ * @since_tizen 9.0
+ *
+ * @param[in] object The tizen core event object handle
+ * @param[in] callback The callback function to be invoked when the event object is destroyed
+ * @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 #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+static void object_destroy_cb(void *data, void *user_data)
+{
+  char *str = (char *)data;
+
+  if (str)
+    free(str);
+}
+
+static tizen_core_event_object_h create_event_object(int id, char *str)
+{
+  tizen_core_event_object_h object = NULL;
+  int ret;
+
+  tizen_core_event_object_create(&object, id, str);
+
+  ret = tizen_core_event_object_set_destroy_cb(object, object_destroy_cb, NULL);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set on_destroy callback");
+    tizen_core_event_object_destroy(object);
+    return NULL;
+  }
+
+  return object;
+}
+ * @endcode
+ *
+ * @see tizen_core_event_object_destroy()
+ */
+int tizen_core_event_object_set_destroy_cb(
     tizen_core_event_object_h object,
-    tizen_core_event_object_on_destroy_cb callback, void *user_data);
+    tizen_core_event_object_destroy_cb callback, void *user_data);
+
+/**
+ * @brief Gets the event ID from the tizen core event object handle.
+ * @since_tizen 9.0
+ *
+ * @param[in] object The tizen core event object handle
+ * @param[out] id The event ID
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_event_object_h object = NULL;
+  int event_id;
+  int ret;
 
-int tizen_core_event_object_get_type(tizen_core_event_object_h object,
-                                     int *type);
+  tizen_core_event_object_create(&object, 22, NULL);
 
+  ret = tizen_core_event_object_get_id(object, &event_id);
+  if (ret != TIZEN_CORE_ERROR_NONE)
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to get event id");
+
+  tizen_core_event_object_destroy(object);
+}
+ * @endcode
+ *
+ * @see tizen_core_event_object_create()
+ */
+int tizen_core_event_object_get_id(tizen_core_event_object_h object, int *id);
+
+/**
+ * @brief Gets the event data from the tizen core event object handle.
+ * @since_tizen 9.0
+ * @remarks The @a data should not be released if the @a object is emitted
+ *          using tizen_core_event_emit().
+ * @remarks The @a data is available until the @a object is released.
+ *
+ * @param[in] object The tizen core event object handle
+ * @param[out] data The event data
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @code
+#include <tizen_core.h>
+static void event_object_destroy_cb(void *event_data, void *user_data)
+{
+  char *value = (char *)event_data;
+
+  if (value)
+    free(value);
+}
+
+static void create_and_destroy_event_object(void)
+{
+  tizen_core_event_object_h object = NULL;
+  char *event_data = strdup("22");
+  char *value = NULL;
+  int ret;
+
+  tizen_core_event_object_create(&object, 22, event_data);
+  tizen_core_event_object_set_destroy_cb(object, event_object_destroy_cb, NULL);
+
+  ret = tizen_core_event_object_get_data(object, &value);
+  if (ret != TIZEN_CORE_ERROR_NONE)
+    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to get event data");
+
+  tizen_core_event_object_destroy(object);
+}
+ * @endcode
+ */
 int tizen_core_event_object_get_data(tizen_core_event_object_h object,
                                      void **data);
 
-int tizen_core_event_generate_type(void);
+/**
+ * @}
+ */
 
 #ifdef __cplusplus
 }
diff --git a/include/tizen_core_event_internal.h b/include/tizen_core_event_internal.h
new file mode 100644 (file)
index 0000000..6daaa8d
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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_BASE_TIZEN_CORE_EVENT_INTERNAL_H__
+#define __TIZEN_BASE_TIZEN_CORE_EVENT_INTERNAL_H__
+
+#include <tizen_core.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Generates the event ID.
+ * @since_tizen 9.0
+ *
+ * @return @c the generated event ID
+ *
+ * @code
+#include <tizen_core.h>
+{
+  tizen_core_event_object_h object = NULL;
+  int id;
+
+  id = tizen_core_event_generate_id();
+  tizen_core_event_object_create(&object, id, NULL);
+}
+ * @endcode
+ */
+int tizen_core_event_generate_id(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_BASE_TIZEN_CORE_EVENT_INTERNAL_H__ */
index 4bb220b210c016db98f6e92c4b147ab7cacba307..fb8b97601005dfdaf6e80fd54b2f97de3f410976 100644 (file)
@@ -39,7 +39,7 @@ class TizenCoreChannelTest : public ::testing::Test  {
     tizen_core_init();
     tizen_core_channel_make_pair(&sender_, &receiver_);
     tizen_core_channel_object_create(&object_);
-    tizen_core_channel_object_set_type(object_, 99);
+    tizen_core_channel_object_set_id(object_, 99);
     tizen_core_channel_object_set_data(object_, const_cast<char*>("test"));
 
     tizen_core_task_create("sender", true, &sender_task_);
@@ -132,10 +132,10 @@ TEST_F(TizenCoreChannelTest, tizen_core_channel_receiver_receive_P) {
   ret = tizen_core_channel_receiver_receive(receiver_, &object);
   ASSERT_EQ(ret, TIZEN_CORE_ERROR_NONE);
 
-  int type = -1;
-  ret = tizen_core_channel_object_get_type(object, &type);
+  int id = -1;
+  ret = tizen_core_channel_object_get_id(object, &id);
   ASSERT_EQ(ret, TIZEN_CORE_ERROR_NONE);
-  ASSERT_EQ(type, 99);
+  ASSERT_EQ(id, 99);
 
   char* data = nullptr;
   ret = tizen_core_channel_object_get_data(object,
@@ -187,30 +187,30 @@ TEST_F(TizenCoreChannelTest, tizen_core_channel_object_destroy_N) {
   ASSERT_EQ(ret, TIZEN_CORE_ERROR_INVALID_PARAMETER);
 }
 
-TEST_F(TizenCoreChannelTest, tizen_core_channel_object_set_type_P) {
-  int ret = tizen_core_channel_object_set_type(object_, 22);
+TEST_F(TizenCoreChannelTest, tizen_core_channel_object_set_id_P) {
+  int ret = tizen_core_channel_object_set_id(object_, 22);
   ASSERT_EQ(ret, TIZEN_CORE_ERROR_NONE);
 
-  int type = -1;
-  ret = tizen_core_channel_object_get_type(object_, &type);
+  int id = -1;
+  ret = tizen_core_channel_object_get_id(object_, &id);
   ASSERT_EQ(ret, TIZEN_CORE_ERROR_NONE);
-  ASSERT_EQ(type, 22);
+  ASSERT_EQ(id, 22);
 }
 
-TEST_F(TizenCoreChannelTest, tizen_core_channel_object_set_type_N) {
-  int ret = tizen_core_channel_object_set_type(nullptr, -1);
+TEST_F(TizenCoreChannelTest, tizen_core_channel_object_set_id_N) {
+  int ret = tizen_core_channel_object_set_id(nullptr, -1);
   ASSERT_EQ(ret, TIZEN_CORE_ERROR_INVALID_PARAMETER);
 }
 
-TEST_F(TizenCoreChannelTest, tizen_core_channel_object_get_type_P) {
-  int type = -1;
-  int ret = tizen_core_channel_object_get_type(object_, &type);
+TEST_F(TizenCoreChannelTest, tizen_core_channel_object_get_id_P) {
+  int id = -1;
+  int ret = tizen_core_channel_object_get_id(object_, &id);
   ASSERT_EQ(ret, TIZEN_CORE_ERROR_NONE);
-  ASSERT_EQ(type, 99);
+  ASSERT_EQ(id, 99);
 }
 
-TEST_F(TizenCoreChannelTest, tizen_core_channel_object_get_type_N) {
-  int ret = tizen_core_channel_object_get_type(nullptr, nullptr);
+TEST_F(TizenCoreChannelTest, tizen_core_channel_object_get_id_N) {
+  int ret = tizen_core_channel_object_get_id(nullptr, nullptr);
   ASSERT_EQ(ret, TIZEN_CORE_ERROR_INVALID_PARAMETER);
 }
 
index cc5a200c270aa54d0e673c36c1598f9f73d58308..e66c140f5fa1ad255d0045c8f98927cae0466a2c 100644 (file)
@@ -15,6 +15,7 @@
  */
 
 #include <tizen_core.h>
+#include <tizen_core_event_internal.h>
 #include <gmock/gmock.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -38,8 +39,8 @@ class TizenCoreEventTest : public ::testing::Test  {
   void SetUp() override {
     tizen_core_init();
     tizen_core_event_create(&event_);
-    type_ = tizen_core_event_generate_type();
-    tizen_core_event_object_create(&object_, type_, const_cast<char*>("test"));
+    id_ = tizen_core_event_generate_id();
+    tizen_core_event_object_create(&object_, id_, const_cast<char*>("test"));
     touched_ = false;
   }
 
@@ -49,7 +50,7 @@ class TizenCoreEventTest : public ::testing::Test  {
       object_ = nullptr;
     }
 
-    type_ = 0;
+    id_ = 0;
 
     if (event_) {
       tizen_core_event_destroy(event_);
@@ -61,7 +62,7 @@ class TizenCoreEventTest : public ::testing::Test  {
 
   tizen_core_event_h event_ = nullptr;
   tizen_core_event_object_h object_ = nullptr;
-  int type_ = 0;
+  int id_ = 0;
   bool touched_ = false;
 };
 
@@ -147,7 +148,7 @@ TEST_F(TizenCoreEventTest, tizen_core_event_emit_N) {
 
 TEST_F(TizenCoreEventTest, tizen_core_event_object_create_P) {
   tizen_core_event_object_h object = nullptr;
-  int ret = tizen_core_event_object_create(&object, type_,
+  int ret = tizen_core_event_object_create(&object, id_,
                                            const_cast<char *>("test2"));
   ASSERT_EQ(ret, TIZEN_CORE_ERROR_NONE);
   ASSERT_NE(object, nullptr);
@@ -171,8 +172,8 @@ TEST_F(TizenCoreEventTest, tizen_core_event_object_destroy_N) {
   ASSERT_EQ(ret, TIZEN_CORE_ERROR_INVALID_PARAMETER);
 }
 
-TEST_F(TizenCoreEventTest, tizen_core_event_object_set_on_destroy_P) {
-  int ret = tizen_core_event_object_set_on_destroy(
+TEST_F(TizenCoreEventTest, tizen_core_event_object_set_destroy_cb_P) {
+  int ret = tizen_core_event_object_set_destroy_cb(
       object_,
       [](void* data, void* user_data) {
         auto* test = static_cast<TizenCoreEventTest*>(user_data);
@@ -186,20 +187,20 @@ TEST_F(TizenCoreEventTest, tizen_core_event_object_set_on_destroy_P) {
   ASSERT_EQ(touched_, true);
 }
 
-TEST_F(TizenCoreEventTest, tizen_core_event_object_set_on_destroy_N) {
-  int ret = tizen_core_event_object_set_on_destroy(nullptr, nullptr, nullptr);
+TEST_F(TizenCoreEventTest, tizen_core_event_object_set_destroy_cb_N) {
+  int ret = tizen_core_event_object_set_destroy_cb(nullptr, nullptr, nullptr);
   ASSERT_EQ(ret, TIZEN_CORE_ERROR_INVALID_PARAMETER);
 }
 
-TEST_F(TizenCoreEventTest, tizen_core_event_object_get_type_P) {
-  int type = -1;
-  int ret = tizen_core_event_object_get_type(object_, &type);
+TEST_F(TizenCoreEventTest, tizen_core_event_object_get_id_P) {
+  int id = -1;
+  int ret = tizen_core_event_object_get_id(object_, &id);
   ASSERT_EQ(ret, TIZEN_CORE_ERROR_NONE);
-  ASSERT_EQ(type, type_);
+  ASSERT_EQ(id, id_);
 }
 
-TEST_F(TizenCoreEventTest, tizen_core_event_object_get_type_N) {
-  int ret = tizen_core_event_object_get_type(nullptr, nullptr);
+TEST_F(TizenCoreEventTest, tizen_core_event_object_get_id_N) {
+  int ret = tizen_core_event_object_get_id(nullptr, nullptr);
   ASSERT_EQ(ret, TIZEN_CORE_ERROR_INVALID_PARAMETER);
 }
 
@@ -216,8 +217,8 @@ TEST_F(TizenCoreEventTest, tizen_core_channel_object_get_data_N) {
   ASSERT_EQ(ret, TIZEN_CORE_ERROR_INVALID_PARAMETER);
 }
 
-TEST_F(TizenCoreEventTest, tizen_core_event_generate_type_P) {
-  int type = tizen_core_event_generate_type();
-  ASSERT_NE(type, 0);
-  ASSERT_EQ(type, type_ + 1);
+TEST_F(TizenCoreEventTest, tizen_core_event_generate_id_P) {
+  int id = tizen_core_event_generate_id();
+  ASSERT_NE(id, 0);
+  ASSERT_EQ(id, id_ + 1);
 }
\ No newline at end of file
index eafe3c9322a89aba832ec4170710dde2ba7e6412..a7c517cb7a69fdcbbe75724fad0588f772993c41 100644 (file)
@@ -18,6 +18,7 @@
 #include <unistd.h>
 #include <tizen_core.h>
 #include <tizen_core_internal.h>
+#include <tizen_core_event_internal.h>
 
 #include <gmock/gmock.h>
 
@@ -62,7 +63,7 @@ class TizenCoreTest : public ::testing::Test  {
 
   tizen_core_event_h event_ = nullptr;
   tizen_core_event_object_h event_object_ = nullptr;
-  int type_ = 0;
+  int id_ = 0;
 
   tizen_core_poll_fd_h poll_fd_ = nullptr;
 
@@ -96,7 +97,7 @@ class TizenCoreTest : public ::testing::Test  {
   void TCoreChannelSetUp() {
     tizen_core_channel_make_pair(&sender_, &receiver_);
     tizen_core_channel_object_create(&channel_object_);
-    tizen_core_channel_object_set_type(channel_object_, 99);
+    tizen_core_channel_object_set_id(channel_object_, 99);
     tizen_core_channel_object_set_data(channel_object_,
                                        const_cast<char*>("test"));
   }
@@ -120,8 +121,8 @@ class TizenCoreTest : public ::testing::Test  {
 
   void TCoreEventSetUp() {
     tizen_core_event_create(&event_);
-    type_ = tizen_core_event_generate_type();
-    tizen_core_event_object_create(&event_object_, type_,
+    id_ = tizen_core_event_generate_id();
+    tizen_core_event_object_create(&event_object_, id_,
                                    const_cast<char*>("test"));
   }
 
@@ -131,7 +132,7 @@ class TizenCoreTest : public ::testing::Test  {
       event_object_ = nullptr;
     }
 
-    type_ = 0;
+    id_ = 0;
 
     if (event_) {
       tizen_core_event_destroy(event_);
@@ -155,14 +156,12 @@ class TizenCoreTest : public ::testing::Test  {
 };
 
 TEST_F(TizenCoreTest, tizen_core_init_P) {
-  int ret = tizen_core_init();
-  ASSERT_NE(ret, 0);
+  tizen_core_init();
   tizen_core_shutdown();
 }
 
 TEST_F(TizenCoreTest, tizen_core_shutdown_P) {
-  int ret = tizen_core_shutdown();
-  ASSERT_EQ(ret, 0);
+  tizen_core_shutdown();
 }
 
 TEST_F(TizenCoreTest, tizen_core_ready_P) {
@@ -449,12 +448,12 @@ TEST_F(TizenCoreTest, tizen_core_add_channel_P) {
       main_core, receiver_,
       [](tizen_core_channel_object_h object, void* user_data) {
         auto* test = static_cast<TizenCoreTest*>(user_data);
-        int type = -1;
-        tizen_core_channel_object_get_type(object, &type);
+        int id = -1;
+        tizen_core_channel_object_get_id(object, &id);
         char* data = nullptr;
         tizen_core_channel_object_get_data(object,
                                            reinterpret_cast<void**>(&data));
-        if (type == 99 && data && !strcmp(data, "test"))
+        if (id == 99 && data && !strcmp(data, "test"))
           test->touched_ = true;
 
         tizen_core_task_quit(test->main_task_);
@@ -514,9 +513,9 @@ TEST_F(TizenCoreTest, tizen_core_emit_event_P) {
   int ret = tizen_core_event_add_handler(
       event_, [](tizen_core_event_object_h object, void* user_data) {
         auto* test = static_cast<TizenCoreTest*>(user_data);
-        int type = -1;
-        tizen_core_event_object_get_type(object, &type);
-        if (type == test->type_) {
+        int id = -1;
+        tizen_core_event_object_get_id(object, &id);
+        if (id == test->id_) {
           test->touched_ = true;
           tizen_core_task_quit(test->main_task_);
         }
index caae4ecef94e180586359d593e1e67c96266769d..946d19f81f92708b95ce630f24ad9766ec5af09f 100644 (file)
@@ -30,15 +30,15 @@ namespace channel {
 template <typename T>
 class EXPORT_API ChannelObject {
  public:
-  ChannelObject() : type_(0) {}
-  ChannelObject(int type, T data) : type_(type), data_(data) {}
+  ChannelObject() : id_(0) {}
+  ChannelObject(int id, T data) : id_(id), data_(data) {}
 
-  void SetType(int type) {
-    type_ = type;
+  void SetId(int id) {
+    id_ = id;
   }
 
-  int GetType() const {
-    return type_;
+  int GetId() const {
+    return id_;
   }
 
   void SetData(T data) {
@@ -58,7 +58,7 @@ class EXPORT_API ChannelObject {
   }
 
  private:
-  int type_;
+  int id_;
   T data_;
   std::string sender_;
 };
index 96d2e58ea9c3392ac7b00468115c30faefc8ae6f..400098fa507ac3bcee681ba1931df83976a429f2 100644 (file)
@@ -31,16 +31,16 @@ template <typename T>
 class EXPORT_API EventObject
     : public std::enable_shared_from_this<EventObject<T>> {
  public:
-  EventObject() : type_(0) {}
-  EventObject(int type, T data) : type_(type), data_(data) {}
+  EventObject() : id_(0) {}
+  EventObject(int id, T data) : id_(id), data_(data) {}
   virtual ~EventObject() = default;
 
-  void SetType(int type) {
-    type_ = type;
+  void SetId(int id) {
+    id_ = id;
   }
 
-  int GetType() const {
-    return type_;
+  int GetId() const {
+    return id_;
   }
 
   void SetData(T data) {
@@ -62,7 +62,7 @@ class EXPORT_API EventObject
   }
 
  private:
-  int type_;
+  int id_;
   T data_;
   std::atomic<uint32_t> ref_count_ { 0 };
   std::shared_ptr<EventObject<T>> self_;
index 89f27e8976c61d47089522347448216c98378b7a..ea24de41ba266788e278f0f7478d066515b4fa8f 100644 (file)
@@ -99,18 +99,18 @@ class SourceExt : public tizen_base::tizen_core::Source {
 
 }  // namespace
 
-API int tizen_core_init(void) {
-  return ++tizen_core_ref;
+API void tizen_core_init(void) {
+  ++tizen_core_ref;
 }
 
-API int tizen_core_shutdown(void) {
+API void tizen_core_shutdown(void) {
   if (tizen_core_ref <= 0)
-    return 0;
+    return;
 
   if (tizen_core_ref == 1)
     tizen_base::tizen_core::ContextManager::GetInst().DisposeAll();
 
-  return --tizen_core_ref;
+  --tizen_core_ref;
 }
 
 API bool tizen_core_ready(void) {
@@ -237,7 +237,7 @@ API int tizen_core_find_from_this_thread(tizen_core_h* core) {
   return TIZEN_CORE_ERROR_NONE;
 }
 
-API int tizen_core_add_idle_job(tizen_core_h core, tizen_core_cb callback,
+API int tizen_core_add_idle_job(tizen_core_h core, tizen_core_task_cb callback,
                                 void* user_data, tizen_core_source_h* source) {
   if (core == nullptr || callback == nullptr || source == nullptr) {
     _E("Invalid parameter");
@@ -256,7 +256,7 @@ API int tizen_core_add_idle_job(tizen_core_h core, tizen_core_cb callback,
 }
 
 API int tizen_core_add_timer(tizen_core_h core, unsigned int interval,
-                             tizen_core_cb callback, void* user_data,
+                             tizen_core_task_cb callback, void* user_data,
                              tizen_core_source_h* source) {
   if (core == nullptr || callback == nullptr || source == nullptr) {
     _E("Invalid parameter");
@@ -277,8 +277,8 @@ API int tizen_core_add_timer(tizen_core_h core, unsigned int interval,
 
 API int tizen_core_add_channel(tizen_core_h core,
                                tizen_core_channel_receiver_h receiver,
-                               tizen_core_channel_cb callback, void* user_data,
-                               tizen_core_source_h* source) {
+                               tizen_core_channel_receive_cb callback,
+                               void* user_data, tizen_core_source_h* source) {
   if (core == nullptr || receiver == nullptr || callback == nullptr ||
       source == nullptr) {
     _E("Invalid parameter");
index e2df6e6ec34c483d3a2cb63dbb598ee567550a5d..35bcac4d80d2b7db2ceab494807a5a555b7bc349 100644 (file)
@@ -170,8 +170,8 @@ API int tizen_core_channel_object_destroy(tizen_core_channel_object_h object) {
   return TIZEN_CORE_ERROR_NONE;
 }
 
-API int tizen_core_channel_object_set_type(tizen_core_channel_object_h object,
-                                           int type) {
+API int tizen_core_channel_object_set_id(tizen_core_channel_object_h object,
+                                         int id) {
   if (object == nullptr) {
     _E("Invalid parameter");
     return TIZEN_CORE_ERROR_INVALID_PARAMETER;
@@ -180,13 +180,13 @@ API int tizen_core_channel_object_set_type(tizen_core_channel_object_h object,
   auto* channel_object =
       static_cast<tizen_base::tizen_core::channel::ChannelObject<void*>*>(
           object);
-  channel_object->SetType(type);
+  channel_object->SetId(id);
   return TIZEN_CORE_ERROR_NONE;
 }
 
-API int tizen_core_channel_object_get_type(tizen_core_channel_object_h object,
-                                           int* type) {
-  if (object == nullptr || type == nullptr) {
+API int tizen_core_channel_object_get_id(tizen_core_channel_object_h object,
+                                         int* id) {
+  if (object == nullptr || id == nullptr) {
     _E("Invalid parameter");
     return TIZEN_CORE_ERROR_INVALID_PARAMETER;
   }
@@ -194,7 +194,7 @@ API int tizen_core_channel_object_get_type(tizen_core_channel_object_h object,
   auto* channel_object =
       static_cast<tizen_base::tizen_core::channel::ChannelObject<void*>*>(
           object);
-  *type = channel_object->GetType();
+  *id = channel_object->GetId();
   return TIZEN_CORE_ERROR_NONE;
 }
 
index 1c6f400d2ad9bfc6d35224ef71c2e91cfaef40ce..4e17394db044407f8ec43058828f01b22a19c4fa 100644 (file)
@@ -21,6 +21,7 @@
 #include <vector>
 
 #include "include/tizen_core.h"
+#include "include/tizen_core_event_internal.h"
 #include "tizen_base/event/event_broker.h"
 #include "tizen_base/log_private.h"
 #include "tizen_base/task.h"
@@ -44,14 +45,14 @@ class EventObjectExt
       destroy_cb_(GetData(), destroy_data_);
   }
 
-  void SetOnDestroy(tizen_core_event_object_on_destroy_cb callback,
+  void SetDestroyCb(tizen_core_event_object_destroy_cb callback,
                     void* data) {
     destroy_cb_ = callback;
     destroy_data_ = data;
   }
 
  private:
-  tizen_core_event_object_on_destroy_cb destroy_cb_ = nullptr;
+  tizen_core_event_object_destroy_cb destroy_cb_ = nullptr;
   void* destroy_data_ = nullptr;
 };
 
@@ -184,7 +185,7 @@ API int tizen_core_event_emit(tizen_core_event_h event,
 }
 
 API int tizen_core_event_object_create(tizen_core_event_object_h* object,
-                                       int type, void* data) {
+                                       int id, void* data) {
   if (object == nullptr) {
     _E("Invalid parameter");
     return TIZEN_CORE_ERROR_INVALID_PARAMETER;
@@ -193,7 +194,7 @@ API int tizen_core_event_object_create(tizen_core_event_object_h* object,
   if (!tizen_core_ready())
     return TIZEN_CORE_ERROR_INVALID_CONTEXT;
 
-  auto event_object = std::make_shared<EventObjectExt>(type, data);
+  auto event_object = std::make_shared<EventObjectExt>(id, data);
   if (event_object == nullptr) {
     _E("Out of memory");
     return TIZEN_CORE_ERROR_OUT_OF_MEMORY;
@@ -211,33 +212,33 @@ API int tizen_core_event_object_destroy(tizen_core_event_object_h object) {
   }
 
   auto* event_object = static_cast<EventObjectExt*>(object);
-  event_object->SetType(-1);
+  event_object->SetId(-1);
   event_object->Unref();
   return TIZEN_CORE_ERROR_NONE;
 }
 
-API int tizen_core_event_object_set_on_destroy(
+API int tizen_core_event_object_set_destroy_cb(
     tizen_core_event_object_h object,
-    tizen_core_event_object_on_destroy_cb callback, void* user_data) {
+    tizen_core_event_object_destroy_cb callback, void* user_data) {
   if (object == nullptr || callback == nullptr) {
     _E("Invalid parameter");
     return TIZEN_CORE_ERROR_INVALID_PARAMETER;
   }
 
   auto* event_object = static_cast<EventObjectExt*>(object);
-  event_object->SetOnDestroy(callback, user_data);
+  event_object->SetDestroyCb(callback, user_data);
   return TIZEN_CORE_ERROR_NONE;
 }
 
-API int tizen_core_event_object_get_type(tizen_core_event_object_h object,
-                                         int* type) {
-  if (object == nullptr || type == nullptr) {
+API int tizen_core_event_object_get_id(tizen_core_event_object_h object,
+                                       int* id) {
+  if (object == nullptr || id == nullptr) {
     _E("Invalid parameter");
     return TIZEN_CORE_ERROR_INVALID_PARAMETER;
   }
 
   auto* event_object = static_cast<EventObjectExt*>(object);
-  *type = event_object->GetType();
+  *id = event_object->GetId();
   return TIZEN_CORE_ERROR_NONE;
 }
 
@@ -253,8 +254,8 @@ API int tizen_core_event_object_get_data(tizen_core_event_object_h object,
   return TIZEN_CORE_ERROR_NONE;
 }
 
-API int tizen_core_event_generate_type(void) {
-  static std::atomic<int> type{0};
-  if ((type + 1) < 0) type = 0;
-  return type++;
+API int tizen_core_event_generate_id(void) {
+  static std::atomic<int> id{0};
+  if ((id + 1) < 0) id = 0;
+  return id++;
 }
\ No newline at end of file