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>
40 //TODO in current solution in each getter there exists a check
41 //"IsWidgetInstalled". Maybe it should be verified, if it could be done
42 //differently (check in WidgetDAO constructor)
44 #define SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN Try
46 #define SQL_CONNECTION_EXCEPTION_HANDLER_END(message) \
47 Catch(DPL::DB::SqlConnection::Exception::Base) { \
49 ReThrowMsg(WidgetDAO::Exception::DatabaseError, \
53 WidgetDAO::WidgetDAO(DPL::OptionalString widgetGUID) :
54 WidgetDAOReadOnly(WidgetDAOReadOnly::getHandle(widgetGUID))
57 WidgetDAO::WidgetDAO(DPL::String tzAppId) :
58 WidgetDAOReadOnly(WidgetDAOReadOnly::getHandle(tzAppId))
61 WidgetDAO::~WidgetDAO()
64 void WidgetDAO::setTizenAppId(const DPL::OptionalString& tzAppId)
66 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
68 using namespace DPL::DB::ORM;
69 wrt::ScopedTransaction transaction(&WrtDatabase::interface());
71 if (!isWidgetInstalled(getHandle())) {
72 ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
73 "Cannot find widget. Handle: " << getHandle());
76 wrt::WidgetInfo::Row row;
77 row.Set_tizen_appid(*tzAppId);
79 WRT_DB_UPDATE(update, wrt::WidgetInfo, &WrtDatabase::interface())
81 Equals<wrt::WidgetInfo::app_id>(getHandle()));
87 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register widget")
90 void WidgetDAO::registerWidget(
91 const TizenAppId & tzAppId,
92 const WidgetRegisterInfo &widgetRegInfo,
93 const IWidgetSecurity &widgetSecurity)
95 LogDebug("Registering widget");
96 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
98 DPL::DB::ORM::wrt::ScopedTransaction transaction(
99 &WrtDatabase::interface());
100 registerWidgetInternal(tzAppId, widgetRegInfo, widgetSecurity);
101 transaction.Commit();
103 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register widget")
106 void WidgetDAO::registerService(
107 const ConfigParserData::ServiceAppInfo &serviceAppInfo,
108 const WidgetRegisterInfo &widgetRegInfo,
109 const IWidgetSecurity &widgetSecurity)
111 LogDebug("Registering service");
112 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
114 DPL::DB::ORM::wrt::ScopedTransaction transaction(
115 &WrtDatabase::interface());
117 registerServiceInternal(serviceAppInfo, widgetRegInfo, widgetSecurity);
118 transaction.Commit();
120 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register service")
123 TizenAppId WidgetDAO::registerWidgetGeneratePkgId(
124 const WidgetRegisterInfo &pWidgetRegisterInfo,
125 const IWidgetSecurity &widgetSecurity)
127 TizenAppId tzAppId = generatePkgId();
128 registerWidget(tzAppId, pWidgetRegisterInfo, widgetSecurity);
132 void WidgetDAO::updateTizenAppId(
133 const TizenAppId & fromAppId,
134 const TizenAppId & toAppId)
136 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
138 using namespace DPL::DB::ORM;
139 using namespace DPL::DB::ORM::wrt;
141 ScopedTransaction transaction(&WrtDatabase::interface());
142 if (!isWidgetInstalled(fromAppId)) {
143 ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
144 "Cannot find widget. tzAppId: " << fromAppId);
147 WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
148 select->Where(Equals<WidgetInfo::tizen_appid>(fromAppId));
150 WidgetInfo::Row row = select->GetSingleRow();
152 //WidgetInfo::Row row;
153 row.Set_tizen_appid(toAppId);
155 WRT_DB_UPDATE(update, WidgetInfo, &WrtDatabase::interface())
156 update->Where(Equals<WidgetInfo::tizen_appid>(fromAppId));
160 transaction.Commit();
162 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to update appid")
165 void WidgetDAO::registerWidgetInternal(
166 const TizenAppId & tzAppId,
167 const WidgetRegisterInfo &widgetRegInfo,
168 const IWidgetSecurity &widgetSecurity,
169 const DPL::Optional<DbWidgetHandle> handle)
171 //Register into WidgetInfo has to be first
172 //as all other tables depend upon that
173 DbWidgetHandle widgetHandle = registerWidgetInfo(tzAppId, widgetRegInfo.tzPkgid, widgetRegInfo.baseFolder,
174 widgetRegInfo.webAppType.appType, widgetRegInfo.packagingType.pkgType,
175 widgetRegInfo.configInfo, widgetSecurity,handle);
177 registerWidgetExtendedInfo(widgetHandle, widgetRegInfo.installedTime,
178 widgetRegInfo.configInfo.splashImgSrc, widgetRegInfo.configInfo.backgroundPage,
179 widgetRegInfo.widgetInstalledPath);
181 registerWidgetLocalizedInfo(widgetHandle, widgetRegInfo.configInfo.localizedDataSet);
183 registerWidgetIcons(widgetHandle, widgetRegInfo.localizationData.icons);
185 registerWidgetStartFile(widgetHandle, widgetRegInfo.localizationData.startFiles);
187 PropertyDAO::RegisterProperties(widgetHandle, tzAppId, widgetRegInfo);
189 registerWidgetFeatures(widgetHandle, widgetRegInfo.configInfo.featuresList);
191 registerWidgetPrivilege(widgetHandle, widgetRegInfo.configInfo.privilegeList);
193 registerWidgetWindowModes(widgetHandle, widgetRegInfo.configInfo.windowModes);
195 registerWidgetWarpInfo(widgetHandle, widgetRegInfo.configInfo.accessInfoSet);
197 registerWidgetAllowNavigationInfo(widgetHandle, widgetRegInfo.configInfo.allowNavigationInfoList);
199 registerWidgetCertificates(widgetHandle, widgetSecurity);
201 CertificateChainList list;
202 widgetSecurity.getCertificateChainList(list, SIGNATURE_DISTRIBUTOR);
203 registerCertificatesChains(widgetHandle, SIGNATURE_DISTRIBUTOR, list);
206 widgetSecurity.getCertificateChainList(list, SIGNATURE_DISTRIBUTOR2);
207 registerCertificatesChains(widgetHandle, SIGNATURE_DISTRIBUTOR2, list);
210 widgetSecurity.getCertificateChainList(list, SIGNATURE_AUTHOR);
211 registerCertificatesChains(widgetHandle, SIGNATURE_AUTHOR, list);
213 registerWidgetSettings(widgetHandle, widgetRegInfo.configInfo.settingsList);
215 registerAppControl(widgetHandle, widgetRegInfo.configInfo.appControlList);
217 registerEncryptedResouceInfo(widgetHandle, widgetRegInfo.encryptedFiles);
219 registerExternalLocations(widgetHandle, widgetRegInfo.externalLocations);
222 #define DO_INSERT(row, table) \
224 WRT_DB_INSERT(insert, table, &WrtDatabase::interface()) \
225 insert->Values(row); \
229 void WidgetDAO::registerWidgetExtendedInfo(DbWidgetHandle widgetHandle,
230 time_t installedTime,
231 const DPL::OptionalString & splashImgSrc, const DPL::OptionalString & backgroundPage,
232 const DPL::OptionalString & widgetInstalledPath)
234 //Try and transaction not needed
235 using namespace DPL::DB::ORM;
236 using namespace DPL::DB::ORM::wrt;
238 WidgetExtendedInfo::Row row;
239 row.Set_app_id(widgetHandle);
240 row.Set_install_time(installedTime);
241 row.Set_splash_img_src(splashImgSrc);
242 row.Set_background_page(backgroundPage);
243 row.Set_installed_path(widgetInstalledPath);
245 DO_INSERT(row, WidgetExtendedInfo)
248 DbWidgetHandle WidgetDAO::registerWidgetInfo(
249 const TizenAppId & tzAppId,
250 const TizenPkgId & tzPkgId,
251 const std::string & baseFolder,
254 const ConfigParserData &widgetConfigurationInfo,
255 const IWidgetSecurity &widgetSecurity,
256 const DPL::Optional<DbWidgetHandle> handle)
258 using namespace DPL::DB::ORM;
259 using namespace DPL::DB::ORM::wrt;
260 // TODO in wrt_db all Columns in WidgetInfo have DEFAULT VALUE set.
261 // Because of that, "Optional" is not used there
265 row.Set_app_id(*handle);
268 row.Set_widget_type(appType);
269 row.Set_widget_id(widgetConfigurationInfo.widget_id);
270 row.Set_defaultlocale(widgetConfigurationInfo.defaultlocale);
271 row.Set_widget_version(widgetConfigurationInfo.version);
272 row.Set_widget_width(widgetConfigurationInfo.width);
273 row.Set_widget_height(widgetConfigurationInfo.height);
274 row.Set_author_name(widgetConfigurationInfo.authorName);
275 row.Set_author_email(widgetConfigurationInfo.authorEmail);
276 row.Set_author_href(widgetConfigurationInfo.authorHref);
277 row.Set_csp_policy(widgetConfigurationInfo.cspPolicy);
278 row.Set_csp_policy_report_only(widgetConfigurationInfo.cspPolicyReportOnly);
279 row.Set_base_folder(DPL::FromUTF8String(baseFolder));
280 row.Set_webkit_plugins_required(widgetConfigurationInfo.flashNeeded);
281 row.Set_tizen_appid(tzAppId);
282 row.Set_tizen_pkgid(tzPkgId);
284 if (!!widgetConfigurationInfo.minVersionRequired) {
285 row.Set_min_version(widgetConfigurationInfo.minVersionRequired);
286 } else if (!!widgetConfigurationInfo.tizenMinVersionRequired) {
287 row.Set_min_version(widgetConfigurationInfo.tizenMinVersionRequired);
290 row.Set_back_supported(widgetConfigurationInfo.backSupported);
291 row.Set_access_network(widgetConfigurationInfo.accessNetwork);
292 row.Set_pkg_type(pkgType);
293 row.Set_security_model_version(
294 static_cast<int>(widgetConfigurationInfo.securityModelVersion));
298 DO_INSERT(row, WidgetInfo);
300 Catch(DPL::DB::SqlConnection::Exception::Base)
302 ReThrowMsg(WidgetDAO::Exception::DatabaseError,
303 "Failed to register widget info.");
307 //get autoincremented value of widgetHandle
308 WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
309 select->Where(Equals<WidgetInfo::tizen_appid>(tzAppId));
310 return select->GetSingleValue<WidgetInfo::app_id>();
316 void WidgetDAO::registerWidgetLocalizedInfo(DbWidgetHandle widgetHandle,
317 const ConfigParserData::LocalizedDataSet &localizedDataSet)
319 using namespace DPL::DB::ORM;
320 using namespace DPL::DB::ORM::wrt;
322 FOREACH(it, localizedDataSet)
324 const DPL::String& locale = it->first;
325 const ConfigParserData::LocalizedData& data = it->second;
327 LocalizedWidgetInfo::Row row;
328 row.Set_app_id(widgetHandle);
329 row.Set_widget_locale(locale);
330 row.Set_widget_name(data.name);
331 row.Set_widget_shortname(data.shortName);
332 row.Set_widget_description(data.description);
333 row.Set_widget_license(data.license);
334 row.Set_widget_license_file(data.licenseFile);
335 row.Set_widget_license_href(data.licenseHref);
337 DO_INSERT(row, LocalizedWidgetInfo)
341 void WidgetDAO::registerWidgetIcons(DbWidgetHandle widgetHandle,
342 const WidgetRegisterInfo::LocalizedIconList &icons)
344 using namespace DPL::DB::ORM;
345 using namespace DPL::DB::ORM::wrt;
349 wrt::WidgetIcon::icon_id::ColumnType icon_id;
351 wrt::WidgetIcon::Row row;
352 row.Set_app_id(widgetHandle);
353 row.Set_icon_src(i->src);
354 row.Set_icon_width(i->width);
355 row.Set_icon_height(i->height);
357 WRT_DB_INSERT(insert, wrt::WidgetIcon, &WrtDatabase::interface())
359 icon_id = static_cast<int>(insert->Execute());
362 FOREACH(j, i->availableLocales)
364 WidgetLocalizedIcon::Row row;
365 row.Set_app_id(widgetHandle);
366 row.Set_icon_id(icon_id);
367 row.Set_widget_locale(*j);
368 DO_INSERT(row, WidgetLocalizedIcon)
373 void WidgetDAO::registerWidgetStartFile(DbWidgetHandle widgetHandle,
374 const WidgetRegisterInfo::LocalizedStartFileList &startFiles)
376 using namespace DPL::DB::ORM;
377 using namespace DPL::DB::ORM::wrt;
379 FOREACH(i, startFiles)
381 WidgetStartFile::start_file_id::ColumnType startFileID;
383 WidgetStartFile::Row row;
384 row.Set_app_id(widgetHandle);
385 row.Set_src(i->path);
387 WRT_DB_INSERT(insert, WidgetStartFile, &WrtDatabase::interface())
389 startFileID = static_cast<int>(insert->Execute());
392 FOREACH(j, i->propertiesForLocales)
394 WidgetLocalizedStartFile::Row row;
395 row.Set_app_id(widgetHandle);
396 row.Set_start_file_id(startFileID);
397 row.Set_widget_locale(j->first);
398 row.Set_type(j->second.type);
399 row.Set_encoding(j->second.encoding);
401 DO_INSERT(row, WidgetLocalizedStartFile)
406 void WidgetDAO::registerWidgetFeatures(DbWidgetHandle widgetHandle,
407 const ConfigParserData::FeaturesList &featuresList)
409 using namespace DPL::DB::ORM;
410 FOREACH(pWidgetFeature, featuresList)
412 wrt::WidgetFeature::Row widgetFeature;
413 widgetFeature.Set_app_id(widgetHandle);
414 widgetFeature.Set_name(pWidgetFeature->name);
415 widgetFeature.Set_rejected(false);
417 DO_INSERT(widgetFeature, wrt::WidgetFeature)
421 void WidgetDAO::registerWidgetPrivilege(DbWidgetHandle widgetHandle,
422 const ConfigParserData::PrivilegeList &privilegeList)
424 using namespace DPL::DB::ORM;
425 using namespace DPL::DB::ORM::wrt;
426 FOREACH(it, privilegeList)
428 WidgetPrivilege::Row widgetPrivilege;
429 widgetPrivilege.Set_app_id(widgetHandle);
430 widgetPrivilege.Set_name(it->name);
432 DO_INSERT(widgetPrivilege, WidgetPrivilege)
436 void WidgetDAO::updateFeatureRejectStatus(const DbWidgetFeature &widgetFeature)
438 // This function could be merged with registerWidgetFeature but it requires
440 // 1. Check "ace step" in installer must be done before "update database
443 // ConfigurationParserData shouldn't be called "ParserData" any more.
444 using namespace DPL::DB::ORM;
446 wrt::ScopedTransaction transaction(&WrtDatabase::interface());
447 WRT_DB_SELECT(select, wrt::WidgetFeature, &WrtDatabase::interface())
448 select->Where(And(Equals<wrt::WidgetFeature::app_id>(m_widgetHandle),
449 Equals<wrt::WidgetFeature::name>(widgetFeature.name)));
451 auto row = select->GetSingleRow();
452 row.Set_rejected(widgetFeature.rejected);
454 WRT_DB_UPDATE(update, wrt::WidgetFeature, &WrtDatabase::interface())
455 update->Where(And(Equals<wrt::WidgetFeature::app_id>(m_widgetHandle),
456 Equals<wrt::WidgetFeature::name>(widgetFeature.name)));
459 transaction.Commit();
462 void WidgetDAO::registerWidgetWindowModes(DbWidgetHandle widgetHandle,
463 const ConfigParserData::StringsList &windowModes)
465 using namespace DPL::DB::ORM;
466 using namespace DPL::DB::ORM::wrt;
467 FOREACH(i, windowModes)
469 wrt::WidgetWindowModes::Row windowMode;
470 windowMode.Set_app_id(widgetHandle);
471 windowMode.Set_window_mode(*i);
473 DO_INSERT(windowMode, wrt::WidgetWindowModes)
477 void WidgetDAO::registerWidgetWarpInfo(DbWidgetHandle widgetHandle,
478 const ConfigParserData::AccessInfoSet &accessInfoSet)
480 using namespace DPL::DB::ORM;
481 using namespace DPL::DB::ORM::wrt;
482 FOREACH(AccIt, accessInfoSet)
484 WidgetWARPInfo::Row row;
485 row.Set_app_id(widgetHandle);
486 row.Set_iri(AccIt->m_strIRI);
487 row.Set_subdomain_access(static_cast <int>(
488 AccIt->m_bSubDomainAccess));
490 DO_INSERT(row, WidgetWARPInfo)
494 void WidgetDAO::registerWidgetAllowNavigationInfo(DbWidgetHandle widgetHandle,
495 const ConfigParserData::AllowNavigationInfoList &allowNavigationInfoList)
497 using namespace DPL::DB::ORM;
498 using namespace DPL::DB::ORM::wrt;
499 FOREACH(allowNaviIt, allowNavigationInfoList)
501 WidgetAllowNavigation::Row row;
502 row.Set_app_id(widgetHandle);
503 row.Set_scheme(allowNaviIt->m_scheme);
504 row.Set_host(allowNaviIt->m_host);
505 DO_INSERT(row, WidgetAllowNavigation)
509 void WidgetDAO::registerWidgetCertificates(DbWidgetHandle widgetHandle,
510 const IWidgetSecurity &widgetSecurity)
512 using namespace DPL::DB::ORM;
513 using namespace DPL::DB::ORM::wrt;
515 FOREACH(it, widgetSecurity.getCertificateList())
517 WidgetCertificateFingerprint::Row row;
518 row.Set_app_id(widgetHandle);
519 row.Set_owner(it->owner);
520 row.Set_chainid(it->chainId);
521 row.Set_type(it->type);
522 row.Set_md5_fingerprint(DPL::FromUTF8String(it->strMD5Fingerprint));
523 row.Set_sha1_fingerprint(DPL::FromUTF8String(it->strSHA1Fingerprint));
524 row.Set_common_name(it->strCommonName);
526 DO_INSERT(row, WidgetCertificateFingerprint)
530 void WidgetDAO::registerCertificatesChains(
531 DbWidgetHandle widgetHandle,
532 CertificateSource certificateSource,
533 const CertificateChainList &
534 certificateChainList)
536 using namespace DPL::DB::ORM;
537 using namespace DPL::DB::ORM::wrt;
538 FOREACH(certChain, certificateChainList)
540 WidgetCertificate::Row row;
541 row.Set_app_id(widgetHandle);
542 row.Set_cert_source(certificateSource);
543 row.Set_encoded_chain(DPL::FromASCIIString(*certChain));
545 DO_INSERT(row, WidgetCertificate);
549 void WidgetDAO::registerWidgetSettings(DbWidgetHandle widgetHandle,
550 const ConfigParserData::SettingsList &settingsList)
552 using namespace DPL::DB::ORM;
553 using namespace DPL::DB::ORM::wrt;
555 FOREACH(pWidgetSetting, settingsList)
557 SettingsList::Row row;
558 row.Set_appId(widgetHandle);
559 row.Set_settingName(pWidgetSetting->m_name);
560 row.Set_settingValue(pWidgetSetting->m_value);
562 DO_INSERT(row, SettingsList)
566 void WidgetDAO::insertAppControlInfo(DbWidgetHandle handle,
568 DPL::String operation,
572 unsigned disposition)
574 using namespace DPL::DB::ORM;
575 using namespace DPL::DB::ORM::wrt;
577 AppControlInfo::Row row;
579 row.Set_app_id(handle);
580 row.Set_execute_index(index);
582 row.Set_operation(operation);
585 row.Set_disposition(disposition);
587 DO_INSERT(row, AppControlInfo);
590 void WidgetDAO::registerAppControl(DbWidgetHandle widgetHandle,
591 const ConfigParserData::AppControlInfoList &appControlList)
593 using namespace DPL::DB::ORM;
594 using namespace DPL::DB::ORM::wrt;
597 FOREACH(appControl_it, appControlList)
599 DPL::String src = appControl_it->m_src;
600 DPL::String operation = appControl_it->m_operation;
601 unsigned index = appControl_it->m_index;
602 unsigned disposition =
603 static_cast<unsigned>(appControl_it->m_disposition);
605 if (!appControl_it->m_uriList.empty())
607 FOREACH(uri_it, appControl_it->m_uriList)
609 DPL::String uri = *uri_it;
611 if (!appControl_it->m_mimeList.empty())
613 FOREACH(mime_it, appControl_it->m_mimeList)
615 DPL::String mime = *mime_it;
617 insertAppControlInfo(widgetHandle, src, operation, uri, mime, index, disposition);
622 DPL::String mime = L"";
624 insertAppControlInfo(widgetHandle, src, operation, uri, mime, index, disposition);
630 DPL::String uri = L"";
632 if (!appControl_it->m_mimeList.empty())
634 FOREACH(mime_it, appControl_it->m_mimeList)
636 DPL::String mime = *mime_it;
638 insertAppControlInfo(widgetHandle, src, operation, uri, mime, index, disposition);
643 DPL::String mime = L"";
645 insertAppControlInfo(widgetHandle, src, operation, uri, mime, index, disposition);
651 void WidgetDAO::registerEncryptedResouceInfo(DbWidgetHandle widgetHandle,
652 const EncryptedFileList &encryptedFiles)
654 using namespace DPL::DB::ORM;
655 using namespace DPL::DB::ORM::wrt;
657 FOREACH(it, encryptedFiles)
659 EncryptedResourceList::Row row;
660 row.Set_app_id(widgetHandle);
661 row.Set_resource(it->fileName);
662 row.Set_size(it->fileSize);
664 DO_INSERT(row, EncryptedResourceList)
668 void WidgetDAO::registerServiceInternal(const ConfigParserData::ServiceAppInfo &serviceAppInfo, const WidgetRegisterInfo &widgetRegInfo, const IWidgetSecurity &widgetSecurity)
670 using namespace DPL::DB::ORM;
671 using namespace DPL::DB::ORM::wrt;
673 DPL::String tzAppId = serviceAppInfo.serviceId;
676 DbWidgetHandle widgetHandle = registerWidgetInfo(tzAppId, widgetRegInfo.tzPkgid, widgetRegInfo.baseFolder,
677 APP_TYPE_TIZENWEBSERVICE, widgetRegInfo.packagingType.pkgType,
678 widgetRegInfo.configInfo, widgetSecurity);
680 registerWidgetExtendedInfo(widgetHandle, widgetRegInfo.installedTime,
681 widgetRegInfo.configInfo.splashImgSrc, widgetRegInfo.configInfo.backgroundPage,
682 widgetRegInfo.widgetInstalledPath);
684 registerWidgetLocalizedInfo(widgetHandle, serviceAppInfo.m_localizedDataSet);
687 WidgetRegisterInfo::LocalizedIconList iconList;
689 FOREACH(it, serviceAppInfo.m_iconsList) {
690 iconList.push_back(WidgetRegisterInfo::LocalizedIcon(*it, localeSet));
692 registerWidgetIcons(widgetHandle, iconList);
694 WidgetRegisterInfo::LocalizedStartFileList startFileList;
695 WidgetRegisterInfo::LocalizedStartFile startFile;
696 WidgetRegisterInfo::StartFileProperties startFileProperties;
697 startFile.path = serviceAppInfo.serviceContent;
698 startFileProperties.type = L"";
699 startFileProperties.encoding = L"UTF-8";
700 startFile.propertiesForLocales[L""] = startFileProperties;
701 startFileList.push_back(startFile);
702 registerWidgetStartFile(widgetHandle, startFileList);
705 PropertyDAO::RegisterProperties(widgetHandle, tzAppId, widgetRegInfo);
707 registerWidgetFeatures(widgetHandle, widgetRegInfo.configInfo.featuresList);
709 registerWidgetPrivilege(widgetHandle, widgetRegInfo.configInfo.privilegeList);
711 registerWidgetWindowModes(widgetHandle, widgetRegInfo.configInfo.windowModes);
713 registerWidgetWarpInfo(widgetHandle, widgetRegInfo.configInfo.accessInfoSet);
715 registerWidgetAllowNavigationInfo(widgetHandle, widgetRegInfo.configInfo.allowNavigationInfoList);
717 registerWidgetCertificates(widgetHandle, widgetSecurity);
719 CertificateChainList list;
720 widgetSecurity.getCertificateChainList(list, SIGNATURE_DISTRIBUTOR);
721 registerCertificatesChains(widgetHandle, SIGNATURE_DISTRIBUTOR, list);
724 widgetSecurity.getCertificateChainList(list, SIGNATURE_AUTHOR);
725 registerCertificatesChains(widgetHandle, SIGNATURE_AUTHOR, list);
727 registerWidgetSettings(widgetHandle, widgetRegInfo.configInfo.settingsList);
729 registerEncryptedResouceInfo(widgetHandle, widgetRegInfo.encryptedFiles);
731 registerExternalLocations(widgetHandle, widgetRegInfo.externalLocations);
734 void WidgetDAO::registerExternalLocations(
735 DbWidgetHandle widgetHandle,
736 const ExternalLocationList &
739 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
741 using namespace DPL::DB::ORM;
742 using namespace DPL::DB::ORM::wrt;
743 DPL::DB::ORM::wrt::ScopedTransaction transaction(
744 &WrtDatabase::interface());
745 LogDebug("Inserting external files for widgetHandle: " << widgetHandle);
746 FOREACH(it, externals)
748 WidgetExternalLocations::Row row;
749 row.Set_app_id(widgetHandle);
750 row.Set_path(DPL::FromUTF8String(*it));
752 DO_INSERT(row, WidgetExternalLocations)
754 transaction.Commit();
756 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register external files");
759 void WidgetDAO::unregisterAllExternalLocations()
761 using namespace DPL::DB::ORM;
762 using namespace DPL::DB::ORM::wrt;
763 LogDebug("Deleting external files for widgetHandle: " << m_widgetHandle);
764 WRT_DB_DELETE(del, WidgetExternalLocations, &WrtDatabase::interface());
765 del->Where(Equals<WidgetExternalLocations::app_id>(m_widgetHandle));
769 void WidgetDAO::unregisterWidget(const TizenAppId & tzAppId)
771 LogDebug("Unregistering widget from DB. tzAppId: " << tzAppId);
772 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
774 DPL::DB::ORM::wrt::ScopedTransaction transaction(
775 &WrtDatabase::interface());
776 unregisterWidgetInternal(tzAppId);
777 transaction.Commit();
779 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to unregister widget")
782 void WidgetDAO::unregisterWidgetInternal(
783 const TizenAppId & tzAppId)
785 using namespace DPL::DB::ORM;
786 using namespace DPL::DB::ORM::wrt;
788 DbWidgetHandle handle = getHandle(tzAppId);
790 // Delete from table Widget Info
791 WRT_DB_DELETE(del, WidgetInfo, &WrtDatabase::interface())
792 del->Where(Equals<WidgetInfo::app_id>(handle));
795 // Deleting in other tables is done via "delete cascade" in SQL
800 #undef SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
801 #undef SQL_CONNECTION_EXCEPTION_HANDLER_END