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";
51 static const wchar_t* _SYSTEM_TELEPHONY = L"http://tizen.org/feature/network.telephony";
54 static const wchar_t* _NETWORK_WIFI = L"http://tizen.org/setting/network.wifi";
55 static const wchar_t* _NETWORK_WIFI_NOTIFICATION = L"http://tizen.org/setting/network.wifi.notification";
56 static const wchar_t* _NETWORK_WIFI_TETHERING = L"http://tizen.org/setting/network.wifi.tethering";
57 static const wchar_t* _NETWORK_WIFI_TETHERING_HIDE = L"http://tizen.org/setting/network.wifi.tethering.hide";
58 static const wchar_t* _NETWORK_WIFI_TETHERING_SECURITY = L"http://tizen.org/setting/network.wifi.tethering.security";
59 static const wchar_t* _NETWORK_WIFI_TETHERING_SECURITY_PASSWORD = L"http://tizen.org/setting/network.wifi.tethering.security.password";
60 static const wchar_t* _USB_TETHERING = L"http://tizen.org/setting/usb.tethering"; //Especially, USB tethering is covered by this provider.
61 static const wchar_t* _NETWORK_WIFI_DIRECT = L"http://tizen.org/setting/network.wifi.direct";
63 static const wchar_t* _SYSTEM_NETWORK_WIFI_DIRECT = L"http://tizen.org/feature/network.wifi.direct";
64 static const wchar_t* _SYSTEM_NETWORK_WIFI = L"http://tizen.org/feature/network.wifi";
67 static const wchar_t* _NETWORK_BLUETOOTH = L"http://tizen.org/setting/network.bluetooth";
68 static const wchar_t* _NETWORK_BLUETOOTH_TETHERING = L"http://tizen.org/setting/network.bluetooth.tethering";
70 static const wchar_t* _SYSTEM_NETWORK_BLUETOOTH = L"http://tizen.org/feature/network.bluetooth";
74 void operator()(char* pValue)
84 _SettingNetworkProvider::_SettingNetworkProvider()
86 , __pWifiDllHandle(null)
87 , __pBluetoothDllHandle(null)
88 , __tetheringHandle(null)
89 , __stateOfFlightMode(0)
91 , __stateOfWifiDirect(0)
92 , __stateOfBluetooth(0)
93 , __flightModeEnabled(false)
94 , __networkBluetoothEnabled(false)
96 , __wifiDirectInit(false)
97 , __pWifiListener(null)
98 , __pWifiDirectListener(null)
99 , __pFlightModeListener(null)
100 , __pBluetoothListener(null)
102 int errorCode = bt_initialize();
105 //For multiple usage, deinitialize should not be called when it terminated.
106 SysLogException(NID_SYS, E_SYSTEM, "It is failed to initialize bluetooth.");
109 errorCode = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED, SettingEventRuntimeInfo, null);
112 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register flight mode event listener");
115 errorCode = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_PACKET_DATA_ENABLED, SettingEventRuntimeInfo, null);
118 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register packet data event listener");
121 errorCode = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED, SettingEventRuntimeInfo, null);
124 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register roaming event listener");
127 errorCode = vconf_notify_key_changed(VCONFKEY_WIFI_STATE, SettingEventVConf, null);
130 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_WIFI_STATE listener");
133 errorCode = tethering_create(&__tetheringHandle);
136 SysLogException(NID_SYS, E_SYSTEM, "It is failed to create tethering handle");
140 errorCode = tethering_set_enabled_cb(__tetheringHandle, TETHERING_TYPE_USB, SettingEventTetheringEnabled, null);
143 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register TETHERING_TYPE_USB listener");
146 errorCode = tethering_set_enabled_cb(__tetheringHandle, TETHERING_TYPE_WIFI, SettingEventTetheringEnabled, null);
149 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register TETHERING_TYPE_WIFI listener");
152 errorCode = tethering_set_enabled_cb(__tetheringHandle, TETHERING_TYPE_BT, SettingEventTetheringEnabled, null);
155 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register TETHERING_TYPE_BT listener");
158 errorCode = tethering_set_disabled_cb(__tetheringHandle, TETHERING_TYPE_USB, SettingEventTetheringDisabled, null);
161 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register TETHERING_TYPE_USB listener");
164 errorCode = tethering_set_disabled_cb(__tetheringHandle, TETHERING_TYPE_WIFI, SettingEventTetheringDisabled, null);
167 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register TETHERING_TYPE_WIFI listener");
170 errorCode = tethering_set_disabled_cb(__tetheringHandle, TETHERING_TYPE_BT, SettingEventTetheringDisabled, null);
173 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register TETHERING_TYPE_BT listener");
177 errorCode = vconf_notify_key_changed(VCONFKEY_WIFI_DIRECT_STATE, SettingEventVConf, null);
180 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_WIFI_DIRECT_STATE listener");
183 errorCode = vconf_notify_key_changed(VCONFKEY_BT_STATUS, SettingEventVConf, null);
186 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_BT_STATUS listener");
189 errorCode = vconf_notify_key_changed(VCONFKEY_MOBILE_HOTSPOT_SECURITY, SettingEventVConf, null);
192 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_MOBILE_HOTSPOT_SECURITY listener");
195 errorCode = vconf_notify_key_changed(VCONFKEY_MOBILE_HOTSPOT_HIDE, SettingEventVConf, null);
198 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_MOBILE_HOTSPOT_HIDE listener");
201 errorCode = vconf_notify_key_changed(VCONFKEY_WIFI_ENABLE_QS, SettingEventVConf, null);
204 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_WIFI_ENABLE_QS listener");
207 errorCode = bt_adapter_set_state_changed_cb(SettingEventBluetooth, (void*)this);
210 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register bluetooth listener");
213 if(__wifiInit == false)
215 SysLog(NID_SYS, "wifi init is started");
216 errorCode = wifi_initialize();
217 SysLog(NID_SYS, "wifi init result is %d", errorCode);
223 _SettingNetworkProvider::~_SettingNetworkProvider()
225 int errorCode = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED);
228 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister flight mode event listener");
231 errorCode = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_PACKET_DATA_ENABLED);
234 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister packet data event listener");
237 errorCode = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED);
240 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister roaming event listener");
243 errorCode = vconf_ignore_key_changed(VCONFKEY_WIFI_STATE, SettingEventVConf);
246 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_WIFI_STATE listener");
249 if(__tetheringHandle != null)
251 errorCode = tethering_unset_enabled_cb(__tetheringHandle, TETHERING_TYPE_USB);
254 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_USB listener");
257 errorCode = tethering_unset_enabled_cb(__tetheringHandle, TETHERING_TYPE_WIFI);
260 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_WIFI listener");
263 errorCode = tethering_unset_enabled_cb(__tetheringHandle, TETHERING_TYPE_BT);
266 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_BT listener");
269 errorCode = tethering_unset_disabled_cb(__tetheringHandle, TETHERING_TYPE_USB);
272 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_USB listener");
275 errorCode = tethering_unset_disabled_cb(__tetheringHandle, TETHERING_TYPE_WIFI);
278 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_WIFI listener");
281 errorCode = tethering_unset_disabled_cb(__tetheringHandle, TETHERING_TYPE_BT);
284 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_BT listener");
287 tethering_destroy(__tetheringHandle);
288 __tetheringHandle = null;
291 errorCode = vconf_ignore_key_changed(VCONFKEY_WIFI_DIRECT_STATE, SettingEventVConf);
294 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_WIFI_DIRECT_STATE listener");
296 errorCode = vconf_ignore_key_changed(VCONFKEY_BT_STATUS, SettingEventVConf);
299 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_BT_STATUS listener");
302 errorCode = vconf_ignore_key_changed(VCONFKEY_MOBILE_HOTSPOT_SECURITY, SettingEventVConf);
305 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_MOBILE_HOTSPOT_SECURITY listener");
308 errorCode = vconf_ignore_key_changed(VCONFKEY_MOBILE_HOTSPOT_HIDE, SettingEventVConf);
311 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_MOBILE_HOTSPOT_HIDE listener");
314 errorCode = vconf_ignore_key_changed(VCONFKEY_WIFI_ENABLE_QS, SettingEventVConf);
317 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_WIFI_ENABLE_QS listener");
320 errorCode = bt_adapter_unset_state_changed_cb();
323 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister bluetooth listener");
326 errorCode = bt_deinitialize();
329 SysLogException(NID_SYS, E_SYSTEM, "It is failed to deinitialize bluetooth.");
332 if(__wifiDirectInit == true)
334 errorCode = wifi_direct_unset_device_state_changed_cb();
335 if(errorCode == WIFI_DIRECT_ERROR_NONE)
337 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister Wi-Fi direct callback.");
340 errorCode = wifi_direct_deinitialize();
341 if(errorCode == WIFI_DIRECT_ERROR_NONE)
343 SysLogException(NID_SYS, E_SYSTEM, "It is failed to deinitialize Wi-Fi direct.");
345 SysLog(NID_SYS, "Wifi direct de-init result is %d.", errorCode);
346 __wifiDirectInit = false;
349 if(__wifiInit == true)
351 errorCode = wifi_deinitialize();
352 if(errorCode == WIFI_ERROR_NONE)
354 SysLogException(NID_SYS, E_SYSTEM, "It is failed to deinitialize Wi-Fi.");
356 SysLog(NID_SYS, "Wifi de-init result is %d.", errorCode);
359 SysLog(NID_SYS, "Network Provider is terminated properly.");
363 _SettingNetworkProvider::GetValue(const String& key, bool& value)
366 result r = E_OBJ_NOT_FOUND;
368 if(key == _NETWORK_FLIGHTMODE)
370 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support flightmode feature.");
371 bool flightModeEnabled = false;
373 errorCode = runtime_info_get_value_bool(RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED, &flightModeEnabled);
374 SysTryReturnResult(NID_SYS, errorCode == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get the RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED");
375 value = flightModeEnabled;
377 else if(key == _NETWORK_TELEPHONY_PACKETSERVICE)
379 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Telephony packet service feature.");
380 bool packetServiceAllowed = false;
382 errorCode = runtime_info_get_value_bool(RUNTIME_INFO_KEY_PACKET_DATA_ENABLED, &packetServiceAllowed);
383 SysTryReturnResult(NID_SYS, errorCode == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get the RUNTIME_INFO_KEY_PACKET_DATA_ENABLED");
384 value = packetServiceAllowed;
386 else if(key == _NETWORK_TELEPHONY_ROAMING)
388 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Telephony roaming feature.");
389 bool dataRoamingEnabled = false;
391 errorCode = runtime_info_get_value_bool(RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED, &dataRoamingEnabled);
392 SysTryReturnResult(NID_SYS, errorCode == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get the RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED");
393 value = dataRoamingEnabled;
395 else if (key == _NETWORK_WIFI)
398 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
400 bool wifiState = false;
401 errorCode = wifi_is_activated(&wifiState);
402 SysTryReturnResult(NID_SYS, errorCode == WIFI_ERROR_NONE, E_SYSTEM, "It is failed to get from wifi_is_activated.");
405 else if (key == _NETWORK_WIFI_NOTIFICATION)
409 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
411 errorCode = vconf_get_int(VCONFKEY_WIFI_ENABLE_QS, &wifiQSState);
412 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_WIFI_ENABLE_QS vconf.");
414 if(wifiQSState == VCONFKEY_WIFI_QS_DISABLE)
423 else if (key == _NETWORK_WIFI_TETHERING)
426 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi tethering feature.");
427 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_SYSTEM, "It is failed to get tethering handle.");
429 value = tethering_is_enabled(__tetheringHandle, TETHERING_TYPE_WIFI);
431 else if (key == _NETWORK_WIFI_TETHERING_HIDE)
434 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi tethering feature.");
435 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_SYSTEM, "It is failed to get tethering handle.");
437 errorCode = tethering_wifi_get_ssid_visibility(__tetheringHandle, &value);
438 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to get wifi tethering visibility state");
440 else if (key == _NETWORK_WIFI_TETHERING_SECURITY)
442 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi tethering feature.");
443 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_SYSTEM, "It is failed to get tethering handle.");
446 tethering_wifi_security_type_e securityType;
447 errorCode = tethering_wifi_get_security_type(__tetheringHandle, &securityType);
448 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to get wifi tethering securiy state");
449 if(securityType == TETHERING_WIFI_SECURITY_TYPE_NONE)
458 else if (key == _USB_TETHERING)
461 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support USB tethering feature.");
462 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_SYSTEM, "It is failed to get tethering handle.");
464 value = tethering_is_enabled(__tetheringHandle, TETHERING_TYPE_USB);
466 else if (key == _NETWORK_WIFI_DIRECT)
468 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi direct feature.");
472 errorCode = vconf_get_int(VCONFKEY_WIFI_DIRECT_STATE, &isActivated);
473 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_WIFI_ENABLE_QS vconf.");
484 else if (key == _NETWORK_BLUETOOTH)
486 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Bluetooth feature.");
488 int bluetoothStatus = VCONFKEY_BT_STATUS_OFF;
489 errorCode = vconf_get_int(VCONFKEY_BT_STATUS, &bluetoothStatus);
490 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to read bluetooth status.");
492 if(bluetoothStatus == VCONFKEY_BT_STATUS_OFF)
501 else if (key == _NETWORK_BLUETOOTH_TETHERING)
503 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Bluetooth tethering feature.");
504 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_SYSTEM, "It is failed to get tethering handle.");
507 value = tethering_is_enabled(__tetheringHandle, TETHERING_TYPE_BT);
513 _SettingNetworkProvider::SetValue(const String& key, const bool value)
516 result r = E_OBJ_NOT_FOUND;
518 if(key == _NETWORK_WIFI_NOTIFICATION)
520 int currentValue = 0;
522 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
523 errorCode = vconf_get_int(VCONFKEY_WIFI_ENABLE_QS, ¤tValue);
524 SysTryReturnResult(NID_SYS, errorCode != -1, E_UNSUPPORTED_OPERATION, "This device does not support %ls key.", key.GetPointer());
528 errorCode = vconf_set_int(VCONFKEY_WIFI_ENABLE_QS, VCONFKEY_WIFI_QS_ENABLE);
532 errorCode = vconf_set_int(VCONFKEY_WIFI_ENABLE_QS, VCONFKEY_WIFI_QS_DISABLE);
534 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_WIFI_ENABLE_QS vconf.");
536 else if(key == _NETWORK_WIFI_TETHERING)
540 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
541 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_SYSTEM, "It is failed to get tethering handle.");
543 r = GetValue(_NETWORK_WIFI, state);
544 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the WIFI state");
545 SysTryReturnResult(NID_SYS, state == true, E_INVALID_STATE, "WIFI is not activated");
549 errorCode = tethering_enable(__tetheringHandle, TETHERING_TYPE_WIFI);
553 errorCode = tethering_disable(__tetheringHandle, TETHERING_TYPE_WIFI);
555 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to change tethering option.");
557 else if(key == _NETWORK_WIFI_TETHERING_HIDE)
560 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
561 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_SYSTEM, "It is failed to get tethering handle.");
563 bool currentState = false;
564 errorCode = tethering_wifi_get_ssid_visibility(__tetheringHandle, ¤tState);
565 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to current wifi tethering visibility setting");
567 if(value == true && currentState == false)
569 errorCode = tethering_wifi_set_ssid_visibility(__tetheringHandle, true);
571 else if(value == false && currentState == true)
573 errorCode = tethering_wifi_set_ssid_visibility(__tetheringHandle, false);
575 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to change wifi tethering visibility setting");
577 else if(key == _NETWORK_WIFI_TETHERING_SECURITY)
580 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
581 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_SYSTEM, "It is failed to get tethering handle.");
583 tethering_wifi_security_type_e securityType;
585 errorCode = tethering_wifi_get_security_type(__tetheringHandle, &securityType);
586 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to get wifi tethering securiy state");
588 if(value == true && securityType == TETHERING_WIFI_SECURITY_TYPE_NONE)
590 errorCode = tethering_wifi_set_security_type(__tetheringHandle, TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK);
592 else if(value == false && securityType == TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK)
594 errorCode = tethering_wifi_set_security_type(__tetheringHandle, TETHERING_WIFI_SECURITY_TYPE_NONE);
596 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to change wifi tethering visibility setting");
598 else if(key == _USB_TETHERING)
601 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature.");
602 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_SYSTEM, "It is failed to get tethering handle.");
606 errorCode = tethering_enable(__tetheringHandle, TETHERING_TYPE_USB);
610 errorCode = tethering_disable(__tetheringHandle, TETHERING_TYPE_USB);
612 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to change tethering option");
614 else if(key == _NETWORK_BLUETOOTH_TETHERING)
617 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature.");
618 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_SYSTEM, "It is failed to get tethering handle.");
621 r = GetValue(_NETWORK_BLUETOOTH, state);
622 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the Bluetooth state");
623 SysTryReturnResult(NID_SYS, state == true, E_INVALID_STATE, "Bluetooth is not activated");
627 errorCode = tethering_enable(__tetheringHandle, TETHERING_TYPE_BT);
631 errorCode = tethering_disable(__tetheringHandle, TETHERING_TYPE_BT);
633 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to change tethering option");
639 _SettingNetworkProvider::SetValueAsync(const String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
642 result r = E_OBJ_NOT_FOUND;
644 if(key == _NETWORK_BLUETOOTH)
646 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Bluetooth feature.");
647 SysTryReturnResult(NID_SYS, __stateOfBluetooth == 0, E_IN_PROGRESS, "Bluetooth is under changing procedure.");
649 __stateOfBluetooth = 1;
650 __pBluetoothListener = listener;
652 SysLog(NID_SYS, "Required bluetooth value is %d.", value);
655 ret = bt_adapter_enable();
659 ret = bt_adapter_disable();
662 SysLog(NID_SYS, "bt_adapter returns %d.", ret);
667 SysLog(NID_SYS, "It is OK to change the bluetooth mode.");
670 case BT_ERROR_ALREADY_DONE:
671 SysLog(NID_SYS, "Bluetooth is already changed.");
672 SettingEventBluetooth(BT_ERROR_NONE, BT_ADAPTER_ENABLED, (void*)this);
674 case BT_ERROR_NOT_ENABLED:
675 SysLog(NID_SYS, "Bluetooth is not enabled.");
676 SettingEventBluetooth(BT_ERROR_NONE, BT_ADAPTER_ENABLED, (void*)this);
679 case BT_ERROR_NOW_IN_PROGRESS:
680 SysLog(NID_SYS, "Currently, Bluetooth change is in progress.");
681 __stateOfBluetooth = 0;
685 case BT_ERROR_NOT_INITIALIZED:
687 SysLog(NID_SYS, "There is an unknown error when changing the bluetooth mode.");
688 __stateOfBluetooth = 0;
697 _SettingNetworkProvider::SetValueForPrivilegedKey(const String& key, bool value)
700 result r = E_OBJ_NOT_FOUND;
701 if(key == _NETWORK_TELEPHONY_PACKETSERVICE)
703 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support telephony packet service feature.");
705 errorCode = vconf_set_bool(VCONFKEY_3G_ENABLE, value);
706 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_3G_ENABLE vconf.");
708 else if(key == _NETWORK_TELEPHONY_ROAMING)
710 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support telephony roaming feature.");
712 errorCode = vconf_set_bool(VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL, value);
713 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL vconf.");
719 _SettingNetworkProvider::SetValueAsyncForPrivilegedKey(const String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
722 result r = E_OBJ_NOT_FOUND;
724 if(key == _NETWORK_FLIGHTMODE)
726 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support flightmode feature.");
729 SysTryReturnResult(NID_SYS, __stateOfFlightMode == 0, E_IN_PROGRESS, "Flightmode is under changing procedure.");
730 __stateOfFlightMode = 1;
732 bool supported = false;
733 int ret = system_info_get_platform_bool("tizen.org/feature/network.telephony", &supported);
734 SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to get system information from configration file.");
736 __pFlightModeListener = listener;
737 if(supported == true)
739 if(__tapiHandle == null)
741 __tapiHandle = tel_init(null);
742 if(__tapiHandle == null)
744 __stateOfFlightMode = 0;
746 SysTryReturnResult(NID_SYS, __tapiHandle != null, E_SYSTEM, "Tapi is not ready.");
748 errorCode = tel_set_flight_mode(__tapiHandle,
749 value ? TAPI_POWER_FLIGHT_MODE_ENTER : TAPI_POWER_FLIGHT_MODE_LEAVE,
750 SettingEventFlightMode, (void*)this);
754 __stateOfFlightMode = 0;
756 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on Network Flight mode(%d).", errorCode);
760 FlightModeEnabler((void*)this);
763 else if(key == _NETWORK_WIFI)
765 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
766 SysTryReturnResult(NID_SYS, __stateOfWifi == 0 && __stateOfWifiDirect == 0, E_IN_PROGRESS, "Wifi processing is under way.");
770 SysLog(NID_SYS, "It creates thread for wifi enable[%d].", value);
772 bool wifiEnabled = false;
773 __pWifiListener = listener;
774 errorCode = wifi_is_activated(&wifiEnabled);
775 if(errorCode != WIFI_ERROR_NONE)
778 SysLogException(NID_SYS, E_SYSTEM, "It is failed to get current status of WIFI.");
782 if(value == wifiEnabled) //Wi-Fi is already changed.
784 SysLog(NID_SYS, "It is try to use dummy thread");
785 r = WifiDummy((void*)this);
786 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to set Wi-Fi state.");
792 errorCode = wifi_activate(SettingWifiActivateCallBack, (void*) this);
796 errorCode = wifi_deactivate(SettingWifiActivateCallBack, (void*) this);
799 if(errorCode != WIFI_ERROR_NONE)
805 else if(key == _NETWORK_WIFI_DIRECT)
807 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
808 SysTryReturnResult(NID_SYS, __stateOfWifi == 0 && __stateOfWifiDirect == 0, E_IN_PROGRESS, "Wifi processing is under way.");
811 __stateOfWifiDirect = 1;
812 SysLog(NID_SYS, "It creates thread for wifi direct enable[%d].", value);
815 __pWifiDirectListener = listener;
816 if(__wifiDirectInit == false)
818 SysLog(NID_SYS, "wifi direct init is started");
819 errorCode = wifi_direct_initialize();
820 SysLog(NID_SYS, "wifi direct init result is %d", errorCode);
821 SysTryReturnResult(NID_SYS, errorCode == WIFI_DIRECT_ERROR_NONE, E_SYSTEM, "It is failed to init wifi direct.");
822 errorCode = wifi_direct_set_device_state_changed_cb(SettingWifiDirectStateChangedCallBack, (void*) this);
823 SysTryReturnResult(NID_SYS, errorCode == WIFI_DIRECT_ERROR_NONE, E_SYSTEM, "It is failed to register wifi direct result callback.");
824 __wifiDirectInit = true;
828 wifi_direct_state_e wifi_direct_state;
829 errorCode = wifi_direct_get_state(&wifi_direct_state);
830 if(errorCode != WIFI_DIRECT_ERROR_NONE)
832 __stateOfWifiDirect = 0;
833 SysLogException(NID_SYS, E_SYSTEM, "It is failed to get current status of WIFI direct.");
837 if((value == false && wifi_direct_state == WIFI_DIRECT_STATE_DEACTIVATED)
838 || (value == true && wifi_direct_state != WIFI_DIRECT_STATE_DEACTIVATED))
840 SysLog(NID_SYS, "Required state is already applied.");
841 WifiDirectDummy((void*)this);
847 errorCode = wifi_direct_activate();
851 errorCode = wifi_direct_deactivate();
853 SysLog(NID_SYS, "wifi_direct_activate result is %d. value is %d.", errorCode, value);
864 _SettingNetworkProvider::WifiDummy(void* data)
866 result r = E_SUCCESS;
867 String settingKey(_NETWORK_WIFI);
868 _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
869 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
870 SysTryReturnResult(NID_SYS, (pSettingInfo != null && pProvider != null), E_SYSTEM, "There is no values of args.");
872 SysTryCatch(NID_SYS, pProvider->__stateOfWifi == 1, r = E_SYSTEM, E_SYSTEM, "There is invalid state.");
874 if(pProvider->__pWifiListener != null)
876 pProvider->__pWifiListener->OnResultReceivedForSetValueAsync(settingKey, E_SUCCESS);
878 r = pSettingInfo->AnnounceSettingEvent(settingKey);
879 SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
882 pProvider->__stateOfWifi = 0;
887 _SettingNetworkProvider::WifiDirectDummy(void* data)
889 result r = E_SUCCESS;
890 String settingKey(_NETWORK_WIFI_DIRECT);
891 _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
892 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
893 SysTryReturnResult(NID_SYS, (pSettingInfo != null && pProvider != null), E_SYSTEM, "There is no values of args.");
894 SysTryCatch(NID_SYS, pProvider->__stateOfWifiDirect == 1, E_SYSTEM, E_SYSTEM, "There is invalid state.");
896 if(pProvider->__pWifiDirectListener != null)
898 pProvider->__pWifiDirectListener->OnResultReceivedForSetValueAsync(settingKey, E_SUCCESS);
900 r = pSettingInfo->AnnounceSettingEvent(settingKey);
901 SysTryCatch(NID_SYS, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
904 pProvider->__stateOfWifiDirect = 0;
909 _SettingNetworkProvider::SettingWifiActivateCallBack(wifi_error_e errorCode, void* data)
911 String settingKey(_NETWORK_WIFI);
913 _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
914 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
915 SysTryReturnVoidResult(NID_SYS, (pSettingInfo != null && pProvider != null), E_SYSTEM, "There is no values of args.");
916 SysTryCatch(NID_SYS, pProvider->__stateOfWifi == 1, E_SYSTEM, E_SYSTEM, "Wi-Fi processing is under way.");
918 if(errorCode != WIFI_ERROR_NONE)
922 case WIFI_ERROR_INVALID_PARAMETER:
923 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by invalid param.");
925 case WIFI_ERROR_OUT_OF_MEMORY:
926 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by out of memory.");
928 case WIFI_ERROR_INVALID_OPERATION:
929 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by invalid operation.");
931 case WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
932 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by family not supported.");
934 case WIFI_ERROR_OPERATION_FAILED:
935 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by operation failed.");
937 case WIFI_ERROR_NO_CONNECTION:
938 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by no connection.");
940 case WIFI_ERROR_ALREADY_EXISTS:
941 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by already exist.");
943 case WIFI_ERROR_OPERATION_ABORTED:
944 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by operation aborted.");
946 case WIFI_ERROR_DHCP_FAILED:
947 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by DHCP fail.");
949 case WIFI_ERROR_INVALID_KEY:
950 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by invalid key.");
952 case WIFI_ERROR_NO_REPLY:
953 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by no reply.");
955 case WIFI_ERROR_SECURITY_RESTRICTED:
956 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by security restricted.");
958 case WIFI_ERROR_NOW_IN_PROGRESS:
959 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is under way.");
964 if(pProvider->__pWifiDirectListener != null)
966 pProvider->__pWifiDirectListener->OnResultReceivedForSetValueAsync(settingKey, E_SUCCESS);
969 pProvider->__stateOfWifi = 0;
973 _SettingNetworkProvider::SettingWifiDirectStateChangedCallBack(wifi_direct_error_e errorCode, wifi_direct_device_state_e deviceState, void* data)
975 result r = E_SUCCESS;
976 String settingKey(_NETWORK_WIFI_DIRECT);
978 _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
979 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
980 SysTryReturnVoidResult(NID_SYS, (pSettingInfo != null && pProvider != null), E_SYSTEM, "There is no values of args.");
982 SysTryCatch(NID_SYS, pProvider->__stateOfWifiDirect == 1 , E_SYSTEM, E_SYSTEM, "There is invalid state.");
984 if(errorCode != WIFI_DIRECT_ERROR_NONE)
989 if(pProvider->__pWifiDirectListener != null)
991 pProvider->__pWifiDirectListener->OnResultReceivedForSetValueAsync(settingKey, r);
995 pProvider->__stateOfWifiDirect = 0;
999 _SettingNetworkProvider::GetValue(const String& key, String& value)
1002 result r = E_OBJ_NOT_FOUND;
1004 if (key == _NETWORK_WIFI_TETHERING_SECURITY_PASSWORD)
1007 unique_ptr<char> password(null);
1009 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi tethering feature.");
1010 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_SYSTEM, "It is failed to get tethering handle.");
1012 errorCode = tethering_wifi_get_passphrase(__tetheringHandle, &pTemp);
1013 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE && pTemp != null, E_SYSTEM, "It is failed to get password");
1015 password.reset(pTemp);
1018 value.Append(password.get());
1024 _SettingNetworkProvider::SetValue(const String& key, const String value)
1027 result r = E_OBJ_NOT_FOUND;
1029 if(key ==_NETWORK_WIFI_TETHERING_SECURITY_PASSWORD)
1032 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi tethering feature.");
1033 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_SYSTEM, "It is failed to get tethering handle.");
1035 unique_ptr<char []> password(_StringConverter::CopyToCharArrayN(value));
1036 SysTryReturnResult(NID_SYS, password != null, E_SYSTEM, "It is failed to convert String to string");
1037 errorCode = tethering_wifi_set_passphrase(__tetheringHandle, password.get());
1038 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to set password");
1044 _SettingNetworkProvider::HasKey(const String& key)
1046 bool wifi_supported = false;
1047 bool wifi_direct_supported = false;
1048 bool bluetooth_supported = false;
1049 bool telephony_supported = false;
1051 int ret = system_info_get_platform_bool("tizen.org/feature/network.wifi", &wifi_supported);
1052 SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to get system information from configration file.");
1054 ret = system_info_get_platform_bool("tizen.org/feature/network.wifi.direct", &wifi_direct_supported);
1055 SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to get system information from configration file.");
1057 ret = system_info_get_platform_bool("tizen.org/feature/network.bluetooth", &bluetooth_supported);
1058 SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to get system information from configration file.");
1060 ret = system_info_get_platform_bool("tizen.org/feature/network.telephony", &telephony_supported);
1061 SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to get system information from configration file.");
1063 if(key == _NETWORK_FLIGHTMODE)
1067 else if(key == _NETWORK_TELEPHONY_PACKETSERVICE || key == _NETWORK_TELEPHONY_ROAMING)
1069 if(telephony_supported == true)
1074 else if(key == _NETWORK_WIFI || key == _NETWORK_WIFI_NOTIFICATION)
1076 if(wifi_supported == true)
1081 else if(key == _NETWORK_WIFI_DIRECT)
1083 if(wifi_direct_supported == true)
1088 else if(key == _NETWORK_WIFI_TETHERING || key == _NETWORK_WIFI_TETHERING_HIDE
1089 || key == _NETWORK_WIFI_TETHERING_SECURITY || key == _NETWORK_WIFI_TETHERING_SECURITY_PASSWORD || key == _USB_TETHERING)
1091 bool isSupported = false;
1092 int errorCode = system_info_get_value_bool(SYSTEM_INFO_KEY_TETHERING_SUPPORTED, &isSupported);
1094 if(errorCode == SYSTEM_INFO_ERROR_NONE && isSupported == true)
1099 else if(key == _NETWORK_BLUETOOTH)
1101 if(bluetooth_supported == true)
1106 else if(key == _NETWORK_BLUETOOTH_TETHERING)
1108 if(__tetheringHandle != null && bluetooth_supported == true)
1117 _SettingNetworkProvider::SettingEventRuntimeInfo(runtime_info_key_e key, void* userData)
1121 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
1122 SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "SettingInfo is not ready.");
1124 if(key == RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED)
1126 settingKey.Append(_NETWORK_FLIGHTMODE);
1128 else if(key == RUNTIME_INFO_KEY_PACKET_DATA_ENABLED)
1130 settingKey.Append(_NETWORK_TELEPHONY_PACKETSERVICE);
1132 else if(key == RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED)
1134 settingKey.Append(_NETWORK_TELEPHONY_ROAMING);
1138 SysLogException(NID_SYS, E_SYSTEM, "It is not supported key.");
1142 result r = pSettingInfo->AnnounceSettingEvent(settingKey);
1143 SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
1147 _SettingNetworkProvider::SettingEventVConf(keynode_t* node, void* userData)
1149 result r = E_SUCCESS;
1151 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
1152 SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
1154 if (strcmp(VCONFKEY_WIFI_STATE, vconf_keynode_get_name(node)) == 0)
1156 int state = VCONFKEY_WIFI_OFF;
1158 errorCode = vconf_get_int(VCONFKEY_WIFI_STATE, &state);
1160 if(errorCode == 0 && (state == VCONFKEY_WIFI_OFF || state == VCONFKEY_WIFI_UNCONNECTED))
1162 settingKey.Append(_NETWORK_WIFI);
1163 r = pSettingInfo->AnnounceSettingEvent(settingKey);
1164 SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
1168 else if (strcmp(VCONFKEY_WIFI_ENABLE_QS, vconf_keynode_get_name(node)) == 0)
1170 settingKey.Append(_NETWORK_WIFI_NOTIFICATION);
1172 else if (strcmp(VCONFKEY_WIFI_DIRECT_STATE, vconf_keynode_get_name(node)) == 0)
1174 int state = VCONFKEY_WIFI_DIRECT_DEACTIVATED;
1176 errorCode = vconf_get_int(VCONFKEY_WIFI_DIRECT_STATE, &state);
1177 SysLog(NID_SYS, "Wi-Fi Direct state is changed. %d", state);
1178 if(errorCode == 0 && (state == VCONFKEY_WIFI_DIRECT_DEACTIVATED || state == VCONFKEY_WIFI_DIRECT_ACTIVATED))
1180 settingKey.Append(_NETWORK_WIFI_DIRECT);
1181 r = pSettingInfo->AnnounceSettingEvent(settingKey);
1182 SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
1186 else if (strcmp(VCONFKEY_BT_STATUS, vconf_keynode_get_name(node)) == 0)
1188 settingKey.Append(_NETWORK_BLUETOOTH);
1190 else if (strcmp(VCONFKEY_MOBILE_HOTSPOT_SECURITY, vconf_keynode_get_name(node)) == 0)
1192 settingKey.Append(_NETWORK_WIFI_TETHERING_SECURITY);
1194 else if (strcmp(VCONFKEY_MOBILE_HOTSPOT_HIDE, vconf_keynode_get_name(node)) == 0)
1196 settingKey.Append(_NETWORK_WIFI_TETHERING_HIDE);
1200 SysLogException(NID_SYS, E_SYSTEM, "It is not supported key.");
1204 r = pSettingInfo->AnnounceSettingEvent(settingKey);
1205 SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
1209 _SettingNetworkProvider::SettingEventTetheringEnabled(tethering_error_e err, tethering_type_e type, bool is_requested, void* data)
1212 SysLog(NID_SYS, "Tethering Endabled Event is occured.");
1214 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
1215 SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
1219 case TETHERING_TYPE_USB:
1220 settingKey.Append(_USB_TETHERING);
1222 case TETHERING_TYPE_WIFI:
1223 settingKey.Append(_NETWORK_WIFI_TETHERING);
1225 case TETHERING_TYPE_BT:
1226 settingKey.Append(_NETWORK_BLUETOOTH_TETHERING);
1232 result r = pSettingInfo->AnnounceSettingEvent(settingKey);
1233 SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
1237 _SettingNetworkProvider::SettingEventTetheringDisabled(tethering_error_e err, tethering_type_e type, tethering_disabled_cause_e cause,void* data)
1239 SysLog(NID_SYS, "Tethering Disabled Event is occured.");
1240 SettingEventTetheringEnabled(err, type, false, null);
1244 _SettingNetworkProvider::SettingEventFlightMode(TapiHandle* handle, int res, void* data, void* user_data)
1246 String settingKey(_NETWORK_FLIGHTMODE);
1248 result r = E_SUCCESS;
1249 SysLog(NID_SYS, "Flightmode response is handle:%x, res:%d, date:%x, user_data:%x", handle, res, data, user_data);
1251 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
1252 SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "SettingInfo is not ready.");
1253 _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)user_data;
1254 SysTryReturnVoidResult(NID_SYS, pProvider != null, E_SYSTEM, "There is invalid provider.");
1255 SysTryCatch(NID_SYS, pProvider->__stateOfFlightMode == 1, E_SYSTEM, E_SYSTEM, "Current state of flight mode is not valid.");
1259 case TAPI_POWER_FLIGHT_MODE_RESP_ON:
1260 SysLog(NID_SYS, "It successes to change flight mode on");
1262 errorCode = vconf_set_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, true);
1265 SysLogException(NID_SYS, E_SYSTEM, "It is failed to set on VCONFKEY_TELEPHONY_FLIGHT_MODE vconf.");
1269 case TAPI_POWER_FLIGHT_MODE_RESP_OFF:
1270 SysLog(NID_SYS, "It successes to change flight mode off");
1272 errorCode = vconf_set_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, false);
1275 SysLogException(NID_SYS, E_SYSTEM, "It is failed to set on VCONFKEY_TELEPHONY_FLIGHT_MODE vconf.");
1279 case TAPI_POWER_FLIGHT_MODE_RESP_FAIL:
1281 SysLogException(NID_SYS, E_SYSTEM, "It is failed to change flight mode");
1285 if(pProvider->__pFlightModeListener != null)
1287 pProvider->__pFlightModeListener->OnResultReceivedForSetValueAsync(settingKey, r);
1291 pProvider->__stateOfFlightMode = 0;
1295 _SettingNetworkProvider::FlightModeEnabler(void* data)
1297 result r = E_SUCCESS;
1299 String settingKey(_NETWORK_FLIGHTMODE);
1301 _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
1302 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
1303 SysTryReturnResult(NID_SYS, pProvider != null && pSettingInfo != null, E_SYSTEM, "Provider or SettingInfo is not ready.");
1304 SysTryCatch(NID_SYS, pProvider->__stateOfFlightMode == 1, E_SYSTEM, E_SYSTEM, "Current state of flight mode is not valid.");
1306 errorCode = vconf_set_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, pProvider->__flightModeEnabled);
1309 SysLogException(NID_SYS, E_SYSTEM, "It is failed to set on VCONFKEY_TELEPHONY_FLIGHT_MODE vconf.");
1314 if(pProvider->__pFlightModeListener != null)
1316 pProvider->__pFlightModeListener->OnResultReceivedForSetValueAsync(settingKey, r);
1320 pProvider->__stateOfFlightMode = 0;
1325 _SettingNetworkProvider::SettingEventBluetooth(int res, bt_adapter_state_e adapter_state, void* user_data)
1327 String settingKey(_NETWORK_BLUETOOTH);
1328 result r = E_SUCCESS;
1329 SysLog(NID_SYS, "Bluetooth callback is invoked. result:%d, adapter_state:%d, user_data:%x", res, adapter_state, user_data);
1331 _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)user_data;
1332 SysTryReturnVoidResult(NID_SYS, pProvider != null, E_SYSTEM, "There is no values of args.");
1333 SysTryCatch(NID_SYS, pProvider->__stateOfBluetooth == 1, E_SYSTEM, E_SYSTEM, "Bluetooth processing is under way.");
1335 if(res == BT_ERROR_NONE)
1344 if(pProvider->__pBluetoothListener != null && pProvider->__stateOfBluetooth == 1)
1346 pProvider->__pBluetoothListener->OnResultReceivedForSetValueAsync(settingKey, r);
1351 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
1352 SysTryCatch(NID_SYS, pSettingInfo != null, E_SYSTEM, E_SYSTEM, "_SettingInfo is not ready.");
1354 result r = pSettingInfo->AnnounceSettingEvent(settingKey);
1355 SysTryCatch(NID_SYS, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
1359 pProvider->__stateOfBluetooth = 0;