Merge "Change the way to conver Mbs to Wcs and vice versa" into tizen_2.1
[platform/framework/native/appfw.git] / src / system / FSys_DeviceManagerImpl.cpp
index 93d7713..731e5a2 100644 (file)
@@ -86,10 +86,10 @@ static const wchar_t* _DEVICE_MANAGER_STATE_CLOSED = L"Closed";
 static const wchar_t* _SYSTEM_INFO_NETWORK_BLUETOOTH = L"http://tizen.org/feature/network.bluetooth";
 static const wchar_t* _SYSTEM_INFO_INPUT_KEYBOARD = L"http://tizen.org/feature/input.keyboard";
 static const wchar_t* _SYSTEM_INFO_TVOUT_SUPPORTED = L"http://tizen.org/feature/screen.output.rca";
+static const wchar_t* _SYSTEM_INFO_HDMI = L"http://tizen.org/feature/screen.output.hdmi";
 
 _DeviceManagerImpl* _DeviceManagerImpl::__pDeviceManagerImpl = null;
 
-
 class _DeviceManagerEventArg : public IEventArg
 {
 public:
@@ -108,11 +108,7 @@ protected:
                IDeviceEventListener* pListener = dynamic_cast<IDeviceEventListener*> (&listener);
                const _DeviceManagerEventArg* pArg = dynamic_cast<const _DeviceManagerEventArg*>(&arg);
 
-               if(pListener == null || pArg == null)
-               {
-                       SysLogException(NID_SYS, E_SYSTEM, "listener or arg is null.");
-                       return;
-               }
+               SysTryReturnVoidResult(NID_SYS, pListener != null && pArg != null, E_SYSTEM, "Parameters are not available.");
 
                pListener->OnDeviceStateChanged(pArg->deviceType, pArg->state);
        }
@@ -308,10 +304,8 @@ _DeviceManagerImpl::MmcEventVconfCallback(keynode_t* node, void* userData)
                        String event;
                        int value = 0;
                        int ret = vconf_get_int(VCONFKEY_APPSERVICE_MMC_STATUS, &value);
-                       if(ret == -1)
-                       {
-                               SysLogException(NID_SYS, E_SYSTEM, "VCONFKEY_APPSERVICE_MMC_STATUS is error");
-                       }
+                       SysTryReturnVoidResult(NID_SYS, ret == 0, E_SYSTEM, "VCONFKEY_APPSERVICE_MMC_STATUS is error");
+
                        if (value == 1)
                        {
                                event = _DEVICE_MANAGER_STATE_MOUNTED;
@@ -419,11 +413,8 @@ _DeviceManagerImpl::SendEvent(DeviceType deviceType, String& state)
                                return;
                        }
                        std::unique_ptr<_DeviceManagerEventArg> pDeviceManagerEventArg(new (std::nothrow) _DeviceManagerEventArg());
-                       if(pDeviceManagerEventArg == null)
-                       {
-                               SysLogException(NID_SYS, E_OUT_OF_MEMORY, "It is failed to create instance of DeviceManagerEventArg");
-                               return;
-                       }
+                       SysTryReturnVoidResult(NID_SYS, pDeviceManagerEventArg != null, E_OUT_OF_MEMORY, "It is failed to create instance of DeviceManagerEventArg");
+
                        pDeviceManagerEventArg->deviceType = deviceType;
                        pDeviceManagerEventArg->state = state;
 
