2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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.
18 * @file FSys_SettingNetworkProvider.cpp
19 * @brief This is the implementation for the _SettingNetworkProvider class.
23 #include <unique_ptr.h>
26 #include <system_info.h>
27 #include <bluetooth.h>
29 #include <FBase_StringConverter.h>
33 #include <FBaseSysLog.h>
35 #include "FSys_SystemInfo.h"
36 #include "FSys_SettingNetworkProvider.h"
40 using namespace Tizen::App;
41 using namespace Tizen::Base;
42 using namespace Tizen::Base;
43 using namespace Utility;
45 namespace Tizen { namespace System
48 static const wchar_t* _NETWORK_FLIGHTMODE = L"http://tizen.org/setting/network.flight_mode";
49 static const wchar_t* _NETWORK_TELEPHONY_PACKETSERVICE = L"http://tizen.org/setting/network.telephony.packet_service";
50 static const wchar_t* _NETWORK_TELEPHONY_ROAMING = L"http://tizen.org/setting/network.telephony.roaming";
53 static const wchar_t* _NETWORK_WIFI = L"http://tizen.org/setting/network.wifi";
54 static const wchar_t* _NETWORK_WIFI_NOTIFICATION = L"http://tizen.org/setting/network.wifi.notification";
55 static const wchar_t* _NETWORK_WIFI_TETHERING = L"http://tizen.org/setting/network.wifi.tethering";
56 static const wchar_t* _NETWORK_WIFI_TETHERING_HIDE = L"http://tizen.org/setting/network.wifi.tethering.hide";
57 static const wchar_t* _NETWORK_WIFI_TETHERING_SECURITY = L"http://tizen.org/setting/network.wifi.tethering.security";
58 //static const wchar_t* _NETWORK_WIFI_TETHERING_SECURITY_PASSWORD = L"http://tizen.org/setting/network.wifi.tethering.security.password";
59 static const wchar_t* _USB_TETHERING = L"http://tizen.org/setting/usb.tethering"; //Especially, USB tethering is covered by this provider.
60 static const wchar_t* _NETWORK_WIFI_DIRECT = L"http://tizen.org/setting/network.wifi.direct";
63 static const wchar_t* _NETWORK_BLUETOOTH = L"http://tizen.org/setting/network.bluetooth";
64 static const wchar_t* _NETWORK_BLUETOOTH_TETHERING = L"http://tizen.org/setting/network.bluetooth.tethering";
66 static const wchar_t* _SYSTEM_NETWORK_BLUETOOTH = L"http://tizen.org/feature/network.bluetooth";
70 void operator()(char* pValue)
80 _SettingNetworkProvider::_SettingNetworkProvider()
82 , __pWifiDllHandle(null)
83 , __pBluetoothDllHandle(null)
84 , __tetheringHandle(null)
85 , __stateOfFlightMode(0)
87 , __stateOfWifiDirect(0)
88 , __stateOfBluetooth(0)
89 , __flightModeEnabled(false)
90 , __networkBluetoothEnabled(false)
92 , __wifiDirectInit(false)
93 , __pWifiListener(null)
94 , __pWifiDirectListener(null)
95 , __pFlightModeListener(null)
96 , __pBluetoothListener(null)
98 int errorCode = bt_initialize();
101 //For multiple usage, deinitialize should not be called when it terminated.
102 SysLogException(NID_SYS, E_SYSTEM, "It is failed to initialize bluetooth.");
105 errorCode = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED, SettingEventRuntimeInfo, null);
108 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register flight mode event listener");
111 errorCode = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_PACKET_DATA_ENABLED, SettingEventRuntimeInfo, null);
114 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register packet data event listener");
117 errorCode = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED, SettingEventRuntimeInfo, null);
120 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register roaming event listener");
123 errorCode = vconf_notify_key_changed(VCONFKEY_WIFI_STATE, SettingEventVConf, null);
126 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_WIFI_STATE listener");
129 errorCode = tethering_create(&__tetheringHandle);
132 SysLogException(NID_SYS, E_SYSTEM, "It is failed to create tethering handle");
136 errorCode = tethering_set_enabled_cb(__tetheringHandle, TETHERING_TYPE_USB, SettingEventTetheringEnabled, null);
139 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register TETHERING_TYPE_USB listener");
142 errorCode = tethering_set_enabled_cb(__tetheringHandle, TETHERING_TYPE_WIFI, SettingEventTetheringEnabled, null);
145 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register TETHERING_TYPE_WIFI listener");
148 errorCode = tethering_set_enabled_cb(__tetheringHandle, TETHERING_TYPE_BT, SettingEventTetheringEnabled, null);
151 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register TETHERING_TYPE_BT listener");
154 errorCode = tethering_set_disabled_cb(__tetheringHandle, TETHERING_TYPE_USB, SettingEventTetheringDisabled, null);
157 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register TETHERING_TYPE_USB listener");
160 errorCode = tethering_set_disabled_cb(__tetheringHandle, TETHERING_TYPE_WIFI, SettingEventTetheringDisabled, null);
163 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register TETHERING_TYPE_WIFI listener");
166 errorCode = tethering_set_disabled_cb(__tetheringHandle, TETHERING_TYPE_BT, SettingEventTetheringDisabled, null);
169 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register TETHERING_TYPE_BT listener");
173 errorCode = vconf_notify_key_changed(VCONFKEY_WIFI_DIRECT_STATE, SettingEventVConf, null);
176 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_WIFI_DIRECT_STATE listener");
179 errorCode = vconf_notify_key_changed(VCONFKEY_BT_STATUS, SettingEventVConf, null);
182 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_BT_STATUS listener");
185 errorCode = vconf_notify_key_changed(VCONFKEY_MOBILE_HOTSPOT_SECURITY, SettingEventVConf, null);
188 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_MOBILE_HOTSPOT_SECURITY listener");
191 errorCode = vconf_notify_key_changed(VCONFKEY_MOBILE_HOTSPOT_HIDE, SettingEventVConf, null);
194 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_MOBILE_HOTSPOT_HIDE listener");
197 errorCode = vconf_notify_key_changed(VCONFKEY_WIFI_ENABLE_QS, SettingEventVConf, null);
200 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_WIFI_ENABLE_QS listener");
203 errorCode = bt_adapter_set_state_changed_cb(SettingEventBluetooth, (void*)this);
206 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register bluetooth listener");
209 if(__wifiInit == false)
211 SysLog(NID_SYS, "wifi init is started");
212 errorCode = wifi_initialize();
213 SysLog(NID_SYS, "wifi init result is %d", errorCode);
219 _SettingNetworkProvider::~_SettingNetworkProvider()
221 int errorCode = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED);
224 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister flight mode event listener");
227 errorCode = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_PACKET_DATA_ENABLED);
230 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister packet data event listener");
233 errorCode = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED);
236 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister roaming event listener");
239 errorCode = vconf_ignore_key_changed(VCONFKEY_WIFI_STATE, SettingEventVConf);
242 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_WIFI_STATE listener");
245 if(__tetheringHandle != null)
247 errorCode = tethering_unset_enabled_cb(__tetheringHandle, TETHERING_TYPE_USB);
250 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_USB listener");
253 errorCode = tethering_unset_enabled_cb(__tetheringHandle, TETHERING_TYPE_WIFI);
256 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_WIFI listener");
259 errorCode = tethering_unset_enabled_cb(__tetheringHandle, TETHERING_TYPE_BT);
262 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_BT listener");
265 errorCode = tethering_unset_disabled_cb(__tetheringHandle, TETHERING_TYPE_USB);
268 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_USB listener");
271 errorCode = tethering_unset_disabled_cb(__tetheringHandle, TETHERING_TYPE_WIFI);
274 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_WIFI listener");
277 errorCode = tethering_unset_disabled_cb(__tetheringHandle, TETHERING_TYPE_BT);
280 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_BT listener");
283 tethering_destroy(__tetheringHandle);
284 __tetheringHandle = null;
287 errorCode = vconf_ignore_key_changed(VCONFKEY_WIFI_DIRECT_STATE, SettingEventVConf);
290 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_WIFI_DIRECT_STATE listener");
292 errorCode = vconf_ignore_key_changed(VCONFKEY_BT_STATUS, SettingEventVConf);
295 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_BT_STATUS listener");
298 errorCode = vconf_ignore_key_changed(VCONFKEY_MOBILE_HOTSPOT_SECURITY, SettingEventVConf);
301 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_MOBILE_HOTSPOT_SECURITY listener");
304 errorCode = vconf_ignore_key_changed(VCONFKEY_MOBILE_HOTSPOT_HIDE, SettingEventVConf);
307 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_MOBILE_HOTSPOT_HIDE listener");
310 errorCode = vconf_ignore_key_changed(VCONFKEY_WIFI_ENABLE_QS, SettingEventVConf);
313 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_WIFI_ENABLE_QS listener");
316 errorCode = bt_adapter_unset_state_changed_cb();
319 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister bluetooth listener");
322 errorCode = bt_deinitialize();
325 SysLogException(NID_SYS, E_SYSTEM, "It is failed to deinitialize bluetooth.");
328 if(__wifiDirectInit == true)
330 errorCode = wifi_direct_unset_device_state_changed_cb();
331 if(errorCode == WIFI_DIRECT_ERROR_NONE)
333 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister Wi-Fi direct callback.");
336 errorCode = wifi_direct_deinitialize();
337 if(errorCode == WIFI_DIRECT_ERROR_NONE)
339 SysLogException(NID_SYS, E_SYSTEM, "It is failed to deinitialize Wi-Fi direct.");
341 SysLog(NID_SYS, "Wifi direct de-init result is %d.", errorCode);
342 __wifiDirectInit = false;
345 if(__wifiInit == true)
347 errorCode = wifi_deinitialize();
348 if(errorCode == WIFI_ERROR_NONE)
350 SysLogException(NID_SYS, E_SYSTEM, "It is failed to deinitialize Wi-Fi.");
352 SysLog(NID_SYS, "Wifi de-init result is %d.", errorCode);
355 SysLog(NID_SYS, "Network Provider is terminated properly.");
359 _SettingNetworkProvider::GetValue(const String& key, bool& value)
362 result r = E_OBJ_NOT_FOUND;
364 if(key == _NETWORK_FLIGHTMODE)
366 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support flightmode feature.");
367 bool flightModeEnabled = false;
369 errorCode = runtime_info_get_value_bool(RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED, &flightModeEnabled);
370 SysTryReturnResult(NID_SYS, errorCode == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get the RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED");
371 value = flightModeEnabled;
373 else if(key == _NETWORK_TELEPHONY_PACKETSERVICE)
375 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Telephony packet service feature.");
376 bool packetServiceAllowed = false;
378 errorCode = runtime_info_get_value_bool(RUNTIME_INFO_KEY_PACKET_DATA_ENABLED, &packetServiceAllowed);
379 SysTryReturnResult(NID_SYS, errorCode == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get the RUNTIME_INFO_KEY_PACKET_DATA_ENABLED");
380 value = packetServiceAllowed;
382 else if(key == _NETWORK_TELEPHONY_ROAMING)
384 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Telephony roaming feature.");
385 bool dataRoamingEnabled = false;
387 errorCode = runtime_info_get_value_bool(RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED, &dataRoamingEnabled);
388 SysTryReturnResult(NID_SYS, errorCode == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get the RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED");
389 value = dataRoamingEnabled;
391 else if (key == _NETWORK_WIFI)
394 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
396 bool wifiState = false;
397 errorCode = wifi_is_activated(&wifiState);
398 SysTryReturnResult(NID_SYS, errorCode == WIFI_ERROR_NONE, E_SYSTEM, "It is failed to get from wifi_is_activated.");
401 else if (key == _NETWORK_WIFI_NOTIFICATION)
405 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
407 errorCode = vconf_get_int(VCONFKEY_WIFI_ENABLE_QS, &wifiQSState);
408 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_WIFI_ENABLE_QS vconf.");
410 if(wifiQSState == VCONFKEY_WIFI_QS_DISABLE)
419 else if (key == _NETWORK_WIFI_TETHERING)
422 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi tethering feature.");
423 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_SYSTEM, "It is failed to get tethering handle.");
425 value = tethering_is_enabled(__tetheringHandle, TETHERING_TYPE_WIFI);
427 else if (key == _NETWORK_WIFI_TETHERING_HIDE)
430 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi tethering feature.");
431 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_SYSTEM, "It is failed to get tethering handle.");
433 errorCode = tethering_wifi_get_ssid_visibility(__tetheringHandle, &value);
434 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to get wifi tethering visibility state");
436 else if (key == _NETWORK_WIFI_TETHERING_SECURITY)
438 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi tethering feature.");
439 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_SYSTEM, "It is failed to get tethering handle.");
442 tethering_wifi_security_type_e securityType;
443 errorCode = tethering_wifi_get_security_type(__tetheringHandle, &securityType);
444 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to get wifi tethering securiy state");
445 if(securityType == TETHERING_WIFI_SECURITY_TYPE_NONE)
454 else if (key == _USB_TETHERING)
457 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support USB tethering feature.");
458 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_SYSTEM, "It is failed to get tethering handle.");
460 value = tethering_is_enabled(__tetheringHandle, TETHERING_TYPE_USB);
462 else if (key == _NETWORK_WIFI_DIRECT)
464 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi direct feature.");
468 errorCode = vconf_get_int(VCONFKEY_WIFI_DIRECT_STATE, &isActivated);
469 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_WIFI_ENABLE_QS vconf.");
480 else if (key == _NETWORK_BLUETOOTH)
482 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Bluetooth feature.");
484 int bluetoothStatus = VCONFKEY_BT_STATUS_OFF;
485 errorCode = vconf_get_int(VCONFKEY_BT_STATUS, &bluetoothStatus);
486 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to read bluetooth status.");
488 if(bluetoothStatus == VCONFKEY_BT_STATUS_OFF)
497 else if (key == _NETWORK_BLUETOOTH_TETHERING)
499 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Bluetooth tethering feature.");
500 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_SYSTEM, "It is failed to get tethering handle.");
503 value = tethering_is_enabled(__tetheringHandle, TETHERING_TYPE_BT);
509 _SettingNetworkProvider::SetValue(const String& key, const bool value)
512 result r = E_OBJ_NOT_FOUND;
514 if(key == _NETWORK_WIFI_NOTIFICATION)
516 int currentValue = 0;
518 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
519 errorCode = vconf_get_int(VCONFKEY_WIFI_ENABLE_QS, ¤tValue);
520 SysTryReturnResult(NID_SYS, errorCode != -1, E_UNSUPPORTED_OPERATION, "This device does not support %ls key.", key.GetPointer());
524 errorCode = vconf_set_int(VCONFKEY_WIFI_ENABLE_QS, VCONFKEY_WIFI_QS_ENABLE);
528 errorCode = vconf_set_int(VCONFKEY_WIFI_ENABLE_QS, VCONFKEY_WIFI_QS_DISABLE);
530 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_WIFI_ENABLE_QS vconf.");
532 else if(key == _NETWORK_WIFI_TETHERING)
536 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
537 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_SYSTEM, "It is failed to get tethering handle.");
539 r = GetValue(_NETWORK_WIFI, state);
540 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the WIFI state");
541 SysTryReturnResult(NID_SYS, state == true, E_INVALID_STATE, "WIFI is not activated");
545 errorCode = tethering_enable(__tetheringHandle, TETHERING_TYPE_WIFI);
549 errorCode = tethering_disable(__tetheringHandle, TETHERING_TYPE_WIFI);
551 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to change tethering option.");
553 else if(key == _NETWORK_WIFI_TETHERING_HIDE)
556 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
557 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_SYSTEM, "It is failed to get tethering handle.");
559 bool currentState = false;
560 errorCode = tethering_wifi_get_ssid_visibility(__tetheringHandle, ¤tState);
561 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to current wifi tethering visibility setting");
563 if(value == true && currentState == false)
565 errorCode = tethering_wifi_set_ssid_visibility(__tetheringHandle, true);
567 else if(value == false && currentState == true)
569 errorCode = tethering_wifi_set_ssid_visibility(__tetheringHandle, false);
571 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to change wifi tethering visibility setting");
573 else if(key == _NETWORK_WIFI_TETHERING_SECURITY)
576 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
577 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_SYSTEM, "It is failed to get tethering handle.");
579 tethering_wifi_security_type_e securityType;
581 errorCode = tethering_wifi_get_security_type(__tetheringHandle, &securityType);
582 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to get wifi tethering securiy state");
584 if(value == true && securityType == TETHERING_WIFI_SECURITY_TYPE_NONE)
586 errorCode = tethering_wifi_set_security_type(__tetheringHandle, TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK);
588 else if(value == false && securityType == TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK)
590 errorCode = tethering_wifi_set_security_type(__tetheringHandle, TETHERING_WIFI_SECURITY_TYPE_NONE);
592 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to change wifi tethering visibility setting");
594 else if(key == _USB_TETHERING)
597 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature.");
598 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_SYSTEM, "It is failed to get tethering handle.");
602 errorCode = tethering_enable(__tetheringHandle, TETHERING_TYPE_USB);
606 errorCode = tethering_disable(__tetheringHandle, TETHERING_TYPE_USB);
608 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to change tethering option");
610 else if(key == _NETWORK_BLUETOOTH_TETHERING)
613 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature.");
614 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_SYSTEM, "It is failed to get tethering handle.");
617 r = GetValue(_NETWORK_BLUETOOTH, state);
618 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the Bluetooth state");
619 SysTryReturnResult(NID_SYS, state == true, E_INVALID_STATE, "Bluetooth is not activated");
623 errorCode = tethering_enable(__tetheringHandle, TETHERING_TYPE_BT);
627 errorCode = tethering_disable(__tetheringHandle, TETHERING_TYPE_BT);
629 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to change tethering option");
635 _SettingNetworkProvider::SetValueAsync(const String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
638 result r = E_OBJ_NOT_FOUND;
640 if(key == _NETWORK_BLUETOOTH)
642 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Bluetooth feature.");
643 SysTryReturnResult(NID_SYS, __stateOfBluetooth == 0, E_IN_PROGRESS, "Bluetooth is under changing procedure.");
645 __stateOfBluetooth = 1;
646 __pBluetoothListener = listener;
648 SysLog(NID_SYS, "Required bluetooth value is %d.", value);
651 ret = bt_adapter_enable();
655 ret = bt_adapter_disable();
658 SysLog(NID_SYS, "bt_adapter returns %d.", ret);
663 SysLog(NID_SYS, "It is OK to change the bluetooth mode.");
666 case BT_ERROR_ALREADY_DONE:
667 SysLog(NID_SYS, "Bluetooth is already changed.");
668 SettingEventBluetooth(BT_ERROR_NONE, BT_ADAPTER_ENABLED, (void*)this);
670 case BT_ERROR_NOT_ENABLED:
671 SysLog(NID_SYS, "Bluetooth is not enabled.");
672 SettingEventBluetooth(BT_ERROR_NONE, BT_ADAPTER_ENABLED, (void*)this);
675 case BT_ERROR_NOW_IN_PROGRESS:
676 SysLog(NID_SYS, "Currently, Bluetooth change is in progress.");
677 __stateOfBluetooth = 0;
681 case BT_ERROR_NOT_INITIALIZED:
683 SysLog(NID_SYS, "There is an unknown error when changing the bluetooth mode.");
684 __stateOfBluetooth = 0;
693 _SettingNetworkProvider::SetValueForPrivilegedKey(const String& key, bool value)
696 result r = E_OBJ_NOT_FOUND;
697 if(key == _NETWORK_TELEPHONY_PACKETSERVICE)
699 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support telephony packet service feature.");
701 errorCode = vconf_set_bool(VCONFKEY_3G_ENABLE, value);
702 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_3G_ENABLE vconf.");
704 else if(key == _NETWORK_TELEPHONY_ROAMING)
706 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support telephony roaming feature.");
708 errorCode = vconf_set_bool(VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL, value);
709 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL vconf.");
715 _SettingNetworkProvider::SetValueAsyncForPrivilegedKey(const String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
718 result r = E_OBJ_NOT_FOUND;
720 if(key == _NETWORK_FLIGHTMODE)
722 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support flightmode feature.");
725 SysTryReturnResult(NID_SYS, __stateOfFlightMode == 0, E_IN_PROGRESS, "Flightmode is under changing procedure.");
726 __stateOfFlightMode = 1;
728 bool supported = false;
729 int ret = system_info_get_platform_bool("tizen.org/feature/network.telephony", &supported);
730 SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to get system information from configration file.");
732 __pFlightModeListener = listener;
733 if(supported == true)
735 if(__tapiHandle == null)
737 __tapiHandle = tel_init(null);
738 if(__tapiHandle == null)
740 __stateOfFlightMode = 0;
742 SysTryReturnResult(NID_SYS, __tapiHandle != null, E_SYSTEM, "Tapi is not ready.");
744 errorCode = tel_set_flight_mode(__tapiHandle,
745 value ? TAPI_POWER_FLIGHT_MODE_ENTER : TAPI_POWER_FLIGHT_MODE_LEAVE,
746 SettingEventFlightMode, (void*)this);
750 __stateOfFlightMode = 0;
752 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on Network Flight mode(%d).", errorCode);
756 FlightModeEnabler((void*)this);
759 else if(key == _NETWORK_WIFI)
761 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
762 SysTryReturnResult(NID_SYS, __stateOfWifi == 0 && __stateOfWifiDirect == 0, E_IN_PROGRESS, "Wifi processing is under way.");
766 SysLog(NID_SYS, "It creates thread for wifi enable[%d].", value);
768 bool wifiEnabled = false;
769 __pWifiListener = listener;
770 errorCode = wifi_is_activated(&wifiEnabled);
771 if(errorCode != WIFI_ERROR_NONE)
774 SysLogException(NID_SYS, E_SYSTEM, "It is failed to get current status of WIFI.");
778 if(value == wifiEnabled) //Wi-Fi is already changed.
780 SysLog(NID_SYS, "It is try to use dummy thread");
781 r = WifiDummy((void*)this);
782 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to set Wi-Fi state.");
788 errorCode = wifi_activate(SettingWifiActivateCallBack, (void*) this);
792 errorCode = wifi_deactivate(SettingWifiActivateCallBack, (void*) this);
795 if(errorCode != WIFI_ERROR_NONE)
801 else if(key == _NETWORK_WIFI_DIRECT)
803 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
804 SysTryReturnResult(NID_SYS, __stateOfWifi == 0 && __stateOfWifiDirect == 0, E_IN_PROGRESS, "Wifi processing is under way.");
807 __stateOfWifiDirect = 1;
808 SysLog(NID_SYS, "It creates thread for wifi direct enable[%d].", value);
811 __pWifiDirectListener = listener;
812 if(__wifiDirectInit == false)
814 SysLog(NID_SYS, "wifi direct init is started");
815 errorCode = wifi_direct_initialize();
816 SysLog(NID_SYS, "wifi direct init result is %d", errorCode);
817 SysTryReturnResult(NID_SYS, errorCode == WIFI_DIRECT_ERROR_NONE, E_SYSTEM, "It is failed to init wifi direct.");
818 errorCode = wifi_direct_set_device_state_changed_cb(SettingWifiDirectStateChangedCallBack, (void*) this);
819 SysTryReturnResult(NID_SYS, errorCode == WIFI_DIRECT_ERROR_NONE, E_SYSTEM, "It is failed to register wifi direct result callback.");
820 __wifiDirectInit = true;
824 wifi_direct_state_e wifi_direct_state;
825 errorCode = wifi_direct_get_state(&wifi_direct_state);
826 if(errorCode != WIFI_DIRECT_ERROR_NONE)
828 __stateOfWifiDirect = 0;
829 SysLogException(NID_SYS, E_SYSTEM, "It is failed to get current status of WIFI direct.");
833 if((value == false && wifi_direct_state == WIFI_DIRECT_STATE_DEACTIVATED)
834 || (value == true && wifi_direct_state != WIFI_DIRECT_STATE_DEACTIVATED))
836 SysLog(NID_SYS, "Required state is already applied.");
837 WifiDirectDummy((void*)this);
843 errorCode = wifi_direct_activate();
847 errorCode = wifi_direct_deactivate();
849 SysLog(NID_SYS, "wifi_direct_activate result is %d. value is %d.", errorCode, value);
860 _SettingNetworkProvider::WifiDummy(void* data)
862 result r = E_SUCCESS;
863 String settingKey(_NETWORK_WIFI);
864 _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
865 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
866 SysTryReturnResult(NID_SYS, (pSettingInfo != null && pProvider != null), E_SYSTEM, "There is no values of args.");
868 SysTryCatch(NID_SYS, pProvider->__stateOfWifi == 1, r = E_SYSTEM, E_SYSTEM, "There is invalid state.");
870 if(pProvider->__pWifiListener != null)
872 pProvider->__pWifiListener->OnResultReceivedForSetValueAsync(settingKey, E_SUCCESS);
874 r = pSettingInfo->AnnounceSettingEvent(settingKey);
875 SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
878 pProvider->__stateOfWifi = 0;
883 _SettingNetworkProvider::WifiDirectDummy(void* data)
885 result r = E_SUCCESS;
886 String settingKey(_NETWORK_WIFI_DIRECT);
887 _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
888 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
889 SysTryReturnResult(NID_SYS, (pSettingInfo != null && pProvider != null), E_SYSTEM, "There is no values of args.");
890 SysTryCatch(NID_SYS, pProvider->__stateOfWifiDirect == 1, E_SYSTEM, E_SYSTEM, "There is invalid state.");
892 if(pProvider->__pWifiDirectListener != null)
894 pProvider->__pWifiDirectListener->OnResultReceivedForSetValueAsync(settingKey, E_SUCCESS);
896 r = pSettingInfo->AnnounceSettingEvent(settingKey);
897 SysTryCatch(NID_SYS, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
900 pProvider->__stateOfWifiDirect = 0;
905 _SettingNetworkProvider::SettingWifiActivateCallBack(wifi_error_e errorCode, void* data)
907 String settingKey(_NETWORK_WIFI);
909 _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
910 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
911 SysTryReturnVoidResult(NID_SYS, (pSettingInfo != null && pProvider != null), E_SYSTEM, "There is no values of args.");
912 SysTryCatch(NID_SYS, pProvider->__stateOfWifi == 1, E_SYSTEM, E_SYSTEM, "Wi-Fi processing is under way.");
916 case WIFI_ERROR_INVALID_PARAMETER:
917 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by invalid param.");
919 case WIFI_ERROR_OUT_OF_MEMORY:
920 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by out of memory.");
922 case WIFI_ERROR_INVALID_OPERATION:
923 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by invalid operation.");
925 case WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
926 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by family not supported.");
928 case WIFI_ERROR_OPERATION_FAILED:
929 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by operation failed.");
931 case WIFI_ERROR_NO_CONNECTION:
932 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by no connection.");
934 case WIFI_ERROR_ALREADY_EXISTS:
935 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by already exist.");
937 case WIFI_ERROR_OPERATION_ABORTED:
938 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by operation aborted.");
940 case WIFI_ERROR_DHCP_FAILED:
941 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by DHCP fail.");
943 case WIFI_ERROR_INVALID_KEY:
944 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by invalid key.");
946 case WIFI_ERROR_NO_REPLY:
947 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by no reply.");
949 case WIFI_ERROR_SECURITY_RESTRICTED:
950 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by security restricted.");
952 case WIFI_ERROR_NOW_IN_PROGRESS:
953 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is under way.");
955 case WIFI_ERROR_NONE:
956 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is work properly");
960 if(pProvider->__pWifiListener != null)
962 SysLog(NID_SYS, "Wi-Fi result is forwarded.");
963 pProvider->__pWifiListener->OnResultReceivedForSetValueAsync(settingKey, E_SUCCESS);
967 SysLog(NID_SYS, "There is no listener.");
970 pProvider->__stateOfWifi = 0;
974 _SettingNetworkProvider::SettingWifiDirectStateChangedCallBack(wifi_direct_error_e errorCode, wifi_direct_device_state_e deviceState, void* data)
976 result r = E_SUCCESS;
977 String settingKey(_NETWORK_WIFI_DIRECT);
979 _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
980 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
981 SysTryReturnVoidResult(NID_SYS, (pSettingInfo != null && pProvider != null), E_SYSTEM, "There is no values of args.");
983 SysTryCatch(NID_SYS, pProvider->__stateOfWifiDirect == 1 , E_SYSTEM, E_SYSTEM, "There is invalid state.");
985 if(errorCode != WIFI_DIRECT_ERROR_NONE)
990 if(pProvider->__pWifiDirectListener != null)
992 pProvider->__pWifiDirectListener->OnResultReceivedForSetValueAsync(settingKey, r);
996 pProvider->__stateOfWifiDirect = 0;
1000 _SettingNetworkProvider::GetValue(const String& key, String& value)
1003 result r = E_OBJ_NOT_FOUND;
1006 if (key == _NETWORK_WIFI_TETHERING_SECURITY_PASSWORD)
1009 unique_ptr<char> password(null);
1011 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi tethering feature.");
1012 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_SYSTEM, "It is failed to get tethering handle.");
1014 errorCode = tethering_wifi_get_passphrase(__tetheringHandle, &pTemp);
1015 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE && pTemp != null, E_SYSTEM, "It is failed to get password");
1017 password.reset(pTemp);
1020 value.Append(password.get());
1027 _SettingNetworkProvider::SetValue(const String& key, const String value)
1030 result r = E_OBJ_NOT_FOUND;
1032 if(key ==_NETWORK_WIFI_TETHERING_SECURITY_PASSWORD)
1035 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi tethering feature.");
1036 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_SYSTEM, "It is failed to get tethering handle.");
1038 unique_ptr<char []> password(_StringConverter::CopyToCharArrayN(value));
1039 SysTryReturnResult(NID_SYS, password != null, E_SYSTEM, "It is failed to convert String to string");
1040 errorCode = tethering_wifi_set_passphrase(__tetheringHandle, password.get());
1041 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to set password");
1048 _SettingNetworkProvider::HasKey(const String& key)
1050 bool wifi_supported = false;
1051 bool wifi_direct_supported = false;
1052 bool bluetooth_supported = false;
1053 bool telephony_supported = false;
1055 int ret = system_info_get_platform_bool("tizen.org/feature/network.wifi", &wifi_supported);
1056 SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to get system information from configration file.");
1058 ret = system_info_get_platform_bool("tizen.org/feature/network.wifi.direct", &wifi_direct_supported);
1059 SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to get system information from configration file.");
1061 ret = system_info_get_platform_bool("tizen.org/feature/network.bluetooth", &bluetooth_supported);
1062 SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to get system information from configration file.");
1064 ret = system_info_get_platform_bool("tizen.org/feature/network.telephony", &telephony_supported);
1065 SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to get system information from configration file.");
1067 if(key == _NETWORK_FLIGHTMODE)
1071 else if(key == _NETWORK_TELEPHONY_PACKETSERVICE || key == _NETWORK_TELEPHONY_ROAMING)
1073 if(telephony_supported == true)
1078 else if(key == _NETWORK_WIFI || key == _NETWORK_WIFI_NOTIFICATION)
1080 if(wifi_supported == true)
1085 else if(key == _NETWORK_WIFI_DIRECT)
1087 if(wifi_direct_supported == true)
1092 else if(key == _NETWORK_WIFI_TETHERING || key == _NETWORK_WIFI_TETHERING_HIDE
1093 || key == _NETWORK_WIFI_TETHERING_SECURITY /*|| key == _NETWORK_WIFI_TETHERING_SECURITY_PASSWORD*/ || key == _USB_TETHERING)
1095 bool isSupported = false;
1096 int errorCode = system_info_get_value_bool(SYSTEM_INFO_KEY_TETHERING_SUPPORTED, &isSupported);
1098 if(errorCode == SYSTEM_INFO_ERROR_NONE && isSupported == true)
1103 else if(key == _NETWORK_BLUETOOTH)
1105 if(bluetooth_supported == true)
1110 else if(key == _NETWORK_BLUETOOTH_TETHERING)
1112 if(__tetheringHandle != null && bluetooth_supported == true)
1121 _SettingNetworkProvider::SettingEventRuntimeInfo(runtime_info_key_e key, void* userData)
1125 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
1126 SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "SettingInfo is not ready.");
1128 if(key == RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED)
1130 settingKey.Append(_NETWORK_FLIGHTMODE);
1132 else if(key == RUNTIME_INFO_KEY_PACKET_DATA_ENABLED)
1134 settingKey.Append(_NETWORK_TELEPHONY_PACKETSERVICE);
1136 else if(key == RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED)
1138 settingKey.Append(_NETWORK_TELEPHONY_ROAMING);
1142 SysLogException(NID_SYS, E_SYSTEM, "It is not supported key.");
1146 result r = pSettingInfo->AnnounceSettingEvent(settingKey);
1147 SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
1151 _SettingNetworkProvider::SettingEventVConf(keynode_t* node, void* userData)
1153 result r = E_SUCCESS;
1155 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
1156 SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
1158 if (strcmp(VCONFKEY_WIFI_STATE, vconf_keynode_get_name(node)) == 0)
1160 int state = VCONFKEY_WIFI_OFF;
1162 errorCode = vconf_get_int(VCONFKEY_WIFI_STATE, &state);
1164 if(errorCode == 0 && (state == VCONFKEY_WIFI_OFF || state == VCONFKEY_WIFI_UNCONNECTED))
1166 settingKey.Append(_NETWORK_WIFI);
1167 r = pSettingInfo->AnnounceSettingEvent(settingKey);
1168 SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
1172 else if (strcmp(VCONFKEY_WIFI_ENABLE_QS, vconf_keynode_get_name(node)) == 0)
1174 settingKey.Append(_NETWORK_WIFI_NOTIFICATION);
1176 else if (strcmp(VCONFKEY_WIFI_DIRECT_STATE, vconf_keynode_get_name(node)) == 0)
1178 int state = VCONFKEY_WIFI_DIRECT_DEACTIVATED;
1180 errorCode = vconf_get_int(VCONFKEY_WIFI_DIRECT_STATE, &state);
1181 SysLog(NID_SYS, "Wi-Fi Direct state is changed. %d", state);
1182 if(errorCode == 0 && (state == VCONFKEY_WIFI_DIRECT_DEACTIVATED || state == VCONFKEY_WIFI_DIRECT_ACTIVATED))
1184 settingKey.Append(_NETWORK_WIFI_DIRECT);
1185 r = pSettingInfo->AnnounceSettingEvent(settingKey);
1186 SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
1190 else if (strcmp(VCONFKEY_BT_STATUS, vconf_keynode_get_name(node)) == 0)
1192 settingKey.Append(_NETWORK_BLUETOOTH);
1194 else if (strcmp(VCONFKEY_MOBILE_HOTSPOT_SECURITY, vconf_keynode_get_name(node)) == 0)
1196 settingKey.Append(_NETWORK_WIFI_TETHERING_SECURITY);
1198 else if (strcmp(VCONFKEY_MOBILE_HOTSPOT_HIDE, vconf_keynode_get_name(node)) == 0)
1200 settingKey.Append(_NETWORK_WIFI_TETHERING_HIDE);
1204 SysLogException(NID_SYS, E_SYSTEM, "It is not supported key.");
1208 r = pSettingInfo->AnnounceSettingEvent(settingKey);
1209 SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
1213 _SettingNetworkProvider::SettingEventTetheringEnabled(tethering_error_e err, tethering_type_e type, bool is_requested, void* data)
1216 SysLog(NID_SYS, "Tethering Endabled Event is occured.");
1218 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
1219 SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
1223 case TETHERING_TYPE_USB:
1224 settingKey.Append(_USB_TETHERING);
1226 case TETHERING_TYPE_WIFI:
1227 settingKey.Append(_NETWORK_WIFI_TETHERING);
1229 case TETHERING_TYPE_BT:
1230 settingKey.Append(_NETWORK_BLUETOOTH_TETHERING);
1236 result r = pSettingInfo->AnnounceSettingEvent(settingKey);
1237 SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
1241 _SettingNetworkProvider::SettingEventTetheringDisabled(tethering_error_e err, tethering_type_e type, tethering_disabled_cause_e cause,void* data)
1243 SysLog(NID_SYS, "Tethering Disabled Event is occured.");
1244 SettingEventTetheringEnabled(err, type, false, null);
1248 _SettingNetworkProvider::SettingEventFlightMode(TapiHandle* handle, int res, void* data, void* user_data)
1250 String settingKey(_NETWORK_FLIGHTMODE);
1252 result r = E_SUCCESS;
1253 SysLog(NID_SYS, "Flightmode response is handle:%x, res:%d, date:%x, user_data:%x", handle, res, data, user_data);
1255 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
1256 SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "SettingInfo is not ready.");
1257 _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)user_data;
1258 SysTryReturnVoidResult(NID_SYS, pProvider != null, E_SYSTEM, "There is invalid provider.");
1259 SysTryCatch(NID_SYS, pProvider->__stateOfFlightMode == 1, E_SYSTEM, E_SYSTEM, "Current state of flight mode is not valid.");
1263 case TAPI_POWER_FLIGHT_MODE_RESP_ON:
1264 SysLog(NID_SYS, "It successes to change flight mode on");
1266 errorCode = vconf_set_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, true);
1269 SysLogException(NID_SYS, E_SYSTEM, "It is failed to set on VCONFKEY_TELEPHONY_FLIGHT_MODE vconf.");
1273 case TAPI_POWER_FLIGHT_MODE_RESP_OFF:
1274 SysLog(NID_SYS, "It successes to change flight mode off");
1276 errorCode = vconf_set_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, false);
1279 SysLogException(NID_SYS, E_SYSTEM, "It is failed to set on VCONFKEY_TELEPHONY_FLIGHT_MODE vconf.");
1283 case TAPI_POWER_FLIGHT_MODE_RESP_FAIL:
1285 SysLogException(NID_SYS, E_SYSTEM, "It is failed to change flight mode");
1289 if(pProvider->__pFlightModeListener != null)
1291 pProvider->__pFlightModeListener->OnResultReceivedForSetValueAsync(settingKey, r);
1295 pProvider->__stateOfFlightMode = 0;
1299 _SettingNetworkProvider::FlightModeEnabler(void* data)
1301 result r = E_SUCCESS;
1303 String settingKey(_NETWORK_FLIGHTMODE);
1305 _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
1306 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
1307 SysTryReturnResult(NID_SYS, pProvider != null && pSettingInfo != null, E_SYSTEM, "Provider or SettingInfo is not ready.");
1308 SysTryCatch(NID_SYS, pProvider->__stateOfFlightMode == 1, E_SYSTEM, E_SYSTEM, "Current state of flight mode is not valid.");
1310 errorCode = vconf_set_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, pProvider->__flightModeEnabled);
1313 SysLogException(NID_SYS, E_SYSTEM, "It is failed to set on VCONFKEY_TELEPHONY_FLIGHT_MODE vconf.");
1318 if(pProvider->__pFlightModeListener != null)
1320 pProvider->__pFlightModeListener->OnResultReceivedForSetValueAsync(settingKey, r);
1324 pProvider->__stateOfFlightMode = 0;
1329 _SettingNetworkProvider::SettingEventBluetooth(int res, bt_adapter_state_e adapter_state, void* user_data)
1331 String settingKey(_NETWORK_BLUETOOTH);
1332 result r = E_SUCCESS;
1333 SysLog(NID_SYS, "Bluetooth callback is invoked. result:%d, adapter_state:%d, user_data:%x", res, adapter_state, user_data);
1335 _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)user_data;
1336 SysTryReturnVoidResult(NID_SYS, pProvider != null, E_SYSTEM, "There is no values of args.");
1337 SysTryCatch(NID_SYS, pProvider->__stateOfBluetooth == 1, E_SYSTEM, E_SYSTEM, "Bluetooth processing is under way.");
1339 if(res == BT_ERROR_NONE)
1348 if(pProvider->__pBluetoothListener != null && pProvider->__stateOfBluetooth == 1)
1350 pProvider->__pBluetoothListener->OnResultReceivedForSetValueAsync(settingKey, r);
1355 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
1356 SysTryCatch(NID_SYS, pSettingInfo != null, E_SYSTEM, E_SYSTEM, "_SettingInfo is not ready.");
1358 result r = pSettingInfo->AnnounceSettingEvent(settingKey);
1359 SysTryCatch(NID_SYS, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
1363 pProvider->__stateOfBluetooth = 0;