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);
284 if (regInfo.webAppType == APP_TYPE_UNKNOWN && regInfo.type !=
286 // TODO : regInfo.type is temporary code for security.
287 // This code will be removed.
288 row.Set_widget_type(regInfo.type.appType);
290 row.Set_widget_type(regInfo.webAppType.appType);
292 row.Set_widget_id(widgetConfigurationInfo.widget_id);
293 row.Set_defaultlocale(widgetConfigurationInfo.defaultlocale);
294 row.Set_widget_version(widgetConfigurationInfo.version);
295 row.Set_widget_width(widgetConfigurationInfo.width);
296 row.Set_widget_height(widgetConfigurationInfo.height);
297 row.Set_author_name(widgetConfigurationInfo.authorName);
298 row.Set_author_email(widgetConfigurationInfo.authorEmail);
299 row.Set_author_href(widgetConfigurationInfo.authorHref);
300 row.Set_base_folder(DPL::FromUTF8String(regInfo.baseFolder));
301 row.Set_webkit_plugins_required(widgetConfigurationInfo.flashNeeded);
302 row.Set_recognized(wacSecurity.isRecognized());
303 row.Set_wac_signed(wacSecurity.isWacSigned());
304 row.Set_distributor_signed(wacSecurity.isDistributorSigned());
305 row.Set_pkgname(widgetName);
307 std::stringstream tmp;
308 tmp << regInfo.minVersion;
309 row.Set_min_version(DPL::FromUTF8String(tmp.str()));
311 row.Set_back_supported(widgetConfigurationInfo.backSupported);
312 row.Set_access_network(widgetConfigurationInfo.accessNetwork);
313 row.Set_pkgname(regInfo.pkgname);
314 row.Set_pkg_type(regInfo.packagingType.pkgType);
318 DO_INSERT(row, WidgetInfo);
320 Catch(DPL::DB::SqlConnection::Exception::Base)
322 ReThrowMsg(WidgetDAO::Exception::DatabaseError,
323 "Failed to register widget info.");
328 //get autoincremented value of widgetHandle
329 WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
330 select->Where(Equals<WidgetInfo::pkgname>(widgetName));
331 return select->GetSingleValue<WidgetInfo::app_id>();
339 void WidgetDAO::registerWidgetLocalizedInfo(DbWidgetHandle widgetHandle,
340 const WidgetRegisterInfo ®Info)
342 using namespace DPL::DB::ORM;
343 using namespace DPL::DB::ORM::wrt;
345 const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
347 FOREACH(it, widgetConfigurationInfo.localizedDataSet)
349 const DPL::String& locale = it->first;
350 const ConfigParserData::LocalizedData& data = it->second;
352 LocalizedWidgetInfo::Row row;
353 row.Set_app_id(widgetHandle);
354 row.Set_widget_locale(locale);
355 row.Set_widget_name(data.name);
356 row.Set_widget_shortname(data.shortName);
357 row.Set_widget_description(data.description);
358 row.Set_widget_license(data.license);
359 row.Set_widget_license_file(data.licenseFile);
360 row.Set_widget_license_href(data.licenseHref);
362 DO_INSERT(row, LocalizedWidgetInfo)
366 void WidgetDAO::registerWidgetIcons(DbWidgetHandle widgetHandle,
367 const WidgetRegisterInfo ®Info)
369 using namespace DPL::DB::ORM;
370 using namespace DPL::DB::ORM::wrt;
373 FOREACH(i, regInfo.localizationData.icons)
375 wrt::WidgetIcon::icon_id::ColumnType icon_id;
377 wrt::WidgetIcon::Row row;
378 row.Set_app_id(widgetHandle);
379 row.Set_icon_src(i->src);
380 row.Set_icon_width(i->width);
381 row.Set_icon_height(i->height);
383 WRT_DB_INSERT(insert, wrt::WidgetIcon, &WrtDatabase::interface())
385 icon_id = insert->Execute();
388 FOREACH(j, i->availableLocales)
390 WidgetLocalizedIcon::Row row;
391 row.Set_app_id(widgetHandle);
392 row.Set_icon_id(icon_id);
393 row.Set_widget_locale(*j);
394 WRT_DB_SELECT(select, WidgetLocalizedIcon, &WrtDatabase::interface())
395 select->Where(And(Equals<WidgetLocalizedIcon::app_id>(widgetHandle),
396 Equals<WidgetLocalizedIcon::widget_locale>(*j)));
397 WidgetLocalizedIcon::Select::RowList rows = select->GetRowList();
399 bool flag = !rows.empty();
403 // already default icon value of same locale exists
404 WRT_DB_UPDATE(update, WidgetLocalizedIcon, &WrtDatabase::interface())
405 update->Where(And(Equals<WidgetLocalizedIcon::app_id>(widgetHandle),
406 Equals<WidgetLocalizedIcon::widget_locale>(*j)));
410 // any icon value of same locale doesn't exist
411 DO_INSERT(row, WidgetLocalizedIcon)
417 void WidgetDAO::registerWidgetStartFile(DbWidgetHandle widgetHandle,
418 const WidgetRegisterInfo ®Info)
420 using namespace DPL::DB::ORM;
421 using namespace DPL::DB::ORM::wrt;
424 FOREACH(i, regInfo.localizationData.startFiles)
426 WidgetStartFile::start_file_id::ColumnType startFileID;
428 WidgetStartFile::Row row;
429 row.Set_app_id(widgetHandle);
430 row.Set_src(i->path);
432 WRT_DB_INSERT(insert, WidgetStartFile, &WrtDatabase::interface())
434 startFileID = insert->Execute();
437 FOREACH(j, i->propertiesForLocales)
439 WidgetLocalizedStartFile::Row row;
440 row.Set_app_id(widgetHandle);
441 row.Set_start_file_id(startFileID);
442 row.Set_widget_locale(j->first);
443 row.Set_type(j->second.type);
444 row.Set_encoding(j->second.encoding);
446 DO_INSERT(row, WidgetLocalizedStartFile)
451 void WidgetDAO::registerWidgetFeatures(DbWidgetHandle widgetHandle,
452 const WidgetRegisterInfo ®Info)
454 using namespace DPL::DB::ORM;
455 const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
458 FOREACH(pWidgetFeature, widgetConfigurationInfo.featuresList)
460 wrt::WidgetFeature::Row widgetFeature;
461 widgetFeature.Set_app_id(widgetHandle);
462 widgetFeature.Set_name(pWidgetFeature->name);
463 widgetFeature.Set_required(pWidgetFeature->required);
464 widgetFeature.Set_rejected(false);
466 wrt::WidgetFeature::widget_feature_id::ColumnType widgetFeatureID;
468 WRT_DB_INSERT(insert, wrt::WidgetFeature, &WrtDatabase::interface())
469 insert->Values(widgetFeature);
470 widgetFeatureID = insert->Execute();
473 // Insert into table FeatureParam
474 wrt::FeatureParam::Row featureParam;
475 featureParam.Set_widget_feature_id(widgetFeatureID);
477 FOREACH(iter, pWidgetFeature->paramsList)
479 featureParam.Set_name(iter->name);
480 featureParam.Set_value(iter->value);
482 DO_INSERT(featureParam, wrt::FeatureParam)
487 void WidgetDAO::updateFeatureRejectStatus(const DbWidgetFeature &widgetFeature){
488 // This function could be merged with registerWidgetFeature but it requires desing change:
489 // 1. Check "ace step" in installer must be done before "update database step"
491 // ConfigurationParserData shouldn't be called "ParserData" any more.
492 using namespace DPL::DB::ORM;
494 wrt::ScopedTransaction transaction(&WrtDatabase::interface());
495 WRT_DB_SELECT(select, wrt::WidgetFeature, &WrtDatabase::interface())
496 select->Where(And(Equals<wrt::WidgetFeature::app_id>(m_widgetHandle),
497 Equals<wrt::WidgetFeature::name>(widgetFeature.name)));
499 auto row = select->GetSingleRow();
500 row.Set_rejected(widgetFeature.rejected);
502 WRT_DB_UPDATE(update, wrt::WidgetFeature, &WrtDatabase::interface())
503 update->Where(And(Equals<wrt::WidgetFeature::app_id>(m_widgetHandle),
504 Equals<wrt::WidgetFeature::name>(widgetFeature.name)));
507 transaction.Commit();
510 void WidgetDAO::registerWidgetWindowModes(DbWidgetHandle widgetHandle,
511 const WidgetRegisterInfo ®Info)
513 using namespace DPL::DB::ORM;
514 using namespace DPL::DB::ORM::wrt;
515 const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
518 FOREACH(i, widgetConfigurationInfo.windowModes)
520 wrt::WidgetWindowModes::Row windowMode;
521 windowMode.Set_app_id(widgetHandle);
522 windowMode.Set_window_mode(*i);
524 DO_INSERT(windowMode, wrt::WidgetWindowModes)
528 void WidgetDAO::registerWidgetWarpInfo(DbWidgetHandle widgetHandle,
529 const WidgetRegisterInfo ®Info)
531 using namespace DPL::DB::ORM;
532 using namespace DPL::DB::ORM::wrt;
533 const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
536 FOREACH(AccIt, widgetConfigurationInfo.accessInfoSet)
538 WidgetWARPInfo::Row row;
539 row.Set_app_id(widgetHandle);
540 row.Set_iri(AccIt->m_strIRI);
541 row.Set_subdomain_access(static_cast <int>(
542 AccIt->m_bSubDomainAccess));
544 DO_INSERT(row, WidgetWARPInfo)
548 void WidgetDAO::registerWidgetCertificates(DbWidgetHandle widgetHandle,
549 const IWacSecurity &wacSecurity)
551 using namespace DPL::DB::ORM;
552 using namespace DPL::DB::ORM::wrt;
555 FOREACH(it, wacSecurity.getCertificateList())
557 WidgetCertificateFingerprint::Row row;
558 row.Set_app_id(widgetHandle);
559 row.Set_owner(it->owner);
560 row.Set_chainid(it->chainId);
561 row.Set_type(it->type);
562 row.Set_md5_fingerprint(DPL::FromUTF8String(it->strMD5Fingerprint));
563 row.Set_sha1_fingerprint(DPL::FromUTF8String(it->strSHA1Fingerprint));
564 row.Set_common_name(it->strCommonName);
566 DO_INSERT(row, WidgetCertificateFingerprint)
570 void WidgetDAO::registerCertificatesChains(DbWidgetHandle widgetHandle,
571 CertificateSource certificateSource,
572 const CertificateChainList &certificateChainList)
574 using namespace DPL::DB::ORM;
575 using namespace DPL::DB::ORM::wrt;
576 FOREACH(certChain, certificateChainList)
578 WidgetCertificate::Row row;
579 row.Set_app_id(widgetHandle);
580 row.Set_cert_source(certificateSource);
581 row.Set_encoded_chain(DPL::FromASCIIString(*certChain));
583 DO_INSERT(row, WidgetCertificate);
587 void WidgetDAO::registerWidgetSettings(DbWidgetHandle widgetHandle,
588 const WidgetRegisterInfo ®Info)
590 using namespace DPL::DB::ORM;
591 using namespace DPL::DB::ORM::wrt;
593 const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
595 FOREACH(pWidgetSetting, widgetConfigurationInfo.settingsList)
597 SettingsList::Row row;
598 row.Set_appId(widgetHandle);
599 row.Set_settingName(pWidgetSetting->m_name);
600 row.Set_settingValue(pWidgetSetting->m_value);
602 DO_INSERT(row, SettingsList)
606 void WidgetDAO::registerAppService(DbWidgetHandle widgetHandle,
607 const WidgetRegisterInfo ®Info)
609 using namespace DPL::DB::ORM;
610 using namespace DPL::DB::ORM::wrt;
611 const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
613 FOREACH(ASIt, widgetConfigurationInfo.appServiceList)
615 ApplicationServiceInfo::Row row;
616 row.Set_app_id(widgetHandle);
617 row.Set_src(ASIt->m_src);
618 row.Set_operation(ASIt->m_operation);
619 row.Set_scheme(ASIt->m_scheme);
620 row.Set_mime(ASIt->m_mime);
622 DO_INSERT(row, ApplicationServiceInfo)
626 void WidgetDAO::registerEncryptedResouceInfo(DbWidgetHandle widgetHandle,
627 const WidgetRegisterInfo ®Info)
629 using namespace DPL::DB::ORM;
630 using namespace DPL::DB::ORM::wrt;
632 FOREACH(it, regInfo.encryptedFiles)
634 EncryptedResourceList::Row row;
635 row.Set_app_id(widgetHandle);
636 row.Set_resource(it->fileName);
637 row.Set_size(it->fileSize);
639 DO_INSERT(row, EncryptedResourceList)
643 void WidgetDAO::registerExternalLocations(const ExternalLocationList & externals)
645 registerExternalLocations(m_widgetHandle, externals);
648 void WidgetDAO::registerExternalLocations(DbWidgetHandle widgetHandle,
649 const ExternalLocationList & externals)
651 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
653 using namespace DPL::DB::ORM;
654 using namespace DPL::DB::ORM::wrt;
655 DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
656 LogDebug("Inserting external files for widgetHandle: " << widgetHandle);
657 FOREACH(it, externals)
659 WidgetExternalLocations::Row row;
660 row.Set_app_id(widgetHandle);
661 row.Set_path(DPL::FromUTF8String(*it));
663 DO_INSERT(row, WidgetExternalLocations)
665 transaction.Commit();
667 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register external files");
670 void WidgetDAO::unregisterAllExternalLocations()
672 using namespace DPL::DB::ORM;
673 using namespace DPL::DB::ORM::wrt;
674 LogDebug("Deleting external files for widgetHandle: " << m_widgetHandle);
675 WRT_DB_DELETE(del, WidgetExternalLocations, &WrtDatabase::interface());
676 del->Where(Equals<WidgetExternalLocations::app_id>(m_widgetHandle));
680 void WidgetDAO::unregisterWidget(const WidgetPkgName & pkgName)
682 LogDebug("Unregistering widget from DB. PkgName: " << pkgName);
683 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
685 DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
686 unregisterWidgetInternal(pkgName);
687 transaction.Commit();
689 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to unregister widget")
692 void WidgetDAO::unregisterWidget(WrtDB::DbWidgetHandle handle)
694 LogDebug("Unregistering widget from DB. Handle: " << handle);
695 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
697 using namespace DPL::DB::ORM;
698 using namespace DPL::DB::ORM::wrt;
699 ScopedTransaction transaction(&WrtDatabase::interface());
701 // Delete from table Widget Info
702 WRT_DB_DELETE(del, WidgetInfo, &WrtDatabase::interface())
703 del->Where(Equals<WidgetInfo::app_id>(handle));
706 transaction.Commit();
708 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to unregister widget")
711 void WidgetDAO::unregisterWidgetInternal(
712 const WidgetPkgName & pkgName)
714 using namespace DPL::DB::ORM;
715 using namespace DPL::DB::ORM::wrt;
717 DbWidgetHandle handle = getHandle(pkgName);
719 // Delete from table Widget Info
720 WRT_DB_DELETE(del, WidgetInfo, &WrtDatabase::interface())
721 del->Where(Equals<WidgetInfo::app_id>(handle));
724 // Deleting in other tables is done via "delete cascade" in SQL
729 #undef SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
730 #undef SQL_CONNECTION_EXCEPTION_HANDLER_END