add missing internal api from tizen 2.4 96/63896/3
authorJiwoong Im <jiwoong.im@samsung.com>
Mon, 28 Mar 2016 10:06:57 +0000 (19:06 +0900)
committerJiwoong Im <jiwoong.im@samsung.com>
Tue, 5 Apr 2016 02:36:04 +0000 (19:36 -0700)
- int ugman_resume_ug()
  int ugman_pause_ug()
  int ugman_create_cb()

Change-Id: I76f13d7f6567e50b46ad159f0f5c8603f4e46e77
Signed-off-by: Jiwoong Im <jiwoong.im@samsung.com>
CMakeLists.txt
include/ug-manager.h
include/ui-gadget.h
src/manager.c
src/ug.c

index 4bcd44f09807703d150e85b94374ac9a12b01243..a60e1aef75936b5165a43e7774e38a5bb75ee43b 100644 (file)
@@ -16,6 +16,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
 
 ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
 ADD_DEFINITIONS("-DDATAFS=\"${DATADIR}\"")
+ADD_DEFINITIONS("-DENABLE_UG_CREATE_CB")
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -Wall")
 
 INCLUDE(FindPkgConfig)
index dc6c778132aff54228a27bf1afd36ec7bdc6305e..133b6ab9c6c3c8d5eae7764c0975e87b7b01560e 100644 (file)
@@ -43,7 +43,9 @@ int ugman_init(void *win, enum ug_option opt);
 int ugman_init_efl(Evas_Object *win, enum ug_option opt);
 
 int ugman_resume(void);
+int ugman_resume_ug(ui_gadget_h ug);
 int ugman_pause(void);
+int ugman_pause_ug(ui_gadget_h ug);
 int ugman_send_event(enum ug_event event);
 int ugman_send_key_event(enum ug_key_event event);
 int ugman_send_message(ui_gadget_h ug, app_control_h msg);
@@ -53,4 +55,8 @@ void *ugman_get_conformant(void);
 
 int ugman_ug_exist(ui_gadget_h ug);
 
+#ifdef ENABLE_UG_CREATE_CB
+int ugman_create_cb(void (*create_cb)(char *, char *, char *, void *), void *user_data);
+#endif
+
 #endif                         /* __UG_MANAGER_H__ */
index 64c833c8fcc8924b8aecdbd475da6b923342a55e..9e0f6533304f7d8f3f266bd9100bf9ee45056030 100644 (file)
@@ -813,6 +813,78 @@ int ug_disable_effect(ui_gadget_h ug);
  */
 int ug_is_installed(const char *name);
 
+/**
+ * @brief Pauses the given UI gadget instance.
+ *
+ * @details @b Purpose: This function is used to pause the specified UI gadget instance and its children in the "Running" state. Eventually, the state of the UI gadget instance will be "Stopped".
+ *
+ * @details @b Typical @b use @b case: Application developers who want to pause the specified UI gadget instance can use this function.
+ *
+ * @details @b Method @b of @b function @b operation: "Pause" state operations of the UI gadgets with the "Running" state in the sub-tree that has the specified UI gadget as the root node are invoked by post-order traversal.
+ *
+ *          @b Context @b of @b function: This function is supposed to be called after successful initialization with ug_init() and creation of ug_create().
+ *
+ * @since_tizen 2.4
+ *
+ * @param[in] ug The UI gadget
+ *
+ * @return  @c 0 on success,
+ *          otherwise @c -1 on error
+ *
+ * @pre ug_init() should be called.
+ *     ug_create() should be used to create the @a ug gadget.
+ *
+ * @see ug_resume_ug()
+ *
+ * @par Sample code:
+ * @code
+ * #include <ui-gadget.h>
+ * ...
+ * // pauses the given UI gadget instance.
+ * ug_pause_ug(ug);
+ * ...
+ * @endcode
+ */
+int ug_pause_ug(ui_gadget_h ug);
+
+/**
+ * @brief Resumes the given UI gadget instance.
+ *
+ * @details @b Purpose: This function is used to resume the specified UI gadget instance and its children in the "Stopped" state. Eventually, the state of the UI gadget instance will be "Running".
+ *
+ * @details @b Typical @b use @b case: Application developers who want to resume the specified UI gadget instance can use this function.
+ *
+ * @details @b Method @b of @b function @b operation: "Resume" state operations of the UI gadgets with the "Stopped" state in the sub-tree that has specified UI gadget as the root node are invoked by post-order traversal.
+ *
+ * @details @b Context @b of @b function: This function should be called after successful initialization by ug_init() and creation of ug_create().
+ *
+ * @since_tizen 2.4
+ *
+ * @param[in] ug The UI gadget
+ *
+ * @return  @c 0 on success,
+ *          otherwise @c -1 on error
+ *
+ * @pre ug_init() should be called.
+ *     ug_create() should be used to create the @a ug gadget.
+ *
+ * @see ug_pause_ug()
+ *
+ * @par Sample code:
+ * @code
+ * #include <ui-gadget.h>
+ * ...
+ * // resumes the given UI gadget instance.
+ * ug_resume_ug(ug);
+ * ...
+ * @endcode
+ */
+int ug_resume_ug(ui_gadget_h ug);
+
+/**
+ * @}
+ */
+
 #ifdef __cplusplus
 }
 #endif
