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);
35 dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_UINT32, &uid, DBUS_TYPE_INT32, &mode, DBUS_TYPE_INVALID);
37 if (dbus_error_is_set(&err)) {
38 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] ttsd Hello : get arguments error (%s)", err.message);
39 dbus_error_free(&err);
41 SLOG(LOG_INFO, tts_tag(), "[IN] ttsd hello : pid(%d), uid(%u), mode(%d)", pid, uid, mode);
42 bool is_initialized = false;
43 bool is_credential_needed = false;
44 int credential_needed = 0;
47 ttsd_server_is_already_initialized(pid, uid, &is_initialized);
48 if (false == is_initialized) {
49 ret = ttsd_server_initialize(pid, uid, (ttsd_mode_e)mode, TTS_IPC_METHOD_DBUS, &is_credential_needed);
51 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] ttsd Hello : server initialize, ret(%d)", ret);
53 if (false == is_credential_needed) {
54 credential_needed = 0;
56 credential_needed = 1;
59 SLOG(LOG_INFO, tts_tag(), "[IN] ttsd hello : already initialized. pid(%d), uid(%u)", pid, uid);
60 ret = TTS_ERROR_ALREADY_INITIALIZED;
61 credential_needed = TTS_CREDENTIAL_NEEDED_ALREADY_INITIALIZED;
63 SLOG(LOG_INFO, tts_tag(), "[INFO] send_hello. pid(%d), uid(%u), ret(%d), credential_needed(%d)", pid, uid, ret, credential_needed);
65 ttsdc_dbus_send_hello(pid, uid, ret, credential_needed);
71 int ttsd_dbus_server_hello_sync(DBusConnection* conn, DBusMessage* msg)
73 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS Hello");
76 reply = dbus_message_new_method_return(msg);
79 if (!dbus_connection_send(conn, reply, NULL)) {
80 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] Out Of Memory!");
83 dbus_connection_flush(conn);
84 dbus_message_unref(reply);
86 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] Fail to create reply message!!");
92 int ttsd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg)
95 dbus_error_init(&err);
99 bool credential_needed = 0;
103 dbus_message_get_args(msg, &err,
104 DBUS_TYPE_INT32, &pid,
105 DBUS_TYPE_UINT32, &uid,
106 DBUS_TYPE_INT32, &mode,
109 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS INITIALIZE");
111 if (dbus_error_is_set(&err)) {
112 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts initialize : get arguments error (%s)", err.message);
113 dbus_error_free(&err);
114 ret = TTSD_ERROR_OPERATION_FAILED;
116 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts initialize : pid(%d), uid(%u), mode(%d)", pid, uid, mode);
117 ret = ttsd_server_initialize(pid, uid, (ttsd_mode_e)mode, TTS_IPC_METHOD_DBUS, &credential_needed);
121 reply = dbus_message_new_method_return(msg);
123 int temp = (int)credential_needed;
124 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts initialize : result(%d), credential_needed(%d)", ret, (int)credential_needed);
126 dbus_message_append_args(reply,
127 DBUS_TYPE_INT32, &ret,
128 DBUS_TYPE_INT32, &temp,
132 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts initialize : result(%d), credential_needed(%d)", ret, credential_needed);
134 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts initialize : result(%d)", ret);
137 if (!dbus_connection_send(conn, reply, NULL)) {
138 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts initialize : Out Of Memory!");
141 dbus_connection_flush(conn);
142 dbus_message_unref(reply);
144 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts initialize : Fail to create reply message!!");
150 int ttsd_dbus_server_finalize(DBusConnection* conn, DBusMessage* msg)
153 dbus_error_init(&err);
158 dbus_message_get_args(msg, &err, DBUS_TYPE_UINT32, &uid, DBUS_TYPE_INVALID);
160 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS FINALIZE");
162 if (dbus_error_is_set(&err)) {
163 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts finalize : get arguments error (%s)", err.message);
164 dbus_error_free(&err);
165 ret = TTSD_ERROR_OPERATION_FAILED;
167 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts finalize : uid(%u)", uid);
168 ret = ttsd_server_finalize(uid);
172 reply = dbus_message_new_method_return(msg);
175 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
178 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts finalize : result(%d)", ret);
180 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts finalize : result(%d)", ret);
183 if (!dbus_connection_send(conn, reply, NULL)) {
184 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts finalize : Out Of Memory!");
187 dbus_connection_flush(conn);
188 dbus_message_unref(reply);
190 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts finalize : Fail to create reply message!!");
196 int ttsd_dbus_server_get_support_voices(DBusConnection* conn, DBusMessage* msg)
199 dbus_error_init(&err);
203 GList* voice_list = NULL;
205 dbus_message_get_args(msg, &err, DBUS_TYPE_UINT32, &uid, DBUS_TYPE_INVALID);
207 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS GET VOICES");
209 if (dbus_error_is_set(&err)) {
210 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts get supported voices : get arguments error (%s)", err.message);
211 dbus_error_free(&err);
212 ret = TTSD_ERROR_OPERATION_FAILED;
214 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] get supported voices : uid(%u)", uid);
215 ret = ttsd_server_get_support_voices(uid, &voice_list);
219 reply = dbus_message_new_method_return(msg);
222 DBusMessageIter args;
223 dbus_message_iter_init_append(reply, &args);
226 dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(ret));
229 /* Append voice size */
230 unsigned int size = g_list_length(voice_list);
232 if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(size))) {
233 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts supported voices : Fail to append type");
234 ret = TTSD_ERROR_OPERATION_FAILED;
240 iter = g_list_first(voice_list);
242 while (NULL != iter) {
246 dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(voice->language));
247 dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(voice->type));
249 if (NULL != voice->language)
250 g_free(voice->language);
255 voice_list = g_list_remove_link(voice_list, iter);
257 iter = g_list_first(voice_list);
260 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts supported voices : result(%d)", ret);
262 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts supported voices : result(%d)", ret);
265 if (!dbus_connection_send(conn, reply, NULL)) {
266 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] error : Out Of Memory!");
269 dbus_connection_flush(conn);
270 dbus_message_unref(reply);
272 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts supported voices : Fail to create reply message!!");
278 int ttsd_dbus_server_get_current_voice(DBusConnection* conn, DBusMessage* msg)
281 dbus_error_init(&err);
288 dbus_message_get_args(msg, &err, DBUS_TYPE_UINT32, &uid, DBUS_TYPE_INVALID);
290 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS GET DEFAULT VOICE");
292 if (dbus_error_is_set(&err)) {
293 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts get default voice : Get arguments error (%s)", err.message);
294 dbus_error_free(&err);
295 ret = TTSD_ERROR_OPERATION_FAILED;
297 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts get default voice : uid(%u)", uid);
298 ret = ttsd_server_get_current_voice(uid, &lang, &voice_type);
302 reply = dbus_message_new_method_return(msg);
306 /* Append result and voice */
307 dbus_message_append_args(reply,
308 DBUS_TYPE_INT32, &ret,
309 DBUS_TYPE_STRING, &lang,
310 DBUS_TYPE_INT32, &voice_type,
312 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts default voice : lang(%s), vctype(%d)", lang, voice_type);
314 dbus_message_append_args(reply,
315 DBUS_TYPE_INT32, &ret,
317 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts default voice : result(%d)", ret);
320 if (!dbus_connection_send(conn, reply, NULL)) {
321 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts default voice : Out Of Memory!");
324 dbus_connection_flush(conn);
325 dbus_message_unref(reply);
327 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts default voice : Fail to create reply message!!");
330 if (NULL != lang) free(lang);
334 int ttsd_dbus_server_add_text(DBusConnection* conn, DBusMessage* msg)
337 dbus_error_init(&err);
339 unsigned int uid, voicetype, speed, uttid;
340 char *text, *lang, *credential;
343 dbus_message_get_args(msg, &err,
344 DBUS_TYPE_UINT32, &uid,
345 DBUS_TYPE_STRING, &text,
346 DBUS_TYPE_STRING, &lang,
347 DBUS_TYPE_INT32, &voicetype,
348 DBUS_TYPE_INT32, &speed,
349 DBUS_TYPE_INT32, &uttid,
350 DBUS_TYPE_STRING, &credential,
353 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS ADD TEXT");
355 if (dbus_error_is_set(&err)) {
356 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts add text : Get arguments error (%s)", err.message);
357 dbus_error_free(&err);
358 ret = TTSD_ERROR_OPERATION_FAILED;
360 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts add text : uid(%u), text(%s), lang(%s), type(%d), speed(%d), uttid(%d), credential(%s)",
361 uid, (NULL == text) ? "NULL" : text, (NULL == lang) ? "NULL" : lang, voicetype, speed, uttid, (NULL == credential) ? "NULL" : credential);
362 ret = ttsd_server_add_text(uid, text, lang, voicetype, speed, uttid, credential);
366 reply = dbus_message_new_method_return(msg);
369 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
372 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts add text : result(%d)", ret);
374 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts add text : result(%d)", ret);
377 if (!dbus_connection_send(conn, reply, NULL)) {
378 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts add text : Out Of Memory!");
381 dbus_connection_flush(conn);
382 dbus_message_unref(reply);
384 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts add text : Fail to create reply message!!");
387 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
388 SLOG(LOG_DEBUG, tts_tag(), " ");
393 int ttsd_dbus_server_play(DBusConnection* conn, DBusMessage* msg)
396 dbus_error_init(&err);
402 dbus_message_get_args(msg, &err,
403 DBUS_TYPE_UINT32, &uid,
404 DBUS_TYPE_STRING, &credential,
407 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS PLAY");
409 if (dbus_error_is_set(&err)) {
410 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts play : Get arguments error (%s)", err.message);
411 dbus_error_free(&err);
412 ret = TTSD_ERROR_OPERATION_FAILED;
414 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts play : uid(%u), credential(%s)", uid, (NULL == credential) ? "NULL" : credential);
415 ret = ttsd_server_play(uid, credential);
419 reply = dbus_message_new_method_return(msg);
422 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
425 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts play : result(%d)", ret);
427 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts play : result(%d)", ret);
430 if (!dbus_connection_send(conn, reply, NULL)) {
431 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts play : Out Of Memory!");
434 dbus_connection_flush(conn);
435 dbus_message_unref(reply);
437 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts play : Fail to create reply message!!");
440 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
441 SLOG(LOG_DEBUG, tts_tag(), " ");
446 int ttsd_dbus_server_stop(DBusConnection* conn, DBusMessage* msg)
449 dbus_error_init(&err);
453 dbus_message_get_args(msg, &err,
454 DBUS_TYPE_UINT32, &uid,
457 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS STOP");
459 if (dbus_error_is_set(&err)) {
460 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts stop : Get arguments error (%s)", err.message);
461 dbus_error_free(&err);
462 ret = TTSD_ERROR_OPERATION_FAILED;
464 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts stop : uid(%u)", uid);
465 ret = ttsd_server_stop(uid);
469 reply = dbus_message_new_method_return(msg);
472 dbus_message_append_args(reply,
473 DBUS_TYPE_INT32, &ret,
477 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts stop : result(%d)", ret);
479 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts stop : result(%d)", ret);
482 if (!dbus_connection_send(conn, reply, NULL)) {
483 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts stop : Out Of Memory!");
486 dbus_connection_flush(conn);
487 dbus_message_unref(reply);
489 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts stop : Fail to create reply message!!");
492 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
493 SLOG(LOG_DEBUG, tts_tag(), " ");
498 int ttsd_dbus_server_pause(DBusConnection* conn, DBusMessage* msg)
501 dbus_error_init(&err);
505 dbus_message_get_args(msg, &err,
506 DBUS_TYPE_UINT32, &uid,
509 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS PAUSE");
511 if (dbus_error_is_set(&err)) {
512 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts pause : Get arguments error (%s)", err.message);
513 dbus_error_free(&err);
514 ret = TTSD_ERROR_OPERATION_FAILED;
516 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts pause : uid(%u)", uid);
517 ret = ttsd_server_pause(uid);
521 reply = dbus_message_new_method_return(msg);
524 dbus_message_append_args(reply,
525 DBUS_TYPE_INT32, &ret,
529 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts pause : result(%d)", ret);
531 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts pause : result(%d)", ret);
534 if (!dbus_connection_send(conn, reply, NULL)) {
535 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts pause : Out Of Memory!");
538 dbus_connection_flush(conn);
539 dbus_message_unref(reply);
541 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts pause : Fail to create reply message!!");
544 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
545 SLOG(LOG_DEBUG, tts_tag(), " ");
550 int ttsd_dbus_server_set_private_data(DBusConnection* conn, DBusMessage* msg)
553 dbus_error_init(&err);
559 dbus_message_get_args(msg, &err,
560 DBUS_TYPE_UINT32, &uid,
561 DBUS_TYPE_STRING, &key,
562 DBUS_TYPE_STRING, &data,
565 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS set private data");
567 if (dbus_error_is_set(&err)) {
568 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] Fail to get arguments (%s)", err.message);
569 dbus_error_free(&err);
570 ret = TTSD_ERROR_OPERATION_FAILED;
572 SLOG(LOG_DEBUG, tts_tag(), "[IN] tts set private data(%d)", uid);
573 ret = ttsd_server_set_private_data(uid, key, data);
577 reply = dbus_message_new_method_return(msg);
580 dbus_message_append_args(reply,
581 DBUS_TYPE_INT32, &ret,
585 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts set private data : (%d)", ret);
587 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts set private data : (%d)", ret);
590 if (!dbus_connection_send(conn, reply, NULL)) {
591 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] Fail to send reply");
594 dbus_connection_flush(conn);
595 dbus_message_unref(reply);
597 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] Fail to create reply message");
600 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
601 SLOG(LOG_DEBUG, tts_tag(), "");
606 int ttsd_dbus_server_get_private_data(DBusConnection* conn, DBusMessage* msg)
609 dbus_error_init(&err);
615 dbus_message_get_args(msg, &err,
616 DBUS_TYPE_UINT32, &uid,
617 DBUS_TYPE_STRING, &key,
620 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS get private data");
622 if (dbus_error_is_set(&err)) {
623 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] Fail to get arguments (%s)", err.message);
624 dbus_error_free(&err);
625 ret = TTSD_ERROR_OPERATION_FAILED;
627 SLOG(LOG_DEBUG, tts_tag(), "[IN] tts get private data : uid(%u)", uid);
628 ret = ttsd_server_get_private_data(uid, key, &data);
632 reply = dbus_message_new_method_return(msg);
635 dbus_message_append_args(reply,
636 DBUS_TYPE_INT32, &ret,
637 DBUS_TYPE_STRING, &data,
641 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts get private data : Result(%d), data(%s)", ret, (NULL == data) ? "NULL" : data);
643 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts get private data : (%d)", ret);
646 if (!dbus_connection_send(conn, reply, NULL)) {
647 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] Fail to send reply");
650 dbus_connection_flush(conn);
651 dbus_message_unref(reply);
653 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] Fail to create reply message");
656 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
657 SLOG(LOG_DEBUG, tts_tag(), "");
667 int ttsd_dbus_server_play_pcm(DBusConnection* conn, DBusMessage* msg)
670 dbus_error_init(&err);
675 dbus_message_get_args(msg, &err,
676 DBUS_TYPE_UINT32, &uid,
679 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS PLAY PCM");
681 if (dbus_error_is_set(&err)) {
682 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts play pcm : Get arguments error (%s)", err.message);
683 dbus_error_free(&err);
684 ret = TTSD_ERROR_OPERATION_FAILED;
686 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts play pcm : uid(%u)", uid);
687 ret = ttsd_server_play_pcm(uid);
691 reply = dbus_message_new_method_return(msg);
694 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
697 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts play pcm : result(%d)", ret);
699 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts play pcm : result(%d)", ret);
702 if (!dbus_connection_send(conn, reply, NULL)) {
703 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts play pcm : Out Of Memory!");
706 dbus_connection_flush(conn);
707 dbus_message_unref(reply);
709 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts play pcm : Fail to create reply message!!");
712 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
713 SLOG(LOG_DEBUG, tts_tag(), " ");
718 int ttsd_dbus_server_stop_pcm(DBusConnection* conn, DBusMessage* msg)
721 dbus_error_init(&err);
726 dbus_message_get_args(msg, &err,
727 DBUS_TYPE_UINT32, &uid,
730 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS STOP PCM");
732 if (dbus_error_is_set(&err)) {
733 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts stop pcm : Get arguments error (%s)", err.message);
734 dbus_error_free(&err);
735 ret = TTSD_ERROR_OPERATION_FAILED;
737 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts stop pcm : uid(%u)", uid);
738 ret = ttsd_server_stop(uid);
742 reply = dbus_message_new_method_return(msg);
745 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
748 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts stop pcm : result(%d)", ret);
750 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts stop pcm : result(%d)", ret);
753 if (!dbus_connection_send(conn, reply, NULL)) {
754 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts stop pcm : Out Of Memory!");
757 dbus_connection_flush(conn);
758 dbus_message_unref(reply);
760 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts stop pcm : Fail to create reply message!!");
763 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
764 SLOG(LOG_DEBUG, tts_tag(), " ");
769 int ttsd_dbus_server_add_pcm(DBusConnection* conn, DBusMessage* msg)
772 dbus_error_init(&err);
782 dbus_message_get_args(msg, &err,
783 DBUS_TYPE_UINT32, &uid,
784 DBUS_TYPE_INT32, &event,
785 DBUS_TYPE_INT32, &audio_type,
786 DBUS_TYPE_INT32, &rate,
787 //DBUS_TYPE_STRING, &data,
788 //DBUS_TYPE_INT32, &data_size,
789 DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
793 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS ADD PCM");
795 if (dbus_error_is_set(&err)) {
796 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts add pcm : Get arguments error (%s)", err.message);
797 dbus_error_free(&err);
798 ret = TTSD_ERROR_OPERATION_FAILED;
800 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts add pcm : uid(%u)", uid);
801 ret = ttsd_server_add_pcm(uid, event, (void*)data, data_size, audio_type, rate);
805 reply = dbus_message_new_method_return(msg);
808 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
811 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts add pcm : result(%d)", ret);
813 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts add pcm : result(%d)", ret);
816 if (!dbus_connection_send(conn, reply, NULL)) {
817 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts add pcm : Out Of Memory!");
820 dbus_connection_flush(conn);
821 dbus_message_unref(reply);
823 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts add pcm : Fail to create reply message!!");
826 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
827 SLOG(LOG_DEBUG, tts_tag(), " ");
832 int ttsd_dbus_server_get_service_state(DBusConnection* conn, DBusMessage* msg)
835 dbus_error_init(&err);
838 int state = (int)TTSD_STATE_READY;
841 dbus_message_get_args(msg, &err,
842 DBUS_TYPE_UINT32, &uid,
845 SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS GET SERVICE STATE");
847 if (dbus_error_is_set(&err)) {
848 SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts get service state : Get arguments error (%s)", err.message);
849 dbus_error_free(&err);
850 ret = TTSD_ERROR_OPERATION_FAILED;
852 SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts get service state : uid(%u)", uid);
853 // TODO: implement behavior
857 reply = dbus_message_new_method_return(msg);
860 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INT32, &state, DBUS_TYPE_INVALID);
863 SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts get service state : result(%d)", ret);
865 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts get service state : result(%d)", ret);
868 if (!dbus_connection_send(conn, reply, NULL)) {
869 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts get service state : Out Of Memory!");
872 dbus_connection_flush(conn);
873 dbus_message_unref(reply);
875 SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts get service state : Fail to create reply message!!");
878 SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
879 SLOG(LOG_DEBUG, tts_tag(), " ");