Patch version revert to build other pakages
[platform/core/api/network-info.git] / test / network_info_roaming_state_changed_test.c
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17
18
19 #include <stdio.h>
20 #include <string.h>
21 #include <telephony_network.h>
22 #include <dlog.h>
23 #include <glib.h>
24
25 #ifdef LOG_TAG
26 #undef LOG_TAG
27 #endif
28 #define LOG_TAG "TIZEN_N_NETWORK_INFO_TEST"
29
30 static GMainLoop *event_loop;
31
32 static void roaming_state_changed_cb_impl(bool is_roaming, void* user_data)
33 {
34         LOGI("[%s] Start roaming_state_changed_cb_impl", __FUNCTION__);
35
36         LOGI("Roaming state - [%s]", (is_roaming == true) ? "ON" : "OFF");
37
38         LOGI("[%s] user data: %s", __FUNCTION__, user_data);
39
40         LOGI("[%s] End roaming_state_changed_cb_impl", __FUNCTION__);
41         g_main_loop_quit(event_loop);
42 }
43
44 int main()
45 {
46         if( network_info_set_roaming_state_changed_cb(roaming_state_changed_cb_impl, "roaming_state_changed_test") == NETWORK_INFO_ERROR_NONE )
47         {
48                 LOGI("[%s] Succeeded to add callback function", __FUNCTION__);
49         }
50         else
51         {
52                 LOGE("[%s] Failed to add callback function", __FUNCTION__);
53                 return -1;
54         }
55
56         LOGI("[%s] If roaming state is changed, then callback function will be called", __FUNCTION__);
57         event_loop = g_main_loop_new(NULL, FALSE);
58         g_main_loop_run(event_loop);
59
60         if( network_info_unset_roaming_state_changed_cb() == NETWORK_INFO_ERROR_NONE )
61         {
62                 LOGI("[%s] Succeeded to remove callback function", __FUNCTION__);
63         }
64         else
65         {
66                 LOGE("[%s] Failed to remove callback function", __FUNCTION__);
67                 return -1;
68         }
69
70         return 0;
71 }