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 ConfigParserData::ParamsList::const_iterator iter;
471 FOREACH(iter, pWidgetFeature->paramsList)
473 featureParam.Set_name(iter->name);
474 featureParam.Set_value(iter->value);
476 DO_INSERT(featureParam, wrt::FeatureParam)
481 void WidgetDAO::updateFeatureRejectStatus(const DbWidgetFeature &widgetFeature){
482 // This function could be merged with registerWidgetFeature but it requires desing change:
483 // 1. Check "ace step" in installer must be done before "update database step"
485 // ConfigurationParserData shouldn't be called "ParserData" any more.
486 using namespace DPL::DB::ORM;
488 wrt::ScopedTransaction transaction(&WrtDatabase::interface());
489 WRT_DB_SELECT(select, wrt::WidgetFeature, &WrtDatabase::interface())
490 select->Where(And(Equals<wrt::WidgetFeature::app_id>(m_widgetHandle),
491 Equals<wrt::WidgetFeature::name>(widgetFeature.name)));
493 auto row = select->GetSingleRow();
494 row.Set_rejected(widgetFeature.rejected);
496 WRT_DB_UPDATE(update, wrt::WidgetFeature, &WrtDatabase::interface())
497 update->Where(And(Equals<wrt::WidgetFeature::app_id>(m_widgetHandle),
498 Equals<wrt::WidgetFeature::name>(widgetFeature.name)));
501 transaction.Commit();
504 void WidgetDAO::registerWidgetWindowModes(DbWidgetHandle widgetHandle,
505 const WidgetRegisterInfo ®Info)
507 using namespace DPL::DB::ORM;
508 using namespace DPL::DB::ORM::wrt;
509 const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
512 FOREACH(i, widgetConfigurationInfo.windowModes)
514 wrt::WidgetWindowModes::Row windowMode;
515 windowMode.Set_app_id(widgetHandle);
516 windowMode.Set_window_mode(*i);
518 DO_INSERT(windowMode, wrt::WidgetWindowModes)
522 void WidgetDAO::registerWidgetWarpInfo(DbWidgetHandle widgetHandle,
523 const WidgetRegisterInfo ®Info)
525 using namespace DPL::DB::ORM;
526 using namespace DPL::DB::ORM::wrt;
527 const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
530 FOREACH(AccIt, widgetConfigurationInfo.accessInfoSet)
532 WidgetWARPInfo::Row row;
533 row.Set_app_id(widgetHandle);
534 row.Set_iri(AccIt->m_strIRI);
535 row.Set_subdomain_access(static_cast <int>(
536 AccIt->m_bSubDomainAccess));
538 DO_INSERT(row, WidgetWARPInfo)
542 void WidgetDAO::registerWidgetCertificates(DbWidgetHandle widgetHandle,
543 const IWacSecurity &wacSecurity)
545 using namespace DPL::DB::ORM;
546 using namespace DPL::DB::ORM::wrt;
549 FOREACH(it, wacSecurity.getCertificateList())
551 WidgetCertificateFingerprint::Row row;
552 row.Set_app_id(widgetHandle);
553 row.Set_owner(it->owner);
554 row.Set_chainid(it->chainId);
555 row.Set_type(it->type);
556 row.Set_md5_fingerprint(DPL::FromUTF8String(it->strMD5Fingerprint));
557 row.Set_sha1_fingerprint(DPL::FromUTF8String(it->strSHA1Fingerprint));
558 row.Set_common_name(it->strCommonName);
560 DO_INSERT(row, WidgetCertificateFingerprint)
564 void WidgetDAO::registerCertificatesChains(DbWidgetHandle widgetHandle,
565 CertificateSource certificateSource,
566 const CertificateChainList &certificateChainList)
568 using namespace DPL::DB::ORM;
569 using namespace DPL::DB::ORM::wrt;
570 FOREACH(certChain, certificateChainList)
572 WidgetCertificate::Row row;
573 row.Set_app_id(widgetHandle);
574 row.Set_cert_source(certificateSource);
575 row.Set_encoded_chain(DPL::FromASCIIString(*certChain));
577 DO_INSERT(row, WidgetCertificate);
581 void WidgetDAO::registerWidgetSettings(DbWidgetHandle widgetHandle,
582 const WidgetRegisterInfo ®Info)
584 using namespace DPL::DB::ORM;
585 using namespace DPL::DB::ORM::wrt;
587 const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
589 FOREACH(pWidgetSetting, widgetConfigurationInfo.settingsList)
591 SettingsList::Row row;
592 row.Set_appId(widgetHandle);
593 row.Set_settingName(pWidgetSetting->m_name);
594 row.Set_settingValue(pWidgetSetting->m_value);
596 DO_INSERT(row, SettingsList)
600 void WidgetDAO::registerAppService(DbWidgetHandle widgetHandle,
601 const WidgetRegisterInfo ®Info)
603 using namespace DPL::DB::ORM;
604 using namespace DPL::DB::ORM::wrt;
605 const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
607 FOREACH(ASIt, widgetConfigurationInfo.appServiceList)
609 ApplicationServiceInfo::Row row;
610 row.Set_app_id(widgetHandle);
611 row.Set_src(ASIt->m_src);
612 row.Set_operation(ASIt->m_operation);
613 row.Set_scheme(ASIt->m_scheme);
614 row.Set_mime(ASIt->m_mime);
616 DO_INSERT(row, ApplicationServiceInfo)
620 void WidgetDAO::registerEncryptedResouceInfo(DbWidgetHandle widgetHandle,
621 const WidgetRegisterInfo ®Info)
623 using namespace DPL::DB::ORM;
624 using namespace DPL::DB::ORM::wrt;
626 FOREACH(it, regInfo.encryptedFiles)
628 EncryptedResourceList::Row row;
629 row.Set_app_id(widgetHandle);
630 row.Set_resource(it->fileName);
631 row.Set_size(it->fileSize);
633 DO_INSERT(row, EncryptedResourceList)
637 void WidgetDAO::registerExternalLocations(const ExternalLocationList & externals)
639 registerExternalLocations(m_widgetHandle, externals);
642 void WidgetDAO::registerExternalLocations(DbWidgetHandle widgetHandle,
643 const ExternalLocationList & externals)
645 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
647 using namespace DPL::DB::ORM;
648 using namespace DPL::DB::ORM::wrt;
649 DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
650 LogDebug("Inserting external files for widgetHandle: " << widgetHandle);
651 FOREACH(it, externals)
653 WidgetExternalLocations::Row row;
654 row.Set_app_id(widgetHandle);
655 row.Set_path(DPL::FromUTF8String(*it));
657 DO_INSERT(row, WidgetExternalLocations)
659 transaction.Commit();
661 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register external files");
664 void WidgetDAO::unregisterAllExternalLocations()
666 using namespace DPL::DB::ORM;
667 using namespace DPL::DB::ORM::wrt;
668 LogDebug("Deleting external files for widgetHandle: " << m_widgetHandle);
669 WRT_DB_DELETE(del, WidgetExternalLocations, &WrtDatabase::interface());
670 del->Where(Equals<WidgetExternalLocations::app_id>(m_widgetHandle));
674 void WidgetDAO::unregisterWidget(const WidgetPkgName & pkgName)
676 LogDebug("Unregistering widget from DB. PkgName: " << pkgName);
677 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
679 DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
680 unregisterWidgetInternal(pkgName);
681 transaction.Commit();
683 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to unregister widget")
686 void WidgetDAO::unregisterWidget(WrtDB::DbWidgetHandle handle)
688 LogDebug("Unregistering widget from DB. Handle: " << handle);
689 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
691 using namespace DPL::DB::ORM;
692 using namespace DPL::DB::ORM::wrt;
693 ScopedTransaction transaction(&WrtDatabase::interface());
695 // Delete from table Widget Info
696 WRT_DB_DELETE(del, WidgetInfo, &WrtDatabase::interface())
697 del->Where(Equals<WidgetInfo::app_id>(handle));
700 transaction.Commit();
702 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to unregister widget")
705 void WidgetDAO::unregisterWidgetInternal(
706 const WidgetPkgName & pkgName)
708 using namespace DPL::DB::ORM;
709 using namespace DPL::DB::ORM::wrt;
711 DbWidgetHandle handle = getHandle(pkgName);
713 // Delete from table Widget Info
714 WRT_DB_DELETE(del, WidgetInfo, &WrtDatabase::interface())
715 del->Where(Equals<WidgetInfo::app_id>(handle));
718 // Deleting in other tables is done via "delete cascade" in SQL
723 #undef SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
724 #undef SQL_CONNECTION_EXCEPTION_HANDLER_END