Merge with master branch
authorKwangyoun Kim <ky85.kim@samsung.com>
Wed, 20 Mar 2013 10:47:34 +0000 (19:47 +0900)
committerKwangyoun Kim <ky85.kim@samsung.com>
Wed, 20 Mar 2013 10:47:34 +0000 (19:47 +0900)
Change-Id: I35dce97cc44b15252224bdd623e114625e53b4d4

1  2 
changelog
client/tts_dbus.c
server/ttsd_dbus.c
server/ttsd_player.h
server/ttsd_server.c

diff --cc changelog
index dfbfb49d99cc57bea86e89f23471fc672ca8f559,0cbfdc12c867c17f82a65cfceff43e35a7853ed8..0cbfdc12c867c17f82a65cfceff43e35a7853ed8
mode 100755,100644..100755
+++ b/changelog
index 7f5eca1de096fe92fe6a7ff59bb6f46e39d3f476,eb5690ef37d8468ae9e43acb3a2fb6e6c0a72916..501c5c3cb8822a055081131f488b2c67b61b5aed
@@@ -940,3 -947,130 +947,130 @@@ int tts_dbus_request_pause(int uid
  
        return result;
  }
 -}
+ static Eina_Bool inotify_event_callback(void* data, Ecore_Fd_Handler *fd_handler)
+ {
+       SLOG(LOG_DEBUG, TAG_TTSC, "===== [File message] Inotify event call");
+       int length;
+       char buffer[sizeof(struct inotify_event) * BUFFER_SIZE];
+       length = read(g_fd_noti, buffer, (sizeof(struct inotify_event) * BUFFER_SIZE));
+       if (0 > length) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[File message] Empty Inotify event");
+               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+               SLOG(LOG_DEBUG, TAG_TTSC, " ");
+               return ECORE_CALLBACK_RENEW; 
+       }
+       bool is_empty_file = true;
+       char filename[64];
+       memset(filename, 0, 64);
+       snprintf(filename, 64, "%s_%d", MESSAGE_FILE_PATH, getpid());
+       FILE *fp;
+       int i = 0;
+       while (i < length) {
+               char text[256];
+               char msg[256];
+               int uid, send_data;
+               struct inotify_event *event = (struct inotify_event *)&buffer[i];
+               i = i + sizeof(struct inotify_event) + event->len;
+               if (IN_CLOSE_WRITE == event->mask) {
+                       fp = fopen(filename, "r");
+                       if (NULL == fp) {
+                               SLOG(LOG_ERROR, TAG_TTSC, "[File message ERROR] open file failed");
+                               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+                               SLOG(LOG_DEBUG, TAG_TTSC, " ");
+                               return ECORE_CALLBACK_RENEW;
+                       }
+                       while (NULL != fgets(text, 256, fp)) {
+                               if (0 > sscanf(text, "%s %d %d", msg, &uid, &send_data)) {
+                                       SLOG(LOG_ERROR, TAG_TTSC, "[File message] sscanf failed");
+                                       continue;
+                               }
+                               SLOG(LOG_DEBUG, TAG_TTSC, "[File message] message - %s, uid - %d, send_data - %d", msg, uid, send_data);
+                               is_empty_file = false;
+                               int uttid;
+                               if (!strcmp(TTSD_METHOD_UTTERANCE_STARTED, msg)) {
+                                       uttid = send_data;
+                                       SLOG(LOG_DEBUG, TAG_TTSC, "<<<< Get Utterance started message : uid(%d), uttid(%d) \n", uid, uttid);
+                                       __tts_cb_utt_started(uid, uttid);
+                               } else if (!strcmp(TTSD_METHOD_UTTERANCE_COMPLETED, msg)) {
+                                       uttid = send_data;
+                                       SLOG(LOG_DEBUG, TAG_TTSC, "<<<< Get Utterance completed message : uid(%d), uttid(%d) \n", uid, uttid);
+                                       __tts_cb_utt_completed(uid, uttid);
+                               } else if (!strcmp(TTSD_METHOD_SET_STATE, msg)) {
+                                       int state = send_data;
+                                       SLOG(LOG_DEBUG, TAG_TTSC, "<<<< Get state change : uid(%d) , state(%d)", uid, state);
+                                       __tts_cb_set_state(uid, state);
+                               }
+                       }
+                       fclose(fp);
+               } else {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[File message] Undefined event");
+               }
+       }
+       if (true == is_empty_file)
+               return ECORE_CALLBACK_PASS_ON;
+       fp = fopen(filename, "w+");
+       if (NULL == fp) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[File message ERROR] open file failed");
+       } else {
+               fclose(fp);
+       }
+       SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+       SLOG(LOG_DEBUG, TAG_TTSC, " ");
+       return ECORE_CALLBACK_PASS_ON;
+ }
+ int tts_file_msg_open_connection()
+ {
+       /* get file notification handler */
+       int fd;
+       int wd;
+       fd = inotify_init();
+       if (fd < 0) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[File message ERROR] Fail get inotify_fd");
+               return -1;
+       }
+       g_fd_noti = fd;
+       int pid = getpid();
+       char path[64];
+       memset(path, 0, 64);
+       snprintf(path, 64, "%s_%d", MESSAGE_FILE_PATH, pid);
+       wd = inotify_add_watch(fd, path, IN_CLOSE_WRITE);
+       g_wd_noti = wd;
+       g_fd_handler_noti = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)inotify_event_callback, NULL, NULL, NULL);                
+       if (NULL == g_fd_handler_noti) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[File message ERROR] Fail to get handler_noti");
+               return -1;
+       }
+       return 0;
+ }
+ int tts_file_msg_close_connection()
+ {
+       /* del inotify variable */
+       ecore_main_fd_handler_del(g_fd_handler_noti);
+       inotify_rm_watch(g_fd_noti, g_wd_noti);
+       close(g_fd_noti);
+       return 0;
++}
index 62bbb955b5f8cced70459d40f7534c8d0126f9af,8bcd52cf1fec635cefa67c3077df120ac3b0283d..dbaa4abdfdf1a70a0aaa2d1688c645bb80677ff5
@@@ -221,11 -287,12 +287,16 @@@ static Eina_Bool listener_event_callbac
  
        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
  
 +      /* daemon internal event*/
 +      else if (dbus_message_is_signal(msg, g_service_interface, TTSD_SIGNAL_NEXT_SYNTHESIS)) 
 +              ttsd_dbus_server_start_next_synthesis();
 +
        /* setting event */
        else if (dbus_message_is_method_call(msg, g_service_interface, TTS_SETTING_METHOD_HELLO))
                ttsd_dbus_server_hello(conn, msg);
index 9a37340b6c790c0c8e5178a80c3036e0fa763daf,cc8d2f1de0856bccb88cbb5267e596b131c7517e..cc8d2f1de0856bccb88cbb5267e596b131c7517e
mode 100755,100644..100755
index 4575d12e5e520729ec3f520d7d14e170b732e757,10dc01ee12b4dbe00ea87c1d4ebe91e57bf67794..10dc01ee12b4dbe00ea87c1d4ebe91e57bf67794
mode 100755,100644..100755