Using database to store the condition details with userid
authorKarthik Subas Chandra Bose <karthik.scb@samsung.com>
Mon, 26 Aug 2013 07:12:23 +0000 (16:12 +0900)
committerKarthik Subas Chandra Bose <karthik.scb@samsung.com>
Fri, 6 Sep 2013 06:57:21 +0000 (15:57 +0900)
Change-Id: I4d3e51815a3f1951b8f3650a82069f9d86c9b257
Signed-off-by: Karthik Subas Chandra Bose <karthik.scb@samsung.com>
inc/FApp_ConditionHandler.h
inc/FApp_ConditionManagerService.h
src/FApp_ConditionHandler.cpp
src/FApp_ConditionManagerService.cpp

index ced8755..4bfe826 100644 (file)
@@ -105,18 +105,25 @@ private:
 
 
 /**
- * @class              _ConditionRegistryHelper
+ * @class              _ConditionDatabaseHelper
  * @brief
- * @since 2.1
+ * @since 3.0
  */
 
-class _ConditionRegistryHelper
+class _ConditionDatabaseHelper
 {
 public:
-               static result AddToRegistry(const Tizen::Base::String& sectionName, const Tizen::App::AppId& appId, const Tizen::Base::String& condition, const Tizen::Base::Collection::IList *pArgs);
-               static result RemoveFromRegistry(const Tizen::Base::String& sectionName);
-               static result GetAllParamsN(const Tizen::Base::Collection::IMap& map, Tizen::App::AppId& appId, Tizen::Base::String& condition, Tizen::Base::Collection::ArrayList*& pArgs);
-};     //_ConditionRegistryHelper
+    static result InsertRecordToConditionDb(const Tizen::Base::String& sectionName, const Tizen::App::AppId& appId, const int& userId,
+               const Tizen::Base::String& condition, const Tizen::Base::Collection::IList *pArgs);
+    static result RemoveRecordFromConditionDb(const Tizen::Base::String& sectionName);
+    static result GetAllSectionsFromConditionDb(Tizen::Base::Collection::ArrayList* pSections);
+    static result GetConditionEntryFromDbN(const Tizen::Base::String& sectionName, Tizen::App::AppId& appId, int& userId,
+               Tizen::Base::String& condition, Tizen::Base::Collection::ArrayList*& pArgs);
+    static result ConvertArgToBundleN(const Tizen::Base::String& key, const Tizen::Base::Collection::IList* pArgs,
+               void*& pBundleBuf, int& length);
+    static result ConvertBundleToArgN(const Tizen::Base::String& key, void*& pBundleBuf, const int& argCount,
+               const int& length, Tizen::Base::Collection::ArrayList*& pArgs);
+};      //_ConditionDatabaseHelper
 
 
 }} //Tizen::App
