Patch version revert to build other pakages
[platform/core/api/network-info.git] / test / network_info_cell_id_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 #include <stdio.h>
19 #include <string.h>
20 #include <telephony_network.h>
21 #include <dlog.h>
22 #include <glib.h>
23
24 #ifdef LOG_TAG
25 #undef LOG_TAG
26 #endif
27 #define LOG_TAG "TIZEN_N_NETWORK_INFO_TEST"
28
29 static GMainLoop *event_loop;
30
31 static void cell_id_changed_cb_impl(int cell_id, void* user_data)
32 {
33         LOGI("[%s] Start cell_id_changed_cb_impl", __FUNCTION__);
34
35         LOGI("[%s] Cell ID: %d", __FUNCTION__, cell_id);
36         LOGI("[%s] user data: %s", __FUNCTION__, user_data);
37
38         LOGI("[%s] End cell_id_changed_cb_impl", __FUNCTION__);
39         g_main_loop_quit(event_loop);
40 }
41
42 int main()
43 {
44         if( network_info_set_cell_id_changed_cb(cell_id_changed_cb_impl, "cell_id_changed_test") == NETWORK_INFO_ERROR_NONE )
45         {
46                 LOGI("[%s] Succeeded to set callback function", __FUNCTION__);
47         }
48         else
49         {
50                 LOGE("[%s] Failed to set callback function", __FUNCTION__);
51                 return -1;
52         }
53
54         LOGI("[%s] If cell id is changed, then callback function will be called", __FUNCTION__);
55         event_loop = g_main_loop_new(NULL, FALSE);
56         g_main_loop_run(event_loop);
57
58         if( network_info_unset_cell_id_changed_cb() == NETWORK_INFO_ERROR_NONE )
59         {
60                 LOGI("[%s] Succeeded to unset callback function", __FUNCTION__);
61         }
62         else
63         {
64                 LOGE("[%s] Failed to unset callback function", __FUNCTION__);
65                 return -1;
66         }
67
68         return 0;
69 }