#include <cynara-session.h>
#include <Ecore_Wayland.h>
#include <system_info.h>
+#include <vconf/vconf.h>
+#include <stdlib.h>
#include "multi_assistant.h"
#include "ma_client.h"
#include "ma_main.h"
#include "ma_defs.h"
+#include "ma_config_mgr.h"
+#define MAX_ASSISTANT_INFO_STR_LEN 128
+#define MAX_ASSISTANT_NUM 10
+#define APPID_URL "db/multi-assistant/enabled_assistants"
+typedef struct{
+ char app_id[MAX_ASSISTANT_INFO_STR_LEN];
+ char name[MAX_ASSISTANT_INFO_STR_LEN];
+ int cnt_lang;
+ bool enabled;
+}assistant_info_t;
+
+static assistant_info_t __assistant_info[MAX_ASSISTANT_NUM];
+
+static int _assistant_info_index;
static ma_h g_ma = NULL;
return MA_ERROR_NONE;
}
-
int ma_initialize(void)
{
if (0 != __ma_get_feature_enabled()) {
ma_client_set_wakeup_engine_command_cb(g_ma, NULL, NULL);
+ return MA_ERROR_NONE;
+}
+
+bool __get_assistant_enable_status(const char* app_id, char* assistants) {
+ char* temp = strtok(assistants, ";");
+ while(temp) {
+ if (!strncmp(app_id, temp, MAX_ASSISTANT_INFO_STR_LEN)) {
+ return true;
+ }
+ temp = strtok(NULL, ";");
+ }
+ return false;
+}
+
+int __get_assistant_info_cb(const char* app_id, const char* name,
+ const char* icon_path, const char* wakeup_list[], int cnt_wakeup,
+ const char* supported_lang[], int cnt_lang, void* user_data) {
+ SLOG(LOG_DEBUG, TAG_MAC, "[Client DEBUG] get assistant info cb start");
+ if (NULL == app_id) {
+ SLOG(LOG_ERROR, TAG_MAC, "[ERROR]app_id NULL, returning");
+ return -1;
+ } else if (0 <= _assistant_info_index && MAX_ASSISTANT_NUM > _assistant_info_index ) {
+ strncpy(__assistant_info[_assistant_info_index].app_id, app_id, MAX_ASSISTANT_INFO_STR_LEN);
+ __assistant_info[_assistant_info_index].app_id[MAX_ASSISTANT_INFO_STR_LEN - 1] = '\0';
+ strncpy(__assistant_info[_assistant_info_index].name, name, MAX_ASSISTANT_INFO_STR_LEN);
+ __assistant_info[_assistant_info_index].name[MAX_ASSISTANT_INFO_STR_LEN - 1] = '\0';
+ __assistant_info[_assistant_info_index].cnt_lang = cnt_lang;
+ __assistant_info[_assistant_info_index].enabled = __get_assistant_enable_status(app_id, vconf_get_str(APPID_URL));;
+ _assistant_info_index++;
+ } else {
+ return -1;
+ }
+ SLOG(LOG_DEBUG, TAG_MAC, "[Client DEBUG] get assistant info cb end");
+ return 0;
+}
+
+int ma_assistant_info_foreach_assistants(ma_assistant_info_list_cb callback, void* user_data) {
+ int res;
+ SLOG(LOG_DEBUG, TAG_MAC, "[Client DEBUG] get assistant info start");
+ if (NULL != callback) {
+ _assistant_info_index = 0;
+ res = ma_config_mgr_get_assistant_info(__get_assistant_info_cb, user_data);
+ if (0 == res) {
+ for (int i = 0; i < _assistant_info_index; i++) {
+ callback(&__assistant_info[i], user_data);
+ }
+ } else {
+ res = MA_ERROR_NOT_SUPPORTED;
+ }
+ } else {
+ res = MA_ERROR_INVALID_PARAMETER;
+ }
+ SLOG(LOG_DEBUG, TAG_MAC, "[Client DEBUG] get assistant info end");
+ return res;
+}
+
+int ma_assistant_info_get_app_id(ma_assistant_info_h handle, char **app_id) {
+ if (NULL == handle)
+ return MA_ERROR_INVALID_PARAMETER;
+ assistant_info_t* info = (assistant_info_t*)handle;
+ if (NULL == info->app_id)
+ return MA_ERROR_NOT_SUPPORTED;
+ *app_id = (char*)info->app_id;
return MA_ERROR_NONE;
}
\ No newline at end of file
#include <multi_assistant_common.h>
-
/**
* @defgroup CAPI_UIX_MULTI_ASSISTANT_CLIENT_MODULE Multi assistant client
* @ingroup CAPI_UIX_MULTI_ASSISTANT_MODULE
*/
int ma_unset_wakeup_engine_command_cb(void);
+/**
+ * @brief Retreives the list of installed assistants.
+ * @since_tizen 5.5
+ *
+ * @param[in] callback A callback for getting the information of the installed assistants.
+ * @param[in] user_data The user data passed to the callback function
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MA_ERROR_NONE Successful
+ * @retval #MA_ERROR_NOT_SUPPORTED Not supported
+ * @retval #MA_ERROR_INVALID_STATE Invalid state
+ * @retval #MA_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see ma_voice_assistant_list_cb()
+ */
+int ma_assistant_info_foreach_assistants(ma_assistant_info_list_cb callback, void* user_data);
+
+/**
+ * @brief Retreives app id of the specific handle.
+ * @since_tizen 5.5
+ *
+ * @remarks You must not release @a app_id using free().
+ * @param[in] handle The handle to the assistant's information
+ * @param[in] app_id The application ID of the given assistant handle
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MA_ERROR_NONE Successful
+ * @retval #MA_ERROR_NOT_SUPPORTED Not supported
+ * @retval #MA_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int ma_assistant_info_get_app_id(ma_assistant_info_h handle, char **app_id);
#ifdef __cplusplus
}
#endif