Code refactoring and removal of factory_widget attribute.
[framework/web/wrt-commons.git] / modules / widget_dao / dao / widget_dao.cpp
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 /**
17  * This file contains the definition of widget dao class.
18  *
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)
25  * @version 1.0
26  * @brief   This file contains the definition of Configuration.
27  */
28
29 #include <dpl/wrt-dao-rw/widget_dao.h>
30
31 #include <sstream>
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>
38
39 namespace WrtDB {
40
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)
44
45 #define SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN          Try
46
47 #define SQL_CONNECTION_EXCEPTION_HANDLER_END(message)   \
48     Catch(DPL::DB::SqlConnection::Exception::Base) {       \
49         LogError(message);                              \
50         ReThrowMsg(WidgetDAO::Exception::DatabaseError, \
51                    message);                            \
52     }
53
54 #define CHECK_WIDGET_EXISTENCE(macro_transaction, macro_handle)          \
55     if (!WidgetDAO::isWidgetInstalled(macro_handle))                      \
56     {                                                                    \
57         macro_transaction.Commit();                                      \
58         LogWarning("Cannot find widget. Handle: " << macro_handle);      \
59         ThrowMsg(WidgetDAO::Exception::WidgetNotExist,                   \
60                  "Cannot find widget. Handle: " << macro_handle);        \
61     }
62
63
64 WidgetDAO::WidgetDAO(DbWidgetHandle widgetHandle) :
65     WidgetDAOReadOnly(widgetHandle)
66 {
67 }
68
69 WidgetDAO::WidgetDAO(DPL::OptionalString widgetGUID) :
70     WidgetDAOReadOnly(WidgetDAOReadOnly::getHandle(widgetGUID))
71 {
72 }
73
74 WidgetDAO::WidgetDAO(DPL::String pkgName) :
75     WidgetDAOReadOnly(WidgetDAOReadOnly::getHandle(pkgName))
76 {
77 }
78
79 WidgetDAO::~WidgetDAO()
80 {
81 }
82
83 void WidgetDAO::removeProperty(
84         const PropertyDAOReadOnly::WidgetPropertyKey &key)
85 {
86     Try {
87         PropertyDAO::RemoveProperty(m_widgetHandle, key);
88     }
89     Catch(PropertyDAOReadOnly::Exception::ReadOnlyProperty){
90         ReThrowMsg(WidgetDAO::Exception::DatabaseError,
91                    "Failure during removing property");
92     }
93 }
94
95 void WidgetDAO::setProperty(
96         const PropertyDAOReadOnly::WidgetPropertyKey &key,
97         const PropertyDAOReadOnly::WidgetPropertyValue &value,
98         bool readOnly)
99 {
100     Try {
101         PropertyDAO::SetProperty(m_widgetHandle, key, value, readOnly);
102     }
103     Catch(PropertyDAOReadOnly::Exception::ReadOnlyProperty){
104         ReThrowMsg(WidgetDAO::Exception::DatabaseError,
105                    "Failure during setting/updating property");
106     }
107 }
108
109 void WidgetDAO::setPkgName(const DPL::OptionalString& pkgName)
110 {
111     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
112     {
113         using namespace DPL::DB::ORM;
114         wrt::ScopedTransaction transaction(&WrtDatabase::interface());
115
116         isWidgetInstalled(getHandle());
117
118         wrt::WidgetInfo::Row row;
119         row.Set_pkgname(pkgName);
120
121         WRT_DB_UPDATE(update, wrt::WidgetInfo, &WrtDatabase::interface())
122         update->Where(
123             Equals<wrt::WidgetInfo::app_id>(getHandle()));
124
125         update->Values(row);
126         update->Execute();
127         transaction.Commit();
128     }
129     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register widget")
130 }
131
132 void WidgetDAO::registerWidget(
133         const DbWidgetHandle& widgetHandle,
134         const WidgetRegisterInfo &widgetRegInfo,
135         const IWacSecurity &wacSecurity)
136 {
137     LogDebug("Registering widget");
138     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
139     {
140         DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
141
142         //Register into WidgetInfo has to be first
143         //as all other tables depend upon that
144         registerWidgetInfo(widgetHandle, widgetRegInfo, wacSecurity);
145
146         registerWidgetExtendedInfo(widgetHandle, widgetRegInfo);
147
148         registerWidgetLocalizedInfo(widgetHandle, widgetRegInfo);
149
150         registerWidgetIcons(widgetHandle, widgetRegInfo);
151
152         registerWidgetStartFile(widgetHandle, widgetRegInfo);
153
154         PropertyDAO::RegisterProperties(widgetHandle, widgetRegInfo);
155
156         registerWidgetFeatures(widgetHandle, widgetRegInfo);
157
158         registerWidgetWindowModes(widgetHandle, widgetRegInfo);
159
160         registerWidgetWarpInfo(widgetHandle, widgetRegInfo);
161
162         registerWidgetCertificates(widgetHandle, wacSecurity);
163
164         CertificateChainList list;
165         wacSecurity.getCertificateChainList(list, SIGNATURE_DISTRIBUTOR);
166         registerCertificatesChains(widgetHandle, SIGNATURE_DISTRIBUTOR, list);
167
168         list.clear();
169         wacSecurity.getCertificateChainList(list, SIGNATURE_AUTHOR);
170         registerCertificatesChains(widgetHandle, SIGNATURE_AUTHOR, list);
171
172         registerWidgetSettings(widgetHandle, widgetRegInfo);
173
174         registerAppService(widgetHandle, widgetRegInfo);
175
176         registerEncryptedResouceInfo(widgetHandle, widgetRegInfo);
177
178         transaction.Commit();
179     }
180     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register widget")
181 }
182
183 #define DO_INSERT(row, table)                              \
184     {                                                      \
185         WRT_DB_INSERT(insert, table, &WrtDatabase::interface()) \
186         insert->Values(row);                               \
187         insert->Execute();                                 \
188     }
189
190 void WidgetDAO::registerWidgetExtendedInfo(DbWidgetHandle widgetHandle,
191         const WidgetRegisterInfo &regInfo)
192 {
193     //Try and transaction not needed
194     using namespace DPL::DB::ORM;
195     using namespace DPL::DB::ORM::wrt;
196
197
198     WidgetExtendedInfo::Row row;
199     row.Set_app_id(widgetHandle);
200     //    row.Set_share_href    (DPL::FromUTF8String(regInfo.shareHref));
201     row.Set_signature_type(regInfo.signatureType);
202     row.Set_test_widget(regInfo.isTestWidget);
203     row.Set_install_time(regInfo.installedTime);
204     row.Set_splash_img_src(regInfo.configInfo.splashImgSrc);
205     row.Set_background_page(regInfo.configInfo.backgroundPage);
206
207
208     DO_INSERT(row, WidgetExtendedInfo)
209 }
210
211 void WidgetDAO::registerWidgetInfo(
212         const DbWidgetHandle& widgetHandle,
213         const WidgetRegisterInfo &regInfo,
214         const IWacSecurity &wacSecurity)
215 {
216     using namespace DPL::DB::ORM;
217     using namespace DPL::DB::ORM::wrt;
218     const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
219
220     // TODO in wrt_db all Columns in WidgetInfo have DEFAULT VALUE set.
221     // Because of that, "Optional" is not used there
222
223     WidgetInfo::Row row;
224     row.Set_app_id(widgetHandle);
225     row.Set_widget_type(regInfo.type.appType);
226     row.Set_widget_id(widgetConfigurationInfo.widget_id);
227     row.Set_defaultlocale(widgetConfigurationInfo.defaultlocale);
228     row.Set_widget_version(widgetConfigurationInfo.version);
229     row.Set_widget_width(widgetConfigurationInfo.width);
230     row.Set_widget_height(widgetConfigurationInfo.height);
231     row.Set_author_name(widgetConfigurationInfo.authorName);
232     row.Set_author_email(widgetConfigurationInfo.authorEmail);
233     row.Set_author_href(widgetConfigurationInfo.authorHref);
234     row.Set_base_folder(DPL::FromUTF8String(regInfo.baseFolder));
235     row.Set_webkit_plugins_required(widgetConfigurationInfo.flashNeeded);
236     row.Set_recognized(wacSecurity.isRecognized());
237     row.Set_wac_signed(wacSecurity.isWacSigned());
238     row.Set_distributor_signed(wacSecurity.isDistributorSigned());
239     {
240         std::stringstream tmp;
241         tmp << regInfo.minVersion;
242         row.Set_min_version(DPL::FromUTF8String(tmp.str()));
243     }
244     row.Set_back_supported(widgetConfigurationInfo.backSupported);
245     row.Set_access_network(widgetConfigurationInfo.accessNetwork);
246     row.Set_pkgname(regInfo.pkgname);
247     row.Set_pkg_type(regInfo.pType.pkgType);
248
249     Try
250     {
251         DO_INSERT(row, WidgetInfo);
252     }
253     Catch(DPL::DB::SqlConnection::Exception::Base)
254     {
255         ReThrowMsg(WidgetDAO::Exception::DatabaseError,
256                    "Failed to register widget info.");
257     }
258 }
259
260 void WidgetDAO::registerWidgetLocalizedInfo(DbWidgetHandle widgetHandle,
261         const WidgetRegisterInfo &regInfo)
262 {
263     using namespace DPL::DB::ORM;
264     using namespace DPL::DB::ORM::wrt;
265
266     const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
267
268     FOREACH(it, widgetConfigurationInfo.localizedDataSet)
269     {
270         const DPL::String& locale = it->first;
271         const ConfigParserData::LocalizedData& data = it->second;
272
273         LocalizedWidgetInfo::Row row;
274         row.Set_app_id(widgetHandle);
275         row.Set_widget_locale(locale);
276         row.Set_widget_name(data.name);
277         row.Set_widget_shortname(data.shortName);
278         row.Set_widget_description(data.description);
279         row.Set_widget_license(data.license);
280         row.Set_widget_license_file(data.licenseFile);
281         row.Set_widget_license_href(data.licenseHref);
282
283         DO_INSERT(row, LocalizedWidgetInfo)
284     }
285 }
286
287 void WidgetDAO::registerWidgetIcons(DbWidgetHandle widgetHandle,
288         const WidgetRegisterInfo &regInfo)
289 {
290     using namespace DPL::DB::ORM;
291     using namespace DPL::DB::ORM::wrt;
292
293
294     FOREACH(i, regInfo.localizationData.icons)
295     {
296         wrt::WidgetIcon::icon_id::ColumnType icon_id;
297         {
298             wrt::WidgetIcon::Row row;
299             row.Set_app_id(widgetHandle);
300             row.Set_icon_src(i->src);
301             row.Set_icon_width(i->width);
302             row.Set_icon_height(i->height);
303
304             WRT_DB_INSERT(insert, wrt::WidgetIcon, &WrtDatabase::interface())
305             insert->Values(row);
306             icon_id = insert->Execute();
307         }
308
309         FOREACH(j, i->availableLocales)
310         {
311             WidgetLocalizedIcon::Row row;
312             row.Set_app_id(widgetHandle);
313             row.Set_icon_id(icon_id);
314             row.Set_widget_locale(*j);
315             WRT_DB_SELECT(select, WidgetLocalizedIcon, &WrtDatabase::interface())
316             select->Where(And(Equals<WidgetLocalizedIcon::app_id>(widgetHandle),
317                               Equals<WidgetLocalizedIcon::widget_locale>(*j)));
318             WidgetLocalizedIcon::Select::RowList rows = select->GetRowList();
319
320             bool flag = !rows.empty();
321
322             if(flag == true)
323             {
324                 // already default icon value of same locale exists
325                 WRT_DB_UPDATE(update, WidgetLocalizedIcon, &WrtDatabase::interface())
326                 update->Where(And(Equals<WidgetLocalizedIcon::app_id>(widgetHandle),
327                                   Equals<WidgetLocalizedIcon::widget_locale>(*j)));
328                 update->Values(row);
329                 update->Execute();
330             }else{
331                 // any icon value of same locale doesn't exist
332                 DO_INSERT(row, WidgetLocalizedIcon)
333             }
334         }
335     }
336 }
337
338 void WidgetDAO::registerWidgetStartFile(DbWidgetHandle widgetHandle,
339         const WidgetRegisterInfo &regInfo)
340 {
341     using namespace DPL::DB::ORM;
342     using namespace DPL::DB::ORM::wrt;
343
344
345     FOREACH(i, regInfo.localizationData.startFiles)
346     {
347         WidgetStartFile::start_file_id::ColumnType startFileID;
348         {
349             WidgetStartFile::Row row;
350             row.Set_app_id(widgetHandle);
351             row.Set_src(i->path);
352
353             WRT_DB_INSERT(insert, WidgetStartFile, &WrtDatabase::interface())
354             insert->Values(row);
355             startFileID = insert->Execute();
356         }
357
358         FOREACH(j, i->propertiesForLocales)
359         {
360             WidgetLocalizedStartFile::Row row;
361             row.Set_app_id(widgetHandle);
362             row.Set_start_file_id(startFileID);
363             row.Set_widget_locale(j->first);
364             row.Set_type(j->second.type);
365             row.Set_encoding(j->second.encoding);
366
367             DO_INSERT(row, WidgetLocalizedStartFile)
368         }
369     }
370 }
371
372 void WidgetDAO::registerWidgetFeatures(DbWidgetHandle widgetHandle,
373         const WidgetRegisterInfo &regInfo)
374 {
375     using namespace DPL::DB::ORM;
376     const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
377
378
379     FOREACH(pWidgetFeature, widgetConfigurationInfo.featuresList)
380     {
381         wrt::WidgetFeature::Row widgetFeature;
382         widgetFeature.Set_app_id(widgetHandle);
383         widgetFeature.Set_name(pWidgetFeature->name);
384         widgetFeature.Set_required(pWidgetFeature->required);
385         widgetFeature.Set_rejected(false);
386
387         wrt::WidgetFeature::widget_feature_id::ColumnType widgetFeatureID;
388         {
389             WRT_DB_INSERT(insert, wrt::WidgetFeature, &WrtDatabase::interface())
390             insert->Values(widgetFeature);
391             widgetFeatureID = insert->Execute();
392         }
393
394         // Insert into table FeatureParam
395         wrt::FeatureParam::Row featureParam;
396         featureParam.Set_widget_feature_id(widgetFeatureID);
397
398         ConfigParserData::ParamsList::const_iterator iter;
399
400         FOREACH(iter, pWidgetFeature->paramsList)
401         {
402             featureParam.Set_name(iter->name);
403             featureParam.Set_value(iter->value);
404
405             DO_INSERT(featureParam, wrt::FeatureParam)
406         }
407     }
408 }
409
410 void WidgetDAO::updateFeatureRejectStatus(const DbWidgetFeature &widgetFeature){
411     // This function could be merged with registerWidgetFeature but it requires desing change:
412     // 1. Check "ace step" in installer must be done before "update database step"
413     // And:
414     // ConfigurationParserData shouldn't be called "ParserData" any more.
415     using namespace DPL::DB::ORM;
416
417     wrt::ScopedTransaction transaction(&WrtDatabase::interface());
418     WRT_DB_SELECT(select, wrt::WidgetFeature, &WrtDatabase::interface())
419     select->Where(And(Equals<wrt::WidgetFeature::app_id>(m_widgetHandle),
420                       Equals<wrt::WidgetFeature::name>(widgetFeature.name)));
421
422     auto row = select->GetSingleRow();
423     row.Set_rejected(widgetFeature.rejected);
424
425     WRT_DB_UPDATE(update, wrt::WidgetFeature, &WrtDatabase::interface())
426     update->Where(And(Equals<wrt::WidgetFeature::app_id>(m_widgetHandle),
427                       Equals<wrt::WidgetFeature::name>(widgetFeature.name)));
428     update->Values(row);
429     update->Execute();
430     transaction.Commit();
431 }
432
433 void WidgetDAO::registerWidgetWindowModes(DbWidgetHandle widgetHandle,
434         const WidgetRegisterInfo &regInfo)
435 {
436     using namespace DPL::DB::ORM;
437     using namespace DPL::DB::ORM::wrt;
438     const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
439
440
441     FOREACH(i, widgetConfigurationInfo.windowModes)
442     {
443         wrt::WidgetWindowModes::Row windowMode;
444         windowMode.Set_app_id(widgetHandle);
445         windowMode.Set_window_mode(*i);
446
447         DO_INSERT(windowMode, wrt::WidgetWindowModes)
448     }
449 }
450
451 void WidgetDAO::registerWidgetWarpInfo(DbWidgetHandle widgetHandle,
452         const WidgetRegisterInfo &regInfo)
453 {
454     using namespace DPL::DB::ORM;
455     using namespace DPL::DB::ORM::wrt;
456     const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
457
458
459     FOREACH(AccIt, widgetConfigurationInfo.accessInfoSet)
460     {
461         WidgetWARPInfo::Row row;
462         row.Set_app_id(widgetHandle);
463         row.Set_iri(AccIt->m_strIRI);
464         row.Set_subdomain_access(static_cast <int>(
465                                      AccIt->m_bSubDomainAccess));
466
467         DO_INSERT(row, WidgetWARPInfo)
468     }
469 }
470
471 void WidgetDAO::registerWidgetCertificates(DbWidgetHandle widgetHandle,
472         const IWacSecurity &wacSecurity)
473 {
474     using namespace DPL::DB::ORM;
475     using namespace DPL::DB::ORM::wrt;
476
477
478     FOREACH(it, wacSecurity.getCertificateList())
479     {
480         WidgetCertificateFingerprint::Row row;
481         row.Set_app_id(widgetHandle);
482         row.Set_owner(it->owner);
483         row.Set_chainid(it->chainId);
484         row.Set_type(it->type);
485         row.Set_md5_fingerprint(DPL::FromUTF8String(it->strMD5Fingerprint));
486         row.Set_sha1_fingerprint(DPL::FromUTF8String(it->strSHA1Fingerprint));
487         row.Set_common_name(it->strCommonName);
488
489         DO_INSERT(row, WidgetCertificateFingerprint)
490     }
491 }
492
493 void WidgetDAO::registerCertificatesChains(DbWidgetHandle widgetHandle,
494         CertificateSource certificateSource,
495         const CertificateChainList &certificateChainList)
496 {
497     using namespace DPL::DB::ORM;
498     using namespace DPL::DB::ORM::wrt;
499     FOREACH(certChain, certificateChainList)
500     {
501         WidgetCertificate::Row row;
502         row.Set_app_id(widgetHandle);
503         row.Set_cert_source(certificateSource);
504         row.Set_encoded_chain(DPL::FromASCIIString(*certChain));
505
506         DO_INSERT(row, WidgetCertificate);
507     }
508 }
509
510 void WidgetDAO::registerWidgetSettings(DbWidgetHandle widgetHandle,
511         const WidgetRegisterInfo &regInfo)
512 {
513     using namespace DPL::DB::ORM;
514     using namespace DPL::DB::ORM::wrt;
515
516     const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
517
518     FOREACH(pWidgetSetting, widgetConfigurationInfo.settingsList)
519     {
520         SettingsList::Row row;
521         row.Set_appId(widgetHandle);
522         row.Set_settingName(pWidgetSetting->m_name);
523         row.Set_settingValue(pWidgetSetting->m_value);
524
525         DO_INSERT(row, SettingsList)
526     }
527 }
528
529 void WidgetDAO::registerAppService(DbWidgetHandle widgetHandle,
530                                    const WidgetRegisterInfo &regInfo)
531 {
532     using namespace DPL::DB::ORM;
533     using namespace DPL::DB::ORM::wrt;
534     const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
535
536     FOREACH(ASIt, widgetConfigurationInfo.appServiceList)
537     {
538         ApplicationServiceInfo::Row row;
539         row.Set_app_id(widgetHandle);
540         row.Set_src(ASIt->m_src);
541         row.Set_operation(ASIt->m_operation);
542         row.Set_scheme(ASIt->m_scheme);
543         row.Set_mime(ASIt->m_mime);
544
545         DO_INSERT(row, ApplicationServiceInfo)
546     }
547 }
548
549 void WidgetDAO::registerEncryptedResouceInfo(DbWidgetHandle widgetHandle,
550         const WidgetRegisterInfo &regInfo)
551 {
552     using namespace DPL::DB::ORM;
553     using namespace DPL::DB::ORM::wrt;
554
555     FOREACH(it, regInfo.encryptedFiles)
556     {
557         EncryptedResourceList::Row row;
558         row.Set_app_id(widgetHandle);
559         row.Set_resource(it->fileName);
560         row.Set_size(it->fileSize);
561
562         DO_INSERT(row, EncryptedResourceList)
563     }
564 }
565
566 void WidgetDAO::registerExternalLocations(const ExternalLocationList & externals)
567 {
568     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
569     {
570         using namespace DPL::DB::ORM;
571         using namespace DPL::DB::ORM::wrt;
572         DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
573         LogDebug("Inserting external files for widgetHandle: " << m_widgetHandle);
574         FOREACH(it, externals)
575         {
576             WidgetExternalLocations::Row row;
577             row.Set_app_id(m_widgetHandle);
578             row.Set_path(DPL::FromUTF8String(*it));
579
580             DO_INSERT(row, WidgetExternalLocations)
581         }
582         transaction.Commit();
583     }
584     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register external files");
585 }
586
587 void WidgetDAO::unregisterAllExternalLocations()
588 {
589     using namespace DPL::DB::ORM;
590     using namespace DPL::DB::ORM::wrt;
591     LogDebug("Deleting external files for widgetHandle: " << m_widgetHandle);
592     WRT_DB_DELETE(del, WidgetExternalLocations, &WrtDatabase::interface());
593     del->Where(Equals<WidgetExternalLocations::app_id>(m_widgetHandle));
594     del->Execute();
595 }
596
597 #undef DO_INSERT
598
599 void WidgetDAO::unregisterWidget(DbWidgetHandle widgetHandle)
600 {
601     LogDebug("Unregistering widget from DB. Handle: " << widgetHandle);
602     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
603     {
604         DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
605         using namespace DPL::DB::ORM;
606         using namespace DPL::DB::ORM::wrt;
607
608         CHECK_WIDGET_EXISTENCE(transaction, widgetHandle)
609
610         // Delete from table Widget Info
611         {
612             WRT_DB_DELETE(del, WidgetInfo, &WrtDatabase::interface())
613             del->Where(Equals<WidgetInfo::app_id>(widgetHandle));
614             del->Execute();
615         }
616
617         // Deleting in other tables is done via "delete cascade" in SQL
618
619         transaction.Commit();
620     }
621     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to unregister widget")
622 }
623
624 #undef SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
625 #undef SQL_CONNECTION_EXCEPTION_HANDLER_END
626 #undef CHECK_WIDGET_EXISTENCE
627
628 } // namespace WrtDB