diff options
author | Jean-Benoit MARTIN <jean-benoit.martin@open.eurogiciel.org> | 2014-08-26 16:28:49 +0200 |
---|---|---|
committer | Jean-Benoit MARTIN <jean-benoit.martin@open.eurogiciel.org> | 2014-09-30 14:09:14 +0200 |
commit | 561e2cae46730cdbadf485dfa7ab449e60524bae (patch) | |
tree | 5d2127e248aac6750950cbd2352976729baa4bc7 /server/thumb-server.c | |
parent | 1b8cf739c37f1103b7fa613b788f0d5e32f5bad9 (diff) | |
download | libmedia-thumbnail-561e2cae46730cdbadf485dfa7ab449e60524bae.tar.gz libmedia-thumbnail-561e2cae46730cdbadf485dfa7ab449e60524bae.tar.bz2 libmedia-thumbnail-561e2cae46730cdbadf485dfa7ab449e60524bae.zip |
Multiuser featuretizen_3.0.m14.3_ivi_releasetizen_3.0.2014.q3_common_releasesubmit/tizen_mobile/20141120.000000submit/tizen_ivi/20141007.222222submit/tizen_common/20141001.125034accepted/tizen/ivi/20141008.075209accepted/tizen/common/20141001.131249tizen_3.0.m14.3_ivitizen_3.0.2014.q3_commonaccepted/tizen_3.0.m14.3_iviaccepted/tizen_3.0.2014.q3_common
Use User UID to write or read into database
Use Unix socket
Fix-Tizen: TC-1482
Change-Id: I557a28de1650c9af1a30ef7d795d64464eaa2e8f
Signed-off-by: Jean-Benoit MARTIN <jean-benoit.martin@open.eurogiciel.org>
Diffstat (limited to 'server/thumb-server.c')
-rwxr-xr-x | server/thumb-server.c | 67 |
1 files changed, 29 insertions, 38 deletions
diff --git a/server/thumb-server.c b/server/thumb-server.c index db17571..bed8711 100755 --- a/server/thumb-server.c +++ b/server/thumb-server.c @@ -49,42 +49,26 @@ static void _media_thumb_signal_handler(void *user_data) thumb_dbg("Singal Hander for HEYNOTI \"power_off_start\""); if (g_thumb_server_mainloop) - g_main_loop_quit(g_thumb_server_mainloop); - else + ecore_main_loop_quit(); + else exit(1); return; } - -void* gmainloop_thread(void *data) +int main() { - GSource *source = NULL; - GIOChannel *channel = (GIOChannel *)data; - GMainContext *context = NULL; - - g_thumb_server_mainloop = g_main_loop_new(context, FALSE); - context = g_main_loop_get_context(g_thumb_server_mainloop); - - source = g_io_create_watch(channel, G_IO_IN); + + int sockfd = -1; - /* Set callback to be called when socket is readable */ - g_source_set_callback(source, (GSourceFunc)_thumb_server_read_socket, NULL, NULL); - g_source_attach(source, context); - - g_main_loop_run(g_thumb_server_mainloop); - - pthread_exit(NULL); -} + GSource *source = NULL; + GIOChannel *channel = NULL; + GMainContext *context = NULL; -int main() -{ /*heynoti for power off*/ int err = 0; int heynoti_id = heynoti_init(); - int sockfd = -1; - if (heynoti_id < 0) { thumb_err("heynoti_init failed"); } else { @@ -98,12 +82,6 @@ int main() } } - /* Create and bind new UDP socket */ - if (!_thumb_server_prepare_socket(&sockfd)) { - thumb_err("Failed to create socket\n"); - return -1; - } - /* Set VCONFKEY_SYSMAN_MMC_FORMAT callback to get noti for SD card format */ err = vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_FORMAT, (vconf_callback_fn) _thumb_daemon_vconf_cb, NULL); if (err == -1) @@ -114,6 +92,27 @@ int main() if (err == -1) thumb_err("vconf_notify_key_changed : %s fails", VCONFKEY_SYSMAN_MMC_STATUS); + /* Create and bind new UDP socket */ + if (!_thumb_server_prepare_socket(&sockfd)) { + thumb_err("Failed to create socket\n"); + return -1; + } + + context = g_main_context_default (); + + /* Create new channel to watch udp socket */ + channel = g_io_channel_unix_new(sockfd); + source = g_io_create_watch(channel, G_IO_IN); + + /* Set callback to be called when socket is readable */ + g_source_set_callback(source, (GSourceFunc)_thumb_server_read_socket, NULL, NULL); + g_source_attach(source, context); + + GSource *source_evas_init = NULL; + source_evas_init = g_idle_source_new (); + g_source_set_callback (source_evas_init, _thumb_daemon_start_jobs, NULL, NULL); + g_source_attach (source_evas_init, context); + /* Would be used when glib 2.32 is installed GSource *sig_handler_src = NULL; sig_handler_src = g_unix_signal_source_new (SIGTERM); @@ -122,13 +121,6 @@ int main() */ ecore_evas_init(); - GIOChannel *channel = NULL; - /* Create new channel to watch udp socket */ - channel = g_io_channel_unix_new(sockfd); - - static pthread_t thread; - pthread_create(&thread, NULL, gmainloop_thread, channel); - thumb_dbg("************************************"); thumb_dbg("*** Thumbnail server is running ***"); thumb_dbg("************************************"); @@ -140,7 +132,6 @@ int main() g_io_channel_shutdown(channel, FALSE, NULL); g_io_channel_unref(channel); _thumb_daemon_finish_jobs(); - g_main_loop_unref(g_thumb_server_mainloop); return 0; } |