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 "ttsd_main.h"
16 #include "ttsd_network.h"
22 bool ttsd_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);
31 SLOG(LOG_DEBUG, get_tag(), "[Network DEBUG] Network configuration : %d", network_configuration);
33 if (network_configuration == 0) {
34 SLOG(LOG_DEBUG, get_tag(), "[Network] Notification : Network connection is OFF ");
35 g_is_connected = false;
37 SLOG(LOG_DEBUG, get_tag(), "[Network] Notification : Network connection is ON ");
38 g_is_connected = true;
40 /* need to notify changing net to engine. */
46 int ttsd_network_initialize()
48 int network_configuration = 0;
49 vconf_get_int(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND , &network_configuration);
50 SLOG(LOG_DEBUG, get_tag(), "[Network DEBUG] Network configuration : %d", network_configuration);
52 if (network_configuration == 0) {
53 /* "0" means the network configuration is not set.
54 * It could be network connection is not open
57 int network_status = 0;
58 vconf_get_int(VCONFKEY_NETWORK_STATUS, &network_status);
60 if(network_status == VCONFKEY_NETWORK_OFF){
61 SLOG(LOG_DEBUG, get_tag(), "[Network] Current network connection is OFF.");
65 * This is the problem of network connection
66 * Just terminate the application, network f/w will fix the problem automatically.
68 SLOG(LOG_WARN, get_tag(), "network status is wrong or IP is not set\n");
69 SLOG(LOG_WARN, get_tag(), "network has problem, try again\n");
73 g_is_connected = false;
75 SLOG(LOG_DEBUG, get_tag(), "[Network] 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);
82 SLOG(LOG_DEBUG, get_tag(), "[Network SUCCESS] Initialize network ...\n");
87 int ttsd_network_finalize()
89 vconf_ignore_key_changed(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, __net_config_change_cb);