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_certificate_confirm_support.cpp
18 * @author Leerang Song (leerang.song@samsung.com)
21 #include "view_logic_certificate_confirm_support.h"
25 #include <dpl/log/log.h>
26 #include <dpl/assert.h>
27 #include <wrt-commons/certificate-dao/certificate_dao_types.h>
28 #include <wrt-commons/certificate-dao/certificate_dao.h>
30 #include <common/view_logic_certificate_support.h>
31 #include <Elementary.h>
32 #include <widget_string.h>
34 namespace ViewModule {
35 namespace CertificateConfirmSupport {
36 using namespace CertificateDB;
37 using namespace ViewModule::CertificateSupportUtil;
42 void askUserForCertificatePermission(
44 PermissionData* data);
45 static void popupCallback(void* data, Evas_Object* obj, void* eventInfo);
47 void askUserForCertificatePermission(
51 LogDebug("askUserForCertificatePermission called");
52 Ewk_Certificate_Policy_Decision* certificatePolicyDecision =
53 static_cast<Ewk_Certificate_Policy_Decision*>(data->m_data);
54 Assert(certificatePolicyDecision);
56 std::string msg = std::string(WRT_POP_CERTIFICATE_PERMISSION)
57 + " " + ewk_certificate_policy_decision_url_get(certificatePolicyDecision);
58 Evas_Object* popup = createPopup(window,
60 WRT_BODY_REMEMBER_PREFERENCE,
65 LogError("Fail to create popup object");
69 evas_object_show(popup);
73 void popupCallback(void* data, Evas_Object* obj, void* /*eventInfo*/)
75 LogDebug("popupCallback");
77 PermissionData* permData = static_cast<PermissionData*>(data);
78 Ewk_Certificate_Policy_Decision* certificatePolicyDecision =
79 static_cast<Ewk_Certificate_Policy_Decision*>(permData->m_data);
81 Evas_Object* popup = getPopup(obj);
82 Result result = getResult(obj);
84 if (result != RESULT_UNKNOWN) {
85 permData->m_certiDao->setCertificateData(permData->m_certiData,
89 (result == RESULT_ALLOW_ALWAYS || result == RESULT_ALLOW_ONCE) ?
90 EINA_TRUE : EINA_FALSE;
92 ewk_certificate_policy_decision_allowed_set(
93 certificatePolicyDecision,
96 evas_object_hide(popup);
97 evas_object_del(popup);
101 void certificatePermissionRequest(
103 CertificateDB::CertificateDAO* certificateDAO,
106 LogDebug("certificationPermissionRequest called");
107 Assert(certificateDAO);
110 Ewk_Certificate_Policy_Decision* certificatePolicyDecision =
111 static_cast<Ewk_Certificate_Policy_Decision*>(data);
112 ewk_certificate_policy_decision_suspend(certificatePolicyDecision);
113 Assert(certificatePolicyDecision);
115 CertificateData certificateData(
117 ewk_certificate_policy_decision_certificate_pem_get(
118 certificatePolicyDecision)));
120 // check cache database
121 Result result = certificateDAO->getResult(certificateData);
123 if (RESULT_ALLOW_ONCE == result || RESULT_ALLOW_ALWAYS == result) {
125 ewk_certificate_policy_decision_allowed_set(
126 certificatePolicyDecision,
129 } else if (RESULT_DENY_ONCE == result || RESULT_DENY_ALWAYS == result) {
131 ewk_certificate_policy_decision_allowed_set(
132 certificatePolicyDecision,
137 PermissionData* permissionData =
138 new PermissionData(certificateDAO,
140 certificatePolicyDecision);
141 askUserForCertificatePermission(window, permissionData);
145 } // namespace ViewModule