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 , __stateOfFlightMode(0)
90 , __stateOfWifiDirect(0)
91 , __stateOfBluetooth(0)
92 , __flightModeEnabled(false)
93 , __networkBluetoothEnabled(false)
95 , __wifiDirectInit(false)
96 , __pWifiListener(null)
97 , __pWifiDirectListener(null)
98 , __pFlightModeListener(null)
99 , __pBluetoothListener(null)
101 int errorCode = bt_initialize();
104 //For multiple usage, deinitialize should not be called when it terminated.
105 SysLogException(NID_SYS, E_SYSTEM, "It is failed to initialize bluetooth.");
108 errorCode = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED, SettingEventRuntimeInfo, null);
111 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register flight mode event listener");
114 errorCode = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_PACKET_DATA_ENABLED, SettingEventRuntimeInfo, null);
117 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register packet data event listener");
120 errorCode = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED, SettingEventRuntimeInfo, null);
123 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register roaming event listener");
126 errorCode = vconf_notify_key_changed(VCONFKEY_WIFI_STATE, SettingEventVConf, null);
129 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_WIFI_STATE listener");
132 errorCode = tethering_create(&__tetheringHandle);
135 SysLogException(NID_SYS, E_SYSTEM, "It is failed to create tethering handle");
138 errorCode = tethering_set_enabled_cb(__tetheringHandle, TETHERING_TYPE_USB, SettingEventTetheringEnabled, null);
141 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register TETHERING_TYPE_USB listener");
144 errorCode = tethering_set_enabled_cb(__tetheringHandle, TETHERING_TYPE_WIFI, SettingEventTetheringEnabled, null);
147 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register TETHERING_TYPE_WIFI listener");
150 errorCode = tethering_set_enabled_cb(__tetheringHandle, TETHERING_TYPE_BT, SettingEventTetheringEnabled, null);
153 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register TETHERING_TYPE_BT listener");
156 errorCode = tethering_set_disabled_cb(__tetheringHandle, TETHERING_TYPE_USB, SettingEventTetheringDisabled, null);
159 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register TETHERING_TYPE_USB listener");
162 errorCode = tethering_set_disabled_cb(__tetheringHandle, TETHERING_TYPE_WIFI, SettingEventTetheringDisabled, null);
165 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register TETHERING_TYPE_WIFI listener");
168 errorCode = tethering_set_disabled_cb(__tetheringHandle, TETHERING_TYPE_BT, SettingEventTetheringDisabled, null);
171 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register TETHERING_TYPE_BT listener");
174 errorCode = vconf_notify_key_changed(VCONFKEY_WIFI_DIRECT_STATE, SettingEventVConf, null);
177 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_WIFI_DIRECT_STATE listener");
180 errorCode = vconf_notify_key_changed(VCONFKEY_BT_STATUS, SettingEventVConf, null);
183 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_BT_STATUS listener");
186 errorCode = vconf_notify_key_changed(VCONFKEY_MOBILE_HOTSPOT_SECURITY, SettingEventVConf, null);
189 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_MOBILE_HOTSPOT_SECURITY listener");
192 errorCode = vconf_notify_key_changed(VCONFKEY_MOBILE_HOTSPOT_HIDE, SettingEventVConf, null);
195 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_MOBILE_HOTSPOT_HIDE listener");
198 errorCode = vconf_notify_key_changed(VCONFKEY_WIFI_ENABLE_QS, SettingEventVConf, null);
201 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_WIFI_ENABLE_QS listener");
204 errorCode = bt_adapter_set_state_changed_cb(SettingEventBluetooth, (void*)this);
207 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register bluetooth listener");
210 if(__wifiInit == false)
212 SysLog(NID_SYS, "wifi init is started");
213 errorCode = wifi_initialize();
214 SysLog(NID_SYS, "wifi init result is %d", errorCode);
220 _SettingNetworkProvider::~_SettingNetworkProvider()
222 int errorCode = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED);
225 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister flight mode event listener");
228 errorCode = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_PACKET_DATA_ENABLED);
231 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister packet data event listener");
234 errorCode = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED);
237 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister roaming event listener");
240 errorCode = vconf_ignore_key_changed(VCONFKEY_WIFI_STATE, SettingEventVConf);
243 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_WIFI_STATE listener");
246 errorCode = tethering_unset_enabled_cb(__tetheringHandle, TETHERING_TYPE_USB);
249 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_USB listener");
252 errorCode = tethering_unset_enabled_cb(__tetheringHandle, TETHERING_TYPE_WIFI);
255 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_WIFI listener");
258 errorCode = tethering_unset_enabled_cb(__tetheringHandle, TETHERING_TYPE_BT);
261 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_BT listener");
264 errorCode = tethering_unset_disabled_cb(__tetheringHandle, TETHERING_TYPE_USB);
267 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_USB listener");
270 errorCode = tethering_unset_disabled_cb(__tetheringHandle, TETHERING_TYPE_WIFI);
273 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_WIFI listener");
276 errorCode = tethering_unset_disabled_cb(__tetheringHandle, TETHERING_TYPE_BT);
279 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_BT listener");
282 tethering_destroy(__tetheringHandle);
283 __tetheringHandle = null;
285 errorCode = vconf_ignore_key_changed(VCONFKEY_WIFI_DIRECT_STATE, SettingEventVConf);
288 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_WIFI_DIRECT_STATE listener");
290 errorCode = vconf_ignore_key_changed(VCONFKEY_BT_STATUS, SettingEventVConf);
293 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_BT_STATUS listener");
296 errorCode = vconf_ignore_key_changed(VCONFKEY_MOBILE_HOTSPOT_SECURITY, SettingEventVConf);
299 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_MOBILE_HOTSPOT_SECURITY listener");
302 errorCode = vconf_ignore_key_changed(VCONFKEY_MOBILE_HOTSPOT_HIDE, SettingEventVConf);
305 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_MOBILE_HOTSPOT_HIDE listener");
308 errorCode = vconf_ignore_key_changed(VCONFKEY_WIFI_ENABLE_QS, SettingEventVConf);
311 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_WIFI_ENABLE_QS listener");
314 errorCode = bt_adapter_unset_state_changed_cb();
317 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister bluetooth listener");
320 errorCode = bt_deinitialize();
323 SysLogException(NID_SYS, E_SYSTEM, "It is failed to deinitialize bluetooth.");
326 if(__wifiDirectInit == true)
328 errorCode = wifi_direct_unset_device_state_changed_cb();
329 if(errorCode == WIFI_DIRECT_ERROR_NONE)
331 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister Wi-Fi direct callback.");
334 errorCode = wifi_direct_deinitialize();
335 if(errorCode == WIFI_DIRECT_ERROR_NONE)
337 SysLogException(NID_SYS, E_SYSTEM, "It is failed to deinitialize Wi-Fi direct.");
339 SysLog(NID_SYS, "Wifi direct de-init result is %d.", errorCode);
340 __wifiDirectInit = false;
343 if(__wifiInit == true)
345 errorCode = wifi_deinitialize();
346 if(errorCode == WIFI_ERROR_NONE)
348 SysLogException(NID_SYS, E_SYSTEM, "It is failed to deinitialize Wi-Fi.");
350 SysLog(NID_SYS, "Wifi de-init result is %d.", errorCode);
353 SysLog(NID_SYS, "Network Provider is terminated properly.");
357 _SettingNetworkProvider::GetValue(const String& key, bool& value)
360 result r = E_OBJ_NOT_FOUND;
362 if(key == _NETWORK_FLIGHTMODE)
364 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support flightmode feature.");
365 bool flightModeEnabled = false;
367 errorCode = runtime_info_get_value_bool(RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED, &flightModeEnabled);
368 SysTryReturnResult(NID_SYS, errorCode == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get the RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED");
369 value = flightModeEnabled;
371 else if(key == _NETWORK_TELEPHONY_PACKETSERVICE)
373 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Telephony packet service feature.");
374 bool packetServiceAllowed = false;
376 errorCode = runtime_info_get_value_bool(RUNTIME_INFO_KEY_PACKET_DATA_ENABLED, &packetServiceAllowed);
377 SysTryReturnResult(NID_SYS, errorCode == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get the RUNTIME_INFO_KEY_PACKET_DATA_ENABLED");
378 value = packetServiceAllowed;
380 else if(key == _NETWORK_TELEPHONY_ROAMING)
382 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Telephony roaming feature.");
383 bool dataRoamingEnabled = false;
385 errorCode = runtime_info_get_value_bool(RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED, &dataRoamingEnabled);
386 SysTryReturnResult(NID_SYS, errorCode == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get the RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED");
387 value = dataRoamingEnabled;
389 else if (key == _NETWORK_WIFI)
392 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
394 bool wifiState = false;
395 errorCode = wifi_is_activated(&wifiState);
396 SysTryReturnResult(NID_SYS, errorCode == WIFI_ERROR_NONE, E_SYSTEM, "It is failed to get from wifi_is_activated.");
399 else if (key == _NETWORK_WIFI_NOTIFICATION)
403 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
405 errorCode = vconf_get_int(VCONFKEY_WIFI_ENABLE_QS, &wifiQSState);
406 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_WIFI_ENABLE_QS vconf.");
408 if(wifiQSState == VCONFKEY_WIFI_QS_DISABLE)
417 else if (key == _NETWORK_WIFI_TETHERING)
420 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi tethering feature.");
421 value = tethering_is_enabled(__tetheringHandle, TETHERING_TYPE_WIFI);
423 else if (key == _NETWORK_WIFI_TETHERING_HIDE)
426 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi tethering feature.");
427 errorCode = tethering_wifi_get_ssid_visibility(__tetheringHandle, &value);
428 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to get wifi tethering visibility state");
430 else if (key == _NETWORK_WIFI_TETHERING_SECURITY)
432 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi tethering feature.");
434 tethering_wifi_security_type_e securityType;
435 errorCode = tethering_wifi_get_security_type(__tetheringHandle, &securityType);
436 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to get wifi tethering securiy state");
437 if(securityType == TETHERING_WIFI_SECURITY_TYPE_NONE)
446 else if (key == _USB_TETHERING)
449 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support USB tethering feature.");
450 value = tethering_is_enabled(__tetheringHandle, TETHERING_TYPE_USB);
452 else if (key == _NETWORK_WIFI_DIRECT)
454 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi direct feature.");
458 errorCode = vconf_get_int(VCONFKEY_WIFI_DIRECT_STATE, &isActivated);
459 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_WIFI_ENABLE_QS vconf.");
470 else if (key == _NETWORK_BLUETOOTH)
472 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Bluetooth feature.");
474 int bluetoothStatus = VCONFKEY_BT_STATUS_OFF;
475 errorCode = vconf_get_int(VCONFKEY_BT_STATUS, &bluetoothStatus);
476 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to read bluetooth status.");
478 if(bluetoothStatus == VCONFKEY_BT_STATUS_OFF)
487 else if (key == _NETWORK_BLUETOOTH_TETHERING)
489 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Bluetooth tethering feature.");
491 value = tethering_is_enabled(__tetheringHandle, TETHERING_TYPE_BT);
497 _SettingNetworkProvider::SetValue(const String& key, const bool value)
500 result r = E_OBJ_NOT_FOUND;
502 if(key == _NETWORK_WIFI_NOTIFICATION)
504 int currentValue = 0;
506 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
507 errorCode = vconf_get_int(VCONFKEY_WIFI_ENABLE_QS, ¤tValue);
508 SysTryReturnResult(NID_SYS, errorCode != -1, E_UNSUPPORTED_OPERATION, "This device does not support %ls key.", key.GetPointer());
512 errorCode = vconf_set_int(VCONFKEY_WIFI_ENABLE_QS, VCONFKEY_WIFI_QS_ENABLE);
516 errorCode = vconf_set_int(VCONFKEY_WIFI_ENABLE_QS, VCONFKEY_WIFI_QS_DISABLE);
518 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_WIFI_ENABLE_QS vconf.");
520 else if(key == _NETWORK_WIFI_TETHERING)
524 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
525 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature.");
526 r = GetValue(_NETWORK_WIFI, state);
527 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the WIFI state");
528 SysTryReturnResult(NID_SYS, state == true, E_INVALID_STATE, "WIFI is not activated");
532 errorCode = tethering_enable(__tetheringHandle, TETHERING_TYPE_WIFI);
536 errorCode = tethering_disable(__tetheringHandle, TETHERING_TYPE_WIFI);
538 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to change tethering option.");
540 else if(key == _NETWORK_WIFI_TETHERING_HIDE)
543 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
545 bool currentState = false;
546 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature.");
547 errorCode = tethering_wifi_get_ssid_visibility(__tetheringHandle, ¤tState);
548 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to current wifi tethering visibility setting");
550 if(value == true && currentState == false)
552 errorCode = tethering_wifi_set_ssid_visibility(__tetheringHandle, true);
554 else if(value == false && currentState == true)
556 errorCode = tethering_wifi_set_ssid_visibility(__tetheringHandle, false);
558 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to change wifi tethering visibility setting");
560 else if(key == _NETWORK_WIFI_TETHERING_SECURITY)
563 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
565 tethering_wifi_security_type_e securityType;
566 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature.");
568 errorCode = tethering_wifi_get_security_type(__tetheringHandle, &securityType);
569 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to get wifi tethering securiy state");
571 if(value == true && securityType == TETHERING_WIFI_SECURITY_TYPE_NONE)
573 errorCode = tethering_wifi_set_security_type(__tetheringHandle, TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK);
575 else if(value == false && securityType == TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK)
577 errorCode = tethering_wifi_set_security_type(__tetheringHandle, TETHERING_WIFI_SECURITY_TYPE_NONE);
579 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to change wifi tethering visibility setting");
581 else if(key == _USB_TETHERING)
584 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature.");
588 errorCode = tethering_enable(__tetheringHandle, TETHERING_TYPE_USB);
592 errorCode = tethering_disable(__tetheringHandle, TETHERING_TYPE_USB);
594 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to change tethering option");
596 else if(key == _NETWORK_BLUETOOTH_TETHERING)
599 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature.");
602 r = GetValue(_NETWORK_BLUETOOTH, state);
603 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the Bluetooth state");
604 SysTryReturnResult(NID_SYS, state == true, E_INVALID_STATE, "Bluetooth is not activated");
608 errorCode = tethering_enable(__tetheringHandle, TETHERING_TYPE_BT);
612 errorCode = tethering_disable(__tetheringHandle, TETHERING_TYPE_BT);
614 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to change tethering option");
620 _SettingNetworkProvider::SetValueAsync(const String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
623 result r = E_OBJ_NOT_FOUND;
625 if(key == _NETWORK_BLUETOOTH)
627 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Bluetooth feature.");
628 SysTryReturnResult(NID_SYS, __stateOfBluetooth == 0, E_IN_PROGRESS, "Bluetooth is under changing procedure.");
630 __stateOfBluetooth = 1;
631 __pBluetoothListener = listener;
633 SysLog(NID_SYS, "Required bluetooth value is %d.", value);
636 ret = bt_adapter_enable();
640 ret = bt_adapter_disable();
643 SysLog(NID_SYS, "bt_adapter returns %d.", ret);
648 SysLog(NID_SYS, "It is OK to change the bluetooth mode.");
651 case BT_ERROR_ALREADY_DONE:
652 SysLog(NID_SYS, "Bluetooth is already changed.");
653 SettingEventBluetooth(BT_ERROR_NONE, BT_ADAPTER_ENABLED, (void*)this);
655 case BT_ERROR_NOT_ENABLED:
656 SysLog(NID_SYS, "Bluetooth is not enabled.");
657 SettingEventBluetooth(BT_ERROR_NONE, BT_ADAPTER_ENABLED, (void*)this);
660 case BT_ERROR_NOW_IN_PROGRESS:
661 SysLog(NID_SYS, "Currently, Bluetooth change is in progress.");
662 __stateOfBluetooth = 0;
666 case BT_ERROR_NOT_INITIALIZED:
668 SysLog(NID_SYS, "There is an unknown error when changing the bluetooth mode.");
669 __stateOfBluetooth = 0;
678 _SettingNetworkProvider::SetValueForPrivilegedKey(const String& key, bool value)
681 result r = E_OBJ_NOT_FOUND;
682 if(key == _NETWORK_TELEPHONY_PACKETSERVICE)
684 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support telephony packet service feature.");
686 errorCode = vconf_set_bool(VCONFKEY_3G_ENABLE, value);
687 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_3G_ENABLE vconf.");
689 else if(key == _NETWORK_TELEPHONY_ROAMING)
691 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support telephony roaming feature.");
693 errorCode = vconf_set_bool(VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL, value);
694 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL vconf.");
700 _SettingNetworkProvider::SetValueAsyncForPrivilegedKey(const String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
703 result r = E_OBJ_NOT_FOUND;
705 if(key == _NETWORK_FLIGHTMODE)
707 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support flightmode feature.");
710 SysTryReturnResult(NID_SYS, __stateOfFlightMode == 0, E_IN_PROGRESS, "Flightmode is under changing procedure.");
711 __stateOfFlightMode = 1;
713 bool supported = false;
714 int ret = system_info_get_platform_bool("tizen.org/feature/network.telephony", &supported);
715 SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to get system information from configration file.");
717 __pFlightModeListener = listener;
718 if(supported == true)
720 if(__tapiHandle == null)
722 __tapiHandle = tel_init(null);
723 if(__tapiHandle == null)
725 __stateOfFlightMode = 0;
727 SysTryReturnResult(NID_SYS, __tapiHandle != null, E_SYSTEM, "Tapi is not ready.");
729 errorCode = tel_set_flight_mode(__tapiHandle,
730 value ? TAPI_POWER_FLIGHT_MODE_ENTER : TAPI_POWER_FLIGHT_MODE_LEAVE,
731 SettingEventFlightMode, (void*)this);
735 __stateOfFlightMode = 0;
737 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on Network Flight mode(%d).", errorCode);
741 FlightModeEnabler((void*)this);
744 else if(key == _NETWORK_WIFI)
746 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
747 SysTryReturnResult(NID_SYS, __stateOfWifi == 0 && __stateOfWifiDirect == 0, E_IN_PROGRESS, "Wifi processing is under way.");
751 SysLog(NID_SYS, "It creates thread for wifi enable[%d].", value);
753 bool wifiEnabled = false;
754 __pWifiListener = listener;
755 errorCode = wifi_is_activated(&wifiEnabled);
756 if(errorCode != WIFI_ERROR_NONE)
759 SysLogException(NID_SYS, E_SYSTEM, "It is failed to get current status of WIFI.");
763 if(value == wifiEnabled) //Wi-Fi is already changed.
765 SysLog(NID_SYS, "It is try to use dummy thread");
766 r = WifiDummy((void*)this);
767 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to set Wi-Fi state.");
773 errorCode = wifi_activate(SettingWifiActivateCallBack, (void*) this);
777 errorCode = wifi_deactivate(SettingWifiActivateCallBack, (void*) this);
780 if(errorCode != WIFI_ERROR_NONE)
786 else if(key == _NETWORK_WIFI_DIRECT)
788 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
789 SysTryReturnResult(NID_SYS, __stateOfWifi == 0 && __stateOfWifiDirect == 0, E_IN_PROGRESS, "Wifi processing is under way.");
792 __stateOfWifiDirect = 1;
793 SysLog(NID_SYS, "It creates thread for wifi direct enable[%d].", value);
796 __pWifiDirectListener = listener;
797 if(__wifiDirectInit == false)
799 SysLog(NID_SYS, "wifi direct init is started");
800 errorCode = wifi_direct_initialize();
801 SysLog(NID_SYS, "wifi direct init result is %d", errorCode);
802 SysTryReturnResult(NID_SYS, errorCode == WIFI_DIRECT_ERROR_NONE, E_SYSTEM, "It is failed to init wifi direct.");
803 errorCode = wifi_direct_set_device_state_changed_cb(SettingWifiDirectStateChangedCallBack, (void*) this);
804 SysTryReturnResult(NID_SYS, errorCode == WIFI_DIRECT_ERROR_NONE, E_SYSTEM, "It is failed to register wifi direct result callback.");
805 __wifiDirectInit = true;
809 wifi_direct_state_e wifi_direct_state;
810 errorCode = wifi_direct_get_state(&wifi_direct_state);
811 if(errorCode != WIFI_DIRECT_ERROR_NONE)
813 __stateOfWifiDirect = 0;
814 SysLogException(NID_SYS, E_SYSTEM, "It is failed to get current status of WIFI direct.");
818 if((value == false && wifi_direct_state == WIFI_DIRECT_STATE_DEACTIVATED)
819 || (value == true && wifi_direct_state != WIFI_DIRECT_STATE_DEACTIVATED))
821 SysLog(NID_SYS, "Required state is already applied.");
822 WifiDirectDummy((void*)this);
828 errorCode = wifi_direct_activate();
832 errorCode = wifi_direct_deactivate();
834 SysLog(NID_SYS, "wifi_direct_activate result is %d. value is %d.", errorCode, value);
845 _SettingNetworkProvider::WifiDummy(void* data)
847 result r = E_SUCCESS;
848 String settingKey(_NETWORK_WIFI);
849 _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
850 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
851 SysTryReturnResult(NID_SYS, (pSettingInfo != null && pProvider != null), E_SYSTEM, "There is no values of args.");
853 SysTryCatch(NID_SYS, pProvider->__stateOfWifi == 1, r = E_SYSTEM, E_SYSTEM, "There is invalid state.");
855 if(pProvider->__pWifiListener != null)
857 pProvider->__pWifiListener->OnResultReceivedForSetValueAsync(settingKey, E_SUCCESS);
859 r = pSettingInfo->AnnounceSettingEvent(settingKey);
860 SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
863 pProvider->__stateOfWifi = 0;
868 _SettingNetworkProvider::WifiDirectDummy(void* data)
870 result r = E_SUCCESS;
871 String settingKey(_NETWORK_WIFI_DIRECT);
872 _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
873 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
874 SysTryReturnResult(NID_SYS, (pSettingInfo != null && pProvider != null), E_SYSTEM, "There is no values of args.");
875 SysTryCatch(NID_SYS, pProvider->__stateOfWifiDirect == 1, E_SYSTEM, E_SYSTEM, "There is invalid state.");
877 if(pProvider->__pWifiDirectListener != null)
879 pProvider->__pWifiDirectListener->OnResultReceivedForSetValueAsync(settingKey, E_SUCCESS);
881 r = pSettingInfo->AnnounceSettingEvent(settingKey);
882 SysTryCatch(NID_SYS, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
885 pProvider->__stateOfWifiDirect = 0;
890 _SettingNetworkProvider::SettingWifiActivateCallBack(wifi_error_e errorCode, void* data)
892 String settingKey(_NETWORK_WIFI);
894 _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
895 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
896 SysTryReturnVoidResult(NID_SYS, (pSettingInfo != null && pProvider != null), E_SYSTEM, "There is no values of args.");
897 SysTryCatch(NID_SYS, pProvider->__stateOfWifi == 1, E_SYSTEM, E_SYSTEM, "Wi-Fi processing is under way.");
899 if(errorCode != WIFI_ERROR_NONE)
903 case WIFI_ERROR_INVALID_PARAMETER:
904 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by invalid param.");
906 case WIFI_ERROR_OUT_OF_MEMORY:
907 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by out of memory.");
909 case WIFI_ERROR_INVALID_OPERATION:
910 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by invalid operation.");
912 case WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
913 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by family not supported.");
915 case WIFI_ERROR_OPERATION_FAILED:
916 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by operation failed.");
918 case WIFI_ERROR_NO_CONNECTION:
919 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by no connection.");
921 case WIFI_ERROR_ALREADY_EXISTS:
922 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by already exist.");
924 case WIFI_ERROR_OPERATION_ABORTED:
925 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by operation aborted.");
927 case WIFI_ERROR_DHCP_FAILED:
928 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by DHCP fail.");
930 case WIFI_ERROR_INVALID_KEY:
931 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by invalid key.");
933 case WIFI_ERROR_NO_REPLY:
934 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by no reply.");
936 case WIFI_ERROR_SECURITY_RESTRICTED:
937 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by security restricted.");
939 case WIFI_ERROR_NOW_IN_PROGRESS:
940 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is under way.");
945 if(pProvider->__pWifiDirectListener != null)
947 pProvider->__pWifiDirectListener->OnResultReceivedForSetValueAsync(settingKey, E_SUCCESS);
950 pProvider->__stateOfWifi = 0;
954 _SettingNetworkProvider::SettingWifiDirectStateChangedCallBack(wifi_direct_error_e errorCode, wifi_direct_device_state_e deviceState, void* data)
956 result r = E_SUCCESS;
957 String settingKey(_NETWORK_WIFI_DIRECT);
959 _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
960 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
961 SysTryReturnVoidResult(NID_SYS, (pSettingInfo != null && pProvider != null), E_SYSTEM, "There is no values of args.");
963 SysTryCatch(NID_SYS, pProvider->__stateOfWifiDirect == 1 , E_SYSTEM, E_SYSTEM, "There is invalid state.");
965 if(errorCode != WIFI_DIRECT_ERROR_NONE)
970 if(pProvider->__pWifiDirectListener != null)
972 pProvider->__pWifiDirectListener->OnResultReceivedForSetValueAsync(settingKey, r);
976 pProvider->__stateOfWifiDirect = 0;
980 _SettingNetworkProvider::GetValue(const String& key, String& value)
983 result r = E_OBJ_NOT_FOUND;
985 if (key == _NETWORK_WIFI_TETHERING_SECURITY_PASSWORD)
988 unique_ptr<char> password(null);
990 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi tethering feature.");
992 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature.");
993 errorCode = tethering_wifi_get_passphrase(__tetheringHandle, &pTemp);
994 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE && pTemp != null, E_SYSTEM, "It is failed to get password");
996 password.reset(pTemp);
999 value.Append(password.get());
1005 _SettingNetworkProvider::SetValue(const String& key, const String value)
1008 result r = E_OBJ_NOT_FOUND;
1010 if(key ==_NETWORK_WIFI_TETHERING_SECURITY_PASSWORD)
1013 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi tethering feature.");
1015 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature.");
1016 unique_ptr<char []> password(_StringConverter::CopyToCharArrayN(value));
1017 SysTryReturnResult(NID_SYS, password != null, E_SYSTEM, "It is failed to convert String to string");
1018 errorCode = tethering_wifi_set_passphrase(__tetheringHandle, password.get());
1019 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to set password");
1025 _SettingNetworkProvider::HasKey(const String& key)
1027 bool wifi_supported = false;
1028 bool wifi_direct_supported = false;
1029 bool bluetooth_supported = false;
1030 bool telephony_supported = false;
1032 int ret = system_info_get_platform_bool("tizen.org/feature/network.wifi", &wifi_supported);
1033 SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to get system information from configration file.");
1035 ret = system_info_get_platform_bool("tizen.org/feature/network.wifi.direct", &wifi_direct_supported);
1036 SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to get system information from configration file.");
1038 ret = system_info_get_platform_bool("tizen.org/feature/network.bluetooth", &bluetooth_supported);
1039 SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to get system information from configration file.");
1041 ret = system_info_get_platform_bool("tizen.org/feature/network.telephony", &telephony_supported);
1042 SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to get system information from configration file.");
1044 if(key == _NETWORK_FLIGHTMODE)
1048 else if(key == _NETWORK_TELEPHONY_PACKETSERVICE || key == _NETWORK_TELEPHONY_ROAMING)
1050 if(telephony_supported == true)
1055 else if(key == _NETWORK_WIFI || key == _NETWORK_WIFI_NOTIFICATION)
1057 if(wifi_supported == true)
1062 else if(key == _NETWORK_WIFI_DIRECT)
1064 if(wifi_direct_supported == true)
1069 else if(key == _NETWORK_WIFI_TETHERING || key == _NETWORK_WIFI_TETHERING_HIDE
1070 || key == _NETWORK_WIFI_TETHERING_SECURITY || key == _NETWORK_WIFI_TETHERING_SECURITY_PASSWORD || key == _USB_TETHERING)
1072 bool isSupported = false;
1073 int errorCode = system_info_get_value_bool(SYSTEM_INFO_KEY_TETHERING_SUPPORTED, &isSupported);
1074 if(errorCode == SYSTEM_INFO_ERROR_NONE && isSupported == true)
1079 else if(key == _NETWORK_BLUETOOTH)
1081 if(bluetooth_supported == true)
1086 else if(key == _NETWORK_BLUETOOTH_TETHERING)
1088 if(__tetheringHandle != null && bluetooth_supported == true)
1097 _SettingNetworkProvider::SettingEventRuntimeInfo(runtime_info_key_e key, void* userData)
1101 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
1102 SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "SettingInfo is not ready.");
1104 if(key == RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED)
1106 settingKey.Append(_NETWORK_FLIGHTMODE);
1108 else if(key == RUNTIME_INFO_KEY_PACKET_DATA_ENABLED)
1110 settingKey.Append(_NETWORK_TELEPHONY_PACKETSERVICE);
1112 else if(key == RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED)
1114 settingKey.Append(_NETWORK_TELEPHONY_ROAMING);
1118 SysLogException(NID_SYS, E_SYSTEM, "It is not supported key.");
1122 result r = pSettingInfo->AnnounceSettingEvent(settingKey);
1123 SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
1127 _SettingNetworkProvider::SettingEventVConf(keynode_t* node, void* userData)
1129 result r = E_SUCCESS;
1131 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
1132 SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
1134 if (strcmp(VCONFKEY_WIFI_STATE, vconf_keynode_get_name(node)) == 0)
1136 int state = VCONFKEY_WIFI_OFF;
1138 errorCode = vconf_get_int(VCONFKEY_WIFI_STATE, &state);
1140 if(errorCode == 0 && (state == VCONFKEY_WIFI_OFF || state == VCONFKEY_WIFI_UNCONNECTED))
1142 settingKey.Append(_NETWORK_WIFI);
1143 r = pSettingInfo->AnnounceSettingEvent(settingKey);
1144 SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
1148 else if (strcmp(VCONFKEY_WIFI_ENABLE_QS, vconf_keynode_get_name(node)) == 0)
1150 settingKey.Append(_NETWORK_WIFI_NOTIFICATION);
1152 else if (strcmp(VCONFKEY_WIFI_DIRECT_STATE, vconf_keynode_get_name(node)) == 0)
1154 int state = VCONFKEY_WIFI_DIRECT_DEACTIVATED;
1156 errorCode = vconf_get_int(VCONFKEY_WIFI_DIRECT_STATE, &state);
1157 SysLog(NID_SYS, "Wi-Fi Direct state is changed. %d", state);
1158 if(errorCode == 0 && (state == VCONFKEY_WIFI_DIRECT_DEACTIVATED || state == VCONFKEY_WIFI_DIRECT_ACTIVATED))
1160 settingKey.Append(_NETWORK_WIFI_DIRECT);
1161 r = pSettingInfo->AnnounceSettingEvent(settingKey);
1162 SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
1166 else if (strcmp(VCONFKEY_BT_STATUS, vconf_keynode_get_name(node)) == 0)
1168 settingKey.Append(_NETWORK_BLUETOOTH);
1170 else if (strcmp(VCONFKEY_MOBILE_HOTSPOT_SECURITY, vconf_keynode_get_name(node)) == 0)
1172 settingKey.Append(_NETWORK_WIFI_TETHERING_SECURITY);
1174 else if (strcmp(VCONFKEY_MOBILE_HOTSPOT_HIDE, vconf_keynode_get_name(node)) == 0)
1176 settingKey.Append(_NETWORK_WIFI_TETHERING_HIDE);
1180 SysLogException(NID_SYS, E_SYSTEM, "It is not supported key.");
1184 r = pSettingInfo->AnnounceSettingEvent(settingKey);
1185 SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
1189 _SettingNetworkProvider::SettingEventTetheringEnabled(tethering_error_e err, tethering_type_e type, bool is_requested, void* data)
1192 SysLog(NID_SYS, "Tethering Endabled Event is occured.");
1194 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
1195 SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
1199 case TETHERING_TYPE_USB:
1200 settingKey.Append(_USB_TETHERING);
1202 case TETHERING_TYPE_WIFI:
1203 settingKey.Append(_NETWORK_WIFI_TETHERING);
1205 case TETHERING_TYPE_BT:
1206 settingKey.Append(_NETWORK_BLUETOOTH_TETHERING);
1212 result 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::SettingEventTetheringDisabled(tethering_error_e err, tethering_type_e type, tethering_disabled_cause_e cause,void* data)
1219 SysLog(NID_SYS, "Tethering Disabled Event is occured.");
1220 SettingEventTetheringEnabled(err, type, false, null);
1224 _SettingNetworkProvider::SettingEventFlightMode(TapiHandle* handle, int res, void* data, void* user_data)
1226 String settingKey(_NETWORK_FLIGHTMODE);
1228 result r = E_SUCCESS;
1229 SysLog(NID_SYS, "Flightmode response is handle:%x, res:%d, date:%x, user_data:%x", handle, res, data, user_data);
1231 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
1232 SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "SettingInfo is not ready.");
1233 _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)user_data;
1234 SysTryReturnVoidResult(NID_SYS, pProvider != null, E_SYSTEM, "There is invalid provider.");
1235 SysTryCatch(NID_SYS, pProvider->__stateOfFlightMode == 1, E_SYSTEM, E_SYSTEM, "Current state of flight mode is not valid.");
1239 case TAPI_POWER_FLIGHT_MODE_RESP_ON:
1240 SysLog(NID_SYS, "It successes to change flight mode on");
1242 errorCode = vconf_set_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, true);
1245 SysLogException(NID_SYS, E_SYSTEM, "It is failed to set on VCONFKEY_TELEPHONY_FLIGHT_MODE vconf.");
1249 case TAPI_POWER_FLIGHT_MODE_RESP_OFF:
1250 SysLog(NID_SYS, "It successes to change flight mode off");
1252 errorCode = vconf_set_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, false);
1255 SysLogException(NID_SYS, E_SYSTEM, "It is failed to set on VCONFKEY_TELEPHONY_FLIGHT_MODE vconf.");
1259 case TAPI_POWER_FLIGHT_MODE_RESP_FAIL:
1261 SysLogException(NID_SYS, E_SYSTEM, "It is failed to change flight mode");
1265 if(pProvider->__pFlightModeListener != null)
1267 pProvider->__pFlightModeListener->OnResultReceivedForSetValueAsync(settingKey, r);
1271 pProvider->__stateOfFlightMode = 0;
1275 _SettingNetworkProvider::FlightModeEnabler(void* data)
1277 result r = E_SUCCESS;
1279 String settingKey(_NETWORK_FLIGHTMODE);
1281 _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
1282 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
1283 SysTryReturnResult(NID_SYS, pProvider != null && pSettingInfo != null, E_SYSTEM, "Provider or SettingInfo is not ready.");
1284 SysTryCatch(NID_SYS, pProvider->__stateOfFlightMode == 1, E_SYSTEM, E_SYSTEM, "Current state of flight mode is not valid.");
1286 errorCode = vconf_set_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, pProvider->__flightModeEnabled);
1289 SysLogException(NID_SYS, E_SYSTEM, "It is failed to set on VCONFKEY_TELEPHONY_FLIGHT_MODE vconf.");
1294 if(pProvider->__pFlightModeListener != null)
1296 pProvider->__pFlightModeListener->OnResultReceivedForSetValueAsync(settingKey, r);
1300 pProvider->__stateOfFlightMode = 0;
1305 _SettingNetworkProvider::SettingEventBluetooth(int res, bt_adapter_state_e adapter_state, void* user_data)
1307 String settingKey(_NETWORK_BLUETOOTH);
1308 result r = E_SUCCESS;
1309 SysLog(NID_SYS, "Bluetooth callback is invoked. result:%d, adapter_state:%d, user_data:%x", res, adapter_state, user_data);
1311 _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)user_data;
1312 SysTryReturnVoidResult(NID_SYS, pProvider != null, E_SYSTEM, "There is no values of args.");
1313 SysTryCatch(NID_SYS, pProvider->__stateOfBluetooth == 1, E_SYSTEM, E_SYSTEM, "Bluetooth processing is under way.");
1315 if(res == BT_ERROR_NONE)
1324 if(pProvider->__pBluetoothListener != null && pProvider->__stateOfBluetooth == 1)
1326 pProvider->__pBluetoothListener->OnResultReceivedForSetValueAsync(settingKey, r);
1331 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
1332 SysTryCatch(NID_SYS, pSettingInfo != null, E_SYSTEM, E_SYSTEM, "_SettingInfo is not ready.");
1334 result r = pSettingInfo->AnnounceSettingEvent(settingKey);
1335 SysTryCatch(NID_SYS, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
1339 pProvider->__stateOfBluetooth = 0;