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.
17 * @file FAppAppSetting.h
18 * @brief This is the implementation file for the %AppSetting class.
25 #include <FAppAppSetting.h>
26 #include <FBaseSysLog.h>
27 #include "FApp_AppSettingImpl.h"
29 using namespace Tizen::Base::Collection;
31 namespace Tizen { namespace App
34 AppSetting* AppSetting::__pAppSettingInstance = null;
36 AppSetting::AppSetting(void)
37 : __pAppSettingImpl(null)
42 AppSetting::~AppSetting(void)
44 delete __pAppSettingImpl;
48 AppSetting::GetInstance(void)
50 static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
52 if (!__pAppSettingInstance)
55 pthread_once(&onceBlock, InitSingleton);
56 result r = GetLastResult();
57 SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
59 __pAppSettingInstance->__pAppSettingImpl = _AppSettingImpl::GetInstance();
60 SysTryCatch(NID_APP, __pAppSettingInstance->__pAppSettingImpl != null, , E_OUT_OF_MEMORY,
61 "[%s] Memory allocation failed.");
64 return __pAppSettingInstance;
67 delete __pAppSettingInstance;
68 __pAppSettingInstance = null;
69 onceBlock = PTHREAD_ONCE_INIT;
74 AppSetting::GetInstance(const Tizen::Base::String& version)
76 return _AppSettingImpl::GetInstance(version);
80 AppSetting::GetInstanceByAppId(const AppId& appId)
82 //TODO: Add privilege checking code
83 return _AppSettingImpl::GetInstanceByAppId(appId);
87 AppSetting::ReleaseInstanceByAppId(const AppId& appId)
89 return _AppSettingImpl::ReleaseInstanceByAppId(appId);
92 Tizen::Base::Collection::IList*
93 AppSetting::GetAppSettingVersionListN(void)
95 return _AppSettingImpl::GetAppSettingVersionListN();
99 AppSetting::GetValue(const Tizen::Base::String& id, bool& value) const
101 return __pAppSettingImpl->GetValue(id, value);
105 AppSetting::GetValue(const Tizen::Base::String& id, int& value) const
107 return __pAppSettingImpl->GetValue(id, value);
111 AppSetting::GetValue(const Tizen::Base::String& id, Tizen::Base::String& value) const
113 return __pAppSettingImpl->GetValue(id, value);
117 AppSetting::SetValue(const Tizen::Base::String& id, bool value)
119 return __pAppSettingImpl->SetValue(id, value);
123 AppSetting::SetValue(const Tizen::Base::String& id, int value)
125 return __pAppSettingImpl->SetValue(id, value);
129 AppSetting::SetValue(const Tizen::Base::String& id, const Tizen::Base::String& value)
131 return __pAppSettingImpl->SetValue(id, value);
135 AppSetting::SetAppSettingEventListener(IAppSettingEventListener* pListener)
137 return __pAppSettingImpl->SetAppSettingEventListener(pListener);
141 AppSetting::InitSingleton(void)
143 AppSetting* pInst = new (std::nothrow) AppSetting();
144 SysTryReturnVoidResult(NID_UI_SCENES, pInst, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
145 GetErrorMessage(E_OUT_OF_MEMORY));
147 __pAppSettingInstance = pInst;
148 std::atexit(DestroySingleton);
152 AppSetting::DestroySingleton(void)
154 delete __pAppSettingInstance;