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<WidgetSecuritySettings::app_id>(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)
+ const IWidgetSecurity &widgetSecurity)
{
LogDebug("Registering widget");
SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
{
DPL::DB::ORM::wrt::ScopedTransaction transaction(
&WrtDatabase::interface());
- registerWidgetInternal(tzAppId, widgetRegInfo, wacSecurity);
+ 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 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(*pWidgetRegisterInfo.configInfo.tizenAppId,
pWidgetRegisterInfo,
- wacSecurity);
+ widgetSecurity);
return widgetHandle;
}
TizenAppId WidgetDAO::registerWidgetGeneratePkgId(
const WidgetRegisterInfo &pWidgetRegisterInfo,
- const IWacSecurity &wacSecurity)
+ 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<WidgetInfo::tizen_appid>(fromAppId));
+
+ WidgetInfo::Row row = select->GetSingleRow();
+
+ //WidgetInfo::Row row;
+ row.Set_tizen_appid(toAppId);
+
+ WRT_DB_UPDATE(update, WidgetInfo, &WrtDatabase::interface())
+ update->Where(Equals<WidgetInfo::tizen_appid>(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 IWidgetSecurity &widgetSecurity,
const DPL::Optional<DbWidgetHandle> handle)
{
//Register into WidgetInfo has to be first
//as all other tables depend upon that
DbWidgetHandle widgetHandle = registerWidgetInfo(tzAppId,
widgetRegInfo,
- wacSecurity,
+ widgetSecurity,
handle);
registerWidgetExtendedInfo(widgetHandle, widgetRegInfo);
registerWidgetStartFile(widgetHandle, widgetRegInfo);
- PropertyDAO::RegisterProperties(tzAppId, widgetRegInfo);
+ PropertyDAO::RegisterProperties(widgetHandle, tzAppId, widgetRegInfo);
registerWidgetFeatures(widgetHandle, widgetRegInfo);
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);
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()) \
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);
DbWidgetHandle WidgetDAO::registerWidgetInfo(
const TizenAppId & tzAppId,
const WidgetRegisterInfo ®Info,
- const IWacSecurity &wacSecurity,
+ const IWidgetSecurity &widgetSecurity,
const DPL::Optional<DbWidgetHandle> handle)
{
using namespace DPL::DB::ORM;
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);
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);
{
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<int>(widgetConfigurationInfo.securityModelVersion));
Try
{
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 = static_cast<int>(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)
}
}
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::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 IWacSecurity &wacSecurity)
+ 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);
}
}
-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);
+ }
+ }
}
}
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)
}
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<WidgetInfo::app_id>(handle));
- del->Execute();
-
- transaction.Commit();
- }
- SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to unregister widget")
-}
-
void WidgetDAO::unregisterWidgetInternal(
const TizenAppId & tzAppId)
{