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_model.cpp
18 * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
20 * @brief Implementation file for widget model
22 #include <widget_model.h>
23 #include <dpl/sstream.h>
24 #include <dpl/event/model_bind_to_dao.h>
25 #include <dpl/wrt-dao-ro/global_config.h>
26 #include <dpl/wrt-dao-ro/widget_config.h>
27 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
29 #include <dpl/utils/folder_size.h>
31 using namespace WrtDB;
33 template <typename RetType, RetType (WidgetDAOReadOnly::*extFun)() const >
34 struct BindToWidgetDAO :
35 DPL::Event::BindToDAO<WidgetModel,
39 &WidgetModel::getTizenId,
44 template <typename RetType, RetType(*extFun) (DPL::String)>
45 struct BindToWidgetDAOStatic :
46 DPL::Event::BindToDAO_Static<WidgetModel,
49 &WidgetModel::getTizenId,
54 WidgetModel::WidgetModel(const std::string &tizenId) :
55 TizenId(DPL::FromASCIIString(tizenId)),
56 TzPkgId(this, &BindToWidgetDAO<WrtDB::TizenPkgId,
57 &WidgetDAOReadOnly::getTizenPkgId>::Get),
58 Type(this, &BindToWidgetDAO<WidgetType,
59 &WidgetDAOReadOnly::getWidgetType>::Get),
62 &BindToWidgetDAO<WidgetSize,
63 &WidgetDAOReadOnly::getPreferredSize>::Get),
65 //localized, so not binded
67 //localized, so not binded
68 // file:// + / : without "/" path, webkit return security error
69 PrefixURL(this, L"file:///"),
72 &BindToWidgetDAO<DPL::String, &WidgetDAOReadOnly::getFullPath>::Get),
73 PersistentStoragePath(this,
75 WidgetConfig::GetWidgetPersistentStoragePath(
78 // use of multiple widget model
79 TemporaryStoragePath(this,
81 WidgetConfig::GetWidgetTemporaryStoragePath(
82 this->TizenId + getTimestamp()))
86 &BindToWidgetDAO<DPL::OptionalString,
87 &WidgetDAOReadOnly::getDefaultlocale>::Get),
89 //localized, so not binded
91 //localized, so not binded
93 //localized, so not binded
95 //localized, so not binded
97 //localized, so not binded
101 &BindToWidgetDAO<DPL::OptionalString,
102 &WidgetDAOReadOnly::getSplashImgSrc>::Get),
105 &BindToWidgetDAO<WindowModeList,
106 &WidgetDAOReadOnly::getWindowModes>::Get),
107 //localized, so not binded
108 // AccessNetwork(this, false),
109 // WarpDefinitionEmpty(this),
112 //TODO this type has to be here now, as Property constructor is wrongly
114 (DPL::Event::Property<bool,
115 DPL::Event::PropertyReadOnly,
116 DPL::Event::PropertyStorageDynamicCached>::ReadDelegateType) &
117 BindToWidgetDAO<bool, &WidgetDAOReadOnly::getBackSupported>::Get),
121 //TODO this type has to be here now, as Property constructor is wrongly
123 (DPL::Event::Property<bool,
124 DPL::Event::PropertyReadOnly,
125 DPL::Event::PropertyStorageDynamicCached>::ReadDelegateType) &
126 BindToWidgetDAO<bool, &WidgetDAOReadOnly::isTestWidget>::Get),
133 DPL::String WidgetModel::getTizenId() const
138 DPL::String WidgetModel::getTimestamp()
143 gettimeofday(&tv, NULL);
144 sprintf(buff, "%lf", (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0f);
145 LogInfo("timestamp: " << buff);
146 DPL::String timeString = DPL::FromUTF8String(std::string(buff));