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 view_logic_security_origin_support.cpp
18 * @author Jihoon Chung (jihoon.chung@samsung.com)
20 * @brief Support security origin dao
23 #include "view_logic_security_origin_support.h"
27 #include <Elementary.h>
28 #include <dpl/log/log.h>
29 #include <dpl/assert.h>
30 #include <dpl/wrt-dao-ro/common_dao_types.h>
31 #include <wrt-commons/security-origin-dao/security_origin_dao.h>
32 #include <widget_model.h>
33 #include <widget_string.h>
34 #include <common/view_logic_get_parent_window_util.h>
36 namespace ViewModule {
38 class SecurityOriginSupportImplementation
42 SecurityOriginDB::SecurityOriginDAOPtr m_securityOriginDAO;
45 SecurityOriginSupportImplementation(WidgetModel* widgetModel) :
49 m_model = widgetModel;
52 ~SecurityOriginSupportImplementation()
55 SecurityOriginDB::SecurityOriginDAO* getSecurityOriginDAO(void)
58 if (!m_securityOriginDAO) {
59 LogDebug("initialize securityOriginDAO");
61 SecurityOriginDB::SecurityOriginDAOPtr(
62 new SecurityOriginDB::SecurityOriginDAO(m_model->TzPkgId.
64 // initialize security result data. Remove allow, deny for
65 m_securityOriginDAO->removeSecurityOriginData(
66 SecurityOriginDB::RESULT_ALLOW_ONCE);
67 m_securityOriginDAO->removeSecurityOriginData(
68 SecurityOriginDB::RESULT_DENY_ONCE);
70 return m_securityOriginDAO.get();
74 SecurityOriginSupport::SecurityOriginSupport(WidgetModel* widgetModel) :
75 m_impl(new SecurityOriginSupportImplementation(widgetModel))
78 SecurityOriginSupport::~SecurityOriginSupport()
81 SecurityOriginDB::SecurityOriginDAO* SecurityOriginSupport::
82 getSecurityOriginDAO(void)
84 return m_impl->getSecurityOriginDAO();
87 Evas_Object* SecurityOriginSupportUtil::createPopup(
90 const char* checkText,
95 LogDebug("createPopup");
96 Evas_Object* parentWindow = PopupUtil::getParentWindow(window);
97 Evas_Object* popup = elm_popup_add(parentWindow);
98 elm_object_style_set(popup, "popup/default");
99 evas_object_size_hint_weight_set(popup,
103 Evas_Object* layout = elm_layout_add(popup);
104 elm_layout_file_set(layout, WRT_EDJ_PATH, "popupWithCheck");
105 evas_object_size_hint_weight_set(layout,
109 Evas_Object* scroller = elm_scroller_add(layout);
110 elm_scroller_policy_set(scroller,
111 ELM_SCROLLER_POLICY_OFF,
112 ELM_SCROLLER_POLICY_AUTO);
114 Evas_Object* label = elm_label_add(scroller);
115 elm_label_line_wrap_set(label, ELM_WRAP_WORD);
116 elm_object_text_set(label, bodyText);
118 Evas_Object* check = elm_check_add(scroller);
119 elm_object_part_text_set(layout, "elm.text", checkText);
120 elm_object_part_content_set(layout, "elm.swallow.checkbox", check);
122 elm_object_content_set(scroller, label);
123 elm_object_part_content_set(layout, "elm.swallow.label", scroller);
124 elm_object_content_set(popup, layout);
126 Evas_Object* btn1 = elm_button_add(popup);
127 elm_object_text_set(btn1, WRT_SK_YES);
128 elm_object_part_content_set(popup, "button1", btn1);
129 evas_object_smart_callback_add(btn1, "clicked", buttonCallback, data);
130 Evas_Object* btn2 = elm_button_add(popup);
131 elm_object_text_set(btn2, WRT_SK_NO);
132 elm_object_part_content_set(popup, "button2", btn2);
133 evas_object_smart_callback_add(btn2, "clicked", buttonCallback, data);
137 Evas_Object* SecurityOriginSupportUtil::getPopup(Evas_Object* button)
141 Evas_Object* popup = button;
142 while (strcmp(elm_object_widget_type_get(popup), "elm_popup")) {
143 popup = elm_object_parent_widget_get(popup);
151 Evas_Object* SecurityOriginSupportUtil::getCheck(Evas_Object* popup)
154 if (strcmp(elm_object_widget_type_get(popup), "elm_popup")) {
157 Evas_Object* check = elm_object_part_content_get(
158 elm_object_content_get(popup),
159 "elm.swallow.checkbox");
163 SecurityOriginDB::Result SecurityOriginSupportUtil::getResult(
166 using namespace SecurityOriginDB;
169 // get popup evas_object
170 Evas_Object* popup = getPopup(button);
172 return RESULT_UNKNOWN;
174 bool allow = !strcmp(WRT_SK_YES, elm_object_text_get(button));
176 // get check evas_object
177 Evas_Object* check = getCheck(popup);
179 return RESULT_UNKNOWN;
182 return elm_check_state_get(check) ? RESULT_ALLOW_ALWAYS :
185 return elm_check_state_get(check) ? RESULT_DENY_ALWAYS :
189 } // namespace ViewModule