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 DbWidgetHandle widgetHandle = registerWidgetInternal(widgetPkgname, widgetRegInfo, wacSecurity);
132 registerExternalLocations(widgetHandle, widgetRegInfo.externalLocations);
133 //TODO: remove construction from handle and move that call to registerWidgetInternal
134 // in new version external fiels should be register together with other informations
135 transaction.Commit();
137 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register widget")
140 void WidgetDAO::registerWidget(
141 WrtDB::DbWidgetHandle handle,
142 const WidgetRegisterInfo & widgetRegInfo,
143 const IWacSecurity &wacSecurity)
145 LogDebug("Registering widget");
146 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
148 DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
149 registerWidgetInternal(L"", widgetRegInfo, wacSecurity, handle);
150 transaction.Commit();
152 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register widget")
155 DbWidgetHandle WidgetDAO::registerWidget(
156 const WidgetRegisterInfo &pWidgetRegisterInfo,
157 const IWacSecurity &wacSecurity)
159 //make it more precise due to very fast tests
161 gettimeofday(&tv, NULL);
162 srand(time(NULL) + tv.tv_usec);
163 DbWidgetHandle widgetHandle;
165 widgetHandle = rand();
166 } while (isWidgetInstalled(widgetHandle));
168 registerWidget(widgetHandle, pWidgetRegisterInfo, wacSecurity);
172 DbWidgetHandle WidgetDAO::registerWidgetInternal(
173 const WidgetPkgName & widgetName,
174 const WidgetRegisterInfo &widgetRegInfo,
175 const IWacSecurity &wacSecurity,
176 const DPL::Optional<DbWidgetHandle> handle)
178 //Register into WidgetInfo has to be first
179 //as all other tables depend upon that
180 DbWidgetHandle widgetHandle = registerWidgetInfo(widgetName, widgetRegInfo, wacSecurity, handle);
182 registerWidgetExtendedInfo(widgetHandle, widgetRegInfo);
184 registerWidgetLocalizedInfo(widgetHandle, widgetRegInfo);
186 registerWidgetIcons(widgetHandle, widgetRegInfo);
188 registerWidgetStartFile(widgetHandle, widgetRegInfo);
190 PropertyDAO::RegisterProperties(widgetHandle, widgetRegInfo);
192 registerWidgetFeatures(widgetHandle, widgetRegInfo);
194 registerWidgetWindowModes(widgetHandle, widgetRegInfo);
196 registerWidgetWarpInfo(widgetHandle, widgetRegInfo);
198 registerWidgetCertificates(widgetHandle, wacSecurity);
200 CertificateChainList list;
201 wacSecurity.getCertificateChainList(list, SIGNATURE_DISTRIBUTOR);
202 registerCertificatesChains(widgetHandle, SIGNATURE_DISTRIBUTOR, list);
205 wacSecurity.getCertificateChainList(list, SIGNATURE_AUTHOR);
206 registerCertificatesChains(widgetHandle, SIGNATURE_AUTHOR, list);
208 registerWidgetSettings(widgetHandle, widgetRegInfo);
210 registerAppService(widgetHandle, widgetRegInfo);
212 registerEncryptedResouceInfo(widgetHandle, widgetRegInfo);
217 void WidgetDAO::registerOrUpdateWidget(
218 const WidgetPkgName & widgetName,
219 const WidgetRegisterInfo &widgetRegInfo,
220 const IWacSecurity &wacSecurity)
222 LogDebug("Reregistering widget");
223 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
225 DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
227 unregisterWidgetInternal(widgetName);
228 DbWidgetHandle widgetHandle = registerWidgetInternal(widgetName, widgetRegInfo, wacSecurity);
229 registerExternalLocations(widgetHandle, widgetRegInfo.externalLocations);
230 //TODO: remove construction from handle and move that call to registerWidgetInternal
231 // in new version external fiels should be register together with other informations
232 transaction.Commit();
234 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to reregister widget")
237 #define DO_INSERT(row, table) \
239 WRT_DB_INSERT(insert, table, &WrtDatabase::interface()) \
240 insert->Values(row); \
244 void WidgetDAO::registerWidgetExtendedInfo(DbWidgetHandle widgetHandle,
245 const WidgetRegisterInfo ®Info)
247 //Try and transaction not needed
248 using namespace DPL::DB::ORM;
249 using namespace DPL::DB::ORM::wrt;
252 WidgetExtendedInfo::Row row;
253 row.Set_app_id(widgetHandle);
254 // row.Set_share_href (DPL::FromUTF8String(regInfo.shareHref));
255 row.Set_signature_type(regInfo.signatureType);
256 row.Set_test_widget(regInfo.isTestWidget);
257 row.Set_install_time(regInfo.installedTime);
258 row.Set_splash_img_src(regInfo.configInfo.splashImgSrc);
259 row.Set_background_page(regInfo.configInfo.backgroundPage);
262 DO_INSERT(row, WidgetExtendedInfo)
265 DbWidgetHandle WidgetDAO::registerWidgetInfo(
266 const WidgetPkgName & widgetName,
267 const WidgetRegisterInfo ®Info,
268 const IWacSecurity &wacSecurity,
269 const DPL::Optional<DbWidgetHandle> handle)
271 using namespace DPL::DB::ORM;
272 using namespace DPL::DB::ORM::wrt;
273 const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
275 // TODO in wrt_db all Columns in WidgetInfo have DEFAULT VALUE set.
276 // Because of that, "Optional" is not used there
281 row.Set_app_id(*handle);
283 row.Set_widget_type(regInfo.type.appType);
284 row.Set_widget_id(widgetConfigurationInfo.widget_id);
285 row.Set_defaultlocale(widgetConfigurationInfo.defaultlocale);
286 row.Set_widget_version(widgetConfigurationInfo.version);
287 row.Set_widget_width(widgetConfigurationInfo.width);
288 row.Set_widget_height(widgetConfigurationInfo.height);
289 row.Set_author_name(widgetConfigurationInfo.authorName);
290 row.Set_author_email(widgetConfigurationInfo.authorEmail);
291 row.Set_author_href(widgetConfigurationInfo.authorHref);
292 row.Set_base_folder(DPL::FromUTF8String(regInfo.baseFolder));
293 row.Set_webkit_plugins_required(widgetConfigurationInfo.flashNeeded);
294 row.Set_recognized(wacSecurity.isRecognized());
295 row.Set_wac_signed(wacSecurity.isWacSigned());
296 row.Set_distributor_signed(wacSecurity.isDistributorSigned());
297 row.Set_pkgname(widgetName);
299 std::stringstream tmp;
300 tmp << regInfo.minVersion;
301 row.Set_min_version(DPL::FromUTF8String(tmp.str()));
303 row.Set_back_supported(widgetConfigurationInfo.backSupported);
304 row.Set_access_network(widgetConfigurationInfo.accessNetwork);
305 row.Set_pkgname(regInfo.pkgname);
306 row.Set_pkg_type(regInfo.pType.pkgType);
310 DO_INSERT(row, WidgetInfo);
312 Catch(DPL::DB::SqlConnection::Exception::Base)
314 ReThrowMsg(WidgetDAO::Exception::DatabaseError,
315 "Failed to register widget info.");
320 //get autoincremented value of widgetHandle
321 WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
322 select->Where(Equals<WidgetInfo::pkgname>(widgetName));
323 return select->GetSingleValue<WidgetInfo::app_id>();
331 void WidgetDAO::registerWidgetLocalizedInfo(DbWidgetHandle widgetHandle,
332 const WidgetRegisterInfo ®Info)
334 using namespace DPL::DB::ORM;
335 using namespace DPL::DB::ORM::wrt;
337 const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
339 FOREACH(it, widgetConfigurationInfo.localizedDataSet)
341 const DPL::String& locale = it->first;
342 const ConfigParserData::LocalizedData& data = it->second;
344 LocalizedWidgetInfo::Row row;
345 row.Set_app_id(widgetHandle);
346 row.Set_widget_locale(locale);
347 row.Set_widget_name(data.name);
348 row.Set_widget_shortname(data.shortName);
349 row.Set_widget_description(data.description);
350 row.Set_widget_license(data.license);
351 row.Set_widget_license_file(data.licenseFile);
352 row.Set_widget_license_href(data.licenseHref);
354 DO_INSERT(row, LocalizedWidgetInfo)
358 void WidgetDAO::registerWidgetIcons(DbWidgetHandle widgetHandle,
359 const WidgetRegisterInfo ®Info)
361 using namespace DPL::DB::ORM;
362 using namespace DPL::DB::ORM::wrt;
365 FOREACH(i, regInfo.localizationData.icons)
367 wrt::WidgetIcon::icon_id::ColumnType icon_id;
369 wrt::WidgetIcon::Row row;
370 row.Set_app_id(widgetHandle);
371 row.Set_icon_src(i->src);
372 row.Set_icon_width(i->width);
373 row.Set_icon_height(i->height);
375 WRT_DB_INSERT(insert, wrt::WidgetIcon, &WrtDatabase::interface())
377 icon_id = insert->Execute();
380 FOREACH(j, i->availableLocales)
382 WidgetLocalizedIcon::Row row;
383 row.Set_app_id(widgetHandle);
384 row.Set_icon_id(icon_id);
385 row.Set_widget_locale(*j);
386 WRT_DB_SELECT(select, WidgetLocalizedIcon, &WrtDatabase::interface())
387 select->Where(And(Equals<WidgetLocalizedIcon::app_id>(widgetHandle),
388 Equals<WidgetLocalizedIcon::widget_locale>(*j)));
389 WidgetLocalizedIcon::Select::RowList rows = select->GetRowList();
391 bool flag = !rows.empty();
395 // already default icon value of same locale exists
396 WRT_DB_UPDATE(update, WidgetLocalizedIcon, &WrtDatabase::interface())
397 update->Where(And(Equals<WidgetLocalizedIcon::app_id>(widgetHandle),
398 Equals<WidgetLocalizedIcon::widget_locale>(*j)));
402 // any icon value of same locale doesn't exist
403 DO_INSERT(row, WidgetLocalizedIcon)
409 void WidgetDAO::registerWidgetStartFile(DbWidgetHandle widgetHandle,
410 const WidgetRegisterInfo ®Info)
412 using namespace DPL::DB::ORM;
413 using namespace DPL::DB::ORM::wrt;
416 FOREACH(i, regInfo.localizationData.startFiles)
418 WidgetStartFile::start_file_id::ColumnType startFileID;
420 WidgetStartFile::Row row;
421 row.Set_app_id(widgetHandle);
422 row.Set_src(i->path);
424 WRT_DB_INSERT(insert, WidgetStartFile, &WrtDatabase::interface())
426 startFileID = insert->Execute();
429 FOREACH(j, i->propertiesForLocales)
431 WidgetLocalizedStartFile::Row row;
432 row.Set_app_id(widgetHandle);
433 row.Set_start_file_id(startFileID);
434 row.Set_widget_locale(j->first);
435 row.Set_type(j->second.type);
436 row.Set_encoding(j->second.encoding);
438 DO_INSERT(row, WidgetLocalizedStartFile)
443 void WidgetDAO::registerWidgetFeatures(DbWidgetHandle widgetHandle,
444 const WidgetRegisterInfo ®Info)
446 using namespace DPL::DB::ORM;
447 const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
450 FOREACH(pWidgetFeature, widgetConfigurationInfo.featuresList)
452 wrt::WidgetFeature::Row widgetFeature;
453 widgetFeature.Set_app_id(widgetHandle);
454 widgetFeature.Set_name(pWidgetFeature->name);
455 widgetFeature.Set_required(pWidgetFeature->required);
456 widgetFeature.Set_rejected(false);
458 wrt::WidgetFeature::widget_feature_id::ColumnType widgetFeatureID;
460 WRT_DB_INSERT(insert, wrt::WidgetFeature, &WrtDatabase::interface())
461 insert->Values(widgetFeature);
462 widgetFeatureID = insert->Execute();
465 // Insert into table FeatureParam
466 wrt::FeatureParam::Row featureParam;
467 featureParam.Set_widget_feature_id(widgetFeatureID);
469 FOREACH(iter, pWidgetFeature->paramsList)
471 featureParam.Set_name(iter->name);
472 featureParam.Set_value(iter->value);
474 DO_INSERT(featureParam, wrt::FeatureParam)
479 void WidgetDAO::updateFeatureRejectStatus(const DbWidgetFeature &widgetFeature){
480 // This function could be merged with registerWidgetFeature but it requires desing change:
481 // 1. Check "ace step" in installer must be done before "update database step"
483 // ConfigurationParserData shouldn't be called "ParserData" any more.
484 using namespace DPL::DB::ORM;
486 wrt::ScopedTransaction transaction(&WrtDatabase::interface());
487 WRT_DB_SELECT(select, wrt::WidgetFeature, &WrtDatabase::interface())
488 select->Where(And(Equals<wrt::WidgetFeature::app_id>(m_widgetHandle),
489 Equals<wrt::WidgetFeature::name>(widgetFeature.name)));
491 auto row = select->GetSingleRow();
492 row.Set_rejected(widgetFeature.rejected);
494 WRT_DB_UPDATE(update, wrt::WidgetFeature, &WrtDatabase::interface())
495 update->Where(And(Equals<wrt::WidgetFeature::app_id>(m_widgetHandle),
496 Equals<wrt::WidgetFeature::name>(widgetFeature.name)));
499 transaction.Commit();
502 void WidgetDAO::registerWidgetWindowModes(DbWidgetHandle widgetHandle,
503 const WidgetRegisterInfo ®Info)
505 using namespace DPL::DB::ORM;
506 using namespace DPL::DB::ORM::wrt;
507 const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
510 FOREACH(i, widgetConfigurationInfo.windowModes)
512 wrt::WidgetWindowModes::Row windowMode;
513 windowMode.Set_app_id(widgetHandle);
514 windowMode.Set_window_mode(*i);
516 DO_INSERT(windowMode, wrt::WidgetWindowModes)
520 void WidgetDAO::registerWidgetWarpInfo(DbWidgetHandle widgetHandle,
521 const WidgetRegisterInfo ®Info)
523 using namespace DPL::DB::ORM;
524 using namespace DPL::DB::ORM::wrt;
525 const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
528 FOREACH(AccIt, widgetConfigurationInfo.accessInfoSet)
530 WidgetWARPInfo::Row row;
531 row.Set_app_id(widgetHandle);
532 row.Set_iri(AccIt->m_strIRI);
533 row.Set_subdomain_access(static_cast <int>(
534 AccIt->m_bSubDomainAccess));
536 DO_INSERT(row, WidgetWARPInfo)
540 void WidgetDAO::registerWidgetCertificates(DbWidgetHandle widgetHandle,
541 const IWacSecurity &wacSecurity)
543 using namespace DPL::DB::ORM;
544 using namespace DPL::DB::ORM::wrt;
547 FOREACH(it, wacSecurity.getCertificateList())
549 WidgetCertificateFingerprint::Row row;
550 row.Set_app_id(widgetHandle);
551 row.Set_owner(it->owner);
552 row.Set_chainid(it->chainId);
553 row.Set_type(it->type);
554 row.Set_md5_fingerprint(DPL::FromUTF8String(it->strMD5Fingerprint));
555 row.Set_sha1_fingerprint(DPL::FromUTF8String(it->strSHA1Fingerprint));
556 row.Set_common_name(it->strCommonName);
558 DO_INSERT(row, WidgetCertificateFingerprint)
562 void WidgetDAO::registerCertificatesChains(DbWidgetHandle widgetHandle,
563 CertificateSource certificateSource,
564 const CertificateChainList &certificateChainList)
566 using namespace DPL::DB::ORM;
567 using namespace DPL::DB::ORM::wrt;
568 FOREACH(certChain, certificateChainList)
570 WidgetCertificate::Row row;
571 row.Set_app_id(widgetHandle);
572 row.Set_cert_source(certificateSource);
573 row.Set_encoded_chain(DPL::FromASCIIString(*certChain));
575 DO_INSERT(row, WidgetCertificate);
579 void WidgetDAO::registerWidgetSettings(DbWidgetHandle widgetHandle,
580 const WidgetRegisterInfo ®Info)
582 using namespace DPL::DB::ORM;
583 using namespace DPL::DB::ORM::wrt;
585 const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
587 FOREACH(pWidgetSetting, widgetConfigurationInfo.settingsList)
589 SettingsList::Row row;
590 row.Set_appId(widgetHandle);
591 row.Set_settingName(pWidgetSetting->m_name);
592 row.Set_settingValue(pWidgetSetting->m_value);
594 DO_INSERT(row, SettingsList)
598 void WidgetDAO::registerAppService(DbWidgetHandle widgetHandle,
599 const WidgetRegisterInfo ®Info)
601 using namespace DPL::DB::ORM;
602 using namespace DPL::DB::ORM::wrt;
603 const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
605 FOREACH(ASIt, widgetConfigurationInfo.appServiceList)
607 ApplicationServiceInfo::Row row;
608 row.Set_app_id(widgetHandle);
609 row.Set_src(ASIt->m_src);
610 row.Set_operation(ASIt->m_operation);
611 row.Set_scheme(ASIt->m_scheme);
612 row.Set_mime(ASIt->m_mime);
614 DO_INSERT(row, ApplicationServiceInfo)
618 void WidgetDAO::registerEncryptedResouceInfo(DbWidgetHandle widgetHandle,
619 const WidgetRegisterInfo ®Info)
621 using namespace DPL::DB::ORM;
622 using namespace DPL::DB::ORM::wrt;
624 FOREACH(it, regInfo.encryptedFiles)
626 EncryptedResourceList::Row row;
627 row.Set_app_id(widgetHandle);
628 row.Set_resource(it->fileName);
629 row.Set_size(it->fileSize);
631 DO_INSERT(row, EncryptedResourceList)
635 void WidgetDAO::registerExternalLocations(const ExternalLocationList & externals)
637 registerExternalLocations(m_widgetHandle, externals);
640 void WidgetDAO::registerExternalLocations(DbWidgetHandle widgetHandle,
641 const ExternalLocationList & externals)
643 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
645 using namespace DPL::DB::ORM;
646 using namespace DPL::DB::ORM::wrt;
647 DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
648 LogDebug("Inserting external files for widgetHandle: " << widgetHandle);
649 FOREACH(it, externals)
651 WidgetExternalLocations::Row row;
652 row.Set_app_id(widgetHandle);
653 row.Set_path(DPL::FromUTF8String(*it));
655 DO_INSERT(row, WidgetExternalLocations)
657 transaction.Commit();
659 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register external files");
662 void WidgetDAO::unregisterAllExternalLocations()
664 using namespace DPL::DB::ORM;
665 using namespace DPL::DB::ORM::wrt;
666 LogDebug("Deleting external files for widgetHandle: " << m_widgetHandle);
667 WRT_DB_DELETE(del, WidgetExternalLocations, &WrtDatabase::interface());
668 del->Where(Equals<WidgetExternalLocations::app_id>(m_widgetHandle));
672 void WidgetDAO::unregisterWidget(const WidgetPkgName & pkgName)
674 LogDebug("Unregistering widget from DB. PkgName: " << pkgName);
675 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
677 DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
678 unregisterWidgetInternal(pkgName);
679 transaction.Commit();
681 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to unregister widget")
684 void WidgetDAO::unregisterWidget(WrtDB::DbWidgetHandle handle)
686 LogDebug("Unregistering widget from DB. Handle: " << handle);
687 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
689 using namespace DPL::DB::ORM;
690 using namespace DPL::DB::ORM::wrt;
691 ScopedTransaction transaction(&WrtDatabase::interface());
693 // Delete from table Widget Info
694 WRT_DB_DELETE(del, WidgetInfo, &WrtDatabase::interface())
695 del->Where(Equals<WidgetInfo::app_id>(handle));
698 transaction.Commit();
700 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to unregister widget")
703 void WidgetDAO::unregisterWidgetInternal(
704 const WidgetPkgName & pkgName)
706 using namespace DPL::DB::ORM;
707 using namespace DPL::DB::ORM::wrt;
709 DbWidgetHandle handle = getHandle(pkgName);
711 // Delete from table Widget Info
712 WRT_DB_DELETE(del, WidgetInfo, &WrtDatabase::interface())
713 del->Where(Equals<WidgetInfo::app_id>(handle));
716 // Deleting in other tables is done via "delete cascade" in SQL
721 #undef SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
722 #undef SQL_CONNECTION_EXCEPTION_HANDLER_END