2 * Copyright (c) 2011 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 int uid);
23 * Dbus Client-Daemon Server
26 int ttsd_dbus_server_hello(DBusConnection* conn, DBusMessage* msg)
28 SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> TTS Hello");
31 reply = dbus_message_new_method_return(msg);
34 if (!dbus_connection_send(conn, reply, NULL)) {
35 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] Out Of Memory!");
38 dbus_connection_flush(conn);
39 dbus_message_unref(reply);
41 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] Fail to create reply message!!");
44 SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<");
45 SLOG(LOG_DEBUG, TAG_TTSD, " ");
50 int ttsd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg)
53 dbus_error_init(&err);
58 dbus_message_get_args(msg, &err,
59 DBUS_TYPE_INT32, &pid,
60 DBUS_TYPE_INT32, &uid,
63 SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> TTS INITIALIZE");
65 if (dbus_error_is_set(&err)) {
66 SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] tts initialize : get arguments error (%s)\n", err.message);
67 dbus_error_free(&err);
68 ret = TTSD_ERROR_OPERATION_FAILED;
71 SLOG(LOG_DEBUG, TAG_TTSD, "[IN] tts initialize : pid(%d), uid(%d) \n", pid , uid);
72 ret = ttsd_server_initialize(pid, uid);
76 reply = dbus_message_new_method_return(msg);
79 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
82 SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] tts initialize : result(%d) \n", ret);
84 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts initialize : result(%d) \n", ret);
87 if (!dbus_connection_send(conn, reply, NULL)) {
88 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts initialize : Out Of Memory!\n");
91 dbus_connection_flush(conn);
92 dbus_message_unref(reply);
94 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts initialize : fail to create reply message!!");
97 SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<");
98 SLOG(LOG_DEBUG, TAG_TTSD, " ");
103 int ttsd_dbus_server_finalize(DBusConnection* conn, DBusMessage* msg)
106 dbus_error_init(&err);
111 dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
113 SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> TTS FINALIZE");
115 if (dbus_error_is_set(&err)) {
116 SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] tts finalize : get arguments error (%s)\n", err.message);
117 dbus_error_free(&err);
118 ret = TTSD_ERROR_OPERATION_FAILED;
121 SLOG(LOG_DEBUG, TAG_TTSD, "[IN] tts finalize : uid(%d) \n", uid);
122 ret = ttsd_server_finalize(uid);
126 reply = dbus_message_new_method_return(msg);
129 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
132 SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] tts finalize : result(%d) \n", ret);
134 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts finalize : result(%d) \n", ret);
137 if (!dbus_connection_send(conn, reply, NULL)) {
138 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts finalize : Out Of Memory!\n");
141 dbus_connection_flush(conn);
142 dbus_message_unref(reply);
144 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts finalize : fail to create reply message!!");
147 SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<");
148 SLOG(LOG_DEBUG, TAG_TTSD, " ");
153 int ttsd_dbus_server_get_support_voices(DBusConnection* conn, DBusMessage* msg)
156 dbus_error_init(&err);
160 GList* voice_list = NULL;
162 dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
164 SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> TTS GET VOICES");
166 if (dbus_error_is_set(&err)) {
167 SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] tts get supported voices : get arguments error (%s)\n", err.message);
168 dbus_error_free(&err);
169 ret = TTSD_ERROR_OPERATION_FAILED;
171 SLOG(LOG_DEBUG, TAG_TTSD, "[IN] get supported voices : uid(%d) \n", uid );
172 ret = ttsd_server_get_support_voices(uid, &voice_list);
176 reply = dbus_message_new_method_return(msg);
179 DBusMessageIter args;
180 dbus_message_iter_init_append(reply, &args);
183 dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(ret));
186 /* Append voice size */
187 int size = g_list_length(voice_list);
189 if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(size))) {
190 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts supported voices : Fail to append type \n");
191 ret = TTSD_ERROR_OPERATION_FAILED;
197 iter = g_list_first(voice_list);
199 while (NULL != iter) {
202 dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(voice->language) );
203 dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(voice->type) );
205 if (NULL != voice->language)
206 g_free(voice->language);
210 voice_list = g_list_remove_link(voice_list, iter);
212 iter = g_list_first(voice_list);
215 SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] tts supported voices : result(%d) \n", ret);
217 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts supported voices : result(%d) \n", ret);
220 if (!dbus_connection_send(conn, reply, NULL)) {
221 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] error : Out Of Memory!\n");
224 dbus_connection_flush(conn);
225 dbus_message_unref(reply);
227 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts supported voices : fail to create reply message!!");
230 SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<");
231 SLOG(LOG_DEBUG, TAG_TTSD, " ");
236 int ttsd_dbus_server_get_current_voice(DBusConnection* conn, DBusMessage* msg)
239 dbus_error_init(&err);
246 dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
248 SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> TTS GET DEFAULT VOICE");
250 if (dbus_error_is_set(&err)) {
251 SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] tts get default voice : Get arguments error (%s)\n", err.message);
252 dbus_error_free(&err);
253 ret = TTSD_ERROR_OPERATION_FAILED;
255 SLOG(LOG_DEBUG, TAG_TTSD, "[IN] tts get default voice : uid(%d) \n", uid);
256 ret = ttsd_server_get_current_voice(uid, &lang, &voice_type);
260 reply = dbus_message_new_method_return(msg);
264 /* Append result and voice */
265 dbus_message_append_args( reply,
266 DBUS_TYPE_INT32, &ret,
267 DBUS_TYPE_STRING, &lang,
268 DBUS_TYPE_INT32, &voice_type,
270 SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] tts default voice : lang(%s), vctype(%d)\n", lang, voice_type );
272 dbus_message_append_args( reply,
273 DBUS_TYPE_INT32, &ret,
275 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts default voice : result(%d) \n", ret);
278 if (!dbus_connection_send(conn, reply, NULL)) {
279 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts default voice : Out Of Memory!\n");
282 dbus_connection_flush(conn);
283 dbus_message_unref(reply);
285 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts default voice : fail to create reply message!!");
288 SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<");
289 SLOG(LOG_DEBUG, TAG_TTSD, " ");
294 int ttsd_dbus_server_add_text(DBusConnection* conn, DBusMessage* msg)
297 dbus_error_init(&err);
299 int uid, voicetype, speed, uttid;
303 dbus_message_get_args(msg, &err,
304 DBUS_TYPE_INT32, &uid,
305 DBUS_TYPE_STRING, &text,
306 DBUS_TYPE_STRING, &lang,
307 DBUS_TYPE_INT32, &voicetype,
308 DBUS_TYPE_INT32, &speed,
309 DBUS_TYPE_INT32, &uttid,
312 SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> TTS ADD TEXT");
314 if (dbus_error_is_set(&err)) {
315 SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] tts add text : Get arguments error (%s)\n", err.message);
316 dbus_error_free(&err);
317 ret = TTSD_ERROR_OPERATION_FAILED;
320 SLOG(LOG_DEBUG, TAG_TTSD, "[IN] tts add text : uid(%d), text(%s), lang(%s), type(%d), speed(%d), uttid(%d) \n",
321 uid, text, lang, voicetype, speed, uttid);
322 ret = ttsd_server_add_queue(uid, text, lang, voicetype, speed, uttid);
326 reply = dbus_message_new_method_return(msg);
329 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
332 SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] tts add text : result(%d) \n", ret);
334 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts add text : result(%d) \n", ret);
337 if (!dbus_connection_send(conn, reply, NULL)) {
338 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts add text : Out Of Memory!\n");
341 dbus_connection_flush(conn);
342 dbus_message_unref(reply);
344 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts add text : fail to create reply message!!");
347 SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<");
348 SLOG(LOG_DEBUG, TAG_TTSD, " ");
353 int ttsd_dbus_server_play(DBusConnection* conn, DBusMessage* msg)
356 dbus_error_init(&err);
361 dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
363 SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> TTS PLAY");
365 if (dbus_error_is_set(&err)) {
366 SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] tts play : Get arguments error (%s)\n", err.message);
367 dbus_error_free(&err);
368 ret = TTSD_ERROR_OPERATION_FAILED;
370 SLOG(LOG_DEBUG, TAG_TTSD, "[IN] tts play : uid(%d) \n", uid );
371 ret = ttsd_server_play(uid);
375 reply = dbus_message_new_method_return(msg);
378 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
381 SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] tts play : result(%d) \n", ret);
383 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts play : result(%d) \n", ret);
386 if (!dbus_connection_send(conn, reply, NULL)) {
387 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts play : Out Of Memory!\n");
390 dbus_connection_flush(conn);
391 dbus_message_unref(reply);
393 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts play : fail to create reply message!!");
396 SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<");
397 SLOG(LOG_DEBUG, TAG_TTSD, " ");
402 int ttsd_dbus_server_stop(DBusConnection* conn, DBusMessage* msg)
405 dbus_error_init(&err);
409 dbus_message_get_args(msg, &err,
410 DBUS_TYPE_INT32, &uid,
413 SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> TTS STOP");
415 if (dbus_error_is_set(&err)) {
416 SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] tts stop : Get arguments error (%s)\n", err.message);
417 dbus_error_free(&err);
418 ret = TTSD_ERROR_OPERATION_FAILED;
420 SLOG(LOG_DEBUG, TAG_TTSD, "[IN] tts stop : uid(%d)\n", uid);
421 ret = ttsd_server_stop(uid);
425 reply = dbus_message_new_method_return(msg);
428 dbus_message_append_args(reply,
429 DBUS_TYPE_INT32, &ret,
433 SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] tts stop : result(%d) \n", ret);
435 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts stop : result(%d) \n", ret);
438 if (!dbus_connection_send(conn, reply, NULL)) {
439 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts stop : Out Of Memory!\n");
442 dbus_connection_flush(conn);
443 dbus_message_unref(reply);
445 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts stop : fail to create reply message!!");
448 SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<");
449 SLOG(LOG_DEBUG, TAG_TTSD, " ");
454 int ttsd_dbus_server_pause(DBusConnection* conn, DBusMessage* msg)
457 dbus_error_init(&err);
462 dbus_message_get_args(msg, &err,
463 DBUS_TYPE_INT32, &uid,
466 SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> TTS PAUSE");
468 if (dbus_error_is_set(&err)) {
469 SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] tts pause : Get arguments error (%s)\n", err.message);
470 dbus_error_free(&err);
471 ret = TTSD_ERROR_OPERATION_FAILED;
473 SLOG(LOG_DEBUG, TAG_TTSD, "[IN] tts pause : uid(%d)\n", uid);
474 ret = ttsd_server_pause(uid, &uttid);
478 reply = dbus_message_new_method_return(msg);
481 dbus_message_append_args(reply,
482 DBUS_TYPE_INT32, &ret,
486 SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] tts pause : result(%d) \n", ret);
488 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts pause : result(%d) \n", ret);
491 if (!dbus_connection_send(conn, reply, NULL)) {
492 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts pause : Out Of Memory!\n");
495 dbus_connection_flush(conn);
496 dbus_message_unref(reply);
498 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts pause : fail to create reply message!!");
501 SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<");
502 SLOG(LOG_DEBUG, TAG_TTSD, " ");
509 * Dbus Setting-Daemon Server
512 int ttsd_dbus_server_setting_initialize(DBusConnection* conn, DBusMessage* msg)
515 dbus_error_init(&err);
520 dbus_message_get_args(msg, &err,
521 DBUS_TYPE_INT32, &pid,
524 SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> SETTING INITIALIZE");
526 if (dbus_error_is_set(&err)) {
527 SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] Receivce setting initialize : Get arguments error (%s)\n", err.message);
528 dbus_error_free(&err);
529 ret = TTSD_ERROR_OPERATION_FAILED;
531 SLOG(LOG_DEBUG, TAG_TTSD, "[IN] Receivce setting initialize : pid(%d) \n", pid);
532 ret = ttsd_server_setting_initialize(pid);
536 reply = dbus_message_new_method_return(msg);
539 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
542 SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] setting initialize : result(%d) \n", ret);
544 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting initialize : result(%d) \n", ret);
547 if (!dbus_connection_send(conn, reply, NULL)) {
548 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting initialize : Out Of Memory!\n");
551 dbus_connection_flush(conn);
552 dbus_message_unref(reply);
554 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting initialize : fail to create reply message!!");
557 SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<");
558 SLOG(LOG_DEBUG, TAG_TTSD, " ");
563 int ttsd_dbus_server_setting_finalize(DBusConnection* conn, DBusMessage* msg)
566 dbus_error_init(&err);
571 dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID);
573 SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> SETTING FINALIZE");
575 if (dbus_error_is_set(&err)) {
576 SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] setting finalize : Get arguments error (%s)\n", err.message);
577 dbus_error_free(&err);
578 ret = TTSD_ERROR_OPERATION_FAILED;
580 SLOG(LOG_DEBUG, TAG_TTSD, "[IN] setting finalize : pid(%d)\n", pid);
581 ret = ttsd_server_setting_finalize(pid);
585 reply = dbus_message_new_method_return(msg);
588 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
591 SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] setting finalize : result(%d) \n", ret);
593 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting finalize : result(%d) \n", ret);
596 if (!dbus_connection_send(conn, reply, NULL)) {
597 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting finalize : Out Of Memory!\n");
600 dbus_connection_flush(conn);
601 dbus_message_unref(reply);
603 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting finalize : fail to create reply message!!");
606 SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<");
607 SLOG(LOG_DEBUG, TAG_TTSD, " ");
612 int ttsd_dbus_server_setting_get_engine_list(DBusConnection* conn, DBusMessage* msg)
615 dbus_error_init(&err);
619 GList* engine_list = NULL;
621 dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID);
623 SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> SETTING GET ENGINE LIST");
625 if (dbus_error_is_set(&err)) {
626 SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] setting engine list : Get arguments error (%s)\n", err.message);
627 dbus_error_free(&err);
628 ret = TTSD_ERROR_OPERATION_FAILED;
630 SLOG(LOG_DEBUG, TAG_TTSD, "[IN] setting engine list : pid(%d) \n", pid);
631 ret = ttsd_server_setting_get_engine_list(pid, &engine_list);
635 reply = dbus_message_new_method_return(msg);
638 DBusMessageIter args;
639 dbus_message_iter_init_append(reply, &args);
642 dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(ret) );
646 int size = g_list_length(engine_list);
647 if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(size))) {
648 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting engine list : fail to append engine size \n");
654 iter = g_list_first(engine_list);
656 while (NULL != iter) {
658 SLOG(LOG_DEBUG, TAG_TTSD, "engine id : %s, engine name : %s, ug_name, : %s",
659 engine->engine_id, engine->engine_name, engine->ug_name);
661 dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(engine->engine_id) );
662 dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(engine->engine_name) );
663 dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(engine->ug_name) );
665 if (NULL != engine->engine_id)
666 g_free(engine->engine_id);
667 if (NULL != engine->engine_name);
668 g_free(engine->engine_name);
669 if (NULL != engine->ug_name);
670 g_free(engine->ug_name);
674 engine_list = g_list_remove_link(engine_list, iter);
676 iter = g_list_first(engine_list);
678 SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] setting engine list : result(%d) \n", ret);
681 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting engine list : result(%d) \n", ret);
684 if (!dbus_connection_send(conn, reply, NULL)) {
685 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting engine list : Out Of Memory!\n");
688 dbus_connection_flush(conn);
689 dbus_message_unref(reply);
691 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting engine list : fail to create reply message!!");
694 SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<");
695 SLOG(LOG_DEBUG, TAG_TTSD, " ");
700 int ttsd_dbus_server_setting_get_engine(DBusConnection* conn, DBusMessage* msg)
703 dbus_error_init(&err);
707 char* engine_id = NULL;
709 dbus_message_get_args(msg, &err,
710 DBUS_TYPE_INT32, &pid,
713 SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> SETTING GET ENGINE");
715 if (dbus_error_is_set(&err)) {
716 SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] setting get engine : Get arguments error (%s)\n", err.message);
717 dbus_error_free(&err);
718 ret = TTSD_ERROR_OPERATION_FAILED;
720 SLOG(LOG_DEBUG, TAG_TTSD, "[IN] setting get engine : pid(%d)\n", pid);
721 ret = ttsd_server_setting_get_current_engine(pid, &engine_id);
725 reply = dbus_message_new_method_return(msg);
729 dbus_message_append_args( reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_STRING, &engine_id, DBUS_TYPE_INVALID);
730 SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] setting get engine : result(%d), engine id(%s)\n", ret, engine_id);
732 dbus_message_append_args( reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
733 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting get engine : result(%d)", ret);
736 if (!dbus_connection_send(conn, reply, NULL)) {
737 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting get engine : Out Of Memory!\n");
740 dbus_connection_flush(conn);
741 dbus_message_unref(reply);
743 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting get engine : fail to create reply message!!");
746 if (NULL != engine_id)
749 SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<");
750 SLOG(LOG_DEBUG, TAG_TTSD, " ");
755 int ttsd_dbus_server_setting_set_engine(DBusConnection* conn, DBusMessage* msg)
758 dbus_error_init(&err);
764 dbus_message_get_args(msg, &err,
765 DBUS_TYPE_INT32, &pid,
766 DBUS_TYPE_STRING, &engine_id,
769 SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> SETTING SET ENGINE");
771 if (dbus_error_is_set(&err)) {
772 SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] setting set engine : Get arguments error (%s)\n", err.message);
773 dbus_error_free(&err);
774 ret = TTSD_ERROR_OPERATION_FAILED;
776 SLOG(LOG_DEBUG, TAG_TTSD, "[IN] setting set engine : pid(%d), engine id(%s)\n", pid, engine_id);
777 ret = ttsd_server_setting_set_current_engine(pid, engine_id);
781 reply = dbus_message_new_method_return(msg);
784 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
787 SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] setting set engine : result(%d) \n", ret);
789 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting set engine : result(%d) \n", ret);
792 if (!dbus_connection_send(conn, reply, NULL)) {
793 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting set engine : Out Of Memory!\n");
796 dbus_connection_flush(conn);
797 dbus_message_unref(reply);
799 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting set engine : fail to create reply message!!");
802 SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<");
803 SLOG(LOG_DEBUG, TAG_TTSD, " ");
808 int ttsd_dbus_server_setting_get_voice_list(DBusConnection* conn, DBusMessage* msg)
811 dbus_error_init(&err);
814 char* engine_id = NULL;
816 GList* voice_list = NULL;
818 dbus_message_get_args(msg, &err,
819 DBUS_TYPE_INT32, &pid,
822 SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> SETTING GET VOICE LIST");
824 if (dbus_error_is_set(&err)) {
825 SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] setting voice list : Get arguments error (%s)\n", err.message);
826 dbus_error_free(&err);
827 ret = TTSD_ERROR_OPERATION_FAILED;
829 SLOG(LOG_DEBUG, TAG_TTSD, "[IN] setting voice list : pid(%d)\n", pid);
830 ret = ttsd_server_setting_get_voice_list(pid, &engine_id, &voice_list);
834 reply = dbus_message_new_method_return(msg);
837 DBusMessageIter args;
839 dbus_message_iter_init_append(reply, &args);
842 dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(ret) );
845 if (dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(engine_id))) {
846 /* Append voice size */
847 int size = g_list_length(voice_list);
848 if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(size))) {
849 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting voice list : Fail to append type \n");
850 ret = TTSD_ERROR_OPERATION_FAILED;
856 iter = g_list_first(voice_list);
858 while (NULL != iter) {
861 dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(voice->language) );
862 dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(voice->type) );
864 if (NULL != voice->language)
865 g_free(voice->language);
869 voice_list = g_list_remove_link(voice_list, iter);
871 iter = g_list_first(voice_list);
874 SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] setting voice list : result(%d) \n", ret);
876 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting voice list : Fail to append engine_id \n");
879 if (NULL != engine_id)
882 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting voice list : result(%d) \n", ret);
885 if (!dbus_connection_send(conn, reply, NULL)) {
886 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting voice list : Out Of Memory!\n");
889 dbus_connection_flush(conn);
890 dbus_message_unref(reply);
892 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting voice list : fail to create reply message!!");
895 SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<");
896 SLOG(LOG_DEBUG, TAG_TTSD, " ");
901 int ttsd_dbus_server_setting_get_default_voice(DBusConnection* conn, DBusMessage* msg)
904 dbus_error_init(&err);
909 ttsp_voice_type_e type;
911 dbus_message_get_args(msg, &err,
912 DBUS_TYPE_INT32, &pid,
915 SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> SETTING GET DEFAULT VOICE");
917 if (dbus_error_is_set(&err)) {
918 SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] setting get default voice : Get arguments error (%s)\n", err.message);
919 dbus_error_free(&err);
920 ret = TTSD_ERROR_OPERATION_FAILED;
922 SLOG(LOG_DEBUG, TAG_TTSD, "[IN] setting get default voice : pid(%d)\n", pid);
923 ret = ttsd_server_setting_get_default_voice(pid, &lang, &type);
927 reply = dbus_message_new_method_return(msg);
931 dbus_message_append_args(reply,
932 DBUS_TYPE_INT32, &ret,
933 DBUS_TYPE_STRING, &lang,
934 DBUS_TYPE_INT32, &type,
936 SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] setting get default voice : result(%d), language(%s), type(%d) \n", ret, lang, type);
938 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
939 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting get default voice : result(%d) \n", ret);
942 if (!dbus_connection_send(conn, reply, NULL)) {
943 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting get default voice : Out Of Memory!\n");
946 dbus_connection_flush(conn);
947 dbus_message_unref(reply);
949 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting get default voice : fail to create reply message!!");
952 SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<");
953 SLOG(LOG_DEBUG, TAG_TTSD, " ");
958 int ttsd_dbus_server_setting_set_default_voice(DBusConnection* conn, DBusMessage* msg)
961 dbus_error_init(&err);
968 dbus_message_get_args(msg, &err,
969 DBUS_TYPE_INT32, &pid,
970 DBUS_TYPE_STRING, &language,
971 DBUS_TYPE_INT32, &voicetype,
974 SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> SET DEFAULT VOICE");
976 if (dbus_error_is_set(&err)) {
977 SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] setting set default voice : Get arguments error (%s)\n", err.message);
978 dbus_error_free(&err);
979 ret = TTSD_ERROR_OPERATION_FAILED;
981 SLOG(LOG_DEBUG, TAG_TTSD, "[IN] setting set default voice : pid(%d), lang(%s), type(%d)\n"
982 , pid, language, voicetype);
983 ret = ttsd_server_setting_set_default_voice(pid, language, voicetype);
987 reply = dbus_message_new_method_return(msg);
990 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
993 SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] setting set default voice : result(%d) \n", ret);
995 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting set default voice : result(%d) \n", ret);
998 if (!dbus_connection_send(conn, reply, NULL)) {
999 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting set default voice : Out Of Memory!\n");
1002 dbus_connection_flush(conn);
1003 dbus_message_unref(reply);
1005 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting set default voice : fail to create reply message!!");
1008 SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<");
1009 SLOG(LOG_DEBUG, TAG_TTSD, " ");
1014 int ttsd_dbus_server_setting_get_speed(DBusConnection* conn, DBusMessage* msg)
1017 dbus_error_init(&err);
1023 dbus_message_get_args(msg, &err,
1024 DBUS_TYPE_INT32, &pid,
1027 SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> SETTING GET SPEED");
1029 if (dbus_error_is_set(&err)) {
1030 SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] setting get speed : Get arguments error (%s)\n", err.message);
1031 dbus_error_free(&err);
1032 ret = TTSD_ERROR_OPERATION_FAILED;
1034 SLOG(LOG_DEBUG, TAG_TTSD, "[IN] setting get default speed : pid(%d)\n", pid);
1035 ret = ttsd_server_setting_get_default_speed(pid, &speed);
1039 reply = dbus_message_new_method_return(msg);
1041 if (NULL != reply) {
1043 dbus_message_append_args( reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INT32, &speed, DBUS_TYPE_INVALID);
1044 SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] setting get default speed : result(%d), speed(%d) \n", ret, speed);
1046 dbus_message_append_args( reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
1047 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting get default speed : result(%d) \n", ret);
1050 if (!dbus_connection_send(conn, reply, NULL)) {
1051 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting get default speed : Out Of Memory!\n");
1054 dbus_connection_flush(conn);
1055 dbus_message_unref(reply);
1057 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting get default speed : fail to create reply message!!");
1060 SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<");
1061 SLOG(LOG_DEBUG, TAG_TTSD, " ");
1066 int ttsd_dbus_server_setting_set_speed(DBusConnection* conn, DBusMessage* msg)
1069 dbus_error_init(&err);
1075 dbus_message_get_args(msg, &err,
1076 DBUS_TYPE_INT32, &pid,
1077 DBUS_TYPE_INT32, &speed,
1080 SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> SETTING GET SPEED");
1082 if (dbus_error_is_set(&err)) {
1083 SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] setting set default speed : Get arguments error (%s)\n", err.message);
1084 dbus_error_free(&err);
1085 ret = TTSD_ERROR_OPERATION_FAILED;
1087 SLOG(LOG_DEBUG, TAG_TTSD, "[IN] setting set default speed : pid(%d), speed(%d)\n", pid, speed);
1088 ret = ttsd_server_setting_set_default_speed(pid, speed);
1092 reply = dbus_message_new_method_return(msg);
1094 if (NULL != reply) {
1095 dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
1098 SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] setting set default speed : result(%d)", ret);
1100 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting set default speed : result(%d)", ret);
1103 if (!dbus_connection_send(conn, reply, NULL)) {
1104 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting set default speed : Out Of Memory!\n");
1107 dbus_connection_flush(conn);
1108 dbus_message_unref(reply);
1110 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting set default speed : fail to create reply message!!");
1113 SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<");
1114 SLOG(LOG_DEBUG, TAG_TTSD, " ");
1119 int ttsd_dbus_server_setting_get_engine_setting(DBusConnection* conn, DBusMessage* msg)
1122 dbus_error_init(&err);
1127 GList* engine_setting_list = NULL;
1129 dbus_message_get_args(msg, &err,
1130 DBUS_TYPE_INT32, &pid,
1133 SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> SETTING GET ENGINE SETTING");
1135 if (dbus_error_is_set(&err)) {
1136 SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] setting get engine option : Get arguments error (%s)\n", err.message);
1137 dbus_error_free(&err);
1138 ret = TTSD_ERROR_OPERATION_FAILED;
1140 SLOG(LOG_DEBUG, TAG_TTSD, "[IN] setting get engine option : pid(%d)", pid);
1141 ret = ttsd_server_setting_get_engine_setting(pid, &engine_id, &engine_setting_list);
1145 reply = dbus_message_new_method_return(msg);
1147 if (NULL != reply) {
1148 DBusMessageIter args;
1149 dbus_message_iter_init_append(reply, &args);
1152 dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(ret) );
1155 if (dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(engine_id))) {
1156 /* Append voice size */
1157 int size = g_list_length(engine_setting_list);
1158 if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(size))) {
1159 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting voice list : Fail to append type \n");
1160 ret = TTSD_ERROR_OPERATION_FAILED;
1164 engine_setting_s* setting;
1166 iter = g_list_first(engine_setting_list);
1168 while (NULL != iter) {
1169 setting = iter->data;
1171 dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(setting->key) );
1172 dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(setting->value) );
1174 if (NULL != setting->key)
1175 g_free(setting->key);
1176 if (NULL != setting->value)
1177 g_free(setting->value);
1178 if (NULL != setting);
1181 engine_setting_list = g_list_remove_link(engine_setting_list, iter);
1183 iter = g_list_first(engine_setting_list);
1186 SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] setting engine setting list : result(%d) \n", ret);
1188 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting voice list : Fail to append engine_id \n");
1191 if (NULL != engine_id)
1194 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting get engine option : result(%d) \n", ret);
1197 if (!dbus_connection_send(conn, reply, NULL)) {
1198 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting get engine option : Out Of Memory!\n");
1201 dbus_connection_flush(conn);
1202 dbus_message_unref(reply);
1204 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting get engine option : fail to create reply message!!");
1207 SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<");
1208 SLOG(LOG_DEBUG, TAG_TTSD, " ");
1213 int ttsd_dbus_server_setting_set_engine_setting(DBusConnection* conn, DBusMessage* msg)
1216 dbus_error_init(&err);
1223 dbus_message_get_args(msg, &err,
1224 DBUS_TYPE_INT32, &pid,
1225 DBUS_TYPE_STRING, &key,
1226 DBUS_TYPE_STRING, &value,
1229 SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> SETTING SET ENGINE SETTING");
1231 if (dbus_error_is_set(&err)) {
1232 SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] setting set engine option : Get arguments error (%s)\n", err.message);
1233 dbus_error_free(&err);
1234 ret = TTSD_ERROR_OPERATION_FAILED;
1236 SLOG(LOG_DEBUG, TAG_TTSD, "[IN] setting set engine option : pid(%d), key(%s), value(%s)\n", pid, key, value);
1237 ret = ttsd_server_setting_set_engine_setting(pid, key, value);
1241 reply = dbus_message_new_method_return(msg);
1243 if (NULL != reply) {
1244 dbus_message_append_args( reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
1247 SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] setting set engine option : result(%d)", ret);
1249 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting set engine option : result(%d)", ret);
1252 if (!dbus_connection_send(conn, reply, NULL)) {
1253 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting set engine option : Out Of Memory!\n");
1255 dbus_connection_flush(conn);
1256 dbus_message_unref(reply);
1258 SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting set engine option : fail to create reply message!!");
1261 SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<");
1262 SLOG(LOG_DEBUG, TAG_TTSD, " ");
1269 * Dbus Server functions for tts daemon intenal
1272 int ttsd_dbus_server_start_next_play(DBusMessage* msg)
1275 dbus_error_init(&err);
1279 dbus_message_get_args(msg, &err,
1280 DBUS_TYPE_INT32, &uid,
1283 SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> TTSD NEXT PLAY");
1285 if (dbus_error_is_set(&err)) {
1286 SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] ttsd 'start next play' : Get arguments error (%s)\n", err.message);
1287 dbus_error_free(&err);
1289 SLOG(LOG_DEBUG, TAG_TTSD, "[IN] ttsd 'start next play' : uid(%d) \n", uid);
1290 int ret = ttsd_server_start_next_play(uid);
1291 SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] ttsd 'start next play' : result(%d) \n", ret);
1294 SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<");
1295 SLOG(LOG_DEBUG, TAG_TTSD, " ");
1300 int ttsd_dbus_server_start_next_synthesis(DBusMessage* msg)
1303 dbus_error_init(&err);
1307 dbus_message_get_args(msg, &err,
1308 DBUS_TYPE_INT32, &uid,
1311 SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> TTSD NEXT SYNTHESIS");
1313 if (dbus_error_is_set(&err)) {
1314 SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] ttsd 'start next synthesis' : Get arguments error (%s)\n", err.message);
1315 dbus_error_free(&err);
1317 SLOG(LOG_DEBUG, TAG_TTSD, "[IN] ttsd 'start next synthesis' : uid(%d) \n", uid);
1318 int ret = ttsd_server_start_next_synthesis(uid);
1319 SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] ttsd 'start next synthesis' : result(%d) \n", ret);
1322 SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<");
1323 SLOG(LOG_DEBUG, TAG_TTSD, " ");