@@ -678,12 +669,14 @@ _DeviceManagerImpl::AddOnExistedListener(DeviceType deviceType, const IDeviceEve
                                {
                                        int value = 0;
                                        int ret = 0;
+                                       bool supported = false;
+                                       r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_HDMI, supported);
+                                       SysTryReturnResult(NID_SYS, supported == true, E_UNSUPPORTED_OPERATION, "Current device does not support HDMI.");
+
                                        ret = vconf_get_int(VCONFKEY_SYSMAN_HDMI, &value);
                                        SysTryReturnResult(NID_SYS, !(ret < 0), E_SYSTEM, "vconf_get_int failed Output value is %d", value);
-                                       if(value < 0)
-                                       {
-                                               return E_UNSUPPORTED_OPERATION;
-                                       }
+                                       SysTryReturnResult(NID_SYS, value >= 0, E_UNSUPPORTED_OPERATION, "Current device does not support HDMI.");
+
                                        if(pDeviceEventListenerContainer->__hdmi == true)
                                        {
                                                r = E_OBJ_ALREADY_EXIST;
@@ -1080,11 +1073,7 @@ _DeviceManagerImpl::SendEvent(runtime_info_key_e key)
 
                bool state = false;
                ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_USB_CONNECTED, &state);
-               if (ret != RUNTIME_INFO_ERROR_NONE)
-               {
-                       SysLogException(NID_SYS, E_SYSTEM, "It is failed to get usb state");
-                       return;
-               }
+               SysTryReturnVoidResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get usb state.");
 
                if (state == true)
                {
@@ -1103,11 +1092,7 @@ _DeviceManagerImpl::SendEvent(runtime_info_key_e key)
 
                bool state = false;
                ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_CHARGER_CONNECTED, &state);
-               if (ret != RUNTIME_INFO_ERROR_NONE)
-               {
-                       SysLogException(NID_SYS, E_SYSTEM, "It is failed to get charger state");
-                       return;
-               }
+               SysTryReturnVoidResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get charger state.");
 
                if (state == true)
                {
@@ -1126,11 +1111,7 @@ _DeviceManagerImpl::SendEvent(runtime_info_key_e key)
 
                bool state = false;
                ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_TV_OUT_CONNECTED, &state);
-               if (ret != RUNTIME_INFO_ERROR_NONE)
-               {
-                       SysLogException(NID_SYS, E_SYSTEM, "It is failed to get tv connect state");
-                       return;
-               }
+               SysTryReturnVoidResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get tv connect state.");
 
                if (state == true)
                {
@@ -1146,11 +1127,7 @@ _DeviceManagerImpl::SendEvent(runtime_info_key_e key)
        {
                int state = 0;
                ret = runtime_info_get_value_int(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, &state);
-               if (ret != RUNTIME_INFO_ERROR_NONE)
-               {
-                       SysLogException(NID_SYS, E_SYSTEM, "It is failed to get audion jack state");
-                       return;
-               }
+               SysTryReturnVoidResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get audio connect state.");
 
                if (state == RUNTIME_INFO_AUDIO_JACK_STATUS_UNCONNECTED)
                {
@@ -1193,11 +1170,7 @@ _DeviceManagerImpl::SendEvent(runtime_info_key_e key)
 
                bool state = false;
                ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_SLIDING_KEYBOARD_OPENED, &state);
-               if (ret != RUNTIME_INFO_ERROR_NONE)
-               {
-                       SysLogException(NID_SYS, E_SYSTEM, "It is failed to get keyboard state");
-                       return;
-               }
+               SysTryReturnVoidResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get built-in keyboard state.");
 
                if (state == true)
                {
@@ -1400,7 +1373,7 @@ _DeviceManagerImpl::GetState(DeviceType deviceType, String& state)
        {
                bool keyboard = false;
                r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_INPUT_KEYBOARD, keyboard);
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Fail to get keyboard option.");
+               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get keyboard option.");
                if (keyboard == false)
                {
                        if(!_AppInfo::IsOspCompat())
@@ -1417,6 +1390,10 @@ _DeviceManagerImpl::GetState(DeviceType deviceType, String& state)
        case DEVICE_TYPE_HDMI:
        {
                int ret = 0;
+               bool supported = false;
+               r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_HDMI, supported);
+               SysTryReturnResult(NID_SYS, supported == false, E_UNSUPPORTED_OPERATION, "Current device does not support HDMI.");
+
                ret = vconf_get_int(VCONFKEY_SYSMAN_HDMI, &value);
                SysTryReturnResult(NID_SYS, !(ret < 0), E_SYSTEM, "vconf_get_int failed Output value is %d", value);
                if (value == 1)