index 409082dae2c8febbfc777d432a13465851b4c94c..0f19b4af2f23782d013832a9fcdc4d02918eea0d 100644 (file)
 #define ugman_idler_add(func, data)  \
        ecore_job_add((Ecore_Cb) func, (void *)data);
 
+#ifdef ENABLE_UG_CREATE_CB
+typedef void (*fn_ug_trace_cb)(char *ug, char *mem, char *parent, void *user_data);
+fn_ug_trace_cb g_create_cb;
+void *g_create_cb_user_data;
+#endif
+
 struct ug_manager {
        ui_gadget_h root;
        ui_gadget_h fv_top;
@@ -605,6 +611,19 @@ static int ugman_ug_create(void *data)
 
        ugman_tree_dump(ug_man.root);
 
+#ifdef ENABLE_UG_CREATE_CB
+       if (g_create_cb) {
+               ui_gadget_h parent = ug->parent;
+
+               _DBG("invoke trace create cb(%p)", g_create_cb);
+
+               g_create_cb((char *)ug->name, (char *)ug->module->addr,
+                               parent ? (char *)parent->name : NULL,
+                               g_create_cb_user_data);
+       }
+#endif
+
+
        return 0;
 }
 
@@ -909,6 +928,25 @@ int ugman_resume(void)
        return 0;
 }
 
+int ugman_resume_ug(ui_gadget_h ug)
+{
+       if (!ug_man.is_initted) {
+               _ERR("ugman_pause_ug failed: manager is not initialized");
+               return -1;
+       }
+
+       if (!ug_man.root || !ug) {
+               _WRN("ugman_pause_ug failed: no root");
+               return -1;
+       }
+
+       _DBG("ugman_resume_ug called");
+
+       ugman_idler_add((Idle_Cb)ugman_ug_resume, ug);
+
+       return 0;
+}
+
 int ugman_pause(void)
 {
        /* PAUSE (Background) */
@@ -929,6 +967,25 @@ int ugman_pause(void)
        return 0;
 }
 
+int ugman_pause_ug(ui_gadget_h ug)
+{
+       if (!ug_man.is_initted) {
+               _ERR("ugman_pause_ug failed: manager is not initialized");
+               return -1;
+       }
+
+       if (!ug_man.root || !ug) {
+               _WRN("ugman_pause_ug failed: no root");
+               return -1;
+       }
+
+       _DBG("ugman_pause_ug called");
+
+       ugman_idler_add((Idle_Cb)ugman_ug_pause, ug);
+
+       return 0;
+}
+
 static int ugman_send_event_pre(void *data)
 {
        job_start();
@@ -1097,3 +1154,20 @@ int ugman_ug_exist(ui_gadget_h ug)
 {
        return ugman_ug_find(ug_man.root, ug);
 }
+
+#ifdef ENABLE_UG_CREATE_CB
+int ugman_create_cb(void (*create_cb)(char *, char *, char *, void *), void *user_data)
+{
+       if (create_cb == NULL) {
+               _DBG("disable trace create cb");
+               g_create_cb_user_data = NULL;
+               g_create_cb = NULL;
+       } else {
+               _DBG("enable trace create cb(%p)", create_cb);
+               g_create_cb_user_data = user_data;
+               g_create_cb = create_cb;
+       }
+
+       return 0;
+}
+#endif
index 0ae34164ed319fe9161f365ad22c3f39a0edd887..2090c58f85aa9a7ee3ff03210a18ce0ba2422448 100644 (file)
--- a/src/ug.c
+++ b/src/ug.c
@@ -140,11 +140,33 @@ UG_API int ug_pause(void)
        return ugman_pause();
 }
 
+UG_API int ug_pause_ug(ui_gadget_h ug)
+{
+       if (!ug || !ugman_ug_exist(ug)) {
+               _ERR("ug_pause_ug() failed: Invalid ug");
+               errno = EINVAL;
+               return -1;
+       }
+
+       return ugman_pause_ug(ug);
+}
+
 UG_API int ug_resume(void)
 {
        return ugman_resume();
 }
 
+UG_API int ug_resume_ug(ui_gadget_h ug)
+{
+       if (!ug || !ugman_ug_exist(ug)) {
+               _ERR("ug_resume_ug() failed: Invalid ug");
+               errno = EINVAL;
+               return -1;
+       }
+
+       return ugman_resume_ug(ug);
+}
+
 UG_API int ug_destroy(ui_gadget_h ug)
 {
        return ugman_ug_del(ug);
@@ -354,3 +376,15 @@ UG_API int ug_is_installed(const char *name)
        return ug_exist(name);
 }
 
+#ifdef ENABLE_UG_CREATE_CB
+UG_API int ug_create_cb(void (*create_cb)(char *, char *, char *, void *), void *user_data)
+{
+       int ret;
+
+       ret = ugman_create_cb(create_cb, user_data);
+       if (ret == -1)
+               _ERR("trace cb register fail");
+
+       return ret;
+}
+#endif