return MA_ERROR_NONE;
}
+int ma_add_wake_word(const char* wake_word, const char *language) {
+ MA_SLOGD("[Manager] Add wake word");
+
+ if (0 != __ma_get_feature_enabled()) {
+ MA_SLOGD("@@@ [Manager] not supported");
+ return MA_ERROR_NOT_SUPPORTED;
+ }
+
+ if (NULL == wake_word || NULL == language) {
+ MA_SLOGE("[ERROR] Invalid parameter"); //LCOV_EXCL_LINE
+ return MA_ERROR_INVALID_PARAMETER;
+ }
+
+ ma_state_e state;
+ if (0 != ma_client_get_client_state(g_ma, &state)) {
+ MA_SLOGE("[ERROR] A handle is not available");
+ MA_SLOGD("@@@");
+ return MA_ERROR_INVALID_STATE;
+ }
+
+ if (state != MA_STATE_READY) {
+ MA_SLOGE("[ERROR] Invalid State: Current state is not 'READY', state(%d)", state);
+ MA_SLOGD("@@@");
+ return MA_ERROR_INVALID_STATE;
+ }
+
+ MA_SLOGI("[Client DEBUG] Add wake word : %s %s", wake_word, language);
+
+ /* Add wake word */
+ int pid = getpid();
+ int ret = ma_dbus_add_wake_word(pid, wake_word, language);
+ if (0 != ret) {
+ MA_SLOGW("[WARNING] Failed to add wake word");
+ } else {
+ MA_SLOGD("[DEBUG] Success to add");
+ }
+ return ret;
+}
+
+int ma_remove_wake_word(const char* wake_word, const char *language) {
+ MA_SLOGD("[Manager] Remove wake word");
+
+ if (0 != __ma_get_feature_enabled()) {
+ MA_SLOGD("@@@ [Manager] not supported");
+ return MA_ERROR_NOT_SUPPORTED;
+ }
+
+ if (NULL == wake_word || NULL == language) {
+ MA_SLOGE("[ERROR] Invalid parameter"); //LCOV_EXCL_LINE
+ return MA_ERROR_INVALID_PARAMETER;
+ }
+
+ ma_state_e state;
+ if (0 != ma_client_get_client_state(g_ma, &state)) {
+ MA_SLOGE("[ERROR] A handle is not available");
+ MA_SLOGD("@@@");
+ return MA_ERROR_INVALID_STATE;
+ }
+
+ if (state != MA_STATE_READY) {
+ MA_SLOGE("[ERROR] Invalid State: Current state is not 'READY', state(%d)", state);
+ MA_SLOGD("@@@");
+ return MA_ERROR_INVALID_STATE;
+ }
+
+ MA_SLOGI("[Client DEBUG] Remove wake word : %s %s", wake_word, language);
+
+ /* Remove wake word */
+ int pid = getpid();
+ int ret = ma_dbus_remove_wake_word(pid, wake_word, language);
+ if (0 != ret) {
+ MA_SLOGW("[WARNING] Failed to remove wake word");
+ } else {
+ MA_SLOGD("[DEBUG] Success to remove");
+ }
+ return ret;
+}
+
//LCOV_EXCL_STOP
return 0;
}
+
+int ma_dbus_add_wake_word(int pid, const char* wake_word, const char* language)
+{
+ if (0 != __dbus_check()) {
+ return MA_ERROR_OPERATION_FAILED;
+ }
+
+ DBusMessage* msg;
+
+ msg = dbus_message_new_method_call(
+ MA_SERVER_SERVICE_NAME,
+ MA_SERVER_SERVICE_OBJECT_PATH,
+ MA_SERVER_SERVICE_INTERFACE,
+ MA_METHOD_ADD_WAKE_WORD);
+
+ if (NULL == msg) {
+ MA_SLOGE("@@ Request multi-assistant add wake word : Fail to make message"); //LCOV_EXCL_LINE
+ return MA_ERROR_OPERATION_FAILED;
+ } else {
+ MA_SLOGD("[DEBUG] multi-assistant add wake word");
+ }
+
+ char* tmp_wake_word = NULL;
+ if (NULL != wake_word) {
+ tmp_wake_word = strdup(wake_word);
+ } else {
+ tmp_wake_word = strdup("#NULL");
+ }
+
+ char* tmp_language = NULL;
+ if (NULL != language) {
+ tmp_language = strdup(language);
+ } else {
+ tmp_language = strdup("#NULL");
+ }
+
+ dbus_message_append_args(msg,
+ DBUS_TYPE_INT32, &pid,
+ DBUS_TYPE_STRING, &tmp_wake_word,
+ DBUS_TYPE_STRING, &tmp_language,
+ DBUS_TYPE_INVALID);
+
+ dbus_message_set_no_reply(msg, TRUE);
+
+ DBusError error;
+ dbus_error_init (&error);
+ if (!dbus_connection_send(g_conn_sender, msg, NULL)) {
+ if (dbus_error_is_set (&error)) {
+ MA_SLOGE("[Dbus ERROR] Fail to Send : %s", error.message); //LCOV_EXCL_LINE
+ dbus_error_free (&error);
+ } else {
+ MA_SLOGE("[Dbus ERROR] Fail to Send"); //LCOV_EXCL_LINE
+ }
+ if (NULL != tmp_wake_word) {
+ free(tmp_wake_word);
+ tmp_wake_word = NULL;
+ }
+ if (NULL != tmp_language) {
+ free(tmp_language);
+ tmp_language = NULL;
+ }
+ return MA_ERROR_OPERATION_FAILED;
+ } else {
+ MA_SLOGD("[Dbus DEBUG] Success to Send");
+ dbus_connection_flush(g_conn_sender);
+ }
+
+ if (NULL != tmp_wake_word) {
+ free(tmp_wake_word);
+ tmp_wake_word = NULL;
+ }
+ if (NULL != tmp_language) {
+ free(tmp_language);
+ tmp_language = NULL;
+ }
+
+ dbus_message_unref(msg);
+
+ return 0;
+}
+
+int ma_dbus_remove_wake_word(int pid, const char* wake_word, const char* language)
+{
+ if (0 != __dbus_check()) {
+ return MA_ERROR_OPERATION_FAILED;
+ }
+
+ DBusMessage* msg;
+
+ msg = dbus_message_new_method_call(
+ MA_SERVER_SERVICE_NAME,
+ MA_SERVER_SERVICE_OBJECT_PATH,
+ MA_SERVER_SERVICE_INTERFACE,
+ MA_METHOD_REMOVE_WAKE_WORD);
+
+ if (NULL == msg) {
+ MA_SLOGE("@@ Request multi-assistant remove wake word : Fail to make message"); //LCOV_EXCL_LINE
+ return MA_ERROR_OPERATION_FAILED;
+ } else {
+ MA_SLOGD("[DEBUG] multi-assistant remove wake word");
+ }
+
+ char* tmp_wake_word = NULL;
+ if (NULL != wake_word) {
+ tmp_wake_word = strdup(wake_word);
+ } else {
+ tmp_wake_word = strdup("#NULL");
+ }
+
+ char* tmp_language = NULL;
+ if (NULL != language) {
+ tmp_language = strdup(language);
+ } else {
+ tmp_language = strdup("#NULL");
+ }
+
+ dbus_message_append_args(msg,
+ DBUS_TYPE_INT32, &pid,
+ DBUS_TYPE_STRING, &tmp_wake_word,
+ DBUS_TYPE_STRING, &tmp_language,
+ DBUS_TYPE_INVALID);
+
+ dbus_message_set_no_reply(msg, TRUE);
+
+ DBusError error;
+ dbus_error_init (&error);
+ if (!dbus_connection_send(g_conn_sender, msg, NULL)) {
+ if (dbus_error_is_set (&error)) {
+ MA_SLOGE("[Dbus ERROR] Fail to Send : %s", error.message); //LCOV_EXCL_LINE
+ dbus_error_free (&error);
+ } else {
+ MA_SLOGE("[Dbus ERROR] Fail to Send"); //LCOV_EXCL_LINE
+ }
+ if (NULL != tmp_wake_word) {
+ free(tmp_wake_word);
+ tmp_wake_word = NULL;
+ }
+ if (NULL != tmp_language) {
+ free(tmp_language);
+ tmp_language = NULL;
+ }
+ return MA_ERROR_OPERATION_FAILED;
+ } else {
+ MA_SLOGD("[Dbus DEBUG] Success to Send");
+ dbus_connection_flush(g_conn_sender);
+ }
+
+ if (NULL != tmp_wake_word) {
+ free(tmp_wake_word);
+ tmp_wake_word = NULL;
+ }
+ if (NULL != tmp_language) {
+ free(tmp_language);
+ tmp_language = NULL;
+ }
+
+ dbus_message_unref(msg);
+
+ return 0;
+}
\ No newline at end of file
int ma_dbus_set_assistant_wakeup_language(int pid, const char* language);
+int ma_dbus_add_wake_word(int pid, const char* wake_word, const char* language);
+
+int ma_dbus_remove_wake_word(int pid, const char* wake_word, const char* language);
+
#ifdef __cplusplus
}
#endif
#define MA_METHOD_SEND_PREPROCESSING_RESULT "ma_method_send_preprocessing_result"
#define MA_METHOD_SET_WAKE_WORD_AUDIO_REQUIRE_FLAG "ma_method_set_wake_word_audio_require_flag"
#define MA_METHOD_SET_ASSISTANT_WAKEUP_LANGUAGE "ma_method_set_assistant_wakeup_language"
+#define MA_METHOD_ADD_WAKE_WORD "ma_method_add_wake_word"
+#define MA_METHOD_REMOVE_WAKE_WORD "ma_method_remove_wake_word"
#define MA_METHOD_ERROR "ma_method_error"
#define MA_UI_METHOD_INITIALIZE "ma_ui_method_initialize"
*/
int ma_unset_voice_key_status_changed_cb(void);
+/**
+ * @brief Adds a wake word used for activating assistant.
+ * @details Different <word, language> pairs identify a different word.
+ * For example, <"Hi Tizen", "en_US"> and <"Hi Tizen", "en_GB">
+ * are different words. If <"Hi Tizen", "en_US"> is added, then
+ * "Hi Tizen" will not wake the Tizen voice assistant if the
+ * wakeup language is set to "en_GB". <"Hi Tizen", "en_GB"> will
+ * have to be added for that.\n
+ * Adding the same word twice does not cause any error to be returned.
+ * @since_tizen 6.0
+ *
+ * @param[in] wake_word The wake word to be added to the list of wake words
+ * @param[in] language The language code for which the word will be added.
+ * The language is identified by its code (e.g. "en_US").
+ *
+ * @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
+ * @retval #MA_ERROR_INVALID_STATE Invalid state
+ * @retval #MA_ERROR_OPERATION_FAILED Operation failed
+ *
+ * @pre The state should be #MA_STATE_READY.
+ */
+int ma_add_wake_word(const char* wake_word, const char *language);
+
+/**
+ * @brief Removes a wake word used for activating assistant.
+ * @details Different <word, language> pairs identify a different word.
+ * For example, <"Hi Tizen", "en_US"> and <"Hi Tizen", "en_GB">
+ * are different words.\n
+ * Removing a word not present on the list does not cause any error
+ * to be returned.
+ * @since_tizen 6.0
+ *
+ * @param[in] wake_word The wake word to be removed from the list of wake words
+ * @param[in] language The language code for which the word will be removed.
+ * The language is identified by its code (e.g. "en_US").
+ *
+ * @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
+ * @retval #MA_ERROR_INVALID_STATE Invalid state
+ * @retval #MA_ERROR_OPERATION_FAILED Operation failed
+ *
+ * @pre The state should be #MA_STATE_READY.
+ */
+int ma_remove_wake_word(const char* wake_word, const char *language);
+
#ifdef __cplusplus
}
#endif