X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=modules%2Fwidget_dao%2Fdao%2Fwidget_dao.cpp;h=ed66aa2fcd82cd198ad9f98093a74e6ed65b13b3;hb=a482f4e94f217af946b8d98a21c0b9a74158cc7b;hp=f22671ea0c35f95f0370a41828dfd6410bd490d7;hpb=d600b6064eea7263e1dc175b65bb57b1cf28f527;p=framework%2Fweb%2Fwrt-commons.git diff --git a/modules/widget_dao/dao/widget_dao.cpp b/modules/widget_dao/dao/widget_dao.cpp index f22671e..ed66aa2 100644 --- a/modules/widget_dao/dao/widget_dao.cpp +++ b/modules/widget_dao/dao/widget_dao.cpp @@ -37,7 +37,6 @@ #include namespace WrtDB { - //TODO in current solution in each getter there exists a check //"IsWidgetInstalled". Maybe it should be verified, if it could be done //differently (check in WidgetDAO constructor) @@ -53,48 +52,18 @@ namespace WrtDB { WidgetDAO::WidgetDAO(DPL::OptionalString widgetGUID) : WidgetDAOReadOnly(WidgetDAOReadOnly::getHandle(widgetGUID)) -{ -} +{} WidgetDAO::WidgetDAO(DPL::String tzAppId) : WidgetDAOReadOnly(WidgetDAOReadOnly::getHandle(tzAppId)) -{ -} +{} WidgetDAO::WidgetDAO(DbWidgetHandle handle) : WidgetDAOReadOnly(handle) -{ -} +{} WidgetDAO::~WidgetDAO() -{ -} - -void WidgetDAO::removeProperty( - const PropertyDAOReadOnly::WidgetPropertyKey &key) -{ - Try { - PropertyDAO::RemoveProperty(m_widgetHandle, key); - } - Catch(PropertyDAOReadOnly::Exception::ReadOnlyProperty){ - ReThrowMsg(WidgetDAO::Exception::DatabaseError, - "Failure during removing property"); - } -} - -void WidgetDAO::setProperty( - const PropertyDAOReadOnly::WidgetPropertyKey &key, - const PropertyDAOReadOnly::WidgetPropertyValue &value, - bool readOnly) -{ - Try { - PropertyDAO::SetProperty(m_widgetHandle, key, value, readOnly); - } - Catch(PropertyDAOReadOnly::Exception::ReadOnlyProperty){ - ReThrowMsg(WidgetDAO::Exception::DatabaseError, - "Failure during setting/updating property"); - } -} +{} void WidgetDAO::setTizenAppId(const DPL::OptionalString& tzAppId) { @@ -105,7 +74,7 @@ void WidgetDAO::setTizenAppId(const DPL::OptionalString& tzAppId) if (!isWidgetInstalled(getHandle())) { ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist, - "Cannot find widget. Handle: " << getHandle()); + "Cannot find widget. Handle: " << getHandle()); } wrt::WidgetInfo::Row row; @@ -132,7 +101,7 @@ void WidgetDAO::setSecurityPopupUsage(const SettingsType value) ScopedTransaction transaction(&WrtDatabase::interface()); if (!isWidgetInstalled(getHandle())) { ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist, - "Cannot find widget. Handle: " << getHandle()); + "Cannot find widget. Handle: " << getHandle()); } WidgetSecuritySettings::Row row; @@ -158,7 +127,7 @@ void WidgetDAO::setGeolocationUsage(const SettingsType value) ScopedTransaction transaction(&WrtDatabase::interface()); if (!isWidgetInstalled(getHandle())) { ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist, - "Cannot find widget. Handle: " << getHandle()); + "Cannot find widget. Handle: " << getHandle()); } WidgetSecuritySettings::Row row; @@ -184,7 +153,7 @@ void WidgetDAO::setWebNotificationUsage(const SettingsType value) ScopedTransaction transaction(&WrtDatabase::interface()); if (!isWidgetInstalled(getHandle())) { ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist, - "Cannot find widget. Handle: " << getHandle()); + "Cannot find widget. Handle: " << getHandle()); } WidgetSecuritySettings::Row row; @@ -210,7 +179,7 @@ void WidgetDAO::setWebDatabaseUsage(const SettingsType value) ScopedTransaction transaction(&WrtDatabase::interface()); if (!isWidgetInstalled(getHandle())) { ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist, - "Cannot find widget. Handle: " << getHandle()); + "Cannot find widget. Handle: " << getHandle()); } WidgetSecuritySettings::Row row; @@ -226,97 +195,95 @@ void WidgetDAO::setWebDatabaseUsage(const SettingsType value) SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to set web database usage") } -void WidgetDAO::setFileSystemUsage(const SettingsType value) -{ - SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN - { - using namespace DPL::DB::ORM; - using namespace DPL::DB::ORM::wrt; - - ScopedTransaction transaction(&WrtDatabase::interface()); - if (!isWidgetInstalled(getHandle())) { - ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist, - "Cannot find widget. Handle: " << getHandle()); - } - - WidgetSecuritySettings::Row row; - row.Set_file_system_usage(value); - - WRT_DB_UPDATE(update, WidgetSecuritySettings, &WrtDatabase::interface()) - update->Where(Equals(getHandle())); - update->Values(row); - update->Execute(); - - transaction.Commit(); - } - SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to set filesystem usage") -} - -void WidgetDAO::registerWidget( - const TizenAppId & tzAppId, - const WidgetRegisterInfo &widgetRegInfo, - const IWacSecurity &wacSecurity) -{ - LogDebug("Registering widget"); - SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN - { - DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface()); - registerWidgetInternal(tzAppId, widgetRegInfo, wacSecurity); - transaction.Commit(); - } - SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register widget") -} - void WidgetDAO::registerWidget( - WrtDB::DbWidgetHandle handle, - const WidgetRegisterInfo &widgetRegInfo, - const IWacSecurity &wacSecurity) + const TizenAppId & tzAppId, + const WidgetRegisterInfo &widgetRegInfo, + const IWidgetSecurity &widgetSecurity) { LogDebug("Registering widget"); SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN { - DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface()); - registerWidgetInternal(generateTizenId(), widgetRegInfo, wacSecurity, handle); + DPL::DB::ORM::wrt::ScopedTransaction transaction( + &WrtDatabase::interface()); + registerWidgetInternal(tzAppId, widgetRegInfo, widgetSecurity); transaction.Commit(); } SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register widget") } DbWidgetHandle WidgetDAO::registerWidget( - const WidgetRegisterInfo &pWidgetRegisterInfo, - const IWacSecurity &wacSecurity) + const WidgetRegisterInfo &pWidgetRegisterInfo, + const IWidgetSecurity &widgetSecurity) { //make it more precise due to very fast tests struct timeval tv; gettimeofday(&tv, NULL); - srand(time(NULL) + tv.tv_usec); DbWidgetHandle widgetHandle; + unsigned int seed = time(NULL); do { - widgetHandle = rand(); + widgetHandle = rand_r(&seed); } while (isWidgetInstalled(widgetHandle)); - registerWidget(widgetHandle, pWidgetRegisterInfo, wacSecurity); + registerWidget(*pWidgetRegisterInfo.configInfo.tizenAppId, + pWidgetRegisterInfo, + widgetSecurity); return widgetHandle; } TizenAppId WidgetDAO::registerWidgetGeneratePkgId( - const WidgetRegisterInfo &pWidgetRegisterInfo, - const IWacSecurity &wacSecurity) + const WidgetRegisterInfo &pWidgetRegisterInfo, + const IWidgetSecurity &widgetSecurity) { TizenAppId tzAppId = generatePkgId(); - registerWidget(tzAppId, pWidgetRegisterInfo, wacSecurity); + registerWidget(tzAppId, pWidgetRegisterInfo, widgetSecurity); return tzAppId; } +void WidgetDAO::updateTizenAppId( + const TizenAppId & fromAppId, + const TizenAppId & toAppId) +{ + SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN + { + using namespace DPL::DB::ORM; + using namespace DPL::DB::ORM::wrt; + + ScopedTransaction transaction(&WrtDatabase::interface()); + if (!isWidgetInstalled(fromAppId)) { + ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist, + "Cannot find widget. tzAppId: " << fromAppId); + } + + WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface()) + select->Where(Equals(fromAppId)); + + WidgetInfo::Row row = select->GetSingleRow(); + + //WidgetInfo::Row row; + row.Set_tizen_appid(toAppId); + + WRT_DB_UPDATE(update, WidgetInfo, &WrtDatabase::interface()) + update->Where(Equals(fromAppId)); + update->Values(row); + update->Execute(); + + transaction.Commit(); + } + SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to update appid") +} + void WidgetDAO::registerWidgetInternal( - const TizenAppId & tzAppId, - const WidgetRegisterInfo &widgetRegInfo, - const IWacSecurity &wacSecurity, - const DPL::Optional handle) + const TizenAppId & tzAppId, + const WidgetRegisterInfo &widgetRegInfo, + const IWidgetSecurity &widgetSecurity, + const DPL::Optional handle) { //Register into WidgetInfo has to be first //as all other tables depend upon that - DbWidgetHandle widgetHandle = registerWidgetInfo(tzAppId, widgetRegInfo, wacSecurity, handle); + DbWidgetHandle widgetHandle = registerWidgetInfo(tzAppId, + widgetRegInfo, + widgetSecurity, + handle); registerWidgetExtendedInfo(widgetHandle, widgetRegInfo); @@ -326,7 +293,7 @@ void WidgetDAO::registerWidgetInternal( registerWidgetStartFile(widgetHandle, widgetRegInfo); - PropertyDAO::RegisterProperties(widgetHandle, widgetRegInfo); + PropertyDAO::RegisterProperties(widgetHandle, tzAppId, widgetRegInfo); registerWidgetFeatures(widgetHandle, widgetRegInfo); @@ -336,19 +303,21 @@ void WidgetDAO::registerWidgetInternal( registerWidgetWarpInfo(widgetHandle, widgetRegInfo); - registerWidgetCertificates(widgetHandle, wacSecurity); + registerWidgetAllowNavigationInfo(widgetHandle, widgetRegInfo); + + registerWidgetCertificates(widgetHandle, widgetSecurity); CertificateChainList list; - wacSecurity.getCertificateChainList(list, SIGNATURE_DISTRIBUTOR); + widgetSecurity.getCertificateChainList(list, SIGNATURE_DISTRIBUTOR); registerCertificatesChains(widgetHandle, SIGNATURE_DISTRIBUTOR, list); list.clear(); - wacSecurity.getCertificateChainList(list, SIGNATURE_AUTHOR); + widgetSecurity.getCertificateChainList(list, SIGNATURE_AUTHOR); registerCertificatesChains(widgetHandle, SIGNATURE_AUTHOR, list); registerWidgetSettings(widgetHandle, widgetRegInfo); - registerAppService(widgetHandle, widgetRegInfo); + registerAppControl(widgetHandle, widgetRegInfo); registerEncryptedResouceInfo(widgetHandle, widgetRegInfo); @@ -357,23 +326,6 @@ void WidgetDAO::registerWidgetInternal( registerWidgetSecuritySettings(widgetHandle); } -void WidgetDAO::registerOrUpdateWidget( - const TizenAppId & widgetName, - const WidgetRegisterInfo &widgetRegInfo, - const IWacSecurity &wacSecurity) -{ - LogDebug("Reregistering widget"); - SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN - { - DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface()); - - unregisterWidgetInternal(widgetName); - registerWidgetInternal(widgetName, widgetRegInfo, wacSecurity); - transaction.Commit(); - } - SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to reregister widget") -} - #define DO_INSERT(row, table) \ { \ WRT_DB_INSERT(insert, table, &WrtDatabase::interface()) \ @@ -382,18 +334,16 @@ void WidgetDAO::registerOrUpdateWidget( } void WidgetDAO::registerWidgetExtendedInfo(DbWidgetHandle widgetHandle, - const WidgetRegisterInfo ®Info) + const WidgetRegisterInfo ®Info) { //Try and transaction not needed using namespace DPL::DB::ORM; using namespace DPL::DB::ORM::wrt; - WidgetExtendedInfo::Row row; row.Set_app_id(widgetHandle); // row.Set_share_href (DPL::FromUTF8String(regInfo.shareHref)); row.Set_signature_type(regInfo.signatureType); - row.Set_test_widget(regInfo.isTestWidget); row.Set_install_time(regInfo.installedTime); row.Set_splash_img_src(regInfo.configInfo.splashImgSrc); row.Set_background_page(regInfo.configInfo.backgroundPage); @@ -403,10 +353,10 @@ void WidgetDAO::registerWidgetExtendedInfo(DbWidgetHandle widgetHandle, } DbWidgetHandle WidgetDAO::registerWidgetInfo( - const TizenAppId & tzAppId, - const WidgetRegisterInfo ®Info, - const IWacSecurity &wacSecurity, - const DPL::Optional handle) + const TizenAppId & tzAppId, + const WidgetRegisterInfo ®Info, + const IWidgetSecurity &widgetSecurity, + const DPL::Optional handle) { using namespace DPL::DB::ORM; using namespace DPL::DB::ORM::wrt; @@ -416,19 +366,12 @@ DbWidgetHandle WidgetDAO::registerWidgetInfo( // Because of that, "Optional" is not used there WidgetInfo::Row row; - if(!!handle) - { + if (!!handle) { row.Set_app_id(*handle); } - if (regInfo.webAppType == APP_TYPE_UNKNOWN && regInfo.type != - APP_TYPE_UNKNOWN) { - // TODO : regInfo.type is temporary code for security. - // This code will be removed. - row.Set_widget_type(regInfo.type.appType); - } else { - row.Set_widget_type(regInfo.webAppType.appType); - } + row.Set_widget_type(regInfo.webAppType.appType); + row.Set_widget_id(widgetConfigurationInfo.widget_id); row.Set_defaultlocale(widgetConfigurationInfo.defaultlocale); row.Set_widget_version(widgetConfigurationInfo.version); @@ -437,11 +380,12 @@ DbWidgetHandle WidgetDAO::registerWidgetInfo( row.Set_author_name(widgetConfigurationInfo.authorName); row.Set_author_email(widgetConfigurationInfo.authorEmail); row.Set_author_href(widgetConfigurationInfo.authorHref); + row.Set_csp_policy(widgetConfigurationInfo.cspPolicy); + row.Set_csp_policy_report_only(widgetConfigurationInfo.cspPolicyReportOnly); row.Set_base_folder(DPL::FromUTF8String(regInfo.baseFolder)); row.Set_webkit_plugins_required(widgetConfigurationInfo.flashNeeded); - row.Set_recognized(wacSecurity.isRecognized()); - row.Set_wac_signed(wacSecurity.isWacSigned()); - row.Set_distributor_signed(wacSecurity.isDistributorSigned()); + row.Set_recognized(widgetSecurity.isRecognized()); + row.Set_distributor_signed(widgetSecurity.isDistributorSigned()); row.Set_tizen_appid(tzAppId); row.Set_tizen_pkgid(regInfo.tzPkgid); { @@ -452,6 +396,8 @@ DbWidgetHandle WidgetDAO::registerWidgetInfo( row.Set_back_supported(widgetConfigurationInfo.backSupported); row.Set_access_network(widgetConfigurationInfo.accessNetwork); row.Set_pkg_type(regInfo.packagingType.pkgType); + row.Set_security_model_version( + static_cast(widgetConfigurationInfo.securityModelVersion)); Try { @@ -463,21 +409,18 @@ DbWidgetHandle WidgetDAO::registerWidgetInfo( "Failed to register widget info."); } - if(!handle) - { + if (!handle) { //get autoincremented value of widgetHandle WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface()) select->Where(Equals(tzAppId)); return select->GetSingleValue(); - } - else - { + } else { return *handle; } } void WidgetDAO::registerWidgetLocalizedInfo(DbWidgetHandle widgetHandle, - const WidgetRegisterInfo ®Info) + const WidgetRegisterInfo ®Info) { using namespace DPL::DB::ORM; using namespace DPL::DB::ORM::wrt; @@ -504,12 +447,11 @@ void WidgetDAO::registerWidgetLocalizedInfo(DbWidgetHandle widgetHandle, } void WidgetDAO::registerWidgetIcons(DbWidgetHandle widgetHandle, - const WidgetRegisterInfo ®Info) + const WidgetRegisterInfo ®Info) { using namespace DPL::DB::ORM; using namespace DPL::DB::ORM::wrt; - FOREACH(i, regInfo.localizationData.icons) { wrt::WidgetIcon::icon_id::ColumnType icon_id; @@ -522,7 +464,7 @@ void WidgetDAO::registerWidgetIcons(DbWidgetHandle widgetHandle, WRT_DB_INSERT(insert, wrt::WidgetIcon, &WrtDatabase::interface()) insert->Values(row); - icon_id = insert->Execute(); + icon_id = static_cast(insert->Execute()); } FOREACH(j, i->availableLocales) @@ -537,12 +479,11 @@ void WidgetDAO::registerWidgetIcons(DbWidgetHandle widgetHandle, } void WidgetDAO::registerWidgetStartFile(DbWidgetHandle widgetHandle, - const WidgetRegisterInfo ®Info) + const WidgetRegisterInfo ®Info) { using namespace DPL::DB::ORM; using namespace DPL::DB::ORM::wrt; - FOREACH(i, regInfo.localizationData.startFiles) { WidgetStartFile::start_file_id::ColumnType startFileID; @@ -553,7 +494,7 @@ void WidgetDAO::registerWidgetStartFile(DbWidgetHandle widgetHandle, WRT_DB_INSERT(insert, WidgetStartFile, &WrtDatabase::interface()) insert->Values(row); - startFileID = insert->Execute(); + startFileID = static_cast(insert->Execute()); } FOREACH(j, i->propertiesForLocales) @@ -571,38 +512,19 @@ void WidgetDAO::registerWidgetStartFile(DbWidgetHandle widgetHandle, } void WidgetDAO::registerWidgetFeatures(DbWidgetHandle widgetHandle, - const WidgetRegisterInfo ®Info) + const WidgetRegisterInfo ®Info) { using namespace DPL::DB::ORM; const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo; - FOREACH(pWidgetFeature, widgetConfigurationInfo.featuresList) { wrt::WidgetFeature::Row widgetFeature; widgetFeature.Set_app_id(widgetHandle); widgetFeature.Set_name(pWidgetFeature->name); - widgetFeature.Set_required(pWidgetFeature->required); widgetFeature.Set_rejected(false); - wrt::WidgetFeature::widget_feature_id::ColumnType widgetFeatureID; - { - WRT_DB_INSERT(insert, wrt::WidgetFeature, &WrtDatabase::interface()) - insert->Values(widgetFeature); - widgetFeatureID = insert->Execute(); - } - - // Insert into table FeatureParam - wrt::FeatureParam::Row featureParam; - featureParam.Set_widget_feature_id(widgetFeatureID); - - FOREACH(iter, pWidgetFeature->paramsList) - { - featureParam.Set_name(iter->name); - featureParam.Set_value(iter->value); - - DO_INSERT(featureParam, wrt::FeatureParam) - } + DO_INSERT(widgetFeature, wrt::WidgetFeature) } } @@ -610,21 +532,25 @@ void WidgetDAO::registerWidgetPrivilege(DbWidgetHandle widgetHandle, const WidgetRegisterInfo ®Info) { using namespace DPL::DB::ORM; + using namespace DPL::DB::ORM::wrt; const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo; FOREACH(it, widgetConfigurationInfo.privilegeList) { - wrt::WidgetPrivilege::Row widgetPrivilege; + WidgetPrivilege::Row widgetPrivilege; widgetPrivilege.Set_app_id(widgetHandle); widgetPrivilege.Set_name(it->name); - DO_INSERT(widgetPrivilege, wrt::WidgetPrivilege) + DO_INSERT(widgetPrivilege, WidgetPrivilege) } } -void WidgetDAO::updateFeatureRejectStatus(const DbWidgetFeature &widgetFeature){ - // This function could be merged with registerWidgetFeature but it requires desing change: - // 1. Check "ace step" in installer must be done before "update database step" +void WidgetDAO::updateFeatureRejectStatus(const DbWidgetFeature &widgetFeature) +{ + // This function could be merged with registerWidgetFeature but it requires + // desing change: + // 1. Check "ace step" in installer must be done before "update database + // step" // And: // ConfigurationParserData shouldn't be called "ParserData" any more. using namespace DPL::DB::ORM; @@ -646,13 +572,12 @@ void WidgetDAO::updateFeatureRejectStatus(const DbWidgetFeature &widgetFeature){ } void WidgetDAO::registerWidgetWindowModes(DbWidgetHandle widgetHandle, - const WidgetRegisterInfo ®Info) + const WidgetRegisterInfo ®Info) { using namespace DPL::DB::ORM; using namespace DPL::DB::ORM::wrt; const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo; - FOREACH(i, widgetConfigurationInfo.windowModes) { wrt::WidgetWindowModes::Row windowMode; @@ -664,13 +589,12 @@ void WidgetDAO::registerWidgetWindowModes(DbWidgetHandle widgetHandle, } void WidgetDAO::registerWidgetWarpInfo(DbWidgetHandle widgetHandle, - const WidgetRegisterInfo ®Info) + const WidgetRegisterInfo ®Info) { using namespace DPL::DB::ORM; using namespace DPL::DB::ORM::wrt; const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo; - FOREACH(AccIt, widgetConfigurationInfo.accessInfoSet) { WidgetWARPInfo::Row row; @@ -683,14 +607,30 @@ void WidgetDAO::registerWidgetWarpInfo(DbWidgetHandle widgetHandle, } } -void WidgetDAO::registerWidgetCertificates(DbWidgetHandle widgetHandle, - const IWacSecurity &wacSecurity) +void WidgetDAO::registerWidgetAllowNavigationInfo(DbWidgetHandle widgetHandle, + const WidgetRegisterInfo ®Info) { using namespace DPL::DB::ORM; using namespace DPL::DB::ORM::wrt; + const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo; + FOREACH(allowNaviIt, widgetConfigurationInfo.allowNavigationInfoList) + { + WidgetAllowNavigation::Row row; + row.Set_app_id(widgetHandle); + row.Set_scheme(allowNaviIt->m_scheme); + row.Set_host(allowNaviIt->m_host); + DO_INSERT(row, WidgetAllowNavigation) + } +} + +void WidgetDAO::registerWidgetCertificates(DbWidgetHandle widgetHandle, + const IWidgetSecurity &widgetSecurity) +{ + using namespace DPL::DB::ORM; + using namespace DPL::DB::ORM::wrt; - FOREACH(it, wacSecurity.getCertificateList()) + FOREACH(it, widgetSecurity.getCertificateList()) { WidgetCertificateFingerprint::Row row; row.Set_app_id(widgetHandle); @@ -705,9 +645,11 @@ void WidgetDAO::registerWidgetCertificates(DbWidgetHandle widgetHandle, } } -void WidgetDAO::registerCertificatesChains(DbWidgetHandle widgetHandle, - CertificateSource certificateSource, - const CertificateChainList &certificateChainList) +void WidgetDAO::registerCertificatesChains( + DbWidgetHandle widgetHandle, + CertificateSource certificateSource, + const CertificateChainList & + certificateChainList) { using namespace DPL::DB::ORM; using namespace DPL::DB::ORM::wrt; @@ -723,7 +665,7 @@ void WidgetDAO::registerCertificatesChains(DbWidgetHandle widgetHandle, } void WidgetDAO::registerWidgetSettings(DbWidgetHandle widgetHandle, - const WidgetRegisterInfo ®Info) + const WidgetRegisterInfo ®Info) { using namespace DPL::DB::ORM; using namespace DPL::DB::ORM::wrt; @@ -741,28 +683,94 @@ void WidgetDAO::registerWidgetSettings(DbWidgetHandle widgetHandle, } } -void WidgetDAO::registerAppService(DbWidgetHandle widgetHandle, +void WidgetDAO::insertAppControlInfo(DbWidgetHandle handle, + DPL::String src, + DPL::String operation, + DPL::String uri, + DPL::String mime, + unsigned index, + unsigned disposition) +{ + using namespace DPL::DB::ORM; + using namespace DPL::DB::ORM::wrt; + + AppControlInfo::Row row; + + row.Set_app_id(handle); + row.Set_execute_index(index); + row.Set_src(src); + row.Set_operation(operation); + row.Set_uri(uri); + row.Set_mime(mime); + row.Set_disposition(disposition); + + DO_INSERT(row, AppControlInfo); +} + +void WidgetDAO::registerAppControl(DbWidgetHandle widgetHandle, const WidgetRegisterInfo ®Info) { using namespace DPL::DB::ORM; using namespace DPL::DB::ORM::wrt; const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo; - FOREACH(ASIt, widgetConfigurationInfo.appServiceList) + // appControlList + FOREACH(appControl_it, widgetConfigurationInfo.appControlList) { - ApplicationServiceInfo::Row row; - row.Set_app_id(widgetHandle); - row.Set_src(ASIt->m_src); - row.Set_operation(ASIt->m_operation); - row.Set_scheme(ASIt->m_scheme); - row.Set_mime(ASIt->m_mime); + DPL::String src = appControl_it->m_src; + DPL::String operation = appControl_it->m_operation; + unsigned index = appControl_it->m_index; + unsigned disposition = appControl_it->m_disposition == + ConfigParserData::AppControlInfo::Disposition::INLINE ? 1 : 0; - DO_INSERT(row, ApplicationServiceInfo) + if (!appControl_it->m_uriList.empty()) + { + FOREACH(uri_it, appControl_it->m_uriList) + { + DPL::String uri = *uri_it; + + if (!appControl_it->m_mimeList.empty()) + { + FOREACH(mime_it, appControl_it->m_mimeList) + { + DPL::String mime = *mime_it; + + insertAppControlInfo(widgetHandle, src, operation, uri, mime, index, disposition); + } + } + else + { + DPL::String mime = L""; + + insertAppControlInfo(widgetHandle, src, operation, uri, mime, index, disposition); + } + } + } + else + { + DPL::String uri = L""; + + if (!appControl_it->m_mimeList.empty()) + { + FOREACH(mime_it, appControl_it->m_mimeList) + { + DPL::String mime = *mime_it; + + insertAppControlInfo(widgetHandle, src, operation, uri, mime, index, disposition); + } + } + else + { + DPL::String mime = L""; + + insertAppControlInfo(widgetHandle, src, operation, uri, mime, index, disposition); + } + } } } void WidgetDAO::registerEncryptedResouceInfo(DbWidgetHandle widgetHandle, - const WidgetRegisterInfo ®Info) + const WidgetRegisterInfo ®Info) { using namespace DPL::DB::ORM; using namespace DPL::DB::ORM::wrt; @@ -778,14 +786,17 @@ void WidgetDAO::registerEncryptedResouceInfo(DbWidgetHandle widgetHandle, } } -void WidgetDAO::registerExternalLocations(DbWidgetHandle widgetHandle, - const ExternalLocationList & externals) +void WidgetDAO::registerExternalLocations( + DbWidgetHandle widgetHandle, + const ExternalLocationList & + externals) { SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN { using namespace DPL::DB::ORM; using namespace DPL::DB::ORM::wrt; - DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface()); + DPL::DB::ORM::wrt::ScopedTransaction transaction( + &WrtDatabase::interface()); LogDebug("Inserting external files for widgetHandle: " << widgetHandle); FOREACH(it, externals) { @@ -810,7 +821,6 @@ void WidgetDAO::registerWidgetSecuritySettings(DbWidgetHandle widgetHandle) row.Set_geolocation_usage(SETTINGS_TYPE_ON); row.Set_web_notification_usage(SETTINGS_TYPE_ON); row.Set_web_database_usage(SETTINGS_TYPE_ON); - row.Set_file_system_usage(SETTINGS_TYPE_ON); DO_INSERT(row, WidgetSecuritySettings) } @@ -830,34 +840,16 @@ void WidgetDAO::unregisterWidget(const TizenAppId & tzAppId) LogDebug("Unregistering widget from DB. tzAppId: " << tzAppId); SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN { - DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface()); + DPL::DB::ORM::wrt::ScopedTransaction transaction( + &WrtDatabase::interface()); unregisterWidgetInternal(tzAppId); transaction.Commit(); } SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to unregister widget") } -void WidgetDAO::unregisterWidget(WrtDB::DbWidgetHandle handle) -{ - LogDebug("Unregistering widget from DB. Handle: " << handle); - SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN - { - using namespace DPL::DB::ORM; - using namespace DPL::DB::ORM::wrt; - ScopedTransaction transaction(&WrtDatabase::interface()); - - // Delete from table Widget Info - WRT_DB_DELETE(del, WidgetInfo, &WrtDatabase::interface()) - del->Where(Equals(handle)); - del->Execute(); - - transaction.Commit(); - } - SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to unregister widget") -} - void WidgetDAO::unregisterWidgetInternal( - const TizenAppId & tzAppId) + const TizenAppId & tzAppId) { using namespace DPL::DB::ORM; using namespace DPL::DB::ORM::wrt; @@ -876,5 +868,4 @@ void WidgetDAO::unregisterWidgetInternal( #undef SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN #undef SQL_CONNECTION_EXCEPTION_HANDLER_END - } // namespace WrtDB