2 * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 * http://www.apache.org/licenses/LICENSE-2.0
7 * Unless required by applicable law or agreed to in writing, software
8 * distributed under the License is distributed on an "AS IS" BASIS,
9 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 * See the License for the specific language governing permissions and
11 * limitations under the License.
15 #include "sttd_main.h"
16 #include "sttd_network.h"
20 static bool g_is_connected;
22 bool sttd_network_is_connected()
24 return g_is_connected;
27 void __net_config_change_cb(keynode_t* node, void *data)
29 int network_configuration = 0;
30 vconf_get_int(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND , &network_configuration);
32 if (network_configuration == 0) {
33 SLOG(LOG_DEBUG, TAG_STTD, "[Network DEBUG] Change Network Connection is OFF ");
34 g_is_connected = false;
36 SLOG(LOG_DEBUG, TAG_STTD, "[Network DEBUG] Change Network Connection is ON ");
37 g_is_connected = true;
39 /* need to notify changing net to engine. */
45 int sttd_network_initialize()
47 int network_configuration = 0;
48 vconf_get_int(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND , &network_configuration);
50 if (network_configuration == 0) {
51 /* "0" means the network configuration is not set.
52 * It could be network connection is not open
55 int network_status = 0;
56 vconf_get_int(VCONFKEY_NETWORK_STATUS, &network_status);
58 if(network_status == VCONFKEY_NETWORK_OFF){
59 printf("Current network connection is OFF!! \n");
60 SLOG(LOG_DEBUG, TAG_STTD, "[Network DEBUG] Current network connection is OFF.");
64 * This is the problem of network connection
65 * Just terminate the application, network f/w will fix the problem automatically.
67 printf("network status is wrong or IP is not set\n");
68 printf("network has problem, try again\n");
72 g_is_connected = false;
74 printf("Current network connection is ON. \n");
75 SLOG(LOG_DEBUG, TAG_STTD, "[Network DEBUG] Current network connection is ON.");
77 g_is_connected = true;
80 vconf_notify_key_changed(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, __net_config_change_cb, NULL);
85 int sttd_network_finalize()
87 vconf_ignore_key_changed(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, __net_config_change_cb);