2 * Copyright (c) 2011-2016 Samsung Electronics Co., Ltd All Rights Reserved
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 * http://www.apache.org/licenses/LICENSE-2.0
7 * Unless required by applicable law or agreed to in writing, software
8 * distributed under the License is distributed on an "AS IS" BASIS,
9 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 * See the License for the specific language governing permissions and
11 * limitations under the License.
15 #include "ttsd_main.h"
16 #include "ttsd_dbus.h"
17 #include "ttsd_dbus_server.h"
18 #include "ttsd_server.h"
20 extern int ttsd_data_get_pid(const unsigned int uid);
23 * Dbus Client-Daemon Server
25 int ttsd_dbus_server_hello(DBusConnection* conn, DBusMessage* msg)
27 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS Hello");
30 dbus_error_init(&err);
36 int registered_event_mask = 0;
37 dbus_message_get_args(msg, &err,
38 DBUS_TYPE_INT32, &pid,
39 DBUS_TYPE_UINT32, &uid,
40 DBUS_TYPE_INT32, &mode,
41 DBUS_TYPE_INT32, &playing_mode,
42 DBUS_TYPE_INT32, ®istered_event_mask,
45 if (dbus_error_is_set(&err)) {
46 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] ttsd Hello : get arguments error (%s)", err.message);
47 dbus_error_free(&err);
49 SLOG(LOG_INFO, tts_tag(), "[IN] ttsd hello : pid(%d), uid(%u), mode(%d), playing_mode(%d)", pid, uid, mode, playing_mode);
50 bool is_initialized = false;
51 bool is_credential_needed = false;
52 ttsd_state_e service_state = TTSD_STATE_INVALID;
53 int credential_needed = 0;
56 ttsd_server_is_already_initialized(pid, uid, &is_initialized);
57 if (false == is_initialized) {
58 ret = ttsd_server_initialize(pid, uid, (ttsd_mode_e)mode, (ttsd_playing_mode_e)playing_mode, registered_event_mask, TTS_IPC_METHOD_DBUS, &service_state, &is_credential_needed);
60 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] ttsd Hello : server initialize, ret(%d)", ret);
62 ttsd_server_update_instant_reprepare_client();
64 credential_needed = is_credential_needed ? 1 : 0;
66 SLOG(LOG_INFO, tts_tag(), "[IN] ttsd hello : already initialized. pid(%d), uid(%u)", pid, uid);
67 ret = TTS_ERROR_ALREADY_INITIALIZED;
68 credential_needed = TTS_CREDENTIAL_NEEDED_ALREADY_INITIALIZED;
71 SLOG(LOG_INFO, tts_tag(), "[INFO] send_hello. pid(%d), uid(%u), ret(%d), service_state(%d), credential_needed(%d)",
72 pid, uid, ret, (int)service_state, credential_needed);
74 ttsdc_dbus_send_hello(pid, uid, ret, (int)service_state, credential_needed);
80 int ttsd_dbus_server_hello_sync(DBusConnection* conn, DBusMessage* msg)
82 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS Hello");
85 reply = dbus_message_new_method_return(msg);
88 if (!dbus_connection_send(conn, reply, NULL)) {
89 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] Out Of Memory!");
92 dbus_connection_flush(conn);
93 dbus_message_unref(reply);
95 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] Fail to create reply message!!");
101 int ttsd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg)
104 dbus_error_init(&err);
108 bool credential_needed = 0;
109 ttsd_state_e service_state = TTSD_STATE_INVALID;
111 int playing_mode = 0;
112 int registered_event_mask = 0;
115 dbus_message_get_args(msg, &err,
116 DBUS_TYPE_INT32, &pid,
117 DBUS_TYPE_UINT32, &uid,
118 DBUS_TYPE_INT32, &mode,
119 DBUS_TYPE_INT32, &playing_mode,
120 DBUS_TYPE_INT32, ®istered_event_mask,
123 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS INITIALIZE");
125 if (dbus_error_is_set(&err)) {
126 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts initialize : get arguments error (%s)", err.message);
127 dbus_error_free(&err);
128 ret = TTSD_ERROR_OPERATION_FAILED;
130 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts initialize : pid(%d), uid(%u), mode(%d), playing_mode(%d)", pid, uid, mode, playing_mode);
131 ret = ttsd_server_initialize(pid, uid, (ttsd_mode_e)mode, (ttsd_playing_mode_e)playing_mode, registered_event_mask, TTS_IPC_METHOD_DBUS, &service_state, &credential_needed);
132 ttsd_server_update_instant_reprepare_client();
136 reply = dbus_message_new_method_return(msg);
138 int tmp_credential_needed = (int)credential_needed;
139 int tmp_service_state = (int)service_state;
140 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts initialize : result(%d), service_state(%d), credential_needed(%d)", ret, tmp_service_state, tmp_credential_needed);
142 dbus_message_append_args(reply,
143 DBUS_TYPE_INT32, &ret,
144 DBUS_TYPE_INT32, &tmp_service_state,
145 DBUS_TYPE_INT32, &tmp_credential_needed,
149 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts initialize : result(%d), service_state(%d), credential_needed(%d)", ret, tmp_service_state, tmp_credential_needed);
151 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts initialize : result(%d)", ret);
154 if (!dbus_connection_send(conn, reply, NULL)) {
155 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts initialize : Out Of Memory!");
158 dbus_connection_flush(conn);
159 dbus_message_unref(reply);
161 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts initialize : Fail to create reply message!!");
167 int ttsd_dbus_server_finalize(DBusConnection* conn, DBusMessage* msg)
170 dbus_error_init(&err);
175 dbus_message_get_args(msg, &err, DBUS_TYPE_UINT32, &uid, DBUS_TYPE_INVALID);
177 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS FINALIZE");
179 if (dbus_error_is_set(&err)) {
180 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts finalize : get arguments error (%s)", err.message);
181 dbus_error_free(&err);
182 ret = TTSD_ERROR_OPERATION_FAILED;
184 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts finalize : uid(%u)", uid);
185 ret = ttsd_server_finalize(uid);
186 ttsd_server_update_instant_reprepare_client();
190 reply = dbus_message_new_method_return(msg);
193 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
196 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts finalize : result(%d)", ret);
198 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts finalize : result(%d)", ret);
201 if (!dbus_connection_send(conn, reply, NULL)) {
202 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts finalize : Out Of Memory!");
205 dbus_connection_flush(conn);
206 dbus_message_unref(reply);
208 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts finalize : Fail to create reply message!!");
214 int ttsd_dbus_server_get_support_voices(DBusConnection* conn, DBusMessage* msg)
217 dbus_error_init(&err);
221 GList* voice_list = NULL;
223 dbus_message_get_args(msg, &err, DBUS_TYPE_UINT32, &uid, DBUS_TYPE_INVALID);
225 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS GET VOICES");
227 if (dbus_error_is_set(&err)) {
228 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts get supported voices : get arguments error (%s)", err.message);
229 dbus_error_free(&err);
230 ret = TTSD_ERROR_OPERATION_FAILED;
232 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] get supported voices : uid(%u)", uid);
233 ret = ttsd_server_get_support_voices(uid, &voice_list);
237 reply = dbus_message_new_method_return(msg);
240 DBusMessageIter args;
241 dbus_message_iter_init_append(reply, &args);
244 dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(ret));
247 /* Append voice size */
248 unsigned int size = g_list_length(voice_list);
250 if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(size))) {
251 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts supported voices : Fail to append type");
252 ret = TTSD_ERROR_OPERATION_FAILED;
258 iter = g_list_first(voice_list);
260 while (NULL != iter) {
264 dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(voice->language));
265 dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(voice->type));
267 if (NULL != voice->language)
268 g_free(voice->language);
273 voice_list = g_list_remove_link(voice_list, iter);
275 iter = g_list_first(voice_list);
278 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts supported voices : result(%d)", ret);
280 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts supported voices : result(%d)", ret);
283 if (!dbus_connection_send(conn, reply, NULL)) {
284 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] error : Out Of Memory!");
287 dbus_connection_flush(conn);
288 dbus_message_unref(reply);
290 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts supported voices : Fail to create reply message!!");
296 int ttsd_dbus_server_get_current_voice(DBusConnection* conn, DBusMessage* msg)
299 dbus_error_init(&err);
306 dbus_message_get_args(msg, &err, DBUS_TYPE_UINT32, &uid, DBUS_TYPE_INVALID);
308 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS GET DEFAULT VOICE");
310 if (dbus_error_is_set(&err)) {
311 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts get default voice : Get arguments error (%s)", err.message);
312 dbus_error_free(&err);
313 ret = TTSD_ERROR_OPERATION_FAILED;
315 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts get default voice : uid(%u)", uid);
316 ret = ttsd_server_get_current_voice(uid, &lang, &voice_type);
320 reply = dbus_message_new_method_return(msg);
324 /* Append result and voice */
325 dbus_message_append_args(reply,
326 DBUS_TYPE_INT32, &ret,
327 DBUS_TYPE_STRING, &lang,
328 DBUS_TYPE_INT32, &voice_type,
330 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts default voice : lang(%s), vctype(%d)", lang, voice_type);
332 dbus_message_append_args(reply,
333 DBUS_TYPE_INT32, &ret,
335 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts default voice : result(%d)", ret);
338 if (!dbus_connection_send(conn, reply, NULL)) {
339 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts default voice : Out Of Memory!");
342 dbus_connection_flush(conn);
343 dbus_message_unref(reply);
345 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts default voice : Fail to create reply message!!");
348 if (NULL != lang) free(lang);
352 int ttsd_dbus_server_add_text(DBusConnection* conn, DBusMessage* msg)
355 dbus_error_init(&err);
357 unsigned int uid, voicetype, speed, uttid;
358 char *text, *lang, *credential;
361 dbus_message_get_args(msg, &err,
362 DBUS_TYPE_UINT32, &uid,
363 DBUS_TYPE_STRING, &text,
364 DBUS_TYPE_STRING, &lang,
365 DBUS_TYPE_INT32, &voicetype,
366 DBUS_TYPE_INT32, &speed,
367 DBUS_TYPE_INT32, &uttid,
368 DBUS_TYPE_STRING, &credential,
371 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS ADD TEXT");
373 if (dbus_error_is_set(&err)) {
374 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts add text : Get arguments error (%s)", err.message);
375 dbus_error_free(&err);
376 ret = TTSD_ERROR_OPERATION_FAILED;
378 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts add text : uid(%u), text(%s), lang(%s), type(%d), speed(%d), uttid(%d), credential(%s)",
379 uid, (NULL == text) ? "NULL" : text, (NULL == lang) ? "NULL" : lang, voicetype, speed, uttid, (NULL == credential) ? "NULL" : credential);
380 ret = ttsd_server_add_text(uid, text, lang, voicetype, speed, uttid, credential);
384 reply = dbus_message_new_method_return(msg);
387 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
390 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts add text : result(%d)", ret);
392 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts add text : result(%d)", ret);
395 if (!dbus_connection_send(conn, reply, NULL)) {
396 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts add text : Out Of Memory!");
399 dbus_connection_flush(conn);
400 dbus_message_unref(reply);
402 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts add text : Fail to create reply message!!");
405 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
406 SLOG(LOG_DEBUG, tts_tag(), " ");
411 int ttsd_dbus_server_add_silent_utterance(DBusConnection* conn, DBusMessage* msg)
414 dbus_error_init(&err);
416 unsigned int uid, duration_in_msec;
421 dbus_message_get_args(msg, &err,
422 DBUS_TYPE_UINT32, &uid,
423 DBUS_TYPE_UINT32, &duration_in_msec,
424 DBUS_TYPE_INT32, &uttid,
425 DBUS_TYPE_STRING, &credential,
428 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS ADD SILENT UTTERANCE");
430 if (dbus_error_is_set(&err)) {
431 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts add silent utterance : Get arguments error (%s)", err.message);
432 dbus_error_free(&err);
433 ret = TTSD_ERROR_OPERATION_FAILED;
435 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts add silent utterance : uid(%u), duration_in_msec(%u), uttid(%d), credential(%s)",
436 uid, duration_in_msec, uttid, (NULL == credential) ? "NULL" : credential);
437 ret = ttsd_server_add_silent_utterance(uid, duration_in_msec, uttid, credential);
441 reply = dbus_message_new_method_return(msg);
444 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
447 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts add silent utterance : result(%d)", ret);
449 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts add silent utterance : result(%d)", ret);
452 if (!dbus_connection_send(conn, reply, NULL)) {
453 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts add silent utterance : Out Of Memory!");
456 dbus_connection_flush(conn);
457 dbus_message_unref(reply);
459 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts add silent utterance : Fail to create reply message!!");
462 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
463 SLOG(LOG_DEBUG, tts_tag(), " ");
468 int ttsd_dbus_server_play(DBusConnection* conn, DBusMessage* msg)
471 dbus_error_init(&err);
477 dbus_message_get_args(msg, &err,
478 DBUS_TYPE_UINT32, &uid,
479 DBUS_TYPE_STRING, &credential,
482 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS PLAY");
484 if (dbus_error_is_set(&err)) {
485 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts play : Get arguments error (%s)", err.message);
486 dbus_error_free(&err);
487 ret = TTSD_ERROR_OPERATION_FAILED;
489 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts play : uid(%u), credential(%s)", uid, (NULL == credential) ? "NULL" : credential);
490 ret = ttsd_server_play(uid, credential);
494 reply = dbus_message_new_method_return(msg);
497 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
500 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts play : result(%d)", ret);
502 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts play : result(%d)", ret);
505 if (!dbus_connection_send(conn, reply, NULL)) {
506 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts play : Out Of Memory!");
509 dbus_connection_flush(conn);
510 dbus_message_unref(reply);
512 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts play : Fail to create reply message!!");
515 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
516 SLOG(LOG_DEBUG, tts_tag(), " ");
521 int ttsd_dbus_server_stop(DBusConnection* conn, DBusMessage* msg)
524 dbus_error_init(&err);
528 dbus_message_get_args(msg, &err,
529 DBUS_TYPE_UINT32, &uid,
532 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS STOP");
534 if (dbus_error_is_set(&err)) {
535 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts stop : Get arguments error (%s)", err.message);
536 dbus_error_free(&err);
537 ret = TTSD_ERROR_OPERATION_FAILED;
539 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts stop : uid(%u)", uid);
540 ret = ttsd_server_stop(uid);
544 reply = dbus_message_new_method_return(msg);
547 dbus_message_append_args(reply,
548 DBUS_TYPE_INT32, &ret,
552 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts stop : result(%d)", ret);
554 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts stop : result(%d)", ret);
557 if (!dbus_connection_send(conn, reply, NULL)) {
558 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts stop : Out Of Memory!");
561 dbus_connection_flush(conn);
562 dbus_message_unref(reply);
564 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts stop : Fail to create reply message!!");
567 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
568 SLOG(LOG_DEBUG, tts_tag(), " ");
573 int ttsd_dbus_server_pause(DBusConnection* conn, DBusMessage* msg)
576 dbus_error_init(&err);
580 dbus_message_get_args(msg, &err,
581 DBUS_TYPE_UINT32, &uid,
584 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS PAUSE");
586 if (dbus_error_is_set(&err)) {
587 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts pause : Get arguments error (%s)", err.message);
588 dbus_error_free(&err);
589 ret = TTSD_ERROR_OPERATION_FAILED;
591 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts pause : uid(%u)", uid);
592 ret = ttsd_server_pause(uid);
596 reply = dbus_message_new_method_return(msg);
599 dbus_message_append_args(reply,
600 DBUS_TYPE_INT32, &ret,
604 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts pause : result(%d)", ret);
606 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts pause : result(%d)", ret);
609 if (!dbus_connection_send(conn, reply, NULL)) {
610 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts pause : Out Of Memory!");
613 dbus_connection_flush(conn);
614 dbus_message_unref(reply);
616 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts pause : Fail to create reply message!!");
619 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
620 SLOG(LOG_DEBUG, tts_tag(), " ");
625 int ttsd_dbus_server_set_private_data(DBusConnection* conn, DBusMessage* msg)
628 dbus_error_init(&err);
634 dbus_message_get_args(msg, &err,
635 DBUS_TYPE_UINT32, &uid,
636 DBUS_TYPE_STRING, &key,
637 DBUS_TYPE_STRING, &data,
640 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS set private data");
642 if (dbus_error_is_set(&err)) {
643 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] Fail to get arguments (%s)", err.message);
644 dbus_error_free(&err);
645 ret = TTSD_ERROR_OPERATION_FAILED;
647 SLOG(LOG_DEBUG, tts_tag(), "[IN] tts set private data(%d)", uid);
648 ret = ttsd_server_set_private_data(uid, key, data);
652 reply = dbus_message_new_method_return(msg);
655 dbus_message_append_args(reply,
656 DBUS_TYPE_INT32, &ret,
660 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts set private data : (%d)", ret);
662 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts set private data : (%d)", ret);
665 if (!dbus_connection_send(conn, reply, NULL)) {
666 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] Fail to send reply");
669 dbus_connection_flush(conn);
670 dbus_message_unref(reply);
672 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] Fail to create reply message");
675 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
676 SLOG(LOG_DEBUG, tts_tag(), "");
681 int ttsd_dbus_server_get_private_data(DBusConnection* conn, DBusMessage* msg)
684 dbus_error_init(&err);
690 dbus_message_get_args(msg, &err,
691 DBUS_TYPE_UINT32, &uid,
692 DBUS_TYPE_STRING, &key,
695 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS get private data");
697 if (dbus_error_is_set(&err)) {
698 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] Fail to get arguments (%s)", err.message);
699 dbus_error_free(&err);
700 ret = TTSD_ERROR_OPERATION_FAILED;
702 SLOG(LOG_DEBUG, tts_tag(), "[IN] tts get private data : uid(%u)", uid);
703 ret = ttsd_server_get_private_data(uid, key, &data);
707 reply = dbus_message_new_method_return(msg);
710 dbus_message_append_args(reply,
711 DBUS_TYPE_INT32, &ret,
712 DBUS_TYPE_STRING, &data,
716 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts get private data : Result(%d), data(%s)", ret, (NULL == data) ? "NULL" : data);
718 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts get private data : (%d)", ret);
721 if (!dbus_connection_send(conn, reply, NULL)) {
722 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] Fail to send reply");
725 dbus_connection_flush(conn);
726 dbus_message_unref(reply);
728 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] Fail to create reply message");
731 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
732 SLOG(LOG_DEBUG, tts_tag(), "");
742 int ttsd_dbus_server_play_pcm(DBusConnection* conn, DBusMessage* msg)
745 dbus_error_init(&err);
750 dbus_message_get_args(msg, &err,
751 DBUS_TYPE_UINT32, &uid,
754 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS PLAY PCM");
756 if (dbus_error_is_set(&err)) {
757 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts play pcm : Get arguments error (%s)", err.message);
758 dbus_error_free(&err);
759 ret = TTSD_ERROR_OPERATION_FAILED;
761 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts play pcm : uid(%u)", uid);
762 ret = ttsd_server_play_pcm(uid);
766 reply = dbus_message_new_method_return(msg);
769 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
772 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts play pcm : result(%d)", ret);
774 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts play pcm : result(%d)", ret);
777 if (!dbus_connection_send(conn, reply, NULL)) {
778 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts play pcm : Out Of Memory!");
781 dbus_connection_flush(conn);
782 dbus_message_unref(reply);
784 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts play pcm : Fail to create reply message!!");
787 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
788 SLOG(LOG_DEBUG, tts_tag(), " ");
793 int ttsd_dbus_server_stop_pcm(DBusConnection* conn, DBusMessage* msg)
796 dbus_error_init(&err);
801 dbus_message_get_args(msg, &err,
802 DBUS_TYPE_UINT32, &uid,
805 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS STOP PCM");
807 if (dbus_error_is_set(&err)) {
808 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts stop pcm : Get arguments error (%s)", err.message);
809 dbus_error_free(&err);
810 ret = TTSD_ERROR_OPERATION_FAILED;
812 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts stop pcm : uid(%u)", uid);
813 ret = ttsd_server_stop(uid);
817 reply = dbus_message_new_method_return(msg);
820 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
823 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts stop pcm : result(%d)", ret);
825 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts stop pcm : result(%d)", ret);
828 if (!dbus_connection_send(conn, reply, NULL)) {
829 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts stop pcm : Out Of Memory!");
832 dbus_connection_flush(conn);
833 dbus_message_unref(reply);
835 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts stop pcm : Fail to create reply message!!");
838 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
839 SLOG(LOG_DEBUG, tts_tag(), " ");
844 int ttsd_dbus_server_add_pcm(DBusConnection* conn, DBusMessage* msg)
847 dbus_error_init(&err);
857 dbus_message_get_args(msg, &err,
858 DBUS_TYPE_UINT32, &uid,
859 DBUS_TYPE_INT32, &event,
860 DBUS_TYPE_INT32, &audio_type,
861 DBUS_TYPE_INT32, &rate,
862 //DBUS_TYPE_STRING, &data,
863 //DBUS_TYPE_INT32, &data_size,
864 DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
868 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS ADD PCM");
870 if (dbus_error_is_set(&err)) {
871 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts add pcm : Get arguments error (%s)", err.message);
872 dbus_error_free(&err);
873 ret = TTSD_ERROR_OPERATION_FAILED;
875 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts add pcm : uid(%u)", uid);
876 ret = ttsd_server_add_pcm(uid, event, (void*)data, data_size, audio_type, rate);
880 reply = dbus_message_new_method_return(msg);
883 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
886 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts add pcm : result(%d)", ret);
888 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts add pcm : result(%d)", ret);
891 if (!dbus_connection_send(conn, reply, NULL)) {
892 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts add pcm : Out Of Memory!");
895 dbus_connection_flush(conn);
896 dbus_message_unref(reply);
898 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts add pcm : Fail to create reply message!!");
901 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
902 SLOG(LOG_DEBUG, tts_tag(), " ");
907 int ttsd_dbus_server_get_service_state(DBusConnection* conn, DBusMessage* msg)
910 dbus_error_init(&err);
913 int state = (int)TTSD_STATE_READY;
916 dbus_message_get_args(msg, &err,
917 DBUS_TYPE_UINT32, &uid,
920 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS GET SERVICE STATE");
922 if (dbus_error_is_set(&err)) {
923 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts get service state : Get arguments error (%s)", err.message);
924 dbus_error_free(&err);
925 ret = TTSD_ERROR_OPERATION_FAILED;
927 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts get service state : uid(%u)", uid);
928 ret = ttsd_server_get_service_state(uid, &state);
932 reply = dbus_message_new_method_return(msg);
935 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INT32, &state, DBUS_TYPE_INVALID);
938 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts get service state : result(%d)", ret);
940 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts get service state : result(%d)", ret);
943 if (!dbus_connection_send(conn, reply, NULL)) {
944 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts get service state : Out Of Memory!");
947 dbus_connection_flush(conn);
948 dbus_message_unref(reply);
950 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts get service state : Fail to create reply message!!");
953 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
954 SLOG(LOG_DEBUG, tts_tag(), " ");