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")
124 TizenAppId WidgetDAO::registerWidgetGeneratePkgId(
125 const WidgetRegisterInfo &pWidgetRegisterInfo,
126 const IWidgetSecurity &widgetSecurity)
128 TizenAppId tzAppId = generatePkgId();
129 registerWidget(tzAppId, pWidgetRegisterInfo, widgetSecurity);
133 void WidgetDAO::updateTizenAppId(
134 const TizenAppId & fromAppId,
135 const TizenAppId & toAppId)
137 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
139 using namespace DPL::DB::ORM;
140 using namespace DPL::DB::ORM::wrt;
142 ScopedTransaction transaction(&WrtDatabase::interface());
143 if (!isWidgetInstalled(fromAppId)) {
144 ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
145 "Cannot find widget. tzAppId: " << fromAppId);
148 WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
149 select->Where(Equals<WidgetInfo::tizen_appid>(fromAppId));
151 WidgetInfo::Row row = select->GetSingleRow();
153 //WidgetInfo::Row row;
154 row.Set_tizen_appid(toAppId);
156 WRT_DB_UPDATE(update, WidgetInfo, &WrtDatabase::interface())
157 update->Where(Equals<WidgetInfo::tizen_appid>(fromAppId));
161 transaction.Commit();
163 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to update appid")
166 void WidgetDAO::registerWidgetInternal(
167 const TizenAppId & tzAppId,
168 const WidgetRegisterInfo &widgetRegInfo,
169 const IWidgetSecurity &widgetSecurity,
170 const DPL::Optional<DbWidgetHandle> handle)
172 //Register into WidgetInfo has to be first
173 //as all other tables depend upon that
174 DbWidgetHandle widgetHandle = registerWidgetInfo(tzAppId, widgetRegInfo.tzPkgid, widgetRegInfo.baseFolder,
175 widgetRegInfo.webAppType.appType, widgetRegInfo.packagingType.pkgType,
176 widgetRegInfo.configInfo, widgetSecurity,handle);
178 registerWidgetExtendedInfo(widgetHandle, widgetRegInfo.installedTime,
179 widgetRegInfo.configInfo.splashImgSrc, widgetRegInfo.configInfo.backgroundPage,
180 widgetRegInfo.widgetInstalledPath);
182 registerWidgetLocalizedInfo(widgetHandle, widgetRegInfo.configInfo.localizedDataSet);
184 registerWidgetIcons(widgetHandle, widgetRegInfo.localizationData.icons);
186 registerWidgetStartFile(widgetHandle, widgetRegInfo.localizationData.startFiles);
188 PropertyDAO::RegisterProperties(widgetHandle, tzAppId, widgetRegInfo);
190 registerWidgetFeatures(widgetHandle, widgetRegInfo.configInfo.featuresList);
192 registerWidgetPrivilege(widgetHandle, widgetRegInfo.configInfo.privilegeList);
194 registerWidgetWindowModes(widgetHandle, widgetRegInfo.configInfo.windowModes);
196 registerWidgetWarpInfo(widgetHandle, widgetRegInfo.configInfo.accessInfoSet);
198 registerWidgetAllowNavigationInfo(widgetHandle, widgetRegInfo.configInfo.allowNavigationInfoList);
200 registerWidgetCertificates(widgetHandle, widgetSecurity);
202 CertificateChainList list;
203 widgetSecurity.getCertificateChainList(list, SIGNATURE_DISTRIBUTOR);
204 registerCertificatesChains(widgetHandle, SIGNATURE_DISTRIBUTOR, list);
207 widgetSecurity.getCertificateChainList(list, SIGNATURE_DISTRIBUTOR2);
208 registerCertificatesChains(widgetHandle, SIGNATURE_DISTRIBUTOR2, list);
211 widgetSecurity.getCertificateChainList(list, SIGNATURE_AUTHOR);
212 registerCertificatesChains(widgetHandle, SIGNATURE_AUTHOR, list);
214 registerWidgetSettings(widgetHandle, widgetRegInfo.configInfo.settingsList);
216 registerAppControl(widgetHandle, widgetRegInfo.configInfo.appControlList);
218 registerEncryptedResouceInfo(widgetHandle, widgetRegInfo.encryptedFiles);
220 registerExternalLocations(widgetHandle, widgetRegInfo.externalLocations);
223 #define DO_INSERT(row, table) \
225 WRT_DB_INSERT(insert, table, &WrtDatabase::interface()) \
226 insert->Values(row); \
230 void WidgetDAO::registerWidgetExtendedInfo(DbWidgetHandle widgetHandle,
231 time_t installedTime,
232 const DPL::OptionalString & splashImgSrc, const DPL::OptionalString & backgroundPage,
233 const DPL::OptionalString & widgetInstalledPath)
235 //Try and transaction not needed
236 using namespace DPL::DB::ORM;
237 using namespace DPL::DB::ORM::wrt;
239 WidgetExtendedInfo::Row row;
240 row.Set_app_id(widgetHandle);
241 row.Set_install_time(installedTime);
242 row.Set_splash_img_src(splashImgSrc);
243 row.Set_background_page(backgroundPage);
244 row.Set_installed_path(widgetInstalledPath);
246 DO_INSERT(row, WidgetExtendedInfo)
249 DbWidgetHandle WidgetDAO::registerWidgetInfo(
250 const TizenAppId & tzAppId,
251 const TizenPkgId & tzPkgId,
252 const std::string & baseFolder,
255 const ConfigParserData &widgetConfigurationInfo,
256 const IWidgetSecurity &widgetSecurity,
257 const DPL::Optional<DbWidgetHandle> handle)
259 using namespace DPL::DB::ORM;
260 using namespace DPL::DB::ORM::wrt;
261 // TODO in wrt_db all Columns in WidgetInfo have DEFAULT VALUE set.
262 // Because of that, "Optional" is not used there
266 row.Set_app_id(*handle);
269 row.Set_widget_type(appType);
270 row.Set_widget_id(widgetConfigurationInfo.widget_id);
271 row.Set_defaultlocale(widgetConfigurationInfo.defaultlocale);
272 row.Set_widget_version(widgetConfigurationInfo.version);
273 row.Set_widget_width(widgetConfigurationInfo.width);
274 row.Set_widget_height(widgetConfigurationInfo.height);
275 row.Set_author_name(widgetConfigurationInfo.authorName);
276 row.Set_author_email(widgetConfigurationInfo.authorEmail);
277 row.Set_author_href(widgetConfigurationInfo.authorHref);
278 row.Set_csp_policy(widgetConfigurationInfo.cspPolicy);
279 row.Set_csp_policy_report_only(widgetConfigurationInfo.cspPolicyReportOnly);
280 row.Set_base_folder(DPL::FromUTF8String(baseFolder));
281 row.Set_webkit_plugins_required(widgetConfigurationInfo.flashNeeded);
282 row.Set_tizen_appid(tzAppId);
283 row.Set_tizen_pkgid(tzPkgId);
285 if (!!widgetConfigurationInfo.minVersionRequired) {
286 row.Set_min_version(widgetConfigurationInfo.minVersionRequired);
287 } else if (!!widgetConfigurationInfo.tizenMinVersionRequired) {
288 row.Set_min_version(widgetConfigurationInfo.tizenMinVersionRequired);
291 row.Set_back_supported(widgetConfigurationInfo.backSupported);
292 row.Set_access_network(widgetConfigurationInfo.accessNetwork);
293 row.Set_pkg_type(pkgType);
294 row.Set_security_model_version(
295 static_cast<int>(widgetConfigurationInfo.securityModelVersion));
299 DO_INSERT(row, WidgetInfo);
301 Catch(DPL::DB::SqlConnection::Exception::Base)
303 ReThrowMsg(WidgetDAO::Exception::DatabaseError,
304 "Failed to register widget info.");
308 //get autoincremented value of widgetHandle
309 WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
310 select->Where(Equals<WidgetInfo::tizen_appid>(tzAppId));
311 return select->GetSingleValue<WidgetInfo::app_id>();
317 void WidgetDAO::registerWidgetLocalizedInfo(DbWidgetHandle widgetHandle,
318 const ConfigParserData::LocalizedDataSet &localizedDataSet)
320 using namespace DPL::DB::ORM;
321 using namespace DPL::DB::ORM::wrt;
323 FOREACH(it, localizedDataSet)
325 const DPL::String& locale = it->first;
326 const ConfigParserData::LocalizedData& data = it->second;
328 LocalizedWidgetInfo::Row row;
329 row.Set_app_id(widgetHandle);
330 row.Set_widget_locale(locale);
331 row.Set_widget_name(data.name);
332 row.Set_widget_shortname(data.shortName);
333 row.Set_widget_description(data.description);
334 row.Set_widget_license(data.license);
335 row.Set_widget_license_file(data.licenseFile);
336 row.Set_widget_license_href(data.licenseHref);
338 DO_INSERT(row, LocalizedWidgetInfo)
342 void WidgetDAO::registerWidgetIcons(DbWidgetHandle widgetHandle,
343 const WidgetRegisterInfo::LocalizedIconList &icons)
345 using namespace DPL::DB::ORM;
346 using namespace DPL::DB::ORM::wrt;
350 wrt::WidgetIcon::icon_id::ColumnType icon_id;
352 wrt::WidgetIcon::Row row;
353 row.Set_app_id(widgetHandle);
354 row.Set_icon_src(i->src);
355 row.Set_icon_width(i->width);
356 row.Set_icon_height(i->height);
358 WRT_DB_INSERT(insert, wrt::WidgetIcon, &WrtDatabase::interface())
360 icon_id = static_cast<int>(insert->Execute());
363 FOREACH(j, i->availableLocales)
365 WidgetLocalizedIcon::Row row;
366 row.Set_app_id(widgetHandle);
367 row.Set_icon_id(icon_id);
368 row.Set_widget_locale(*j);
369 DO_INSERT(row, WidgetLocalizedIcon)
374 void WidgetDAO::registerWidgetStartFile(DbWidgetHandle widgetHandle,
375 const WidgetRegisterInfo::LocalizedStartFileList &startFiles)
377 using namespace DPL::DB::ORM;
378 using namespace DPL::DB::ORM::wrt;
380 FOREACH(i, startFiles)
382 WidgetStartFile::start_file_id::ColumnType startFileID;
384 WidgetStartFile::Row row;
385 row.Set_app_id(widgetHandle);
386 row.Set_src(i->path);
388 WRT_DB_INSERT(insert, WidgetStartFile, &WrtDatabase::interface())
390 startFileID = static_cast<int>(insert->Execute());
393 FOREACH(j, i->propertiesForLocales)
395 WidgetLocalizedStartFile::Row row;
396 row.Set_app_id(widgetHandle);
397 row.Set_start_file_id(startFileID);
398 row.Set_widget_locale(j->first);
399 row.Set_type(j->second.type);
400 row.Set_encoding(j->second.encoding);
402 DO_INSERT(row, WidgetLocalizedStartFile)
407 void WidgetDAO::registerWidgetFeatures(DbWidgetHandle widgetHandle,
408 const ConfigParserData::FeaturesList &featuresList)
410 using namespace DPL::DB::ORM;
411 FOREACH(pWidgetFeature, featuresList)
413 wrt::WidgetFeature::Row widgetFeature;
414 widgetFeature.Set_app_id(widgetHandle);
415 widgetFeature.Set_name(pWidgetFeature->name);
416 widgetFeature.Set_rejected(false);
418 DO_INSERT(widgetFeature, wrt::WidgetFeature)
422 void WidgetDAO::registerWidgetPrivilege(DbWidgetHandle widgetHandle,
423 const ConfigParserData::PrivilegeList &privilegeList)
425 using namespace DPL::DB::ORM;
426 using namespace DPL::DB::ORM::wrt;
427 FOREACH(it, privilegeList)
429 WidgetPrivilege::Row widgetPrivilege;
430 widgetPrivilege.Set_app_id(widgetHandle);
431 widgetPrivilege.Set_name(it->name);
433 DO_INSERT(widgetPrivilege, WidgetPrivilege)
437 void WidgetDAO::updateFeatureRejectStatus(const DbWidgetFeature &widgetFeature)
439 // This function could be merged with registerWidgetFeature but it requires
441 // 1. Check "ace step" in installer must be done before "update database
444 // ConfigurationParserData shouldn't be called "ParserData" any more.
445 using namespace DPL::DB::ORM;
447 wrt::ScopedTransaction transaction(&WrtDatabase::interface());
448 WRT_DB_SELECT(select, wrt::WidgetFeature, &WrtDatabase::interface())
449 select->Where(And(Equals<wrt::WidgetFeature::app_id>(m_widgetHandle),
450 Equals<wrt::WidgetFeature::name>(widgetFeature.name)));
452 auto row = select->GetSingleRow();
453 row.Set_rejected(widgetFeature.rejected);
455 WRT_DB_UPDATE(update, wrt::WidgetFeature, &WrtDatabase::interface())
456 update->Where(And(Equals<wrt::WidgetFeature::app_id>(m_widgetHandle),
457 Equals<wrt::WidgetFeature::name>(widgetFeature.name)));
460 transaction.Commit();
463 void WidgetDAO::registerWidgetWindowModes(DbWidgetHandle widgetHandle,
464 const ConfigParserData::StringsList &windowModes)
466 using namespace DPL::DB::ORM;
467 using namespace DPL::DB::ORM::wrt;
468 FOREACH(i, windowModes)
470 wrt::WidgetWindowModes::Row windowMode;
471 windowMode.Set_app_id(widgetHandle);
472 windowMode.Set_window_mode(*i);
474 DO_INSERT(windowMode, wrt::WidgetWindowModes)
478 void WidgetDAO::registerWidgetWarpInfo(DbWidgetHandle widgetHandle,
479 const ConfigParserData::AccessInfoSet &accessInfoSet)
481 using namespace DPL::DB::ORM;
482 using namespace DPL::DB::ORM::wrt;
483 FOREACH(AccIt, accessInfoSet)
485 WidgetWARPInfo::Row row;
486 row.Set_app_id(widgetHandle);
487 row.Set_iri(AccIt->m_strIRI);
488 row.Set_subdomain_access(static_cast <int>(
489 AccIt->m_bSubDomainAccess));
491 DO_INSERT(row, WidgetWARPInfo)
495 void WidgetDAO::registerWidgetAllowNavigationInfo(DbWidgetHandle widgetHandle,
496 const ConfigParserData::AllowNavigationInfoList &allowNavigationInfoList)
498 using namespace DPL::DB::ORM;
499 using namespace DPL::DB::ORM::wrt;
500 FOREACH(allowNaviIt, allowNavigationInfoList)
502 WidgetAllowNavigation::Row row;
503 row.Set_app_id(widgetHandle);
504 row.Set_scheme(allowNaviIt->m_scheme);
505 row.Set_host(allowNaviIt->m_host);
506 DO_INSERT(row, WidgetAllowNavigation)
510 void WidgetDAO::registerWidgetCertificates(DbWidgetHandle widgetHandle,
511 const IWidgetSecurity &widgetSecurity)
513 using namespace DPL::DB::ORM;
514 using namespace DPL::DB::ORM::wrt;
516 FOREACH(it, widgetSecurity.getCertificateList())
518 WidgetCertificateFingerprint::Row row;
519 row.Set_app_id(widgetHandle);
520 row.Set_owner(it->owner);
521 row.Set_chainid(it->chainId);
522 row.Set_type(it->type);
523 row.Set_md5_fingerprint(DPL::FromUTF8String(it->strMD5Fingerprint));
524 row.Set_sha1_fingerprint(DPL::FromUTF8String(it->strSHA1Fingerprint));
525 row.Set_common_name(it->strCommonName);
527 DO_INSERT(row, WidgetCertificateFingerprint)
531 void WidgetDAO::registerCertificatesChains(
532 DbWidgetHandle widgetHandle,
533 CertificateSource certificateSource,
534 const CertificateChainList &
535 certificateChainList)
537 using namespace DPL::DB::ORM;
538 using namespace DPL::DB::ORM::wrt;
539 FOREACH(certChain, certificateChainList)
541 WidgetCertificate::Row row;
542 row.Set_app_id(widgetHandle);
543 row.Set_cert_source(certificateSource);
544 row.Set_encoded_chain(DPL::FromASCIIString(*certChain));
546 DO_INSERT(row, WidgetCertificate);
550 void WidgetDAO::registerWidgetSettings(DbWidgetHandle widgetHandle,
551 const ConfigParserData::SettingsList &settingsList)
553 using namespace DPL::DB::ORM;
554 using namespace DPL::DB::ORM::wrt;
556 FOREACH(pWidgetSetting, settingsList)
558 SettingsList::Row row;
559 row.Set_appId(widgetHandle);
560 row.Set_settingName(pWidgetSetting->m_name);
561 row.Set_settingValue(pWidgetSetting->m_value);
563 DO_INSERT(row, SettingsList)
567 void WidgetDAO::insertAppControlInfo(DbWidgetHandle handle,
569 DPL::String operation,
573 unsigned disposition)
575 using namespace DPL::DB::ORM;
576 using namespace DPL::DB::ORM::wrt;
578 AppControlInfo::Row row;
580 row.Set_app_id(handle);
581 row.Set_execute_index(index);
583 row.Set_operation(operation);
586 row.Set_disposition(disposition);
588 DO_INSERT(row, AppControlInfo);
591 void WidgetDAO::registerAppControl(DbWidgetHandle widgetHandle,
592 const ConfigParserData::AppControlInfoList &appControlList)
594 using namespace DPL::DB::ORM;
595 using namespace DPL::DB::ORM::wrt;
598 FOREACH(appControl_it, appControlList)
600 DPL::String src = appControl_it->m_src;
601 DPL::String operation = appControl_it->m_operation;
602 unsigned index = appControl_it->m_index;
603 unsigned disposition =
604 static_cast<unsigned>(appControl_it->m_disposition);
606 if (!appControl_it->m_uriList.empty())
608 FOREACH(uri_it, appControl_it->m_uriList)
610 DPL::String uri = *uri_it;
612 if (!appControl_it->m_mimeList.empty())
614 FOREACH(mime_it, appControl_it->m_mimeList)
616 DPL::String mime = *mime_it;
618 insertAppControlInfo(widgetHandle, src, operation, uri, mime, index, disposition);
623 DPL::String mime = L"";
625 insertAppControlInfo(widgetHandle, src, operation, uri, mime, index, disposition);
631 DPL::String uri = L"";
633 if (!appControl_it->m_mimeList.empty())
635 FOREACH(mime_it, appControl_it->m_mimeList)
637 DPL::String mime = *mime_it;
639 insertAppControlInfo(widgetHandle, src, operation, uri, mime, index, disposition);
644 DPL::String mime = L"";
646 insertAppControlInfo(widgetHandle, src, operation, uri, mime, index, disposition);
652 void WidgetDAO::registerEncryptedResouceInfo(DbWidgetHandle widgetHandle,
653 const EncryptedFileList &encryptedFiles)
655 using namespace DPL::DB::ORM;
656 using namespace DPL::DB::ORM::wrt;
658 FOREACH(it, encryptedFiles)
660 EncryptedResourceList::Row row;
661 row.Set_app_id(widgetHandle);
662 row.Set_resource(it->fileName);
663 row.Set_size(it->fileSize);
665 DO_INSERT(row, EncryptedResourceList)
669 void WidgetDAO::registerServiceInternal(const ConfigParserData::ServiceAppInfo &serviceAppInfo, const WidgetRegisterInfo &widgetRegInfo, const IWidgetSecurity &widgetSecurity)
671 using namespace DPL::DB::ORM;
672 using namespace DPL::DB::ORM::wrt;
674 DPL::String tzAppId = serviceAppInfo.serviceId;
677 DbWidgetHandle widgetHandle = registerWidgetInfo(tzAppId, widgetRegInfo.tzPkgid, widgetRegInfo.baseFolder,
678 APP_TYPE_TIZENWEBSERVICE, widgetRegInfo.packagingType.pkgType,
679 widgetRegInfo.configInfo, widgetSecurity);
681 registerWidgetExtendedInfo(widgetHandle, widgetRegInfo.installedTime,
682 widgetRegInfo.configInfo.splashImgSrc, widgetRegInfo.configInfo.backgroundPage,
683 widgetRegInfo.widgetInstalledPath);
685 registerWidgetLocalizedInfo(widgetHandle, serviceAppInfo.m_localizedDataSet);
688 WidgetRegisterInfo::LocalizedIconList iconList;
690 FOREACH(it, serviceAppInfo.m_iconsList) {
691 iconList.push_back(WidgetRegisterInfo::LocalizedIcon(*it, localeSet));
693 registerWidgetIcons(widgetHandle, iconList);
695 WidgetRegisterInfo::LocalizedStartFileList startFileList;
696 WidgetRegisterInfo::LocalizedStartFile startFile;
697 WidgetRegisterInfo::StartFileProperties startFileProperties;
698 startFile.path = serviceAppInfo.serviceContent;
699 startFileProperties.type = L"";
700 startFileProperties.encoding = L"UTF-8";
701 startFile.propertiesForLocales[L""] = startFileProperties;
702 startFileList.push_back(startFile);
703 registerWidgetStartFile(widgetHandle, startFileList);
706 PropertyDAO::RegisterProperties(widgetHandle, tzAppId, widgetRegInfo);
708 registerWidgetFeatures(widgetHandle, widgetRegInfo.configInfo.featuresList);
710 registerWidgetPrivilege(widgetHandle, widgetRegInfo.configInfo.privilegeList);
712 registerWidgetWindowModes(widgetHandle, widgetRegInfo.configInfo.windowModes);
714 registerWidgetWarpInfo(widgetHandle, widgetRegInfo.configInfo.accessInfoSet);
716 registerWidgetAllowNavigationInfo(widgetHandle, widgetRegInfo.configInfo.allowNavigationInfoList);
718 registerWidgetCertificates(widgetHandle, widgetSecurity);
720 CertificateChainList list;
721 widgetSecurity.getCertificateChainList(list, SIGNATURE_DISTRIBUTOR);
722 registerCertificatesChains(widgetHandle, SIGNATURE_DISTRIBUTOR, list);
725 widgetSecurity.getCertificateChainList(list, SIGNATURE_AUTHOR);
726 registerCertificatesChains(widgetHandle, SIGNATURE_AUTHOR, list);
728 registerWidgetSettings(widgetHandle, widgetRegInfo.configInfo.settingsList);
730 registerEncryptedResouceInfo(widgetHandle, widgetRegInfo.encryptedFiles);
732 registerExternalLocations(widgetHandle, widgetRegInfo.externalLocations);
735 void WidgetDAO::registerExternalLocations(
736 DbWidgetHandle widgetHandle,
737 const ExternalLocationList &
740 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
742 using namespace DPL::DB::ORM;
743 using namespace DPL::DB::ORM::wrt;
744 DPL::DB::ORM::wrt::ScopedTransaction transaction(
745 &WrtDatabase::interface());
746 LogDebug("Inserting external files for widgetHandle: " << widgetHandle);
747 FOREACH(it, externals)
749 WidgetExternalLocations::Row row;
750 row.Set_app_id(widgetHandle);
751 row.Set_path(DPL::FromUTF8String(*it));
753 DO_INSERT(row, WidgetExternalLocations)
755 transaction.Commit();
757 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register external files");
760 void WidgetDAO::unregisterAllExternalLocations()
762 using namespace DPL::DB::ORM;
763 using namespace DPL::DB::ORM::wrt;
764 LogDebug("Deleting external files for widgetHandle: " << m_widgetHandle);
765 WRT_DB_DELETE(del, WidgetExternalLocations, &WrtDatabase::interface());
766 del->Where(Equals<WidgetExternalLocations::app_id>(m_widgetHandle));
770 void WidgetDAO::unregisterWidget(const TizenAppId & tzAppId)
772 LogDebug("Unregistering widget from DB. tzAppId: " << tzAppId);
773 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
775 DPL::DB::ORM::wrt::ScopedTransaction transaction(
776 &WrtDatabase::interface());
777 unregisterWidgetInternal(tzAppId);
778 transaction.Commit();
780 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to unregister widget")
783 void WidgetDAO::unregisterWidgetInternal(
784 const TizenAppId & tzAppId)
786 using namespace DPL::DB::ORM;
787 using namespace DPL::DB::ORM::wrt;
789 DbWidgetHandle handle = getHandle(tzAppId);
791 // Delete from table Widget Info
792 WRT_DB_DELETE(del, WidgetInfo, &WrtDatabase::interface())
793 del->Where(Equals<WidgetInfo::app_id>(handle));
796 // Deleting in other tables is done via "delete cascade" in SQL
801 #undef SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
802 #undef SQL_CONNECTION_EXCEPTION_HANDLER_END