Fix memory leaks
[platform/framework/native/appfw.git] / src / security / FSec_PrivacyInfoImpl.cpp
index e929e6a..d436b14 100755 (executable)
@@ -1,5 +1,4 @@
 //
-// Open Service Platform
 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
 //
 // Licensed under the Apache License, Version 2.0 (the License);
@@ -24,7 +23,9 @@
 #include <unique_ptr.h>
 #include <FSecPrivacyInfo.h>
 #include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
 #include <FSec_AccessController.h>
+#include <privacy_info_client.h>
 #include "FSec_PrivacyInfoImpl.h"
 
 using namespace Tizen::Base;
@@ -76,10 +77,25 @@ _PrivacyInfoImpl::SetEnabled(bool enable)
 String
 _PrivacyInfoImpl::GetDisplayName(void) const
 {
-       String privacyURI = L"http://tizen.org/privacy/";
        String displayName;
 
-       __privacyId.SubString(privacyURI.GetLength(), displayName);
+       int ret = PRIV_MGR_ERROR_SUCCESS;
+       char* pPrivacyDisplayName;
+       privacy_info_client_s privacyInfo;
+
+       std::unique_ptr<char[]> pPrivacyId(null);
+       pPrivacyId.reset(_StringConverter::CopyToCharArrayN(__privacyId));
+       SysTryReturn(NID_SEC, pPrivacyId != null, displayName, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+
+       privacyInfo.privacy_id = pPrivacyId.get();
+       ret = privacy_info_client_get_privacy_display_name(&privacyInfo, &pPrivacyDisplayName);
+       SysTryReturn(NID_SEC, ret == PRIV_MGR_ERROR_SUCCESS, displayName, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+       displayName.Append(pPrivacyDisplayName);
+
+       if (pPrivacyDisplayName != null)
+       {
+               free(pPrivacyDisplayName);
+       }
 
        return displayName;
 }
@@ -87,7 +103,7 @@ _PrivacyInfoImpl::GetDisplayName(void) const
 String
 _PrivacyInfoImpl::GetDescription(void) const
 {
-       String description("undefined");
+       String description("Undefined");
        return description;
 }