-_PackageManagerImpl::RegisterAppInfoList(int id, ArrayList* pList)
-{
- SysTryReturnResult(NID_APP, __pDb != null, E_SYSTEM, "__pDb is null");
-
- result r = E_SUCCESS;
- String query;
- DbStatement* pStmt = null;
-
- if (pList != null)
- {
- for (int i = 0; i < pList->GetCount(); i++)
- {
- _PackageAppInfoImpl* pAppInfoImpl = dynamic_cast <_PackageAppInfoImpl*>(pList->GetAt(i));
-
- if (pAppInfoImpl != null)
- {
- DbEnumerator* pEnum = null;
- int uniqueId = 0;
-
- String name = pAppInfoImpl->GetName();
- String defaultapp = pAppInfoImpl->GetDefault();
- String mainmenuIcon = pAppInfoImpl->GetMainmenuIcon();
- String settingIcon = pAppInfoImpl->GetSettingIcon();
- String quickpanelIcon = pAppInfoImpl->GetQuickpanelIcon();
- int appFeature = pAppInfoImpl->GetAppFeature();
- String packageName = pAppInfoImpl->GetPackageName();
- String type = pAppInfoImpl->GetType();
-
- ArrayList* pLaunchConditionImplList = pAppInfoImpl->GetLaunchConditionList();
- ArrayList* pNotificationImplList = pAppInfoImpl->GetNotificationList();
- ArrayList* pAppFeatureImplList = pAppInfoImpl->GetAppFeatureList();
- ArrayList* pDataControlImplList = pAppInfoImpl->GetDataControlList();
-
- query.Format(
- 1024, L"INSERT INTO AppInfo "
- "(ID, APP_NAME, APP_DEFAULT, APP_MAINMENU_ICON, APP_SETTING_ICON, APP_TICKER_ICON, APP_QUICKPANEL_ICON, APP_LAUNCHIMAGE_ICON, APP_FEATURE, PACKAGE_NAME, APP_TYPE) "
- "VALUES (?,?,?,?,?,?,?,?,?,?,?)");
-
- pStmt = CreateStatementN(*__pDb, query);
- //SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
-
- if (id != 0)
- {
- r = pStmt->BindInt(0, id);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!name.IsEmpty())
- {
- r = pStmt->BindString(1, name);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!defaultapp.IsEmpty())
- {
- r = pStmt->BindString(2, defaultapp);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!mainmenuIcon.IsEmpty())
- {
- r = pStmt->BindString(3, mainmenuIcon);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!settingIcon.IsEmpty())
- {
- r = pStmt->BindString(4, settingIcon);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!quickpanelIcon.IsEmpty())
- {
- r = pStmt->BindString(6, quickpanelIcon);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (appFeature != 0)
- {
- r = pStmt->BindInt(8, appFeature);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!packageName.IsEmpty())
- {
- r = pStmt->BindString(9, packageName);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!type.IsEmpty())
- {
- r = pStmt->BindString(10, type);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- pEnum = ExecuteStatementN(*__pDb, pStmt);
-
- query.Clear();
- delete pStmt;
- pStmt = null;
- delete pEnum;
-
- pAppInfoImpl->SetPkgId(id);
- uniqueId = pAppInfoImpl->GetUniqueId();
- RegisterLaunchConditionList(uniqueId, pLaunchConditionImplList);
- RegisterNotificationList(uniqueId, pNotificationImplList);
- RegisterAppFeatureList(uniqueId, pAppFeatureImplList);
- RegisterDataControlList(uniqueId, pDataControlImplList);
- //RegisterAppControlList(uniqueId, pAppControlImplList);
- }
- }
- }
-
- r = GetLastResult();
-
-CATCH:
- delete pStmt;
-
- return r;
-}
-
-result
-_PackageManagerImpl::RegisterLaunchConditionList(int id, ArrayList* pList)
-{
- SysTryReturnResult(NID_APP, __pDb != null, E_SYSTEM, "__pDb is null");
-
- result r = E_SUCCESS;
- String query;
- DbStatement* pStmt = null;
-
- if (pList != null)
- {
- for (int i = 0; i < pList->GetCount(); i++)
- {
- _LaunchConditionInfoImpl* pLaunchCondition = dynamic_cast<_LaunchConditionInfoImpl*>(pList->GetAt(i));
-
- if (pLaunchCondition != null)
- {
- DbEnumerator* pEnum = null;
-
- String name = pLaunchCondition->GetName();
- String value = pLaunchCondition->GetValue();
-
- query.Format(1024, L"INSERT INTO LaunchCondition (ID, NAME, VALUE) VALUES (?,?,?)");
-
- pStmt = CreateStatementN(*__pDb, query);
- //SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
-
- if (id != 0)
- {
- r = pStmt->BindInt(0, id);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!name.IsEmpty())
- {
- r = pStmt->BindString(1, name);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!value.IsEmpty())
- {
- r = pStmt->BindString(2, value);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- pEnum = ExecuteStatementN(*__pDb, pStmt);
-
- query.Clear();
- delete pStmt;
- pStmt = null;
- delete pEnum;
- }
- }
- }
-
- r = GetLastResult();
-
-CATCH:
- delete pStmt;
-
- return r;
-}
-
-result
-_PackageManagerImpl::RegisterNotificationList(int id, ArrayList* pList)
-{
- SysTryReturnResult(NID_APP, __pDb != null, E_SYSTEM, "__pDb is null");
-
- result r = E_SUCCESS;
- String query;
- DbStatement* pStmt = null;
-
- if (pList != null)
- {
- for (int i = 0; i < pList->GetCount(); i++)
- {
- _NotificationInfoImpl* pNotification = dynamic_cast<_NotificationInfoImpl*>(pList->GetAt(i));
-
- if (pNotification != null)
- {
- DbEnumerator* pEnum = null;
-
- String name = pNotification->GetName();
- String value = pNotification->GetValue();
-
- query.Format(1024, L"INSERT INTO Notification (ID, NAME, VALUE) VALUES (?,?,?)");
-
- pStmt = CreateStatementN(*__pDb, query);
- //SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
-
- if (id != 0)
- {
- r = pStmt->BindInt(0, id);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!name.IsEmpty())
- {
- r = pStmt->BindString(1, name);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!value.IsEmpty())
- {
- r = pStmt->BindString(2, value);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- pEnum = ExecuteStatementN(*__pDb, pStmt);
-
- query.Clear();
- delete pStmt;
- pStmt = null;
- delete pEnum;
- }
- }
- }
-
- r = GetLastResult();
-
-CATCH:
- delete pStmt;
-
- return r;
-}
-
-result
-_PackageManagerImpl::RegisterAppFeatureList(int id, ArrayList* pList)
-{
- SysTryReturnResult(NID_APP, __pDb != null, E_SYSTEM, "__pDb is null");
-
- result r = E_SUCCESS;
- String query;
- DbStatement* pStmt = null;
-
- if (pList != null)
- {
- for (int i = 0; i < pList->GetCount(); i++)
- {
- _AppFeatureInfoImpl* pAppFeature = dynamic_cast<_AppFeatureInfoImpl*>(pList->GetAt(i));
-
- if (pAppFeature != null)
- {
- DbEnumerator* pEnum = null;
-
- String name = pAppFeature->GetName();
- String value = pAppFeature->GetValue();
-
- query.Format(1024, L"INSERT INTO AppFeature (ID, NAME, VALUE) VALUES (?,?,?)");
-
- pStmt = CreateStatementN(*__pDb, query);
- //SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
-
- if (id != 0)
- {
- r = pStmt->BindInt(0, id);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!name.IsEmpty())
- {
- r = pStmt->BindString(1, name);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!value.IsEmpty())
- {
- r = pStmt->BindString(2, value);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- pEnum = ExecuteStatementN(*__pDb, pStmt);
-
- query.Clear();
- delete pStmt;
- pStmt = null;
- delete pEnum;
- }
- }
- }
-
- r = GetLastResult();
-
-CATCH:
- delete pStmt;
-
- return r;
-}
-
-result
-_PackageManagerImpl::RegisterDataControlList(int id, ArrayList* pList)
-{
- SysTryReturnResult(NID_APP, __pDb != null, E_SYSTEM, "__pDb is null");
-
- result r = E_SUCCESS;
- String query;
- DbStatement* pStmt = null;
-
- if (pList != null)
- {
- for (int i = 0; i < pList->GetCount(); i++)
- {
- _DataControlInfoImpl* pDataControl = dynamic_cast<_DataControlInfoImpl*>(pList->GetAt(i));
-
- if (pDataControl != null)
- {
- DbEnumerator* pEnum = null;
-
- String providerId = pDataControl->GetProviderId();
- ArrayList* pTypeList = pDataControl->GetControlTypeList();
-
- if (pTypeList != null)
- {
- for (int j = 0; j < pTypeList->GetCount(); j++)
- {
- _DataControlTypeImpl* pControlType = dynamic_cast<_DataControlTypeImpl*>(pTypeList->GetAt(j));
-
- if (pControlType != null)
- {
- String access = pControlType->GetAccess();
- String type = pControlType->GetType();
-
- query.Format(1024, L"INSERT INTO DataControl (ID, PROVIDER_ID, TYPE, ACCESS) VALUES (?,?,?,?)");
-
- pStmt = CreateStatementN(*__pDb, query);
- //SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
-
- if (id != 0)
- {
- r = pStmt->BindInt(0, id);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!providerId.IsEmpty())
- {
- r = pStmt->BindString(1, providerId);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!type.IsEmpty())
- {
- r = pStmt->BindString(2, type);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!access.IsEmpty())
- {
- r = pStmt->BindString(3, access);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- pEnum = ExecuteStatementN(*__pDb, pStmt);
-
- query.Clear();
- delete pStmt;
- pStmt = null;
- delete pEnum;
- }
- }
- }
- }
- }
- }
-
- r = GetLastResult();
-
-CATCH:
- delete pStmt;
-
- return r;
-}
-
-int
-_PackageManagerImpl::FindRecord(const String& tableName, const String& columnName, const String& value) const
-{
-
- result r = E_SUCCESS;
- Database db;
- String query;
- DbStatement* pStmt = null;
- DbEnumerator* pEnum = null;
- int uniqueId = 0;
-
- r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
- //SysTryCatch(NID_APP, r == E_SUCCESS, r, r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
-
- query.Format(1024, L"SELECT * FROM %ls WHERE %ls = '%ls'", tableName.GetPointer(), columnName.GetPointer(), value.GetPointer());
-
- pStmt = CreateStatementN(db, query);
- //SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
-
- pEnum = ExecuteStatementN(db, pStmt);
-
- if (pEnum != null)
- {
- if (pEnum->MoveNext() == E_SUCCESS)
- {
- pEnum->GetIntAt(0, uniqueId);
- }
-
- delete pEnum;
- }
-
-//CATCH:
- delete pStmt;
-
- return uniqueId;
-}
-
-result
-_PackageManagerImpl::GetRecord(const String& tableName, int uniqueId, const String& columnName, String& value) const
-{
- result r = E_SUCCESS;
- Database db;
- String query;
- DbStatement* pStmt = null;
- DbEnumerator* pEnum = null;
-
- r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
- //SysTryCatch(NID_APP, r == E_SUCCESS, r, r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
-
- query.Format(1024, L"SELECT %ls FROM %ls WHERE UNIQUE_ID = %d", columnName.GetPointer(), tableName.GetPointer(), uniqueId);
-
- pStmt = CreateStatementN(db, query);
- //SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
-
- pEnum = ExecuteStatementN(db, pStmt);
-
- if (pEnum != null)
- {
- if (pEnum->MoveNext() == E_SUCCESS)
- {
- pEnum->GetStringAt(0, value);
- }
-
- delete pEnum;
- }
-
-//CATCH:
- delete pStmt;
-
- return r;
-}
-
-result
-_PackageManagerImpl::RegisterPrivileges(int id, const String& privileges, const String& hmacPrivileges, int certType)
-{
- SysTryReturnResult(NID_APP, __pDb != null, E_SYSTEM, "__pDb is null");
-
- result r = E_SUCCESS;
- String query;
- DbStatement* pStmt = null;
- DbEnumerator* pEnum = null;
-
- query.Format(1024, L"INSERT INTO PkgPrivileges (ID, PRIVILEGES, HMAC_PPRIVILEGES, CERTIFICATE_TYPE) VALUES (?,?,?,?)");
-
- pStmt = CreateStatementN(*__pDb, query);
- SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
-
- if (id != 0)
- {
- r = pStmt->BindInt(0, id);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!privileges.IsEmpty())
- {
- r = pStmt->BindString(1, privileges);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (!hmacPrivileges.IsEmpty())
- {
- r = pStmt->BindString(2, hmacPrivileges);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- if (certType != 0)
- {
- r = pStmt->BindInt(3, certType);
- SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while constructing a database.", GetErrorMessage(r));
- }
-
- pEnum = ExecuteStatementN(*__pDb, pStmt);
-
- delete pStmt;
- pStmt = null;
- delete pEnum;
- pEnum = null;
-
- r = GetLastResult();
-
-CATCH:
- delete pStmt;
- return r;
-}
-
-result