Initialize Tizen 2.3
[framework/telephony/libslp-tapi.git] / wearable / TC / testcase / util_common.c
1 /*
2  * libslp-tapi
3  *
4  * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Ja-young Gu <jygu@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20
21 #include <glib.h>
22 #include "util_common.h"
23
24 static GMainLoop *g_loop = NULL;
25 static GMainContext *g_ctx = NULL;
26
27 void util_init_loop ()
28 {
29         g_ctx = g_main_context_new ();
30         g_main_context_push_thread_default (g_ctx);
31         g_loop = g_main_loop_new (g_ctx, FALSE);
32 }
33
34 void util_free_loop ()
35 {
36         g_main_context_pop_thread_default (g_ctx);
37         g_main_loop_unref (g_loop);
38         g_main_context_unref (g_ctx);
39
40         g_ctx = NULL;
41         g_loop = NULL;
42
43 }
44
45 void util_start_loop ()
46 {
47         g_main_loop_run (g_loop);
48 }
49
50 void util_stop_loop ()
51 {
52         g_main_loop_quit (g_loop);
53 }