index fe97999..52c3533 100644 (file)
@@ -46,9 +46,8 @@ class _ConditionHandler;
 class _ConditionManagerService
        : public Tizen::Base::Object
 {
-       typedef Tizen::Base::Collection::ArrayListT<_ConditionHandler*> _ConditionHandlers;
-       typedef Tizen::Base::Collection::HashMapT<Tizen::Base::String, _ConditionHandler*> _ConditionHandlerMap;
-
+       typedef Tizen::Base::Collection::HashMapT<Tizen::Base::String, _ConditionHandler*> _ConditionHandlersMap;
+       typedef Tizen::Base::Collection::HashMapT<Tizen::Base::String, Tizen::Base::String> _ConditionDataMap;
 
 public:
        _ConditionManagerService(void);
@@ -63,10 +62,10 @@ public:
 
 private:
        // internal
-       result InitializePlugins(void);
-       result InitializePluginEntry(Tizen::Base::Collection::IMap& map);
+       result InitializePluginData(void);
+       result LoadConditionPlugin(const Tizen::Base::String& fileName);
        result InitializeConditionalOperations(void);
-       result InitializeConditionalOperationEntry(const Tizen::Base::String& sectionName, const Tizen::Base::Collection::IMap& map);
+       result InitializeConditionalOperationEntry(const Tizen::Base::String& sectionName);
        _ConditionHandler* GetLaunchConditionHandler(const Tizen::Base::String& pluginName);
        _ConditionHandler* GetHandlerByCondition(const Tizen::Base::String& condition);
 
@@ -76,8 +75,8 @@ private:
        void Dump(void) const;
 
 private:
-       _ConditionHandlers __handlers;
-       _ConditionHandlerMap __handlerLookupTable;
+       _ConditionHandlersMap __handlers;
+       _ConditionDataMap __handlerLookupTable;
 
        _StringComparerT __strComparer;
        _StringHashMapProviderT __strHashMapProvider;
index 3e67370..5eb9064 100644 (file)
@@ -168,7 +168,10 @@ _ConditionHandler::AddCondition(_AppLaunchCondition& operation)
        {
                CreateUniqueId(uniqueId);
                operation.__regSectionName = uniqueId;
-               _ConditionRegistryHelper::AddToRegistry(uniqueId, operation.GetAppId(), operation.GetConditionString(), operation.__pArguments );
+               //TODO
+               int userId = 1; //operation.GetUserId();
+               _ConditionDatabaseHelper::InsertRecordToConditionDb(uniqueId, operation.GetAppId(), userId,
+                               operation.GetConditionString(), operation.__pArguments);
        }
        else
        {
@@ -216,8 +219,7 @@ _ConditionHandler::RemoveCondition(const PackageId& packageId, const String& app
                {
                        r = __pPluginInstance->Unregister(*pOperation);
 
-                       //SysTryCatch(NID_APP, !IsFailed(r), delete pOperation, r, "[%s] failed to Unregister(%ls, %ls)", GetErrorMessage(r), pOperation->GetAppId().GetPointer(), pOperation->GetConditionString().GetPointer() );//TBC
-                       _ConditionRegistryHelper::RemoveFromRegistry(pOperation->__regSectionName);
+                       _ConditionDatabaseHelper::RemoveRecordFromConditionDb(pOperation->__regSectionName);
 
                        r = __conditionalOperations.Remove(pOperation->GetConditionString(), pOperation);
                        SysTryLog(NID_APP, !IsFailed(r), "[%s]", GetErrorMessage(r));
index 60a47d3..a36f268 100644 (file)
 
 #include <FIoDirectory.h>
 #include <FIoRegistry.h>
-#include <FAppApp.h>
+#include <FIoDatabase.h>
+#include <FIoDbStatement.h>
+#include <FIoDbEnumerator.h>
 
+#include <FAppApp.h>
 #include <FBaseSysLog.h>
+#include <FBaseColHashMap.h>
+
+#include <FBase_StringConverter.h>
 #include <FIo_RegistryImpl.h>
+#include <FIo_DatabaseImpl.h>
 
 #include "FApp_Types.h"
 #include "FAppPkg_PackageManagerImpl.h"
@@ -47,12 +54,15 @@ namespace
        const String REG_KEY_KEY = L"Key";
        const String REG_KEY_FILENAME = L"Filename";
 
-       const String REGISTRY_FILE_OPERATIONS = L"data/app-launch-conditions.ini";
-       const String REG_KEY_APPID = L"AppId";
-       const String REG_KEY_CONDTION = L"Condition";
-       const String REG_KEY_LAUNCH_TYPE = L"LaunchType";
-       const String REG_KEY_ARG_COUNT = L"ArgCount";
-       const String REG_KEY_ARG = L"Arg";
+       const String DATABASE_COND_OPERATIONS = L"app-launch-conditions.db";
+       const int DB_TABLE_COND_SECTION_NAME = 0;
+       const int DB_TABLE_COND_APPID = 1;
+       const int DB_TABLE_COND_USERID = 2;
+       const int DB_TABLE_COND_CONDITION = 3;
+       const int DB_TABLE_COND_LAUNCHTYPE = 4;
+       const int DB_TABLE_COND_ARG_COUNT = 5;
+       const int DB_TABLE_COND_ARG_LENGTH = 6;
+       const int DB_TABLE_COND_ARG = 7;
 
        const int MAX_LEN_ARG = 1024;
        const int MAX_LEN_CONDITION = 400;
@@ -68,16 +78,9 @@ _ConditionManagerService::_ConditionManagerService()
 _ConditionManagerService::~_ConditionManagerService()
 {
        SysLog(NID_APP, "Enter");
-       result r = E_SUCCESS;
 
-       //_ConditionHandler* pHandler = null;
-       for (int i =0; i < __handlers.GetCount(); i ++)
-       {
-               _ConditionHandler* pHandler = null;
-               r = __handlers.GetAt(i, pHandler);
-               delete pHandler;
-       }
        __handlers.RemoveAll();
+       __handlerLookupTable.RemoveAll();
 
        SysLog(NID_APP, "Exit");
 }
@@ -86,70 +89,73 @@ result
 _ConditionManagerService::Construct(void)
 {
        SysLog(NID_APP,"Enter.");
-
        result r = E_SUCCESS;
 
-       r = __handlers.Construct();
-       SysTryReturn(NID_APP, !IsFailed(r), r, r, "failed to __handlers.Construct.(%s)", GetErrorMessage(r) );
+       r = __handlers.Construct(0, 0, __strHashMapProvider, __strComparer);
+       SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to __handlers.Construct.");
 
-       r = __handlerLookupTable.Construct( 16, 0.75f, __strHashMapProvider, __strComparer);
-       SysTryReturn(NID_APP, !IsFailed(r), r, r, "failed to __handlerLookupTable.Construct.(%s)", GetErrorMessage(r) );
+       r = __handlerLookupTable.Construct(0, 0, __strHashMapProvider, __strComparer);
+       SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to __handlerLookupTable.Construct.");
 
-       r = InitializePlugins();
-       SysTryReturn(NID_APP, !IsFailed(r), r, r, "failed to InitializePlugins.(%s)", GetErrorMessage(r) );
+       r = InitializePluginData();
+       SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to InitializePluginData.");
 
        r = InitializeConditionalOperations();
-       SysTryLog(NID_APP, !IsFailed(r), "failed to InitializeLaunchConditions.(%s)", GetErrorMessage(r) );
+       SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to InitializeLaunchConditions.");
 
        SysLog(NID_APP,"Exit.");
        return E_SUCCESS;
 }
 
 result
-_ConditionManagerService::InitializePlugins(void)
+_ConditionManagerService::InitializePluginData(void)
 {
        SysLog(NID_APP,"Enter.");
        _RegistryImpl reg;
-       const String& homePath = App::GetInstance()->GetAppRootPath();
+       IList *pSections = null;
 
-       result r = reg.Construct(homePath + REGISTRY_FILE_PLUGIN, REG_OPEN_READ_ONLY , null);
-       if (IsFailed(r))
-       {
-               SysLog(NID_APP, "failed to open registry '%ls' (%s)", (homePath + REGISTRY_FILE_PLUGIN).GetPointer(), GetErrorMessage(r) );
-               return E_SUCCESS;
-       }
+       const String& homePath = App::GetInstance()->GetAppRootPath();
+       result r = reg.Construct(homePath + REGISTRY_FILE_PLUGIN, REG_OPEN_READ_ONLY, null);
+       SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to open registry '%ls'", (homePath + REGISTRY_FILE_PLUGIN).GetPointer());
 
-       IList *pSections = null;
        r = reg.GetSectionListN(&pSections);
-       SysTryReturn(NID_APP, !IsFailed(r), r, r, "failed to GetSectionListN. (%s)", GetErrorMessage(r) );
+       SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to GetSectionListN.");
 
        std::unique_ptr<IEnumerator> pEnum(pSections->GetEnumeratorN());
-       String* pSecName = null;
-
-       IMap* pMap = null;
+       SysTryCatch(NID_APP, pEnum != null,  , E_FAILURE, "failed to GetEnumeratorN.");
 
        while (pEnum->MoveNext() == E_SUCCESS)
        {
+               String* pSecName = null;
+
                pSecName = static_cast<String*>(pEnum->GetCurrent());
                pSecName->Trim();
 
-               pMap = reg.GetAllEntriesN(*pSecName);
-               SysTryCatch(NID_APP, pMap != null, , E_SYSTEM, "");// try next
+               std::unique_ptr<IMap> pMap(reg.GetAllEntriesN(*pSecName));
+               SysTryCatch(NID_APP, pMap != null,  , E_FAILURE, "failed to GetAllEntriesN.");
 
-               r = InitializePluginEntry(*pMap);
-               if ( r == E_OBJ_NOT_FOUND)
+               const String* pTypes = static_cast<const String*>(pMap->GetValue(REG_KEY_KEY));
+               const String* pFilename = static_cast<const String*>(pMap->GetValue(REG_KEY_FILENAME));
+
+               SysTryCatch(NID_APP, pTypes != null, , E_OBJ_NOT_FOUND, "registry value is invalid. pTypes is null");
+               SysTryCatch(NID_APP, pFilename != null, , E_OBJ_NOT_FOUND, "registry value is invalid. pFilename is null");
+
+               Utility::StringTokenizer strTok(*pTypes, L',');
+               String keyTypes;
+
+               if (strTok.GetTokenCount() == 0)
                {
-                       // empty statement
+                       __handlerLookupTable.Add(*pTypes, *pFilename);
                }
                else
                {
-                       SysTryCatch(NID_APP, !IsFailed(r), , r, "");
+                       while (strTok.GetNextToken(keyTypes) == E_SUCCESS)
+                       {
+                               keyTypes.Trim();
+                               __handlerLookupTable.Add(keyTypes, *pFilename);
+                       }
                }
-
-               pMap->RemoveAll(true);
-               delete pMap;
        }
-
        pSections->RemoveAll(true);
        delete pSections;
 
@@ -158,151 +164,165 @@ _ConditionManagerService::InitializePlugins(void)
 
 CATCH:
        SysLog(NID_APP,"Catch.");
+
        pSections->RemoveAll(true);
        delete pSections;
-
        return r;
 }
 
 result
-_ConditionManagerService::InitializePluginEntry(IMap& map)
+_ConditionManagerService::LoadConditionPlugin(const String& fileName)
 {
-       result r = E_SUCCESS;
+       _RegistryImpl reg;
+       _ConditionHandler* pHandler = null;
+       HashMap* pMap = null;
+
+       const String& homePath = App::GetInstance()->GetAppRootPath();
+       result r = reg.Construct(homePath + REGISTRY_FILE_PLUGIN, REG_OPEN_READ_ONLY, null);
+       SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to open registry '%ls'", (homePath + REGISTRY_FILE_PLUGIN).GetPointer());
 
-       const String* pTypes = static_cast<const String*>(map.GetValue(REG_KEY_KEY));
-       const String* pFilename = static_cast<const String*>(map.GetValue(REG_KEY_FILENAME));
-       _ConditionHandler * pHandler = null;
+       r = reg.GetEntryListN(fileName, &pMap);
+       SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to GetEntryListN.");
 
-       SysTryReturn(NID_APP, pTypes != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "registry value is invalid. pTypes is null");
-       SysTryReturn(NID_APP, pFilename != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "registry value is invalid. pFilename is null");
+       const String* pTypes = static_cast<const String*>(pMap->GetValue(REG_KEY_KEY));
+       const String* pFilename = static_cast<const String*>(pMap->GetValue(REG_KEY_FILENAME));
 
-       Utility::StringTokenizer strTok(*pTypes, L',');
-       String type;
+       SysTryCatch(NID_APP, pTypes != null, , E_OBJ_NOT_FOUND, "registry value is invalid. pTypes is null");
+       SysTryCatch(NID_APP, pFilename != null, , E_OBJ_NOT_FOUND, "registry value is invalid. pFilename is null");
 
        pHandler = new (std::nothrow) _ConditionHandler(*pFilename, *pTypes);
-       SysTryReturn(NID_APP, pHandler != null, E_FAILURE, E_FAILURE, "failed to new _ConditionHandler(%ls, %ls).", pFilename->GetPointer(), pTypes->GetPointer() );
+       SysTryCatch(NID_APP, pHandler != null,  , E_FAILURE, "failed to construct _ConditionHandler(%ls, %ls).",
+                       pFilename->GetPointer(), pTypes->GetPointer());
 
        r = pHandler->Construct();
-       SysTryCatch(NID_APP, !IsFailed(r), , r, "failed to pHandler->Construct. (%s)", GetErrorMessage(r) );
+       SysTryCatch(NID_APP, !IsFailed(r), , r, "failed to pHandler->Construct.");
 
-       __handlers.Add(pHandler);
-
-
-       if ( strTok.GetTokenCount() == 0)
-       {
-               __handlerLookupTable.Add(*pTypes, pHandler);
-       }
-       else
-       {
-               while ( strTok.GetNextToken(type) == E_SUCCESS)
-               {
-                       type.Trim();
-                       __handlerLookupTable.Add(type, pHandler);
-               }
-       }
-
-       SysLog(NID_APP, "%ls is loaded.", pFilename->GetPointer() );
+       __handlers.Add(*pFilename, pHandler);
+       SysLog(NID_APP, "%ls is loaded.", pFilename->GetPointer());
 
+       pMap->RemoveAll(true);
+       delete pMap;
        return E_SUCCESS;
 
 CATCH:
        SysLog(NID_APP, "CATCH:");
+
+       pMap->RemoveAll(true);
+       delete pMap;
        delete pHandler;
+
        return r;
 }
 
-// condinfo.ini
 result
 _ConditionManagerService::InitializeConditionalOperations(void)
 {
        SysLog(NID_APP,"Enter.");
-       _RegistryImpl reg;
-       String homePath = App::GetInstance()->GetAppRootPath();
+       _DatabaseImpl condDb;
+       result r = E_SUCCESS;
+       String sql;
 
-       result r = reg.Construct(homePath + REGISTRY_FILE_OPERATIONS, REG_OPEN_READ_ONLY, null);
-//     SysTryReturn(NID_APP, !IsFailed(r), r, r, "");
-       if ( IsFailed(r))
+       const String& homePath = App::GetInstance()->GetAppDataPath();
+       if(!(condDb.Exists(homePath + DATABASE_COND_OPERATIONS)))
        {
-               SysLog(NID_APP, "failed to open registry '%ls'", (homePath + REGISTRY_FILE_OPERATIONS).GetPointer());
-               return E_SUCCESS;
-       }
+               r = condDb.Construct(homePath + DATABASE_COND_OPERATIONS, DB_OPEN_READ_WRITE | DB_OPEN_CREATE);
+               SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to create/open database '%ls'",
+                               (homePath + DATABASE_COND_OPERATIONS).GetPointer());
 
-       IList *pSections = null;
-       reg.GetSectionListN(&pSections );
-
-       IEnumerator*    pEnum = pSections->GetEnumeratorN();
-       String* pSecName = null;
+               sql.Append(L"CREATE TABLE IF NOT EXISTS CondTbl (SectionName TEXT PRIMARY KEY, AppId TEXT, UserId INTEGER,"
+                               "Condition TEXT, LaunchType TEXT, ArgCount INTEGER, ArgLength INTEGER, Arguments BLOB)");
 
-       IMap* pMap = null;
+               r = condDb.ExecuteSql(sql, true);
+               SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to execute sql statement.");
 
-       while (pEnum->MoveNext() == E_SUCCESS)
+               SysLog(NID_APP,"Database created successfully.");
+       }
+       else
        {
-               pSecName = static_cast<String*>(pEnum->GetCurrent());
-               pSecName->Trim();
+               SysLog(NID_APP,"Database available and trying to open to read conditions.");
+               String* pSecName = null;
 
-               pMap = reg.GetAllEntriesN(*pSecName);
-               SysTryCatch(NID_APP, pMap != null, r = E_INVALID_FORMAT, E_INVALID_FORMAT, "failed to GetAllEntryNamesN(%ls)", pSecName->GetPointer() );
+               std::unique_ptr<ArrayList> pSections(new (std::nothrow) ArrayList(SingleObjectDeleter));
+               SysTryReturnResult(NID_APP, pSections != null, E_OUT_OF_MEMORY, "failed to allocate memory for ArrayList.");
 
-               r = InitializeConditionalOperationEntry(*pSecName, *pMap);
-               SysTryLog(NID_APP, !IsFailed(r), "failed to InitializeConditionalOperationEntry(%ls), but ignored.", pSecName->GetPointer() );
+               r = pSections->Construct();
+               SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to Construct arraylist.");
 
-               pMap->RemoveAll(true);
-               delete pMap;
+               r = _ConditionDatabaseHelper::GetAllSectionsFromConditionDb(pSections.get());
+               SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to GetAllSectionsFromConditionDb.");
 
-               pMap = null;
-       }
+               std::unique_ptr< IEnumerator > pEnum(pSections->GetEnumeratorN());
+               SysTryReturnResult(NID_APP, pEnum != null, r, "failed to GetEnumeratorN.");
 
-       r = E_SUCCESS;
-
-CATCH:
-       delete pEnum;
-
-       pSections->RemoveAll(true);
-       delete pSections;
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       pSecName = static_cast<String*>(pEnum->GetCurrent());
+                       pSecName->Trim();
 
+                       r = InitializeConditionalOperationEntry(*pSecName);
+                       SysTryLog(NID_APP, !IsFailed(r), "failed to InitializeConditionalOperationEntry(%ls), but ignored.",
+                                       pSecName->GetPointer());
+               }
+       }
        SysLog(NID_APP,"Exit.");
-       return r;
+       return E_SUCCESS;
 }
 
 result
