2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * This file contains the definition of widget dao class.
19 * @file widget_dao.cpp
20 * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
21 * @author Bartosz Janiak (b.janiak@samsung.com)
22 * @author Yang Jie (jie2.yang@samsung.com)
23 * @author Koeun Choi(koeun.choi@samsung.com)
24 * @author Pawel Sikorski(p.sikorski@samsung.com)
26 * @brief This file contains the definition of Configuration.
29 #include <dpl/wrt-dao-rw/widget_dao.h>
32 #include <dpl/log/log.h>
33 #include <dpl/foreach.h>
34 #include <dpl/wrt-dao-ro/webruntime_database.h>
35 #include <dpl/wrt-dao-rw/property_dao.h>
36 #include <orm_generator_wrt.h>
37 #include <dpl/wrt-dao-ro/WrtDatabase.h>
41 //TODO in current solution in each getter there exists a check
42 //"IsWidgetInstalled". Maybe it should be verified, if it could be done
43 //differently (check in WidgetDAO constructor)
45 #define SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN Try
47 #define SQL_CONNECTION_EXCEPTION_HANDLER_END(message) \
48 Catch(DPL::DB::SqlConnection::Exception::Base) { \
50 ReThrowMsg(WidgetDAO::Exception::DatabaseError, \
54 WidgetDAO::WidgetDAO(DPL::OptionalString widgetGUID) :
55 WidgetDAOReadOnly(WidgetDAOReadOnly::getHandle(widgetGUID))
59 WidgetDAO::WidgetDAO(DPL::String pkgName) :
60 WidgetDAOReadOnly(WidgetDAOReadOnly::getHandle(pkgName))
64 WidgetDAO::WidgetDAO(DbWidgetHandle handle) :
65 WidgetDAOReadOnly(handle)
69 WidgetDAO::~WidgetDAO()
73 void WidgetDAO::removeProperty(
74 const PropertyDAOReadOnly::WidgetPropertyKey &key)
77 PropertyDAO::RemoveProperty(m_widgetHandle, key);
79 Catch(PropertyDAOReadOnly::Exception::ReadOnlyProperty){
80 ReThrowMsg(WidgetDAO::Exception::DatabaseError,
81 "Failure during removing property");
85 void WidgetDAO::setProperty(
86 const PropertyDAOReadOnly::WidgetPropertyKey &key,
87 const PropertyDAOReadOnly::WidgetPropertyValue &value,
91 PropertyDAO::SetProperty(m_widgetHandle, key, value, readOnly);
93 Catch(PropertyDAOReadOnly::Exception::ReadOnlyProperty){
94 ReThrowMsg(WidgetDAO::Exception::DatabaseError,
95 "Failure during setting/updating property");
99 void WidgetDAO::setPkgName(const DPL::OptionalString& pkgName)
101 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
103 using namespace DPL::DB::ORM;
104 wrt::ScopedTransaction transaction(&WrtDatabase::interface());
106 isWidgetInstalled(getHandle());
108 wrt::WidgetInfo::Row row;
109 row.Set_pkgname(pkgName);
111 WRT_DB_UPDATE(update, wrt::WidgetInfo, &WrtDatabase::interface())
113 Equals<wrt::WidgetInfo::app_id>(getHandle()));
117 transaction.Commit();
119 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register widget")
122 void WidgetDAO::registerWidget(
123 const WidgetPkgName & widgetPkgname,
124 const WidgetRegisterInfo &widgetRegInfo,
125 const IWacSecurity &wacSecurity)
127 LogDebug("Registering widget");
128 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
130 DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
131 registerWidgetInternal(widgetPkgname, widgetRegInfo, wacSecurity);
132 transaction.Commit();
134 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register widget")
137 void WidgetDAO::registerWidget(
138 WrtDB::DbWidgetHandle handle,
139 const WidgetRegisterInfo &widgetRegInfo,
140 const IWacSecurity &wacSecurity)
142 LogDebug("Registering widget");
143 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
145 DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
146 registerWidgetInternal(generateTizenId(), widgetRegInfo, wacSecurity, handle);
147 transaction.Commit();
149 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register widget")
152 DbWidgetHandle WidgetDAO::registerWidget(
153 const WidgetRegisterInfo &pWidgetRegisterInfo,
154 const IWacSecurity &wacSecurity)
156 //make it more precise due to very fast tests
158 gettimeofday(&tv, NULL);
159 srand(time(NULL) + tv.tv_usec);
160 DbWidgetHandle widgetHandle;
162 widgetHandle = rand();
163 } while (isWidgetInstalled(widgetHandle));
165 registerWidget(widgetHandle, pWidgetRegisterInfo, wacSecurity);
169 WidgetPkgName WidgetDAO::registerWidgetGenerateTizenId(
170 const WidgetRegisterInfo &pWidgetRegisterInfo,
171 const IWacSecurity &wacSecurity)
173 WidgetPkgName widgetPkgName = generateTizenId();
174 registerWidget(widgetPkgName, pWidgetRegisterInfo, wacSecurity);
175 return widgetPkgName;
178 void WidgetDAO::registerWidgetInternal(
179 const WidgetPkgName & widgetName,
180 const WidgetRegisterInfo &widgetRegInfo,
181 const IWacSecurity &wacSecurity,
182 const DPL::Optional<DbWidgetHandle> handle)
184 //Register into WidgetInfo has to be first
185 //as all other tables depend upon that
186 DbWidgetHandle widgetHandle = registerWidgetInfo(widgetName, widgetRegInfo, wacSecurity, handle);
188 registerWidgetExtendedInfo(widgetHandle, widgetRegInfo);
190 registerWidgetLocalizedInfo(widgetHandle, widgetRegInfo);
192 registerWidgetIcons(widgetHandle, widgetRegInfo);
194 registerWidgetStartFile(widgetHandle, widgetRegInfo);
196 PropertyDAO::RegisterProperties(widgetHandle, widgetRegInfo);
198 registerWidgetFeatures(widgetHandle, widgetRegInfo);
200 registerWidgetWindowModes(widgetHandle, widgetRegInfo);
202 registerWidgetWarpInfo(widgetHandle, widgetRegInfo);
204 registerWidgetCertificates(widgetHandle, wacSecurity);
206 CertificateChainList list;
207 wacSecurity.getCertificateChainList(list, SIGNATURE_DISTRIBUTOR);
208 registerCertificatesChains(widgetHandle, SIGNATURE_DISTRIBUTOR, list);
211 wacSecurity.getCertificateChainList(list, SIGNATURE_AUTHOR);
212 registerCertificatesChains(widgetHandle, SIGNATURE_AUTHOR, list);
214 registerWidgetSettings(widgetHandle, widgetRegInfo);
216 registerAppService(widgetHandle, widgetRegInfo);
218 registerEncryptedResouceInfo(widgetHandle, widgetRegInfo);
220 registerExternalLocations(widgetHandle, widgetRegInfo.externalLocations);
223 void WidgetDAO::registerOrUpdateWidget(
224 const WidgetPkgName & widgetName,
225 const WidgetRegisterInfo &widgetRegInfo,
226 const IWacSecurity &wacSecurity)
228 LogDebug("Reregistering widget");
229 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
231 DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
233 unregisterWidgetInternal(widgetName);
234 registerWidgetInternal(widgetName, widgetRegInfo, wacSecurity);
235 transaction.Commit();
237 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to reregister widget")
240 #define DO_INSERT(row, table) \
242 WRT_DB_INSERT(insert, table, &WrtDatabase::interface()) \
243 insert->Values(row); \
247 void WidgetDAO::registerWidgetExtendedInfo(DbWidgetHandle widgetHandle,
248 const WidgetRegisterInfo ®Info)
250 //Try and transaction not needed
251 using namespace DPL::DB::ORM;
252 using namespace DPL::DB::ORM::wrt;
255 WidgetExtendedInfo::Row row;
256 row.Set_app_id(widgetHandle);
257 // row.Set_share_href (DPL::FromUTF8String(regInfo.shareHref));
258 row.Set_signature_type(regInfo.signatureType);
259 row.Set_test_widget(regInfo.isTestWidget);
260 row.Set_install_time(regInfo.installedTime);
261 row.Set_splash_img_src(regInfo.configInfo.splashImgSrc);
262 row.Set_background_page(regInfo.configInfo.backgroundPage);
265 DO_INSERT(row, WidgetExtendedInfo)
268 DbWidgetHandle WidgetDAO::registerWidgetInfo(
269 const WidgetPkgName & widgetName,
270 const WidgetRegisterInfo ®Info,
271 const IWacSecurity &wacSecurity,
272 const DPL::Optional<DbWidgetHandle> handle)
274 using namespace DPL::DB::ORM;
275 using namespace DPL::DB::ORM::wrt;
276 const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
278 // TODO in wrt_db all Columns in WidgetInfo have DEFAULT VALUE set.
279 // Because of that, "Optional" is not used there
284 row.Set_app_id(*handle);
287 if (regInfo.webAppType == APP_TYPE_UNKNOWN && regInfo.type !=
289 // TODO : regInfo.type is temporary code for security.
290 // This code will be removed.
291 row.Set_widget_type(regInfo.type.appType);
293 row.Set_widget_type(regInfo.webAppType.appType);
295 row.Set_widget_id(widgetConfigurationInfo.widget_id);
296 row.Set_defaultlocale(widgetConfigurationInfo.defaultlocale);
297 row.Set_widget_version(widgetConfigurationInfo.version);
298 row.Set_widget_width(widgetConfigurationInfo.width);
299 row.Set_widget_height(widgetConfigurationInfo.height);
300 row.Set_author_name(widgetConfigurationInfo.authorName);
301 row.Set_author_email(widgetConfigurationInfo.authorEmail);
302 row.Set_author_href(widgetConfigurationInfo.authorHref);
303 row.Set_base_folder(DPL::FromUTF8String(regInfo.baseFolder));
304 row.Set_webkit_plugins_required(widgetConfigurationInfo.flashNeeded);
305 row.Set_recognized(wacSecurity.isRecognized());
306 row.Set_wac_signed(wacSecurity.isWacSigned());
307 row.Set_distributor_signed(wacSecurity.isDistributorSigned());
308 row.Set_pkgname(widgetName);
310 std::stringstream tmp;
311 tmp << regInfo.minVersion;
312 row.Set_min_version(DPL::FromUTF8String(tmp.str()));
314 row.Set_back_supported(widgetConfigurationInfo.backSupported);
315 row.Set_access_network(widgetConfigurationInfo.accessNetwork);
316 row.Set_pkg_type(regInfo.packagingType.pkgType);
320 DO_INSERT(row, WidgetInfo);
322 Catch(DPL::DB::SqlConnection::Exception::Base)
324 ReThrowMsg(WidgetDAO::Exception::DatabaseError,
325 "Failed to register widget info.");
330 //get autoincremented value of widgetHandle
331 WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
332 select->Where(Equals<WidgetInfo::pkgname>(widgetName));
333 return select->GetSingleValue<WidgetInfo::app_id>();
341 void WidgetDAO::registerWidgetLocalizedInfo(DbWidgetHandle widgetHandle,
342 const WidgetRegisterInfo ®Info)
344 using namespace DPL::DB::ORM;
345 using namespace DPL::DB::ORM::wrt;
347 const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
349 FOREACH(it, widgetConfigurationInfo.localizedDataSet)
351 const DPL::String& locale = it->first;
352 const ConfigParserData::LocalizedData& data = it->second;
354 LocalizedWidgetInfo::Row row;
355 row.Set_app_id(widgetHandle);
356 row.Set_widget_locale(locale);
357 row.Set_widget_name(data.name);
358 row.Set_widget_shortname(data.shortName);
359 row.Set_widget_description(data.description);
360 row.Set_widget_license(data.license);
361 row.Set_widget_license_file(data.licenseFile);
362 row.Set_widget_license_href(data.licenseHref);
364 DO_INSERT(row, LocalizedWidgetInfo)
368 void WidgetDAO::registerWidgetIcons(DbWidgetHandle widgetHandle,
369 const WidgetRegisterInfo ®Info)
371 using namespace DPL::DB::ORM;
372 using namespace DPL::DB::ORM::wrt;
375 FOREACH(i, regInfo.localizationData.icons)
377 wrt::WidgetIcon::icon_id::ColumnType icon_id;
379 wrt::WidgetIcon::Row row;
380 row.Set_app_id(widgetHandle);
381 row.Set_icon_src(i->src);
382 row.Set_icon_width(i->width);
383 row.Set_icon_height(i->height);
385 WRT_DB_INSERT(insert, wrt::WidgetIcon, &WrtDatabase::interface())
387 icon_id = insert->Execute();
390 FOREACH(j, i->availableLocales)
392 WidgetLocalizedIcon::Row row;
393 row.Set_app_id(widgetHandle);
394 row.Set_icon_id(icon_id);
395 row.Set_widget_locale(*j);
396 WRT_DB_SELECT(select, WidgetLocalizedIcon, &WrtDatabase::interface())
397 select->Where(And(Equals<WidgetLocalizedIcon::app_id>(widgetHandle),
398 Equals<WidgetLocalizedIcon::widget_locale>(*j)));
399 WidgetLocalizedIcon::Select::RowList rows = select->GetRowList();
401 bool flag = !rows.empty();
405 // already default icon value of same locale exists
406 WRT_DB_UPDATE(update, WidgetLocalizedIcon, &WrtDatabase::interface())
407 update->Where(And(Equals<WidgetLocalizedIcon::app_id>(widgetHandle),
408 Equals<WidgetLocalizedIcon::widget_locale>(*j)));
412 // any icon value of same locale doesn't exist
413 DO_INSERT(row, WidgetLocalizedIcon)
419 void WidgetDAO::registerWidgetStartFile(DbWidgetHandle widgetHandle,
420 const WidgetRegisterInfo ®Info)
422 using namespace DPL::DB::ORM;
423 using namespace DPL::DB::ORM::wrt;
426 FOREACH(i, regInfo.localizationData.startFiles)
428 WidgetStartFile::start_file_id::ColumnType startFileID;
430 WidgetStartFile::Row row;
431 row.Set_app_id(widgetHandle);
432 row.Set_src(i->path);
434 WRT_DB_INSERT(insert, WidgetStartFile, &WrtDatabase::interface())
436 startFileID = insert->Execute();
439 FOREACH(j, i->propertiesForLocales)
441 WidgetLocalizedStartFile::Row row;
442 row.Set_app_id(widgetHandle);
443 row.Set_start_file_id(startFileID);
444 row.Set_widget_locale(j->first);
445 row.Set_type(j->second.type);
446 row.Set_encoding(j->second.encoding);
448 DO_INSERT(row, WidgetLocalizedStartFile)
453 void WidgetDAO::registerWidgetFeatures(DbWidgetHandle widgetHandle,
454 const WidgetRegisterInfo ®Info)
456 using namespace DPL::DB::ORM;
457 const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
460 FOREACH(pWidgetFeature, widgetConfigurationInfo.featuresList)
462 wrt::WidgetFeature::Row widgetFeature;
463 widgetFeature.Set_app_id(widgetHandle);
464 widgetFeature.Set_name(pWidgetFeature->name);
465 widgetFeature.Set_required(pWidgetFeature->required);
466 widgetFeature.Set_rejected(false);
468 wrt::WidgetFeature::widget_feature_id::ColumnType widgetFeatureID;
470 WRT_DB_INSERT(insert, wrt::WidgetFeature, &WrtDatabase::interface())
471 insert->Values(widgetFeature);
472 widgetFeatureID = insert->Execute();
475 // Insert into table FeatureParam
476 wrt::FeatureParam::Row featureParam;
477 featureParam.Set_widget_feature_id(widgetFeatureID);
479 FOREACH(iter, pWidgetFeature->paramsList)
481 featureParam.Set_name(iter->name);
482 featureParam.Set_value(iter->value);
484 DO_INSERT(featureParam, wrt::FeatureParam)
489 void WidgetDAO::updateFeatureRejectStatus(const DbWidgetFeature &widgetFeature){
490 // This function could be merged with registerWidgetFeature but it requires desing change:
491 // 1. Check "ace step" in installer must be done before "update database step"
493 // ConfigurationParserData shouldn't be called "ParserData" any more.
494 using namespace DPL::DB::ORM;
496 wrt::ScopedTransaction transaction(&WrtDatabase::interface());
497 WRT_DB_SELECT(select, wrt::WidgetFeature, &WrtDatabase::interface())
498 select->Where(And(Equals<wrt::WidgetFeature::app_id>(m_widgetHandle),
499 Equals<wrt::WidgetFeature::name>(widgetFeature.name)));
501 auto row = select->GetSingleRow();
502 row.Set_rejected(widgetFeature.rejected);
504 WRT_DB_UPDATE(update, wrt::WidgetFeature, &WrtDatabase::interface())
505 update->Where(And(Equals<wrt::WidgetFeature::app_id>(m_widgetHandle),
506 Equals<wrt::WidgetFeature::name>(widgetFeature.name)));
509 transaction.Commit();
512 void WidgetDAO::registerWidgetWindowModes(DbWidgetHandle widgetHandle,
513 const WidgetRegisterInfo ®Info)
515 using namespace DPL::DB::ORM;
516 using namespace DPL::DB::ORM::wrt;
517 const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
520 FOREACH(i, widgetConfigurationInfo.windowModes)
522 wrt::WidgetWindowModes::Row windowMode;
523 windowMode.Set_app_id(widgetHandle);
524 windowMode.Set_window_mode(*i);
526 DO_INSERT(windowMode, wrt::WidgetWindowModes)
530 void WidgetDAO::registerWidgetWarpInfo(DbWidgetHandle widgetHandle,
531 const WidgetRegisterInfo ®Info)
533 using namespace DPL::DB::ORM;
534 using namespace DPL::DB::ORM::wrt;
535 const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
538 FOREACH(AccIt, widgetConfigurationInfo.accessInfoSet)
540 WidgetWARPInfo::Row row;
541 row.Set_app_id(widgetHandle);
542 row.Set_iri(AccIt->m_strIRI);
543 row.Set_subdomain_access(static_cast <int>(
544 AccIt->m_bSubDomainAccess));
546 DO_INSERT(row, WidgetWARPInfo)
550 void WidgetDAO::registerWidgetCertificates(DbWidgetHandle widgetHandle,
551 const IWacSecurity &wacSecurity)
553 using namespace DPL::DB::ORM;
554 using namespace DPL::DB::ORM::wrt;
557 FOREACH(it, wacSecurity.getCertificateList())
559 WidgetCertificateFingerprint::Row row;
560 row.Set_app_id(widgetHandle);
561 row.Set_owner(it->owner);
562 row.Set_chainid(it->chainId);
563 row.Set_type(it->type);
564 row.Set_md5_fingerprint(DPL::FromUTF8String(it->strMD5Fingerprint));
565 row.Set_sha1_fingerprint(DPL::FromUTF8String(it->strSHA1Fingerprint));
566 row.Set_common_name(it->strCommonName);
568 DO_INSERT(row, WidgetCertificateFingerprint)
572 void WidgetDAO::registerCertificatesChains(DbWidgetHandle widgetHandle,
573 CertificateSource certificateSource,
574 const CertificateChainList &certificateChainList)
576 using namespace DPL::DB::ORM;
577 using namespace DPL::DB::ORM::wrt;
578 FOREACH(certChain, certificateChainList)
580 WidgetCertificate::Row row;
581 row.Set_app_id(widgetHandle);
582 row.Set_cert_source(certificateSource);
583 row.Set_encoded_chain(DPL::FromASCIIString(*certChain));
585 DO_INSERT(row, WidgetCertificate);
589 void WidgetDAO::registerWidgetSettings(DbWidgetHandle widgetHandle,
590 const WidgetRegisterInfo ®Info)
592 using namespace DPL::DB::ORM;
593 using namespace DPL::DB::ORM::wrt;
595 const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
597 FOREACH(pWidgetSetting, widgetConfigurationInfo.settingsList)
599 SettingsList::Row row;
600 row.Set_appId(widgetHandle);
601 row.Set_settingName(pWidgetSetting->m_name);
602 row.Set_settingValue(pWidgetSetting->m_value);
604 DO_INSERT(row, SettingsList)
608 void WidgetDAO::registerAppService(DbWidgetHandle widgetHandle,
609 const WidgetRegisterInfo ®Info)
611 using namespace DPL::DB::ORM;
612 using namespace DPL::DB::ORM::wrt;
613 const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
615 FOREACH(ASIt, widgetConfigurationInfo.appServiceList)
617 ApplicationServiceInfo::Row row;
618 row.Set_app_id(widgetHandle);
619 row.Set_src(ASIt->m_src);
620 row.Set_operation(ASIt->m_operation);
621 row.Set_scheme(ASIt->m_scheme);
622 row.Set_mime(ASIt->m_mime);
624 DO_INSERT(row, ApplicationServiceInfo)
628 void WidgetDAO::registerEncryptedResouceInfo(DbWidgetHandle widgetHandle,
629 const WidgetRegisterInfo ®Info)
631 using namespace DPL::DB::ORM;
632 using namespace DPL::DB::ORM::wrt;
634 FOREACH(it, regInfo.encryptedFiles)
636 EncryptedResourceList::Row row;
637 row.Set_app_id(widgetHandle);
638 row.Set_resource(it->fileName);
639 row.Set_size(it->fileSize);
641 DO_INSERT(row, EncryptedResourceList)
645 void WidgetDAO::registerExternalLocations(DbWidgetHandle widgetHandle,
646 const ExternalLocationList & externals)
648 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
650 using namespace DPL::DB::ORM;
651 using namespace DPL::DB::ORM::wrt;
652 DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
653 LogDebug("Inserting external files for widgetHandle: " << widgetHandle);
654 FOREACH(it, externals)
656 WidgetExternalLocations::Row row;
657 row.Set_app_id(widgetHandle);
658 row.Set_path(DPL::FromUTF8String(*it));
660 DO_INSERT(row, WidgetExternalLocations)
662 transaction.Commit();
664 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register external files");
667 void WidgetDAO::unregisterAllExternalLocations()
669 using namespace DPL::DB::ORM;
670 using namespace DPL::DB::ORM::wrt;
671 LogDebug("Deleting external files for widgetHandle: " << m_widgetHandle);
672 WRT_DB_DELETE(del, WidgetExternalLocations, &WrtDatabase::interface());
673 del->Where(Equals<WidgetExternalLocations::app_id>(m_widgetHandle));
677 void WidgetDAO::unregisterWidget(const WidgetPkgName & pkgName)
679 LogDebug("Unregistering widget from DB. PkgName: " << pkgName);
680 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
682 DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
683 unregisterWidgetInternal(pkgName);
684 transaction.Commit();
686 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to unregister widget")
689 void WidgetDAO::unregisterWidget(WrtDB::DbWidgetHandle handle)
691 LogDebug("Unregistering widget from DB. Handle: " << handle);
692 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
694 using namespace DPL::DB::ORM;
695 using namespace DPL::DB::ORM::wrt;
696 ScopedTransaction transaction(&WrtDatabase::interface());
698 // Delete from table Widget Info
699 WRT_DB_DELETE(del, WidgetInfo, &WrtDatabase::interface())
700 del->Where(Equals<WidgetInfo::app_id>(handle));
703 transaction.Commit();
705 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to unregister widget")
708 void WidgetDAO::unregisterWidgetInternal(
709 const WidgetPkgName & pkgName)
711 using namespace DPL::DB::ORM;
712 using namespace DPL::DB::ORM::wrt;
714 DbWidgetHandle handle = getHandle(pkgName);
716 // Delete from table Widget Info
717 WRT_DB_DELETE(del, WidgetInfo, &WrtDatabase::interface())
718 del->Where(Equals<WidgetInfo::app_id>(handle));
721 // Deleting in other tables is done via "delete cascade" in SQL
726 #undef SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
727 #undef SQL_CONNECTION_EXCEPTION_HANDLER_END