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 * @file widget_deserialize_model.h
18 * @author Piotr Marcinkiewicz (p.marcinkiew@samsung.com)
20 * @brief Widget deserialization creates WidgetModel from WidgetDAOReadOnly
23 #include "widget_localize_model.h"
24 #include "widget_model.h"
26 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
27 #include <dpl/log/log.h>
31 std::shared_ptr<WidgetModel> deserializeWidgetModel(const std::string& tizenId)
33 std::shared_ptr<WidgetModel> model;
34 DPL::String dplTizenId(DPL::FromUTF8String(tizenId));
35 if (WrtDB::WidgetDAOReadOnly::isWidgetInstalled(dplTizenId)) {
36 LogDebug("Widget installed - creating model");
37 model.reset(new WidgetModel(tizenId));
40 WrtDB::WidgetDAOReadOnly dao(
41 WrtDB::WidgetDAOReadOnly::getHandle(dplTizenId));
44 Domain::localizeWidgetModel(model->defaultlocale.Get());
46 WrtDB::WidgetAccessInfoList widgetAccessInfoList;
47 // widgetAccessInfoList is output parameter
48 dao.getWidgetAccessInfo(widgetAccessInfoList);
49 model->AccessList.Set(widgetAccessInfoList);
51 // Widget application service information data
52 WidgetApplicationServiceList widgetApplicationServiceList;
53 // widgetApplicationServiceList is output parameter
54 dao.getAppServiceList(widgetApplicationServiceList);
55 model->AppServiceList.Set(widgetApplicationServiceList);
57 // Set Widget Settings
58 WidgetSettings widgetSettings;
59 dao.getWidgetSettings(widgetSettings);
60 model->SettingList.Set(widgetSettings);
62 LogError("Widget is not installed - model not created");