2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 #include <telephony_network.h>
28 #define LOG_TAG "TIZEN_N_NETWORK_INFO_TEST"
30 static GMainLoop *event_loop;
32 char* convert_network_service_state_to_string(network_info_service_state_e network_service_state)
34 switch(network_service_state)
36 case NETWORK_INFO_SERVICE_STATE_IN_SERVICE:
38 case NETWORK_INFO_SERVICE_STATE_OUT_OF_SERVICE:
39 return "Out of service";
40 case NETWORK_INFO_SERVICE_STATE_EMERGENCY_ONLY:
41 return "Emergency only";
42 case NETWORK_INFO_SERVICE_STATE_RADIO_OFF:
49 void state_changed_cb(network_info_service_state_e status, void* user_data)
51 LOGI("[%s] Start telephony_service_changed_cb", __FUNCTION__);
53 LOGI("[%s] Service status: %s", __FUNCTION__, convert_network_service_state_to_string(status));
54 LOGI("[%s] user data: %s", __FUNCTION__, user_data);
56 LOGI("[%s] End telephony_service_changed_cb", __FUNCTION__);
57 g_main_loop_quit(event_loop);
62 if( network_info_set_service_state_changed_cb(state_changed_cb, "telephony_service_changed_test") == NETWORK_INFO_ERROR_NONE )
64 LOGI("[%s] Succeeded to add callback function", __FUNCTION__);
68 LOGE("[%s] Failed to add callback function", __FUNCTION__);
72 LOGI("[%s] If service status is changed, then callback function will be called", __FUNCTION__);
73 event_loop = g_main_loop_new(NULL, FALSE);
74 g_main_loop_run(event_loop);
76 if( network_info_unset_service_state_changed_cb() == NETWORK_INFO_ERROR_NONE )
78 LOGI("[%s] Succeeded to remove callback function", __FUNCTION__);
82 LOGE("[%s] Failed to remove callback function", __FUNCTION__);