#include <FBaseSysLog.h>
#include <FBaseRtMutexGuard.h>
#include <FIoFile.h>
-#include <FIoFileAttributes.h>
#include <FIoRegistry.h>
-#include "FAppAppRegistry.h"
+#include <FAppAppRegistry.h>
#include "FApp_AppRegistryImpl.h"
#include "FApp_AppInfo.h"
__mutex.Create();
+ {
+ MutexGuard lock(__mutex);
+
+ Registry reg;
+ r = reg.Construct(__regPath, "a+");
+ SysAssertf(!IsFailed(r), "[%s] Constructing the registry file (%ls) has failed.", GetErrorMessage(r), __regPath.GetPointer());
+
+ r = reg.AddSection(__sectionName);
+ if (r == E_SECTION_ALREADY_EXIST)
+ {
+ r = E_SUCCESS;
+ }
+ }
return r;
}
{
MutexGuard lock(__mutex);
- Registry* pReg = LoadN(READ_WRITE);
+ Registry* pReg = LoadN(ReadWrite);
SysTryReturnResult(NID_APP, pReg != null, GetLastResult(), "Propagating to caller...");
result r = pReg->AddValue(__sectionName, key, value);
{
MutexGuard lock(__mutex);
- Registry* pReg = LoadN(READ_WRITE);
+ Registry* pReg = LoadN(ReadWrite);
SysTryReturnResult(NID_APP, pReg != null, GetLastResult(), "Propagating to caller...");
result r = pReg->AddValue(__sectionName, key, value);
{
MutexGuard lock(__mutex);
- Registry* pReg = LoadN(READ_WRITE);
+ Registry* pReg = LoadN(ReadWrite);
SysTryReturnResult(NID_APP, pReg != null, GetLastResult(), "Propagating to caller...");
result r = pReg->AddValue(__sectionName, key, value);
{
MutexGuard lock(__mutex);
- Registry* pReg = LoadN(READ_WRITE);
+ Registry* pReg = LoadN(ReadWrite);
SysTryReturnResult(NID_APP, pReg != null, GetLastResult(), "Propagating to caller...");
result r = pReg->SetValue(__sectionName, key, value);
{
MutexGuard lock(__mutex);
- Registry* pReg = LoadN(READ_WRITE);
+ Registry* pReg = LoadN(ReadWrite);
SysTryReturnResult(NID_APP, pReg != null, GetLastResult(), "Propagating to caller...");
result r = pReg->SetValue(__sectionName, key, value);
{
MutexGuard lock(__mutex);
- Registry* pReg = LoadN(READ_WRITE);
+ Registry* pReg = LoadN(ReadWrite);
SysTryReturnResult(NID_APP, pReg != null, GetLastResult(), "Propagating to caller...");
result r = pReg->SetValue(__sectionName, key, value);
{
MutexGuard lock(__mutex);
- Registry* pReg = LoadN(READ_WRITE);
+ Registry* pReg = LoadN(ReadWrite);
SysTryReturnResult(NID_APP, pReg != null, GetLastResult(), "Propagating to caller...");
result r = pReg->RemoveValue(__sectionName, key);
{
MutexGuard lock(__mutex);
- Registry* pReg = LoadN(READ_ONLY);
+ Registry* pReg = LoadN(ReadOnly);
SysTryReturnResult(NID_APP, pReg != null, GetLastResult(), "Propagating to caller...");
result r = pReg->GetValue(__sectionName, key, value);
{
MutexGuard lock(__mutex);
- Registry* pReg = LoadN(READ_ONLY);
+ Registry* pReg = LoadN(ReadOnly);
SysTryReturnResult(NID_APP, pReg != null, GetLastResult(), "Propagating to caller...");
result r = pReg->GetValue(__sectionName, key, value);
{
MutexGuard lock(__mutex);
- Registry* pReg = LoadN(READ_ONLY);
+ Registry* pReg = LoadN(ReadOnly);
SysTryReturnResult(NID_APP, pReg != null, GetLastResult(), "Propagating to caller...");
result r = pReg->GetValue(__sectionName, key, value);
}
Registry*
-_AppRegistryImpl::LoadN(LoadType type) const
+_AppRegistryImpl::LoadN(ReadOnlyTag) const
{
- result r = E_SUCCESS;
-
Registry* pReg = new (std::nothrow) Registry();
SysTryReturn(NID_APP, pReg != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
- if (type == READ_ONLY)
- {
- r = pReg->Construct(__regPath, "r");
- }
- else
- {
- r = pReg->Construct(__regPath, "a+");
- }
-
+ result r = pReg->Construct(__regPath, "r");
SysAssertf(!IsFailed(r), "Constructing the registry file (%ls) has failed. %s occurred.",
__regPath.GetPointer(), GetErrorMessage(r));
- r = pReg->AddSection(__sectionName);
- if (r == E_SECTION_ALREADY_EXIST)
- {
- r = E_SUCCESS;
- }
+ SetLastResult(r);
+ return pReg;
+}
- SysAssertf(!IsFailed(r), "Adding section to registry has failed. %s occurred.", GetErrorMessage(r));
+Registry*
+_AppRegistryImpl::LoadN(ReadWriteTag) const
+{
+ Registry* pReg = new (std::nothrow) Registry();
+ SysTryReturn(NID_APP, pReg != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ result r = pReg->Construct(__regPath, "a+");
+ SysAssertf(!IsFailed(r), "Constructing the registry file (%ls) has failed. %s occurred.",
+ __regPath.GetPointer(), GetErrorMessage(r));
SetLastResult(r);
return pReg;
#include <FBaseObject.h>
#include <FAppTypes.h>
-
-namespace Tizen { namespace Base { namespace Runtime { class Mutex; } } }
-namespace Tizen { namespace Io { class Registry; } }
+#include <FBaseRtMutex.h>
namespace Tizen { namespace App
{
+struct ReadOnlyTag {};
+struct ReadWriteTag {};
+
+static const ReadOnlyTag ReadOnly = {};
+static const ReadWriteTag ReadWrite = {};
+
/**
* @class _AppRegistryImpl
* @brief This class manages an application's preferences.
- * @since 1.0
*/
class _AppRegistryImpl
- : public Tizen::Base::Object
{
public:
/**
* This is the destructor for this class.
- *
- * @since 1.0
*/
- virtual ~_AppRegistryImpl(void);
+ ~_AppRegistryImpl(void);
/**
* Adds a string value along with the specified key.
*
- * @since 1.0
* @return An error code
* @param[in] key A key corresponding to the value
* @param[in] value A string value
/**
* Adds an integer value along with the specified key.
*
- * @since 1.0
* @return An error code
* @param[in] key A key corresponding to the value
* @param[in] value An integer value
/**
* Adds a floating point value along with the specified key.
*
- * @since 1.0
* @return An error code
* @param[in] key A key corresponding to the value
* @param[in] value A floating point value
/**
* Updates a string value associated with the specified key.
*
- * @since 1.0
* @return An error code
* @param[in] key A key corresponding to the value
* @param[in] value A string value
/**
* Updates an integer value associated with the specified key.
*
- * @since 1.0
* @return An error code
* @param[in] key A key corresponding to the value
* @param[in] value An integer value
/**
* Updates a floating point value associated with the specified key.
*
- * @since 1.0
* @return An error code
* @param[in] key A key corresponding to the value
* @param[in] value A floating point value
* Saves the values temporarily in the persistent storage. @n
* This method is invoked internally when the instance of this class is deleted.
*
- * @since 1.0
* @return An error code
* @exception E_SUCCESS The method is successful.
*/
/**
* Removes a preference associated with the specified key.
*
- * @since 1.0
* @return An error code
* @param[in] key The key of the value to be removed
* @exception E_SUCCESS The method is successful.
/**
* Retrieves a string value associated with the specified key.
*
- * @since 1.0
* @return An error code
* @param[in] key The key of the value to retrieve
* @param[out] value A string value to be retrieved
/**
* Retrieves an integer value associated with the specified key.
*
- * @since 1.0
* @return An error code
* @param[in] key The key of the value to retrieve
* @param[out] value An integer value to be retrieved
/**
* Retrieves a floating point value associated with the specified key.
*
- * @since 1.0
* @return An error code
* @param[in] key The key of the value to retrieve
* @param[out] value A floating point value to be retrieved
private:
/**
* This is the default constructor for this class.
- *
- * @since 1.0
*/
_AppRegistryImpl(void);
/**
* This is the copy constructor for this class.
- *
- * @since 1.0
*/
_AppRegistryImpl(const _AppRegistryImpl& source);
/**
* Allocates memory for an _AppRegistryImpl object.
*
- * @since 1.0
* @return An error code
* @exception E_SUCCESS The method is successful.
*/
*/
_AppRegistryImpl& operator =(const _AppRegistryImpl& source);
-private:
- enum LoadType {
- READ_ONLY,
- READ_WRITE
- };
+ /**
+ * Loads the registry file.
+ *
+ * @since 2.2
+ * @return The registry instance
+ * @exception E_SUCCESS The method is successful.
+ */
+ Tizen::Io::Registry* LoadN(ReadOnlyTag) const;
/**
* Loads the registry file.
* @return The registry instance
* @exception E_SUCCESS The method is successful.
*/
- Tizen::Io::Registry* LoadN(LoadType type) const;
+ Tizen::Io::Registry* LoadN(ReadWriteTag) const;
+
private:
const Tizen::Base::String __sectionName;