From ba912093feafee9de63a17aeab5ca453b1762568 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Thu, 19 Sep 2024 13:14:36 +0900 Subject: [PATCH] Add new MMI CAPI Change-Id: I4287a51cc45b236ddfcf6633e56b2dce59e53881 --- capi/common/mmi-attribute.h | 283 ++++++ capi/common/mmi-data.h | 821 ++++++++++++++++++ capi/common/mmi-error.h | 72 ++ capi/common/mmi-primitive-value.h | 436 ++++++++++ capi/common/mmi-signal.h | 311 +++++++ capi/meson.build | 13 + capi/mmi.h | 374 ++++++++ capi/node/mmi-node-types.h | 377 ++++++++ capi/node/mmi-node.h | 575 ++++++++++++ capi/node/mmi-port.h | 324 +++++++ capi/workflow/mmi-workflow.h | 348 ++++++++ doc/mmi-doc.h | 212 +++++ src/mmi-cli/mmi-cli-node-tester.cpp | 6 +- src/mmi-cli/mmi-cli.cpp | 35 +- src/mmi-manager/mmi-ipc-ecore.cpp | 2 + src/mmi-manager/mmi-node-instance.cpp | 1 + src/mmi-manager/mmi-node-instance.h | 1 + src/mmi-manager/mmi-plugin-module-proxy.cpp | 2 + src/mmi-manager/mmi-port-instance.h | 3 +- src/mmi-manager/mmi-self-container.cpp | 72 +- src/mmi-manager/mmi-self-container.h | 4 +- src/mmi/meson.build | 1 + src/mmi/mmi-ipc-ecore.cpp | 2 + src/mmi/mmi-ipc-tidl.cpp | 2 + src/mmi/mmi-node-internal.h | 14 + src/mmi/mmi-node.cpp | 49 +- src/mmi/mmi-port-internal.h | 79 ++ src/mmi/mmi-port.cpp | 23 +- src/mmi/mmi-workflow-instance-manager.h | 16 + src/mmi/mmi-workflow-instance.cpp | 22 + src/mmi/mmi-workflow-internal.h | 22 + .../mmi-plugin-module-registry-tests.cpp | 2 +- .../mmi-workflow-instance-tests.cpp | 6 +- 33 files changed, 4445 insertions(+), 65 deletions(-) create mode 100644 capi/common/mmi-attribute.h create mode 100644 capi/common/mmi-data.h create mode 100644 capi/common/mmi-error.h create mode 100644 capi/common/mmi-primitive-value.h create mode 100644 capi/common/mmi-signal.h create mode 100644 capi/meson.build create mode 100644 capi/mmi.h create mode 100644 capi/node/mmi-node-types.h create mode 100644 capi/node/mmi-node.h create mode 100644 capi/node/mmi-port.h create mode 100644 capi/workflow/mmi-workflow.h create mode 100644 doc/mmi-doc.h create mode 100644 src/mmi/mmi-port-internal.h diff --git a/capi/common/mmi-attribute.h b/capi/common/mmi-attribute.h new file mode 100644 index 0000000..b4757b3 --- /dev/null +++ b/capi/common/mmi-attribute.h @@ -0,0 +1,283 @@ +/* + * 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_UIX_MMI_ATTRIBUTE_H__ +#define __TIZEN_UIX_MMI_ATTRIBUTE_H__ + + +#include +#include + + +/** +* @file mmi-attribute.h +*/ + + +/** +* @addtogroup CAPI_UIX_MMI_COMMON_MODULE +* @{ +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Handle for MMI attributes. + * @details This handle represents an attribute of a workflow or a node + * @since_tizen 9.0 + */ +typedef struct mmi_attribute_s* mmi_attribute_h; + + +/** + * @brief Creates a new MMI attribute with a given primitive value and name. + * @details This function initializes a new MMI attribute with the provided primitive value and name. + * @since_tizen 9.0 + * @remarks The @a attribute should be released using mmi_attribute_destroy(). + * + * @param[in] value The primitive value to set for the attribute. + * @param[in] name The name to assign to the attribute. + * @param[out] attribute A pointer to store the newly created attribute handle. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_primitive_value_h value; // Indicates the primitive value to be set in the attribute + mmi_attribute_h attribute = NULL; + mmi_attribute_create(value, "Name", &attribute); + ... + mmi_attribute_destroy(attribute); + * @endcode + */ +int mmi_attribute_create(mmi_primitive_value_h value, const char *name, mmi_attribute_h *attribute); + +/** + * @brief Sets the name of an MMI attribute. + * @details This function updates the name of the specified MMI attribute. + * @since_tizen 9.0 + * + * @param[in] attribute The attribute handle whose name needs to be updated. + * @param[in] name The new name to assign to the attribute. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + */ +int mmi_attribute_set_name(mmi_attribute_h attribute, const char *name); + +/** + * @brief Retrieves the name of an MMI attribute. + * @details This function fetches the name associated with the specified MMI attribute. + * @since_tizen 9.0 + * @remarks The @a name should be released using free(). + * + * @param[in] attribute The attribute handle from which to retrieve the name. + * @param[out] name A pointer to store the retrieved name. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_attribute_h attribute; // Indicates the handle of the attribute + char *name = NULL; + mmi_attribute_get_name(attribute, &name): + ... + free(name); + * @endcode + */ +int mmi_attribute_get_name(mmi_attribute_h attribute, char **name); + +/** + * @brief Retrieves the primitive value of an MMI attribute. + * @details This function fetches the primitive value stored in the specified MMI attribute. + * @since_tizen 9.0 + * @remarks The @a value should be released using mmi_primitive_value_destroy(). + * + * @param[in] attribute The attribute handle from which to retrieve the value. + * @param[out] value A pointer to store the retrieved primitive value handle. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @par Example + * @code + #include + ... + mmi_attribute_h attribute; // Indicates the handle of the attribute + mmi_primitive_value_h value = NULL; + mmi_attribute_get_value(attribute, &value); + ... + mmi_primitive_value_destroy(value); + * @endcode + */ +int mmi_attribute_get_value(mmi_attribute_h attribute, mmi_primitive_value_h *value); + +/** + * @brief Clones an existing MMI attribute. + * @details This function creates a deep copy of the specified MMI attribute. + * @since_tizen 9.0 + * @remarks The @a cloned should be released using mmi_attribute_destroy(). + * + * @param[in] attribute The attribute handle to clone. + * @param[out] cloned A pointer to store the handle of the cloned attribute. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_attribute_h attribute; // Indicates the handle of the attribute + mmi_attribute_h cloned = NULL; + mmi_attribute_clone(attribute, &cloned); + ... + mmi_attribute_destroy(cloned); + * @endcode + */ +int mmi_attribute_clone(mmi_attribute_h attribute, mmi_attribute_h *cloned); + +/** + * @brief Destroys an MMI attribute. + * @details This function releases all resources associated with the specified MMI attribute. + * @since_tizen 9.0 + * + * @param[in] attribute The attribute handle to destroy. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + */ +int mmi_attribute_destroy(mmi_attribute_h attribute); + +/** + * @brief Converts an MMI attribute to a byte array. + * @details This function serializes the specified MMI attribute into a byte array. + * @since_tizen 9.0 + * @remarks The @a bytes should be released using free(). + * + * @param[in] attribute The attribute handle to serialize. + * @param[out] bytes A pointer to store the serialized byte array. + * @param[out] length A pointer to store the length of the serialized byte array. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_attribute_h attribute; // Indicates the handle of the attribute + unsigned char *bytes = nullptr; + size_t size = 0; + mmi_attribute_to_bytes(attribute, &bytes, &size); + ... + free(bytes); + * @endcode + */ +int mmi_attribute_to_bytes(mmi_attribute_h attribute, unsigned char **bytes, size_t *length); + +/** + * @brief Reconstructs an MMI attribute from a byte array. + * @details This function deserializes the specified byte array into an MMI attribute. + * @since_tizen 9.0 + * @remarks The @a attribute should be released using mmi_attribute_destroy(). + * + * @param[in] bytes The byte array to deserialize. + * @param[in] length The length of the byte array. + * @param[out] attribute A pointer to store the reconstructed attribute handle. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + unsigned char *bytes; // Indicates the byte array to be converted + size_t size; // Indicates the size of the byte array + mmi_attribute_h attribute = NULL; + mmi_attribute_from_bytes(bytes, size, &attribute); + ... + mmi_attribute_destroy(attribute); + * @endcode + */ +int mmi_attribute_from_bytes(const unsigned char *bytes, size_t length, mmi_attribute_h *attribute); + +/** + * @brief Creates a new MMI attribute containing a string array. + * @details This function initializes a new MMI attribute with the provided string array and name. + * @since_tizen 9.0 + * @remarks The @a attribute should be released using mmi_attribute_destroy(). + * + * @param[in] name The name to assign to the attribute. + * @param[in] strings The array of strings to set for the attribute. + * @param[in] count The number of strings in the array. + * @param[out] attribute A pointer to store the newly created attribute handle. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_attribute_h attribute = NULL; + const char *commands[] = {"Open", "Close"}; + mmi_attribute_create_string_array("COMMANDS", commands, 2, &attribute); + ... + mmi_attribute_destroy(attribute); + * @endcode + */ +int mmi_attribute_create_string_array(const char *name, const char *strings[], size_t count, mmi_attribute_h *attribute); + + +#ifdef __cplusplus +} +#endif + + +/** + * @} + */ + + +#endif /* __TIZEN_UIX_MMI_ATTRIBUTE_H__ */ diff --git a/capi/common/mmi-data.h b/capi/common/mmi-data.h new file mode 100644 index 0000000..7118071 --- /dev/null +++ b/capi/common/mmi-data.h @@ -0,0 +1,821 @@ +/* + * 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_UIX_MMI_DATA_H__ +#define __TIZEN_UIX_MMI_DATA_H__ + + +#include + + +/** +* @file mmi-data.h +*/ + + +/** +* @addtogroup CAPI_UIX_MMI_COMMON_MODULE +* @ingroup CAPI_UIX_MMI_MODULE +* @{ +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumeration for MMI data types. + * @details This enumeration defines the different data types supported by the MMI framework. + * @since_tizen 9.0 + */ +typedef enum { + MMI_DATA_TYPE_BOOLEAN, /**< Boolean data type */ + MMI_DATA_TYPE_INTEGER, /**< Integer data type */ + MMI_DATA_TYPE_FLOAT, /**< Float data type */ + MMI_DATA_TYPE_TEXT, /**< Text data type */ + MMI_DATA_TYPE_JSON, /**< JSON data type */ + MMI_DATA_TYPE_USER_IDENTIFICATION, /**< User identification data type */ + MMI_DATA_TYPE_AUDIO, /**< Audio data type */ + MMI_DATA_TYPE_VIDEO, /**< Video data type */ + MMI_DATA_TYPE_COORDINATE, /**< Coordinate data type */ + MMI_DATA_TYPE_BOUNDING_BOX, /**< Bounding box data type */ + MMI_DATA_TYPE_ARRAY, /**< Array data type */ + MMI_DATA_TYPE_STRUCT, /**< Struct data type */ + MMI_DATA_TYPE_ANY, /**< Any data type */ +} mmi_data_type_e; + +/** + * @brief Handle for MMI data. + * @details This handle represents a data that can flow among nodes in MMI framework. + * @since_tizen 9.0 + */ +typedef struct mmi_data_s *mmi_data_h; + +/** + * @brief Creates a boolean data object. + * @details This function creates a boolean data object with the specified value. + * @since_tizen 9.0 + * @remarks The @a data should be released using mmi_data_destroy(). + * + * @param[in] value The boolean value to set in the data object. + * @param[out] data A pointer to store the handle of the created data object. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_data_h data = NULL; + mmi_data_create_bool(true, &data); + ... + mmi_data_destroy(data); + * @endcode + */ +int mmi_data_create_bool(bool value, mmi_data_h *data); + +/** + * @brief Creates an integer data object. + * @details This function creates an integer data object with the specified value. + * @since_tizen 9.0 + * @remarks The @a data should be released using mmi_data_destroy(). + * + * @param[in] value The integer value to set in the data object. + * @param[out] data A pointer to store the handle of the created data object. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_data_h data = NULL; + mmi_data_create_int(3, &data); + ... + mmi_data_destroy(data); + * @endcode + */ +int mmi_data_create_int(int value, mmi_data_h *data); + +/** + * @brief Creates a float data object. + * @details This function creates a float data object with the specified value. + * @since_tizen 9.0 + * @remarks The @a data should be released using mmi_data_destroy(). + * + * @param[in] value The float value to set in the data object. + * @param[out] data A pointer to store the handle of the created data object. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_data_h data = NULL; + mmi_data_create_float(3.14f, &data); + ... + mmi_data_destroy(data); + * @endcode + */ +int mmi_data_create_float(float value, mmi_data_h *data); + +/** + * @brief Creates a text data object. + * @details This function creates a text data object with the specified value. + * @since_tizen 9.0 + * @remarks The @a data should be released using mmi_data_destroy(). + * + * @param[in] value The text value to set in the data object. + * @param[out] data A pointer to store the handle of the created data object. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + const char *value; // Indicates the text to be set in the data object. + mmi_data_h data = NULL; + mmi_data_create_text(value, &data); + ... + mmi_data_destroy(data); + * @endcode + */ +int mmi_data_create_text(const char *value, mmi_data_h *data); + +/** + * @brief Creates an audio data object. + * @details This function creates an audio data object with the specified buffer and length. + * @since_tizen 9.0 + * @remarks The @a data should be released using mmi_data_destroy(). + * + * @param[in] ptr The pointer to the audio buffer. + * @param[in] len The length of the audio buffer. + * @param[out] data A pointer to store the handle of the created data object. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + const void *ptr; // Indicates the address of the data to be stored in the data object. + size_t len; // Indicates the length of the data to be stored in the data object. + mmi_data_h data = NULL; + mmi_data_create_audio(ptr, len, &data); + ... + mmi_data_destroy(data); + * @endcode + */ +int mmi_data_create_audio(const void *ptr, size_t len, mmi_data_h *data); + +/** + * @brief Creates a video data object. + * @details This function creates a video data object with the specified buffer and length. + * @since_tizen 9.0 + * @remarks The @a data should be released using mmi_data_destroy(). + * + * @param[in] ptr The pointer to the video buffer. + * @param[in] len The length of the video buffer. + * @param[out] data A pointer to store the handle of the created data object. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + const void *ptr; // Indicates the address of the data to be stored in the data object. + size_t len; // Indicates the length of the data to be stored in the data object. + mmi_data_h data = NULL; + mmi_data_create_video(ptr, len, &data); + ... + mmi_data_destroy(data); + * @endcode + */ +int mmi_data_create_video(const void *ptr, size_t len, mmi_data_h *data); + +/** + * @brief Creates a user identification data object. + * @details This function creates a user identification data object with the specified buffer and length. + * @since_tizen 9.0 + * @remarks The @a data should be released using mmi_data_destroy(). + * + * @param[in] ptr The pointer to the user identification buffer. + * @param[in] len The length of the user identification buffer. + * @param[out] data A pointer to store the handle of the created data object. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + const void *ptr; // Indicates the address of the data to be stored in the data object. + size_t len; // Indicates the length of the data to be stored in the data object. + mmi_data_h data = NULL; + mmi_data_create_user_identification(ptr, len, &data); + ... + mmi_data_destroy(data); + * @endcode + */ +int mmi_data_create_user_identification(const void *ptr, size_t len, mmi_data_h *data); + +/** + * @brief Creates a coordinate data object. + * @details This function creates a coordinate data object with the specified x and y values. + * @since_tizen 9.0 + * @remarks The @a data should be released using mmi_data_destroy(). + * + * @param[in] x The x-coordinate value. + * @param[in] y The y-coordinate value. + * @param[out] data A pointer to store the handle of the created data object. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_data_h data = NULL; + mmi_data_create_coordinate(0, 0, &data); + ... + mmi_data_destroy(data); + * @endcode + */ +int mmi_data_create_coordinate(int x, int y, mmi_data_h *data); + +/** + * @brief Creates a bounding box data object. + * @details This function creates a bounding box data object with the specified x, y, width, and height values. + * @since_tizen 9.0 + * @remarks The @a data should be released using mmi_data_destroy(). + * + * @param[in] x The x-coordinate value. + * @param[in] y The y-coordinate value. + * @param[in] w The width value. + * @param[in] h The height value. + * @param[out] data A pointer to store the handle of the created data object. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_data_h data = NULL; + mmi_data_create_bounding_box(0, 0, 10, 10, &data); + ... + mmi_data_destroy(data); + * @endcode + */ +int mmi_data_create_bounding_box(int x, int y, int w, int h, mmi_data_h *data); + +/** + * @brief Creates a new data array handle. + * @details This function allocates memory for a new data array handle and initializes it. + * @since_tizen 9.0 + * @remarks The @a array_handle should be released using mmi_data_destroy(). + * + * @param[out] array_handle A pointer to the newly created data array handle. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_data_h array_handle = NULL; + mmi_data_create_array(&array_handle); + ... + mmi_data_destroy(array_handle); + * @endcode + */ +int mmi_data_create_array(mmi_data_h *array_handle); + +/** + * @brief Adds an element to a data array. + * @details This function adds a new element to the specified data array. + * @since_tizen 9.0 + * + * @param[in] array_handle The handle to the data array where the element will be added. + * @param[in] element The handle to the element to be added to the array. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + */ +int mmi_data_add_array_element(mmi_data_h array_handle, mmi_data_h element); + +/** + * @brief Creates a new data structure handle. + * @details This function allocates memory for a new data structure handle and initializes it. + * @since_tizen 9.0 + * @remarks The @a struct_handle should be released using mmi_data_destroy(). + * + * @param[out] struct_handle A pointer to the newly created data structure handle. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_data_h struct_handle = NULL; + mmi_data_create_struct(&struct_handle); + ... + mmi_data_destroy(struct_handle); + * @endcode + */ +int mmi_data_create_struct(mmi_data_h *struct_handle); + +/** + * @brief Sets an element in a data structure. + * @details This function sets the value of an element in the specified data structure. + * @since_tizen 9.0 + * + * @param[in] struct_handle The handle to the data structure where the element will be set. + * @param[in] name The name of the element to be set. + * @param[in] element The handle to the element to be set in the structure. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + */ +int mmi_data_set_struct_element(mmi_data_h struct_handle, const char *name, mmi_data_h element); + +/** + * @brief Retrieves the type of a data handle. + * @details This function retrieves the type of the specified data handle. + * @since_tizen 9.0 + * + * @param[in] data The handle to the data whose type is to be retrieved. + * @param[out] type A pointer to the variable where the type will be stored. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + */ +int mmi_data_get_type(mmi_data_h data, mmi_data_type_e *type); + +/** + * @brief Retrieves the boolean value from a data handle. + * @details This function retrieves the boolean value stored in the specified data handle. + * @since_tizen 9.0 + * + * @param[in] data The handle to the data from which the boolean value will be retrieved. + * @param[out] value A pointer to the variable where the boolean value will be stored. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + */ +int mmi_data_get_bool(mmi_data_h data, bool *value); + +/** + * @brief Retrieves the integer value from a data handle. + * @details This function retrieves the integer value stored in the specified data handle. + * @since_tizen 9.0 + * + * @param[in] data The handle to the data from which the integer value will be retrieved. + * @param[out] value A pointer to the variable where the integer value will be stored. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + */ +int mmi_data_get_int(mmi_data_h data, int *value); + +/** + * @brief Retrieves the floating-point value from a data handle. + * @details This function retrieves the floating-point value stored in the specified data handle. + * @since_tizen 9.0 + * + * @param[in] data The handle to the data from which the floating-point value will be retrieved. + * @param[out] value A pointer to the variable where the floating-point value will be stored. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + */ +int mmi_data_get_float(mmi_data_h data, float *value); + +/** + * @brief Retrieves the text string from a data handle. + * @details This function retrieves the text string stored in the specified data handle. + * @since_tizen 9.0 + * @remarks The @a text should not be released. + * The @a text is available until data is released. + * + * @param[in] data The handle to the data from which the text string will be retrieved. + * @param[out] text A pointer to the variable where the text string will be stored. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @par Example + * @code + #include + ... + mmi_data_h data; // Indicates the data handle + const char *text = NULL; + mmi_data_get_text(data, &text); + * @endcode + */ +int mmi_data_get_text(mmi_data_h data, const char **text); + +/** + * @brief Retrieves the audio data from a data handle. + * @details This function retrieves the audio data stored in the specified data handle. + * @since_tizen 9.0 + * @remarks The @a ptr should not be released. + * The @a ptr is available until data is released. + * + * @param[in] data The handle to the data from which the audio data will be retrieved. + * @param[out] ptr A pointer to the variable where the audio data will be stored. + * @param[out] len A pointer to the variable where the length of the audio data will be stored. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @par Example + * @code + #include + ... + mmi_data_h data; // Indicates the data handle + const void *ptr = NULL; + size_t len = 0; + mmi_data_get_audio(data, &ptr, &len); + * @endcode + */ +int mmi_data_get_audio(mmi_data_h data, const void **ptr, size_t *len); + +/** + * @brief Retrieves the video data from a data handle. + * @details This function retrieves the video data stored in the specified data handle. + * @since_tizen 9.0 + * @remarks The @a ptr should not be released. + * The @a ptr is available until data is released. + * + * @param[in] data The handle to the data from which the video data will be retrieved. + * @param[out] ptr A pointer to the variable where the video data will be stored. + * @param[out] len A pointer to the variable where the length of the video data will be stored. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @par Example + * @code + #include + ... + mmi_data_h data; // Indicates the data handle + const void *ptr = NULL; + size_t len = 0; + mmi_data_get_video(data, &ptr, &len); + * @endcode + */ +int mmi_data_get_video(mmi_data_h data, const void **ptr, size_t *len); + +/** + * @brief Retrieves the user identification data from a data handle. + * @details This function retrieves the user identification data stored in the specified data handle. + * @since_tizen 9.0 + * @remarks The @a ptr should not be released. + * The @a ptr is available until data is released. + * + * @param[in] data The handle to the data from which the user identification data will be retrieved. + * @param[out] ptr A pointer to the variable where the user identification data will be stored. + * @param[out] len A pointer to the variable where the length of the user identification data will be stored. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @par Example + * @code + #include + ... + mmi_data_h data; // Indicates the data handle + const void *ptr = NULL; + size_t len = 0; + mmi_data_get_user_identification(data, &ptr, &len); + * @endcode + */ +int mmi_data_get_user_identification(mmi_data_h data, const void **ptr, size_t *len); + +/** + * @brief Retrieves the coordinate data from a data handle. + * @details This function retrieves the coordinate data stored in the specified data handle. + * @since_tizen 9.0 + * + * @param[in] data The handle to the data from which the coordinate data will be retrieved. + * @param[out] x A pointer to the variable where the x-coordinate value will be stored. + * @param[out] y A pointer to the variable where the y-coordinate value will be stored. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + */ +int mmi_data_get_coordinate(mmi_data_h data, int *x, int *y); + +/** + * @brief Retrieves the bounding box of the given data. + * @details This function retrieves the bounding box coordinates (x, y, width, height) of the specified data. + * + * @since_tizen 9.0 + * + * @param[in] data The handle to the data object. + * @param[out] x Pointer to an integer where the x-coordinate will be stored. + * @param[out] y Pointer to an integer where the y-coordinate will be stored. + * @param[out] w Pointer to an integer where the width will be stored. + * @param[out] h Pointer to an integer where the height will be stored. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + */ +int mmi_data_get_bounding_box(mmi_data_h data, int *x, int *y, int *w, int *h); + +/** + * @brief Gets the number of elements in the array. + * @details This function retrieves the total count of elements present in the specified array. + * + * @since_tizen 9.0 + * + * @param[in] array The handle to the array object. + * @param[out] count Pointer to a size_t where the element count will be stored. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + */ +int mmi_data_get_array_count(mmi_data_h array, size_t *count); + +/** + * @brief Retrieves an element from the array at the specified index. + * @details This function retrieves a handle to the element located at the specified index in the array. + * @since_tizen 9.0 + * @remarks The @a element should not be released. + * The @a element is available until struct_handle is released. + * + * @param[in] array The handle to the array object. + * @param[in] index The index of the element to retrieve. + * @param[out] element Pointer to a #mmi_data_h where the element handle will be stored. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_data_h data; // Indicates the handle of the data + mmi_data_h element = NULL; + mmi_data_get_array_element(data, 1, &element); + ... + * @endcode + */ +int mmi_data_get_array_element(mmi_data_h array, size_t index, mmi_data_h *element); + +/** + * @brief Retrieves an element from the structure by its name. + * @details This function retrieves a handle to the element in the structure identified by the specified name. + * @since_tizen 9.0 + * @remarks The @a element should not be released. + * The @a element is available until struct_handle is released. + * + * @param[in] struct_handle The handle to the structure object. + * @param[in] name The name of the element to retrieve. + * @param[out] element Pointer to a #mmi_data_h where the element handle will be stored. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_data_h data; // Indicates the handle of the data + mmi_data_h element = NULL; + mmi_data_get_struct_element(data, "element_1", &element); + ... + * @endcode + */ +int mmi_data_get_struct_element(mmi_data_h struct_handle, const char *name, mmi_data_h *element); + +/** + * @brief Gets the number of elements in the structure. + * @details This function retrieves the total count of elements present in the specified structure. + * + * @since_tizen 9.0 + * + * @param[in] struct_handle The handle to the structure object. + * @param[out] count Pointer to a size_t where the element count will be stored. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + */ +int mmi_data_get_struct_count(mmi_data_h struct_handle, size_t *count); + +/** + * @brief Retrieves the name of the element at the specified index in the structure. + * @details This function retrieves the name of the element located at the specified index in the structure. + * @since_tizen 9.0 + * @remarks The @a name should not be released. + * The @a name is available until struct_handle is released. + * + * @param[in] struct_handle The handle to the structure object. + * @param[in] index The index of the element whose name is to be retrieved. + * @param[out] name Pointer to a const char pointer where the name will be stored. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_data_h data; // Indicates the handle of the data structure + char *name = NULL; + mmi_data_get_struct_element_name(data, 1, &name): + ... + * @endcode + */ +int mmi_data_get_struct_element_name(mmi_data_h struct_handle, size_t index, const char **name); + +/** + * @brief Retrieves the of the element at the specified index in the structure. + * @details This function retrieves a handle to the value of the element located at the specified index in the structure. + * @since_tizen 9.0 + * @remarks The @a element should not be released. + * The @a element is available until struct_handle is released. + * + * @param[in] struct_handle The handle to the structure object. + * @param[in] index The index of the element whose value is to be retrieved. + * @param[out] element Pointer to a #mmi_data_h where the element handle will be stored. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_data_h data; // Indicates the handle of the data structure + mmi_data_h element = NULL; + mmi_data_get_struct_element_value(data, 1, &element); + ... + * @endcode + */ +int mmi_data_get_struct_element_value(mmi_data_h struct_handle, size_t index, mmi_data_h *element); + +/** + * @brief Converts the MMI data handle to a byte array. + * @details This function converts the given MMI data handle into a byte array representation. + * @since_tizen 9.0 + * @remarks The @a bytes should be released using free(). + * + * @param[in] data The handle to the MMI data. + * @param[out] bytes A pointer to store the resulting byte array. + * @param[out] length A pointer to store the length of the byte array. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_data_h data; // Indicates the handle of the data + unsigned char *bytes = nullptr; + size_t size = 0; + mmi_data_to_bytes(data, &bytes, &size); + ... + free(bytes); + * @endcode + */ +int mmi_data_to_bytes(mmi_data_h data, unsigned char **bytes, size_t *length); + +/** + * @brief Creates an MMI data handle from a byte array. + * @details This function creates an MMI data handle from the provided byte array. + * @since_tizen 9.0 + * @remarks The @a data should be released using mmi_data_destroy(). + * + * @param[in] bytes The byte array containing the data. + * @param[in] length The length of the byte array. + * @param[out] data A pointer to store the resulting MMI data handle. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + unsigned char *bytes; // Indicates the byte array to be converted + size_t size; // Indicates the size of the byte array + mmi_data_h data = NULL; + mmi_data_from_bytes(bytes, size, &data); + ... + mmi_data_destroy(data); + * @endcode + */ +int mmi_data_from_bytes(unsigned char *bytes, size_t length, mmi_data_h *data); + +/** + * @brief Destroys the given MMI data handle. + * @details This function destroys the specified MMI data handle and releases associated resources. + * @since_tizen 9.0 + * + * @param[in] data The handle to the MMI data. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + */ +int mmi_data_destroy(mmi_data_h data); + + +#ifdef __cplusplus +} +#endif + + +/** + * @} + */ + + +#endif /* __TIZEN_UIX_MMI_DATA_H__ */ diff --git a/capi/common/mmi-error.h b/capi/common/mmi-error.h new file mode 100644 index 0000000..a597ff7 --- /dev/null +++ b/capi/common/mmi-error.h @@ -0,0 +1,72 @@ +/* + * 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_UIX_MMI_ERROR_H__ +#define __TIZEN_UIX_MMI_ERROR_H__ + + +#include + + +/** +* @file mmi-error.h +*/ + + +/** +* @addtogroup CAPI_UIX_MMI_COMMON_MODULE +* @{ +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef TIZEN_ERROR_MMI +#define TIZEN_ERROR_MMI -0x030F0000 +#endif + +/** + * @brief Enumerations for MMI error codes. + * @since_tizen 9.0 + */ +typedef enum { + MMI_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + MMI_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of Memory */ + MMI_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */ + MMI_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + MMI_ERROR_TIMED_OUT = TIZEN_ERROR_TIMED_OUT, /**< No answer from the daemon */ + MMI_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ + MMI_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< MMI NOT supported */ + MMI_ERROR_OPERATION_FAILED = (TIZEN_ERROR_MMI | 0x01), /**< Operation failed */ + MMI_ERROR_RESOURCE_BUSY = (TIZEN_ERROR_MMI | 0x02), /**< Resource busy */ +} mmi_error_e; + + +#ifdef __cplusplus +} +#endif + + +/** + * @} + */ + + +#endif /* __TIZEN_UIX_MMI_ERROR_H__ */ diff --git a/capi/common/mmi-primitive-value.h b/capi/common/mmi-primitive-value.h new file mode 100644 index 0000000..6dee42c --- /dev/null +++ b/capi/common/mmi-primitive-value.h @@ -0,0 +1,436 @@ +/* + * 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_UIX_MMI_PRIMITIVE_VALUE_H__ +#define __TIZEN_UIX_MMI_PRIMITIVE_VALUE_H__ + + +#include + + +/** +* @file mmi-primitive-value.h +*/ + + +/** +* @addtogroup CAPI_UIX_MMI_COMMON_MODULE +* @{ +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * @brief Enumeration for primitive value types. + * @details This enumeration defines the different types of primitive values supported by the MMI framework. + * @since_tizen 9.0 +*/ +typedef enum { + MMI_PRIMITIVE_VALUE_TYPE_INT, /**< Integer type */ + MMI_PRIMITIVE_VALUE_TYPE_FLOAT, /**< Floating-point type */ + MMI_PRIMITIVE_VALUE_TYPE_STRING, /**< String type */ + MMI_PRIMITIVE_VALUE_TYPE_BOOL, /**< Boolean type */ + MMI_PRIMITIVE_VALUE_TYPE_ARRAY, /**< Array type */ +} mmi_primitive_value_type_e; + +/** + * @brief Handle for MMI primitive value. + * @details This handle represents a primitive value that an attribute can store within the MMI framework. + * @since_tizen 9.0 + */ +typedef struct mmi_primitive_value_s* mmi_primitive_value_h; + + +/** + * @brief Creates a primitive value handle for an integer. + * @details This function creates a handle for an integer primitive value. + * @since_tizen 9.0 + * @remarks The @a handle should be released using mmi_primitive_value_destroy(). + * + * @param[in] data The integer value to be stored in the handle. + * @param[out] handle Pointer to the handle which will be populated with the newly created handle. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_primitive_value_h handle = NULL; + mmi_primitive_value_create_int(3, &handle); + ... + mmi_primitive_value_destroy(handle); + * @endcode + */ +int mmi_primitive_value_create_int(int data, mmi_primitive_value_h *handle); + +/** + * @brief Creates a primitive value handle for a floating-point number. + * @details This function creates a handle for a floating-point primitive value. + * @since_tizen 9.0 + * @remarks The @a handle should be released using mmi_primitive_value_destroy(). + * + * @param[in] data The floating-point value to be stored in the handle. + * @param[out] handle Pointer to the handle which will be populated with the newly created handle. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_primitive_value_h handle = NULL; + mmi_primitive_value_create_float(3.14, &handle); + ... + mmi_primitive_value_destroy(handle); + * @endcode + */ +int mmi_primitive_value_create_float(float data, mmi_primitive_value_h *handle); + +/** + * @brief Creates a primitive value handle for a string. + * @details This function creates a handle for a string primitive value. + * @since_tizen 9.0 + * @remarks The @a handle should be released using mmi_primitive_value_destroy(). + * + * @param[in] data The string value to be stored in the handle. + * @param[out] handle Pointer to the handle which will be populated with the newly created handle. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_primitive_value_h handle = NULL; + mmi_primitive_value_create_string("Test", &handle); + ... + mmi_primitive_value_destroy(handle); + * @endcode + */ +int mmi_primitive_value_create_string(const char *data, mmi_primitive_value_h *handle); + +/** + * @brief Creates a primitive value handle for a boolean. + * @details This function creates a handle for a boolean primitive value. + * @since_tizen 9.0 + * @remarks The @a handle should be released using mmi_primitive_value_destroy(). + * + * @param[in] data The boolean value to be stored in the handle. + * @param[out] handle Pointer to the handle which will be populated with the newly created handle. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_primitive_value_h handle = NULL; + mmi_primitive_value_create_bool(true, &handle); + ... + mmi_primitive_value_destroy(handle); + * @endcode + */ +int mmi_primitive_value_create_bool(bool data, mmi_primitive_value_h *handle); + +/** + * @brief Creates a primitive value handle for an array. + * @details This function creates a handle for an array primitive value. + * @since_tizen 9.0 + * @remarks The @a handle should be released using mmi_primitive_value_destroy(). + * + * @param[out] handle Pointer to the handle which will be populated with the newly created handle. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_primitive_value_h handle = NULL; + mmi_primitive_value_create_array(&handle); + ... + mmi_primitive_value_destroy(handle); + * @endcode + */ +int mmi_primitive_value_create_array(mmi_primitive_value_h *handle); + +/** + * @brief Adds an element to a primitive value array. + * @details This function adds an element to a primitive value array. + * @since_tizen 9.0 + * + * @param[in] array The handle of the array to which the element will be added. + * @param[in] element The handle of the element to be added to the array. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + */ +int mmi_primitive_value_add_array_element(mmi_primitive_value_h array, mmi_primitive_value_h element); + +/** + * @brief Gets the type of the primitive value. + * @details This function retrieves the type of the primitive value represented by the given handle. + * @since_tizen 9.0 + * + * @param[in] handle The handle to the primitive value. + * @param[out] type A pointer to store the type of the primitive value. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + */ +int mmi_primitive_value_get_type(mmi_primitive_value_h handle, mmi_primitive_value_type_e *type); + +/** + * @brief Gets the integer value from the primitive value. + * @details This function retrieves the integer value stored in the primitive value represented by the given handle. + * @since_tizen 9.0 + * + * @param[in] handle The handle to the primitive value. + * @param[out] value A pointer to store the integer value. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + */ +int mmi_primitive_value_get_int(mmi_primitive_value_h handle, int *value); + +/** + * @brief Gets the floating-point value from the primitive value. + * @details This function retrieves the floating-point value stored in the primitive value represented by the given handle. + * @since_tizen 9.0 + * + * @param[in] handle The handle to the primitive value. + * @param[out] value A pointer to store the floating-point value. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + */ +int mmi_primitive_value_get_float(mmi_primitive_value_h handle, float *value); + +/** + * @brief Gets the string value from the primitive value. + * @details This function retrieves the string value stored in the primitive value represented by the given handle. + * @since_tizen 9.0 + * @remarks The @a string should not be released. + * The @a string is available until data is released. + * + * @param[in] handle The handle to the primitive value. + * @param[out] string A pointer to store the string value. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @par Example + * @code + #include + ... + mmi_primitive_value_h value; // Indicates the primitive value handle + const char *string = NULL; + mmi_primitive_value_get_string(value, &string); + * @endcode + */ +int mmi_primitive_value_get_string(mmi_primitive_value_h handle, const char **string); + +/** + * @brief Gets the boolean value from the primitive value. + * @details This function retrieves the boolean value stored in the primitive value represented by the given handle. + * @since_tizen 9.0 + * + * @param[in] handle The handle to the primitive value. + * @param[out] value A pointer to store the boolean value. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + */ +int mmi_primitive_value_get_bool(mmi_primitive_value_h handle, bool *value); + +/** + * @brief Gets the count of elements in the array. + * @details This function retrieves the number of elements in the array represented by the given handle. + * @since_tizen 9.0 + * + * @param[in] array The handle to the array. + * @param[out] count A pointer to store the number of elements in the array. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + */ +int mmi_primitive_value_get_array_count(mmi_primitive_value_h array, size_t *count); + +/** + * @brief Gets the element at the specified index in the array. + * @details This function retrieves the element at the specified index in the array represented by the given handle. + * @since_tizen 9.0 + * @remarks The @a element should not be released. + * The @a element is available until struct_handle is released. + * + * @param[in] array The handle to the array. + * @param[in] index The index of the element to retrieve. + * @param[out] element A pointer to store the handle of the retrieved element. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @par Example + * @code + #include + ... + mmi_primitive_value_h value; // Indicates the handle of the primitive value + mmi_primitive_value_h element = NULL; + mmi_primitive_value_get_array_element(value, 1, &element); + ... + * @endcode + */ +int mmi_primitive_value_get_array_element(mmi_primitive_value_h array, size_t index, mmi_primitive_value_h *element); + +/** + * @brief Clones a primitive value handle. + * @details This function creates a copy of the given primitive value handle. + * @since_tizen 9.0 + * @remarks The @a cloned should be released using mmi_attribute_destroy(). + * + * @param[in] handle The handle of the primitive value to be cloned. + * @param[out] cloned A pointer to store the cloned primitive value handle. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_primitive_value_h value; // Indicates the handle of the primitive value + mmi_primitive_value_h cloned = NULL; + mmi_primitive_value_clone(value, &cloned); + ... + mmi_primitive_value_destroy(cloned); + * @endcode + */ +int mmi_primitive_value_clone(mmi_primitive_value_h handle, mmi_primitive_value_h *cloned); + +/** + * @brief Destroys a primitive value handle. + * @details This function frees the resources associated with the given primitive value handle. + * @since_tizen 9.0 + * + * @param[in] handle The handle of the primitive value to be destroyed. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + */ +int mmi_primitive_value_destroy(mmi_primitive_value_h handle); + +/** + * @brief Converts a primitive value handle to a byte array. + * @details This function serializes the given primitive value handle into a byte array. + * @since_tizen 9.0 + * @remarks The @a bytes should be released using free(). + * + * @param[in] handle The handle of the primitive value to be converted. + * @param[out] bytes A pointer to store the resulting byte array. + * @param[out] size A pointer to store the size of the byte array. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_primitive_value_h value; // Indicates the handle of the primitive value + unsigned char *bytes = nullptr; + size_t size = 0; + mmi_primitive_value_to_bytes(value, &bytes, &size); + ... + free(bytes); + * @endcode + */ +int mmi_primitive_value_to_bytes(mmi_primitive_value_h handle, unsigned char **bytes, size_t *size); + +/** + * @brief Creates a primitive value handle from a byte array. + * @details This function deserializes a byte array into a primitive value handle. + * @since_tizen 9.0 + * @remarks The @a handle should be released using mmi_primitive_value_destroy(). + * + * @param[in] bytes The byte array containing the serialized primitive value. + * @param[in] size The size of the byte array. + * @param[out] handle A pointer to store the resulting primitive value handle. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + unsigned char *bytes; // Indicates the byte array to be converted + size_t size; // Indicates the size of the byte array + mmi_primitive_value_h value = NULL; + mmi_primitive_value_from_bytes(bytes, size, &value); + ... + mmi_primitive_value_destroy(data); + * @endcode + */ +int mmi_primitive_value_from_bytes(unsigned char *bytes, size_t size, mmi_primitive_value_h *handle); + +#ifdef __cplusplus +} +#endif + + +/** + * @} + */ + + +#endif /* __TIZEN_UIX_MMI_PRIMITIVE_VALUE_H__ */ diff --git a/capi/common/mmi-signal.h b/capi/common/mmi-signal.h new file mode 100644 index 0000000..2917bed --- /dev/null +++ b/capi/common/mmi-signal.h @@ -0,0 +1,311 @@ +/* + * 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_UIX_MMI_SIGNAL_H__ +#define __TIZEN_UIX_MMI_SIGNAL_H__ + + +#include +#include +#include + +#include + +/** +* @file mmi-signal.h +*/ + + +/** +* @addtogroup CAPI_UIX_MMI_COMMON_MODULE +* @{ +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Handle for MMI signal parameter. + * @details This handle represents a parameter that a signal can embed within the MMI framework. + * @since_tizen 9.0 + */ +typedef struct mmi_signal_parameter_s* mmi_signal_parameter_h; + +/** + * @brief Handle for MMI signal. + * @details This handle represents a signal that can be sent to a workflow or a node within the MMI framework. + * @since_tizen 9.0 + */ +typedef struct mmi_signal_s* mmi_signal_h; + +/** + * @brief Creates a new signal parameter. + * @details This function creates a new signal parameter with the given primitive value and name. + * @since_tizen 9.0 + * @remarks The @a parameter should be released using mmi_signal_parameter_destroy(). + * + * @param[in] value The primitive value to associate with the parameter. + * @param[in] name The name of the parameter. + * @param[out] parameter A pointer to store the newly created parameter handle. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_primitive_value_h value; // Indicates the primitive value to be set in the signal_parameter + mmi_signal_parameter_h parameter = NULL; + mmi_signal_parameter_create(value, "Name", ¶meter); + ... + mmi_signal_parameter_destroy(parameter); + * @endcode + */ +int mmi_signal_parameter_create(mmi_primitive_value_h value, const char *name, mmi_signal_parameter_h *parameter); + +/** + * @brief Retrieves the name of a signal parameter. + * @details This function retrieves the name associated with the given signal parameter. + * @since_tizen 9.0 + * @remarks The @a name should be released using free(). + * + * @param[in] parameter The signal parameter handle. + * @param[out] name A pointer to store the name of the parameter. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_signal_parameter_h parameter; // Indicates the handle of the signal parameter + char *name = NULL; + mmi_signal_parameter_get_name(parameter, &name): + ... + free(name); + * @endcode + */ +int mmi_signal_parameter_get_name(mmi_signal_parameter_h parameter, char **name); + +/** + * @brief Retrieves the primitive value of a signal parameter. + * @details This function retrieves the primitive value associated with the given signal parameter. + * @since_tizen 9.0 + * @remarks The @a value should be released using mmi_primitive_value_destroy(). + * + * @param[in] parameter The signal parameter handle. + * @param[out] value A pointer to store the primitive value of the parameter. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_signal_parameter_h parameter; // Indicates the handle of the signal parameter + mmi_primitive_value_h value = NULL; + mmi_signal_parameter_get_value(parameter, &value); + ... + mmi_primitive_value_destroy(value); + * @endcode + */ +int mmi_signal_parameter_get_value(mmi_signal_parameter_h parameter, mmi_primitive_value_h *value); + +/** + * @brief Clones a signal parameter. + * @details This function creates a deep copy of the given signal parameter. + * @since_tizen 9.0 + * @remarks The @a cloned should be released using mmi_signal_parameter_destroy(). + * + * @param[in] parameter The signal parameter handle to clone. + * @param[out] cloned A pointer to store the cloned parameter handle. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_signal_parameter_h parameter; // Indicates the handle of the signal parameter + mmi_signal_parameter_h cloned = NULL; + mmi_signal_parameter_clone(parameter, &cloned); + ... + mmi_signal_parameter_destroy(cloned); + * @endcode + */ +int mmi_signal_parameter_clone(mmi_signal_parameter_h parameter, mmi_signal_parameter_h *cloned); + +/** + * @brief Destroys a signal parameter. + * @details This function destroys the given signal parameter and releases its resources. + * @since_tizen 9.0 + * + * @param[in] parameter The signal parameter handle to destroy. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + */ +int mmi_signal_parameter_destroy(mmi_signal_parameter_h parameter); + +/** + * @brief Creates a new signal. + * @details This function creates a new signal with the given name. + * @since_tizen 9.0 + * @remarks The @a handle should be released using mmi_signal_destroy(). + * + * @param[in] name The name of the signal. + * @param[out] handle A pointer to store the newly created signal handle. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_signal_h handle = NULL; + mmi_signal_create("Name", &handle); + ... + mmi_signal_destroy(handle); + * @endcode + */ +int mmi_signal_create(const char *name, mmi_signal_h *handle); + +/** + * @brief Adds a parameter to a signal. + * @details This function adds the given parameter to the specified signal. + * @since_tizen 9.0 + * + * @param[in] handle The signal handle to which the parameter will be added. + * @param[in] parameter The parameter handle to add to the signal. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + */ +int mmi_signal_add_parameter(mmi_signal_h handle, mmi_signal_parameter_h parameter); + +/** + * @brief Retrieves the name of a signal. + * @details This function retrieves the name associated with the given signal. + * @since_tizen 9.0 + * @remarks The @a name should be released using free(). + * + * @param[in] handle The signal handle. + * @param[out] name A pointer to store the name of the signal. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_signal_h handle; // Indicates the handle of the signal + char *name = NULL; + mmi_signal_get_name(handle, &name): + ... + free(name); + * @endcode + */ +int mmi_signal_get_name(mmi_signal_h handle, char **name); + +/** + * @brief Retrieves the number of parameters in a signal. + * @details This function retrieves the count of parameters currently associated with the given signal. + * @since_tizen 9.0 + * + * @param[in] handle The signal handle. + * @param[out] count A pointer to store the number of parameters. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + */ +int mmi_signal_get_parameter_count(mmi_signal_h handle, int *count); + +/** + * @brief Retrieves a parameter from a signal by index. + * @details This function retrieves the parameter at the specified index from the given signal. + * @since_tizen 9.0 + * @remarks The @a parameter should be released using mmi_signal_parameter_destroy(). + * + * @param[in] handle The signal handle. + * @param[in] index The index of the parameter to retrieve. + * @param[out] parameter A pointer to store the retrieved parameter handle. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @par Example + * @code + #include + ... + mmi_signal_h handle; // Indicates the handle of the signal + mmi_signal_parameter_h parameter = NULL; + mmi_signal_get_parameter(handle, 1, ¶meter); + ... + mmi_signal_parameter_destroy(parameter); + * @endcode + */ +int mmi_signal_get_parameter(mmi_signal_h handle, int index, mmi_signal_parameter_h *parameter); + +/** + * @brief Destroys a signal. + * @details This function destroys the given signal and releases its resources. + * @since_tizen 9.0 + * + * @param[in] handle The signal handle to destroy. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + */ +int mmi_signal_destroy(mmi_signal_h handle); + +#ifdef __cplusplus +} +#endif + + +/** + * @} + */ + + +#endif /* __TIZEN_UIX_MMI_SIGNAL_H__ */ diff --git a/capi/meson.build b/capi/meson.build new file mode 100644 index 0000000..0035d85 --- /dev/null +++ b/capi/meson.build @@ -0,0 +1,13 @@ +install_headers( + 'common/mmi-primitive-value.h', + 'common/mmi-data.h', + 'common/mmi-attribute.h', + 'common/mmi-error.h', + 'common/mmi-signal.h', + 'workflow/mmi-workflow.h', + 'node/mmi-node.h', + 'node/mmi-node-types.h', + 'node/mmi-port.h', + 'mmi.h', + subdir : 'mmi' + ) diff --git a/capi/mmi.h b/capi/mmi.h new file mode 100644 index 0000000..01d7240 --- /dev/null +++ b/capi/mmi.h @@ -0,0 +1,374 @@ +/* + * 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_UIX_MMI_H__ +#define __TIZEN_UIX_MMI_H__ + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/** +* @file mmi.h +* @brief This file contains the MMI API. +*/ + +/** +* @addtogroup CAPI_UIX_MMI_MODULE +* @{ +*/ + +/** + * @brief Enumeration for MMI state. + * @details This enumeration defines the different states of the MMI client. + * @since_tizen 9.0 +*/ +typedef enum { + MMI_STATE_NONE = 0, /**< Indicates that there is no active state. */ + MMI_STATE_READY, /**< Indicates that the MMI client is ready to use. */ +} mmi_state_e; + + +/** + * @brief Callback function type for MMI state change notifications. + * @details This callback function is called whenever the state of the MMI client changes. + * @since_tizen 9.0 + * + * @param[in] state The new state of the MMI client. + * @param[in] user_data User-provided data passed to the callback function. + * + * @return An integer value indicating the result of the callback execution. + * @retval 0 on success, otherwise a negative error value. + * + * @see mmi_state_e +*/ +typedef int (*mmi_state_changed_cb)(mmi_state_e state, void *user_data); + + +/** + * @brief Handle for MMI workflow instance. + * @details This handle represents a workflow instance created within the MMI framework. + * @since_tizen 9.0 +*/ +typedef void* mmi_workflow_instance_h; + + +/** + * @brief Callback function type for handling workflow output. + * @details This callback function is called when the MMI framework generates output for a workflow instance. + * @since_tizen 9.0 + * @remarks The @a instance should not be released. + * The @a data should not be released. + * The @a data can be used only in the callback. To use outside, make a copy. + * + * @param[in] instance The workflow instance handle for which the output is generated. + * The @a instance is the same object for which the callback was set/added. + * The @a instance is available until the workflow instance is released. + * @param[in] name The name associated with the workflow output. + * The @a name can be used only in the callback. To use outside, make a copy. + * @param[in] data The output data generated by the workflow. + * @param[in] user_data User-provided data passed to the callback function. + * + * @see mmi_workflow_instance_set_output_cb() + * @see mmi_workflow_instance_unset_output_cb() +*/ +typedef void (*mmi_workflow_output_cb)(mmi_workflow_instance_h instance, const char *name, mmi_data_h data, void *user_data); + +/** + * @brief Initializes the MMI framework. + * @details This function initializes the MMI (Multimodal Interaction) framework. It must be called before any other MMI functions. + * @since_tizen 9.0 + * + * @return 0 on success, otherwise a negative error value + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_NOT_SUPPORTED Not supported + * @retval #MMI_ERROR_OPERATION_FAILED Operation failed + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @see mmi_deinitialize(void) + */ +int mmi_initialize(void); + +/** + * @brief Deinitializes the MMI framework. + * @details This function deinitializes the MMI (Multimodal Interaction) framework. It must be called after all MMI operations are completed. + * @since_tizen 9.0 + * + * @return 0 on success, otherwise a negative error value + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_OPERATION_FAILED Operation failed + * + * @see mmi_initialize(void) + */ +int mmi_deinitialize(void); + +/** + * @brief Sets a callback function to be invoked when the MMI state changes. + * @details This function sets a callback function that will be called whenever the state of the MMI framework changes. + * @since_tizen 9.0 + * + * @param[in] callback The callback function to be called when state is changed + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see mmi_state_changed_cb() + * @see mmi_unset_state_changed_cb() + */ +int mmi_set_state_changed_cb(mmi_state_changed_cb callback, void *user_data); + +/** + * @brief Unsets the previously set callback function for MMI state changes. + * @details This function removes the previously set callback function that was called whenever the state of the MMI framework changes. + * @since_tizen 9.0 + * + * @param[in] callback The callback function to be unset + * + * @return 0 on success, otherwise a negative error value + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre A callback function must have been set using mmi_set_state_changed_cb() before calling this function. + * @post The callback function will no longer be called when the MMI state changes. + * + * @see mmi_state_changed_cb() + * @see mmi_set_state_changed_cb() + */ +int mmi_unset_state_changed_cb(mmi_state_changed_cb callback); + +/** + * @brief Creates a new workflow instance from a standard workflow prototype. + * @details This function creates a new workflow instance from a predefined standard workflow prototype. + * @since_tizen 9.0 + * @remarks The @a instance should be released using mmi_workflow_instance_destroy(). + * + * @param[in] type The type of the standard workflow prototype + * @param[out] instance A pointer to the created workflow instance handle + * + * @return 0 on success, otherwise a negative error value + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_workflow_instance_h instance; + mmi_standard_workflow_instance_create(MMI_STANDARD_WORKFLOW_VOICE_TOUCH, &instance); + ... + mmi_workflow_instance_destroy(instance); + * @endcode + * + * @see mmi_standard_workflow_type_e + * @see mmi_workflow_instance_destroy() + */ +int mmi_standard_workflow_instance_create(mmi_standard_workflow_type_e type, mmi_workflow_instance_h *instance); + +/** + * @brief Instantiates a workflow from a custom workflow prototype. + * @details This function creates an instance of a workflow based on a custom workflow prototype. + * @since_tizen 9.0 + * @remarks The @a instance should be released using mmi_workflow_instance_destroy(). + * + * @param[in] workflow The handle to the custom workflow prototype. + * @param[out] instance The handle to the newly created workflow instance. + * + * @return 0 on success, otherwise a negative error value + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @pre The custom workflow prototype must be valid and properly configured. + * @post A new workflow instance will be created and assigned to the provided instance handle. + * + * @par Example + * @code + #include + ... + const char *workflow_script = "@workflow\n..."; + mmi_workflow_h workflow; + mmi_workflow_create_from_script(workflow_script, &workflow); + ... + mmi_workflow_instance_h instance; + mmi_custom_workflow_instance_create(workflow, &instance); + ... + mmi_workflow_instance_destroy(instance); + * @endcode + * + * @see mmi_workflow_h + * @see mmi_workflow_instance_h + */ +int mmi_custom_workflow_instance_create(mmi_workflow_h workflow, mmi_workflow_instance_h *instance); + +/** + * @brief Destroys a workflow instance. + * @details This function destroys a workflow instance and releases all associated resources. + * @since_tizen 9.0 + * + * @param[in] instance The handle to the workflow instance to be destroyed. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful. + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter. + * + * @pre The workflow instance must have been created and activated before calling this function. + * @post The workflow instance is destroyed and its handle becomes invalid. + * + * @see mmi_workflow_instance_create() + * @see mmi_workflow_instance_activate() +*/ +int mmi_workflow_instance_destroy(mmi_workflow_instance_h instance); + +/** + * @brief Activates a workflow instance. + * @details This function starts the execution of a workflow instance. + * @since_tizen 9.0 + * + * @param[in] instance The handle to the workflow instance to be activated. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful. + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter. + * + * @pre The workflow instance must have been created before calling this function. + * @post The workflow instance is ready to process inputs and emit outputs. + * + * @see mmi_workflow_instance_create() + * @see mmi_workflow_instance_deactivate() +*/ +int mmi_workflow_instance_activate(mmi_workflow_instance_h instance); + +/** + * @brief Deactivates a workflow instance. + * @details This function stops the execution of a workflow instance. + * @since_tizen 9.0 + * + * @param[in] instance The handle to the workflow instance to be deactivated. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful. + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter. + * + * @pre The workflow instance must have been created and activated before calling this function. + * @post The workflow instance is stopped and cannot process inputs or emit outputs. + * + * @see mmi_workflow_instance_activate() + * */ +int mmi_workflow_instance_deactivate(mmi_workflow_instance_h instance); + +/** + * @brief Sets an attribute of a workflow instance. + * @details This function sets an attribute to the workflow instance. + * @since_tizen 9.0 + * + * @param[in] instance The handle to the workflow instance. + * @param[in] attribute The handle to the attribute to be set. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful. + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter. + * + * @pre The workflow instance must have been created before calling this function. + * @post The attribute is set to the workflow instance. + * + * @see mmi_attribute_create() +*/ +int mmi_workflow_instance_set_attribute(mmi_workflow_instance_h instance, mmi_attribute_h attribute); + +/** + * @brief Emits a signal to a workflow instance. + * @details This function sends a signal to the workflow instance. + * @since_tizen 9.0 + * + * @param[in] instance The handle to the workflow instance. + * @param[in] signal The handle to the signal to be emitted. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful. + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter. + * + * @pre The workflow instance must have been created and activated before calling this function. + * @post The signal is processed by the workflow instance. + * + * @see mmi_signal_create() +*/ +int mmi_workflow_instance_emit_signal(mmi_workflow_instance_h instance, mmi_signal_h signal); + +/** + * @brief Sets a callback function to receive workflow output. + * @details This function sets a callback function that will be called when the workflow instance emits output. + * @since_tizen 9.0 + * + * @param[in] instance The handle to the workflow instance. + * @param[in] name The name associated with the callback. + * @param[in] callback The callback function to be set. + * @param[in] user_data The user data to be passed to the callback function. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful. + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter. + * + * @pre The workflow instance must have been created before calling this function. + * @post The callback function will be called when the workflow instance emits output. + * + * @see mmi_workflow_output_cb() + * @see mmi_workflow_instance_unset_output_cb() +*/ +int mmi_workflow_instance_set_output_cb(mmi_workflow_instance_h instance, const char *name, mmi_workflow_output_cb callback, void *user_data); + +/** + * @brief Unsets a callback function for an output of a workflow instance. + * @details This function unsets a callback function that was set by mmi_workflow_instance_set_output_cb(). + * After this function is called, the callback function will not be called when the workflow instance emits output. + * @since_tizen 9.0 + * + * @param[in] instance The handle to the workflow instance + * @param[in] callback The callback function pointer to unset + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MMI_ERROR_NONE Successful. + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter. + * + * @pre The workflow instance must have been created before calling this function. + * @post The callback function will not be called when the workflow instance emits output. + * + * @see mmi_workflow_output_cb() + * @see mmi_workflow_instance_set_output_cb() +*/ +int mmi_workflow_instance_unset_output_cb(mmi_workflow_instance_h instance, mmi_workflow_output_cb callback); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + + + +#endif /* __TIZEN_UIX_MMI_H__ */ diff --git a/capi/node/mmi-node-types.h b/capi/node/mmi-node-types.h new file mode 100644 index 0000000..1e0ca41 --- /dev/null +++ b/capi/node/mmi-node-types.h @@ -0,0 +1,377 @@ +/* + * 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_UIX_MMI_NODE_TYPES_H__ +#define __TIZEN_UIX_MMI_NODE_TYPES_H__ + + + +#include + +/** +* @file mmi-node-types.h +*/ + + +/** +* @addtogroup CAPI_UIX_MMI_NODE_MODULE +* @{ +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * @brief Enumeration for MMI source node type. + * @details This enumeration defines the different source node types supported by the MMI framework. + * @since_tizen 9.0 + */ +enum mmi_node_source_type_e { + MMI_NODE_SOURCE_TYPE_NONE, /**< Indicates that there is no source node type. */ + MMI_NODE_SOURCE_TYPE_SCREEN_ANALYZER, /**< Represents a screen analyzer node type. */ +}; + +/** + * @brief Enumeration for MMI processor node type. + * @details This enumeration defines the different processor node types supported by the MMI framework. + * @since_tizen 9.0 + */ +enum mmi_node_processor_type_e { + MMI_NODE_PROCESSOR_TYPE_NONE /**< Indicates that there is no processor node type. */ +}; + +/** + * @brief Enumeration for MMI logic node type. + * @details This enumeration defines the different logic node types supported by the MMI framework. + * @since_tizen 9.0 + */ +enum mmi_node_logic_type_e { + MMI_NODE_LOGIC_TYPE_NONE, /**< Indicates that there is no logic node type. */ + MMI_NODE_LOGIC_TYPE_FIXED_STRING_MATCH, /**< Represents a fixed string match logic node type. */ +}; + +/** + * @brief Enumeration for MMI controller node type. + * @details This enumeration defines the different controller node types supported by the MMI framework. + * @since_tizen 9.0 + */ +enum mmi_node_controller_type_e { + MMI_NODE_CONTROLLER_TYPE_NONE, /**< Indicates that there is no controller node type. */ +}; + +/** + * @brief Enumeration for MMI action node type. + * @details This enumeration defines the different action node types supported by the MMI framework. + * @since_tizen 9.0 + */ +enum mmi_node_action_type_e { + MMI_NODE_ACTION_TYPE_NONE, /**< Indicates that there is no action node type. */ + MMI_NODE_ACTION_TYPE_MOUSE_EVENT, /**< Represents a mouse event action node type. */ + MMI_NODE_ACTION_TYPE_KEY_EVENT, /**< Represents a key event action node type. */ +}; + +/** + * @brief Creates a new source node. + * @details This function creates a new source node of the specified type and returns a handle to it. + * @since_tizen 9.0 + * @remarks The @a node should be released using mmi_node_destroy(). + * + * @param[in] type The type of the source node to be created. + * @param[out] node A pointer to store the handle of the newly created source node. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_node_h node = NULL; + mmi_node_create_source(MMI_NODE_SOURCE_TYPE_NONE, &node); + ... + mmi_node_destroy(node); + * @endcode + * + * @see mmi_node_source_type_e + * @see mmi_node_destroy() + */ +int mmi_node_create_source(mmi_node_source_type_e type, mmi_node_h *node); + +/** + * @brief Gets the type of the source node. + * @details This function retrieves the type of the specified source node. + * @since_tizen 9.0 + * + * @param[in] node The handle of the source node. + * @param[out] type A pointer to store the type of the source node. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre The source node must be created using mmi_node_create_source(). + * + * @see mmi_node_source_type_e + * @see mmi_node_create_source() + */ +int mmi_node_get_source_type(mmi_node_h node, mmi_node_source_type_e *type); + +/** + * @brief Creates a new processor node. + * @details This function creates a new processor node of the specified type and returns a handle to it. + * @since_tizen 9.0 + * @remarks The @a node should be released using mmi_node_destroy(). + * + * @param[in] type The type of the processor node to be created. + * @param[out] node A pointer to store the handle of the newly created processor node. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_node_h node = NULL; + mmi_node_create_processor(MMI_NODE_PROCESSOR_TYPE_NONE, &node); + ... + mmi_node_destroy(node); + * @endcode + + * @see mmi_node_processor_type_e + * @see mmi_node_destroy() + */ +int mmi_node_create_processor(mmi_node_processor_type_e type, mmi_node_h *node); + +/** + * @brief Gets the type of the processor node. + * @details This function retrieves the type of the specified processor node. + * @since_tizen 9.0 + * + * @param[in] node The handle of the processor node. + * @param[out] type A pointer to store the type of the processor node. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre The processor node must be created using mmi_node_create_processor(). + * + * @see mmi_node_processor_type_e + * @see mmi_node_create_processor() + */ +int mmi_node_get_processor_type(mmi_node_h node, mmi_node_processor_type_e *type); + +/** + * @brief Creates a new logic node. + * @details This function creates a new logic node of the specified type and returns a handle to it. + * @since_tizen 9.0 + * @remarks The @a node should be released using mmi_node_destroy(). + * + * @param[in] type The type of the logic node to be created. + * @param[out] node A pointer to store the handle of the newly created logic node. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_node_h node = NULL; + mmi_node_create_logic(MMI_NODE_LOGIC_TYPE_NONE, &node); + ... + mmi_node_destroy(node); + * @endcode + + * @see mmi_node_logic_type_e + * @see mmi_node_destroy() + * + */ +int mmi_node_create_logic(mmi_node_logic_type_e type, mmi_node_h *node); + +/** + * @brief Gets the type of the logic node. + * @details This function retrieves the type of the specified logic node. + * @since_tizen 9.0 + * + * @param[in] node The handle of the logic node. + * @param[out] type A pointer to store the type of the logic node. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre The logic node must be created using mmi_node_create_logic(). + * + * @see mmi_node_logic_type_e + * @see mmi_node_create_logic() + */ +int mmi_node_get_logic_type(mmi_node_h node, mmi_node_logic_type_e *type); + +/** + * @brief Creates a new MMI controller node. + * @details This function creates a new MMI controller node of the specified type. + * @since_tizen 9.0 + * @remarks The @a node should be released using mmi_node_destroy(). + * + * @param[in] type The type of the controller to be created. + * @param[out] node A pointer to the newly created node handle. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_node_h node = NULL; + mmi_node_create_controller(MMI_NODE_CONTROLLER_TYPE_NONE, &node); + ... + mmi_node_destroy(node); + * @endcode + */ +int mmi_node_create_controller(mmi_node_controller_type_e type, mmi_node_h *node); + +/** + * @brief Gets the type of the MMI controller node. + * @details This function retrieves the type of the specified MMI controller node. + * @since_tizen 9.0 + * + * @param[in] node The handle of the node controller. + * @param[out] type A pointer to store the type of the node controller. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + */ +int mmi_node_get_controller_type(mmi_node_h node, mmi_node_controller_type_e *type); + +/** + * @brief Creates a new MMI action node. + * @details This function creates a new MMI action node of the specified type. + * @since_tizen 9.0 + * @remarks The @a node should be released using mmi_node_destroy(). + * + * @param[in] type The type of the action to be created. + * @param[out] node A pointer to the newly created node handle. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_node_h node = NULL; + mmi_node_create_action(MMI_NODE_ACTION_TYPE_NONE, &node); + ... + mmi_node_destroy(node); + * @endcode + */ +int mmi_node_create_action(mmi_node_action_type_e type, mmi_node_h *node); + +/** + * @brief Gets the type of the MMI action node. + * @details This function retrieves the type of the specified MMI action node. + * @since_tizen 9.0 + * + * @param[in] node The handle of the node action. + * @param[out] type A pointer to store the type of the node action. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + */ +int mmi_node_get_action_type(mmi_node_h node, mmi_node_action_type_e *type); + +/** + * @brief Creates a new MMI node with a custom type. + * @details This function creates a new MMI node with a custom type identifier. + * @since_tizen 9.0 + * @remarks The @a node should be released using mmi_node_destroy(). + * + * @param[in] custom_type_id The custom type identifier for the node. + * @param[out] node A pointer to the newly created node handle. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_node_h node = NULL; + mmi_node_create_custom("Test", &node); + ... + mmi_node_destroy(node); + * @endcode + */ +int mmi_node_create_custom(const char *custom_type_id, mmi_node_h *node); + +/** + * @brief Gets the custom type identifier of the MMI node. + * @details This function retrieves the custom type identifier of the specified MMI node. + * @since_tizen 9.0 + * @remarks The @a custom_type_id should not be released. + * @remarks The @a custom_type_id is available until node is released. + * + * @param[in] node The handle of the node. + * @param[out] custom_type_id A pointer to store the custom type identifier of the node. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @par Example + * @code + #include + ... + mmi_node_h node; // Indicates the handle of the node + const char *custom_type_id = NULL; + mmi_node_get_custom_type(node, &custom_type_id); + * @endcode + */ +int mmi_node_get_custom_type(mmi_node_h node, const char **custom_type_id); + +#ifdef __cplusplus +} +#endif + + +/** + * @} + */ + + +#endif /* __TIZEN_UIX_MMI_NODE_TYPES_H__ */ diff --git a/capi/node/mmi-node.h b/capi/node/mmi-node.h new file mode 100644 index 0000000..b46e83b --- /dev/null +++ b/capi/node/mmi-node.h @@ -0,0 +1,575 @@ +/* + * 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_UIX_MMI_NODE_H__ +#define __TIZEN_UIX_MMI_NODE_H__ + + +#include +#include +#include +#include +#include + +/** +* @file mmi-node.h +*/ + + +/** +* @addtogroup CAPI_UIX_MMI_NODE_MODULE +* @ingroup CAPI_UIX_MMI_MODULE +* @{ +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumeration for MMI node types. + * @details This enumeration defines the different types of nodes in the MMI framework. + * @since_tizen 9.0 +*/ +typedef enum { + MMI_NODE_TYPE_NONE, /**< Indicates no specific node type. */ + MMI_NODE_TYPE_SOURCE, /**< Represents a source node. */ + MMI_NODE_TYPE_PROCESSOR, /**< Represents a processor node. */ + MMI_NODE_TYPE_LOGIC, /**< Represents a logic node. */ + MMI_NODE_TYPE_CONTROLLER, /**< Represents a controller node. */ + MMI_NODE_TYPE_ACTION, /**< Represents an action node. */ + MMI_NODE_TYPE_CUSTOM, /**< Represents a custom node. */ +} mmi_node_type_e; + +/** + * @brief Handle for MMI node instance. + * @details This handle represents an instance of a node created within the MMI framework. + * @since_tizen 9.0 +*/ +typedef void* mmi_node_instance_h; + +/** + * @brief Callback function type for MMI node initialization. + * @details This callback function is called when a node instance is initialized. + * @since_tizen 9.0 + * @remarks The @a instance should not be released. + * The @a instance is available until the node instance is released. + * + * @param[in] instance The handle of the initialized node instance. + * @param[in] user_data The user data passed from the callback registration function. + * + * @return An integer value indicating the result of the callback execution. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter +*/ +typedef int (*mmi_node_initialized_cb)(mmi_node_instance_h instance, void *user_data); + +/** + * @brief Callback function type for MMI node deinitialization. + * @details This callback function is called when a node instance is deinitialized. + * @since_tizen 9.0 + * @remarks The @a instance should not be released. + * The @a instance is available until the node instance is released. + * + * @param[in] instance The handle of the deinitialized node instance. + * @param[in] user_data The user data passed from the callback registration function. + * + * @return An integer value indicating the result of the callback execution. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter +*/ +typedef int (*mmi_node_deinitialized_cb)(mmi_node_instance_h instance, void *user_data); + +/** + * @brief Callback function type for setting MMI node attributes. + * @details This callback function is called when an attribute is set on a node instance. + * @since_tizen 9.0 + * @remarks The @a instance should not be released. + * The @a instance is available until the node instance is released. + * @remarks The @a attribute should not be released. + * The @a attribute can be used only in the callback. To use outside, make a copy. + * + * @param[in] instance The handle of the node instance. + * @param[in] attribute The handle of the attribute being set. + * @param[in] user_data The user data passed from the callback registration function. + * + * @return An integer value indicating the result of the callback execution. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter +*/ +typedef int (*mmi_node_attribute_set_cb)(mmi_node_instance_h instance, mmi_attribute_h attribute, void *user_data); + +/** + * @brief Callback function type for MMI node activation. + * @details This callback function is called when a node instance is activated. + * @since_tizen 9.0 + * @remarks The @a instance should not be released. + * The @a instance is available until the node instance is released. + * + * @param[in] instance The handle of the activated node instance. + * @param[in] user_data The user data passed from the callback registration function. + * + * @return An integer value indicating the result of the callback execution. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter +*/ +typedef int (*mmi_node_activated_cb)(mmi_node_instance_h instance, void *user_data); + +/** + * @brief Callback function type for MMI node deactivation. + * @details This callback function is called when a node instance is deactivated. + * @since_tizen 9.0 + * @remarks The @a instance should not be released. + * The @a instance is available until the node instance is released. + * + * @param[in] instance The handle of the deactivated node instance. + * @param[in] user_data The user data passed from the callback registration function. + * + * @return An integer value indicating the result of the callback execution. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter +*/ +typedef int (*mmi_node_deactivated_cb)(mmi_node_instance_h instance, void *user_data); + +/** + * @brief Callback function type for receiving MMI signals. + * @details This callback function is called when a signal is received by a node instance. + * @since_tizen 9.0 + * @remarks The @a instance should not be released. + * The @a instance is available until the node instance is released. + * @remarks The @a signal should not be released. + * The @a signal can be used only in the callback. To use outside, make a copy. + * + * @param[in] instance The handle of the node instance receiving the signal. + * @param[in] signal The handle of the received signal. + * @param[in] user_data The user data passed from the callback registration function. + * + * @return An integer value indicating the result of the callback execution. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter +*/ +typedef int (*mmi_node_signal_received_cb)(mmi_node_instance_h instance, mmi_signal_h signal, void *user_data); + +/** + * @brief Handle for MMI node. + * @details This handle represents a node created within the MMI framework. + * @since_tizen 9.0 +*/ +typedef struct mmi_node_s* mmi_node_h; + +/** + * @brief Sets a callback function to be invoked when the node is initialized. + * @details This function sets a callback function that will be called when the node is initialized. + * @since_tizen 9.0 + * + * @param[in] node The handle of the node for which the initialized callback function is to be set. + * @param[in] callback The callback function to be called when the node is initialized. + * @param[in] user_data The user data to be passed to the callback function. + * + * @return 0 on success, otherwise a negative error value + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see mmi_node_initialized_cb() + */ +int mmi_node_set_initialized_cb(mmi_node_h node, mmi_node_initialized_cb callback, void *user_data); + +/** + * @brief Sets a callback function to be invoked when the node is deinitialized. + * @details This function sets a callback function that will be called when the node is deinitialized. + * @since_tizen 9.0 + * + * @param[in] node The handle of the node for which the deinitialized callback function is to be set. + * @param[in] callback The callback function to be called when the node is deinitialized. + * @param[in] user_data The user data to be passed to the callback function. + * + * @return 0 on success, otherwise a negative error value + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see mmi_node_deinitialized_cb() + */ +int mmi_node_set_deinitialized_cb(mmi_node_h node, mmi_node_deinitialized_cb callback, void *user_data); + +/** + * @brief Sets a callback function to be invoked when an attribute is set on the node. + * @details This function sets a callback function that will be called when an attribute is set on the node. + * @since_tizen 9.0 + * + * @param[in] node The handle of the node for which the attribute set callback function is to be set. + * @param[in] callback The callback function to be called when an attribute is set on the node. + * @param[in] user_data The user data to be passed to the callback function. + * + * @return 0 on success, otherwise a negative error value + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see mmi_node_attribute_set_cb() + */ +int mmi_node_set_attribute_set_cb(mmi_node_h node, mmi_node_attribute_set_cb callback, void *user_data); + +/** + * @brief Sets a callback function to be invoked when the node is activated. + * @details This function sets a callback function that will be called when the node is activated. + * @since_tizen 9.0 + * + * @param[in] node The handle of the node for which the activated callback function is to be set. + * @param[in] callback The callback function to be called when the node is activated. + * @param[in] user_data The user data to be passed to the callback function. + * + * @return 0 on success, otherwise a negative error value + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see mmi_node_activated_cb() + */ +int mmi_node_set_activated_cb(mmi_node_h node, mmi_node_activated_cb callback, void *user_data); + +/** + * @brief Sets a callback function to be invoked when the specified MMI node is deactivated. + * @details This function sets a callback function that will be called whenever the specified node is deactivated. + * @since_tizen 9.0 + * + * @param[in] node The handle of the MMI node. + * @param[in] callback The callback function to be called when the node is deactivated. + * @param[in] user_data The user data to be passed to the callback function. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see mmi_node_deactivated_cb() + * @see mmi_node_unset_deactivated_cb() + */ +int mmi_node_set_deactivated_cb(mmi_node_h node, mmi_node_deactivated_cb callback, void *user_data); + +/** + * @brief Sets a callback function to be invoked when a signal is received by the specified MMI node. + * @details This function sets a callback function that will be called whenever a signal is received by the specified node. + * @since_tizen 9.0 + * + * @param[in] node The handle of the MMI node. + * @param[in] callback The callback function to be called when a signal is received. + * @param[in] user_data The user data to be passed to the callback function. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see mmi_node_signal_received_cb() + * @see mmi_node_unset_signal_received_cb() + */ +int mmi_node_set_signal_received_cb(mmi_node_h node, mmi_node_signal_received_cb callback, void *user_data); + +/** + * @brief Adds a static port to a static node. + * @details This function adds an already created port to a node. The port must be created before calling this function. + * @since_tizen 9.0 + * + * @param[in] node The handle to the node where the port will be added. + * @param[in] port The handle to the port that will be added to the node. + * + * @return An integer value indicating the result of the operation. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre The port must be created before adding it to the node. + * @post The port is added to the node. + */ +int mmi_node_add_port(mmi_node_h node, mmi_port_h port); + +/** + * @brief Finds a port in a node matching the given name and type. + * @details This function searches for a port in a node that matches the specified name and type. + * @since_tizen 9.0 + * @remarks The @a port should not be released. + * The @a port is available until node is released. + * + * @param[in] node The handle to the node where the search will be performed. + * @param[in] port_type The type of the port to be found. + * @param[in] port_name The name of the port to be found. + * @param[out] port A pointer to store the handle of the found port. + * + * @return An integer value indicating the result of the operation. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre The node must exist and contain ports. + * @post If the port is found, its handle is stored in the provided pointer. + * + * @par Example + * @code + #include + ... + mmi_node_h node; // Indicates the data handle + mmi_port_h port = NULL; + mmi_node_find_port(node, MMI_PORT_TYPE_OUT, "OUTPUT", &port); + * @endcode + */ +int mmi_node_find_port(mmi_node_h node, mmi_port_type_e port_type, const char *port_name, mmi_port_h *port); + +/** + * @brief Retrieves the type of a node. + * @details This function retrieves the type of the node represented by the given handle. + * @since_tizen 9.0 + * + * @param[in] node The handle to the node whose type will be retrieved. + * @param[out] type A pointer to store the type of the node. + * + * @return An integer value indicating the result of the operation. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre The node must exist. + * @post The type of the node is stored in the provided pointer. + */ +int mmi_node_get_type(mmi_node_h node, mmi_node_type_e *type); + +/** + * @brief Retrieves the number of ports in a node. + * @details This function retrieves the total number of ports present in the node. + * @since_tizen 9.0 + * + * @param[in] node The handle the node whose port count will be retrieved. + * @param[out] port_count A pointer to store the number of ports in the node. + * + * @return An integer value indicating the result of the operation. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre The node must exist. + * @post The number of ports in the node is stored in the provided pointer. + */ +int mmi_node_get_port_count(mmi_node_h node, size_t *port_count); + +/** + * @brief Retrieves the port at the given index. + * @details This function retrieves the port at the specified index in the node. + * @since_tizen 9.0 + * @remarks The @a port should not be released. + * The @a port is available until node is released. + * + * @param[in] node The handle to the node from which the port will be retrieved. + * @param[in] index The index of the port to be retrieved. + * @param[out] port A pointer to store the handle of the retrieved port. + * + * @return An integer value indicating the result of the operation. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre The node must exist and contain ports. + * @post The handle of the port at the specified index is stored in the provided pointer. + * + * @par Example + * @code + #include + ... + mmi_node_h node; // Indicates the data handle + mmi_port_h port = NULL; + mmi_node_get_port(node, 0, &port); + * @endcode + */ +int mmi_node_get_port(mmi_node_h node, size_t index, mmi_port_h *port); + +/** + * @brief Registers a node. + * @details This function registers the node within the MMI framework. + * @since_tizen 9.0 + * + * @param[in] node The handle to the node to be registered. + * + * @return An integer value indicating the result of the operation. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre The node must exist and be properly initialized. + * @post The node is registered within the MMI framework. + */ +int mmi_node_register(mmi_node_h node); + +/** + * @brief Clones a node. + * @details This function creates a copy of the node and returns a handle to the cloned node. + * @since_tizen 9.0 + * @remarks The @a cloned should be released using mmi_attribute_destroy(). + * + * @param[in] node The handle to the node to be cloned. + * @param[out] cloned A pointer to store the handle of the cloned node. + * + * @return An integer value indicating the result of the operation. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre The node must exist. + * @post A clone of the node is created and its handle is stored in the provided pointer. + * + * @par Example + * @code + #include + ... + mmi_node_h node; // Indicates the handle of the node + mmi_node_h cloned = NULL; + mmi_node_clone(node, &cloned); + ... + mmi_node_destroy(cloned); + * @endcode + */ +int mmi_node_clone(mmi_node_h node, mmi_node_h *cloned); + +/** + * @brief Destroys a node. + * @details This function destroys the node and releases all associated resources. + * @since_tizen 9.0 + * + * @param[in] node The handle to the node to be destroyed. + * + * @return An integer value indicating the result of the operation. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre The node must exist. + * @post The node is destroyed and all associated resources are released. + */ +int mmi_node_destroy(mmi_node_h node); + +/** + * @brief Provides an attribute to a node instance. + * @details This function sets an attribute to a specified node instance. + * @since_tizen 9.0 + * + * @param[in] instance The handle to the node instance. + * @param[in] attribute The handle to the attribute to be set. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + */ +int mmi_node_instance_set_attribute(mmi_node_instance_h instance, mmi_attribute_h attribute); + +/** + * @brief Retrieves a port instance of a node instance. + * @details This function finds and retrieves a port instance of a specified node instance based on its type and name. + * @since_tizen 9.0 + * @remarks The @a port_instance should not be released. + * @remarks The @a port_instance is available until node_instance is released. + * + * @param[in] node_instance The handle to the node instance. + * @param[in] port_type The type of the port (input or output). + * @param[in] port_name The name of the port. + * @param[out] port_instance The handle to the retrieved port instance. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @par Example + * @code + mmi_node_instance_h node; // Indicates the node instance handle. + mmi_port_instance_h port = NULL; + mmi_node_instance_find_port_instance(node, MMI_PORT_TYPE_OUT, "OUTPUT", &port); + * @endcode + */ +int mmi_node_instance_find_port_instance(mmi_node_instance_h node_instance, mmi_port_type_e port_type, const char *port_name, mmi_port_instance_h *port_instance); + +/** + * @brief Finds a node instance that has the given port instance. + * @details This function finds and retrieves the node instance that contains the specified port instance. + * @since_tizen 9.0 + * @remarks The @a node_instance should not be released. + * @remarks The @a node_instance is available until port_instance is released. + * + * @param[in] port_instance The handle to the port instance. + * @param[out] node_instance The handle to the retrieved node instance. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @par Example + * @code + mmi_port_instance_h port; // Indicates the port instance of the node. + mmi_node_instance_h node = NULL; + mmi_node_instance_find_by_port_instance(port, &node); + * @endcode + */ +int mmi_node_instance_find_by_port_instance(mmi_port_instance_h port_instance, mmi_node_instance_h *node_instance); + +/** + * @brief Retrieves a sibling port instance of a port instance in a node. + * @details This function finds and retrieves a sibling port instance of a specified port instance in a node, matching the given name. + * @since_tizen 9.0 + * @remarks The @a sibling should not be released. + * @remarks The @a sibling is available until node is released. + * + * @param[in] instance The handle to the port instance. + * @param[in] sibling_name The name of the sibling port. + * @param[out] sibling The handle to the retrieved sibling port instance. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @par Example + * @code + mmi_port_instance_h port; // Indicates the port instance of the node. + mmi_port_instance_h sibling = NULL; + mmi_node_instance_find_sibling_port_instance(port, "PORT_2", &sibling); + * @endcode + */ +int mmi_node_instance_find_sibling_port_instance(mmi_port_instance_h instance, const char *sibling_name, mmi_port_instance_h *sibling); + +/** + * @brief Emits a signal from a node instance. + * @details This function emits a signal from a specified node instance. + * @since_tizen 9.0 + * + * @param[in] instance The handle to the node instance. + * @param[in] signal The handle to the signal to be emitted. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + */ +int mmi_node_instance_emit_signal(mmi_node_instance_h instance, mmi_signal_h signal); + +/** + * @brief Updates the pending activation result of a node instance. + * @details This function updates the result of the last activation callback call for a specified node instance. + * @since_tizen 9.0 + * + * @param[in] result The result to be updated. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + */ +int mmi_node_instance_update_pending_activation_result(mmi_error_e result); + +#ifdef __cplusplus +} +#endif + + +/** + * @} + */ + + +#endif /* __TIZEN_UIX_MMI_NODE_H__ */ diff --git a/capi/node/mmi-port.h b/capi/node/mmi-port.h new file mode 100644 index 0000000..c1391e1 --- /dev/null +++ b/capi/node/mmi-port.h @@ -0,0 +1,324 @@ +/* + * 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_UIX_MMI_PORT_H__ +#define __TIZEN_UIX_MMI_PORT_H__ + + +#include +#include + +/** +* @file mmi-port.h +*/ + + +/** +* @addtogroup CAPI_UIX_MMI_NODE_MODULE +* @{ +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumeration for port types. + * @details This enumeration defines the different types of ports available in the MMI framework. + * @since_tizen 9.0 +*/ +typedef enum { + MMI_PORT_TYPE_IN, /**< Indicates an input port. */ + MMI_PORT_TYPE_OUT, /**< Indicates an output port. */ +} mmi_port_type_e; + +/** + * @brief Handle for MMI port instance. + * @details This handle represents a port instance created within the MMI framework. + * @since_tizen 9.0 +*/ +typedef void* mmi_port_instance_h; + +/** + * @brief Callback function type for input data reception. + * @details This callback function is called whenever input data is received for a port instance. + * @since_tizen 9.0 + * @remarks The @a instance should not be released. + * The @a instance is available until the port instance is released. + * @remarks The @a data should not be released. + * The @a data can be used only in the callback. To use outside, make a copy. + * + * @param[in] instance The port instance handle. + * @param[in] data The received input data. + * @param[in] user_data The user data passed from the registration function. + * + * @return An integer value indicating the result of the callback execution. + * @retval 0 on success, otherwise a negative error value. +*/ +typedef int (*mmi_port_input_data_received_cb)(mmi_port_instance_h instance, mmi_data_h data, void *user_data); + +/** + * @brief Handle for MMI port. + * @details This handle represents a port created within the MMI framework. + * @since_tizen 9.0 +*/ +typedef struct mmi_port_s* mmi_port_h; + +/** + * @brief Creates a new port. + * @details This function creates a new port and initializes its resources. + * @since_tizen 9.0 + * @remarks The @a port should be released using mmi_port_destroy(). + * + * @param[out] port A pointer to the newly created port handle. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_port_h port = NULL; + mmi_port_create(&port); + ... + mmi_port_destroy(port); + * @endcode + * + * @see mmi_port_destroy() + */ +int mmi_port_create(mmi_port_h *port); + +/** + * @brief Gets the name of a port. + * @details This function retrieves the name associated with the specified port. + * @since_tizen 9.0 + * @remarks The @a name should be released using free(). + * + * @param[in] port The port handle. + * @param[out] name A pointer to the buffer where the name will be stored. + * @param[out] length A pointer to the variable that will receive the length of the name. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre The port handle must be valid and initialized. + * @post The caller is responsible for freeing the allocated memory for the name. + * + * @par Example + * @code + #include + ... + mmi_port_h port; // Indicates the handle of the port + char *name = NULL; + size_t length = 0; + mmi_port_get_name(port, &name, &length); + ... + free(name); + * @endcode + * + * @see mmi_port_set_name() + */ +int mmi_port_get_name(mmi_port_h port, char **name, size_t *length); + +/** + * @brief Gets the type of a port. + * @details This function retrieves the type associated with the specified port. + * @since_tizen 9.0 + * + * @param[in] port The port handle. + * @param[out] type A pointer to the variable that will receive the type of the port. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre The port handle must be valid and initialized. + * + * @see mmi_port_set_type() + * @see mmi_port_type_e + */ +int mmi_port_get_type(mmi_port_h port, mmi_port_type_e *type); + +/** + * @brief Gets the data type of a port. + * @details This function retrieves the data type associated with the specified port. + * @since_tizen 9.0 + * + * @param[in] port The port handle. + * @param[out] data_type A pointer to the variable that will receive the data type of the port. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre The port handle must be valid and initialized. + * + * @see mmi_port_set_data_type() + * @see mmi_data_type_e + */ +int mmi_port_get_data_type(mmi_port_h port, mmi_data_type_e *data_type); + +/** + * @brief Sets the name of a port. + * @details This function sets the name for the specified port. + * @since_tizen 9.0 + * + * @param[in] port The port handle. + * @param[in] name The new name to be set for the port. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre The port handle must be valid and initialized. + * + * @see mmi_port_get_name() + */ +int mmi_port_set_name(mmi_port_h port, const char *name); + +/** + * @brief Sets the type of a port. + * @details This function sets the type for the specified port. + * @since_tizen 9.0 + * + * @param[in] port The port handle. + * @param[in] type The new type to be set for the port. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre The port handle must be valid and initialized. + * + * @see mmi_port_get_type() + * @see mmi_port_type_e + */ +int mmi_port_set_type(mmi_port_h port, mmi_port_type_e type); + +/** + * @brief Sets the data type of a port. + * @details This function sets the data type for the specified port. + * @since_tizen 9.0 + * + * @param[in] port The port handle. + * @param[in] data_type The new data type to be set for the port. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre The port handle must be valid and initialized. + * + * @see mmi_port_get_data_type() + * @see mmi_data_type_e + */ +int mmi_port_set_data_type(mmi_port_h port, mmi_data_type_e data_type); + +/** + * @brief Sets the input data received callback function. + * @details This function sets the callback function that will be invoked when input data is received on the specified port. + * @since_tizen 9.0 + * + * @param[in] port The handle of the MMI port. + * @param[in] callback The callback function to set. + * @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 #MMI_ERROR_NONE Successful. + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter. + */ +int mmi_port_set_input_data_received_cb(mmi_port_h port, mmi_port_input_data_received_cb callback, void *user_data); + +/** + * @brief Clones a port. + * @details This function creates a copy of the specified port. + * @since_tizen 9.0 + * @remarks The @a cloned should be released using mmi_port_destroy(). + * + * @param[in] port The port handle to be cloned. + * @param[out] cloned A pointer to the newly created cloned port handle. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @pre The port handle must be valid and initialized. + * @post The cloned port handle must be destroyed using mmi_port_destroy() after use. + * + * @par Example + * @code + #include + ... + mmi_port_h port; // Indicates the handle of the port + mmi_port_h cloned = NULL; + mmi_port_clone(port, &cloned); + ... + mmi_port_destroy(cloned); + * @endcode + * + * @see mmi_port_create() + * @see mmi_port_destroy() + */ +int mmi_port_clone(mmi_port_h port, mmi_port_h *cloned); + +/** + * @brief Destroys a port. + * @details This function destroys the specified port, releasing all associated resources. + * @since_tizen 9.0 + * + * @param[in] port The handle of the port to be destroyed. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + */ +int mmi_port_destroy(mmi_port_h port); + +/** + * @brief Generates data to the port with the given port instance. + * @details This function generates data to the specified port using the provided port instance and data handle. + * @since_tizen 9.0 + * + * @param[in] instance The handle of the port instance. + * @param[in] data The handle of the data to be generated. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + */ +int mmi_port_instance_generate_output(mmi_port_instance_h instance, mmi_data_h data); + +#ifdef __cplusplus +} +#endif + + +/** + * @} + */ + + +#endif /* __TIZEN_UIX_MMI_PORT_H__ */ diff --git a/capi/workflow/mmi-workflow.h b/capi/workflow/mmi-workflow.h new file mode 100644 index 0000000..ea24d66 --- /dev/null +++ b/capi/workflow/mmi-workflow.h @@ -0,0 +1,348 @@ +/* + * 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_UIX_MMI_WORKFLOW_H__ +#define __TIZEN_UIX_MMI_WORKFLOW_H__ + + +#include +#include +#include + + +/** +* @file mmi-workflow.h +*/ + + +/** +* @addtogroup CAPI_UIX_MMI_WORKFLOW_MODULE +* @ingroup CAPI_UIX_MMI_MODULE +* @{ +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumeration for standard MMI workflows. + * @details This enumeration defines the different types of standard workflows supported by the MMI framework. + * @since_tizen 9.0 +*/ +typedef enum { + MMI_STANDARD_WORKFLOW_NONE = 0, /**< Indicates that no standard workflow is selected. */ + MMI_STANDARD_WORKFLOW_VOICE_TOUCH, /**< Indicates the Voice Touch workflow. */ +} mmi_standard_workflow_type_e; + +/** + * @brief Handle for MMI workflow prototypes. + * @details This handle represents a workflow prototype created within the MMI framework. + * @since_tizen 9.0 +*/ +typedef struct mmi_workflow_s* mmi_workflow_h; + +/** + * @brief Creates a new workflow prototype. + * @details This function allocates memory for a new workflow prototype and returns its handle. + * @since_tizen 9.0 + * @remarks The @a workflow should be released using mmi_workflow_destroy(). + * + * @param[out] workflow A pointer to store the handle of the newly created workflow prototype. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_workflow_h workflow = NULL; + mmi_workflow_create(&workflow); + ... + mmi_workflow_destroy(workflow); + * @endcode + * + * @see mmi_workflow_destroy() + */ +int mmi_workflow_create(mmi_workflow_h *workflow); + +/** + * @brief Sets the type of a workflow prototype. + * @details This function assigns a standard workflow type to the given workflow prototype. + * @since_tizen 9.0 + * + * @param[in] workflow The handle of the workflow prototype. + * @param[in] type The standard workflow type to be set. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see mmi_standard_workflow_type_e + * @see mmi_workflow_get_type() + */ +int mmi_workflow_set_type(mmi_workflow_h workflow, mmi_standard_workflow_type_e type); + +/** + * @brief Gets the type of a workflow prototype. + * @details This function retrieves the standard workflow type assigned to the given workflow prototype. + * @since_tizen 9.0 + * + * @param[in] workflow The handle of the workflow prototype. + * @param[out] type A pointer to store the retrieved standard workflow type. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see mmi_standard_workflow_type_e + * @see mmi_workflow_set_type() + */ +int mmi_workflow_get_type(mmi_workflow_h workflow, mmi_standard_workflow_type_e *type); + +/** + * @brief Adds a node to a workflow prototype. + * @details This function adds a node with a given name to the workflow prototype. + * @since_tizen 9.0 + * + * @param[in] workflow The handle of the workflow prototype. + * @param[in] node_name The name of the node to be added. + * @param[in] node The handle of the node to be added. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see mmi_node_h + */ +int mmi_workflow_node_add(mmi_workflow_h workflow, const char *node_name, mmi_node_h node); + +/** + * @brief Links two nodes in a workflow prototype using their names and port names. + * @details This function links the output port of one node to the input port of another node. + * @since_tizen 9.0 + * + * @param[in] workflow The handle of the workflow prototype. + * @param[in] from_node_name The name of the source node. + * @param[in] from_port_name The name of the output port of the source node. + * @param[in] to_node_name The name of the destination node. + * @param[in] to_port_name The name of the input port of the destination node. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see mmi_node_h + */ +int mmi_workflow_link_nodes_by_names(mmi_workflow_h workflow, const char *from_node_name, const char *from_port_name, const char *to_node_name, const char *to_port_name); + +/** + * @brief Assigns an attribute of a workflow to an attribute of a specific node. + * @details This function assigns a workflow attribute to a target attribute of a specific node in the workflow prototype. + * @since_tizen 9.0 + * + * @param[in] workflow The handle of the workflow prototype. + * @param[in] attribute_name The name of the workflow attribute to be assigned. + * @param[in] target_node_name The name of the target node. + * @param[in] target_attribute_name The name of the target attribute in the node. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see mmi_attribute_h + */ +int mmi_workflow_attribute_assign(mmi_workflow_h workflow, const char *attribute_name, const char *target_node_name, const char *target_attribute_name); + +/** + * @brief Sets the default value of an attribute of a workflow. + * @details This function sets the default value for a workflow attribute. + * @since_tizen 9.0 + * + * @param[in] workflow The handle of the workflow prototype. + * @param[in] default_value The handle of the default value to be set. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see mmi_attribute_h + */ +int mmi_workflow_attribute_set_default_value(mmi_workflow_h workflow, mmi_attribute_h default_value); + +/** + * @brief Assigns a signal of a workflow to a signal of a specific node in a workflow prototype. + * @details This function assigns a signal from a workflow to a target signal of a specific node in the workflow prototype. + * @since_tizen 9.0 + * + * @param[in] workflow The handle to the workflow. + * @param[in] signal_name The name of the signal to assign. + * @param[in] target_node_name The name of the target node where the signal will be assigned. + * @param[in] target_signal_name The name of the target signal in the target node. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @see mmi_workflow_h +*/ +int mmi_workflow_signal_assign(mmi_workflow_h workflow, const char *signal_name, const char *target_node_name, const char *target_signal_name); + +/** + * @brief Assigns an output of a workflow to a OUT port of a specific node in a workflow prototype. + * @details This function assigns an output from a workflow to a target OUT port of a specific node in the workflow prototype. + * @since_tizen 9.0 + * + * @param[in] workflow The handle to the workflow. + * @param[in] workflow_output The name of the output to assign. + * @param[in] out_node_name The name of the target node where the output will be assigned. + * @param[in] node_out_port_name The name of the target OUT port in the target node. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @see mmi_workflow_h +*/ +int mmi_workflow_output_assign(mmi_workflow_h workflow, const char *workflow_output, const char *out_node_name, const char *node_out_port_name); + +/** + * @brief Assigns an output of a workflow to a OUT port of a specific node in a workflow prototype using a port handle. + * @details This function assigns an output from a workflow to a target OUT port of a specific node in the workflow prototype using a port handle. + * @since_tizen 9.0 + * + * @param[in] workflow The handle to the workflow. + * @param[in] workflow_output The name of the output to assign. + * @param[in] port The handle to the target port where the output will be assigned. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @see mmi_workflow_h + * @see mmi_port_h +*/ +int mmi_workflow_output_assign_by_port(mmi_workflow_h workflow, const char *workflow_output, mmi_port_h port); + +/** + * @brief Registers a standard workflow prototype to the workflow manager. + * @details This function registers a standard workflow prototype to the workflow manager for further use. + * @since_tizen 9.0 + * + * @param[in] workflow The handle to the workflow prototype to register. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @see mmi_workflow_h +*/ +int mmi_standard_workflow_register(mmi_workflow_h workflow); + +/** + * @brief Clones a workflow. + * @details This function creates a clone of the specified workflow. + * @since_tizen 9.0 + * @remarks The @a cloned should be released using mmi_workflow_destroy(). + * + * @param[in] workflow The handle to the workflow to clone. + * @param[out] cloned A pointer to store the handle of the cloned workflow. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_workflow_h workflow; // Indicates the handle of the workflow + mmi_workflow_h cloned = NULL; + mmi_workflow_clone(workflow, &cloned); + ... + mmi_workflow_destroy(cloned); + * @endcode + * + * @see mmi_workflow_h +*/ +int mmi_workflow_clone(mmi_workflow_h workflow, mmi_workflow_h *cloned); + +/** + * @brief Creates a workflow prototype from a script. + * @details This function creates a workflow prototype from the provided script. + * @since_tizen 9.0 + * @remarks The @a workflow should be released using mmi_workflow_destroy(). + * + * @param[in] script The script to create the workflow prototype from. + * @param[out] workflow A pointer to store the handle of the created workflow prototype. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @par Example + * @code + #include + ... + mmi_workflow_h workflow = NULL; + mmi_workflow_create_from_script("@workflow", &workflow); + ... + mmi_workflow_destroy(workflow); + * @endcode + * + * @see mmi_workflow_h +*/ +int mmi_workflow_create_from_script(const char *script, mmi_workflow_h *workflow); + +/** + * @brief Destroys a workflow prototype. + * @details This function destroys the specified workflow prototype. + * @since_tizen 9.0 + * + * @param[in] workflow The handle to the workflow prototype to destroy. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MMI_ERROR_OUT_OF_MEMORY Out of memory + * + * @see mmi_workflow_h +*/ +int mmi_workflow_destroy(mmi_workflow_h workflow); + +#ifdef __cplusplus +} +#endif + + +/** + * @} + */ + + +#endif /* __TIZEN_UIX_MMI_WORKFLOW_H__ */ diff --git a/doc/mmi-doc.h b/doc/mmi-doc.h new file mode 100644 index 0000000..3784faa --- /dev/null +++ b/doc/mmi-doc.h @@ -0,0 +1,212 @@ +/* + * 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_UIX_MMI_DOC_H__ +#define __TIZEN_UIX_MMI_DOC_H__ + + +/** + * @file mmi-doc.h + * @brief This file contains high level documentation of the MMI API. + */ + +/** + * @ingroup CAPI_UIX_FRAMEWORK + * @defgroup CAPI_UIX_MMI_MODULE MMI + * @brief The @ref CAPI_UIX_MMI_MODULE API provides control functions for client applications such as creating and runing instances of the MMI workflow through the MMI framework. + * + * @section CAPI_UIX_MMI_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_UIX_MMI_MODULE_OVERVIEW Overview + * The MMI API provides control functions for client applications such as creating and runing instances of the MMI workflow through the MMI framework. + * The MMI workflow collects data from various modalities, processes it, and performs the function of deriving meaningful information to provide to client applications. + * \n + * This API set allows you to: + * - initialize/deinitialize the MMI Framework + * - set/unset a callback function for MMI state changes + * - create/destroy standard or custom workflow instances + * - activate/deactivate workflow instances + * - set attributes to workflow instances + * - emit signals to workflow instances + * - set/unset a callback function to receive the output of workflow instance + * \n + * By utilizing these functionalities, application developers can use multimodal workflows that integrate different modalities such as voice, touch, and vision. + * + * @subsection CAPI_UIX_MMI_MODULE_LIFE_CYCLE_STATE_TRANSITIONS State Transitions + *
+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
FUNCTIONPRE-STATEPOST-STATESYNC TYPE
mmi_initialize() NONE READY SYNC
mmi_deinitialize() READY NONE SYNC
+ * + * @subsection CAPI_UIX_MMI_MODULE_LIFE_CYCLE_CALLBACK_OPERATIONS Callback(Event) Operations + * The callback mechanism is used to notify the application about significant MMI events. + *
+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
REGISTERUNREGISTERCALLBACKDESCRIPTION
mmi_set_state_changed_cb()mmi_unset_state_changed_cb()mmi_state_changed_cb()This callback is used to notify that the MMI state has changed
mmi_workflow_instance_set_output_cb()mmi_workflow_instance_unset_output_cb()mmi_workflow_output_cb()This callback is used to notify that an error has occurred
+ */ + +/** + * @ingroup CAPI_UIX_MMI_MODULE + * @defgroup CAPI_UIX_MMI_COMMON_MODULE MMI Common + * @brief The @ref CAPI_UIX_MMI_COMMON_MODULE API provides common functions for sending and receiving data and signals to/from the MMI framework. + * @section CAPI_UIX_MMI_COMMON_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_UIX_MMI_COMMON_MODULE_OVERVIEW Overview + * The MMI Common API allows you to: + * - create/destroy various types of data objects that can be transferred beween MMI nodes, workflows and applications + * - create/destroy attributes that are used to set the properties of MMI nodes and workflows + * - create/destroy signals that are used to notify MMI nodes and workflows about events + * - serialize/deserialize data objects, attributes, and signals +*/ + +/** + * @ingroup CAPI_UIX_MMI_MODULE + * @defgroup CAPI_UIX_MMI_NODE_MODULE MMI Node + * @brief The @ref CAPI_UIX_MMI_NODE_MODULE API provides functions for creating and managing MMI node modules + * @section CAPI_UIX_MMI_NODE_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_UIX_MMI_NODE_MODULE_OVERVIEW Overview + * The MMI API provides functions for creating and managing MMI node modules. + * Nodes represent distinct elements within the workflow, each fulfilling a particular role such as data acquisition, data transformation, or decision making. + * By integrating various types of nodes, workflows can support various multimodal interactions. + * \n + * This API set allows you to: + * - create/destroy nodes of various types + * - retrieve the type of a given node + * - add ports to a node for data exchange + * - find ports by their names and types + * - set initialization, deinitialization, activation, deactivation, and signal receiving callbacks for a node + * - set input data processing callbacks for a port + * - register nodes into the MMI framework to enable them to be used by workflows + * + * @subsection CAPI_UIX_MMI_NODE_CALLBACK_OPERATIONS Node Callback(Event) Operations + * The callback mechanism is used to notify the MMI Node module about significant events. + *
+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
SETCALLBACKDESCRIPTION
mmi_node_set_initialized_cb()mmi_node_initialized_cb()This callback function is called when a node instance is initialized
mmi_node_set_deinitialized_cb()mmi_node_deinitialized_cb()This callback function is called when a node instance is deinitialized
mmi_node_set_attribute_set_cb()mmi_node_attribute_set_cb()This callback function is called when an attribute is set on a node instance
mmi_node_set_activated_cb()mmi_node_activated_cb()This callback function is called when a node instance is activated
mmi_node_set_deactivated_cb()mmi_node_deactivated_cb()This callback function is called when a node instance is deactivated
mmi_node_set_signal_received_cb()mmi_node_signal_received_cb()This callback function is called when a signal is received by a node instance
+ * + * @subsection CAPI_UIX_MMI_NODE_PORT_CALLBACK_OPERATIONS Port Callback(Event) Operations + * The callback mechanism is used to notify the MMI Node module about significant events on its port. + *
+ * + * + * + * + * + * + * + * + * + * + *
SETCALLBACKDESCRIPTION
mmi_port_set_input_data_received_cb()mmi_port_input_data_received_cb()This callback function is called whenever input data is received for a port instance
+*/ + +/** + * @ingroup CAPI_UIX_MMI_MODULE + * @defgroup CAPI_UIX_MMI_WORKFLOW_MODULE MMI Workflow + * @brief The @ref CAPI_UIX_MMI_WORKFLOW_MODULE API provides functions for creating MMI workflow modules + * @section CAPI_UIX_MMI_WORKFLOW_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_UIX_MMI_WORKFLOW_MODULE_OVERVIEW Overview + * The MMI Workflow API provides functions to manage workflows in the MMI framework. + * Workflows consist of nodes connected together to form a graph representing a series of actions executed in response to certain data flows, events, or conditions. + * \n + * This API set allows you to: + * - create/destroy workflows + * - set/get the standard type of a workflow + * - add nodes to a workflow + * - link nodes together by specifying input and output ports + * - assign attributes to nodes within a workflow + * - set default values for attributes + * - assign signals to nodes within a workflow + * - associate workflow output with a specific node and port + * - register standard workflows + * - create custom workflows from scripts +*/ + +#endif /* __TIZEN_UIX_MMI_DOC_H__ */ diff --git a/src/mmi-cli/mmi-cli-node-tester.cpp b/src/mmi-cli/mmi-cli-node-tester.cpp index 39c71ee..a9fb4e8 100644 --- a/src/mmi-cli/mmi-cli-node-tester.cpp +++ b/src/mmi-cli/mmi-cli-node-tester.cpp @@ -11,6 +11,8 @@ #include "cli/cli.h" #include "mmi.h" +#include "mmi-node-internal.h" +#include "mmi-port-internal.h" #include "mmi-defines.h" #include "mmi-plugin-module.h" #include "mmi-plugin-storage.h" @@ -27,14 +29,14 @@ struct PortInstance std::string m_name; mmi_port_type_e m_port_type; mmi_data_type_e m_data_type; - mmi_port_callbacks_s m_callbacks{{nullptr}, {nullptr}}; + mmi_port_callbacks_s m_callbacks; }; struct NodeInstance { mmi_node_type_e m_node_type; - mmi_node_callbacks_s m_callbacks{{nullptr}, {nullptr}, {nullptr}, {nullptr}, {nullptr}, {nullptr}}; + mmi_node_callbacks_s m_callbacks; std::vector m_ports; }; diff --git a/src/mmi-cli/mmi-cli.cpp b/src/mmi-cli/mmi-cli.cpp index 26b50a8..72b9d0b 100644 --- a/src/mmi-cli/mmi-cli.cpp +++ b/src/mmi-cli/mmi-cli.cpp @@ -3,13 +3,13 @@ #include #include "adishavit/argh.h" -#include "magic_enum/magic_enum.hpp" #include "cliecoresession.h" #include "cli/cli.h" #include "mmi.h" +#include "mmi-workflow-internal.h" #ifdef USE_VOICE_TOUCH_TV #include @@ -176,30 +176,6 @@ static char *get_navigation_viv_response(std::string direction, std::string repe } #endif -static std::string to_string(mmi_data_h data) -{ - mmi_data_type_e type; - mmi_data_get_type(data, &type); - if (type == MMI_DATA_TYPE_TEXT) { - const char *value = nullptr; - mmi_data_get_text(data, &value); - return std::string(value ? value : "NULL"); - } else if (type == MMI_DATA_TYPE_FLOAT) { - float value; - mmi_data_get_float(data, &value); - return std::to_string(value); - } else if (type == MMI_DATA_TYPE_BOOLEAN) { - bool value; - mmi_data_get_bool(data, &value); - return std::string(value ? "TRUE" : "FALSE"); - } else if (type == MMI_DATA_TYPE_INTEGER) { - int value; - mmi_data_get_int(data, &value); - return std::to_string(value); - } - return std::string("Unknown"); -} - class Program { public: @@ -223,14 +199,7 @@ public: static_cast(type), &m_instance); mmi_workflow_instance_set_output_cb(m_instance, "COMMAND", [](mmi_workflow_instance_h instance, const char *name, mmi_data_h data, void *user_data) { - mmi_data_type_e type; - mmi_data_get_type(data, &type); - std::cout << - "OUTPUT data received : " << - "[Name:" << std::string(name ? name : "") << "]" << - "[Type:" << std::string(magic_enum::enum_name(type)) << "]" << - "[Value:" << to_string(data) << "]" << - std::endl; + std::cout << "OUTPUT data received : " << std::string(name ? name : "") << std::endl; }, nullptr); mmi_workflow_instance_set_output_cb(m_instance, "UTTERANCE", diff --git a/src/mmi-manager/mmi-ipc-ecore.cpp b/src/mmi-manager/mmi-ipc-ecore.cpp index 90c9e99..dfac2cc 100644 --- a/src/mmi-manager/mmi-ipc-ecore.cpp +++ b/src/mmi-manager/mmi-ipc-ecore.cpp @@ -2,6 +2,8 @@ #include +#include "mmi-defines.h" + namespace mmi { namespace communication { diff --git a/src/mmi-manager/mmi-node-instance.cpp b/src/mmi-manager/mmi-node-instance.cpp index 3e68136..0ce086f 100644 --- a/src/mmi-manager/mmi-node-instance.cpp +++ b/src/mmi-manager/mmi-node-instance.cpp @@ -24,6 +24,7 @@ #include "mmi-node-instance.h" #include "mmi-manager-log.h" +#include "mmi-port-internal.h" namespace mmi { diff --git a/src/mmi-manager/mmi-node-instance.h b/src/mmi-manager/mmi-node-instance.h index 31be821..3cd9731 100644 --- a/src/mmi-manager/mmi-node-instance.h +++ b/src/mmi-manager/mmi-node-instance.h @@ -25,6 +25,7 @@ #define __MMI_NODE_INSTANCE_H__ #include "mmi-node.h" +#include "mmi-node-internal.h" #include "mmi-node-prototype-manager.h" #include "mmi-plugin-module-proxy.h" #include "mmi-port-instance-manager.h" diff --git a/src/mmi-manager/mmi-plugin-module-proxy.cpp b/src/mmi-manager/mmi-plugin-module-proxy.cpp index a73396a..25c9f84 100644 --- a/src/mmi-manager/mmi-plugin-module-proxy.cpp +++ b/src/mmi-manager/mmi-plugin-module-proxy.cpp @@ -27,6 +27,8 @@ #include "mmi-manager-log.h" #include "mmi-workflow-internal.h" +#include "mmi-node-internal.h" +#include "mmi-port-internal.h" namespace mmi { diff --git a/src/mmi-manager/mmi-port-instance.h b/src/mmi-manager/mmi-port-instance.h index 7a27a44..de583cf 100644 --- a/src/mmi-manager/mmi-port-instance.h +++ b/src/mmi-manager/mmi-port-instance.h @@ -26,6 +26,7 @@ #include "mmi.h" #include "mmi-port.h" +#include "mmi-port-internal.h" #include "mmi-data-gateway.h" #include @@ -51,7 +52,7 @@ public: void on_output_data_received(mmi_data_h data); private: std::string m_name; - mmi_port_callbacks_s m_callbacks{{nullptr}, {nullptr}}; + mmi_port_callbacks_s m_callbacks; std::vector> m_linked_port_instances; std::vector> m_data_gateways; diff --git a/src/mmi-manager/mmi-self-container.cpp b/src/mmi-manager/mmi-self-container.cpp index 02359f5..add9ddd 100644 --- a/src/mmi-manager/mmi-self-container.cpp +++ b/src/mmi-manager/mmi-self-container.cpp @@ -39,7 +39,6 @@ TestNodePluginModule::TestNodePluginModule() { default_node_callbacks.deactivated_cb = node_deactivated_cb; default_node_callbacks.signal_received_cb = node_signal_received_cb; - default_port_callbacks.output_format_requested_cb = port_output_format_requested_cb; default_port_callbacks.input_data_received_cb = port_input_data_received_cb; } @@ -76,10 +75,6 @@ int TestNodePluginModule::node_signal_received_cb(mmi_node_instance_h instance, return MMI_ERROR_NONE; } -int TestNodePluginModule::port_output_format_requested_cb(mmi_port_instance_h instance, const char **format, void *user_data) { - _D("Port output format request callback is called for %p", instance); - return MMI_ERROR_NONE; -} int TestNodePluginModule::port_input_data_received_cb(mmi_port_instance_h instance, mmi_data_h data, void *user_data) { _D("Port input data callback is called for %p", instance); return MMI_ERROR_NONE; @@ -210,35 +205,64 @@ mmi_plugin_module_node_list_s PluginModuleProxySelfContainerTest::load_node_prot mmi_port_set_name(screen_info_port, "SCREEN_INFO"); mmi_port_set_type(screen_info_port, MMI_PORT_TYPE_OUT); mmi_port_set_data_type(screen_info_port, MMI_DATA_TYPE_TEXT); - mmi_port_set_callbacks(screen_info_port, m_node_screen_analyzer.m_screen_info_port_callbacks, nullptr); - mmi_node_h screen_anlayzer_node = nullptr; - mmi_node_create_source(MMI_NODE_SOURCE_TYPE_SCREEN_ANALYZER, &screen_anlayzer_node); - mmi_node_add_port(screen_anlayzer_node, screen_info_port); - mmi_node_set_callbacks(screen_anlayzer_node, m_node_screen_analyzer.m_node_callbacks, nullptr); - mmi_node_register(screen_anlayzer_node); + mmi_port_set_input_data_received_cb(screen_info_port, + m_node_screen_analyzer.m_screen_info_port_callbacks.input_data_received_cb, nullptr); + + mmi_node_h screen_analyzer_node = nullptr; + mmi_node_create_source(MMI_NODE_SOURCE_TYPE_SCREEN_ANALYZER, &screen_analyzer_node); + mmi_node_add_port(screen_analyzer_node, screen_info_port); + + mmi_node_set_initialized_cb(screen_analyzer_node, + m_node_screen_analyzer.m_node_callbacks.initialized_cb, nullptr); + mmi_node_set_deinitialized_cb(screen_analyzer_node, + m_node_screen_analyzer.m_node_callbacks.deinitialized_cb, nullptr); + mmi_node_set_attribute_set_cb(screen_analyzer_node, + m_node_screen_analyzer.m_node_callbacks.attribute_set_cb, nullptr); + mmi_node_set_activated_cb(screen_analyzer_node, + m_node_screen_analyzer.m_node_callbacks.activated_cb, nullptr); + mmi_node_set_deactivated_cb(screen_analyzer_node, + m_node_screen_analyzer.m_node_callbacks.deactivated_cb, nullptr); + mmi_node_set_signal_received_cb(screen_analyzer_node, + m_node_screen_analyzer.m_node_callbacks.signal_received_cb, nullptr); - mmi_node_destroy(screen_anlayzer_node); + mmi_node_register(screen_analyzer_node); + + mmi_node_destroy(screen_analyzer_node); mmi_port_h match_text_port = nullptr; mmi_port_create(&match_text_port); mmi_port_set_name(match_text_port, "TEXT"); mmi_port_set_type(match_text_port, MMI_PORT_TYPE_IN); mmi_port_set_data_type(match_text_port, MMI_DATA_TYPE_TEXT); - mmi_port_set_callbacks(match_text_port, m_node_match.m_text_port_callbacks, nullptr); + mmi_port_set_input_data_received_cb(match_text_port, + m_node_match.m_text_port_callbacks.input_data_received_cb, nullptr); mmi_port_h match_candidate_port = nullptr; mmi_port_create(&match_candidate_port); mmi_port_set_name(match_candidate_port, "MATCHED_CANDIDATE"); mmi_port_set_type(match_candidate_port, MMI_PORT_TYPE_OUT); mmi_port_set_data_type(match_candidate_port, MMI_DATA_TYPE_TEXT); - mmi_port_set_callbacks(match_candidate_port, m_node_match.m_text_port_callbacks, nullptr); + mmi_port_set_input_data_received_cb(match_candidate_port, + m_node_match.m_text_port_callbacks.input_data_received_cb, nullptr); mmi_node_h match_node = nullptr; mmi_node_create_logic(MMI_NODE_LOGIC_TYPE_FIXED_STRING_MATCH, &match_node); mmi_node_add_port(match_node, match_text_port); mmi_node_add_port(match_node, match_candidate_port); - mmi_node_set_callbacks(match_node, m_node_match.m_node_callbacks, nullptr); + + mmi_node_set_initialized_cb(match_node, + m_node_match.m_node_callbacks.initialized_cb, nullptr); + mmi_node_set_deinitialized_cb(match_node, + m_node_match.m_node_callbacks.deinitialized_cb, nullptr); + mmi_node_set_attribute_set_cb(match_node, + m_node_match.m_node_callbacks.attribute_set_cb, nullptr); + mmi_node_set_activated_cb(match_node, + m_node_match.m_node_callbacks.activated_cb, nullptr); + mmi_node_set_deactivated_cb(match_node, + m_node_match.m_node_callbacks.deactivated_cb, nullptr); + mmi_node_set_signal_received_cb(match_node, + m_node_match.m_node_callbacks.signal_received_cb, nullptr); mmi_node_register(match_node); mmi_node_destroy(match_node); @@ -248,12 +272,26 @@ mmi_plugin_module_node_list_s PluginModuleProxySelfContainerTest::load_node_prot mmi_port_set_name(key_event_port, "KEY_EVENT"); mmi_port_set_type(key_event_port, MMI_PORT_TYPE_IN); mmi_port_set_data_type(key_event_port, MMI_DATA_TYPE_TEXT); - mmi_port_set_callbacks(key_event_port, m_node_key_event.m_key_event_port_callbacks, nullptr); + mmi_port_set_input_data_received_cb(key_event_port, + m_node_key_event.m_key_event_port_callbacks.input_data_received_cb, nullptr); mmi_node_h key_event_node = nullptr; mmi_node_create_action(MMI_NODE_ACTION_TYPE_KEY_EVENT, &key_event_node); mmi_node_add_port(key_event_node, key_event_port); - mmi_node_set_callbacks(key_event_node, m_node_key_event.m_node_callbacks, nullptr); + + mmi_node_set_initialized_cb(key_event_node, + m_node_key_event.m_node_callbacks.initialized_cb, nullptr); + mmi_node_set_deinitialized_cb(key_event_node, + m_node_key_event.m_node_callbacks.deinitialized_cb, nullptr); + mmi_node_set_attribute_set_cb(key_event_node, + m_node_key_event.m_node_callbacks.attribute_set_cb, nullptr); + mmi_node_set_activated_cb(key_event_node, + m_node_key_event.m_node_callbacks.activated_cb, nullptr); + mmi_node_set_deactivated_cb(key_event_node, + m_node_key_event.m_node_callbacks.deactivated_cb, nullptr); + mmi_node_set_signal_received_cb(key_event_node, + m_node_key_event.m_node_callbacks.signal_received_cb, nullptr); + mmi_node_register(key_event_node); mmi_node_destroy(key_event_node); diff --git a/src/mmi-manager/mmi-self-container.h b/src/mmi-manager/mmi-self-container.h index 6ebd823..ac6fb28 100644 --- a/src/mmi-manager/mmi-self-container.h +++ b/src/mmi-manager/mmi-self-container.h @@ -27,6 +27,9 @@ #include "mmi-plugin-module-proxy.h" #include "mmi-manager-log.h" +#include "mmi-node-internal.h" +#include "mmi-port-internal.h" + #include #include #include @@ -51,7 +54,6 @@ public: static int node_activated_cb(mmi_node_instance_h instance, void *user_data); static int node_deactivated_cb(mmi_node_instance_h instance, void *user_data); static int node_signal_received_cb(mmi_node_instance_h instance, mmi_signal_h signal, void *user_data); - static int port_output_format_requested_cb(mmi_port_instance_h instance, const char **format, void *user_data); static int port_input_data_received_cb(mmi_port_instance_h instance, mmi_data_h data, void *user_data); mmi_node_callbacks_s default_node_callbacks; diff --git a/src/mmi/meson.build b/src/mmi/meson.build index e44cc8b..5d35046 100644 --- a/src/mmi/meson.build +++ b/src/mmi/meson.build @@ -62,6 +62,7 @@ mmi_lib = shared_library( pkgconfig = import('pkgconfig') pkgconfig.generate( filebase : 'mmi', + subdirs : ['mmi'], name : 'mmi', description : 'Multi-modal Interaction Framework Library', version : meson.project_version(), diff --git a/src/mmi/mmi-ipc-ecore.cpp b/src/mmi/mmi-ipc-ecore.cpp index 3bfbcf3..30335b1 100644 --- a/src/mmi/mmi-ipc-ecore.cpp +++ b/src/mmi/mmi-ipc-ecore.cpp @@ -1,5 +1,7 @@ #include "mmi-ipc-ecore.h" +#include "mmi-defines.h" + namespace mmi { namespace communication { diff --git a/src/mmi/mmi-ipc-tidl.cpp b/src/mmi/mmi-ipc-tidl.cpp index de0610b..4e95f6a 100644 --- a/src/mmi/mmi-ipc-tidl.cpp +++ b/src/mmi/mmi-ipc-tidl.cpp @@ -65,6 +65,8 @@ static void result_cb(void *user_data, const char *source_name, bundle *data) { } workflow_instance->call_output_callback(source_name, restored_data); + + mmi_data_destroy(restored_data); } void CommunicationChannelTIDL::on_connected(rpc_port_proxy_mmi_h h, void *user_data) { diff --git a/src/mmi/mmi-node-internal.h b/src/mmi/mmi-node-internal.h index 30292b2..35b5049 100644 --- a/src/mmi/mmi-node-internal.h +++ b/src/mmi/mmi-node-internal.h @@ -20,11 +20,21 @@ #define __TIZEN_UIX_MMI_NODE_INTERNAL_H__ #include +#include #ifdef __cplusplus extern "C" { #endif +typedef struct { + mmi_node_initialized_cb initialized_cb; + mmi_node_deinitialized_cb deinitialized_cb; + mmi_node_attribute_set_cb attribute_set_cb; + mmi_node_activated_cb activated_cb; + mmi_node_deactivated_cb deactivated_cb; + mmi_node_signal_received_cb signal_received_cb; +} mmi_node_callbacks_s; + struct mmi_node_s { mmi_node_type_e type; int sub_type; @@ -34,6 +44,10 @@ struct mmi_node_s { mmi_node_callbacks_s callbacks; }; +int mmi_node_get_callbacks(mmi_node_h node, mmi_node_callbacks_s *callbacks); + +int mmi_node_set_callbacks(mmi_node_h node, mmi_node_callbacks_s callbacks, void *user_data); + #ifdef __cplusplus } #endif diff --git a/src/mmi/mmi-node.cpp b/src/mmi/mmi-node.cpp index 7dfcc38..241f285 100644 --- a/src/mmi/mmi-node.cpp +++ b/src/mmi/mmi-node.cpp @@ -119,12 +119,57 @@ int mmi_node_get_callbacks(mmi_node_h node, mmi_node_callbacks_s *callbacks) { return MMI_ERROR_NONE; } -int mmi_node_set_callbacks(mmi_node_h node, mmi_node_callbacks_s callbacks, void *user_data) { +int mmi_node_set_initialized_cb(mmi_node_h node, mmi_node_initialized_cb callback, void *user_data) { if (nullptr == node) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; } - node->callbacks = callbacks; + node->callbacks.initialized_cb = callback; + return MMI_ERROR_NONE; +} + +int mmi_node_set_deinitialized_cb(mmi_node_h node, mmi_node_deinitialized_cb callback, void *user_data) { + if (nullptr == node) { + LOGE("[ERROR] parameter is null"); + return MMI_ERROR_INVALID_PARAMETER; + } + node->callbacks.deinitialized_cb = callback; + return MMI_ERROR_NONE; +} + +int mmi_node_set_attribute_set_cb(mmi_node_h node, mmi_node_attribute_set_cb callback, void *user_data) { + if (nullptr == node) { + LOGE("[ERROR] parameter is null"); + return MMI_ERROR_INVALID_PARAMETER; + } + node->callbacks.attribute_set_cb = callback; + return MMI_ERROR_NONE; +} + +int mmi_node_set_activated_cb(mmi_node_h node, mmi_node_activated_cb callback, void *user_data) { + if (nullptr == node) { + LOGE("[ERROR] parameter is null"); + return MMI_ERROR_INVALID_PARAMETER; + } + node->callbacks.activated_cb = callback; + return MMI_ERROR_NONE; +} + +int mmi_node_set_deactivated_cb(mmi_node_h node, mmi_node_deactivated_cb callback, void *user_data) { + if (nullptr == node) { + LOGE("[ERROR] parameter is null"); + return MMI_ERROR_INVALID_PARAMETER; + } + node->callbacks.deactivated_cb = callback; + return MMI_ERROR_NONE; +} + +int mmi_node_set_signal_received_cb(mmi_node_h node, mmi_node_signal_received_cb callback, void *user_data) { + if (nullptr == node) { + LOGE("[ERROR] parameter is null"); + return MMI_ERROR_INVALID_PARAMETER; + } + node->callbacks.signal_received_cb = callback; return MMI_ERROR_NONE; } diff --git a/src/mmi/mmi-port-internal.h b/src/mmi/mmi-port-internal.h new file mode 100644 index 0000000..0d5448c --- /dev/null +++ b/src/mmi/mmi-port-internal.h @@ -0,0 +1,79 @@ +/* + * 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_UIX_MMI_PORT_INTERNAL_H__ +#define __TIZEN_UIX_MMI_PORT_INTERNAL_H__ + + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Callback function type for output format requests. + * @details This callback function is called whenever an output format request is made for a port instance. + * @since_tizen 9.0 + * @remarks The @a instance should not be released. + * The @a instance is available until the port instance is released. + * + * @param[in] instance The port instance handle. + * @param[out] format The requested output format. + * @param[in] user_data The user data passed from the registration function. + * + * @return An integer value indicating the result of the callback execution. + * @retval 0 on success, otherwise a negative error value. +*/ +typedef int (*mmi_port_output_format_requested_cb)(mmi_port_instance_h instance, const char **format, void *user_data); + +typedef struct { + mmi_port_output_format_requested_cb output_format_requested_cb; + void *output_format_requested_user_data; + mmi_port_input_data_received_cb input_data_received_cb; + void *input_data_received_user_data; +} mmi_port_callbacks_s; + +/** + * @brief Structure representing a port instance. + * @details This structure contains information about a port instance, including its name, type, data type, and associated callbacks. + * @since_tizen 9.0 +*/ +struct mmi_port_s { + char name[MMI_NAME_MAX_LENGTH]; /**< Name of the port. */ + mmi_port_type_e type; /**< Type of the port (input or output). */ + mmi_data_type_e data_type; /**< Data type supported by the port. */ + mmi_port_callbacks_s callbacks; /**< Callbacks associated with the port. */ +}; + +int mmi_port_get_callbacks(mmi_port_h port, mmi_port_callbacks_s *callbacks); + +int mmi_port_set_callbacks(mmi_port_h port, mmi_port_callbacks_s callbacks, void *user_data); + +#ifdef __cplusplus +} +#endif + + +/** + * @} + */ + + +#endif /* __TIZEN_UIX_MMI_PORT_INTERNAL_H__ */ diff --git a/src/mmi/mmi-port.cpp b/src/mmi/mmi-port.cpp index 9635f4e..f459b31 100644 --- a/src/mmi/mmi-port.cpp +++ b/src/mmi/mmi-port.cpp @@ -19,6 +19,7 @@ #include "mmi.h" #include "mmi-common.h" #include "mmi-port.h" +#include "mmi-port-internal.h" #include "mmi-plugin-storage.h" #include @@ -82,7 +83,6 @@ MMI_API int mmi_port_get_data_type(mmi_port_h port, mmi_data_type_e *data_type) return MMI_ERROR_NONE; } -// LCOV_EXCL_START MMI_API int mmi_port_get_callbacks(mmi_port_h port, mmi_port_callbacks_s *callbacks) { if (nullptr == port || nullptr == callbacks) { LOGE("[ERROR] parameter is null"); @@ -90,12 +90,10 @@ MMI_API int mmi_port_get_callbacks(mmi_port_h port, mmi_port_callbacks_s *callba } mmi_port_s *port_s = static_cast(port); - *callbacks = port_s->callbacks; return MMI_ERROR_NONE; } -// LCOV_EXCL_STOP MMI_API int mmi_port_set_name(mmi_port_h port, const char *name) { if (nullptr == port || nullptr == name) { @@ -136,15 +134,30 @@ MMI_API int mmi_port_set_data_type(mmi_port_h port, mmi_data_type_e data_type) { return MMI_ERROR_NONE; } -MMI_API int mmi_port_set_callbacks(mmi_port_h port, mmi_port_callbacks_s callbacks, void *user_data) { +MMI_API int mmi_port_set_output_format_requested_cb(mmi_port_h port, mmi_port_output_format_requested_cb callback, void *user_data) +{ if (nullptr == port) { + LOGE("[ERROR] Port is null"); + return MMI_ERROR_INVALID_PARAMETER; + } + + mmi_port_s *port_s = static_cast(port); + + port_s->callbacks.output_format_requested_cb = callback; + + return MMI_ERROR_NONE; +} + +MMI_API int mmi_port_set_input_data_received_cb(mmi_port_h port, mmi_port_input_data_received_cb callback, void *user_data) +{ + if (nullptr == port || nullptr == callback) { LOGE("[ERROR] parameter is null"); return MMI_ERROR_INVALID_PARAMETER; } mmi_port_s *port_s = static_cast(port); - port_s->callbacks = callbacks; + port_s->callbacks.input_data_received_cb = callback; return MMI_ERROR_NONE; } diff --git a/src/mmi/mmi-workflow-instance-manager.h b/src/mmi/mmi-workflow-instance-manager.h index ff7fab6..27ad0a8 100644 --- a/src/mmi/mmi-workflow-instance-manager.h +++ b/src/mmi/mmi-workflow-instance-manager.h @@ -54,6 +54,22 @@ public: return ret; } + bool remove_output_callback(std::string key, mmi_workflow_output_cb callback) { + bool ret = false; + if (callback) { + for (auto it = callbacks.begin(); it!= callbacks.end(); ) { + if (key.compare(it->first) == 0 && + it->second.first == callback) { + it = callbacks.erase(it); + } else { + ++it; + } + } + ret = true; + } + return ret; + } + bool call_output_callback(std::string key, mmi_data_h data) { bool ret = false; if (callbacks.find(key) != callbacks.end()) { diff --git a/src/mmi/mmi-workflow-instance.cpp b/src/mmi/mmi-workflow-instance.cpp index c3da4bd..62eec09 100644 --- a/src/mmi/mmi-workflow-instance.cpp +++ b/src/mmi/mmi-workflow-instance.cpp @@ -274,3 +274,25 @@ MMI_API int mmi_workflow_instance_set_output_cb(mmi_workflow_instance_h instance return MMI_ERROR_NONE; } // LCOV_EXCL_STOP + +MMI_API int mmi_workflow_instance_unset_output_cb(mmi_workflow_instance_h instance, const char *name, mmi_workflow_output_cb callback) { + if (nullptr == instance) { + LOGE("[ERROR] parameter is null"); + return MMI_ERROR_INVALID_PARAMETER; + } + + if (nullptr == name) { + LOGE("[ERROR] parameter is null"); + return MMI_ERROR_INVALID_PARAMETER; + } + + if (nullptr == callback) { + LOGE("[ERROR] parameter is null"); + return MMI_ERROR_INVALID_PARAMETER; + } + + WorkflowInstance *workflow_instance = static_cast(instance); + workflow_instance->remove_output_callback(std::string{name}, callback); + + return MMI_ERROR_NONE; +} diff --git a/src/mmi/mmi-workflow-internal.h b/src/mmi/mmi-workflow-internal.h index 24c6248..fcb7132 100644 --- a/src/mmi/mmi-workflow-internal.h +++ b/src/mmi/mmi-workflow-internal.h @@ -20,6 +20,7 @@ #define __TIZEN_UIX_MMI_WORKFLOW_INTERNAL_H__ +#include #include #include #include "mmi-defines.h" @@ -93,6 +94,27 @@ struct mmi_workflow_s { size_t output_assignment_info_count; }; +/** + * @brief Feeds data to a port of a node within a workflow instance. + * @details This function sends data to a specific port of a node within the workflow instance. + * @since_tizen 9.0 + * + * @param[in] instance The handle to the workflow instance. + * @param[in] node_name The name of the node to which the data is sent. + * @param[in] port_name The name of the port within the node to which the data is sent. + * @param[in] data The handle to the data to be fed. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MMI_ERROR_NONE Successful. + * @retval #MMI_ERROR_INVALID_PARAMETER Invalid parameter. + * + * @pre The workflow instance must have been created and activated before calling this function. + * @post The data is processed by the workflow instance. + * + * @see mmi_data_create() +*/ +int mmi_workflow_instance_feed_data(mmi_workflow_instance_h instance, const char *node_name, const char *port_name, mmi_data_h data); + #ifdef __cplusplus } diff --git a/tests/mmi-manager/plugin-module-registry/mmi-plugin-module-registry-tests.cpp b/tests/mmi-manager/plugin-module-registry/mmi-plugin-module-registry-tests.cpp index 7afb296..54d7b30 100644 --- a/tests/mmi-manager/plugin-module-registry/mmi-plugin-module-registry-tests.cpp +++ b/tests/mmi-manager/plugin-module-registry/mmi-plugin-module-registry-tests.cpp @@ -264,7 +264,7 @@ TEST_F(PluginModuleRegistryTest, NonExistingWorkflowNotRetrieved_n) { bool ret = registry.load_workflow_prototypes(); ASSERT_TRUE(ret); - auto workflow = workflow_prototype_store->get_workflow_prototype(MMI_STANDARD_WORKFLOW_VOICE_TOUCH); + auto workflow = workflow_prototype_store->get_workflow_prototype(MMI_STANDARD_WORKFLOW_NONE); ASSERT_EQ(nullptr, workflow); registry.deinitialize(); diff --git a/tests/mmi-manager/workflow-instance/mmi-workflow-instance-tests.cpp b/tests/mmi-manager/workflow-instance/mmi-workflow-instance-tests.cpp index 257e895..5c6cfbc 100644 --- a/tests/mmi-manager/workflow-instance/mmi-workflow-instance-tests.cpp +++ b/tests/mmi-manager/workflow-instance/mmi-workflow-instance-tests.cpp @@ -30,7 +30,7 @@ public: mmi_primitive_value_h value = nullptr; mmi_primitive_value_create_string("Default", &value); mmi_attribute_h default_value = nullptr; - mmi_attribute_create(value, "COMMAND", &default_value); + mmi_attribute_create(value, "CANDIDATES", &default_value); attribute_default_value_info.default_value = default_value; mmi_primitive_value_destroy(value); @@ -278,7 +278,7 @@ TEST_F(WorkflowInstanceTest, WorkflowAttributePassedProperlyAfter2ndInitializati mmi_primitive_value_h value = nullptr; mmi_primitive_value_create_string("Hello", &value); mmi_attribute_h attribute = nullptr; - mmi_attribute_create(value, "COMMAND", &attribute); + mmi_attribute_create(value, "CANDIDATES", &attribute); EXPECT_TRUE(workflow_instance->set_attribute(attribute)); EXPECT_EQ(g_last_node_attribute_set_history.m_type, MMI_NODE_TYPE_LOGIC); EXPECT_TRUE(std::holds_alternative(g_last_node_attribute_set_history.m_sub_type)); @@ -349,7 +349,7 @@ TEST_F(WorkflowInstanceTest, WorkflowDefaultAttributePassedProperlyAfter2ndIniti char *name = nullptr; mmi_attribute_get_name(g_last_node_attribute_set_history.m_attribute, &name); - EXPECT_STREQ(name, "CANDIDATE"); + EXPECT_STREQ(name, "CANDIDATES"); free(name); mmi_primitive_value_h history_item_value; -- 2.34.1