-_ConditionManagerService::InitializeConditionalOperationEntry(const String& sectionName, const IMap& map)
+_ConditionManagerService::InitializeConditionalOperationEntry(const String& sectionName)
 {
        String appId;
        String condition;
+       int userId = 0;
        ArrayList* pArgs = null;
 
-       result r =      _ConditionRegistryHelper::GetAllParamsN(map, appId, condition, pArgs);
-       SysTryReturn(NID_APP, !IsFailed(r), r, r, "[%s] app(%ls), condition(%ls) is failed to register.", GetErrorMessage(r), appId.GetPointer(), condition.GetPointer() );
+       result r = _ConditionDatabaseHelper::GetConditionEntryFromDbN(sectionName, appId, userId, condition, pArgs);
+       SysTryReturnResult(NID_APP, !IsFailed(r), r, "Not able to fetch the condition data.");
 
        r = RegisterAppLaunch( appId, condition, pArgs, AppManager::LAUNCH_OPTION_DEFAULT, &sectionName);
        SysTryLog(NID_APP, !IsFailed(r), "[%s] app(%ls), condition(%ls) is failed to register.", GetErrorMessage(r), appId.GetPointer(), condition.GetPointer() );
 
+       if(r == E_INVALID_CONDITION)
+       {
+               r = _ConditionDatabaseHelper::RemoveRecordFromConditionDb(sectionName);
+               SysTryReturnResult(NID_APP, !IsFailed(r), r, "Removing the table entry for the invalid conditions.");
+       }
+
        if (pArgs != null)
        {
                pArgs->RemoveAll(true);
                delete pArgs;
        }
        return r;
-
-//CATCH:
-//     // remove invalid conditions.
-//     _ConditionRegistryHelper::RemoveFromRegistry(sectionName);
-//     return r;
 }
 
 _ConditionHandler*
 _ConditionManagerService::GetHandlerByCondition(const String& condition)
 {
        Tizen::Base::Utility::StringTokenizer strTok(condition, L"=");
-       SysTryReturn(NID_APP, strTok.GetTokenCount() > 0, null, E_INVALID_ARG, "Condition string is invalid.(%ls)", condition.GetPointer() );
+       SysTryReturn(NID_APP, strTok.GetTokenCount() > 0, null, E_INVALID_ARG, "Condition string is invalid.(%ls)",
+                       condition.GetPointer());
 
        String key;
        result r = strTok.GetNextToken(key);
-       SysTryReturn(NID_APP, !IsFailed(r), null, E_INVALID_ARG, "[%s](%ls)", GetErrorMessage(r), condition.GetPointer() );
+       SysTryReturn(NID_APP, !IsFailed(r), null, E_INVALID_ARG, "[%s](%ls)", GetErrorMessage(r), condition.GetPointer());
+
+       String fileName;
+       r = __handlerLookupTable.GetValue(key, fileName);
+       SysTryReturn(NID_APP, !IsFailed(r), null, E_INVALID_ARG, "[%s](%ls)", GetErrorMessage(r), key.GetPointer());
+
+       bool isHandlerFound = false;
+       r = __handlers.ContainsKey(fileName, isHandlerFound);
+       if(!isHandlerFound)
+       {
+               r = LoadConditionPlugin(fileName);
+               SysTryReturn(NID_APP, !IsFailed(r), null, E_INVALID_ARG, "LoadConditionPlugin failed [%s](%ls)",
+                        GetErrorMessage(r), fileName.GetPointer());
+       }
 
        _ConditionHandler* pHandler = null;
-       r = __handlerLookupTable.GetValue(key, pHandler);
-       SysTryReturn(NID_APP, !IsFailed(r), null, E_INVALID_ARG, "[%s](%ls)", GetErrorMessage(r), key.GetPointer() );
+       r = __handlers.GetValue(fileName, pHandler);
+       SysTryReturn(NID_APP, !IsFailed(r), null, E_INVALID_ARG, "[%s](%ls)", GetErrorMessage(r), fileName.GetPointer());
 
        return pHandler;
 }
