Support AUL watch control 14/209214/4
authorHwankyu Jhun <h.jhun@samsung.com>
Wed, 3 Jul 2019 10:30:38 +0000 (19:30 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 10 Jul 2019 08:21:21 +0000 (17:21 +0900)
To enable manual render, the entry point of the app-control callback is
needed. The aul_watch_control_cb() callback function is called before
calling the app_control_cb() callback function.

Adds:
 - aul_watch_control_add_handler()
 - aul_watch_control_remove_handler()

Change-Id: I14443adf62a905d5887118be9f313f689ae9df11
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
CMakeLists.txt
include/aul_watch_control.h [new file with mode: 0644]
src/aul_launch.c
src/aul_watch_control.c [new file with mode: 0644]
src/aul_watch_control_internal.h [new file with mode: 0644]

index f1a8502..05b1571 100755 (executable)
@@ -87,6 +87,7 @@ SET(HEADERS_LIB_AUL
        aul_comp_info.h
        aul_comp_context.h
        aul_comp_info_internal.h
+       aul_watch_control.h
        )
 
 # Install headers, other files
diff --git a/include/aul_watch_control.h b/include/aul_watch_control.h
new file mode 100644 (file)
index 0000000..e6c8fd9
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2019 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 __AUL_WATCH_CONTROL_H__
+#define __AUL_WATCH_CONTROL_H__
+
+#include <bundle.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief The watch control handle.
+ * @since_tizen 5.5
+ */
+typedef void *aul_watch_control_h;
+
+/**
+ * @brief Called when another application sends a launch request to the application.
+ * @details Before calling app_control_cb() function, this callback function is called.
+ * @since_tizen 5.5
+ *
+ * @param[in]   b               The bundle object
+ * @param[in]   user_data       The user data passed from the callback registration function
+ * @see aul_watch_control_add_handler()
+ *
+ * @remarks This is only for App Framework internally.
+ */
+typedef void (*aul_watch_control_cb)(bundle *b, void *user_data);
+
+/**
+ * @brief Adds the watch control handle.
+ * @since_tizen 5.5
+ *
+ * @param[in]   callback        The callback function
+ * @param[in]   user_data       The user data to be passed to the callback function
+ * @param[out]  handle          The watch control handle
+ * @return      @c 0 on success,
+ *              otherwise a negative error value
+ *
+ * @see aul_watch_control_remove_handler()
+ * @see aul_watch_control_cb()
+ *
+ * @remarks This is only for App Framework internally.
+ */
+int aul_watch_control_add_handler(aul_watch_control_cb callback,
+               void *user_data, aul_watch_control_h *handle);
+
+/**
+ * @brief Removes registered watch control handle.
+ * @since_tizen 5.5
+ *
+ * @param[in]   handle          The watch control handle
+ * @return      @c 0 on success,
+ *              otherwise a negative error value
+ *
+ * @see aul_watch_control_add_handler()
+ *
+ * @remarks This is only for App Framework internally.
+ */
+int aul_watch_control_remove_handler(aul_watch_control_h handle);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __AUL_WATCH_CONTROL_H__ */
index 637c78b..c735520 100644 (file)
@@ -36,6 +36,7 @@
 #include "aul_sock.h"
 #include "launch.h"
 #include "key.h"
+#include "aul_watch_control_internal.h"
 
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
 
@@ -84,6 +85,7 @@ static void __dispatch_app_start(aul_request_h req)
 {
        const char *str;
 
+       aul_watch_control_invoke(req->b);
        __invoke_aul_handler(AUL_START, req->b);
        str = bundle_get_val(req->b, AUL_K_DATA_CONTROL_TYPE);
        if (str && !strcmp(str, "CORE")) {
diff --git a/src/aul_watch_control.c b/src/aul_watch_control.c
new file mode 100644 (file)
index 0000000..6d06bef
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2019 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.
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <glib.h>
+
+#include "aul.h"
+#include "aul_api.h"
+#include "aul_util.h"
+#include "aul_watch_control.h"
+#include "aul_watch_control_internal.h"
+
+struct aul_watch_control_s {
+       aul_watch_control_cb callback;
+       void *user_data;
+};
+
+static GList *__controls;
+
+API int aul_watch_control_add_handler(aul_watch_control_cb callback,
+               void *user_data, aul_watch_control_h *handle)
+{
+       struct aul_watch_control_s *control;
+
+       if (!callback || !handle) {
+               _E("Invalid parameter");
+               return AUL_R_EINVAL;
+       }
+
+       control = calloc(1, sizeof(struct aul_watch_control_s));
+       if (!control) {
+               _E("Out of memory");
+               return AUL_R_ENOMEM;
+       }
+
+       control->callback = callback;
+       control->user_data = user_data;
+
+       __controls = g_list_append(__controls, control);
+
+       *handle = control;
+
+       return AUL_R_OK;
+}
+
+API int aul_watch_control_remove_handler(aul_watch_control_h handle)
+{
+       if (!handle || !g_list_find(__controls, handle)) {
+               _E("Invalid parameter");
+               return AUL_R_EINVAL;
+       }
+
+       __controls = g_list_remove(__controls, handle);
+       free(handle);
+
+       return AUL_R_OK;
+}
+
+static void __foreach_control_cb(gpointer data, gpointer user_data)
+{
+       struct aul_watch_control_s *control;
+       bundle *b = (bundle *)user_data;
+
+       control = (struct aul_watch_control_s *)data;
+       control->callback(b, control->user_data);
+}
+
+void aul_watch_control_invoke(bundle *b)
+{
+       if (!__controls)
+               return;
+
+       g_list_foreach(__controls, __foreach_control_cb, b);
+}
diff --git a/src/aul_watch_control_internal.h b/src/aul_watch_control_internal.h
new file mode 100644 (file)
index 0000000..cc3d3b6
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2019 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 __AUL_WATCH_CONTROL_INTENRAL_H__
+#define __AUL_WATCH_CONTROL_INTERNAL_H__
+
+#include <bundle.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void aul_watch_control_invoke(bundle *b);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __AUL_WATCH_CONTROL_INTERNAL_H__ */