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.");
920 case WIFI_ERROR_INVALID_PARAMETER:
921 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by invalid param.");
923 case WIFI_ERROR_OUT_OF_MEMORY:
924 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by out of memory.");
926 case WIFI_ERROR_INVALID_OPERATION:
927 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by invalid operation.");
929 case WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
930 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by family not supported.");
932 case WIFI_ERROR_OPERATION_FAILED:
933 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by operation failed.");
935 case WIFI_ERROR_NO_CONNECTION:
936 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by no connection.");
938 case WIFI_ERROR_ALREADY_EXISTS:
939 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by already exist.");
941 case WIFI_ERROR_OPERATION_ABORTED:
942 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by operation aborted.");
944 case WIFI_ERROR_DHCP_FAILED:
945 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by DHCP fail.");
947 case WIFI_ERROR_INVALID_KEY:
948 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by invalid key.");
950 case WIFI_ERROR_NO_REPLY:
951 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by no reply.");
953 case WIFI_ERROR_SECURITY_RESTRICTED:
954 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by security restricted.");
956 case WIFI_ERROR_NOW_IN_PROGRESS:
957 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is under way.");
959 case WIFI_ERROR_NONE:
960 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is work properly");
964 if(pProvider->__pWifiListener != null)
966 SysLog(NID_SYS, "Wi-Fi result is forwarded.");
967 pProvider->__pWifiListener->OnResultReceivedForSetValueAsync(settingKey, E_SUCCESS);
971 SysLog(NID_SYS, "There is no listener.");
974 pProvider->__stateOfWifi = 0;
978 _SettingNetworkProvider::SettingWifiDirectStateChangedCallBack(wifi_direct_error_e errorCode, wifi_direct_device_state_e deviceState, void* data)
980 result r = E_SUCCESS;
981 String settingKey(_NETWORK_WIFI_DIRECT);
983 _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
984 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
985 SysTryReturnVoidResult(NID_SYS, (pSettingInfo != null && pProvider != null), E_SYSTEM, "There is no values of args.");
987 SysTryCatch(NID_SYS, pProvider->__stateOfWifiDirect == 1 , E_SYSTEM, E_SYSTEM, "There is invalid state.");
989 if(errorCode != WIFI_DIRECT_ERROR_NONE)
994 if(pProvider->__pWifiDirectListener != null)
996 pProvider->__pWifiDirectListener->OnResultReceivedForSetValueAsync(settingKey, r);
1000 pProvider->__stateOfWifiDirect = 0;
1004 _SettingNetworkProvider::GetValue(const String& key, String& value)
1007 result r = E_OBJ_NOT_FOUND;
1010 if (key == _NETWORK_WIFI_TETHERING_SECURITY_PASSWORD)
1013 unique_ptr<char> password(null);
1015 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi tethering feature.");
1016 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_SYSTEM, "It is failed to get tethering handle.");
1018 errorCode = tethering_wifi_get_passphrase(__tetheringHandle, &pTemp);
1019 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE && pTemp != null, E_SYSTEM, "It is failed to get password");
1021 password.reset(pTemp);
1024 value.Append(password.get());
1031 _SettingNetworkProvider::SetValue(const String& key, const String value)
1034 result r = E_OBJ_NOT_FOUND;
1036 if(key ==_NETWORK_WIFI_TETHERING_SECURITY_PASSWORD)
1039 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi tethering feature.");
1040 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_SYSTEM, "It is failed to get tethering handle.");
1042 unique_ptr<char []> password(_StringConverter::CopyToCharArrayN(value));
1043 SysTryReturnResult(NID_SYS, password != null, E_SYSTEM, "It is failed to convert String to string");
1044 errorCode = tethering_wifi_set_passphrase(__tetheringHandle, password.get());
1045 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to set password");
1052 _SettingNetworkProvider::HasKey(const String& key)
1054 bool wifi_supported = false;
1055 bool wifi_direct_supported = false;
1056 bool bluetooth_supported = false;
1057 bool telephony_supported = false;
1059 int ret = system_info_get_platform_bool("tizen.org/feature/network.wifi", &wifi_supported);
1060 SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to get system information from configration file.");
1062 ret = system_info_get_platform_bool("tizen.org/feature/network.wifi.direct", &wifi_direct_supported);
1063 SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to get system information from configration file.");
1065 ret = system_info_get_platform_bool("tizen.org/feature/network.bluetooth", &bluetooth_supported);
1066 SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to get system information from configration file.");
1068 ret = system_info_get_platform_bool("tizen.org/feature/network.telephony", &telephony_supported);
1069 SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to get system information from configration file.");
1071 if(key == _NETWORK_FLIGHTMODE)
1075 else if(key == _NETWORK_TELEPHONY_PACKETSERVICE || key == _NETWORK_TELEPHONY_ROAMING)
1077 if(telephony_supported == true)
1082 else if(key == _NETWORK_WIFI || key == _NETWORK_WIFI_NOTIFICATION)
1084 if(wifi_supported == true)
1089 else if(key == _NETWORK_WIFI_DIRECT)
1091 if(wifi_direct_supported == true)
1096 else if(key == _NETWORK_WIFI_TETHERING || key == _NETWORK_WIFI_TETHERING_HIDE
1097 || key == _NETWORK_WIFI_TETHERING_SECURITY /*|| key == _NETWORK_WIFI_TETHERING_SECURITY_PASSWORD*/ || key == _USB_TETHERING)
1099 bool isSupported = false;
1100 int errorCode = system_info_get_value_bool(SYSTEM_INFO_KEY_TETHERING_SUPPORTED, &isSupported);
1102 if(errorCode == SYSTEM_INFO_ERROR_NONE && isSupported == true)
1107 else if(key == _NETWORK_BLUETOOTH)
1109 if(bluetooth_supported == true)
1114 else if(key == _NETWORK_BLUETOOTH_TETHERING)
1116 if(__tetheringHandle != null && bluetooth_supported == true)
1125 _SettingNetworkProvider::SettingEventRuntimeInfo(runtime_info_key_e key, void* userData)
1129 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
1130 SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "SettingInfo is not ready.");
1132 if(key == RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED)
1134 settingKey.Append(_NETWORK_FLIGHTMODE);
1136 else if(key == RUNTIME_INFO_KEY_PACKET_DATA_ENABLED)
1138 settingKey.Append(_NETWORK_TELEPHONY_PACKETSERVICE);
1140 else if(key == RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED)
1142 settingKey.Append(_NETWORK_TELEPHONY_ROAMING);
1146 SysLogException(NID_SYS, E_SYSTEM, "It is not supported key.");
1150 result r = pSettingInfo->AnnounceSettingEvent(settingKey);
1151 SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
1155 _SettingNetworkProvider::SettingEventVConf(keynode_t* node, void* userData)
1157 result r = E_SUCCESS;
1159 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
1160 SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
1162 if (strcmp(VCONFKEY_WIFI_STATE, vconf_keynode_get_name(node)) == 0)
1164 int state = VCONFKEY_WIFI_OFF;
1166 errorCode = vconf_get_int(VCONFKEY_WIFI_STATE, &state);
1168 if(errorCode == 0 && (state == VCONFKEY_WIFI_OFF || state == VCONFKEY_WIFI_UNCONNECTED))
1170 settingKey.Append(_NETWORK_WIFI);
1171 r = pSettingInfo->AnnounceSettingEvent(settingKey);
1172 SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
1176 else if (strcmp(VCONFKEY_WIFI_ENABLE_QS, vconf_keynode_get_name(node)) == 0)
1178 settingKey.Append(_NETWORK_WIFI_NOTIFICATION);
1180 else if (strcmp(VCONFKEY_WIFI_DIRECT_STATE, vconf_keynode_get_name(node)) == 0)
1182 int state = VCONFKEY_WIFI_DIRECT_DEACTIVATED;
1184 errorCode = vconf_get_int(VCONFKEY_WIFI_DIRECT_STATE, &state);
1185 SysLog(NID_SYS, "Wi-Fi Direct state is changed. %d", state);
1186 if(errorCode == 0 && (state == VCONFKEY_WIFI_DIRECT_DEACTIVATED || state == VCONFKEY_WIFI_DIRECT_ACTIVATED))
1188 settingKey.Append(_NETWORK_WIFI_DIRECT);
1189 r = pSettingInfo->AnnounceSettingEvent(settingKey);
1190 SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
1194 else if (strcmp(VCONFKEY_BT_STATUS, vconf_keynode_get_name(node)) == 0)
1196 settingKey.Append(_NETWORK_BLUETOOTH);
1198 else if (strcmp(VCONFKEY_MOBILE_HOTSPOT_SECURITY, vconf_keynode_get_name(node)) == 0)
1200 settingKey.Append(_NETWORK_WIFI_TETHERING_SECURITY);
1202 else if (strcmp(VCONFKEY_MOBILE_HOTSPOT_HIDE, vconf_keynode_get_name(node)) == 0)
1204 settingKey.Append(_NETWORK_WIFI_TETHERING_HIDE);
1208 SysLogException(NID_SYS, E_SYSTEM, "It is not supported key.");
1212 r = pSettingInfo->AnnounceSettingEvent(settingKey);
1213 SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
1217 _SettingNetworkProvider::SettingEventTetheringEnabled(tethering_error_e err, tethering_type_e type, bool is_requested, void* data)
1220 SysLog(NID_SYS, "Tethering Endabled Event is occured.");
1222 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
1223 SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
1227 case TETHERING_TYPE_USB:
1228 settingKey.Append(_USB_TETHERING);
1230 case TETHERING_TYPE_WIFI:
1231 settingKey.Append(_NETWORK_WIFI_TETHERING);
1233 case TETHERING_TYPE_BT:
1234 settingKey.Append(_NETWORK_BLUETOOTH_TETHERING);
1240 result r = pSettingInfo->AnnounceSettingEvent(settingKey);
1241 SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
1245 _SettingNetworkProvider::SettingEventTetheringDisabled(tethering_error_e err, tethering_type_e type, tethering_disabled_cause_e cause,void* data)
1247 SysLog(NID_SYS, "Tethering Disabled Event is occured.");
1248 SettingEventTetheringEnabled(err, type, false, null);
1252 _SettingNetworkProvider::SettingEventFlightMode(TapiHandle* handle, int res, void* data, void* user_data)
1254 String settingKey(_NETWORK_FLIGHTMODE);
1256 result r = E_SUCCESS;
1257 SysLog(NID_SYS, "Flightmode response is handle:%x, res:%d, date:%x, user_data:%x", handle, res, data, user_data);
1259 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
1260 SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "SettingInfo is not ready.");
1261 _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)user_data;
1262 SysTryReturnVoidResult(NID_SYS, pProvider != null, E_SYSTEM, "There is invalid provider.");
1263 SysTryCatch(NID_SYS, pProvider->__stateOfFlightMode == 1, E_SYSTEM, E_SYSTEM, "Current state of flight mode is not valid.");
1267 case TAPI_POWER_FLIGHT_MODE_RESP_ON:
1268 SysLog(NID_SYS, "It successes to change flight mode on");
1270 errorCode = vconf_set_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, true);
1273 SysLogException(NID_SYS, E_SYSTEM, "It is failed to set on VCONFKEY_TELEPHONY_FLIGHT_MODE vconf.");
1277 case TAPI_POWER_FLIGHT_MODE_RESP_OFF:
1278 SysLog(NID_SYS, "It successes to change flight mode off");
1280 errorCode = vconf_set_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, false);
1283 SysLogException(NID_SYS, E_SYSTEM, "It is failed to set on VCONFKEY_TELEPHONY_FLIGHT_MODE vconf.");
1287 case TAPI_POWER_FLIGHT_MODE_RESP_FAIL:
1289 SysLogException(NID_SYS, E_SYSTEM, "It is failed to change flight mode");
1293 if(pProvider->__pFlightModeListener != null)
1295 pProvider->__pFlightModeListener->OnResultReceivedForSetValueAsync(settingKey, r);
1299 pProvider->__stateOfFlightMode = 0;
1303 _SettingNetworkProvider::FlightModeEnabler(void* data)
1305 result r = E_SUCCESS;
1307 String settingKey(_NETWORK_FLIGHTMODE);
1309 _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
1310 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
1311 SysTryReturnResult(NID_SYS, pProvider != null && pSettingInfo != null, E_SYSTEM, "Provider or SettingInfo is not ready.");
1312 SysTryCatch(NID_SYS, pProvider->__stateOfFlightMode == 1, E_SYSTEM, E_SYSTEM, "Current state of flight mode is not valid.");
1314 errorCode = vconf_set_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, pProvider->__flightModeEnabled);
1317 SysLogException(NID_SYS, E_SYSTEM, "It is failed to set on VCONFKEY_TELEPHONY_FLIGHT_MODE vconf.");
1322 if(pProvider->__pFlightModeListener != null)
1324 pProvider->__pFlightModeListener->OnResultReceivedForSetValueAsync(settingKey, r);
1328 pProvider->__stateOfFlightMode = 0;
1333 _SettingNetworkProvider::SettingEventBluetooth(int res, bt_adapter_state_e adapter_state, void* user_data)
1335 String settingKey(_NETWORK_BLUETOOTH);
1336 result r = E_SUCCESS;
1337 SysLog(NID_SYS, "Bluetooth callback is invoked. result:%d, adapter_state:%d, user_data:%x", res, adapter_state, user_data);
1339 _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)user_data;
1340 SysTryReturnVoidResult(NID_SYS, pProvider != null, E_SYSTEM, "There is no values of args.");
1341 SysTryCatch(NID_SYS, pProvider->__stateOfBluetooth == 1, E_SYSTEM, E_SYSTEM, "Bluetooth processing is under way.");
1343 if(res == BT_ERROR_NONE)
1352 if(pProvider->__pBluetoothListener != null && pProvider->__stateOfBluetooth == 1)
1354 pProvider->__pBluetoothListener->OnResultReceivedForSetValueAsync(settingKey, r);
1359 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
1360 SysTryCatch(NID_SYS, pSettingInfo != null, E_SYSTEM, E_SYSTEM, "_SettingInfo is not ready.");
1362 result r = pSettingInfo->AnnounceSettingEvent(settingKey);
1363 SysTryCatch(NID_SYS, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
1367 pProvider->__stateOfBluetooth = 0;