[Release] wrt_0.8.225
[platform/framework/web/wrt.git] / src / domain / widget_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_model.cpp
18  * @author  Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
19  * @version 1.0
20  * @brief   Implementation file for widget model
21  */
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/widget_dao_read_only.h>
26
27 #include <dpl/utils/folder_size.h>
28
29 using namespace WrtDB;
30
31 template <typename RetType, RetType(WidgetDAOReadOnly::*extFun) () const >
32 struct BindToWidgetDAO :
33     DPL::Event::BindToDAO<WidgetModel,
34                           RetType,
35                           DPL::String,
36                           WidgetDAOReadOnly,
37                           &WidgetModel::getTizenId,
38                           extFun>
39 {};
40
41 template <typename RetType, RetType(*extFun) (DPL::String)>
42 struct BindToWidgetDAOStatic :
43     DPL::Event::BindToDAO_Static<WidgetModel,
44                                  RetType,
45                                  DPL::String,
46                                  &WidgetModel::getTizenId,
47                                  extFun>
48 {};
49
50 WidgetModel::WidgetModel(const std::string &tizenId) :
51     TizenId(DPL::FromASCIIString(tizenId)),
52     TzPkgId(this, &BindToWidgetDAO<WrtDB::TizenPkgId,
53                                    &WidgetDAOReadOnly::getTizenPkgId>::Get),
54     Type(this, &BindToWidgetDAO<WidgetType,
55                                 &WidgetDAOReadOnly::getWidgetType>::Get),
56     CspPolicy(this, &BindToWidgetDAO<DPL::OptionalString,
57                                      &WidgetDAOReadOnly::getCspPolicy>::Get),
58     CspReportOnlyPolicy(this, &BindToWidgetDAO<DPL::OptionalString,
59                         &WidgetDAOReadOnly::getCspPolicyReportOnly>::Get),
60     ActualSize(this),
61     PreferredSize(this,
62                   &BindToWidgetDAO<WidgetSize,
63                                    &WidgetDAOReadOnly::getPreferredSize>::Get),
64     StartURL(this),
65     //localized, so not binded
66     StartFileInfo(this),
67 #ifdef APP_SCHEME_ENABLED
68     PrefixURL(this, DPL::String(L"app://") + DPL::FromASCIIString(tizenId) + L"/"),
69 #else
70     //localized, so not binded
71     // file:// + / : without "/" path, webkit return security error
72     PrefixURL(this, L"file:///"),
73 #endif
74     InstallPath(
75         this,
76         &BindToWidgetDAO<DPL::String, &WidgetDAOReadOnly::getFullPath>::Get),
77     PersistentStoragePath(this),
78     TemporaryStoragePath(this),
79     defaultlocale(
80         this,
81         &BindToWidgetDAO<DPL::OptionalString,
82                          &WidgetDAOReadOnly::getDefaultlocale>::Get),
83     Name(this),
84     //localized, so not binded
85     ShortName(this),
86     //localized, so not binded
87     Description(this),
88     //localized, so not binded
89     License(this),
90     //localized, so not binded
91     LicenseHref(this),
92     //localized, so not binded
93     Icon(this),
94     SplashImg(
95         this,
96         &BindToWidgetDAO<DPL::OptionalString,
97                          &WidgetDAOReadOnly::getSplashImgSrc>::Get),
98     WindowModes(
99         this,
100         &BindToWidgetDAO<WindowModeList,
101                          &WidgetDAOReadOnly::getWindowModes>::Get),
102     //localized, so not binded
103     //    AccessNetwork(this, false),
104     //    WarpDefinitionEmpty(this),
105     BackSupported(
106         this,
107         //TODO this type has to be here now, as Property constructor is wrongly
108         //chosen
109         (DPL::Event::Property<bool,
110                               DPL::Event::PropertyReadOnly,
111                               DPL::Event::PropertyStorageDynamicCached>::
112              ReadDelegateType) &
113         BindToWidgetDAO<bool, &WidgetDAOReadOnly::getBackSupported>::Get),
114     AccessList(this),
115     SettingList(this),
116     AppControlList(this),
117     AppControlIndex(this),
118     SecurityModelVersion(this, &BindToWidgetDAO<WidgetSecurityModelVersion, &WidgetDAOReadOnly::getSecurityModelVersion>::Get),
119     SecurePopupUsage(this, &BindToWidgetDAO<SettingsType, &WidgetDAOReadOnly::getSecurityPopupUsage>::Get),
120     GeolocationUsage(this, &BindToWidgetDAO<SettingsType, &WidgetDAOReadOnly::getGeolocationUsage>::Get),
121     WebNotificationUsage(this, &BindToWidgetDAO<SettingsType, &WidgetDAOReadOnly::getWebNotificationUsage>::Get),
122     WebStorageUsage(this, &BindToWidgetDAO<SettingsType, &WidgetDAOReadOnly::getWebDatabaseUsage>::Get)
123 {}
124
125 DPL::String WidgetModel::getTizenId() const
126 {
127     return TizenId;
128 }