Fix SettingClient to get instance.
[platform/framework/native/appfw.git] / src / app / FApp_AppSettingImpl.cpp
index 949a767..f7aabd9 100644 (file)
@@ -1,5 +1,4 @@
 //
-// Open Service Platform
 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
 //
 // Licensed under the Apache License, Version 2.0 (the License);
@@ -165,11 +164,10 @@ _AppSettingImpl::_MutiInstanceManager::GetInstanceByAppId(const AppId& appId)
        SysTryReturn(NID_APP, pPkgMgrImpl != null, null, E_SYSTEM,
                                 "[%s] A system error has been occurred. failed to get _PackageMaangerImpl.", GetErrorMessage(E_SYSTEM));
 
-       PackageInfo* pPackageInfo = null;
-       pPackageInfo = pPkgMgrImpl->GetPackageInfoN(packageId); // !E_SUCCESS for DB fail and query fail
+       std::unique_ptr<PackageInfo> pPackageInfo(pPkgMgrImpl->GetPackageInfoN(packageId));     // !E_SUCCESS for DB fail and query fail
        SysTryReturn(NID_APP, pPackageInfo != null, null, E_APP_NOT_INSTALLED, "[%s] Propagating.", GetErrorMessage(E_APP_NOT_INSTALLED));
 
-       const _PackageInfoImpl* pPkgInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo);
+       const _PackageInfoImpl* pPkgInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo.get());
        SysTryReturn(NID_APP, pPkgInfoImpl != null, null, E_SYSTEM,
                                 "[%s] A system error has been occurred. failed to get _PackageInfoImpl.", GetErrorMessage(E_SYSTEM));
 
@@ -200,7 +198,6 @@ _AppSettingImpl::_MutiInstanceManager::GetInstanceByAppId(const AppId& appId)
 
 CATCH:
        delete pAppSettingInstance;
-       delete pPackageInfo;
        return null;
 }
 
@@ -469,8 +466,7 @@ _AppSettingImpl::GetValue(const Tizen::Base::String& id, bool& value) const
        const _SettingItem* pItem = dynamic_cast<const _SettingItem*>(pObject);
        SysTryReturnResult(NID_APP, pItem != null, E_TYPE_MISMATCH, "Type mismatch for instance of id.");
        const Boolean* pBoolean = dynamic_cast<const Boolean*>(pItem->GetValue());
-       SysTryReturnResult(NID_APP, pBoolean != null, E_TYPE_MISMATCH,
-                                          "Type mismatch between requested type bool and object type of %ls.", id.GetPointer());
+       SysTryReturnResult(NID_APP, pBoolean != null, E_TYPE_MISMATCH, "Type mismatch between requested type bool and object type.");
        value = pBoolean->ToBool();
 
        return E_SUCCESS;
@@ -484,8 +480,7 @@ _AppSettingImpl::GetValue(const Tizen::Base::String& id, int& value) const
        const _SettingItem* pItem = dynamic_cast<const _SettingItem*>(pObject);
        SysTryReturnResult(NID_APP, pItem != null, E_TYPE_MISMATCH, "Type mismatch for instance of id.");
        const Integer* pInteger = dynamic_cast<const Integer*>(pItem->GetValue());
-       SysTryReturnResult(NID_APP, pInteger != null, E_TYPE_MISMATCH,
-                                          "Type mismatch between requested type int and object type of %ls.", id.GetPointer());
+       SysTryReturnResult(NID_APP, pInteger != null, E_TYPE_MISMATCH, "Type mismatch between requested type int and object type.");
        value = pInteger->ToInt();
 
        return E_SUCCESS;
