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/wrt_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 WrtLogD("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 WrtLogD("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 boost::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);
220 #if USE(WEB_PROVIDER)
221 registerLiveBoxInfo(widgetHandle, widgetRegInfo);
225 #define DO_INSERT(row, table) \
227 WRT_DB_INSERT(insert, table, &WrtDatabase::interface()) \
228 insert->Values(row); \
232 void WidgetDAO::registerWidgetExtendedInfo(DbWidgetHandle widgetHandle,
233 time_t installedTime,
234 const DPL::OptionalString & splashImgSrc,
235 const DPL::OptionalString & backgroundPage,
236 const DPL::OptionalString & widgetInstalledPath)
238 //Try and transaction not needed
239 using namespace DPL::DB::ORM;
240 using namespace DPL::DB::ORM::wrt;
242 WidgetExtendedInfo::Row row;
243 row.Set_app_id(widgetHandle);
244 row.Set_install_time(installedTime);
245 row.Set_splash_img_src(splashImgSrc);
246 row.Set_background_page(backgroundPage);
247 row.Set_installed_path(widgetInstalledPath);
249 DO_INSERT(row, WidgetExtendedInfo)
252 DbWidgetHandle WidgetDAO::registerWidgetInfo(
253 const TizenAppId & tzAppId,
254 const TizenPkgId & tzPkgId,
255 const std::string & baseFolder,
258 const ConfigParserData &widgetConfigurationInfo,
259 const IWidgetSecurity & /*widgetSecurity*/,
260 const boost::optional<DbWidgetHandle> handle)
262 using namespace DPL::DB::ORM;
263 using namespace DPL::DB::ORM::wrt;
264 // TODO in wrt_db all Columns in WidgetInfo have DEFAULT VALUE set.
265 // Because of that, "Optional" is not used there
269 row.Set_app_id(*handle);
272 row.Set_widget_type(appType);
273 row.Set_widget_id(widgetConfigurationInfo.widget_id);
274 row.Set_defaultlocale(widgetConfigurationInfo.defaultlocale);
275 row.Set_widget_version(widgetConfigurationInfo.version);
276 row.Set_widget_width(widgetConfigurationInfo.width);
277 row.Set_widget_height(widgetConfigurationInfo.height);
278 row.Set_author_name(widgetConfigurationInfo.authorName);
279 row.Set_author_email(widgetConfigurationInfo.authorEmail);
280 row.Set_author_href(widgetConfigurationInfo.authorHref);
281 row.Set_csp_policy(widgetConfigurationInfo.cspPolicy);
282 row.Set_csp_policy_report_only(widgetConfigurationInfo.cspPolicyReportOnly);
283 row.Set_tizen_appid(tzAppId);
284 row.Set_tizen_pkgid(tzPkgId);
286 if (!!widgetConfigurationInfo.minVersionRequired) {
287 row.Set_min_version(widgetConfigurationInfo.minVersionRequired);
288 } else if (!!widgetConfigurationInfo.tizenMinVersionRequired) {
289 row.Set_min_version(widgetConfigurationInfo.tizenMinVersionRequired);
292 row.Set_back_supported(widgetConfigurationInfo.backSupported);
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,
574 using namespace DPL::DB::ORM;
575 using namespace DPL::DB::ORM::wrt;
577 AppControlInfo::Row row;
579 row.Set_app_id(handle);
581 row.Set_operation(operation);
584 // reuse execute_index field to store reset value to remove db migration task.
585 row.Set_execute_index(reload);
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;
602 if (appControl_it->m_reload == L"false") {
604 } else if (appControl_it->m_reload == L"true") {
608 if (!appControl_it->m_uriList.empty())
610 FOREACH(uri_it, appControl_it->m_uriList)
612 DPL::String uri = *uri_it;
614 if (!appControl_it->m_mimeList.empty())
616 FOREACH(mime_it, appControl_it->m_mimeList)
618 DPL::String mime = *mime_it;
620 insertAppControlInfo(widgetHandle, src, operation, uri, mime, reload);
625 DPL::String mime = L"";
627 insertAppControlInfo(widgetHandle, src, operation, uri, mime, reload);
633 DPL::String uri = L"";
635 if (!appControl_it->m_mimeList.empty())
637 FOREACH(mime_it, appControl_it->m_mimeList)
639 DPL::String mime = *mime_it;
641 insertAppControlInfo(widgetHandle, src, operation, uri, mime, reload);
646 DPL::String mime = L"";
648 insertAppControlInfo(widgetHandle, src, operation, uri, mime, reload);
654 void WidgetDAO::registerEncryptedResouceInfo(DbWidgetHandle widgetHandle,
655 const EncryptedFileList &encryptedFiles)
657 using namespace DPL::DB::ORM;
658 using namespace DPL::DB::ORM::wrt;
660 FOREACH(it, encryptedFiles)
662 EncryptedResourceList::Row row;
663 row.Set_app_id(widgetHandle);
664 row.Set_resource(it->fileName);
665 row.Set_size(it->fileSize);
667 DO_INSERT(row, EncryptedResourceList)
671 void WidgetDAO::registerServiceInternal(const ConfigParserData::ServiceAppInfo &serviceAppInfo, const WidgetRegisterInfo &widgetRegInfo, const IWidgetSecurity &widgetSecurity)
673 using namespace DPL::DB::ORM;
674 using namespace DPL::DB::ORM::wrt;
676 DPL::String tzAppId = serviceAppInfo.serviceId;
679 DbWidgetHandle widgetHandle = registerWidgetInfo(tzAppId, widgetRegInfo.tzPkgid, widgetRegInfo.baseFolder,
680 APP_TYPE_TIZENWEBSERVICE, widgetRegInfo.packagingType.pkgType,
681 widgetRegInfo.configInfo, widgetSecurity);
683 registerWidgetExtendedInfo(widgetHandle, widgetRegInfo.installedTime,
684 widgetRegInfo.configInfo.splashImgSrc, widgetRegInfo.configInfo.backgroundPage,
685 widgetRegInfo.widgetInstalledPath);
687 registerWidgetLocalizedInfo(widgetHandle, serviceAppInfo.m_localizedDataSet);
690 WidgetRegisterInfo::LocalizedIconList iconList;
692 FOREACH(it, serviceAppInfo.m_iconsList) {
693 iconList.push_back(WidgetRegisterInfo::LocalizedIcon(*it, localeSet));
695 registerWidgetIcons(widgetHandle, iconList);
697 WidgetRegisterInfo::LocalizedStartFileList startFileList;
698 WidgetRegisterInfo::LocalizedStartFile startFile;
699 WidgetRegisterInfo::StartFileProperties startFileProperties;
700 startFile.path = serviceAppInfo.serviceContent;
701 startFileProperties.type = L"";
702 startFileProperties.encoding = L"UTF-8";
703 startFile.propertiesForLocales[L""] = startFileProperties;
704 startFileList.push_back(startFile);
705 registerWidgetStartFile(widgetHandle, startFileList);
708 PropertyDAO::RegisterProperties(widgetHandle, tzAppId, widgetRegInfo);
710 registerWidgetFeatures(widgetHandle, widgetRegInfo.configInfo.featuresList);
712 registerWidgetPrivilege(widgetHandle, widgetRegInfo.configInfo.privilegeList);
714 registerWidgetWindowModes(widgetHandle, widgetRegInfo.configInfo.windowModes);
716 registerWidgetWarpInfo(widgetHandle, widgetRegInfo.configInfo.accessInfoSet);
718 registerWidgetAllowNavigationInfo(widgetHandle, widgetRegInfo.configInfo.allowNavigationInfoList);
720 registerWidgetCertificates(widgetHandle, widgetSecurity);
722 CertificateChainList list;
723 widgetSecurity.getCertificateChainList(list, SIGNATURE_DISTRIBUTOR);
724 registerCertificatesChains(widgetHandle, SIGNATURE_DISTRIBUTOR, list);
727 widgetSecurity.getCertificateChainList(list, SIGNATURE_AUTHOR);
728 registerCertificatesChains(widgetHandle, SIGNATURE_AUTHOR, list);
730 registerWidgetSettings(widgetHandle, widgetRegInfo.configInfo.settingsList);
732 registerEncryptedResouceInfo(widgetHandle, widgetRegInfo.encryptedFiles);
734 registerExternalLocations(widgetHandle, widgetRegInfo.externalLocations);
737 void WidgetDAO::registerExternalLocations(
738 DbWidgetHandle widgetHandle,
739 const ExternalLocationList &
742 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
744 using namespace DPL::DB::ORM;
745 using namespace DPL::DB::ORM::wrt;
746 DPL::DB::ORM::wrt::ScopedTransaction transaction(
747 &WrtDatabase::interface());
748 WrtLogD("Inserting external files for widgetHandle: %i", widgetHandle);
749 FOREACH(it, externals)
751 WidgetExternalLocations::Row row;
752 row.Set_app_id(widgetHandle);
753 row.Set_path(DPL::FromUTF8String(*it));
755 DO_INSERT(row, WidgetExternalLocations)
757 transaction.Commit();
759 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register external files");
761 #if USE(WEB_PROVIDER)
762 void WidgetDAO::registerLiveBoxInfo(DbWidgetHandle widgetHandle,
763 const WidgetRegisterInfo ®Info)
765 using namespace DPL::DB::ORM;
766 using namespace DPL::DB::ORM::wrt;
768 ConfigParserData::LiveboxList liveBoxList = regInfo.configInfo.m_livebox;
770 FOREACH(it, liveBoxList)
772 LiveBoxInfo::Row row;
773 row.Set_app_id(widgetHandle);
774 row.Set_livebox_id((**it).m_liveboxId);
776 DO_INSERT(row, LiveBoxInfo)
780 void WidgetDAO::unregisterAllExternalLocations()
782 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
784 using namespace DPL::DB::ORM;
785 using namespace DPL::DB::ORM::wrt;
786 WrtLogD("Deleting external files for widgetHandle: %i", m_widgetHandle);
787 WRT_DB_DELETE(del, WidgetExternalLocations, &WrtDatabase::interface());
788 del->Where(Equals<WidgetExternalLocations::app_id>(m_widgetHandle));
791 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to unregister external locations")
794 void WidgetDAO::unregisterWidget(const TizenAppId & tzAppId)
796 WrtLogD("Unregistering widget from DB. tzAppId: %ls", tzAppId.c_str());
797 SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
799 DPL::DB::ORM::wrt::ScopedTransaction transaction(
800 &WrtDatabase::interface());
801 unregisterWidgetInternal(tzAppId);
802 transaction.Commit();
804 SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to unregister widget")
807 void WidgetDAO::unregisterWidgetInternal(
808 const TizenAppId & tzAppId)
810 using namespace DPL::DB::ORM;
811 using namespace DPL::DB::ORM::wrt;
813 DbWidgetHandle handle = getHandle(tzAppId);
815 // Delete from table Widget Info
816 WRT_DB_DELETE(del, WidgetInfo, &WrtDatabase::interface())
817 del->Where(Equals<WidgetInfo::app_id>(handle));
820 // Deleting in other tables is done via "delete cascade" in SQL
825 #undef SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
826 #undef SQL_CONNECTION_EXCEPTION_HANDLER_END