From: Dongchul Lim Date: Mon, 7 Apr 2014 10:45:04 +0000 (+0900) Subject: Initial refactoring merge X-Git-Tag: accepted/tizen/generic/20140408.095612^0 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fapi%2Fnetwork-info.git;a=commitdiff_plain;h=9ada3a5aab5c2eb907c3222e2d23107eda077a93 Initial refactoring merge Change-Id: I1e24e2da1b254bdee6951f756f28acd2329b14ae --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d863ba..e72d19e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,7 +61,7 @@ FOREACH(flag ${${fw_name}_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") IF("${ARCH}" STREQUAL "arm") @@ -103,6 +103,7 @@ CONFIGURE_FILE( @ONLY ) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) +ADD_SUBDIRECTORY(test) IF(UNIX) diff --git a/packaging/capi-telephony-network-info.spec b/packaging/capi-telephony-network-info.spec index 9a698b1..5673e9d 100644 --- a/packaging/capi-telephony-network-info.spec +++ b/packaging/capi-telephony-network-info.spec @@ -1,7 +1,11 @@ +%define major 3 +%define minor 0 +%define patchlevel 1 + Name: capi-telephony-network-info Summary: A Telephony Network Information library in Tizen Native API -Version: 0.1.0 -Release: 11 +Version: %{major}.%{minor}.%{patchlevel} +Release: 1 Group: C API License: Apache-2.0 Source0: %{name}-%{version}.tar.gz diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100755 index 0000000..97657b6 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,20 @@ +SET(fw_test "${fw_name}-test") + +INCLUDE(FindPkgConfig) +pkg_check_modules(${fw_test} REQUIRED glib-2.0) +FOREACH(flag ${${fw_test}_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall") + +#ADD_EXECUTABLE("system-sensor" system-sensor.c) +#TARGET_LINK_LIBRARIES("system-sensor" ${fw_name} ${${fw_test}_LDFLAGS}) + +aux_source_directory(. sources) +FOREACH(src ${sources}) + GET_FILENAME_COMPONENT(src_name ${src} NAME_WE) + MESSAGE("${src_name}") + ADD_EXECUTABLE(${src_name} ${src}) + TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS}) +ENDFOREACH() diff --git a/test/network_info_cell_id_changed_test.c b/test/network_info_cell_id_changed_test.c new file mode 100644 index 0000000..7e825c8 --- /dev/null +++ b/test/network_info_cell_id_changed_test.c @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include +#include +#include +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "TIZEN_N_NETWORK_INFO_TEST" + +static GMainLoop *event_loop; + +static void cell_id_changed_cb_impl(int cell_id, void* user_data) +{ + LOGI("[%s] Start cell_id_changed_cb_impl", __FUNCTION__); + + LOGI("[%s] Cell ID: %d", __FUNCTION__, cell_id); + LOGI("[%s] user data: %s", __FUNCTION__, user_data); + + LOGI("[%s] End cell_id_changed_cb_impl", __FUNCTION__); + g_main_loop_quit(event_loop); +} + +int main() +{ + if( network_info_set_cell_id_changed_cb(cell_id_changed_cb_impl, "cell_id_changed_test") == NETWORK_INFO_ERROR_NONE ) + { + LOGI("[%s] Succeeded to set callback function", __FUNCTION__); + } + else + { + LOGE("[%s] Failed to set callback function", __FUNCTION__); + return -1; + } + + LOGI("[%s] If cell id is changed, then callback function will be called", __FUNCTION__); + event_loop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(event_loop); + + if( network_info_unset_cell_id_changed_cb() == NETWORK_INFO_ERROR_NONE ) + { + LOGI("[%s] Succeeded to unset callback function", __FUNCTION__); + } + else + { + LOGE("[%s] Failed to unset callback function", __FUNCTION__); + return -1; + } + + return 0; +} diff --git a/test/network_info_get_cell_id_test.c b/test/network_info_get_cell_id_test.c new file mode 100644 index 0000000..9c8fa0a --- /dev/null +++ b/test/network_info_get_cell_id_test.c @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "TIZEN_N_NETWORK_INFO_TEST" + + +int main() +{ + int ret = 0; + int cell_id = 0; + int ret_value = network_info_get_cell_id(&cell_id); + + switch(ret_value) + { + case NETWORK_INFO_ERROR_NONE: + LOGI("[%s] Cell ID is %d", __FUNCTION__, cell_id); + ret = 0; + break; + case NETWORK_INFO_ERROR_INVALID_PARAMETER: + LOGI("[%s] Invalid parameter", __FUNCTION__); + ret = -1; + break; + case NETWORK_INFO_ERROR_OUT_OF_SERVICE: + LOGI("[%s] Out of service\n", __FUNCTION__); + ret = -1; + break; + case NETWORK_INFO_ERROR_OPERATION_FAILED: + LOGI("[%s] Cannot find Cell ID value\n", __FUNCTION__); + ret = -1; + break; + default: + LOGI("[%s] Unexpected return value\n", __FUNCTION__); + ret = -1; + break; + } + + return ret; +} diff --git a/test/network_info_get_lac_test.c b/test/network_info_get_lac_test.c new file mode 100644 index 0000000..eb06de7 --- /dev/null +++ b/test/network_info_get_lac_test.c @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "TIZEN_N_NETWORK_INFO_TEST" + + +int main() +{ + int ret = 0; + int lac = 0; + int ret_value = network_info_get_lac(&lac); + + switch(ret_value) + { + case NETWORK_INFO_ERROR_NONE: + LOGI("[%s] Location Area Code is %d", __FUNCTION__, lac); + ret = 0; + break; + case NETWORK_INFO_ERROR_INVALID_PARAMETER: + LOGI("[%s] Invalid parameter", __FUNCTION__); + ret = -1; + break; + case NETWORK_INFO_ERROR_OUT_OF_SERVICE: + LOGI("[%s] Out of service", __FUNCTION__); + ret = -1; + break; + case NETWORK_INFO_ERROR_OPERATION_FAILED: + LOGI("[%s] Cannot find Location Area Code value", __FUNCTION__); + ret = -1; + break; + default: + LOGI("[%s] Unexpected return value", __FUNCTION__); + ret = -1; + break; + } + + return ret; +} diff --git a/test/network_info_get_mcc_test.c b/test/network_info_get_mcc_test.c new file mode 100644 index 0000000..e35d5e1 --- /dev/null +++ b/test/network_info_get_mcc_test.c @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include +#include +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "TIZEN_N_NETWORK_INFO_TEST" + + +int main() +{ + int ret = 0; + char* mcc = NULL; + int ret_value = network_info_get_mcc(&mcc); + + switch(ret_value) + { + case NETWORK_INFO_ERROR_NONE: + LOGI("[%s] Mobile Country Code is %s", __FUNCTION__, mcc); + ret = 0; + free(mcc); + break; + case NETWORK_INFO_ERROR_INVALID_PARAMETER: + LOGI("[%s] Invalid parameter", __FUNCTION__); + ret = -1; + break; + case NETWORK_INFO_ERROR_OUT_OF_MEMORY: + LOGI("[%s] Out of memory", __FUNCTION__); + ret = -1; + break; + case NETWORK_INFO_ERROR_OUT_OF_SERVICE: + LOGI("[%s] Out of service", __FUNCTION__); + ret = -1; + break; + case NETWORK_INFO_ERROR_OPERATION_FAILED: + LOGI("[%s] Cannot find Mobile Country Code value", __FUNCTION__); + ret = -1; + break; + default: + LOGI("[%s] Unexpected return value", __FUNCTION__); + ret = -1; + break; + } + + + return ret; +} diff --git a/test/network_info_get_mnc_test.c b/test/network_info_get_mnc_test.c new file mode 100644 index 0000000..fd99251 --- /dev/null +++ b/test/network_info_get_mnc_test.c @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include +#include +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "TIZEN_N_NETWORK_INFO_TEST" + + +int main() +{ + int ret = 0; + char* mnc = NULL; + int ret_value = network_info_get_mnc(&mnc); + + switch(ret_value) + { + case NETWORK_INFO_ERROR_NONE: + LOGI("[%s] Mobile Network Code is %s", __FUNCTION__, mnc); + ret = 0; + free(mnc); + break; + case NETWORK_INFO_ERROR_INVALID_PARAMETER: + LOGI("[%s] Invalid parameter", __FUNCTION__); + ret = -1; + break; + case NETWORK_INFO_ERROR_OUT_OF_MEMORY: + printf("[%s] Out of memory", __FUNCTION__); + ret = -1; + break; + case NETWORK_INFO_ERROR_OUT_OF_SERVICE: + LOGI("[%s] Out of service", __FUNCTION__); + ret = -1; + break; + case NETWORK_INFO_ERROR_OPERATION_FAILED: + LOGI("[%s] Cannot find Mobile Network Code value", __FUNCTION__); + ret = -1; + break; + default: + LOGI("[%s] Unexpected return value", __FUNCTION__); + ret = -1; + break; + } + + return ret; +} diff --git a/test/network_info_get_provider_name_test.c b/test/network_info_get_provider_name_test.c new file mode 100644 index 0000000..c135aaf --- /dev/null +++ b/test/network_info_get_provider_name_test.c @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include +#include +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "TIZEN_N_NETWORK_INFO_TEST" + +int main() +{ + int ret = 0; + char* provider_name = NULL; + int ret_value = network_info_get_provider_name(&provider_name); + + switch(ret_value) + { + case NETWORK_INFO_ERROR_NONE: + LOGI("Provider name is %s", provider_name); + ret = 0; + free(provider_name); + break; + case NETWORK_INFO_ERROR_INVALID_PARAMETER: + LOGI("Invalid parameter"); + ret = -1; + break; + case NETWORK_INFO_ERROR_OUT_OF_SERVICE: + LOGI("Out of service"); + ret = -1; + break; + case NETWORK_INFO_ERROR_OPERATION_FAILED: + LOGI("Cannot find provider name value"); + ret = -1; + break; + default: + LOGI("Unexpected return value"); + ret = -1; + break; + } + + return ret; +} diff --git a/test/network_info_get_rssi_test.c b/test/network_info_get_rssi_test.c new file mode 100644 index 0000000..3a8e3e5 --- /dev/null +++ b/test/network_info_get_rssi_test.c @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "TIZEN_N_NETWORK_INFO_TEST" + +int main() +{ + int ret = 0; + network_info_rssi_e rssi = NETWORK_INFO_RSSI_0; + int ret_value = network_info_get_rssi(&rssi); + + switch(ret_value) + { + case NETWORK_INFO_ERROR_NONE: + LOGI("Received Signal Strength Indicator is TELEPHONY_RSSI_%d", rssi); + ret = 0; + break; + case NETWORK_INFO_ERROR_INVALID_PARAMETER: + LOGI("Invalid parameter"); + ret = -1; + break; + case NETWORK_INFO_ERROR_OUT_OF_SERVICE: + LOGI("Out of service"); + ret = -1; + break; + case NETWORK_INFO_ERROR_OPERATION_FAILED: + LOGI("Cannot find Received Signal Strength Indicator value"); + ret = -1; + break; + default: + LOGI("Unexpected return value"); + ret = -1; + break; + } + + return ret; +} diff --git a/test/network_info_get_state_test.c b/test/network_info_get_state_test.c new file mode 100644 index 0000000..d0ad0d0 --- /dev/null +++ b/test/network_info_get_state_test.c @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "TIZEN_N_NETWORK_INFO_TEST" + +int main() +{ + int ret = 0; + network_info_service_state_e network_service_state = NETWORK_INFO_SERVICE_STATE_OUT_OF_SERVICE; + int ret_value = network_info_get_service_state(&network_service_state); + + switch(ret_value) + { + case NETWORK_INFO_ERROR_NONE: + switch(network_service_state) + { + case NETWORK_INFO_SERVICE_STATE_IN_SERVICE: + LOGI("Service status is NETWORK_INFO_SERVICE_STATE_IN_SERVICE."); + break; + case NETWORK_INFO_SERVICE_STATE_OUT_OF_SERVICE: + LOGI("Service status is NETWORK_INFO_SERVICE_STATE_OUT_OF_SERVICE."); + break; + case NETWORK_INFO_SERVICE_STATE_EMERGENCY_ONLY: + LOGI("Service status is TELEPHONY_NETWORK_EMERGENCY_ONLY."); + break; + case NETWORK_INFO_SERVICE_STATE_RADIO_OFF: + LOGI("Service status is TELEPHONY_NETWORK_RADIO_OFF."); + break; + default: + LOGI("Service type is unknown.\n"); + break; + } + ret = 0; + break; + case NETWORK_INFO_ERROR_INVALID_PARAMETER: + LOGI("Invalid parameter"); + ret = -1; + break; + case NETWORK_INFO_ERROR_OPERATION_FAILED: + LOGI("Cannot find service status."); + ret = -1; + break; + default: + LOGI("Unexpected return value."); + ret = -1; + break; + } + + return ret; +} diff --git a/test/network_info_get_type_test.c b/test/network_info_get_type_test.c new file mode 100644 index 0000000..c32438a --- /dev/null +++ b/test/network_info_get_type_test.c @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "TIZEN_N_NETWORK_INFO_TEST" + +int main() +{ + int ret = 0; + network_info_type_e network_type = NETWORK_INFO_TYPE_UNKNOWN; + int ret_value = network_info_get_type(&network_type); + + switch(ret_value) + { + case NETWORK_INFO_ERROR_NONE: + switch(network_type) + { + case NETWORK_INFO_TYPE_GSM: + LOGI("Network type is NETWORK_INFO_TYPE_GSM."); + break; + case NETWORK_INFO_TYPE_GPRS: + LOGI("Network type is NETWORK_INFO_TYPE_GPRS."); + break; + case NETWORK_INFO_TYPE_EDGE: + LOGI("Network type is NETWORK_INFO_TYPE_EDGE."); + break; + case NETWORK_INFO_TYPE_UMTS: + LOGI("Network type is NETWORK_INFO_TYPE_UMTS."); + break; + case NETWORK_INFO_TYPE_HSDPA: + LOGI("Network type is NETWORK_INFO_TYPE_HSDPA."); + break; + default: + LOGI("Unexpected network type."); + break; + } + ret = 0; + break; + case NETWORK_INFO_ERROR_INVALID_PARAMETER: + LOGI("Invalid parameter"); + ret = -1; + break; + case NETWORK_INFO_ERROR_OUT_OF_SERVICE: + LOGI("Out of service"); + ret = -1; + break; + case NETWORK_INFO_ERROR_OPERATION_FAILED: + LOGI("Cannot find network type."); + ret = -1; + break; + default: + LOGI("Unexpected return value.\n"); + ret = -1; + break; + } + + return ret; +} diff --git a/test/network_info_is_roaming_test.c b/test/network_info_is_roaming_test.c new file mode 100644 index 0000000..42df37f --- /dev/null +++ b/test/network_info_is_roaming_test.c @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "TIZEN_N_NETWORK_INFO_TEST" + +int main() +{ + int ret = 0; + bool is_roaming = false; + int ret_value = network_info_is_roaming(&is_roaming); + + switch(ret_value) + { + case NETWORK_INFO_ERROR_NONE: + LOGI("Roaming state - [%s]", (is_roaming == true) ? "ON" : "OFF"); + ret = 0; + break; + case NETWORK_INFO_ERROR_INVALID_PARAMETER: + LOGI("Invalid parameter"); + ret = -1; + break; + case NETWORK_INFO_ERROR_OUT_OF_SERVICE: + LOGI("Out of service"); + ret = -1; + break; + case NETWORK_INFO_ERROR_OPERATION_FAILED: + LOGI("Cannot find roaming state"); + ret = -1; + break; + default: + LOGI("Unexpected return value"); + ret = -1; + break; + } + + return ret; +} diff --git a/test/network_info_roaming_state_changed_test.c b/test/network_info_roaming_state_changed_test.c new file mode 100644 index 0000000..9947d38 --- /dev/null +++ b/test/network_info_roaming_state_changed_test.c @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include +#include +#include +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "TIZEN_N_NETWORK_INFO_TEST" + +static GMainLoop *event_loop; + +static void roaming_state_changed_cb_impl(bool is_roaming, void* user_data) +{ + LOGI("[%s] Start roaming_state_changed_cb_impl", __FUNCTION__); + + LOGI("Roaming state - [%s]", (is_roaming == true) ? "ON" : "OFF"); + + LOGI("[%s] user data: %s", __FUNCTION__, user_data); + + LOGI("[%s] End roaming_state_changed_cb_impl", __FUNCTION__); + g_main_loop_quit(event_loop); +} + +int main() +{ + if( network_info_set_roaming_state_changed_cb(roaming_state_changed_cb_impl, "roaming_state_changed_test") == NETWORK_INFO_ERROR_NONE ) + { + LOGI("[%s] Succeeded to add callback function", __FUNCTION__); + } + else + { + LOGE("[%s] Failed to add callback function", __FUNCTION__); + return -1; + } + + LOGI("[%s] If roaming state is changed, then callback function will be called", __FUNCTION__); + event_loop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(event_loop); + + if( network_info_unset_roaming_state_changed_cb() == NETWORK_INFO_ERROR_NONE ) + { + LOGI("[%s] Succeeded to remove callback function", __FUNCTION__); + } + else + { + LOGE("[%s] Failed to remove callback function", __FUNCTION__); + return -1; + } + + return 0; +} diff --git a/test/network_info_rssi_changed_test.c b/test/network_info_rssi_changed_test.c new file mode 100644 index 0000000..000c663 --- /dev/null +++ b/test/network_info_rssi_changed_test.c @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include +#include +#include +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "TIZEN_N_NETWORK_INFO_TEST" + +static GMainLoop *event_loop; + +static void rssi_changed_cb_impl(network_info_rssi_e rssi, void* user_data) +{ + LOGI("[%s] Start rssi_changed_cb_impl", __FUNCTION__); + + LOGI("[%s] RSSI: %d", __FUNCTION__, rssi); + LOGI("[%s] user data: %s", __FUNCTION__, user_data); + + LOGI("[%s] End rssi_changed_cb_impl", __FUNCTION__); + g_main_loop_quit(event_loop); +} + +int main() +{ + if( network_info_set_rssi_changed_cb(rssi_changed_cb_impl, "rssi_changed_test") == NETWORK_INFO_ERROR_NONE ) + { + LOGI("[%s] Succeeded to add callback function", __FUNCTION__); + } + else + { + LOGE("[%s] Failed to add callback function", __FUNCTION__); + return -1; + } + + LOGI("[%s] If RSSI is changed, then callback function will be called", __FUNCTION__); + event_loop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(event_loop); + + if( network_info_unset_rssi_changed_cb() == NETWORK_INFO_ERROR_NONE ) + { + LOGI("[%s] Succeeded to remove callback function", __FUNCTION__); + } + else + { + LOGE("[%s] Failed to remove callback function", __FUNCTION__); + return -1; + } + + return 0; +} diff --git a/test/network_info_service_state_changed_test.c b/test/network_info_service_state_changed_test.c new file mode 100644 index 0000000..f351dc7 --- /dev/null +++ b/test/network_info_service_state_changed_test.c @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include +#include +#include +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "TIZEN_N_NETWORK_INFO_TEST" + +static GMainLoop *event_loop; + +static const char *capi_network_service_state[] = { +"In service", +"Out of service", +"Emergency only", +"Radio off", +}; + +static void state_changed_cb(network_info_service_state_e status, void* user_data) +{ + LOGI("[%s] Start telephony_service_changed_cb", __FUNCTION__); + + LOGI("[%s] Service status: %s", __FUNCTION__, capi_network_service_state[status]); + LOGI("[%s] user data: %s", __FUNCTION__, user_data); + + LOGI("[%s] End telephony_service_changed_cb", __FUNCTION__); + g_main_loop_quit(event_loop); +} + +int main() +{ + if( network_info_set_service_state_changed_cb(state_changed_cb, "telephony_service_changed_test") == NETWORK_INFO_ERROR_NONE ) + { + LOGI("[%s] Succeeded to add callback function", __FUNCTION__); + } + else + { + LOGE("[%s] Failed to add callback function", __FUNCTION__); + return -1; + } + + LOGI("[%s] If service status is changed, then callback function will be called", __FUNCTION__); + event_loop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(event_loop); + + if( network_info_unset_service_state_changed_cb() == NETWORK_INFO_ERROR_NONE ) + { + LOGI("[%s] Succeeded to remove callback function", __FUNCTION__); + } + else + { + LOGE("[%s] Failed to remove callback function", __FUNCTION__); + return -1; + } + + return 0; +}