static int g_waiting_time = 3000;
static char *g_service_name;
+static char *g_service_object;
static char *g_service_interface;
int ttsdc_send_hello(int pid, int uid)
{
+ if (NULL == g_conn) {
+ SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Dbus connection is not available" );
+ return -1;
+ }
+
char service_name[64];
memset(service_name, 0, 64);
snprintf(service_name, 64, "%s%d", TTS_CLIENT_SERVICE_NAME, pid);
}
int ttsdc_send_message(int pid, int uid, int data, char *method)
-{
+{
+#if 0
+ if (NULL == g_conn) {
+ SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Dbus connection is not available" );
+ return -1;
+ }
+
char service_name[64];
memset(service_name, 0, 64);
snprintf(service_name, 64, "%s%d", TTS_CLIENT_SERVICE_NAME, pid);
}
dbus_message_unref(msg);
+#endif
+ char send_filename[64];
+ memset(send_filename, 0, 64);
+ snprintf(send_filename, 64, "/%s_%d", MESSAGE_FILE_PATH, pid);
+
+ FILE* fp;
+ fp = fopen(send_filename, "a+");
+ if (NULL == fp) {
+ SLOG(LOG_ERROR, get_tag(), "[File message ERROR] Fail to open message file");
+ return -1;
+ }
+ SLOG(LOG_DEBUG, get_tag(), "[File message] Write send file - %s, uid=%d, send_data=%d", method, uid, data);
+
+ fprintf(fp, "%s %d %d\n", method, uid, data);
+
+ fclose(fp);
+
return 0;
}
int ttsdc_send_error_message(int pid, int uid, int uttid, int reason)
{
+ if (NULL == g_conn) {
+ SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Dbus connection is not available" );
+ return -1;
+ }
+
char service_name[64];
memset(service_name, 0, 64);
snprintf(service_name, 64, "%s%d", TTS_CLIENT_SERVICE_NAME, pid);
return 0;
}
+#if 0
+int ttsd_send_start_next_synthesis()
+{
+ if (NULL == g_conn) {
+ SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Dbus connection is not available" );
+ return -1;
+ }
+
+ DBusMessage* msg;
+
+ msg = dbus_message_new_signal(
+ g_service_object, /* object name of the signal */
+ g_service_interface, /* interface name of the signal */
+ TTSD_SIGNAL_NEXT_SYNTHESIS); /* name of the signal */
+
+ if (NULL == msg) {
+ SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] >>>> Fail to make message for 'start next synthesis'");
+ return -1;
+ }
+
+ if (!dbus_connection_send(g_conn, msg, NULL)) {
+ SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] >>>> Fail to send message for 'start next synthesis'");
+ return -1;
+ }
+
+ SLOG(LOG_DEBUG, get_tag(), "[Dbus] >>>> Send message for 'start next synthesis'");
+
+ dbus_connection_flush(g_conn);
+ dbus_message_unref(msg);
+
+ return 0;
+}
+#endif
static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handler)
{
else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_PAUSE))
ttsd_dbus_server_pause(conn, msg);
+#if 0
+ /* daemon internal event*/
+ else if (dbus_message_is_signal(msg, g_service_interface, TTSD_SIGNAL_NEXT_SYNTHESIS))
+ ttsd_dbus_server_start_next_synthesis();
+#endif
/* setting event */
else if (dbus_message_is_method_call(msg, g_service_interface, TTS_SETTING_METHOD_HELLO))
return ECORE_CALLBACK_RENEW;
}
-int ttsd_dbus_open_connection(ttsd_mode_e mode)
+int ttsd_dbus_open_connection()
{
DBusError err;
dbus_error_init(&err);
if (TTSD_MODE_SCREEN_READER == ttsd_get_mode()) {
g_service_name = (char*)malloc(sizeof(char) * strlen(TTS_SR_SERVER_SERVICE_NAME) + 1);
+ g_service_object = (char*)malloc(sizeof(char) * strlen(TTS_SR_SERVER_SERVICE_OBJECT_PATH) + 1);
g_service_interface = (char*)malloc(sizeof(char) * strlen(TTS_SR_SERVER_SERVICE_INTERFACE) + 1);
strcpy(g_service_name, TTS_SR_SERVER_SERVICE_NAME);
+ strcpy(g_service_object, TTS_SR_SERVER_SERVICE_OBJECT_PATH);
strcpy(g_service_interface, TTS_SR_SERVER_SERVICE_INTERFACE);
} else if (TTSD_MODE_NOTIFICATION == ttsd_get_mode()) {
g_service_name = (char*)malloc(sizeof(char) * strlen(TTS_NOTI_SERVER_SERVICE_NAME) + 1);
+ g_service_object = (char*)malloc(sizeof(char) * strlen(TTS_NOTI_SERVER_SERVICE_OBJECT_PATH) + 1);
g_service_interface = (char*)malloc(sizeof(char) * strlen(TTS_NOTI_SERVER_SERVICE_INTERFACE) + 1);
strcpy(g_service_name, TTS_NOTI_SERVER_SERVICE_NAME);
+ strcpy(g_service_object, TTS_NOTI_SERVER_SERVICE_OBJECT_PATH);
strcpy(g_service_interface, TTS_NOTI_SERVER_SERVICE_INTERFACE);
} else {
g_service_name = (char*)malloc(sizeof(char) * strlen(TTS_SERVER_SERVICE_NAME) + 1);
+ g_service_object = (char*)malloc(sizeof(char) * strlen(TTS_SERVER_SERVICE_OBJECT_PATH) + 1);
g_service_interface = (char*)malloc(sizeof(char) * strlen(TTS_SERVER_SERVICE_INTERFACE) + 1);
strcpy(g_service_name, TTS_SERVER_SERVICE_NAME);
+ strcpy(g_service_object, TTS_SERVER_SERVICE_OBJECT_PATH);
strcpy(g_service_interface, TTS_SERVER_SERVICE_INTERFACE);
}
if (NULL != g_service_name)
free(g_service_name);
+ if (NULL != g_service_object)
+ free(g_service_object);
+
if (NULL != g_service_interface)
free(g_service_interface);
return 0;
}
+
+int ttsd_file_msg_open_connection(int pid)
+{
+ /* Make file for Inotify */
+ char send_filename[64];
+ memset(send_filename, 0, 64);
+ snprintf(send_filename, 64, "%s_%d", MESSAGE_FILE_PATH, pid);
+
+ FILE* fp;
+ fp = fopen(send_filename, "a+");
+ if (NULL == fp) {
+ SLOG(LOG_ERROR, get_tag(), "[File message ERROR] Fail to make message file");
+ return -1;
+ }
+ SLOG(LOG_DEBUG, get_tag(), "[File message] Make message file");
+ fclose(fp);
+ return 0;
+}
+
+int ttsd_file_msg_close_connection(int pid)
+{
+ /* delete inotify file */
+ char path[64];
+ memset(path, 0, 64);
+ snprintf(path, 64, "%s_%d", MESSAGE_FILE_PATH, pid);
+ if (0 == access(path, R_OK)) {
+ if (0 != remove(path)) {
+ SLOG(LOG_WARN, get_tag(), "[File message WARN] Fail to remove message file");
+ }
+ }
+ SLOG(LOG_DEBUG, get_tag(), "[File message] Delete message file");
+ return 0;
+}