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.
18 * @file FAppAppSetting.h
19 * @brief This is the header file for the %AppSetting class.
21 * This header file contains the declarations of the %AppSetting class.
24 #ifndef _FAPP_APP_SETTING_H_
25 #define _FAPP_APP_SETTING_H_
27 #include <FBaseTypes.h>
28 #include <FBaseString.h>
29 #include <FBaseObject.h>
30 #include <FAppTypes.h>
33 namespace Tizen { namespace Base { namespace Collection
39 namespace Tizen { namespace App
42 class IAppSettingEventListener;
46 * @brief This class manages an application's settings.
50 * @final This class is not intended for extension.
52 * The %AppSetting class is a helper class for an application to save or restore its settings.
53 * A setting entity is composed of a string-typed key and a value. The value type must be only of these three types: @c int, @c bool, and @c String.
54 * The settings are pre-defined in setting/setting.xml in the application's base directory
55 * and they can be easily set with %Tizen IDE (<a href="../org.tizen.native.appprogramming/html/ide_sdk_tools/creating_running_app_setting.htm">Creating and Using Application Settings</a>, <a href="../org.tizen.native.appprogramming/html/ide_sdk_tools/application_settings_editor.htm">Application Settings Editor</a>).
56 * (The setting.xml is a symbolic link to the currently used setting file, which is related to the current version of the application.) @n
57 * The %AppSetting class is basically used for specific applications such as IME, which have no UI.
58 * Because the applications have no external way to modify their settings, users can adjust the setting values through the setting application, which is delegated to manage the settings.
59 * For supporting the consistency of setting values between two applications, the target application and the setting application, when setting a value in the setting application, the target application is notified from the setting application through
60 * IAppSettingEventListener::OnAppSettingChanged()
61 * For detailed example on this class, see <a href="../org.tizen.native.appprogramming/html/tutorials/app_tutorial/task_app_settings.htm?resultof=%22%41%70%70%53%65%74%74%69%6e%67%22%20%22%61%70%70%73%65%74%74%69%6e%67%22%20">Task: App Setting</a>.
63 * @see IAppSettingEventListener
65 class _OSP_EXPORT_ AppSetting
66 : public Tizen::Base::Object
70 * Gets the application setting instance.
74 * @return A pointer to the %AppSetting instance for the last setting, @n
75 * else @c null if it fails
76 * @exception E_SUCCESS The method is successful.
77 * @exception E_OUT_OF_MEMORY The memory is insufficient.
78 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
79 * @remarks The specific error code can be accessed using the GetLastResult() method.
81 static AppSetting* GetInstance(void);
84 * Gets the application setting instance of the specified version.
88 * @return A pointer to the %AppSetting instance, @n
89 * else @c null if it fails
90 * @param[in] settingVersion The version of setting is retrieved from GetAppSettingVersionListN()
91 * @exception E_SUCCESS The method is successful.
92 * @exception E_OBJ_NOT_FOUND The specified version is not found.
93 * @exception E_OUT_OF_MEMORY The memory is insufficient.
94 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
95 * @remarks The specific error code can be accessed using the GetLastResult() method.
96 * @see GetAppSettingVersionListN()
98 static AppSetting* GetInstance(const Tizen::Base::String& settingVersion);
101 * Gets the application setting instance of the specified AppId.
105 * @privlevel platform
106 * @privilege %http://tizen.org/privilege/appsetting
108 * @return A pointer to the %AppSetting instance, @n
109 * else @c null if it fails
110 * @param[in] appId The AppId of the application that has a valid application setting
111 * @exception E_SUCCESS The method is successful.
112 * @exception E_OBJ_NOT_FOUND The instance of specified AppId does not have setting information.
113 * @exception E_OUT_OF_MEMORY The memory is insufficient.
114 * @exception E_INVALID_ARG The specified input parameter is invalid.
115 * @exception E_APP_NOT_INSTALLED The AppId is not found.
116 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
117 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
118 * @remarks The specific error code can be accessed using the GetLastResult() method.
119 * @see ReleaseInstanceByAppId()
121 static AppSetting* GetInstanceByAppId(const AppId& appId);
124 * Releases the specified application setting instance.
128 * @privlevel platform
129 * @privilege %http://tizen.org/privilege/appsetting
131 * @return An error code
132 * @param[in] appId The AppId of the application that has a valid application setting
133 * @exception E_SUCCESS The method is successful.
134 * @exception E_OBJ_NOT_FOUND The specified instance of AppId is not found or already released.
135 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
136 * @remarks Individual instances are managed by the platform. @n
137 * It is recommended to release instances to reduce memory usage.
138 * @see GetInstanceByAppId()
140 static result ReleaseInstanceByAppId(const AppId& appId);
143 * Gets a list of all the versions that existed prior to the current version. @n
144 * The versions listed are based on the setting.xml file, which is generated when an application is installed.
148 * @return A pointer to the list that contains the Tizen::Base::String instances of version list @n
149 * The latest version string is located in the first position. If the old version does not exist then return empty collection.
150 * @exception E_SUCCESS The method is successful.
151 * @exception E_OUT_OF_MEMORY The memory is insufficient.
152 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
153 * @remarks The specific error code can be accessed using the GetLastResult() method.
155 static Tizen::Base::Collection::IList* GetAppSettingVersionListN(void);
158 * Gets a @c bool value associated with the specified @c id.
162 * @return An error code
163 * @param[in] id The ID of the value to retrieve
164 * @param[out] value A boolean value to retrieve
165 * @exception E_SUCCESS The method is successful.
166 * @exception E_OUT_OF_MEMORY The memory is insufficient.
167 * @exception E_OBJ_NOT_FOUND The specified @c id is not found in the application setting.
168 * @exception E_INVALID_ARG A specified input parameter is invalid.
169 * @exception E_TYPE_MISMATCH The operation has attempted to access different types.
171 result GetValue(const Tizen::Base::String& id, bool& value) const;
174 * Gets an integer value associated with the specified @c id.
178 * @return An error code
179 * @param[in] id The ID of the value to retrieve
180 * @param[out] value An integer value to retrieve
181 * @exception E_SUCCESS The method is successful.
182 * @exception E_OUT_OF_MEMORY The memory is insufficient.
183 * @exception E_OBJ_NOT_FOUND The specified @c id is not found in the application setting.
184 * @exception E_INVALID_ARG A specified input parameter is invalid.
185 * @exception E_TYPE_MISMATCH The operation has attempted to access different types.
187 result GetValue(const Tizen::Base::String& id, int& value) const;
190 * Gets a string value associated with the specified @c id.
194 * @return An error code
195 * @param[in] id The id of the value to retrieve
196 * @param[out] value A string value to retrieve
197 * @exception E_SUCCESS The method is successful.
198 * @exception E_OUT_OF_MEMORY The memory is insufficient.
199 * @exception E_OBJ_NOT_FOUND The specified @c id is not found in the application setting.
200 * @exception E_INVALID_ARG A specified input parameter is invalid.
201 * @exception E_TYPE_MISMATCH The operation has attempted to access different types.
203 result GetValue(const Tizen::Base::String& id, Tizen::Base::String& value) const;
206 * Sets a @c bool value associated with the specified @c id.
210 * @return An error code
211 * @param[in] id The ID of the value to modify
212 * @param[in] value A boolean value
213 * @exception E_SUCCESS The method is successful.
214 * @exception E_OUT_OF_MEMORY The memory is insufficient.
215 * @exception E_OBJ_NOT_FOUND The specified @c id is not found in the application setting.
216 * @exception E_INVALID_ARG A specified input parameter is invalid.
217 * @exception E_TYPE_MISMATCH The operation has attempted to access different types.
218 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
220 result SetValue(const Tizen::Base::String& id, bool value);
223 * Sets an integer value associated with the specified @c id.
227 * @return An error code
228 * @param[in] id The ID of the value to modify
229 * @param[in] value An integer value
230 * @exception E_SUCCESS The method is successful.
231 * @exception E_OUT_OF_MEMORY The memory is insufficient.
232 * @exception E_OBJ_NOT_FOUND The specified @c id is not found in the application setting.
233 * @exception E_OUT_OF_RANGE The specified @c value is out of range.
234 * @exception E_INVALID_ARG A specified input parameter is invalid.
235 * @exception E_TYPE_MISMATCH The operation has attempted to access different types.
236 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
238 result SetValue(const Tizen::Base::String& id, int value);
241 * Sets a string value associated with the specified @c id.
245 * @return An error code
246 * @param[in] id The ID of the value to modify
247 * @param[in] value A string value
248 * @exception E_SUCCESS The method is successful.
249 * @exception E_OUT_OF_MEMORY The memory is insufficient.
250 * @exception E_OBJ_NOT_FOUND The specified @c id is not found in the application setting.
251 * @exception E_OUT_OF_RANGE The specified string length is out of range.
252 * @exception E_INVALID_ARG A specified input parameter is invalid.
253 * @exception E_TYPE_MISMATCH The operation has attempted to access different types.
254 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
256 result SetValue(const Tizen::Base::String& id, const Tizen::Base::String& value);
259 * Sets a setting event listener.
263 * @return An error code
264 * @param[in] pListener An instance of IAppSettingEventListener to set, @n
265 * else @c null to clear a previous one
266 * @exception E_SUCCESS The method is successful.
268 result SetAppSettingEventListener(IAppSettingEventListener* pListener);
272 * This default constructor is intentionally declared as private to implement the Singleton semantic.
279 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
283 AppSetting(const AppSetting& rhs);
286 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
290 AppSetting& operator =(const AppSetting& rhs);
293 * This destructor is intentionally declared as private to implement the Singleton semantic.
297 virtual ~AppSetting(void);
299 static void InitSingleton(void);
300 static void DestroySingleton(void);
303 friend class _AppSettingImpl;
304 class _AppSettingImpl* __pAppSettingImpl;
305 static AppSetting* __pAppSettingInstance;
310 #endif // _FAPP_APP_SETTING_H_