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
30 #include <widget_data_types.h>
32 #include <dpl/foreach.h>
34 WidgetAccessList::WidgetAccessList() : m_isAccessAll(false)
37 WidgetAccessList::WidgetAccessList(
38 const WrtDB::WidgetAccessInfoList &widgetAccessInfoList) :
41 FOREACH(it, widgetAccessInfoList)
43 if (DPL::FromUTF32String(L"*") == it->strIRI) {
45 m_warpIriList.clear();
51 warpIri.set(DPL::ToUTF8String(it->strIRI).c_str(),
54 if (warpIri.isAccessDefinition()) {
55 m_warpIriList.push_back(warpIri);
60 bool WidgetAccessList::getIsAccessAll() const
65 const WarpIRIList* WidgetAccessList::getWarpIRIList() const
67 return &m_warpIriList;
70 bool WidgetAccessList::isRequiredIRI(const DPL::String &iri) const
77 requestIri.set(iri.c_str(), false);
79 FOREACH(it, m_warpIriList)
81 if (it->isSubDomain(requestIri)) {
89 bool WidgetAccessList::operator ==(const WidgetAccessList& other) const
91 return m_warpIriList == other.m_warpIriList &&
92 m_isAccessAll == other.m_isAccessAll;
95 WidgetSettingList::WidgetSettingList() :
96 m_RotationLock(Screen_Portrait),
97 m_IndicatorPresence(Indicator_Enable),
98 m_BackButtonPresence(BackButton_Disable),
99 m_ContextMenu(ContextMenu_Enable),
100 m_Encryption(Encryption_Disable),
101 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)
146 m_BackButtonPresence = BackButton_Disable;
148 LogError("Invalid backbutton presence value!! [" <<
150 m_BackButtonPresence = BackButton_Disable;
152 } else if (name == SETTING_NAME_CONTEXT_MENU)
154 if (value == SETTING_VALUE_ENABLE) {
155 m_ContextMenu = ContextMenu_Enable;
156 } else if (value == SETTING_VALUE_DISABLE) {
157 m_ContextMenu = ContextMenu_Disable;
159 LogError("Invalid contextmenu value!! [" <<
161 m_ContextMenu = ContextMenu_Enable;
163 } else if (name == SETTING_NAME_ENCRYPTION) {
164 if (value == SETTING_VALUE_ENCRYPTION_ENABLE) {
165 m_Encryption = Encryption_Enable;
167 SETTING_VALUE_ENCRYPTION_DISABLE)
169 m_Encryption = Encryption_Disable;
171 LogError("Invalid encryption value!! [" <<
173 m_Encryption = Encryption_Disable;
175 } else if (name == SETTING_NAME_BACKGROUND_SUPPORT) {
176 if (value == SETTING_VALUE_ENABLE) {
177 m_BackgroundSupport = BackgroundSupport_Enable;
178 } else if (value == SETTING_VALUE_DISABLE) {
179 m_BackgroundSupport = BackgroundSupport_Disable;
181 LogError("Invalid background-support value!! [" <<
183 m_BackgroundSupport = BackgroundSupport_Disable;
185 } else if (name == SETTING_NAME_USER_AGENT) {
186 DPL::OptionalString userAgent = value;
187 if (!userAgent.IsNull()) {
188 m_UserAgent = DPL::ToUTF8String(*userAgent);
191 LogError("Invalid setting name!! [" << name << "]");
194 LogDebug("m_RotationLock: " << m_RotationLock);
195 LogDebug("m_IndicatorPresence: " << m_IndicatorPresence);
196 LogDebug("m_BackButtonPresence: " << m_BackButtonPresence);
197 LogDebug("m_ContextMenu: " << m_ContextMenu);
198 LogDebug("m_Encryption: " << m_Encryption);
199 LogDebug("m_BackgroundSupport: " << m_BackgroundSupport);
202 WidgetSettingScreenLock WidgetSettingList::getRotationValue() const
204 return m_RotationLock;
207 WidgetSettingIndicatorPresence WidgetSettingList::getIndicatorPresence() const
209 return m_IndicatorPresence;
212 WidgetSettingBackButtonPresence WidgetSettingList::getBackButtonPresence()
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;