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";
72 static const wchar_t* _NETWORK_RESULT_SUCCESS = L"osp.system.result.success";
73 static const wchar_t* _NETWORK_RESULT_SYSTEM = L"osp.system.result.system";
77 void operator()(char* pValue)
87 _SettingNetworkProvider::_SettingNetworkProvider()
89 , __pWifiDllHandle(null)
90 , __pBluetoothDllHandle(null)
91 , __stateOfFlightMode(0)
93 , __stateOfWifiDirect(0)
94 , __stateOfBluetooth(0)
95 , __flightModeEnabled(false)
96 , __networkBluetoothEnabled(false)
98 , __wifiDirectInit(false)
99 , __pWifiListener(null)
100 , __pWifiDirectListener(null)
101 , __pFlightModeListener(null)
102 , __pBluetoothListener(null)
104 int errorCode = bt_initialize();
107 //For multiple usage, deinitialize should not be called when it terminated.
108 SysLogException(NID_SYS, E_SYSTEM, "It is failed to initialize bluetooth.");
111 errorCode = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED, SettingEventRuntimeInfo, null);
114 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register flight mode event listener");
117 errorCode = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_PACKET_DATA_ENABLED, SettingEventRuntimeInfo, null);
120 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register packet data event listener");
123 errorCode = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED, SettingEventRuntimeInfo, null);
126 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register roaming event listener");
129 errorCode = vconf_notify_key_changed(VCONFKEY_WIFI_STATE, SettingEventVConf, null);
132 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_WIFI_STATE listener");
135 errorCode = tethering_create(&__tetheringHandle);
138 SysLogException(NID_SYS, E_SYSTEM, "It is failed to create tethering handle");
141 errorCode = tethering_set_enabled_cb(__tetheringHandle, TETHERING_TYPE_USB, SettingEventTetheringEnabled, null);
144 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register TETHERING_TYPE_USB listener");
147 errorCode = tethering_set_enabled_cb(__tetheringHandle, TETHERING_TYPE_WIFI, SettingEventTetheringEnabled, null);
150 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register TETHERING_TYPE_WIFI listener");
153 errorCode = tethering_set_enabled_cb(__tetheringHandle, TETHERING_TYPE_BT, SettingEventTetheringEnabled, null);
156 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register TETHERING_TYPE_BT listener");
159 errorCode = tethering_set_disabled_cb(__tetheringHandle, TETHERING_TYPE_USB, SettingEventTetheringDisabled, null);
162 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register TETHERING_TYPE_USB listener");
165 errorCode = tethering_set_disabled_cb(__tetheringHandle, TETHERING_TYPE_WIFI, SettingEventTetheringDisabled, null);
168 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register TETHERING_TYPE_WIFI listener");
171 errorCode = tethering_set_disabled_cb(__tetheringHandle, TETHERING_TYPE_BT, SettingEventTetheringDisabled, null);
174 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 errorCode = tethering_unset_enabled_cb(__tetheringHandle, TETHERING_TYPE_USB);
252 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_USB listener");
255 errorCode = tethering_unset_enabled_cb(__tetheringHandle, TETHERING_TYPE_WIFI);
258 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_WIFI listener");
261 errorCode = tethering_unset_enabled_cb(__tetheringHandle, TETHERING_TYPE_BT);
264 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_BT listener");
267 errorCode = tethering_unset_disabled_cb(__tetheringHandle, TETHERING_TYPE_USB);
270 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_USB listener");
273 errorCode = tethering_unset_disabled_cb(__tetheringHandle, TETHERING_TYPE_WIFI);
276 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_WIFI listener");
279 errorCode = tethering_unset_disabled_cb(__tetheringHandle, TETHERING_TYPE_BT);
282 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_BT listener");
285 tethering_destroy(__tetheringHandle);
286 __tetheringHandle = null;
288 errorCode = vconf_ignore_key_changed(VCONFKEY_WIFI_DIRECT_STATE, SettingEventVConf);
291 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_WIFI_DIRECT_STATE listener");
293 errorCode = vconf_ignore_key_changed(VCONFKEY_BT_STATUS, SettingEventVConf);
296 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_BT_STATUS listener");
299 errorCode = vconf_ignore_key_changed(VCONFKEY_MOBILE_HOTSPOT_SECURITY, SettingEventVConf);
302 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_MOBILE_HOTSPOT_SECURITY listener");
305 errorCode = vconf_ignore_key_changed(VCONFKEY_MOBILE_HOTSPOT_HIDE, SettingEventVConf);
308 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_MOBILE_HOTSPOT_HIDE listener");
311 errorCode = vconf_ignore_key_changed(VCONFKEY_WIFI_ENABLE_QS, SettingEventVConf);
314 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_WIFI_ENABLE_QS listener");
317 errorCode = bt_adapter_unset_state_changed_cb();
320 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister bluetooth listener");
323 errorCode = bt_deinitialize();
326 SysLogException(NID_SYS, E_SYSTEM, "It is failed to deinitialize bluetooth.");
329 if(__wifiDirectInit == true)
331 errorCode = wifi_direct_unset_device_state_changed_cb();
332 if(errorCode == WIFI_DIRECT_ERROR_NONE)
334 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister Wi-Fi direct callback.");
337 errorCode = wifi_direct_deinitialize();
338 if(errorCode == WIFI_DIRECT_ERROR_NONE)
340 SysLogException(NID_SYS, E_SYSTEM, "It is failed to deinitialize Wi-Fi direct.");
342 SysLog(NID_SYS, "Wifi direct de-init result is %d.", errorCode);
343 __wifiDirectInit = false;
346 if(__wifiInit == true)
348 errorCode = wifi_deinitialize();
349 if(errorCode == WIFI_ERROR_NONE)
351 SysLogException(NID_SYS, E_SYSTEM, "It is failed to deinitialize Wi-Fi.");
353 SysLog(NID_SYS, "Wifi de-init result is %d.", errorCode);
356 SysLog(NID_SYS, "Network Provider is terminated properly.");
360 _SettingNetworkProvider::GetValue(const String& key, bool& value)
363 result r = E_OBJ_NOT_FOUND;
365 if(key == _NETWORK_FLIGHTMODE)
367 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support flightmode feature.");
368 bool flightModeEnabled = false;
370 errorCode = runtime_info_get_value_bool(RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED, &flightModeEnabled);
371 SysTryReturnResult(NID_SYS, errorCode == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get the RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED");
372 value = flightModeEnabled;
374 else if(key == _NETWORK_TELEPHONY_PACKETSERVICE)
376 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Telephony packet service feature.");
377 bool packetServiceAllowed = false;
379 errorCode = runtime_info_get_value_bool(RUNTIME_INFO_KEY_PACKET_DATA_ENABLED, &packetServiceAllowed);
380 SysTryReturnResult(NID_SYS, errorCode == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get the RUNTIME_INFO_KEY_PACKET_DATA_ENABLED");
381 value = packetServiceAllowed;
383 else if(key == _NETWORK_TELEPHONY_ROAMING)
385 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Telephony roaming feature.");
386 bool dataRoamingEnabled = false;
388 errorCode = runtime_info_get_value_bool(RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED, &dataRoamingEnabled);
389 SysTryReturnResult(NID_SYS, errorCode == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get the RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED");
390 value = dataRoamingEnabled;
392 else if (key == _NETWORK_WIFI)
395 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
397 bool wifiState = false;
398 errorCode = wifi_is_activated(&wifiState);
399 SysTryReturnResult(NID_SYS, errorCode == WIFI_ERROR_NONE, E_SYSTEM, "It is failed to get from wifi_is_activated.");
402 else if (key == _NETWORK_WIFI_NOTIFICATION)
406 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
408 errorCode = vconf_get_int(VCONFKEY_WIFI_ENABLE_QS, &wifiQSState);
409 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_WIFI_ENABLE_QS vconf.");
411 if(wifiQSState == VCONFKEY_WIFI_QS_DISABLE)
420 else if (key == _NETWORK_WIFI_TETHERING)
423 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi tethering feature.");
424 value = tethering_is_enabled(__tetheringHandle, TETHERING_TYPE_WIFI);
426 else if (key == _NETWORK_WIFI_TETHERING_HIDE)
429 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi tethering feature.");
430 errorCode = tethering_wifi_get_ssid_visibility(__tetheringHandle, &value);
431 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to get wifi tethering visibility state");
433 else if (key == _NETWORK_WIFI_TETHERING_SECURITY)
435 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi tethering feature.");
437 tethering_wifi_security_type_e securityType;
438 errorCode = tethering_wifi_get_security_type(__tetheringHandle, &securityType);
439 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to get wifi tethering securiy state");
440 if(securityType == TETHERING_WIFI_SECURITY_TYPE_NONE)
449 else if (key == _USB_TETHERING)
452 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support USB tethering feature.");
453 value = tethering_is_enabled(__tetheringHandle, TETHERING_TYPE_USB);
455 else if (key == _NETWORK_WIFI_DIRECT)
457 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi direct feature.");
461 errorCode = vconf_get_int(VCONFKEY_WIFI_DIRECT_STATE, &isActivated);
462 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_WIFI_ENABLE_QS vconf.");
473 else if (key == _NETWORK_BLUETOOTH)
475 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Bluetooth feature.");
477 int bluetoothStatus = VCONFKEY_BT_STATUS_OFF;
478 errorCode = vconf_get_int(VCONFKEY_BT_STATUS, &bluetoothStatus);
479 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to read bluetooth status.");
481 if(bluetoothStatus == VCONFKEY_BT_STATUS_OFF)
490 else if (key == _NETWORK_BLUETOOTH_TETHERING)
492 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Bluetooth tethering feature.");
494 value = tethering_is_enabled(__tetheringHandle, TETHERING_TYPE_BT);
500 _SettingNetworkProvider::SetValue(const String& key, const bool value)
503 result r = E_OBJ_NOT_FOUND;
505 if(key == _NETWORK_WIFI_NOTIFICATION)
507 int currentValue = 0;
509 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
510 errorCode = vconf_get_int(VCONFKEY_WIFI_ENABLE_QS, ¤tValue);
511 SysTryReturnResult(NID_SYS, errorCode != -1, E_UNSUPPORTED_OPERATION, "This device does not support %ls key.", key.GetPointer());
515 errorCode = vconf_set_int(VCONFKEY_WIFI_ENABLE_QS, VCONFKEY_WIFI_QS_ENABLE);
519 errorCode = vconf_set_int(VCONFKEY_WIFI_ENABLE_QS, VCONFKEY_WIFI_QS_DISABLE);
521 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_WIFI_ENABLE_QS vconf.");
523 else if(key == _NETWORK_WIFI_TETHERING)
527 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
528 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature.");
529 r = GetValue(_NETWORK_WIFI, state);
530 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the WIFI state");
531 SysTryReturnResult(NID_SYS, state == true, E_INVALID_STATE, "WIFI is not activated");
535 errorCode = tethering_enable(__tetheringHandle, TETHERING_TYPE_WIFI);
539 errorCode = tethering_disable(__tetheringHandle, TETHERING_TYPE_WIFI);
541 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to change tethering option.");
543 else if(key == _NETWORK_WIFI_TETHERING_HIDE)
546 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
548 bool currentState = false;
549 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature.");
550 errorCode = tethering_wifi_get_ssid_visibility(__tetheringHandle, ¤tState);
551 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to current wifi tethering visibility setting");
553 if(value == true && currentState == false)
555 errorCode = tethering_wifi_set_ssid_visibility(__tetheringHandle, true);
557 else if(value == false && currentState == true)
559 errorCode = tethering_wifi_set_ssid_visibility(__tetheringHandle, false);
561 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to change wifi tethering visibility setting");
563 else if(key == _NETWORK_WIFI_TETHERING_SECURITY)
566 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
568 tethering_wifi_security_type_e securityType;
569 SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature.");
571 errorCode = tethering_wifi_get_security_type(__tetheringHandle, &securityType);
572 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to get wifi tethering securiy state");
574 if(value == true && securityType == TETHERING_WIFI_SECURITY_TYPE_NONE)
576 errorCode = tethering_wifi_set_security_type(__tetheringHandle, TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK);
578 else if(value == false && securityType == TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK)
580 errorCode = tethering_wifi_set_security_type(__tetheringHandle, TETHERING_WIFI_SECURITY_TYPE_NONE);
582 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to change wifi tethering visibility setting");
584 else if(key == _USB_TETHERING)
587 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature.");
591 errorCode = tethering_enable(__tetheringHandle, TETHERING_TYPE_USB);
595 errorCode = tethering_disable(__tetheringHandle, TETHERING_TYPE_USB);
597 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to change tethering option");
599 else if(key == _NETWORK_BLUETOOTH_TETHERING)
602 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature.");
605 r = GetValue(_NETWORK_BLUETOOTH, state);
606 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the Bluetooth state");
607 SysTryReturnResult(NID_SYS, state == true, E_INVALID_STATE, "Bluetooth is not activated");
611 errorCode = tethering_enable(__tetheringHandle, TETHERING_TYPE_BT);
615 errorCode = tethering_disable(__tetheringHandle, TETHERING_TYPE_BT);
617 SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to change tethering option");
623 _SettingNetworkProvider::SetValueAsync(const String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
626 result r = E_OBJ_NOT_FOUND;
628 if(key == _NETWORK_BLUETOOTH)
630 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Bluetooth feature.");
631 SysTryReturnResult(NID_SYS, __stateOfBluetooth == 0, E_IN_PROGRESS, "Bluetooth is under changing procedure.");
633 __stateOfBluetooth = 1;
634 __pBluetoothListener = listener;
638 ret = bt_adapter_enable();
642 ret = bt_adapter_disable();
645 SysLog(NID_SYS, "bt_adapter returns %d.", ret);
650 SysLog(NID_SYS, "It is OK to change the bluetooth mode.");
653 case BT_ERROR_ALREADY_DONE:
654 case BT_ERROR_NOT_ENABLED:
655 SysLog(NID_SYS, "Bluetooth is already enabled.");
656 SettingEventBluetooth(BT_ERROR_NONE, BT_ADAPTER_ENABLED, (void*)this);
659 case BT_ERROR_NOW_IN_PROGRESS:
660 SysLog(NID_SYS, "Currently, Bluetooth change is in progress.");
661 __stateOfBluetooth = 0;
665 case BT_ERROR_NOT_INITIALIZED:
667 SysLog(NID_SYS, "There is an unknown error when changing the bluetooth mode.");
668 __stateOfBluetooth = 0;
677 _SettingNetworkProvider::SetValueForPrivilegedKey(const String& key, bool value)
680 result r = E_OBJ_NOT_FOUND;
681 if(key == _NETWORK_TELEPHONY_PACKETSERVICE)
683 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support telephony packet service feature.");
685 errorCode = vconf_set_bool(VCONFKEY_3G_ENABLE, value);
686 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_3G_ENABLE vconf.");
688 else if(key == _NETWORK_TELEPHONY_ROAMING)
690 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support telephony roaming feature.");
692 errorCode = vconf_set_bool(VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL, value);
693 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL vconf.");
699 _SettingNetworkProvider::SetValueAsyncForPrivilegedKey(const String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
702 result r = E_OBJ_NOT_FOUND;
704 if(key == _NETWORK_FLIGHTMODE)
706 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support flightmode feature.");
709 SysTryReturnResult(NID_SYS, __stateOfFlightMode == 0, E_IN_PROGRESS, "Flightmode is under changing procedure.");
710 __stateOfFlightMode = 1;
712 bool supported = false;
713 int ret = system_info_get_platform_bool("tizen.org/feature/network.telephony", &supported);
714 SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to get system information from configration file.");
716 __pFlightModeListener = listener;
717 if(supported == true)
719 if(__tapiHandle == null)
721 __tapiHandle = tel_init(null);
722 if(__tapiHandle == null)
724 __stateOfFlightMode = 0;
726 SysTryReturnResult(NID_SYS, __tapiHandle != null, E_SYSTEM, "Tapi is not ready.");
728 errorCode = tel_set_flight_mode(__tapiHandle,
729 value ? TAPI_POWER_FLIGHT_MODE_ENTER : TAPI_POWER_FLIGHT_MODE_LEAVE,
730 SettingEventFlightMode, (void*)this);
734 __stateOfFlightMode = 0;
736 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on Network Flight mode(%d).", errorCode);
740 FlightModeEnabler((void*)this);
743 else if(key == _NETWORK_WIFI)
745 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
746 SysTryReturnResult(NID_SYS, __stateOfWifi == 0 && __stateOfWifiDirect == 0, E_IN_PROGRESS, "Wifi processing is under way.");
750 SysLog(NID_SYS, "It creates thread for wifi enable[%d].", value);
752 bool wifiEnabled = false;
753 __pWifiListener = listener;
754 errorCode = wifi_is_activated(&wifiEnabled);
755 if(errorCode != WIFI_ERROR_NONE)
758 SysLogException(NID_SYS, E_SYSTEM, "It is failed to get current status of WIFI.");
762 if(value == wifiEnabled) //Wi-Fi is already changed.
764 SysLog(NID_SYS, "It is try to use dummy thread");
765 r = WifiDummy((void*)this);
766 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to set Wi-Fi state.");
772 errorCode = wifi_activate(SettingWifiActivateCallBack, (void*) this);
776 errorCode = wifi_deactivate(SettingWifiActivateCallBack, (void*) this);
779 if(errorCode != WIFI_ERROR_NONE)
785 else if(key == _NETWORK_WIFI_DIRECT)
787 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
788 SysTryReturnResult(NID_SYS, __stateOfWifi == 0 && __stateOfWifiDirect == 0, E_IN_PROGRESS, "Wifi processing is under way.");
791 __stateOfWifiDirect = 1;
792 SysLog(NID_SYS, "It creates thread for wifi direct enable[%d].", value);
795 __pWifiDirectListener = listener;
796 if(__wifiDirectInit == false)
798 SysLog(NID_SYS, "wifi direct init is started");
799 errorCode = wifi_direct_initialize();
800 SysLog(NID_SYS, "wifi direct init result is %d", errorCode);
801 SysTryReturnResult(NID_SYS, errorCode == WIFI_DIRECT_ERROR_NONE, E_SYSTEM, "It is failed to init wifi direct.");
802 errorCode = wifi_direct_set_device_state_changed_cb(SettingWifiDirectStateChangedCallBack, (void*) this);
803 SysTryReturnResult(NID_SYS, errorCode == WIFI_DIRECT_ERROR_NONE, E_SYSTEM, "It is failed to register wifi direct result callback.");
804 __wifiDirectInit = true;
808 wifi_direct_state_e wifi_direct_state;
809 errorCode = wifi_direct_get_state(&wifi_direct_state);
810 if(errorCode != WIFI_DIRECT_ERROR_NONE)
812 __stateOfWifiDirect = 0;
813 SysLogException(NID_SYS, E_SYSTEM, "It is failed to get current status of WIFI direct.");
817 if((value == false && wifi_direct_state == WIFI_DIRECT_STATE_DEACTIVATED)
818 || (value == true && wifi_direct_state != WIFI_DIRECT_STATE_DEACTIVATED))
820 SysLog(NID_SYS, "Required state is already applied.");
821 WifiDirectDummy((void*)this);
827 errorCode = wifi_direct_activate();
831 errorCode = wifi_direct_deactivate();
833 SysLog(NID_SYS, "wifi_direct_activate result is %d. value is %d.", errorCode, value);
844 _SettingNetworkProvider::WifiDummy(void* data)
846 result r = E_SUCCESS;
847 String settingKey(_NETWORK_WIFI);
848 _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
849 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
850 SysTryReturnResult(NID_SYS, (pSettingInfo != null && pProvider != null), E_SYSTEM, "There is no values of args.");
852 SysTryCatch(NID_SYS, pProvider->__stateOfWifi == 1, r = E_SYSTEM, E_SYSTEM, "There is invalid state.");
854 if(pProvider->__pWifiListener != null)
856 pProvider->__pWifiListener->OnResultReceivedForSetValueAsync(settingKey, E_SUCCESS);
858 r = pSettingInfo->AnnounceSettingEvent(settingKey);
859 SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
862 pProvider->__stateOfWifi = 0;
867 _SettingNetworkProvider::WifiDirectDummy(void* data)
869 result r = E_SUCCESS;
870 String settingKey(_NETWORK_WIFI_DIRECT);
871 _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
872 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
873 SysTryReturnResult(NID_SYS, (pSettingInfo != null && pProvider != null), E_SYSTEM, "There is no values of args.");
874 SysTryCatch(NID_SYS, pProvider->__stateOfWifiDirect == 1, E_SYSTEM, E_SYSTEM, "There is invalid state.");
876 if(pProvider->__pWifiDirectListener != null)
878 pProvider->__pWifiDirectListener->OnResultReceivedForSetValueAsync(settingKey, E_SUCCESS);
880 r = pSettingInfo->AnnounceSettingEvent(settingKey);
881 SysTryCatch(NID_SYS, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
884 pProvider->__stateOfWifiDirect = 0;
889 _SettingNetworkProvider::SettingWifiActivateCallBack(wifi_error_e errorCode, void* data)
891 String settingKey(_NETWORK_WIFI);
893 _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
894 _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
895 SysTryReturnVoidResult(NID_SYS, (pSettingInfo != null && pProvider != null), E_SYSTEM, "There is no values of args.");
896 SysTryCatch(NID_SYS, pProvider->__stateOfWifi == 1, E_SYSTEM, E_SYSTEM, "Wi-Fi processing is under way.");
898 if(errorCode != WIFI_ERROR_NONE)
902 case WIFI_ERROR_INVALID_PARAMETER:
903 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by invalid param.");
905 case WIFI_ERROR_OUT_OF_MEMORY:
906 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by out of memory.");
908 case WIFI_ERROR_INVALID_OPERATION:
909 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by invalid operation.");
911 case WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
912 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by family not supported.");
914 case WIFI_ERROR_OPERATION_FAILED:
915 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by operation failed.");
917 case WIFI_ERROR_NO_CONNECTION:
918 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by no connection.");
920 case WIFI_ERROR_ALREADY_EXISTS:
921 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by already exist.");
923 case WIFI_ERROR_OPERATION_ABORTED:
924 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by operation aborted.");
926 case WIFI_ERROR_DHCP_FAILED:
927 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by DHCP fail.");
929 case WIFI_ERROR_INVALID_KEY:
930 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by invalid key.");
932 case WIFI_ERROR_NO_REPLY:
933 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by no reply.");
935 case WIFI_ERROR_SECURITY_RESTRICTED:
936 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by security restricted.");
938 case WIFI_ERROR_NOW_IN_PROGRESS:
939 SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is under way.");
944 if(pProvider->__pWifiDirectListener != null)
946 pProvider->__pWifiDirectListener->OnResultReceivedForSetValueAsync(settingKey, E_SUCCESS);
949 pProvider->__stateOfWifi = 0;
953 _SettingNetworkProvider::SettingWifiDirectStateChangedCallBack(wifi_direct_error_e errorCode, wifi_direct_device_state_e deviceState, void* data)
955 result r = E_SUCCESS;
956 String settingKey(_NETWORK_WIFI_DIRECT);
957 String returnValue = _NETWORK_RESULT_SUCCESS;
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;