@@ -337,7 +357,7 @@ _ConditionManagerService::RegisterAppLaunch(const Tizen::App::AppId& appId, cons
        SysTryReturnResult(NID_APP, condition.IsEmpty()==false, E_INVALID_ARG, "The launch condition is empty or too long (Maximum %d bytes).", MAX_LEN_CONDITION);
        SysTryReturnResult(NID_APP, condition.GetLength() < MAX_LEN_CONDITION, E_INVALID_ARG, "The launch condition is empty or too long (Maximum %d bytes).", MAX_LEN_CONDITION);
        //SysTryReturnResult(NID_APP, _PackageManagerImpl::GetInstance()->IsPackageInstalled(packageId) == true, E_APP_NOT_INSTALLED, "The application(%ls) is not installed.", appId.GetPointer()); // Moved to client side due to negative test.
-       SysTryReturn(NID_APP, pArguments == null || (r = ValidateArguments(pArguments)) == E_SUCCESS, r, r, "[%s]", GetErrorMessage(r));
+       SysTryReturnResult(NID_APP, pArguments == null || (r = ValidateArguments(pArguments)) == E_SUCCESS, r, "The launch arguments are not valid.");
 
        SysTryReturnResult(NID_APP,appId.GetLength() < WIDGET_APP_MAX_APPID_LENGTH, E_INVALID_ARG, "The appId is too long (Maximum %d bytes).", WIDGET_APP_MAX_APPID_LENGTH);
 
@@ -396,7 +416,7 @@ _ConditionManagerService::UnregisterAppLaunch(const Tizen::App::AppId& appId, co
        else
        {
                _ConditionHandler* pHandler = GetHandlerByCondition(*pCondition);
-               SysTryReturnResult(NID_APP, pHandler != null, E_OBJ_NOT_FOUND, "");
+               SysTryReturnResult(NID_APP, pHandler != null, E_OBJ_NOT_FOUND, "failed to GetHandlerByCondition");
 
                String curAppName;
                appId.SubString(10, curAppName);
@@ -412,16 +432,18 @@ result
 _ConditionManagerService::UnregisterAppLaunch(const Tizen::App::AppId& appId)
 {
        result r = E_SUCCESS;
-       _ConditionHandler* pHandler = null;
-       for (int i =0; i < __handlers.GetCount(); i ++)
+
+       std::unique_ptr< IMapEnumeratorT<String, _ConditionHandler*> > pMapEnum(__handlers.GetMapEnumeratorN());
+       SysTryReturnResult(NID_APP, pMapEnum != null, r = GetLastResult(), "failed to GetMapEnumeratorN.");
+
+       while(pMapEnum->MoveNext() == E_SUCCESS)
        {
-               pHandler = null;
-               r = __handlers.GetAt(i, pHandler);
-               SysTryReturn(NID_APP, pHandler != null, r, r, "[%s]", GetErrorMessage(r) );
+               _ConditionHandler* pHandler = null;
+               r = pMapEnum->GetValue(pHandler);
+               SysTryReturnResult(NID_APP, pHandler != null, r, "failed to get handler.");
 
                String appName;
                appId.SubString(10, appName);
-
                pHandler->RemoveCondition(_PackageManagerImpl::GetPackageIdByAppId(appId), appName, null);
        }
 
@@ -432,12 +454,15 @@ result
 _ConditionManagerService::UnregisterAppLaunchByPackageId(const Tizen::App::PackageId& packageId)
 {
        result r = E_SUCCESS;
-       _ConditionHandler* pHandler = null;
-       for (int i =0; i < __handlers.GetCount(); i ++)
+
+       std::unique_ptr< IMapEnumeratorT<String, _ConditionHandler*> > pMapEnum(__handlers.GetMapEnumeratorN());
+       SysTryReturnResult(NID_APP, pMapEnum != null, r = GetLastResult(), "failed to GetMapEnumeratorN.");
+
+       while(pMapEnum->MoveNext() == E_SUCCESS)
        {
-               pHandler = null;
-               r = __handlers.GetAt(i, pHandler);
-               SysTryReturn(NID_APP, pHandler != null, r, r, "[%s]", GetErrorMessage(r) );
+               _ConditionHandler* pHandler = null;
+               r = pMapEnum->GetValue(pHandler);
+               SysTryReturnResult(NID_APP, pHandler != null, r, "failed to get the handler.");
 
                pHandler->RemoveCondition(packageId, L"", null);
        }
@@ -455,13 +480,17 @@ _ConditionManagerService::IsAppLaunchRegistered(const Tizen::App::AppId& appId,
        if (pCondition == null)
        {
                result r = E_SUCCESS;
-               _ConditionHandler* pHandler = null;
-               for (int i =0; i < __handlers.GetCount(); i ++)
+
+               std::unique_ptr< IMapEnumeratorT<String, _ConditionHandler*> > pMapEnum(__handlers.GetMapEnumeratorN());
+               SysTryReturn(NID_APP, pMapEnum != null, r, r, "failed to GetMapEnumeratorN. (%s)", GetLastResult());
+
+               while(pMapEnum->MoveNext() == E_SUCCESS)
                {
-                       pHandler = null;
-                       r = __handlers.GetAt(i, pHandler);
-                       SysTryReturn(NID_APP, pHandler != null, r, r, "[%s]", GetErrorMessage(r) );
-                       if ( pHandler->HasCondition(appId, null) == true)
+                       _ConditionHandler* pHandler = null;
+                       r = pMapEnum->GetValue(pHandler);
+                       SysTryReturn(NID_APP, pHandler != null, r, r, "[%s]", GetErrorMessage(r));
+
+                       if (pHandler->HasCondition(appId, null) == true)
                        {
                                return true;
                        }
@@ -478,119 +507,263 @@ _ConditionManagerService::IsAppLaunchRegistered(const Tizen::App::AppId& appId,
        return false;
 }
 
-
-///////////////////////////////////////////
-// internal helper
-///////////////////////////////////////////
-//TODO: save arguments
 result
-_ConditionRegistryHelper::AddToRegistry(const String& sectionName, const Tizen::App::AppId& appId, /*const String& executableName,*/ const String& condition, const IList *pArg)
+_ConditionDatabaseHelper::InsertRecordToConditionDb(const String& sectionName, const AppId& appId, const int& userId,
+               const String& condition, const IList* pArgs)
 {
-       _RegistryImpl reg;
+       _DatabaseImpl condDb;
+       void* pBundleBuf = null;
+       int length = 0;
+       String statement;
+
+       const String& homePath = App::GetInstance()->GetAppDataPath();
+       result r = condDb.Construct(homePath + DATABASE_COND_OPERATIONS, DB_OPEN_READ_WRITE);
+       SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to create/open database '%ls'",
+                                       (homePath + DATABASE_COND_OPERATIONS).GetPointer());
+
+       r = condDb.BeginTransaction();
+       SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to begin database transaction.");
 
-       result r = reg.Construct(App::GetInstance()->GetAppRootPath() + REGISTRY_FILE_OPERATIONS, REG_OPEN_READ_WRITE | REG_OPEN_CREATE, null);
-       SysTryReturn(NID_APP, !IsFailed(r), r, r, "%s", GetErrorMessage(r) );
+       statement.Append(L"INSERT INTO CondTbl (SectionName, AppId, UserId, Condition, LaunchType, ArgCount, ArgLength, Arguments) "
+                                          "VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
 
-       r = reg.AddSection(sectionName);
-       SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] sectionName : %ls", GetErrorMessage(r), sectionName.GetPointer() );
+       std::unique_ptr<DbStatement> pStmt(condDb.CreateStatementN(statement));
+       SysTryReturnResult(NID_APP, pStmt != null, E_FAILURE, "failed to create sql statement.");
 
-       r = reg.AddValue(sectionName, REG_KEY_APPID, appId);
-       r = reg.AddValue(sectionName, REG_KEY_CONDTION, condition);
-       r = reg.AddValue(sectionName, REG_KEY_LAUNCH_TYPE, L"");
+       r = pStmt->BindString(DB_TABLE_COND_SECTION_NAME, sectionName);
+       SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to bind sectionName to database.");
 
-       if (pArg != null)
+       r = pStmt->BindString(DB_TABLE_COND_APPID, appId);
+       SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to bind appId to database.");
+
+       r = pStmt->BindInt(DB_TABLE_COND_USERID, userId);
+       SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to bind userId to database.");
+
+       r = pStmt->BindString(DB_TABLE_COND_CONDITION, condition);
+       SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to bind condition to database.");
+
+       r = pStmt->BindString(DB_TABLE_COND_LAUNCHTYPE, L"");
+       SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to bind launchtype to database.");
+
+       //Add the Arg data to bundle and then store in db
+       if (pArgs == null)
        {
-               String value = Integer::ToString(pArg->GetCount());
-               r = reg.AddValue(sectionName, REG_KEY_ARG_COUNT, value );
+               r = pStmt->BindInt(DB_TABLE_COND_ARG_COUNT, 0);
+               SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to bind argcount to database.");
+       }
+       else
+       {
+               r = ConvertArgToBundleN(sectionName, pArgs, pBundleBuf, length);
+               SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to ConvertArgToBundleN.");
 
-               const String* pCurArg = null;
-               String key;
-               for( int i = 0; i< pArg->GetCount(); i ++)
-               {
-                       pCurArg = dynamic_cast<const String*>(pArg->GetAt(i));
-                       if (pCurArg != null)
-                       {
-                               key = REG_KEY_ARG + Integer::ToString(i);
-                               r = reg.AddValue(sectionName, key, *pCurArg);
-                       }
-               }
+               r = pStmt->BindInt(DB_TABLE_COND_ARG_COUNT, pArgs->GetCount());
+               SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to bind argcount to database.");
+
+               r = pStmt->BindInt(DB_TABLE_COND_ARG_LENGTH, length);
+               SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to bind length to database.");
+
+               r = pStmt->BindBlob(DB_TABLE_COND_ARG, pBundleBuf, length);
+               SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to bind pBundleBuf to database.");
        }
 
-       r = reg.Flush();
-       SysTryCatch(NID_APP, !IsFailed(r), , r, "%s", GetErrorMessage(r) );
+       std::unique_ptr<DbEnumerator> pEnum(condDb.ExecuteStatementN(*pStmt));
+       SysTryReturnResult(NID_APP, pEnum == null, r, "pEnum should be null as INSERT operation took place.");
 
-       SysLog(NID_APP, "ConditionInfo is added to registry. [%ls] app(%ls), condition=%ls, lunchType=none", sectionName.GetPointer(), appId.GetPointer(), condition.GetPointer() );
+       r = condDb.CommitTransaction();
+       SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to commit database transaction.");
 
+       bundle_free_encoded_rawdata((bundle_raw**)&pBundleBuf);
        return E_SUCCESS;
-
-CATCH:
-       return r;
 }
 
 result
-_ConditionRegistryHelper::RemoveFromRegistry(const String &section)
+_ConditionDatabaseHelper::RemoveRecordFromConditionDb(const String& sectionName)
 {
-       _RegistryImpl reg;
-       result r = reg.Construct(App::GetInstance()->GetAppRootPath() + REGISTRY_FILE_OPERATIONS, REG_OPEN_READ_WRITE, null);
-       SysTryReturn(NID_APP, !IsFailed(r), r, r, "%s", GetErrorMessage(r) );
+       _DatabaseImpl condDb;
+       String statement;
+
+       const String& homePath = App::GetInstance()->GetAppDataPath();
+       result r = condDb.Construct(homePath + DATABASE_COND_OPERATIONS, DB_OPEN_READ_WRITE);
+       SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to create/open database '%ls'",
+                                       (homePath + DATABASE_COND_OPERATIONS).GetPointer());
+
+       r = condDb.BeginTransaction();
+       SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to begin database transaction.");
+
+       statement.Append(L"DELETE FROM CondTbl WHERE SectionName = ?");
+       std::unique_ptr<DbStatement> pStmt(condDb.CreateStatementN(statement));
+       SysTryReturnResult(NID_APP, pStmt != null, E_FAILURE, "failed to create sql statement.");
+
+       r = pStmt->BindString(DB_TABLE_COND_SECTION_NAME, sectionName);
+       SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to bind sectionName to database.");
 
-       r = reg.RemoveSection(section);
-       SysTryCatch(NID_APP, !IsFailed(r), , r, "%s", GetErrorMessage(r) );
+       std::unique_ptr<DbEnumerator> pEnum(condDb.ExecuteStatementN(*pStmt));
+       SysTryReturnResult(NID_APP, pEnum == null, r, "pEnum should be null as DELETE operation took place.");
 
-       r = reg.Flush();
-       SysTryCatch(NID_APP, !IsFailed(r), , r, "%s", GetErrorMessage(r) );
+       r = condDb.CommitTransaction();
+       SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to commit database transaction.");
 
-       SysLog(NID_APP, "Removed. [%ls]", section.GetPointer() );
        return E_SUCCESS;
+}
 
-CATCH:
-       return r;
+result
+_ConditionDatabaseHelper::GetAllSectionsFromConditionDb(ArrayList* pSections)
+{
+       _DatabaseImpl condDb;
+       String sectionName;
+       String sql;
+
+       const String& homePath = App::GetInstance()->GetAppDataPath();
+       result r = condDb.Construct(homePath + DATABASE_COND_OPERATIONS, DB_OPEN_READ_ONLY);
+       SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to create/open database '%ls'",
+                                       (homePath + DATABASE_COND_OPERATIONS).GetPointer());
+
+       sql.Append(L"SELECT SectionName FROM CondTbl");
+       std::unique_ptr<DbEnumerator> pEnum(condDb.QueryN(sql));
+       SysTryReturnResult(NID_APP, pEnum != null, E_FAILURE, "failed to query sql statement.");
+
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               r = pEnum->GetStringAt(DB_TABLE_COND_SECTION_NAME, sectionName);
+               SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to get sectionName from database.");
+
+               r = pSections->Add(*new String(sectionName));
+               SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to add sectionName to Array.");
+       }
+
+       return E_SUCCESS;
 }
 
 result
-_ConditionRegistryHelper::GetAllParamsN(const IMap& map, AppId& appId, String& condition, ArrayList*& pArgs)
+_ConditionDatabaseHelper::GetConditionEntryFromDbN(const String& sectionName, AppId& appId, int& userId,
+               String& condition, ArrayList*& pArgs)
 {
-       const String*   pAppId = static_cast<const String*>(map.GetValue(REG_KEY_APPID));
-       const String*   pCondition = static_cast<const String*>(map.GetValue(REG_KEY_CONDTION));
-       //      const String*   pLaunchMode = static_cast<const String*>(map.GetValue(REG_KEY_LAUNCH_TYPE));
-       SysTryReturn(NID_APP, pAppId != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "registry value is invalid. pAppId is null");
-       SysTryReturn(NID_APP, pCondition != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "registry value is invalid. pCondition is null");
-
-       const String*   pArgCount = static_cast<const String*>(map.GetValue(REG_KEY_ARG_COUNT));
-       if (pArgCount != null)
+       _DatabaseImpl condDb;
+       String launchType;
+       String statement;
+       int argCount = 0;
+
+       const String& homePath = App::GetInstance()->GetAppDataPath();
+       result r = condDb.Construct(homePath + DATABASE_COND_OPERATIONS, DB_OPEN_READ_ONLY);
+       SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to create/open database '%ls'",
+                                       (homePath + DATABASE_COND_OPERATIONS).GetPointer());
+
+       statement.Append(L"SELECT * FROM CondTbl WHERE SectionName = ?");
+       std::unique_ptr<DbStatement> pStmt(condDb.CreateStatementN(statement));
+       SysTryReturnResult(NID_APP, pStmt != null, E_FAILURE, "failed to create sql statement.");
+
+       r = pStmt->BindString(DB_TABLE_COND_SECTION_NAME, sectionName);
+       SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to bind sectionName to database.");
+
+       std::unique_ptr<DbEnumerator> pEnum(condDb.ExecuteStatementN(*pStmt));
+       SysTryReturnResult(NID_APP, pEnum != null, E_FAILURE, "failed to execute sql statement.");
+
+       while (pEnum->MoveNext() == E_SUCCESS)
        {
-               int argCount;
-               Integer::Parse(*pArgCount, argCount);
+               r = pEnum->GetStringAt(DB_TABLE_COND_APPID, appId);
+               SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to get appId from database.");
+
+               r = pEnum->GetIntAt(DB_TABLE_COND_USERID, userId);
+               SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to get userId from database.");
+
+               r = pEnum->GetStringAt(DB_TABLE_COND_CONDITION, condition);
+               SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to get condition from database.");
+
+               r = pEnum->GetStringAt(DB_TABLE_COND_LAUNCHTYPE, launchType);
+               SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to get launchType from database.");
+
+               //Get the bundle data from db and convert to arg format
+               r = pEnum->GetIntAt(DB_TABLE_COND_ARG_COUNT, argCount);
+               SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to get argCount from database.");
+
                if (argCount > 0)
                {
-                       String key;
-                       const String*   pValue = null;
-                       pArgs = new ArrayList();
-                       pArgs->Construct();
-                       for (int i = 0; i< argCount; i++)
-                       {
-                               key = REG_KEY_ARG + Integer::ToString(i);
-                               pValue = dynamic_cast<const String*>(map.GetValue(key));
-                               SysTryCatch(NID_APP,  pValue != null, , GetLastResult(), "failed to get '%ls'.", key.GetPointer() );
-                               pArgs->Add(*new String(*pValue));
-                       }
+                       int length = 0;
+                       r = pEnum->GetIntAt(DB_TABLE_COND_ARG_LENGTH, length);
+                       SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to get length from database.");
+
+                       void* pBundleBuf = new (std::nothrow) bundle_raw[length];
+                       SysTryReturnResult(NID_APP, pBundleBuf != null, E_OUT_OF_MEMORY, "Memory allocation failure for bundle data.");
+
+                       r = pEnum->GetBlobAt(DB_TABLE_COND_ARG, pBundleBuf, length);
+                       SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to get pBundleBuf from database.");
+
+                       r = ConvertBundleToArgN(sectionName, pBundleBuf, argCount, length, pArgs);
+                       SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to ConvertBundleToArgN.");
                }
        }
 
-       appId = *pAppId;
-       condition = *pCondition;
+       return E_SUCCESS;
+}
+
+result
+_ConditionDatabaseHelper::ConvertArgToBundleN(const String& key, const IList* pArgs, void*& pBundleBuf, int& length)
+{
+       SysTryReturnResult(NID_APP, pArgs != null, E_OBJ_NOT_FOUND, "Argument list not available.");
+
+       bundle_raw* pBundleRaw = null;
+       String keyStr;
+       int bunRet = 0;
+       int index = 0;
+
+       bundle* pBundle = bundle_create();
+       SysTryReturnResult(NID_APP, pBundle != null, E_FAILURE, "Creating bundle failed.");
+
+       std::unique_ptr<IEnumerator> pEnum(pArgs->GetEnumeratorN());
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               keyStr.Clear();
+               String* pStr = static_cast<String*>(pEnum->GetCurrent());
+               pStr->Trim();
+
+               keyStr.Format(MAX_LEN_ARG, L"%ls_%d", key.GetPointer(), index++);
+               char* pKey =  _StringConverter::CopyToCharArrayN(keyStr);
+               char* pValue = _StringConverter::CopyToCharArrayN(*pStr);
+
+               bunRet = bundle_add(pBundle, pKey, pValue);
+               delete pKey;
+               delete pValue;
+       }
+
+       bunRet = bundle_encode_raw(pBundle, &pBundleRaw, &length);
+       pBundleBuf = static_cast<void*>(pBundleRaw);
+       bundle_free(pBundle);
 
        return E_SUCCESS;
+}
 
-CATCH:
-       if (pArgs != null)
+result
+_ConditionDatabaseHelper::ConvertBundleToArgN(const String& key, void*& pBundleBuf, const int& argCount,
+               const int& length, ArrayList*& pArgs)
+{
+       SysTryReturnResult(NID_APP, pBundleBuf != null, E_OBJ_NOT_FOUND, "Invalid bundle memory passed.");
+
+       String keyStr;
+       bundle_raw* pBundleRaw = static_cast<bundle_raw*>(pBundleBuf);
+       bundle* pBundle = bundle_decode_raw(pBundleRaw, length);
+       SysTryReturnResult(NID_APP, pBundle != null, E_FAILURE, "Getting bundle instance failed.");
+
+       pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
+       SysTryReturnResult(NID_APP, pArgs != null, E_OUT_OF_MEMORY, "Allocating array failed.");
+
+       pArgs->Construct();
+       for (int loopCount = 0; loopCount < argCount; loopCount++)
        {
-               pArgs->RemoveAll(true);
+               keyStr.Clear();
+               keyStr.Format(MAX_LEN_ARG, L"%ls_%d", key.GetPointer(), loopCount);
+
+               char* pKey =  _StringConverter::CopyToCharArrayN(keyStr);
+               const char* pValue = bundle_get_val(pBundle, pKey);
+               if (pValue)
+               {
+                       pArgs->Add(*(new (std::nothrow) String(pValue)));
+               }
+               delete pKey;
        }
-       delete pArgs;
-       pArgs = null;
 
-       return E_FAILURE;
+       free(pBundleBuf);
+       bundle_free(pBundle);
+       return E_SUCCESS;
 }
 
 void