2 * Copyright (c) 2012 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 * This file have been implemented in compliance with W3C WARP SPEC.
18 * but there are some patent issue between W3C WARP SPEC and APPLE.
19 * so if you want to use this file, refer to the README file in root directory
22 * @file widget_data_types.cpp
23 * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
24 * @author Tomasz Iwanek (t.iwanek@samsung.com) (implementation moved to cpp)
29 #include <widget_data_types.h>
31 #include <dpl/foreach.h>
33 WidgetAccessList::WidgetAccessList() : m_isAccessAll(false)
37 WidgetAccessList::WidgetAccessList(const WrtDB::WidgetAccessInfoList &widgetAccessInfoList) :
40 FOREACH(it, widgetAccessInfoList)
42 if (DPL::FromUTF32String(L"*") == it->strIRI) {
44 m_warpIriList.clear();
50 warpIri.set(DPL::ToUTF8String(it->strIRI).c_str(),
53 if (warpIri.isAccessDefinition()) {
54 m_warpIriList.push_back(warpIri);
59 bool WidgetAccessList::getIsAccessAll() const
64 const WarpIRIList* WidgetAccessList::getWarpIRIList() const
66 return &m_warpIriList;
69 bool WidgetAccessList::isRequiredIRI(const DPL::String &iri) const
76 requestIri.set(iri.c_str(), false);
78 FOREACH(it, m_warpIriList)
80 if (it->isSubDomain(requestIri)) {
88 bool WidgetAccessList::operator ==(const WidgetAccessList& other) const
90 return m_warpIriList == other.m_warpIriList &&
91 m_isAccessAll == other.m_isAccessAll;
94 WidgetSettingList::WidgetSettingList() :
95 m_RotationLock(Screen_Portrait),
96 m_IndicatorPresence(Indicator_Enable),
97 m_BackButtonPresence(BackButton_Disable),
98 m_ContextMenu(ContextMenu_Enable),
99 m_Encryption(Encryption_Disable),
100 m_BackgroundSupport(BackgroundSupport_Disable)
104 WidgetSettingList::WidgetSettingList(WidgetSettings &widgetSettings)
106 m_RotationLock = Screen_Portrait;
107 m_IndicatorPresence = Indicator_Enable;
108 m_BackButtonPresence = BackButton_Disable;
109 m_ContextMenu = ContextMenu_Enable;
110 m_Encryption = Encryption_Disable;
111 m_BackgroundSupport = BackgroundSupport_Disable;
113 FOREACH(it, widgetSettings)
115 DPL::String name = it->settingName;
116 DPL::String value = it->settingValue;
118 if (name == SETTING_NAME_SCREEN_ORIENTATION) {
119 if (value == SETTING_VALUE_SCREEN_ORIENTATION_PORTRAIT) {
120 m_RotationLock = Screen_Portrait;
122 SETTING_VALUE_SCREEN_ORIENTATION_LANDSCAPE)
124 m_RotationLock = Screen_Landscape;
126 LogError("Invalid screen orientation value!! [" <<
128 m_RotationLock = Screen_Portrait;
130 } else if (name == SETTING_NAME_INDICATOR_PRESENCE) {
131 if (value == SETTING_VALUE_INDICATOR_PRESENCE_ENALBE) {
132 m_IndicatorPresence = Indicator_Enable;
133 } else if (value == SETTING_VALUE_INDICATOR_PRESENCE_DISABLE) {
134 m_IndicatorPresence = Indicator_Disable;
136 LogError("Invalid indicator presence value!! [" <<
138 m_IndicatorPresence = Indicator_Enable;
140 } else if (name == SETTING_NAME_BACKBUTTON_PRESENCE) {
141 if (value == SETTING_VALUE_BACKBUTTON_PRESENCE_ENALBE) {
142 m_BackButtonPresence = BackButton_Enable;
144 SETTING_VALUE_BACKBUTTON_PRESENCE_DISABLE) {
145 m_BackButtonPresence = BackButton_Disable;
147 LogError("Invalid backbutton presence value!! [" <<
149 m_BackButtonPresence = BackButton_Disable;
151 } else if ( name == SETTING_NAME_CONTEXT_MENU
152 #ifndef DEPRECATED_SETTING_STRING
153 || name == SETTING_NAME_CONTEXTMENU
156 if (value == SETTING_VALUE_ENABLE) {
157 m_ContextMenu = ContextMenu_Enable;
158 } else if (value == SETTING_VALUE_DISABLE) {
159 m_ContextMenu = ContextMenu_Disable;
161 LogError("Invalid contextmenu value!! [" <<
163 m_ContextMenu = ContextMenu_Enable;
165 } else if (name == SETTING_NAME_ENCRYPTION) {
166 if (value == SETTING_VALUE_ENCRYPTION_ENABLE) {
167 m_Encryption = Encryption_Enable;
169 SETTING_VALUE_ENCRYPTION_DISABLE) {
170 m_Encryption = Encryption_Disable;
172 LogError("Invalid encryption value!! [" <<
174 m_Encryption = Encryption_Disable;
176 } else if (name == SETTING_NAME_BACKGROUND_SUPPORT) {
177 if (value == SETTING_VALUE_ENABLE) {
178 m_BackgroundSupport = BackgroundSupport_Enable;
179 } else if (value == SETTING_VALUE_DISABLE) {
180 m_BackgroundSupport = BackgroundSupport_Disable;
182 LogError("Invalid background-support value!! [" <<
184 m_BackgroundSupport = BackgroundSupport_Disable;
186 } else if (name == SETTING_NAME_USER_AGENT) {
187 DPL::OptionalString userAgent = value;
188 if (!userAgent.IsNull()) {
189 m_UserAgent = DPL::ToUTF8String(*userAgent);
192 LogError("Invalid setting name!! [" << name << "]");
195 LogDebug("m_RotationLock: " << m_RotationLock);
196 LogDebug("m_IndicatorPresence: " << m_IndicatorPresence);
197 LogDebug("m_BackButtonPresence: " << m_BackButtonPresence);
198 LogDebug("m_ContextMenu: " << m_ContextMenu);
199 LogDebug("m_Encryption: " << m_Encryption);
200 LogDebug("m_BackgroundSupport: " << m_BackgroundSupport);
203 WidgetSettingScreenLock WidgetSettingList::getRotationValue() const
205 return m_RotationLock;
208 WidgetSettingIndicatorPresence WidgetSettingList::getIndicatorPresence() const
210 return m_IndicatorPresence;
213 WidgetSettingBackButtonPresence WidgetSettingList::getBackButtonPresence() const
215 return m_BackButtonPresence;
218 WidgetSettingContextMenu WidgetSettingList::getContextMenu() const
220 return m_ContextMenu;
223 WidgetSettingEncryption WidgetSettingList::getEncryption() const
228 WidgetSettingBackgroundSupport WidgetSettingList::getBackgroundSupport() const
230 return m_BackgroundSupport;
233 bool WidgetSettingList::isEncrypted() const
235 if (m_Encryption == Encryption_Enable) {
241 std::string WidgetSettingList::getUserAgent() const
246 bool WidgetSettingList::operator ==(const WidgetSettingList& other) const
248 return m_RotationLock == other.m_RotationLock &&
249 m_IndicatorPresence == other.m_IndicatorPresence &&
250 m_BackButtonPresence == other.m_BackButtonPresence &&
251 m_ContextMenu == other.m_ContextMenu &&
252 m_Encryption == other.m_Encryption &&
253 m_BackgroundSupport == other.m_BackgroundSupport &&
254 m_UserAgent == other.m_UserAgent;