Update wrt_0.8.85
[platform/framework/web/wrt.git] / src / domain / widget_deserialize_model.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  * @file    widget_deserialize_model.h
18  * @author  Piotr Marcinkiewicz (p.marcinkiew@samsung.com)
19  * @version 1.0
20  * @brief   Widget deserialization creates WidgetModel from WidgetDAOReadOnly
21  */
22
23 #include "widget_localize_model.h"
24
25 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
26 #include <dpl/log/log.h>
27
28 namespace Domain {
29
30 std::shared_ptr<WidgetModel> deserializeWidgetModel(WidgetHandle widgetHandle)
31 {
32     std::shared_ptr<WidgetModel> model;
33     if (WrtDB::WidgetDAOReadOnly::isWidgetInstalled(widgetHandle)) {
34         LogDebug("Widget installed - creating model");
35         model.reset(new WidgetModel(widgetHandle));
36
37         // Read DAO data
38         WrtDB::WidgetDAOReadOnly dao(widgetHandle);
39
40         // Set localized data
41         Domain::localizeWidgetModel(model);
42
43         WrtDB::WidgetAccessInfoList widgetAccessInfoList;
44         // widgetAccessInfoList is output parameter
45         dao.getWidgetAccessInfo(widgetAccessInfoList);
46         model->AccessList.Set(widgetAccessInfoList);
47
48         // Widget application service information data
49         WidgetApplicationServiceList widgetApplicationServiceList;
50         // widgetApplicationServiceList is output parameter
51         dao.getAppServiceList(widgetApplicationServiceList);
52         model->AppServiceList.Set(widgetApplicationServiceList);
53
54         // Set Widget Settings
55         WidgetSettings widgetSettings;
56         dao.getWidgetSettings(widgetSettings);
57         model->SettingList.Set(widgetSettings);
58     } else {
59         LogError("Widget is not installed - model not created");
60     }
61     return model;
62 }
63
64 } //Namespace Domain
65