Merge commit 'ed22efa' into tizen
[platform/core/uifw/multi-assistant-service.git] / inc / service_ipc_dbus.h
1 /*
2  * Copyright 2020 Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.1 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://floralicense.org/license/
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __SERVICE_IPC_DBUS_H__
18 #define __SERVICE_IPC_DBUS_H__
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 #include <dbus/dbus.h>
25 #include <Ecore.h>
26
27 #include "service_ipc_dbus_dispatcher.h"
28
29 class CServiceMain;
30
31 class CServiceIpcDbus {
32 public:
33         CServiceIpcDbus() {}
34         virtual ~CServiceIpcDbus() {}
35
36         int open_connection();
37         int close_connection();
38         int send_hello(int pid);
39         int send_error_message(int reason, const char* err_msg);
40         int send_streaming_audio_data(int pid, int event, void* data, unsigned int data_size);
41         int change_active_state(int pid, int state);
42         int send_preprocessing_information(int pid, const char* app_id);
43         int send_streaming_section_changed(int pid, int section);
44         int send_preprocessing_result(int pid, bool result);
45         int send_wakeup_engine_command(int pid, const char* command);
46         int change_service_state(int pid, int state);
47         int change_voice_key_status(int pid, int status);
48         int masc_ui_dbus_send_hello(void);
49         int masc_ui_dbus_send_asr_result(int pid, int event, const char* asr_result);
50         int masc_ui_dbus_send_result(int pid, const char* display_text, const char* utterance_text, const char* result_json);
51         int masc_ui_dbus_change_assistant(const char* app_id);
52         int masc_ui_dbus_send_error_message(int reason, const char* err_msg);
53         int masc_ui_dbus_send_recognition_result(int pid, int result);
54         int masc_ui_dbus_enable_common_ui(int enable);
55
56         DBusConnection* get_connection_listener() { return mConnectionListener; }
57         CServiceIpcDbusDispatcher* get_dispatcher() { return &mDispatcher; }
58
59         void set_client_manager(CClientManager* manager) {
60                 mClientManager = manager;
61         }
62         void set_service_ipc_observer(IServiceIpcObserver* observer) {
63                 mDispatcher.set_ipc_observer(observer);
64         }
65 private:
66         int __dbus_check();
67         void connection_free();
68         int reconnect();
69         int mas_check_dbus_connection();
70
71 private:
72         CServiceIpcDbusDispatcher mDispatcher;
73
74         DBusConnection* mConnectionSender{NULL};
75         DBusConnection* mConnectionListener{NULL};
76
77         Ecore_Fd_Handler* mFdHandler{NULL};
78
79         int mStreamingDataSerial{0};
80
81         CClientManager* mClientManager{nullptr};
82 };
83
84 #ifdef __cplusplus
85 }
86 #endif
87
88 #endif  /* __SERVICE_IPC_DBUS_H__ */