2 * Copyright 2012-2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include "MsgHelper.h"
23 #include "MsgUtilFile.h"
24 #include "MsgCppTypes.h"
27 static GMainLoop *loop;
29 static gboolean _worker_done(void* data)
31 if (g_main_loop_is_running(loop))
32 g_main_loop_quit(loop);
37 // may called by threads
40 g_idle_add(_worker_done,NULL);
43 int main(int argc, char** argv)
46 MSG_DEBUG("############### Start msg_helper ###############");
48 #if !GLIB_CHECK_VERSION(2, 31, 0)
56 MSG_DEBUG("No arguments to run msg_helper.");
60 MSG_DEBUG("argv[0] [%s] ", argv[0]);
62 if(g_strcmp0(argv[0], MSG_NORMAL_SOUND_START) == 0)
64 MsgSoundPlayStart(false);
67 if(g_strcmp0(argv[0], MSG_EMERGENCY_SOUND_START) == 0)
69 MsgSoundPlayStart(true);
72 else if(g_strcmp0(argv[0],MSG_SOUND_STOP) == 0)
79 loop = g_main_loop_new(NULL, FALSE);
81 if (MsgSensorConnect() == MSG_SUCCESS)
82 if (MsgRegSensorCB(&worker_done) != MSG_SUCCESS)
83 MsgSensorDisconnect();
87 MSG_DEBUG("Waiting for working jobs to be finished!!!");
90 g_main_loop_run(loop);
94 MSG_DEBUG("Fail to create g_main_loop!!!");
95 MsgSensorDisconnect();