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,
43 template <typename RetType, RetType(*extFun) (DPL::String)>
44 struct BindToWidgetDAOStatic :
45 DPL::Event::BindToDAO_Static<WidgetModel,
48 &WidgetModel::getTizenId,
52 WidgetModel::WidgetModel(const std::string &tizenId) :
53 TizenId(DPL::FromASCIIString(tizenId)),
54 TzPkgId(this, &BindToWidgetDAO<WrtDB::TizenPkgId,
55 &WidgetDAOReadOnly::getTizenPkgId>::Get),
56 Type(this, &BindToWidgetDAO<WidgetType,
57 &WidgetDAOReadOnly::getWidgetType>::Get),
58 CspPolicy(this, &BindToWidgetDAO<DPL::OptionalString,
59 &WidgetDAOReadOnly::getCspPolicy>::Get),
60 CspReportOnlyPolicy(this, &BindToWidgetDAO<DPL::OptionalString,
61 &WidgetDAOReadOnly::getCspPolicyReportOnly>::Get),
64 &BindToWidgetDAO<WidgetSize,
65 &WidgetDAOReadOnly::getPreferredSize>::Get),
67 //localized, so not binded
69 #ifdef APP_SCHEME_ENABLED
70 PrefixURL(this, DPL::String(L"app://") + DPL::FromASCIIString(tizenId) + L"/"),
72 //localized, so not binded
73 // file:// + / : without "/" path, webkit return security error
74 PrefixURL(this, L"file:///"),
78 &BindToWidgetDAO<DPL::String, &WidgetDAOReadOnly::getFullPath>::Get),
79 PersistentStoragePath(this,
81 WidgetConfig::GetWidgetPersistentStoragePath(
84 // use of multiple widget model
85 TemporaryStoragePath(this,
87 WidgetConfig::GetWidgetTemporaryStoragePath(
88 this->TizenId + getTimestamp()))
92 &BindToWidgetDAO<DPL::OptionalString,
93 &WidgetDAOReadOnly::getDefaultlocale>::Get),
95 //localized, so not binded
97 //localized, so not binded
99 //localized, so not binded
101 //localized, so not binded
103 //localized, so not binded
107 &BindToWidgetDAO<DPL::OptionalString,
108 &WidgetDAOReadOnly::getSplashImgSrc>::Get),
111 &BindToWidgetDAO<WindowModeList,
112 &WidgetDAOReadOnly::getWindowModes>::Get),
113 //localized, so not binded
114 // AccessNetwork(this, false),
115 // WarpDefinitionEmpty(this),
118 //TODO this type has to be here now, as Property constructor is wrongly
120 (DPL::Event::Property<bool,
121 DPL::Event::PropertyReadOnly,
122 DPL::Event::PropertyStorageDynamicCached>::
124 BindToWidgetDAO<bool, &WidgetDAOReadOnly::getBackSupported>::Get),
128 //TODO this type has to be here now, as Property constructor is wrongly
130 (DPL::Event::Property<bool,
131 DPL::Event::PropertyReadOnly,
132 DPL::Event::PropertyStorageDynamicCached>::
134 BindToWidgetDAO<bool, &WidgetDAOReadOnly::isTestWidget>::Get),
137 AppControlList(this),
138 AppControlIndex(this),
139 SecurityModelVersion(this,
140 &BindToWidgetDAO<WidgetSecurityModelVersion,
141 &WidgetDAOReadOnly::getSecurityModelVersion>::Get)
144 DPL::String WidgetModel::getTizenId() const
149 DPL::String WidgetModel::getTimestamp()
154 gettimeofday(&tv, NULL);
155 sprintf(buff, "%lf", (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0f);
156 LogInfo("timestamp: " << buff);
157 DPL::String timeString = DPL::FromUTF8String(std::string(buff));