@@ -499,8 +494,7 @@ _AppSettingImpl::GetValue(const Tizen::Base::String& id, Tizen::Base::String& va
        const _SettingItem* pItem = dynamic_cast<const _SettingItem*>(pObject);
        SysTryReturnResult(NID_APP, pItem != null, E_TYPE_MISMATCH, "Type mismatch for instance of id.");
        const String* pString = dynamic_cast<const String*>(pItem->GetValue());
-       SysTryReturnResult(NID_APP, pString != null, E_TYPE_MISMATCH,
-                                          "Type mismatch between requested type String and object type of %ls.", id.GetPointer());
+       SysTryReturnResult(NID_APP, pString != null, E_TYPE_MISMATCH, "Type mismatch between requested type String and object type.");
        value = *pString;
 
        return E_SUCCESS;
@@ -514,8 +508,7 @@ _AppSettingImpl::SetValue(const Tizen::Base::String& id, bool value, bool save)
        _SettingItem* pItem = dynamic_cast<_SettingItem*>(pObject);
        SysTryReturnResult(NID_APP, pItem != null, E_TYPE_MISMATCH, "Type mismatch for instance of id.");
        Boolean* pBoolean = dynamic_cast<Boolean*>(pItem->GetValue());
-       SysTryReturnResult(NID_APP, pBoolean != null, E_TYPE_MISMATCH,
-                                          "Type mismatch between requested type bool and object type of %ls.", id.GetPointer());
+       SysTryReturnResult(NID_APP, pBoolean != null, E_TYPE_MISMATCH, "Type mismatch between requested type bool and object type.");
        *pBoolean = value;
 
        static const String strTrue(L"true");
@@ -545,8 +538,7 @@ _AppSettingImpl::SetValue(const Tizen::Base::String& id, int value, bool save)
        _SettingItem* pItem = dynamic_cast<_SettingItem*>(pObject);
        SysTryReturnResult(NID_APP, pItem != null, E_TYPE_MISMATCH, "Type mismatch for instance of id.");
        Integer* pInteger = dynamic_cast<Integer*>(pItem->GetValue());
-       SysTryReturnResult(NID_APP, pInteger != null, E_TYPE_MISMATCH,
-                                          "Type mismatch between requested type int and object type of %ls.", id.GetPointer());
+       SysTryReturnResult(NID_APP, pInteger != null, E_TYPE_MISMATCH, "Type mismatch between requested type int and object type.");
 
        SysTryReturnResult(NID_APP, (pItem->GetMin() <= value), E_OUT_OF_RANGE, "value(%d) is less than minimum range(%d).",
                                           value, pItem->GetMin());
@@ -577,8 +569,7 @@ _AppSettingImpl::SetValue(const Tizen::Base::String& id, const Tizen::Base::Stri
        _SettingItem* pItem = dynamic_cast<_SettingItem*>(pObject);
        SysTryReturnResult(NID_APP, pItem != null, E_TYPE_MISMATCH, "Type mismatch for instance of id.");
        String* pString = dynamic_cast<String*>(pItem->GetValue());
-       SysTryReturnResult(NID_APP, pString != null, E_TYPE_MISMATCH,
-                                          "Type mismatch between requested type String and object type of %ls.", id.GetPointer());
+       SysTryReturnResult(NID_APP, pString != null, E_TYPE_MISMATCH, "Type mismatch between requested type String and object type.");
 
        SysTryReturnResult(NID_APP, pItem->GetMin() <= value.GetLength(), E_OUT_OF_RANGE,
                                           "value length(%d) less than minimum length(%d).", value.GetLength(), pItem->GetMin());
@@ -641,7 +632,7 @@ _AppSettingImpl::Construct(const AppId& correspondAppId, const String& version)
        SysTryReturn(NID_APP, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
        if (!__oldVersionInstance)
        {
-               SysTryReturnResult(NID_APP, InitizlizeDBus(), E_SYSTEM, "A system error has been occurred. DBus initialization failed.");
+               SysTryReturnResult(NID_APP, InitializeDBus(), E_SYSTEM, "A system error has been occurred. DBus initialization failed.");
        }
        r = Load();
        SysTryReturnResult(NID_APP, !IsFailed(r), E_SYSTEM, "A system error has been occurred. Loading procedure failed.");
@@ -662,7 +653,7 @@ _AppSettingImpl::ConstructByAppPath(const AppId& correspondAppId, const Tizen::B
 
        r = __settingContainer.Construct();
        SysTryReturn(NID_APP, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
-       SysTryReturnResult(NID_APP, InitizlizeDBus(), E_SYSTEM, "A system error has been occurred. DBus initialization failed.");
+       SysTryReturnResult(NID_APP, InitializeDBus(), E_SYSTEM, "A system error has been occurred. DBus initialization failed.");
        r = Load();
        SysTryReturn(NID_APP, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
 
@@ -977,7 +968,7 @@ _AppSettingImpl::UpdateProperty(xmlNodePtr pNode, const String& value)
 }
 
 bool
-_AppSettingImpl::InitizlizeDBus(void)
+_AppSettingImpl::InitializeDBus(void)
 {
        DBusError error;
        dbus_error_init(&error);
@@ -1115,11 +1106,11 @@ _AppSettingImpl::SetValueFromDBusData(const char* pId, const char* pValue)
                        SetValue(strId, strValue, false);
                        return;
                }
-               SysLog(NID_APP, "Failed determin value type for id=%s", pId);
+               SysSecureLog(NID_APP, "Failed determine value type for id= %s", pId);
        }
        else
        {
-               SysLog(NID_APP, "Failed find value for id=%s", pId);
+               SysSecureLog(NID_APP, "Failed find value for id= %s", pId);
        }
 }