update tizen source
[framework/messaging/msg-service.git] / msg_helper / main.cpp
1 /*
2 *
3 * Copyright (c) 2000-2012 Samsung Electronics Co., Ltd. All Rights Reserved.
4 *
5 * This file is part of msg-service.
6 *
7 * Contact: Jaeyun Jeong <jyjeong@samsung.com>
8 *          Sangkoo Kim <sangkoo.kim@samsung.com>
9 *          Seunghwan Lee <sh.cat.lee@samsung.com>
10 *          SoonMin Jung <sm0415.jung@samsung.com>
11 *          Jae-Young Lee <jy4710.lee@samsung.com>
12 *          KeeBum Kim <keebum.kim@samsung.com>
13 *
14 * PROPRIETARY/CONFIDENTIAL
15 *
16 * This software is the confidential and proprietary information of
17 * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
18 * disclose such Confidential Information and shall use it only in
19 * accordance with the terms of the license agreement you entered
20 * into with SAMSUNG ELECTRONICS.
21 *
22 * SAMSUNG make no representations or warranties about the suitability
23 * of the software, either express or implied, including but not limited
24 * to the implied warranties of merchantability, fitness for a particular
25 * purpose, or non-infringement. SAMSUNG shall not be liable for any
26 * damages suffered by licensee as a result of using, modifying or
27 * distributing this software or its derivatives.
28 *
29 */
30
31 #include <stdio.h>
32 #include <glib.h>
33 #include <sys/time.h>
34 #include <stdlib.h>
35
36 #include "MsgHelper.h"
37 #include "MsgUtilFile.h"
38 #include "MsgCppTypes.h"
39 #include "MsgDebug.h"
40
41 static GMainLoop *loop;
42
43 static gboolean _worker_done(void* data)
44 {
45         if (g_main_loop_is_running(loop))
46                 g_main_loop_quit(loop);
47
48         return 0;
49 }
50
51 // may called by threads
52 void worker_done()
53 {
54         g_idle_add(_worker_done,NULL);
55 }
56
57 int main(int argc, char** argv)
58 {
59
60         MSG_DEBUG("############### Start msg_helper ###############");
61
62         g_thread_init(NULL);
63
64         bool notEnd = false;
65
66         if(argc < 1)
67         {
68                 MSG_DEBUG("No arguments to run msg_helper.");
69                 return 0;
70         }
71
72         MSG_DEBUG("argv[0] [%s] ", argv[0]);
73
74         if(strcmp(argv[0],MSG_SOUND_START)==0)
75         {
76                 MsgSoundPlayStart();
77                 notEnd = true;
78         }
79         else if(strcmp(argv[0],MSG_SOUND_STOP)==0)
80         {
81                 MsgSoundPlayStop();
82         }
83
84         if(notEnd)
85         {
86                 loop = g_main_loop_new(NULL, FALSE);
87
88
89                 if (loop != NULL)
90                 {
91                         MSG_DEBUG("Waiting for working jobs to be finished!!!");
92
93                         // Run GMainLoop
94                         g_main_loop_run(loop);
95                 }
96                 else
97                 {
98                         MSG_DEBUG("Fail to create g_main_loop!!!");
99                 }
100         }
101
102         return 0;
103 }