2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file FAppAppSetting.h
19 * @brief This is the implementation file for the %AppSetting class.
26 #include <FAppAppSetting.h>
27 #include <FBaseSysLog.h>
28 #include "FApp_AppSettingImpl.h"
30 using namespace Tizen::Base::Collection;
32 namespace Tizen { namespace App
35 AppSetting* AppSetting::__pAppSettingInstance = null;
37 AppSetting::AppSetting(void)
38 : __pAppSettingImpl(null)
43 AppSetting::~AppSetting(void)
45 delete __pAppSettingImpl;
49 AppSetting::GetInstance(void)
51 static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
53 if (!__pAppSettingInstance)
56 pthread_once(&onceBlock, InitSingleton);
57 result r = GetLastResult();
58 SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
60 __pAppSettingInstance->__pAppSettingImpl = _AppSettingImpl::GetInstance();
61 SysTryCatch(NID_APP, __pAppSettingInstance->__pAppSettingImpl != null, , E_OUT_OF_MEMORY,
62 "[%s] Memory allocation failed.");
65 return __pAppSettingInstance;
68 delete __pAppSettingInstance;
69 __pAppSettingInstance = null;
70 onceBlock = PTHREAD_ONCE_INIT;
75 AppSetting::GetInstance(const Tizen::Base::String& version)
77 return _AppSettingImpl::GetInstance(version);
81 AppSetting::GetInstanceByAppId(const AppId& appId)
83 //TODO: Add privilege checking code
84 return _AppSettingImpl::GetInstanceByAppId(appId);
88 AppSetting::ReleaseInstanceByAppId(const AppId& appId)
90 return _AppSettingImpl::ReleaseInstanceByAppId(appId);
93 Tizen::Base::Collection::IList*
94 AppSetting::GetAppSettingVersionListN(void)
96 return _AppSettingImpl::GetAppSettingVersionListN();
100 AppSetting::GetValue(const Tizen::Base::String& id, bool& value) const
102 return __pAppSettingImpl->GetValue(id, value);
106 AppSetting::GetValue(const Tizen::Base::String& id, int& value) const
108 return __pAppSettingImpl->GetValue(id, value);
112 AppSetting::GetValue(const Tizen::Base::String& id, Tizen::Base::String& value) const
114 return __pAppSettingImpl->GetValue(id, value);
118 AppSetting::SetValue(const Tizen::Base::String& id, bool value)
120 return __pAppSettingImpl->SetValue(id, value);
124 AppSetting::SetValue(const Tizen::Base::String& id, int value)
126 return __pAppSettingImpl->SetValue(id, value);
130 AppSetting::SetValue(const Tizen::Base::String& id, const Tizen::Base::String& value)
132 return __pAppSettingImpl->SetValue(id, value);
136 AppSetting::SetAppSettingEventListener(IAppSettingEventListener* pListener)
138 return __pAppSettingImpl->SetAppSettingEventListener(pListener);
142 AppSetting::InitSingleton(void)
144 AppSetting* pInst = new (std::nothrow) AppSetting();
145 SysTryReturnVoidResult(NID_UI_SCENES, pInst, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
146 GetErrorMessage(E_OUT_OF_MEMORY));
148 __pAppSettingInstance = pInst;
149 std::atexit(DestroySingleton);
153 AppSetting::DestroySingleton(void)
155 delete __pAppSettingInstance;