INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/inc)
SET(SRCS
- src/multi_assistant_config.c
- src/multi_assistant_service.c
- src/multi_assistant_service_plugin.c
- src/multi_assistant_dbus.c
- src/multi_assistant_dbus_server.c
+ src/main.cpp
+ src/multi_assistant_config.cpp
+ src/multi_assistant_service.cpp
+ src/multi_assistant_service_plugin.cpp
+ src/multi_assistant_dbus.cpp
+ src/multi_assistant_dbus_server.cpp
)
ADD_EXECUTABLE(${BINNAME} ${SRCS})
} ma_assistant_info_s;
typedef int (*mas_config_assistant_info_cb)(ma_assistant_info_s* info, void* user_data);
+
int mas_config_get_assistant_info(mas_config_assistant_info_cb callback, void* user_data);
int mas_config_load_custom_wake_words(const char* app_id,
char wakeup_word[MAX_WAKEUP_WORDS_NUM][MAX_WAKEUP_WORD_LEN],
/**************************************************************************************
*** Definitions for DBus
*************************************************************************************/
-#define MA_CLIENT_SERVICE_NAME "org.tizen.multiassistant.maclient"
-#define MA_CLIENT_SERVICE_OBJECT_PATH "/org/tizen/multiassistant/maclient"
-#define MA_CLIENT_SERVICE_INTERFACE "org.tizen.multiassistant.maclient"
+#define MA_CLIENT_SERVICE_NAME "org.tizen.multiassistant.maclient"
+#define MA_CLIENT_SERVICE_OBJECT_PATH "/org/tizen/multiassistant/maclient"
+#define MA_CLIENT_SERVICE_INTERFACE "org.tizen.multiassistant.maclient"
-#define MA_UI_CLIENT_SERVICE_NAME "org.tizen.multiassistant.mauiclient"
-#define MA_UI_CLIENT_SERVICE_OBJECT_PATH"/org/tizen/multiassistant/mauiclient"
-#define MA_UI_CLIENT_SERVICE_INTERFACE "org.tizen.multiassistant.mauiclient"
+#define MA_UI_CLIENT_SERVICE_NAME "org.tizen.multiassistant.mauiclient"
+#define MA_UI_CLIENT_SERVICE_OBJECT_PATH "/org/tizen/multiassistant/mauiclient"
+#define MA_UI_CLIENT_SERVICE_INTERFACE "org.tizen.multiassistant.mauiclient"
-#define MA_SERVER_SERVICE_NAME "org.tizen.multiassistant.maserver"
-#define MA_SERVER_SERVICE_OBJECT_PATH "/org/tizen/multiassistant/maserver"
-#define MA_SERVER_SERVICE_INTERFACE "org.tizen.multiassistant.maserver"
+#define MA_SERVER_SERVICE_NAME "org.tizen.multiassistant.maserver"
+#define MA_SERVER_SERVICE_OBJECT_PATH "/org/tizen/multiassistant/maserver"
+#define MA_SERVER_SERVICE_INTERFACE "org.tizen.multiassistant.maserver"
/**************************************************************************************
*** Definitions for DBus methods
#define _MULTI_ASSISTANT_SERVICE_H_
#include <dlog/dlog.h>
-
+#include <multi_assistant.h>
+#include <multi_assistant_internal.h>
#ifdef __cplusplus
extern "C" {
int mas_client_get_audio_source_type(int pid, char** type);
+int mas_client_send_preprocessing_information(int pid);
+
+int mas_client_activate(int pid);
+
+int mas_client_deactivate(int pid);
+
int mas_client_request_speech_data(int pid);
int mas_client_send_asr_result(int pid, int event, char* asr_result);
int mas_client_set_background_volume(int pid, double ratio);
-int mas_client_set_preprocessing_allow_mode(int pid, int mode, const char* appid);
+int mas_client_set_preprocessing_allow_mode(int pid, ma_preprocessing_allow_mode_e mode, const char* appid);
int mas_client_send_preprocessing_result(int pid, bool result);
int mas_set_current_service_state(ma_service_state_e state);
+int mas_bring_client_to_foreground(const char* appid);
+
ma_service_state_e mas_get_current_service_state();
int mas_launch_client_by_appid(const char *appid, CLIENT_LAUNCH_MODE launch_mode);
int mas_update_voice_key_support_mode();
+bool app_create(void *data);
+
+void app_terminate(void *data);
#ifdef __cplusplus
}
#ifndef _MULTI_ASSISTANT_SERVICE_PLUGIN_H_
#define _MULTI_ASSISTANT_SERVICE_PLUGIN_H_
+#include <tzplatform_config.h>
#include <dlog/dlog.h>
#include <multi_assistant_service.h>
int multi_assistant_service_plugin_set_speech_status_callback(wakeup_service_speech_status_cb callback, void* user_data);
+int multi_assistant_service_plugin_set_setting_changed_callback(wakeup_service_setting_changed_cb callback, void* user_data);
+
int multi_assistant_service_plugin_set_error_callback(wakeup_service_error_cb callback, void* user_data);
+int multi_assistant_service_plugin_set_streaming_section_changed_callback(wakeup_service_streaming_section_changed_cb callback, void* user_data);
+
+int multi_assistant_service_plugin_set_wakeup_engine_command_callback(wakeup_service_wakeup_engine_command_cb callback, void* user_data);
+
+int multi_assistant_service_plugin_set_wakeup_service_state_changed_callback(wakeup_service_wakeup_service_state_changed_cb callback, void* user_data);
+
+int multi_assistant_service_plugin_set_voice_key_status_changed_callback(wakeup_service_voice_key_status_changed_cb callback, void* user_data);
+
#define MA_WAKEUP_MANAGER_PATH tzplatform_mkpath(tzplatform_getid("TZ_SYS_RO_SHARE"), "multiassistant/")
BuildRequires: pkgconfig(multi-assistant)
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(pkgmgr-info)
-
BuildRequires: boost-system
BuildRequires: boost-thread
BuildRequires: cmake
export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
%endif
-export CFLAGS+=" -Wno-format-truncation -Wno-format-overflow"
-export CXXFLAGS+=" -Wno-format-truncation -Wno-format-overflow"
+export CFLAGS+=" -Wno-format-truncation -Wno-stringop-truncation -Wno-format-overflow"
+export CXXFLAGS+=" -Wno-format-truncation -Wno-stringop-truncation -Wno-format-overflow"
export LDFLAGS
%cmake \
--- /dev/null
+/*
+ * Copyright 2018-2019 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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.
+ */
+
+#include <tizen.h>
+#include <service_app.h>
+
+#include "multi_assistant_service_client.h"
+
+static bool service_app_create(void *data)
+{
+ return app_create(data);
+}
+
+static void service_app_terminate(void *data)
+{
+
+ return app_terminate(data);
+}
+
+static void service_app_control(app_control_h app_control, void *data)
+{
+ // Todo: add your code here.
+ return;
+}
+
+static void service_app_lang_changed(app_event_info_h event_info, void *user_data)
+{
+ /*APP_EVENT_LANGUAGE_CHANGED*/
+ return;
+}
+
+static void service_app_region_changed(app_event_info_h event_info, void *user_data)
+{
+ /*APP_EVENT_REGION_FORMAT_CHANGED*/
+}
+
+static void service_app_low_battery(app_event_info_h event_info, void *user_data)
+{
+ /*APP_EVENT_LOW_BATTERY*/
+}
+
+static void service_app_low_memory(app_event_info_h event_info, void *user_data)
+{
+ /*APP_EVENT_LOW_MEMORY*/
+}
+
+int main(int argc, char* argv[])
+{
+ char ad[50] = {0,};
+ service_app_lifecycle_callback_s event_callback;
+ app_event_handler_h handlers[5] = {NULL, };
+
+ event_callback.create = service_app_create;
+ event_callback.terminate = service_app_terminate;
+ event_callback.app_control = service_app_control;
+
+ service_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, service_app_low_battery, &ad);
+ service_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, service_app_low_memory, &ad);
+ service_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, service_app_lang_changed, &ad);
+ service_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, service_app_region_changed, &ad);
+
+ int ret = service_app_main(argc, argv, &event_callback, ad);
+ LOGI("Main function exits with : %d", ret);
+ return ret;
+}
#include <libxml/parser.h>
#include <sys/types.h>
#include <dirent.h>
+#include <unistd.h>
+
+#include <app_preference.h>
#include "multi_assistant_config.h"
#include "multi_assistant_main.h"
} else if (cur->name && 0 == xmlStrcmp(cur->name, (const xmlChar*)MA_TAG_ASSISTANT_CUSTOM_UI)) {
key = xmlNodeGetContent(cur);
if (key) {
- if (0 == xmlStrcasecmp(key, "true")) {
+ if (0 == xmlStrcasecmp(key, reinterpret_cast<const xmlChar*>("true"))) {
temp.custom_ui_option = true;
}
MAS_LOGD("Use custom UI : %d", temp.custom_ui_option);
preference_set_string("custom_wakeup_words", wakeup_words);
preference_set_string("custom_wakeup_languages", wakeup_languages);
return 0;
-}
+}
\ No newline at end of file
#include <message_port.h>
#include "multi_assistant_main.h"
+#include "multi_assistant_service_client.h"
#include "multi_assistant_dbus_server.h"
#include "multi_assistant_dbus.h"
"MESSAGE_PORT_ERROR_UNKNOWN");
}
-int masc_dbus_send_streaming_audio_data(int pid, int event, unsigned char* data, unsigned int data_size)
+int masc_dbus_send_streaming_audio_data(int pid, int event, void* data, unsigned int data_size)
{
static unsigned char pending_buffer[STREAMING_BUFFER_SIZE];
static unsigned int pending_buffer_size = 0;
MA_CLIENT_SERVICE_INTERFACE,
MAS_METHOD_ACTIVE_STATE_CHANGE);
- static int count = 0;
if (NULL == msg) {
MAS_LOGE(">>>> Request mas send activate message : Fail to make message");
return -1; // MAS_ERROR_OPERATION_FAILED;
MA_CLIENT_SERVICE_INTERFACE,
MAS_METHOD_SEND_PREPROCESSING_INFORMATION);
- static int count = 0;
if (NULL == msg) {
MAS_LOGE(">>>> Request mas send preprocessing assistant information : Fail to make message");
return -1; // MAS_ERROR_OPERATION_FAILED;
int masc_dbus_send_streaming_section_changed(int pid, int section)
{
- static int serial = 0;
bundle *b = bundle_create();
streaming_data_header header;
MA_CLIENT_SERVICE_INTERFACE,
MAS_METHOD_SEND_PREPROCESSING_RESULT);
- static int count = 0;
if (NULL == msg) {
MAS_LOGE(">>>> Request mas send preprocessing result : Fail to make message");
return -1; // MAS_ERROR_OPERATION_FAILED;
MA_CLIENT_SERVICE_INTERFACE,
MAS_METHOD_SEND_WAKEUP_ENGINE_COMMAND);
- static int count = 0;
if (NULL == msg) {
MAS_LOGE(">>>> Request mas send wakeup engine command : Fail to make message");
return -1; // MAS_ERROR_OPERATION_FAILED;
MA_CLIENT_SERVICE_INTERFACE,
MAS_METHOD_SERVICE_STATE_CHANGE);
- static int count = 0;
if (NULL == msg) {
MAS_LOGE(">>>> Request mas send service state message : Fail to make message");
return -1; // MAS_ERROR_OPERATION_FAILED;
MA_CLIENT_SERVICE_INTERFACE,
MAS_METHOD_VOICE_KEY_STATUS_CHANGE);
- static int count = 0;
if (NULL == msg) {
MAS_LOGE(">>>> Request mas send voice key status change message : Fail to make message");
return -1; // MAS_ERROR_OPERATION_FAILED;
return 0;
}
-int masc_ui_dbus_change_assistant(char* app_id)
+int masc_ui_dbus_change_assistant(const char* app_id)
{
if (0 != __dbus_check()) {
return -1; //MAS_ERROR_OPERATION_FAILED;
__mas_dbus_connection_free();
return 0;
-}
+}
\ No newline at end of file
int masc_dbus_send_error_message(int reason, const char* err_msg);
-int masc_dbus_send_streaming_audio_data(int pid, int event, unsigned char* data, unsigned int data_size);
+int masc_dbus_send_streaming_audio_data(int pid, int event, void* data, unsigned int data_size);
int masc_dbus_active_state_change(int pid, int state);
int masc_ui_dbus_send_result(int pid, const char* display_text, const char* utterance_text, const char* result_json);
-int masc_ui_dbus_change_assistant(char* app_id);
+int masc_ui_dbus_change_assistant(const char* app_id);
int masc_ui_dbus_send_error_message(int reason, const char* err_msg);
* limitations under the License.
*/
+#include <stdlib.h>
+
#include "multi_assistant_main.h"
#include "multi_assistant_dbus.h"
#include "multi_assistant_dbus_server.h"
MAS_LOGE("[OUT ERROR] mas initialize : Fail to create reply message!!");
}
- return 0;
+ return ret;
}
int ma_service_dbus_deinitialize(DBusConnection* conn, DBusMessage* msg)
MAS_LOGE("[OUT ERROR] tts default voice : Fail to create reply message!!");
}
- return 0;
+ return ret;
}
int ma_service_dbus_get_audio_source_type(DBusConnection* conn, DBusMessage* msg)
if (temp_type)
free(temp_type);
- return 0;
+ return ret;
}
int ma_service_dbus_send_asr_result(DBusConnection* conn, DBusMessage* msg)
MAS_LOGD("<<<<<");
MAS_LOGD(" ");
- return 0;
+ return ret;
}
int ma_service_dbus_send_result(DBusConnection* conn, DBusMessage* msg)
MAS_LOGD("<<<<<");
MAS_LOGD(" ");
- return 0;
+ return ret;
}
int ma_service_dbus_send_recognition_result(DBusConnection* conn, DBusMessage* msg)
MAS_LOGD("<<<<<");
MAS_LOGD(" ");
- return 0;
+ return ret;
}
int ma_service_dbus_start_streaming_audio_data(DBusConnection* conn, DBusMessage* msg)
MAS_LOGD("<<<<<");
MAS_LOGD(" ");
- return 0;
+ return ret;
}
int ma_service_dbus_stop_streaming_audio_data(DBusConnection* conn, DBusMessage* msg)
MAS_LOGD("<<<<<");
MAS_LOGD(" ");
- return 0;
+ return ret;
}
int ma_service_dbus_update_voice_feedback_state(DBusConnection* conn, DBusMessage* msg)
MAS_LOGD("<<<<<");
MAS_LOGD(" ");
- return 0;
+ return ret;
}
int ma_service_dbus_send_assistant_specific_command(DBusConnection* conn, DBusMessage* msg)
MAS_LOGD("<<<<<");
MAS_LOGD(" ");
- return 0;
+ return ret;
}
int ma_service_dbus_set_background_volume(DBusConnection* conn, DBusMessage* msg)
MAS_LOGD("<<<<<");
MAS_LOGD(" ");
- return 0;
+ return ret;
}
int ma_service_dbus_set_preprocessing_allow_mode(DBusConnection* conn, DBusMessage* msg)
temp_app_id = strdup(app_id);
}
MAS_LOGI("[IN] mas set preprocessing allow mode : pid(%d), mode(%d), app_id(%s)", pid, mode, temp_app_id);
- ret = mas_client_set_preprocessing_allow_mode(pid, mode, temp_app_id);
+ ret = mas_client_set_preprocessing_allow_mode(pid,
+ static_cast<ma_preprocessing_allow_mode_e>(mode), temp_app_id);
if (NULL != temp_app_id)
free(temp_app_id);
}
MAS_LOGD("<<<<<");
MAS_LOGD(" ");
- return 0;
+ return ret;
}
int ma_service_dbus_send_preprocessing_result(DBusConnection* conn, DBusMessage* msg)
MAS_LOGD("<<<<<");
MAS_LOGD(" ");
- return 0;
+ return ret;
}
int ma_service_dbus_set_wake_word_audio_require_flag(DBusConnection* conn, DBusMessage* msg)
MAS_LOGD("<<<<<");
MAS_LOGD(" ");
- return 0;
+ return ret;
}
int ma_service_dbus_set_assistant_language(DBusConnection* conn, DBusMessage* msg)
MAS_LOGD("<<<<<");
MAS_LOGD(" ");
- return 0;
+ return ret;
}
int ma_service_dbus_add_wake_word(DBusConnection* conn, DBusMessage* msg)
MAS_LOGD("<<<<<");
MAS_LOGD(" ");
- return 0;
+ return ret;
}
int ma_service_dbus_remove_wake_word(DBusConnection* conn, DBusMessage* msg)
MAS_LOGD("<<<<<");
MAS_LOGD(" ");
- return 0;
+ return ret;
}
int ma_service_ui_dbus_initialize(DBusConnection* conn, DBusMessage* msg)
MAS_LOGE("[OUT ERROR] mas ui initialize : Fail to create reply message!!");
}
- return 0;
+ return ret;
}
int ma_service_ui_dbus_deinitialize(DBusConnection* conn, DBusMessage* msg)
MAS_LOGE("[OUT ERROR] mas ui deinitialize : Fail to create reply message!!");
}
- return 0;
+ return ret;
}
int ma_service_ui_dbus_change_assistant(DBusConnection* conn, DBusMessage* msg)
MAS_LOGD("<<<<<");
MAS_LOGD(" ");
- return 0;
-}
+ return ret;
+}
\ No newline at end of file
#include <app_manager.h>
#include <app.h>
#include <aul.h>
+#include <aul_svc.h>
#include <malloc.h>
#include <Ecore.h>
#include <vconf.h>
int i;
for (i = 0; i < count; i++) {
- data = g_slist_nth_data(g_client_list, i);
+ data = static_cast<ma_client_s*>(g_slist_nth_data(g_client_list, i));
if (NULL != data) {
if (0 == strncmp(data->appid, appid, MAX_APPID_LEN)) {
int i;
for (i = 0; i < count; i++) {
- data = g_slist_nth_data(g_client_list, i);
+ data = static_cast<ma_client_s*>(g_slist_nth_data(g_client_list, i));
if (NULL != data) {
if (data->pid == pid) {
return 0;
}
-int mas_client_set_preprocessing_allow_mode(int pid, int mode, const char* appid)
+int mas_client_set_preprocessing_allow_mode(int pid, ma_preprocessing_allow_mode_e mode, const char* appid)
{
const char* pid_appid = NULL;
char buf[MAX_APPID_LEN] = {'\0',};
}
int status = aul_app_get_status_bypid(pid);
- if (-1 != ret && 0 > status) {
+ if (NULL != ret && 0 > status) {
MAS_LOGE("The appid for %d was %s, but it seems to be terminated : %d",
pid, (ret ? ret : "NULL"), status);
mas_client_deinitialize(pid);
int i;
for (i = 0; i < count; i++) {
- data = g_slist_nth_data(g_client_list, i);
+ data = static_cast<ma_client_s*>(g_slist_nth_data(g_client_list, i));
if (NULL != data && -1 != data->pid) {
int ret = masc_dbus_service_state_change(data->pid, state);
return;
}
-bool service_app_create(void *data)
+bool app_create(void *data)
{
// Todo: add your code here.
return true;
}
-void service_app_terminate(void *data)
+void app_terminate(void *data)
{
MAS_LOGI("[ENTER]");
if (g_pkgmgr) {
return;
}
-void service_app_control(app_control_h app_control, void *data)
-{
- // Todo: add your code here.
- return;
-}
-
-static void
-service_app_lang_changed(app_event_info_h event_info, void *user_data)
-{
- /*APP_EVENT_LANGUAGE_CHANGED*/
- return;
-}
-
-static void
-service_app_region_changed(app_event_info_h event_info, void *user_data)
-{
- /*APP_EVENT_REGION_FORMAT_CHANGED*/
-}
-
-static void
-service_app_low_battery(app_event_info_h event_info, void *user_data)
-{
- /*APP_EVENT_LOW_BATTERY*/
-}
-
-static void
-service_app_low_memory(app_event_info_h event_info, void *user_data)
-{
- /*APP_EVENT_LOW_MEMORY*/
-}
-
-int main(int argc, char* argv[])
-{
- char ad[50] = {0,};
- service_app_lifecycle_callback_s event_callback;
- app_event_handler_h handlers[5] = {NULL, };
-
- event_callback.create = service_app_create;
- event_callback.terminate = service_app_terminate;
- event_callback.app_control = service_app_control;
-
- service_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, service_app_low_battery, &ad);
- service_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, service_app_low_memory, &ad);
- service_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, service_app_lang_changed, &ad);
- service_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, service_app_region_changed, &ad);
-
- int ret = service_app_main(argc, argv, &event_callback, ad);
- LOGI("Main function exits with : %d", ret);
- return ret;
-}
}
#endif /* -TEST_CODE */
-Eina_Bool process_wakeup_event_by_appid_timer(char* appid)
+Eina_Bool process_wakeup_event_by_appid_timer(void* data)
{
+ char* appid = static_cast<char*>(data);
MAS_LOGD("[ENTER] appid(%s)", appid);
int pid = -1;
return ECORE_CALLBACK_CANCEL;
}
-Eina_Bool process_wakeup_event_by_word_timer(char* wakeup_word)
+Eina_Bool process_wakeup_event_by_word_timer(void* data)
{
+ char* wakeup_word = static_cast<char*>(data);
MAS_LOGD("[ENTER]");
if (!wakeup_word) return EINA_FALSE;
const char* appid = mas_get_client_appid_by_wakeup_word(wakeup_word);
- process_wakeup_event_by_appid_timer(strdup(appid));
+ process_wakeup_event_by_appid_timer(static_cast<void*>(strdup(appid)));
if (wakeup_word) free(wakeup_word);
return ECORE_CALLBACK_CANCEL;
}
-static void __wakeup_event_cb(mas_wakeup_event_info wakeup_info, void* user_data)
+static void __wakeup_event_cb(mas_wakeup_event_info wakeup_info, const char* wakeup_word, void* user_data)
{
MAS_LOGD("[SUCCESS] __wakeup_event_cb is called, wakeup_word(%s)", wakeup_info.wakeup_word);
int ret = -1;
#endif /* - TEST_CODE */
if (wakeup_info.wakeup_appid) {
ecore_thread_main_loop_begin();
- ecore_timer_add(0.0f, process_wakeup_event_by_appid_timer, (void*)strdup(wakeup_info.wakeup_appid));
+ ecore_timer_add(0.0f, process_wakeup_event_by_appid_timer,
+ static_cast<void*>(strdup(wakeup_info.wakeup_appid)));
ecore_thread_main_loop_end();
} else if (wakeup_info.wakeup_word) {
ecore_thread_main_loop_begin();
- ecore_timer_add(0.0f, process_wakeup_event_by_word_timer, (void*)strdup(wakeup_info.wakeup_word));
+ ecore_timer_add(0.0f, process_wakeup_event_by_word_timer,
+ static_cast<void*>(strdup(wakeup_info.wakeup_word)));
ecore_thread_main_loop_end();
}