Update wrt-commons_0.2.67
[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_factory_widget(regInfo.isFactoryWidget);
203     row.Set_test_widget(regInfo.isTestWidget);
204     row.Set_install_time(regInfo.installedTime);
205     row.Set_splash_img_src(regInfo.configInfo.splashImgSrc);
206     row.Set_background_page(regInfo.configInfo.backgroundPage);
207
208
209     DO_INSERT(row, WidgetExtendedInfo)
210 }
211
212 void WidgetDAO::registerWidgetInfo(
213         const DbWidgetHandle& widgetHandle,
214         const WidgetRegisterInfo &regInfo,
215         const IWacSecurity &wacSecurity)
216 {
217     using namespace DPL::DB::ORM;
218     using namespace DPL::DB::ORM::wrt;
219     const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
220
221     // TODO in wrt_db all Columns in WidgetInfo have DEFAULT VALUE set.
222     // Because of that, "Optional" is not used there
223
224     WidgetInfo::Row row;
225     row.Set_app_id(widgetHandle);
226     row.Set_widget_type(regInfo.type.appType);
227     row.Set_widget_id(widgetConfigurationInfo.widget_id);
228     row.Set_defaultlocale(widgetConfigurationInfo.defaultlocale);
229     row.Set_widget_version(widgetConfigurationInfo.version);
230     row.Set_widget_width(widgetConfigurationInfo.width);
231     row.Set_widget_height(widgetConfigurationInfo.height);
232     row.Set_author_name(widgetConfigurationInfo.authorName);
233     row.Set_author_email(widgetConfigurationInfo.authorEmail);
234     row.Set_author_href(widgetConfigurationInfo.authorHref);
235     row.Set_base_folder(DPL::FromUTF8String(regInfo.baseFolder));
236     row.Set_webkit_plugins_required(widgetConfigurationInfo.flashNeeded);
237     row.Set_recognized(wacSecurity.isRecognized());
238     row.Set_wac_signed(wacSecurity.isWacSigned());
239     row.Set_distributor_signed(wacSecurity.isDistributorSigned());
240     {
241         std::stringstream tmp;
242         tmp << regInfo.minVersion;
243         row.Set_min_version(DPL::FromUTF8String(tmp.str()));
244     }
245     row.Set_back_supported(widgetConfigurationInfo.backSupported);
246     row.Set_access_network(widgetConfigurationInfo.accessNetwork);
247     row.Set_pkgname(regInfo.pkgname);
248     row.Set_pkg_type(regInfo.pType.pkgType);
249
250     Try
251     {
252         DO_INSERT(row, WidgetInfo);
253     }
254     Catch(DPL::DB::SqlConnection::Exception::Base)
255     {
256         ReThrowMsg(WidgetDAO::Exception::DatabaseError,
257                    "Failed to register widget info.");
258     }
259 }
260
261 void WidgetDAO::registerWidgetLocalizedInfo(DbWidgetHandle widgetHandle,
262         const WidgetRegisterInfo &regInfo)
263 {
264     using namespace DPL::DB::ORM;
265     using namespace DPL::DB::ORM::wrt;
266
267     const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
268
269     FOREACH(it, widgetConfigurationInfo.localizedDataSet)
270     {
271         const DPL::String& locale = it->first;
272         const ConfigParserData::LocalizedData& data = it->second;
273
274         LocalizedWidgetInfo::Row row;
275         row.Set_app_id(widgetHandle);
276         row.Set_widget_locale(locale);
277         row.Set_widget_name(data.name);
278         row.Set_widget_shortname(data.shortName);
279         row.Set_widget_description(data.description);
280         row.Set_widget_license(data.license);
281         row.Set_widget_license_file(data.licenseFile);
282         row.Set_widget_license_href(data.licenseHref);
283
284         DO_INSERT(row, LocalizedWidgetInfo)
285     }
286 }
287
288 void WidgetDAO::registerWidgetIcons(DbWidgetHandle widgetHandle,
289         const WidgetRegisterInfo &regInfo)
290 {
291     using namespace DPL::DB::ORM;
292     using namespace DPL::DB::ORM::wrt;
293
294
295     FOREACH(i, regInfo.localizationData.icons)
296     {
297         wrt::WidgetIcon::icon_id::ColumnType icon_id;
298         {
299             wrt::WidgetIcon::Row row;
300             row.Set_app_id(widgetHandle);
301             row.Set_icon_src(i->src);
302             row.Set_icon_width(i->width);
303             row.Set_icon_height(i->height);
304
305             WRT_DB_INSERT(insert, wrt::WidgetIcon, &WrtDatabase::interface())
306             insert->Values(row);
307             icon_id = insert->Execute();
308         }
309
310         FOREACH(j, i->availableLocales)
311         {
312             WidgetLocalizedIcon::Row row;
313             row.Set_app_id(widgetHandle);
314             row.Set_icon_id(icon_id);
315             row.Set_widget_locale(*j);
316             WRT_DB_SELECT(select, WidgetLocalizedIcon, &WrtDatabase::interface())
317             select->Where(And(Equals<WidgetLocalizedIcon::app_id>(widgetHandle),
318                               Equals<WidgetLocalizedIcon::widget_locale>(*j)));
319             WidgetLocalizedIcon::Select::RowList rows = select->GetRowList();
320
321             bool flag = !rows.empty();
322
323             if(flag == true)
324             {
325                 // already default icon value of same locale exists
326                 WRT_DB_UPDATE(update, WidgetLocalizedIcon, &WrtDatabase::interface())
327                 update->Where(And(Equals<WidgetLocalizedIcon::app_id>(widgetHandle),
328                                   Equals<WidgetLocalizedIcon::widget_locale>(*j)));
329                 update->Values(row);
330                 update->Execute();
331             }else{
332                 // any icon value of same locale doesn't exist
333                 DO_INSERT(row, WidgetLocalizedIcon)
334             }
335         }
336     }
337 }
338
339 void WidgetDAO::registerWidgetStartFile(DbWidgetHandle widgetHandle,
340         const WidgetRegisterInfo &regInfo)
341 {
342     using namespace DPL::DB::ORM;
343     using namespace DPL::DB::ORM::wrt;
344
345
346     FOREACH(i, regInfo.localizationData.startFiles)
347     {
348         WidgetStartFile::start_file_id::ColumnType startFileID;
349         {
350             WidgetStartFile::Row row;
351             row.Set_app_id(widgetHandle);
352             row.Set_src(i->path);
353
354             WRT_DB_INSERT(insert, WidgetStartFile, &WrtDatabase::interface())
355             insert->Values(row);
356             startFileID = insert->Execute();
357         }
358
359         FOREACH(j, i->propertiesForLocales)
360         {
361             WidgetLocalizedStartFile::Row row;
362             row.Set_app_id(widgetHandle);
363             row.Set_start_file_id(startFileID);
364             row.Set_widget_locale(j->first);
365             row.Set_type(j->second.type);
366             row.Set_encoding(j->second.encoding);
367
368             DO_INSERT(row, WidgetLocalizedStartFile)
369         }
370     }
371 }
372
373 void WidgetDAO::registerWidgetFeatures(DbWidgetHandle widgetHandle,
374         const WidgetRegisterInfo &regInfo)
375 {
376     using namespace DPL::DB::ORM;
377     const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
378
379
380     FOREACH(pWidgetFeature, widgetConfigurationInfo.featuresList)
381     {
382         wrt::WidgetFeature::Row widgetFeature;
383         widgetFeature.Set_app_id(widgetHandle);
384         widgetFeature.Set_name(pWidgetFeature->name);
385         widgetFeature.Set_required(pWidgetFeature->required);
386         widgetFeature.Set_rejected(false);
387
388         wrt::WidgetFeature::widget_feature_id::ColumnType widgetFeatureID;
389         {
390             WRT_DB_INSERT(insert, wrt::WidgetFeature, &WrtDatabase::interface())
391             insert->Values(widgetFeature);
392             widgetFeatureID = insert->Execute();
393         }
394
395         // Insert into table FeatureParam
396         wrt::FeatureParam::Row featureParam;
397         featureParam.Set_widget_feature_id(widgetFeatureID);
398
399         ConfigParserData::ParamsList::const_iterator iter;
400
401         FOREACH(iter, pWidgetFeature->paramsList)
402         {
403             featureParam.Set_name(iter->name);
404             featureParam.Set_value(iter->value);
405
406             DO_INSERT(featureParam, wrt::FeatureParam)
407         }
408     }
409 }
410
411 void WidgetDAO::updateFeatureRejectStatus(const DbWidgetFeature &widgetFeature){
412     // This function could be merged with registerWidgetFeature but it requires desing change:
413     // 1. Check "ace step" in installer must be done before "update database step"
414     // And:
415     // ConfigurationParserData shouldn't be called "ParserData" any more.
416     using namespace DPL::DB::ORM;
417
418     wrt::ScopedTransaction transaction(&WrtDatabase::interface());
419     WRT_DB_SELECT(select, wrt::WidgetFeature, &WrtDatabase::interface())
420     select->Where(And(Equals<wrt::WidgetFeature::app_id>(m_widgetHandle),
421                       Equals<wrt::WidgetFeature::name>(widgetFeature.name)));
422
423     auto row = select->GetSingleRow();
424     row.Set_rejected(widgetFeature.rejected);
425
426     WRT_DB_UPDATE(update, wrt::WidgetFeature, &WrtDatabase::interface())
427     update->Where(And(Equals<wrt::WidgetFeature::app_id>(m_widgetHandle),
428                       Equals<wrt::WidgetFeature::name>(widgetFeature.name)));
429     update->Values(row);
430     update->Execute();
431     transaction.Commit();
432 }
433
434 void WidgetDAO::registerWidgetWindowModes(DbWidgetHandle widgetHandle,
435         const WidgetRegisterInfo &regInfo)
436 {
437     using namespace DPL::DB::ORM;
438     using namespace DPL::DB::ORM::wrt;
439     const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
440
441
442     FOREACH(i, widgetConfigurationInfo.windowModes)
443     {
444         wrt::WidgetWindowModes::Row windowMode;
445         windowMode.Set_app_id(widgetHandle);
446         windowMode.Set_window_mode(*i);
447
448         DO_INSERT(windowMode, wrt::WidgetWindowModes)
449     }
450 }
451
452 void WidgetDAO::registerWidgetWarpInfo(DbWidgetHandle widgetHandle,
453         const WidgetRegisterInfo &regInfo)
454 {
455     using namespace DPL::DB::ORM;
456     using namespace DPL::DB::ORM::wrt;
457     const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
458
459
460     FOREACH(AccIt, widgetConfigurationInfo.accessInfoSet)
461     {
462         WidgetWARPInfo::Row row;
463         row.Set_app_id(widgetHandle);
464         row.Set_iri(AccIt->m_strIRI);
465         row.Set_subdomain_access(static_cast <int>(
466                                      AccIt->m_bSubDomainAccess));
467
468         DO_INSERT(row, WidgetWARPInfo)
469     }
470 }
471
472 void WidgetDAO::registerWidgetCertificates(DbWidgetHandle widgetHandle,
473         const IWacSecurity &wacSecurity)
474 {
475     using namespace DPL::DB::ORM;
476     using namespace DPL::DB::ORM::wrt;
477
478
479     FOREACH(it, wacSecurity.getCertificateList())
480     {
481         WidgetCertificateFingerprint::Row row;
482         row.Set_app_id(widgetHandle);
483         row.Set_owner(it->owner);
484         row.Set_chainid(it->chainId);
485         row.Set_type(it->type);
486         row.Set_md5_fingerprint(DPL::FromUTF8String(it->strMD5Fingerprint));
487         row.Set_sha1_fingerprint(DPL::FromUTF8String(it->strSHA1Fingerprint));
488         row.Set_common_name(it->strCommonName);
489
490         DO_INSERT(row, WidgetCertificateFingerprint)
491     }
492 }
493
494 void WidgetDAO::registerCertificatesChains(DbWidgetHandle widgetHandle,
495         CertificateSource certificateSource,
496         const CertificateChainList &certificateChainList)
497 {
498     using namespace DPL::DB::ORM;
499     using namespace DPL::DB::ORM::wrt;
500     FOREACH(certChain, certificateChainList)
501     {
502         WidgetCertificate::Row row;
503         row.Set_app_id(widgetHandle);
504         row.Set_cert_source(certificateSource);
505         row.Set_encoded_chain(DPL::FromASCIIString(*certChain));
506
507         DO_INSERT(row, WidgetCertificate);
508     }
509 }
510
511 void WidgetDAO::registerWidgetSettings(DbWidgetHandle widgetHandle,
512         const WidgetRegisterInfo &regInfo)
513 {
514     using namespace DPL::DB::ORM;
515     using namespace DPL::DB::ORM::wrt;
516
517     const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
518
519     FOREACH(pWidgetSetting, widgetConfigurationInfo.settingsList)
520     {
521         SettginsList::Row row;
522         row.Set_appId(widgetHandle);
523         row.Set_settingName(pWidgetSetting->m_name);
524         row.Set_settingValue(pWidgetSetting->m_value);
525
526         DO_INSERT(row, SettginsList)
527     }
528 }
529
530 void WidgetDAO::registerAppService(DbWidgetHandle widgetHandle,
531                                    const WidgetRegisterInfo &regInfo)
532 {
533     using namespace DPL::DB::ORM;
534     using namespace DPL::DB::ORM::wrt;
535     const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
536
537     FOREACH(ASIt, widgetConfigurationInfo.appServiceList)
538     {
539         ApplicationServiceInfo::Row row;
540         row.Set_app_id(widgetHandle);
541         row.Set_src(ASIt->m_src);
542         row.Set_operation(ASIt->m_operation);
543         row.Set_scheme(ASIt->m_scheme);
544         row.Set_mime(ASIt->m_mime);
545
546         DO_INSERT(row, ApplicationServiceInfo)
547     }
548 }
549
550 void WidgetDAO::registerEncryptedResouceInfo(DbWidgetHandle widgetHandle,
551         const WidgetRegisterInfo &regInfo)
552 {
553     using namespace DPL::DB::ORM;
554     using namespace DPL::DB::ORM::wrt;
555
556     FOREACH(it, regInfo.encryptedFiles)
557     {
558         EncryptedResourceList::Row row;
559         row.Set_app_id(widgetHandle);
560         row.Set_resource(it->fileName);
561         row.Set_size(it->fileSize);
562
563         DO_INSERT(row, EncryptedResourceList)
564     }
565 }
566
567 void WidgetDAO::registerExternalLocations(const ExternalLocationList & externals)
568 {
569     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
570     {
571         using namespace DPL::DB::ORM;
572         using namespace DPL::DB::ORM::wrt;
573         DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
574         LogDebug("Inserting external files for widgetHandle: " << m_widgetHandle);
575         FOREACH(it, externals)
576         {
577             WidgetExternalLocations::Row row;
578             row.Set_app_id(m_widgetHandle);
579             row.Set_path(DPL::FromUTF8String(*it));
580
581             DO_INSERT(row, WidgetExternalLocations)
582         }
583         transaction.Commit();
584     }
585     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register external files");
586 }
587
588 void WidgetDAO::unregisterAllExternalLocations()
589 {
590     using namespace DPL::DB::ORM;
591     using namespace DPL::DB::ORM::wrt;
592     LogDebug("Deleting external files for widgetHandle: " << m_widgetHandle);
593     WRT_DB_DELETE(del, WidgetExternalLocations, &WrtDatabase::interface());
594     del->Where(Equals<WidgetExternalLocations::app_id>(m_widgetHandle));
595     del->Execute();
596 }
597
598 #undef DO_INSERT
599
600 void WidgetDAO::unregisterWidget(DbWidgetHandle widgetHandle)
601 {
602     LogDebug("Unregistering widget from DB. Handle: " << widgetHandle);
603     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
604     {
605         DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
606         using namespace DPL::DB::ORM;
607         using namespace DPL::DB::ORM::wrt;
608
609         CHECK_WIDGET_EXISTENCE(transaction, widgetHandle)
610
611         // Delete from table Widget Info
612         {
613             WRT_DB_DELETE(del, WidgetInfo, &WrtDatabase::interface())
614             del->Where(Equals<WidgetInfo::app_id>(widgetHandle));
615             del->Execute();
616         }
617
618         // Deleting in other tables is done via "delete cascade" in SQL
619
620         transaction.Commit();
621     }
622     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to unregister widget")
623 }
624
625 #undef SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
626 #undef SQL_CONNECTION_EXCEPTION_HANDLER_END
627 #undef CHECK_WIDGET_EXISTENCE
628
629 } // namespace WrtDB