SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register widget")
}
+void WidgetDAO::setSecurityPopupUsage(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_security_popup_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 security popup usage")
+}
+
+void WidgetDAO::setGeolocationUsage(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_geolocation_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 geolocation usage")
+}
+
+void WidgetDAO::setWebNotificationUsage(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_web_notification_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 web notification usage")
+}
+
+void WidgetDAO::setWebDatabaseUsage(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_web_database_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 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 WidgetPkgName & widgetPkgname,
const WidgetRegisterInfo &widgetRegInfo,
registerEncryptedResouceInfo(widgetHandle, widgetRegInfo);
registerExternalLocations(widgetHandle, widgetRegInfo.externalLocations);
+
+ registerWidgetSecuritySettings(widgetHandle);
}
void WidgetDAO::registerOrUpdateWidget(
SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register external files");
}
+void WidgetDAO::registerWidgetSecuritySettings(DbWidgetHandle widgetHandle)
+{
+ SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+ {
+ using namespace DPL::DB::ORM;
+ using namespace DPL::DB::ORM::wrt;
+ DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
+
+ WidgetSecuritySettings::Row row;
+ row.Set_app_id(widgetHandle);
+ row.Set_security_popup_usage(SETTINGS_TYPE_ON);
+ 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)
+ transaction.Commit();
+ }
+ SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register external files");
+}
+
void WidgetDAO::unregisterAllExternalLocations()
{
using namespace DPL::DB::ORM;
typedef DPL::DB::ORM::wrt::WidgetInfo::Row WidgetInfoRow;
typedef DPL::DB::ORM::wrt::WidgetFeature::widget_feature_id::ColumnType
- WidgetFeatureId;
+ WidgetFeatureId;
+typedef DPL::DB::ORM::wrt::WidgetSecuritySettings::Row
+ WidgetSecuritySettingsRow;
namespace {
SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed in GetWidgetInfoRow")
}
+WidgetSecuritySettingsRow getWidgetSecuritySettingsRow(int widgetHandle)
+{
+ LogDebug("Getting WidgetSecuritySettings row. Handle: " << widgetHandle);
+ SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+ {
+ using namespace DPL::DB::ORM;
+ using namespace DPL::DB::ORM::wrt;
+ WRT_DB_SELECT(select, WidgetSecuritySettings, &WrtDatabase::interface())
+ select->Where(Equals<WidgetSecuritySettings::app_id>(widgetHandle));
+
+ WidgetSecuritySettings::Select::RowList rows = select->GetRowList();
+ if (rows.empty()) {
+ ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
+ "Cannot find widget. Handle: " << widgetHandle);
+ }
+ return rows.front();
+ }
+ SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed in getWidgetSecuritySettingsRow")
+}
+
const int MAX_TIZENID_LENGTH = 10;
} // namespace
return tizenId;
}
+SettingsType WidgetDAOReadOnly::getSecurityPopupUsage(void) const
+{
+ WidgetSecuritySettingsRow row =
+ getWidgetSecuritySettingsRow(m_widgetHandle);
+ DPL::OptionalInt result = row.Get_security_popup_usage();
+ return static_cast<SettingsType>(*result);
+}
+
+SettingsType WidgetDAOReadOnly::getGeolocationUsage(void) const
+{
+ WidgetSecuritySettingsRow row =
+ getWidgetSecuritySettingsRow(m_widgetHandle);
+ DPL::OptionalInt result = row.Get_geolocation_usage();
+ return static_cast<SettingsType>(*result);
+}
+
+SettingsType WidgetDAOReadOnly::getWebNotificationUsage(void) const
+{
+ WidgetSecuritySettingsRow row =
+ getWidgetSecuritySettingsRow(m_widgetHandle);
+ DPL::OptionalInt result = row.Get_web_notification_usage();
+ return static_cast<SettingsType>(*result);
+}
+
+SettingsType WidgetDAOReadOnly::getWebDatabaseUsage(void) const
+{
+ WidgetSecuritySettingsRow row =
+ getWidgetSecuritySettingsRow(m_widgetHandle);
+ DPL::OptionalInt result = row.Get_web_database_usage();
+ return static_cast<SettingsType>(*result);
+}
+
+SettingsType WidgetDAOReadOnly::getFileSystemUsage(void) const
+{
+ WidgetSecuritySettingsRow row =
+ getWidgetSecuritySettingsRow(m_widgetHandle);
+ DPL::OptionalInt result = row.Get_file_system_usage();
+ return static_cast<SettingsType>(*result);
+}
+
#undef SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
#undef SQL_CONNECTION_EXCEPTION_HANDLER_END
#undef CHECK_WIDGET_EXISTENCE